Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle shaders without execution model in spread-volatile-semantics #4766

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions source/opt/spread_volatile_semantics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ bool HasOnlyEntryPointsAsFunctions(IRContext* context, Module* module) {
} // namespace

Pass::Status SpreadVolatileSemantics::Process() {
if (HasNoExecutionModel()) {
return Status::SuccessWithoutChange;
}

if (!HasOnlyEntryPointsAsFunctions(context(), get_module())) {
return Status::Failure;
}
Expand Down
7 changes: 7 additions & 0 deletions source/opt/spread_volatile_semantics.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ class SpreadVolatileSemantics : public Pass {
}

private:
// Returns true if it does not have an execution model. Linkage shaders do not
// have an execution model.
bool HasNoExecutionModel() {
return get_module()->entry_points().empty() &&
context()->get_feature_mgr()->HasCapability(SpvCapabilityLinkage);
}

// Iterates interface variables and spreads the Volatile semantics if it has
// load instructions for the Volatile semantics.
Pass::Status SpreadVolatileSemanticsToVariables(
Expand Down
20 changes: 20 additions & 0 deletions test/opt/spread_volatile_semantics_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1113,6 +1113,26 @@ OpFunctionEnd
SinglePassRunAndMatch<SpreadVolatileSemantics>(text, true);
}

TEST_F(VolatileSpreadTest, SkipIfItHasNoExecutionModel) {
const std::string text = R"(
OpCapability Shader
OpCapability Linkage
OpMemoryModel Logical GLSL450
%2 = OpTypeVoid
%3 = OpTypeFunction %2
%4 = OpFunction %2 None %3
%5 = OpLabel
OpReturn
OpFunctionEnd
)";

Pass::Status status;
std::tie(std::ignore, status) =
SinglePassRunToBinary<SpreadVolatileSemantics>(text,
/* skip_nop = */ false);
EXPECT_EQ(status, Pass::Status::SuccessWithoutChange);
}

} // namespace
} // namespace opt
} // namespace spvtools