Port invalid SPIR-V tests to SPVASM instead of GLSL.

Bug: dawn:572
Change-Id: I4d244d6837f70720a04236ecb751785e27a14d10
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/44763
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez 2021-03-16 18:09:59 +00:00 committed by Commit Bot service account
parent af607f7f80
commit 0ed19c6640
3 changed files with 80 additions and 34 deletions

View File

@ -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: {

View File

@ -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;

View File

@ -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));
}