Skip to content

Commit

Permalink
[WebGPU] CTS validation/render_pipeline/shader_module.html is failing
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=266739
<radar://119958283>

Reviewed by Tadeu Zagallo.

ShaderModule was just missing device mismatch to pass and correction
for vertex-only pipelines.

* LayoutTests/http/tests/webgpu/webgpu/api/validation/render_pipeline/shader_module-expected.txt:
Add passing expectations.

* Source/WebGPU/WebGPU/RenderPipeline.mm:
(WebGPU::Device::createRenderPipeline):

Canonical link: https://commits.webkit.org/272612@main
  • Loading branch information
mwyrzykowski committed Jan 3, 2024
1 parent 3bef04c commit 7e2a446
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
(Populate me when we're ready to investigate this test)

PASS :device_mismatch:
PASS :invalid,vertex:isAsync=true;isVertexShaderValid=true
PASS :invalid,vertex:isAsync=true;isVertexShaderValid=false
PASS :invalid,vertex:isAsync=false;isVertexShaderValid=true
PASS :invalid,vertex:isAsync=false;isVertexShaderValid=false
PASS :invalid,fragment:isAsync=true;isFragmentShaderValid=true
PASS :invalid,fragment:isAsync=true;isFragmentShaderValid=false
PASS :invalid,fragment:isAsync=false;isFragmentShaderValid=true
PASS :invalid,fragment:isAsync=false;isFragmentShaderValid=false

8 changes: 6 additions & 2 deletions Source/WebGPU/WebGPU/RenderPipeline.mm
Original file line number Diff line number Diff line change
Expand Up @@ -885,8 +885,10 @@ static bool textureFormatAllowedForRetunType(WGPUTextureFormat format, MTLDataTy
return returnInvalidRenderPipeline(*this, isAsync, "Vertex module has an invalid chain"_s);

const auto& vertexModule = WebGPU::fromAPI(descriptor.vertex.module);
if (!vertexModule.isValid())
if (!vertexModule.isValid() || !vertexModule.ast())
return returnInvalidRenderPipeline(*this, isAsync, "Vertex module is not valid"_s);
if (&vertexModule.device() != this)
return returnInvalidRenderPipeline(*this, isAsync, "Vertex module was created with a different device"_s);

const auto& vertexFunctionName = fromAPI(descriptor.vertex.entryPoint);
auto libraryCreationResult = createLibrary(m_device, vertexModule, pipelineLayout, vertexFunctionName.length() ? vertexFunctionName : vertexModule.defaultVertexEntryPoint(), label);
Expand Down Expand Up @@ -918,6 +920,9 @@ static bool textureFormatAllowedForRetunType(WGPUTextureFormat format, MTLDataTy
if (!fragmentModule.isValid() || !fragmentModule.ast())
return returnInvalidRenderPipeline(*this, isAsync, "Fragment module is invalid"_s);

if (&fragmentModule.device() != this)
return returnInvalidRenderPipeline(*this, isAsync, "Fragment module was created with a different device"_s);

usesFragDepth = fragmentModule.ast()->usesFragDepth();
usesSampleMask = fragmentModule.ast()->usesSampleMask();
const auto& fragmentFunctionName = fromAPI(fragmentDescriptor.entryPoint);
Expand Down Expand Up @@ -1022,7 +1027,6 @@ static bool textureFormatAllowedForRetunType(WGPUTextureFormat format, MTLDataTy

if (descriptor.fragment && !hasAtLeastOneColorTarget && !descriptor.depthStencil)
return returnInvalidRenderPipeline(*this, isAsync, "No color targets or depth stencil were specified in the descriptor"_s);

if (usesFragDepth && mtlRenderPipelineDescriptor.depthAttachmentPixelFormat == MTLPixelFormatInvalid)
return returnInvalidRenderPipeline(*this, isAsync, "Shader writes to frag depth but no depth texture set"_s);

Expand Down

0 comments on commit 7e2a446

Please sign in to comment.