Skip to content

Commit

Permalink
gpu: Don't run spirv-opt on non-instrumented shaders
Browse files Browse the repository at this point in the history
  • Loading branch information
spencer-lunarg committed Jul 10, 2024
1 parent d03e2bc commit 6ee4dec
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions layers/gpu/instrumentation/gpu_shader_instrumentor.h
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ class GpuShaderInstrumentor : public ValidationStateTracker {
const SafeCreateInfo &modified_create_infos, bool passed_in_shader_stage_ci);

// GPU-AV and DebugPrint are going to have a different way to do the actual shader instrumentation logic
// Returns if shader was instrumented successfully or not
virtual bool InstrumentShader(const vvl::span<const uint32_t> &input, uint32_t unique_shader_id, const Location &loc,
std::vector<uint32_t> &out_instrumented_spirv) = 0;

Expand Down
5 changes: 5 additions & 0 deletions layers/gpu/instrumentation/gpuav_instrumentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ bool Validator::InstrumentShader(const vvl::span<const uint32_t> &input, uint32_
module.RunPassRayQuery();
}

// If nothing was instrumented, leave early to save time
if (!module.IsInstrumented()) {
return false;
}

for (const auto info : module.link_info_) {
module.LinkFunction(info);
}
Expand Down
1 change: 1 addition & 0 deletions layers/gpu/spirv/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class Module {
// Order of functions that will try to be linked in
std::vector<LinkInfo> link_info_;
void LinkFunction(const LinkInfo& info);
bool IsInstrumented() const { return !link_info_.empty(); }

// The class is designed to be written out to a binary file.
void ToBinary(std::vector<uint32_t>& out);
Expand Down

0 comments on commit 6ee4dec

Please sign in to comment.