summaryrefslogtreecommitdiffstats
path: root/src/shader_recompiler/backend/spirv
diff options
context:
space:
mode:
authorFeng Chen <vonchenplus@gmail.com>2021-09-08 04:28:09 +0200
committerFeng Chen <vonchenplus@gmail.com>2021-09-08 04:30:00 +0200
commitb1e655f89824bb1c43fc5160cd879b60bb60dbad (patch)
tree69f6a100891bda53954742f03c338b019276e86d /src/shader_recompiler/backend/spirv
parentDetail adjustment (diff)
downloadyuzu-b1e655f89824bb1c43fc5160cd879b60bb60dbad.tar
yuzu-b1e655f89824bb1c43fc5160cd879b60bb60dbad.tar.gz
yuzu-b1e655f89824bb1c43fc5160cd879b60bb60dbad.tar.bz2
yuzu-b1e655f89824bb1c43fc5160cd879b60bb60dbad.tar.lz
yuzu-b1e655f89824bb1c43fc5160cd879b60bb60dbad.tar.xz
yuzu-b1e655f89824bb1c43fc5160cd879b60bb60dbad.tar.zst
yuzu-b1e655f89824bb1c43fc5160cd879b60bb60dbad.zip
Diffstat (limited to 'src/shader_recompiler/backend/spirv')
-rw-r--r--src/shader_recompiler/backend/spirv/emit_context.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/shader_recompiler/backend/spirv/emit_context.cpp b/src/shader_recompiler/backend/spirv/emit_context.cpp
index 118a80165..2885e6799 100644
--- a/src/shader_recompiler/backend/spirv/emit_context.cpp
+++ b/src/shader_recompiler/backend/spirv/emit_context.cpp
@@ -430,15 +430,14 @@ Id DescType(EmitContext& ctx, Id sampled_type, Id pointer_type, u32 count) {
}
}
-size_t FindFistUnUsedLocation(const std::bitset<IR::NUM_GENERICS>& used_locations,
- size_t previous_unused_location) {
- size_t location = previous_unused_location + 1;
- while (location < used_locations.size() && used_locations.test(location))
- ++location;
- if (location == used_locations.size()) {
- throw RuntimeError("Unable to get an unused location for legacy attribute");
- }
- return location;
+size_t FindNextUnusedLocation(const std::bitset<IR::NUM_GENERICS>& used_locations,
+ size_t start_offset) {
+ for (size_t location = start_offset; location < used_locations.size(); ++location) {
+ if (!used_locations.test(location)) {
+ return location;
+ }
+ }
+ throw RuntimeError("Unable to get an unused location for legacy attribute");
}
} // Anonymous namespace
@@ -1280,7 +1279,7 @@ void EmitContext::DefineInputs(const IR::Program& program) {
}
size_t previous_unused_location = 0;
if (loads.AnyComponent(IR::Attribute::ColorFrontDiffuseR)) {
- size_t location = FindFistUnUsedLocation(used_locations, previous_unused_location);
+ const size_t location = FindNextUnusedLocation(used_locations, previous_unused_location);
previous_unused_location = location;
used_locations.set(location);
const Id id{DefineInput(*this, F32[4], true)};
@@ -1289,7 +1288,8 @@ void EmitContext::DefineInputs(const IR::Program& program) {
}
for (size_t index = 0; index < NUM_FIXEDFNCTEXTURE; ++index) {
if (loads.AnyComponent(IR::Attribute::FixedFncTexture0S + index * 4)) {
- size_t location = FindFistUnUsedLocation(used_locations, previous_unused_location);
+ const size_t location =
+ FindNextUnusedLocation(used_locations, previous_unused_location);
previous_unused_location = location;
used_locations.set(location);
const Id id{DefineInput(*this, F32[4], true)};
@@ -1356,7 +1356,7 @@ void EmitContext::DefineOutputs(const IR::Program& program) {
}
size_t previous_unused_location = 0;
if (info.stores.AnyComponent(IR::Attribute::ColorFrontDiffuseR)) {
- size_t location = FindFistUnUsedLocation(used_locations, previous_unused_location);
+ const size_t location = FindNextUnusedLocation(used_locations, previous_unused_location);
previous_unused_location = location;
used_locations.set(location);
const Id id{DefineOutput(*this, F32[4], invocations)};
@@ -1365,7 +1365,8 @@ void EmitContext::DefineOutputs(const IR::Program& program) {
}
for (size_t index = 0; index < NUM_FIXEDFNCTEXTURE; ++index) {
if (info.stores.AnyComponent(IR::Attribute::FixedFncTexture0S + index * 4)) {
- size_t location = FindFistUnUsedLocation(used_locations, previous_unused_location);
+ const size_t location =
+ FindNextUnusedLocation(used_locations, previous_unused_location);
previous_unused_location = location;
used_locations.set(location);
const Id id{DefineOutput(*this, F32[4], invocations)};