Detail adjustment

This commit is contained in:
Feng Chen 2021-09-08 10:28:09 +08:00
parent bbc1800c1b
commit b1e655f898

View file

@ -430,16 +430,15 @@ 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 FindNextUnusedLocation(const std::bitset<IR::NUM_GENERICS>& used_locations,
size_t previous_unused_location) { size_t start_offset) {
size_t location = previous_unused_location + 1; for (size_t location = start_offset; location < used_locations.size(); ++location) {
while (location < used_locations.size() && used_locations.test(location)) if (!used_locations.test(location)) {
++location;
if (location == used_locations.size()) {
throw RuntimeError("Unable to get an unused location for legacy attribute");
}
return location; return location;
} }
}
throw RuntimeError("Unable to get an unused location for legacy attribute");
}
} // Anonymous namespace } // Anonymous namespace
void VectorTypes::Define(Sirit::Module& sirit_ctx, Id base_type, std::string_view name) { void VectorTypes::Define(Sirit::Module& sirit_ctx, Id base_type, std::string_view name) {
@ -1280,7 +1279,7 @@ void EmitContext::DefineInputs(const IR::Program& program) {
} }
size_t previous_unused_location = 0; size_t previous_unused_location = 0;
if (loads.AnyComponent(IR::Attribute::ColorFrontDiffuseR)) { 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; previous_unused_location = location;
used_locations.set(location); used_locations.set(location);
const Id id{DefineInput(*this, F32[4], true)}; 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) { for (size_t index = 0; index < NUM_FIXEDFNCTEXTURE; ++index) {
if (loads.AnyComponent(IR::Attribute::FixedFncTexture0S + index * 4)) { 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; previous_unused_location = location;
used_locations.set(location); used_locations.set(location);
const Id id{DefineInput(*this, F32[4], true)}; 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; size_t previous_unused_location = 0;
if (info.stores.AnyComponent(IR::Attribute::ColorFrontDiffuseR)) { 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; previous_unused_location = location;
used_locations.set(location); used_locations.set(location);
const Id id{DefineOutput(*this, F32[4], invocations)}; 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) { for (size_t index = 0; index < NUM_FIXEDFNCTEXTURE; ++index) {
if (info.stores.AnyComponent(IR::Attribute::FixedFncTexture0S + index * 4)) { 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; previous_unused_location = location;
used_locations.set(location); used_locations.set(location);
const Id id{DefineOutput(*this, F32[4], invocations)}; const Id id{DefineOutput(*this, F32[4], invocations)};