Skip to content

Commit

Permalink
[OPT] Add SPV_KHR_ray_tracing to allow list
Browse files Browse the repository at this point in the history
When adding SPV_KHR_ray_tracing to the allow lists, we missed the list
in local-single-store-elim. Adding it now.

microsoft/DirectXShaderCompiler#7063
  • Loading branch information
s-perron committed Jan 14, 2025
1 parent 995922d commit 43d0dd9
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 1 deletion.
3 changes: 2 additions & 1 deletion source/opt/local_single_store_elim_pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ void LocalSingleStoreElimPass::InitExtensionAllowList() {
"SPV_NV_cooperative_matrix",
"SPV_KHR_cooperative_matrix",
"SPV_KHR_ray_tracing_position_fetch",
"SPV_KHR_fragment_shading_rate"});
"SPV_KHR_fragment_shading_rate",
"SPV_KHR_ray_tracing"});
}
bool LocalSingleStoreElimPass::ProcessVariable(Instruction* var_inst) {
std::vector<Instruction*> users;
Expand Down
50 changes: 50 additions & 0 deletions test/opt/local_single_store_elim_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,56 @@ namespace {

using LocalSingleStoreElimTest = PassTest<::testing::Test>;

TEST_F(LocalSingleStoreElimTest, DoSomethingWithExtensions) {
const std::string capabilities_and_extensions =
R"(OpCapability Shader
OpExtension "SPV_EXT_fragment_shader_interlock"
OpExtension "SPV_NV_compute_shader_derivatives"
OpExtension "SPV_KHR_ray_query"
OpExtension "SPV_NV_shader_subgroup_partitioned"
OpExtension "SPV_KHR_ray_tracing"
OpExtension "SPV_EXT_descriptor_indexing"
)";

const std::string before = capabilities_and_extensions +
R"(%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %2 "main"
OpExecutionMode %2 OriginUpperLeft
OpSource GLSL 140
%void = OpTypeVoid
%4 = OpTypeFunction %void
%float = OpTypeFloat 32
%_ptr_Function_float = OpTypePointer Function %float
%float_0 = OpConstant %float 0
%2 = OpFunction %void None %4
%8 = OpLabel
%9 = OpVariable %_ptr_Function_float Function
OpStore %9 %float_0
%10 = OpLoad %float %9
OpReturn
OpFunctionEnd
)";
const std::string after = capabilities_and_extensions +
R"(%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %2 "main"
OpExecutionMode %2 OriginUpperLeft
OpSource GLSL 140
%void = OpTypeVoid
%4 = OpTypeFunction %void
%float = OpTypeFloat 32
%_ptr_Function_float = OpTypePointer Function %float
%float_0 = OpConstant %float 0
%2 = OpFunction %void None %4
%8 = OpLabel
%9 = OpVariable %_ptr_Function_float Function
OpStore %9 %float_0
OpReturn
OpFunctionEnd
)";
SinglePassRunAndCheck<LocalSingleStoreElimPass>(before, after, true, true);
}
TEST_F(LocalSingleStoreElimTest, PositiveAndNegative) {
// Single store to v is optimized. Multiple store to
// f is not optimized.
Expand Down

0 comments on commit 43d0dd9

Please sign in to comment.