diff --git a/src/dawn_native/ShaderModule.cpp b/src/dawn_native/ShaderModule.cpp index 04949c572a..e21907d181 100644 --- a/src/dawn_native/ShaderModule.cpp +++ b/src/dawn_native/ShaderModule.cpp @@ -566,6 +566,10 @@ namespace dawn_native { } info->texture.sampleType = wgpu::TextureSampleType::Depth; } + if (imageType.ms && imageType.arrayed) { + return DAWN_VALIDATION_ERROR( + "Multisampled array textures aren't supported"); + } break; } case BindingInfoType::Buffer: { diff --git a/src/tests/unittests/validation/RenderPipelineValidationTests.cpp b/src/tests/unittests/validation/RenderPipelineValidationTests.cpp index 93c52bddfe..45a941c26b 100644 --- a/src/tests/unittests/validation/RenderPipelineValidationTests.cpp +++ b/src/tests/unittests/validation/RenderPipelineValidationTests.cpp @@ -501,33 +501,6 @@ TEST_F(RenderPipelineValidationTest, StorageBufferInVertexShaderNoLayout) { ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor)); } -// Test that a pipeline with defaulted layout may not have multisampled array textures -// TODO(enga): Also test multisampled cube, cube array, and 3D. These have no GLSL keywords. -// TODO(cwallez@chromium.org): Convert them to SPIRV ASM to remove the dependency on glslang. -TEST_F(RenderPipelineValidationTest, MultisampledTexture) { - utils::ComboRenderPipelineDescriptor descriptor(device); - descriptor.layout = nullptr; - descriptor.cFragmentStage.module = fsModule; - - // Base case works. - descriptor.vertexStage.module = - utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"( - #version 450 - layout(set = 0, binding = 0) uniform texture2DMS texture; - void main() { - })"); - device.CreateRenderPipeline(&descriptor); - - // texture2DMSArray invalid - descriptor.vertexStage.module = - utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"( - #version 450 - layout(set = 0, binding = 0) uniform texture2DMSArray texture; - void main() { - })"); - ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor)); -} - // Tests that strip primitive topologies require an index format TEST_F(RenderPipelineValidationTest, StripIndexFormatRequired) { constexpr uint32_t kNumStripType = 2u; diff --git a/src/tests/unittests/validation/ShaderModuleValidationTests.cpp b/src/tests/unittests/validation/ShaderModuleValidationTests.cpp index 2662de4166..be47d3cb6b 100644 --- a/src/tests/unittests/validation/ShaderModuleValidationTests.cpp +++ b/src/tests/unittests/validation/ShaderModuleValidationTests.cpp @@ -73,14 +73,83 @@ TEST_F(ShaderModuleValidationTest, NoChainedDescriptor) { } // Test that it is not allowed to use combined texture and sampler. -// TODO(cwallez@chromium.org): Convert them to SPIRV ASM to remove the dependency on glslang. TEST_F(ShaderModuleValidationTest, CombinedTextureAndSampler) { + // SPIR-V ASM produced by glslang for the following fragment shader: + // + // #version 450 + // layout(set = 0, binding = 0) uniform sampler2D tex; + // void main () {} + // + // Note that the following defines an interface combined texture/sampler which is not allowed + // in Dawn / WebGPU. + // + // %8 = OpTypeSampledImage %7 + // %_ptr_UniformConstant_8 = OpTypePointer UniformConstant %8 + // %tex = OpVariable %_ptr_UniformConstant_8 UniformConstant const char* shader = R"( - #version 450 - layout (set = 0, binding = 0) uniform sampler2D texture; - void main() { - })"; + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpName %main "main" + OpName %tex "tex" + OpDecorate %tex DescriptorSet 0 + OpDecorate %tex Binding 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %7 = OpTypeImage %float 2D 0 0 0 1 Unknown + %8 = OpTypeSampledImage %7 +%_ptr_UniformConstant_8 = OpTypePointer UniformConstant %8 + %tex = OpVariable %_ptr_UniformConstant_8 UniformConstant + %main = OpFunction %void None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd + )"; - ASSERT_DEVICE_ERROR( - utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, shader)); + ASSERT_DEVICE_ERROR(utils::CreateShaderModuleFromASM(device, shader)); +} + +// Test that it is not allowed to declare a multisampled-array interface texture. +// TODO(enga): Also test multisampled cube, cube array, and 3D. These have no GLSL keywords. +TEST_F(ShaderModuleValidationTest, MultisampledArrayTexture) { + // SPIR-V ASM produced by glslang for the following fragment shader: + // + // #version 450 + // layout(set=0, binding=0) uniform texture2DMSArray tex; + // void main () {}} + // + // Note that the following defines an interface array multisampled texture which is not allowed + // in Dawn / WebGPU. + // + // %7 = OpTypeImage %float 2D 0 1 1 1 Unknown + // %_ptr_UniformConstant_7 = OpTypePointer UniformConstant %7 + // %tex = OpVariable %_ptr_UniformConstant_7 UniformConstant + const char* shader = R"( + OpCapability Shader + %1 = OpExtInstImport "GLSL.std.450" + OpMemoryModel Logical GLSL450 + OpEntryPoint Fragment %main "main" + OpExecutionMode %main OriginUpperLeft + OpSource GLSL 450 + OpName %main "main" + OpName %tex "tex" + OpDecorate %tex DescriptorSet 0 + OpDecorate %tex Binding 0 + %void = OpTypeVoid + %3 = OpTypeFunction %void + %float = OpTypeFloat 32 + %7 = OpTypeImage %float 2D 0 1 1 1 Unknown +%_ptr_UniformConstant_7 = OpTypePointer UniformConstant %7 + %tex = OpVariable %_ptr_UniformConstant_7 UniformConstant + %main = OpFunction %void None %3 + %5 = OpLabel + OpReturn + OpFunctionEnd + )"; + + ASSERT_DEVICE_ERROR(utils::CreateShaderModuleFromASM(device, shader)); }