Bug 264371

Summary: [WGSL] textureSampleGrad is not implemented
Product: WebKit Reporter: Mike Wyrzykowski <mwyrzykowski>
Component: WebGPUAssignee: Tadeu Zagallo <tzagallo>
Status: RESOLVED FIXED    
Severity: Normal CC: webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description Mike Wyrzykowski 2023-11-07 15:42:20 PST
textureSampleGrad should map to sample which takes a gradient (page 202 of the Metal shading language spec)

Open https://webgpu.github.io/webgpu-samples/samples/normalMap.

Note the failure:

MSL compilation error: Error Domain=MTLLibraryErrorDomain Code=3 "program_source:120:26: error: use of undeclared identifier 'textureSampleGrad'
        if ((local7.z >= textureSampleGrad(global11, global8, local7.xy, local2, local3).r)) {
                         ^
" UserInfo={NSLocalizedDescription=program_source:120:26: error: use of undeclared identifier 'textureSampleGrad'
        if ((local7.z >= textureSampleGrad(global11, global8, local7.xy, local2, local3).r)) {


it comes from this WGSL:

 // Walk the depth texture, and stop when the ray intersects the depth map
  var pos = vec3(startUV, 0);
  for (var i = 0; i < 32; i++) {
    if (pos.z >= textureSampleGrad(depthTexture, textureSampler, pos.xy, ddx, ddy).r) {
      break; // Hit the surface
    }
    pos += posDelta;
  }

in https://webgpu.github.io/webgpu-samples/samples/normalMap#./normalMap.wgsl
Comment 1 Radar WebKit Bug Importer 2023-11-07 15:42:37 PST
<rdar://problem/118084526>
Comment 2 Tadeu Zagallo 2023-11-08 07:23:09 PST
Pull request: https://github.com/WebKit/WebKit/pull/20162
Comment 3 EWS 2023-11-09 00:44:11 PST
Committed 270430@main (8af46bcd0f22): <https://commits.webkit.org/270430@main>

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