diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/shader_recompiler/backend/spirv/emit_context.cpp | 27 |
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) { | |||
| 430 | } | 430 | } |
| 431 | } | 431 | } |
| 432 | 432 | ||
| 433 | size_t FindFistUnUsedLocation(const std::bitset<IR::NUM_GENERICS>& used_locations, | 433 | size_t FindNextUnusedLocation(const std::bitset<IR::NUM_GENERICS>& used_locations, |
| 434 | size_t previous_unused_location) { | 434 | size_t start_offset) { |
| 435 | size_t location = previous_unused_location + 1; | 435 | for (size_t location = start_offset; location < used_locations.size(); ++location) { |
| 436 | while (location < used_locations.size() && used_locations.test(location)) | 436 | if (!used_locations.test(location)) { |
| 437 | ++location; | 437 | return location; |
| 438 | if (location == used_locations.size()) { | 438 | } |
| 439 | throw RuntimeError("Unable to get an unused location for legacy attribute"); | 439 | } |
| 440 | } | 440 | throw RuntimeError("Unable to get an unused location for legacy attribute"); |
| 441 | return location; | ||
| 442 | } | 441 | } |
| 443 | } // Anonymous namespace | 442 | } // Anonymous namespace |
| 444 | 443 | ||
| @@ -1280,7 +1279,7 @@ void EmitContext::DefineInputs(const IR::Program& program) { | |||
| 1280 | } | 1279 | } |
| 1281 | size_t previous_unused_location = 0; | 1280 | size_t previous_unused_location = 0; |
| 1282 | if (loads.AnyComponent(IR::Attribute::ColorFrontDiffuseR)) { | 1281 | if (loads.AnyComponent(IR::Attribute::ColorFrontDiffuseR)) { |
| 1283 | size_t location = FindFistUnUsedLocation(used_locations, previous_unused_location); | 1282 | const size_t location = FindNextUnusedLocation(used_locations, previous_unused_location); |
| 1284 | previous_unused_location = location; | 1283 | previous_unused_location = location; |
| 1285 | used_locations.set(location); | 1284 | used_locations.set(location); |
| 1286 | const Id id{DefineInput(*this, F32[4], true)}; | 1285 | const Id id{DefineInput(*this, F32[4], true)}; |
| @@ -1289,7 +1288,8 @@ void EmitContext::DefineInputs(const IR::Program& program) { | |||
| 1289 | } | 1288 | } |
| 1290 | for (size_t index = 0; index < NUM_FIXEDFNCTEXTURE; ++index) { | 1289 | for (size_t index = 0; index < NUM_FIXEDFNCTEXTURE; ++index) { |
| 1291 | if (loads.AnyComponent(IR::Attribute::FixedFncTexture0S + index * 4)) { | 1290 | if (loads.AnyComponent(IR::Attribute::FixedFncTexture0S + index * 4)) { |
| 1292 | size_t location = FindFistUnUsedLocation(used_locations, previous_unused_location); | 1291 | const size_t location = |
| 1292 | FindNextUnusedLocation(used_locations, previous_unused_location); | ||
| 1293 | previous_unused_location = location; | 1293 | previous_unused_location = location; |
| 1294 | used_locations.set(location); | 1294 | used_locations.set(location); |
| 1295 | const Id id{DefineInput(*this, F32[4], true)}; | 1295 | const Id id{DefineInput(*this, F32[4], true)}; |
| @@ -1356,7 +1356,7 @@ void EmitContext::DefineOutputs(const IR::Program& program) { | |||
| 1356 | } | 1356 | } |
| 1357 | size_t previous_unused_location = 0; | 1357 | size_t previous_unused_location = 0; |
| 1358 | if (info.stores.AnyComponent(IR::Attribute::ColorFrontDiffuseR)) { | 1358 | if (info.stores.AnyComponent(IR::Attribute::ColorFrontDiffuseR)) { |
| 1359 | size_t location = FindFistUnUsedLocation(used_locations, previous_unused_location); | 1359 | const size_t location = FindNextUnusedLocation(used_locations, previous_unused_location); |
| 1360 | previous_unused_location = location; | 1360 | previous_unused_location = location; |
| 1361 | used_locations.set(location); | 1361 | used_locations.set(location); |
| 1362 | const Id id{DefineOutput(*this, F32[4], invocations)}; | 1362 | const Id id{DefineOutput(*this, F32[4], invocations)}; |
| @@ -1365,7 +1365,8 @@ void EmitContext::DefineOutputs(const IR::Program& program) { | |||
| 1365 | } | 1365 | } |
| 1366 | for (size_t index = 0; index < NUM_FIXEDFNCTEXTURE; ++index) { | 1366 | for (size_t index = 0; index < NUM_FIXEDFNCTEXTURE; ++index) { |
| 1367 | if (info.stores.AnyComponent(IR::Attribute::FixedFncTexture0S + index * 4)) { | 1367 | if (info.stores.AnyComponent(IR::Attribute::FixedFncTexture0S + index * 4)) { |
| 1368 | size_t location = FindFistUnUsedLocation(used_locations, previous_unused_location); | 1368 | const size_t location = |
| 1369 | FindNextUnusedLocation(used_locations, previous_unused_location); | ||
| 1369 | previous_unused_location = location; | 1370 | previous_unused_location = location; |
| 1370 | used_locations.set(location); | 1371 | used_locations.set(location); |
| 1371 | const Id id{DefineOutput(*this, F32[4], invocations)}; | 1372 | const Id id{DefineOutput(*this, F32[4], invocations)}; |