mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-20 02:47:02 +02:00
shader: factor live execution guards before resource planning
This commit is contained in:
@@ -566,10 +566,11 @@ void TestGuardedDirectImageTable() {
|
||||
Bounded, BoundMissing, BoundUnrelated, BoundBypass, BoundAnyLane,
|
||||
BoundDiamond, BoundBranchSpecific, BoundMismatched,
|
||||
BoundExec, BoundExecUnguarded, BoundExecMismatched, BoundExecAnd, BoundExecUnprovenActive,
|
||||
BoundExecFactored,
|
||||
Finite, FiniteZero, FiniteMissing, FiniteWrong, FiniteSigned, FiniteAdd, FiniteXor,
|
||||
FiniteShared, FiniteSharedBypass, FiniteLate
|
||||
};
|
||||
const auto make_plan = [](Guard guard) {
|
||||
const auto make_plan = [](Guard guard, uint32_t operand_order = 0u) {
|
||||
const bool finite = guard >= Guard::Finite;
|
||||
const bool bounded = guard >= Guard::Bounded && !finite;
|
||||
const bool exec_bound = bounded && guard >= Guard::BoundExec;
|
||||
@@ -650,8 +651,19 @@ void TestGuardedDirectImageTable() {
|
||||
? ValueOpcode::BitwiseAnd32 : ValueOpcode::BitwiseOr32, {encoded, varying});
|
||||
const auto retained = fixture.Emit(ValueOpcode::SelectU32,
|
||||
{previous, stopped, Value(0u)});
|
||||
const auto vcc = fixture.Emit(ValueOpcode::LogicalAnd, {previous,
|
||||
fixture.Emit(ValueOpcode::INotEqual32, {retained, Value(0u)})});
|
||||
const auto stopped_lane = fixture.Emit(ValueOpcode::INotEqual32, {retained, Value(0u)});
|
||||
auto vcc = fixture.Emit(ValueOpcode::LogicalAnd,
|
||||
operand_order & 1u ? std::initializer_list<Value>{stopped_lane, previous}
|
||||
: std::initializer_list<Value>{previous, stopped_lane});
|
||||
if (guard == Guard::BoundExecFactored) {
|
||||
const auto empty = fixture.Emit(ValueOpcode::IEqual32, {key, Value(UINT32_MAX)});
|
||||
const auto sentinel = fixture.Emit(ValueOpcode::LogicalAnd,
|
||||
operand_order & 2u ? std::initializer_list<Value>{empty, previous}
|
||||
: std::initializer_list<Value>{previous, empty});
|
||||
vcc = fixture.Emit(ValueOpcode::LogicalOr,
|
||||
operand_order & 4u ? std::initializer_list<Value>{sentinel, vcc}
|
||||
: std::initializer_list<Value>{vcc, sentinel});
|
||||
}
|
||||
const auto remaining = fixture.Emit(ValueOpcode::LogicalNot, {vcc});
|
||||
active = guard == Guard::BoundExecUnprovenActive ? remaining
|
||||
: fixture.Emit(ValueOpcode::LogicalAnd, {previous, remaining});
|
||||
@@ -799,10 +811,12 @@ void TestGuardedDirectImageTable() {
|
||||
fixture.AddMemory(memory, 0x130));
|
||||
}
|
||||
if (exec_bound) ConstantPropagationPass(fixture.program.blocks);
|
||||
if (guard == Guard::BoundExec) {
|
||||
if (guard == Guard::BoundExec || guard == Guard::BoundExecFactored) {
|
||||
std::vector<const Inst *> pending{active.ResolveInstruction()};
|
||||
uint32_t conjunctions = 0;
|
||||
for (size_t index = 0; index < pending.size(); ++index) {
|
||||
const auto *inst = pending[index];
|
||||
conjunctions += inst->GetOpcode() == ValueOpcode::LogicalAnd;
|
||||
Check(inst->GetOpcode() != ValueOpcode::SelectU32 &&
|
||||
inst->GetOpcode() != ValueOpcode::BitwiseOr32,
|
||||
"EXEC bound retained its integer Boolean encoding");
|
||||
@@ -812,6 +826,7 @@ void TestGuardedDirectImageTable() {
|
||||
pending.push_back(operand);
|
||||
}
|
||||
}
|
||||
Check(conjunctions == 1u, "EXEC bound retained repeated active-lane conjunctions");
|
||||
}
|
||||
fixture.PlanAndTrack();
|
||||
const auto source = fixture.program.info.images[0].source;
|
||||
@@ -829,6 +844,7 @@ void TestGuardedDirectImageTable() {
|
||||
auto plan = make_plan(Guard::Nonzero);
|
||||
make_plan(Guard::SccNonZero);
|
||||
make_plan(Guard::Plain);
|
||||
for (uint32_t order = 0; order < 8u; ++order) make_plan(Guard::BoundExecFactored, order);
|
||||
for (const auto guard : {Guard::Zero, Guard::Unrelated, Guard::Bypass,
|
||||
Guard::ExecZero, Guard::VccZero, Guard::BoundMissing,
|
||||
Guard::BoundUnrelated, Guard::BoundBypass, Guard::BoundAnyLane,
|
||||
@@ -914,13 +930,14 @@ void TestGuardedDirectImageTable() {
|
||||
"batched descriptor read crossed the 48-bit endpoint");
|
||||
|
||||
make_plan(Guard::Bounded);
|
||||
for (const auto guard : {Guard::BoundDiamond, Guard::BoundExec}) {
|
||||
for (const auto guard : {Guard::BoundDiamond, Guard::BoundExec, Guard::BoundExecFactored}) {
|
||||
auto bounded = make_plan(guard);
|
||||
Check(bounded.capture_specialization_reads && bounded.info.images[1].written,
|
||||
"bounded table with image writes omitted specialization read capture");
|
||||
LinearTestMemory records;
|
||||
const uint32_t record_offset = guard == Guard::BoundExec ? 672u : 3696u;
|
||||
const uint32_t record_stride = guard == Guard::BoundExec ? 784u : 272u;
|
||||
const bool exec_bound = guard != Guard::BoundDiamond;
|
||||
const uint32_t record_offset = exec_bound ? 672u : 3696u;
|
||||
const uint32_t record_stride = exec_bound ? 784u : 272u;
|
||||
for (uint32_t key = 0; key < 2u; ++key) {
|
||||
const auto word = (record_offset + key * record_stride) / 4u;
|
||||
records.words[word] = 0x500u + key;
|
||||
|
||||
@@ -36569,8 +36569,11 @@ void CheckGuardedRecordImageTable(VulkanHarness &vulkan) {
|
||||
EncodeSop1(0x04, 126, 28)});
|
||||
code.push_back(EncodeSopc(0x09, 22, 21));
|
||||
if (masked) code.insert(code.end(), {
|
||||
EncodeVopc(0xc2, 249, 22), // Mask the FF1 sentinel into s2:s3.
|
||||
EncodeVopcSdwa(193, 2, 1, 6, 6, 0, 0, 0, 0, 0, 0, 1, 1),
|
||||
EncodeVop2(0x1c, 10, 253, 13), // SCC encoded as 0/1, OR per-lane done.
|
||||
EncodeVopc(0xc5, InlineU32(0), 10),
|
||||
EncodeSop2(0x11, 106, 106, 2),
|
||||
EncodeSop2(0x15, 126, 28, 106)});
|
||||
range_exit = code.size(); code.push_back(0u);
|
||||
}
|
||||
@@ -36621,7 +36624,8 @@ void CheckGuardedRecordImageTable(VulkanHarness &vulkan) {
|
||||
else test.opcodes.insert(test.opcodes.end(), {O::S_CMP_GE_U32, O::S_CBRANCH_SCC1,
|
||||
O::S_BITCMP1_B32});
|
||||
if (masked) test.opcodes.insert(test.opcodes.end(), {O::S_CSELECT_B64,
|
||||
O::V_OR_B32, O::V_CMP_NE_U32, O::S_ANDN2_B64, O::S_CBRANCH_EXECZ});
|
||||
O::V_CMP_EQ_U32, O::V_OR_B32, O::V_CMP_NE_U32, O::S_OR_B64,
|
||||
O::S_ANDN2_B64, O::S_CBRANCH_EXECZ});
|
||||
test.opcodes.insert(test.opcodes.end(), {O::S_MOV_B64, O::V_ADD_NC_U32});
|
||||
auto compiled = CompileCase(test, vulkan.SubgroupSize());
|
||||
const auto sampled_count = std::ranges::count_if(compiled.program.info.images,
|
||||
|
||||
Reference in New Issue
Block a user