Bug 264272 - [WGSL] Error opening https://threejs.org/examples/?q=webgpu#webgpu_compute_texture_pingpong
Summary: [WGSL] Error opening https://threejs.org/examples/?q=webgpu#webgpu_compute_te...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebGPU (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Tadeu Zagallo
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-11-06 11:02 PST by Mike Wyrzykowski
Modified: 2023-11-07 09:15 PST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Wyrzykowski 2023-11-06 11:02:43 PST
[WGSL] Error opening https://threejs.org/examples/?q=webgpu#webgpu_compute_texture_pingpong

__wgslDiv is missing a definition opening 

Generated Metal code:
#include <metal_stdlib>
#include <metal_types>

using namespace metal;

struct __ArgumentBufferT_0 {
    texture2d<float, access::sample> global1 [[id(0)]];
    texture2d<float, access::write> global2 [[id(1)]];
};

vec<float, 4> function1(texture2d<float, access::sample> parameter1, vec<int, 2> parameter2)
{
    vec<float, 4> local0 = vec<float, 4>(0., 0., 0., 0.);
    local0 += parameter1.read(uint2((parameter2 + vec<int, 2>(-1, 1))), 0);
    local0 += parameter1.read(uint2((parameter2 + vec<int, 2>(-1, -1))), 0);
    local0 += parameter1.read(uint2((parameter2 + vec<int, 2>(0, 0))), 0);
    local0 += parameter1.read(uint2((parameter2 + vec<int, 2>(1, -1))), 0);
    local0 += parameter1.read(uint2((parameter2 + vec<int, 2>(1, 1))), 0);
    return (local0 / 5.);
}

void function3(texture2d<float, access::sample> parameter5, texture2d<float, access::write> parameter6, unsigned parameter7)
{
    unsigned local2 = (parameter7 % 512u);
    unsigned local3 = __wgslDiv(parameter7, 512u);
    vec<int, 2> local4 = vec<int, 2>(int(local2), int(local3));
    vec<float, 3> local5 = function1(parameter5, local4).rgb;
    parameter6.write(vec<float, 4>((local5 * 1.0499999523162842), 1.), uint2(local4));
}

[[kernel]]  void function4(vec<unsigned, 3> parameter8 [[thread_position_in_grid]], constant __ArgumentBufferT_0& __ArgumentBuffer_0 [[buffer(0)]])
{
    unsigned global0 { };
    texture2d<float, access::sample> global1 = __ArgumentBuffer_0.global1;
    texture2d<float, access::write> global2 = __ArgumentBuffer_0.global2;
    global0 = parameter8.x;
    function3(global1, global2, global0);
}


MSL compilation error: Error Domain=MTLLibraryErrorDomain Code=3 "program_source:25:23: error: use of undeclared identifier '__wgslDiv'
    unsigned local3 = __wgslDiv(parameter7, 512u);
                      ^
" UserInfo={NSLocalizedDescription=program_source:25:23: error: use of undeclared identifier '__wgslDiv'
    unsigned local3 = __wgslDiv(parameter7, 512u);
                      ^
}
Comment 1 Radar WebKit Bug Importer 2023-11-06 11:03:05 PST
<rdar://problem/118009042>
Comment 2 Tadeu Zagallo 2023-11-07 07:27:08 PST
Pull request: https://github.com/WebKit/WebKit/pull/20100
Comment 3 EWS 2023-11-07 09:15:38 PST
Committed 270328@main (3944b4d13d3b): <https://commits.webkit.org/270328@main>

Reviewed commits have been landed. Closing PR #20100 and removing active labels.