From 8c584a1f4c0b3a2da838b2d3893d694d02eec78c Mon Sep 17 00:00:00 2001 From: Ryan Harrison Date: Mon, 14 Jun 2021 19:07:17 +0000 Subject: [PATCH] Make usage of overridable constants a validation error This feature is not yet implemented in Tint and it not planned for OT. BUG=dawn:799 Change-Id: Ib97dcd39e8ae956aa6fdc4cc1b148ec7f101b061 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/54280 Commit-Queue: Ryan Harrison Reviewed-by: Corentin Wallez --- src/dawn_native/ShaderModule.cpp | 5 +++++ src/tests/end2end/ShaderTests.cpp | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/dawn_native/ShaderModule.cpp b/src/dawn_native/ShaderModule.cpp index 96fe955b17..930fcf4acc 100644 --- a/src/dawn_native/ShaderModule.cpp +++ b/src/dawn_native/ShaderModule.cpp @@ -886,6 +886,11 @@ namespace dawn_native { for (auto& entryPoint : entryPoints) { ASSERT(result.count(entryPoint.name) == 0); + if (!entryPoint.overridable_constants.empty()) { + return DAWN_VALIDATION_ERROR( + "Pipeline overridable constants are not implemented yet"); + } + auto metadata = std::make_unique(); DAWN_TRY_ASSIGN(metadata->stage, TintPipelineStageToShaderStage(entryPoint.stage)); diff --git a/src/tests/end2end/ShaderTests.cpp b/src/tests/end2end/ShaderTests.cpp index 6184a5e9d4..75a3eb859e 100644 --- a/src/tests/end2end/ShaderTests.cpp +++ b/src/tests/end2end/ShaderTests.cpp @@ -305,6 +305,23 @@ fn fragmentMain(input : VertexOut) -> [[location(0)]] vec4 { wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&rpDesc); } +// Feature currently not implemented in Tint, so should fail validation. +TEST_P(ShaderTests, PipelineOverridableUsed) { + DAWN_TEST_UNSUPPORTED_IF(HasToggleEnabled("skip_validation")); + DAWN_TEST_UNSUPPORTED_IF(!HasToggleEnabled("use_tint_generator")); + + std::string shader = R"( +[[override]] let foo : f32; + +[[stage(compute)]] +fn ep_func() { + var local_foo : f32; + local_foo = foo; + return; +})"; + ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, shader.c_str())); +} + DAWN_INSTANTIATE_TEST(ShaderTests, D3D12Backend(), MetalBackend(),