Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions core/libs/prx/libSceAgcDriver/tests/BdaContracts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,26 @@ void RunBdaContractTests() {
program.BlockOrder().push_back(&block);
ValidateBdaTarget(program, target);
AgcDriver::Graphics::Require(!BdaInvocationsMayStop(program), "a BDA program with barriers must keep its invocations running");
for (const auto opcode : {IrOpcode::ReadLane, IrOpcode::WriteLane}) {
IrProgram lanes;
lanes.Resources().stage = IrShaderStage::Pixel;
auto& laneBlock = lanes.CreateBlock();
laneBlock.AppendInstruction(&lanes.CreateValue(opcode, IrType::U32));
lanes.BlockOrder().push_back(&laneBlock);
AgcDriver::Graphics::Require(!BdaInvocationsMayStop(lanes), std::string("a pixel program with ") + (opcode == IrOpcode::ReadLane ? "v_readlane" : "v_writelane") + " must keep its invocations running: a waterfall over a mask that holds a stopped lane never clears its bit");
}
IrProgram plain;
plain.Resources().stage = IrShaderStage::Pixel;
auto& plainBlock = plain.CreateBlock();
plainBlock.AppendInstruction(&plain.CreateValue(IrOpcode::ReadFirstLane, IrType::U32));
plain.BlockOrder().push_back(&plainBlock);
AgcDriver::Graphics::Require(BdaInvocationsMayStop(plain), "a BDA program with only v_readfirstlane must still stop a faulting invocation");
IrProgram computeLanes;
computeLanes.Resources().stage = IrShaderStage::Compute;
auto& computeBlock = computeLanes.CreateBlock();
computeBlock.AppendInstruction(&computeLanes.CreateValue(IrOpcode::ReadLane, IrType::U32));
computeLanes.BlockOrder().push_back(&computeBlock);
AgcDriver::Graphics::Require(BdaInvocationsMayStop(computeLanes), "a compute program with v_readlane and no barrier must still stop a faulting invocation");
program.Resources().stage = IrShaderStage::TessellationControl;
ValidateBdaTarget(program, target);
program.Resources().stage = IrShaderStage::Compute;
Expand Down
5 changes: 4 additions & 1 deletion core/shader/recompiler/SpirvBackend/src/SpirvBdaRead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,12 @@ void ValidateBdaTarget(const IrProgram& program, const SpirvTargetOptions& targe
}

bool BdaInvocationsMayStop(const IrProgram& program) {
const bool pixel = program.Resources().stage == IrShaderStage::Pixel;
for (const auto* block : program.BlockOrder()) {
for (const auto* instruction : block->Instructions()) {
if (instruction->Opcode() == IrOpcode::Barrier) return false;
const auto opcode = instruction->Opcode();
if (opcode == IrOpcode::Barrier) return false;
if (pixel && (opcode == IrOpcode::ReadLane || opcode == IrOpcode::WriteLane)) return false;
}
}
return true;
Expand Down
Loading