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
3 changes: 2 additions & 1 deletion core/libs/prx/libSceAgcDriver/Graphics/src/State.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,8 @@ void decodeDepth(const Registers& cx, std::uint32_t depthControl, State& result)
depth.lastSlice = (view >> 13u) & 0x7ffu;
depth.address = zFormat != 0 ? base(0x012, 0x01a) : 0;
depth.stencilAddress = stencil ? base(0x013, 0x01b) : 0;
Require(zFormat == 0 || depthReadOnly || base(0x014, 0x01c) == depth.address, "depth read and written at different addresses is unsupported");
const bool depthWritten = zFormat != 0 && !depthReadOnly && (depthClear || (depthControl & 6u) == 6u || (read(cx, 0x000) & 0x60u) != 0);
Require(!depthWritten || base(0x014, 0x01c) == depth.address, "depth read and written at different addresses is unsupported");
Require(!stencil || stencilReadOnly || base(0x015, 0x01d) == depth.stencilAddress, "stencil read and written at different addresses is unsupported");
if (depth.samples != 1u) {
depth.pipeBankXor = static_cast<std::uint32_t>(depth.address & 65535u);
Expand Down
17 changes: 17 additions & 0 deletions core/libs/prx/libSceAgcDriver/tests/Graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1727,6 +1727,23 @@ void DepthStencilTests() {
const auto rejection = AgcDriver::Graphics::DrawRejection(queue, false);
Require(rejection.empty(), "precheck rejected a stencil draw with a surface: " + rejection);
Require(state.depth && state.depth->address == 0x10000 && state.depth->stencilAddress == 0x20000 && state.depth->format == VK_FORMAT_D32_SFLOAT_S8_UINT && state.depth->clearStencil == 7 && state.depth->htileAddress == 0x10000030000ull && !state.depth->htileStencil, "depth surface decode changed");
{
auto split = queue;
split.context[0x014] = 0;
for (const auto control : {0x00700711u, 0x00700715u, 0x00700713u}) {
split.context[0x200] = control;
const auto splitState = AgcDriver::Graphics::DecodeState(split);
Require(splitState.depth && splitState.depth->address == 0x10000 && !splitState.depthWrite, "a depth plane the draw does not write rejected another write address");
Require(AgcDriver::Graphics::DrawRejection(split, false).empty(), "precheck rejected a depth plane the draw does not write at another write address");
}
split.context[0x200] = 0x00700717u;
expectFailure([&] { AgcDriver::Graphics::DecodeState(split); }, "depth read and written at different addresses");
split.context[0x200] = 0x00700711u;
for (const auto control : {0x01u, 0x20u, 0x40u, 0x60u}) {
split.context[0x000] = control;
expectFailure([&] { AgcDriver::Graphics::DecodeState(split); }, "depth read and written at different addresses");
}
}
for (const auto clear : {0u, 1u, 2u, 3u}) {
auto retained = queue;
retained.context[0x8e] = retained.context[0x8f] = retained.context[0x203] = 0;
Expand Down
2 changes: 2 additions & 0 deletions core/libs/prx/libSceAgcDriver/tests/Pm4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,9 @@ void testContextAndBases() {
expectFailure([&] { AgcDriver::Pm4::Validate(makePacket(0x15, {1, 1, 1, 0x2063}, 2), 0); }, "dispatch modifiers");
expectFailure([&] { AgcDriver::Pm4::Validate(makePacket(0x15, {1, 1, 1, 0x41}, 4), 0); }, "header flags");
AgcDriver::Pm4::Validate(makePacket(0x15, {1, 1, 1, 0x49}), 0);
AgcDriver::Pm4::Validate(makePacket(0x16, {0, 0x49}), 0);
expectFailure([&] { AgcDriver::Pm4::Validate(makePacket(0x15, {1, 1, 1, 0x51}), 0); }, "dispatch modifiers");
expectFailure([&] { AgcDriver::Pm4::Validate(makePacket(0x16, {0, 0x51}), 0); }, "indirect dispatch modifiers");
execute(state, makePacket(0x13, {32}));
execute(state, makePacket(0x26, {0x1000, 1}));
execute(state, makePacket(0x2a, {1}));
Expand Down
14 changes: 14 additions & 0 deletions core/libs/prx/libSceAgcDriver/tests/ShaderMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1328,6 +1328,20 @@ void verifyDescriptorPhis() {
sequential.context.memory = sequentialMemory.Regions();
static_cast<void>(Recompile(sequential, *sequentialCapture));

const auto planRestoredSampler = [&](std::span<const std::uint32_t> code, const char* message) {
auto request = makeRequest(code);
const auto plan = GetResourcePlan(request);
require(plan->info.samplers.size() == 1u && plan->info.sampledPairs.size() == 1u, message);
AgcDriver::ShaderMemory memory({});
const auto capture = memory.Capture(request);
request.context.memory = memory.Regions();
static_cast<void>(Recompile(request, *capture));
};
std::vector<std::uint32_t> restoredSamplerCode{0xf40c0200u, 0xfa000000u, 0xf4080500u, 0xfa000020u, 0xf4080600u, 0xfa000040u, 0xbe930380u, 0xbf8cc07fu, 0xf09c0f08u, 0x00a20400u, 0xbe900380u, 0xbe910380u, 0xbe9c0414u, 0xbe9e0416u, 0xbf068011u, 0xbf850001u, 0x80128112u, 0xbe94041cu, 0xbe96041eu, 0x80118111u, 0xbf0a8211u, 0xbf85fff6u, 0xf09c0f08u, 0x00a20000u, 0x80108110u, 0xbf0a8210u, 0xbf85fff0u, 0x80138113u, 0xbf0a8213u, 0xbf85ffecu, 0xbf8c3f70u, 0xe0700000u, 0x80060000u, 0xe0700000u, 0x80060400u, 0x7d880090u, 0xbea23c6au, 0x4a020081u, 0xe0700000u, 0x80060100u, 0xbf810000u};
planRestoredSampler(restoredSamplerCode, "descriptor Phi: an S# copied out and back in three nested loops was planned as more than one sampler");
restoredSamplerCode.erase(restoredSamplerCode.end() - 6, restoredSamplerCode.end() - 1);
planRestoredSampler(restoredSamplerCode, "descriptor Phi: an S# copied out and back in three nested loops without a masked write was planned as more than one sampler");

const auto entryWrites = [&](std::initializer_list<std::uint32_t> words) {
auto code = loopCode;
code.insert(code.begin() + 8, words);
Expand Down
5 changes: 3 additions & 2 deletions core/libs/prx/libSceAgcDriver/tests/WaveControlDecode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ void verifyDecode() {
require(decoded[11].op == RdnaOpcode::SCodeEnd, "s_code_end");
}

std::string recompile(std::span<const std::uint32_t> code) {
std::string recompile(std::span<const std::uint32_t> code, std::uint32_t subgroupSize = 64u) {
const std::array<std::uint32_t, 4> userData{0x10000000u, 0x00100000u, 0x40u, 0x00027facu};
const std::array<std::uint32_t, 2> capabilities{1u, 61u};
const std::array<std::string_view, 1> extensions{"SPV_KHR_storage_buffer_storage_class"};
Expand All @@ -74,7 +74,7 @@ std::string recompile(std::span<const std::uint32_t> code) {
request.context.compute = ShaderComputeStageInfo{{64u, 1u, 1u}, 0u, {false, false, false}, false, 1u};
request.target.vulkanVersion = 0x00403000u;
request.target.spirvVersion = 0x00010600u;
request.target.subgroupSize = 64u;
request.target.subgroupSize = subgroupSize;
request.target.bdaAbiVersion = 1;
request.target.supportedCapabilities = capabilities;
request.target.supportedExtensions = extensions;
Expand Down Expand Up @@ -104,6 +104,7 @@ void verifyTranslation() {
require(recompile(trailingLoop).empty(), "a program padded with s_code_end after its last branch is refused: " + recompile(trailingLoop));
const auto orderedAdd = withStore({0xd8fe0000u, 0x05000001u});
require(recompile(orderedAdd).empty(), "ds_ordered_count adding to a GDS counter is refused: " + recompile(orderedAdd));
require(recompile(orderedAdd, 32u).empty(), "ds_ordered_count of a wave64 on 32-lane subgroups is refused: " + recompile(orderedAdd, 32u));

const std::vector<std::tuple<std::string_view, std::vector<std::uint32_t>, std::string_view>> refused{
{"s_sethalt 1", withStore({0xbf8d0001u}), "s_sethalt 1 at pc 0 halts the wave"},
Expand Down
Loading