diff --git a/src/dawn_native/ShaderModule.cpp b/src/dawn_native/ShaderModule.cpp index 502ec4062d..fd5ce0e1a5 100644 --- a/src/dawn_native/ShaderModule.cpp +++ b/src/dawn_native/ShaderModule.cpp @@ -871,6 +871,7 @@ namespace dawn_native { tint::transform::Manager transformManager; transformManager.append( std::make_unique()); + transformManager.append(std::make_unique()); DAWN_TRY_ASSIGN(program, RunTransforms(&transformManager, &program)); } @@ -1072,6 +1073,7 @@ namespace dawn_native { transformManager.append( MakeVertexPullingTransform(vertexState, entryPoint, pullingBufferBindingSet)); transformManager.append(std::make_unique()); + transformManager.append(std::make_unique()); if (GetDevice()->IsRobustnessEnabled()) { // TODO(enga): Run the Tint BoundArrayAccessors transform instead of the SPIRV Tools // one, but it appears to crash after running VertexPulling. diff --git a/src/dawn_native/opengl/ShaderModuleGL.cpp b/src/dawn_native/opengl/ShaderModuleGL.cpp index 398589d386..1b9070ea3e 100644 --- a/src/dawn_native/opengl/ShaderModuleGL.cpp +++ b/src/dawn_native/opengl/ShaderModuleGL.cpp @@ -79,19 +79,19 @@ namespace dawn_native { namespace opengl { } MaybeError ShaderModule::Initialize(ShaderModuleParseResult* parseResult) { - DAWN_TRY(InitializeBase(parseResult)); if (GetDevice()->IsToggleEnabled(Toggle::UseTintGenerator)) { #ifdef DAWN_ENABLE_WGSL - tint::Program program = std::move(*parseResult->tintProgram.release()); - std::ostringstream errorStream; errorStream << "Tint SPIR-V (for GLSL) writer failure:" << std::endl; tint::transform::Manager transformManager; transformManager.append(std::make_unique()); transformManager.append(std::make_unique()); + transformManager.append(std::make_unique()); - DAWN_TRY_ASSIGN(program, RunTransforms(&transformManager, &program)); + tint::Program program; + DAWN_TRY_ASSIGN(program, + RunTransforms(&transformManager, parseResult->tintProgram.get())); tint::writer::spirv::Generator generator(&program); if (!generator.Generate()) { @@ -100,9 +100,18 @@ namespace dawn_native { namespace opengl { } mSpirv = generator.result(); + + ShaderModuleParseResult transformedParseResult; + transformedParseResult.tintProgram = + std::make_unique(std::move(program)); + transformedParseResult.spirv = mSpirv; + + DAWN_TRY(InitializeBase(&transformedParseResult)); #else UNREACHABLE(); #endif + } else { + DAWN_TRY(InitializeBase(parseResult)); } return {}; } diff --git a/src/dawn_native/vulkan/ShaderModuleVk.cpp b/src/dawn_native/vulkan/ShaderModuleVk.cpp index 61c7f1ca53..baccde81d2 100644 --- a/src/dawn_native/vulkan/ShaderModuleVk.cpp +++ b/src/dawn_native/vulkan/ShaderModuleVk.cpp @@ -47,22 +47,22 @@ namespace dawn_native { namespace vulkan { } MaybeError ShaderModule::Initialize(ShaderModuleParseResult* parseResult) { - DAWN_TRY(InitializeBase(parseResult)); - std::vector spirv; const std::vector* spirvPtr; + if (GetDevice()->IsToggleEnabled(Toggle::UseTintGenerator)) { #ifdef DAWN_ENABLE_WGSL - tint::Program program = std::move(*std::move(parseResult->tintProgram).release()); - std::ostringstream errorStream; errorStream << "Tint SPIR-V writer failure:" << std::endl; tint::transform::Manager transformManager; transformManager.append(std::make_unique()); transformManager.append(std::make_unique()); + transformManager.append(std::make_unique()); - DAWN_TRY_ASSIGN(program, RunTransforms(&transformManager, &program)); + tint::Program program; + DAWN_TRY_ASSIGN(program, + RunTransforms(&transformManager, parseResult->tintProgram.get())); tint::writer::spirv::Generator generator(&program); if (!generator.Generate()) { @@ -72,10 +72,18 @@ namespace dawn_native { namespace vulkan { spirv = generator.result(); spirvPtr = &spirv; + + ShaderModuleParseResult transformedParseResult; + transformedParseResult.tintProgram = + std::make_unique(std::move(program)); + transformedParseResult.spirv = spirv; + + DAWN_TRY(InitializeBase(&transformedParseResult)); #else UNREACHABLE(); #endif } else { + DAWN_TRY(InitializeBase(parseResult)); spirvPtr = &GetSpirv(); } diff --git a/src/tests/end2end/MultisampledRenderingTests.cpp b/src/tests/end2end/MultisampledRenderingTests.cpp index c6e63b5c9b..43b5de61fd 100644 --- a/src/tests/end2end/MultisampledRenderingTests.cpp +++ b/src/tests/end2end/MultisampledRenderingTests.cpp @@ -733,8 +733,9 @@ TEST_P(MultisampledRenderingTest, MultisampledRenderingWithDepthTestAndSampleMas // Test using one multisampled color attachment with resolve target can render correctly // with non-default sample mask and shader-output mask. TEST_P(MultisampledRenderingTest, ResolveInto2DTextureWithSampleMaskAndShaderOutputMask) { - // TODO(crbug.com/tint/372): Support sample mask builtin. - DAWN_SKIP_TEST_IF(HasToggleEnabled("use_tint_generator")); + // TODO(github.com/KhronosGroup/SPIRV-Cross/issues/1626): SPIRV-Cross produces bad GLSL for + // unsigned SampleMask builtins + DAWN_SKIP_TEST_IF(HasToggleEnabled("use_tint_generator") && (IsOpenGL() || IsOpenGLES())); // TODO(crbug.com/dawn/673): Work around or enforce via validation that sample variables are not // supported on some platforms. @@ -783,8 +784,9 @@ TEST_P(MultisampledRenderingTest, ResolveInto2DTextureWithSampleMaskAndShaderOut // Test doing MSAA resolve into multiple resolve targets works correctly with a non-default // shader-output mask. TEST_P(MultisampledRenderingTest, ResolveIntoMultipleResolveTargetsWithShaderOutputMask) { - // TODO(crbug.com/tint/372): Support sample mask builtin. - DAWN_SKIP_TEST_IF(HasToggleEnabled("use_tint_generator")); + // TODO(github.com/KhronosGroup/SPIRV-Cross/issues/1626): SPIRV-Cross produces bad GLSL for + // unsigned SampleMask builtins + DAWN_SKIP_TEST_IF(HasToggleEnabled("use_tint_generator") && (IsOpenGL() || IsOpenGLES())); // TODO(crbug.com/dawn/673): Work around or enforce via validation that sample variables are not // supported on some platforms.