mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-10-07 14:26:36 +00:00
[TEST] Prune on passthrough stores
This commit is contained in:
@@ -391,6 +391,52 @@ IR::Program MergeDualVertexPrograms(IR::Program& vertex_a, IR::Program& vertex_b
|
||||
return result;
|
||||
}
|
||||
|
||||
void PrunePassthroughStores(IR::Program& program, const VaryingState& previous_stage_stores) {
|
||||
if (program.stage != Stage::Geometry || program.is_geometry_passthrough) {
|
||||
return;
|
||||
}
|
||||
VaryingState pruned;
|
||||
for (size_t index = 0; index < program.info.passthrough.mask.size(); ++index) {
|
||||
if (!program.info.passthrough.mask[index] || previous_stage_stores.mask[index]) {
|
||||
continue;
|
||||
}
|
||||
const IR::Attribute attr{static_cast<IR::Attribute>(index)};
|
||||
if (attr >= IR::Attribute::PositionX && attr <= IR::Attribute::PositionW) {
|
||||
continue;
|
||||
}
|
||||
pruned.mask[index] = true;
|
||||
}
|
||||
if (pruned.mask.none()) {
|
||||
return;
|
||||
}
|
||||
const auto erase_matching{[&pruned](IR::Block* block, IR::Opcode opcode, bool skip_used) {
|
||||
auto it{block->begin()};
|
||||
while (it != block->end()) {
|
||||
IR::Inst& inst{*it};
|
||||
if (inst.GetOpcode() != opcode ||
|
||||
!pruned.mask[static_cast<size_t>(inst.Arg(0).Attribute())]) {
|
||||
++it;
|
||||
continue;
|
||||
}
|
||||
if (skip_used && inst.HasUses()) {
|
||||
++it;
|
||||
continue;
|
||||
}
|
||||
inst.Invalidate();
|
||||
it = block->Instructions().erase(it);
|
||||
}
|
||||
}};
|
||||
for (IR::Block* const block : program.post_order_blocks) {
|
||||
erase_matching(block, IR::Opcode::SetAttribute, false);
|
||||
}
|
||||
for (IR::Block* const block : program.post_order_blocks) {
|
||||
erase_matching(block, IR::Opcode::GetAttribute, true);
|
||||
}
|
||||
program.info.stores.mask &= ~pruned.mask;
|
||||
program.info.loads.mask &= ~pruned.mask;
|
||||
program.info.passthrough.mask &= ~pruned.mask;
|
||||
}
|
||||
|
||||
void ConvertLegacyToGeneric(IR::Program& program, const Shader::RuntimeInfo& runtime_info) {
|
||||
auto& stores = program.info.stores;
|
||||
if (stores.Legacy()) {
|
||||
|
||||
@@ -29,6 +29,8 @@ namespace Shader::Maxwell {
|
||||
|
||||
void ConvertLegacyToGeneric(IR::Program& program, const RuntimeInfo& runtime_info);
|
||||
|
||||
void PrunePassthroughStores(IR::Program& program, const VaryingState& previous_stage_stores);
|
||||
|
||||
// Maxwell v1 and older Nvidia cards don't support setting gl_Layer from non-geometry stages.
|
||||
// This creates a workaround by setting the layer as a generic output and creating a
|
||||
// passthrough geometry shader that reads the generic and sets the layer.
|
||||
|
||||
Reference in New Issue
Block a user