diff --git a/core/libs/prx/libSceAgcDriver/Execution/include/Pm4.hpp b/core/libs/prx/libSceAgcDriver/Execution/include/Pm4.hpp index 3e481e5f9174..826ae1f982d2 100644 --- a/core/libs/prx/libSceAgcDriver/Execution/include/Pm4.hpp +++ b/core/libs/prx/libSceAgcDriver/Execution/include/Pm4.hpp @@ -3,6 +3,7 @@ #include "prx/libSceAgcDriver/Execution/include/QueueState.hpp" #include "prx/libSceAgcDriver/Execution/include/Pm4Opcodes.hpp" +#include "RuntimeAbi.hpp" #include #include #include @@ -13,6 +14,10 @@ namespace AgcDriver::Pm4 { constexpr std::size_t GdsBytes = 0x10000; +constexpr std::size_t GdsOrderedTurnOffset = GdsBytes; +constexpr std::size_t GdsOrderedTimeoutsOffset = GdsBytes + sizeof(std::uint32_t); +constexpr std::size_t GdsBindingBytes = GdsBytes + ShaderRecompiler::RuntimeAbi::GdsMetadataDwords * sizeof(std::uint32_t); +constexpr std::size_t GdsAllocationBytes = (GdsBindingBytes + 0xffffu) & ~std::size_t{0xffffu}; std::uint64_t GdsAddress(); void RequestImportableGds(bool requested); bool ImportableGdsRequested(); diff --git a/core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp b/core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp index 37a7e4afd33a..8b44cfba2466 100644 --- a/core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp +++ b/core/libs/prx/libSceAgcDriver/Execution/src/Pm4.cpp @@ -60,17 +60,17 @@ std::uint64_t GdsAddress() { const char* const anonymousSharedMemory = reinterpret_cast(1); if (ImportableGdsRequested() && std::getenv("APS5_NO_SHARED_GDS") == nullptr) { if (const int descriptor = shm_open_nid_postfix(anonymousSharedMemory, OpenReadWrite, 0600); descriptor >= 0) { - void* shared = ftruncate_nid_postfix(descriptor, GdsBytes) == 0 ? mmap_nid_postfix(nullptr, GdsBytes, ReadWrite, Shared, descriptor, 0) : nullptr; + void* shared = ftruncate_nid_postfix(descriptor, GdsAllocationBytes) == 0 ? mmap_nid_postfix(nullptr, GdsAllocationBytes, ReadWrite, Shared, descriptor, 0) : nullptr; close_nid_postfix(descriptor); if (shared != nullptr && shared != reinterpret_cast(static_cast(-1))) { - std::memset(shared, 0, GdsBytes); + std::memset(shared, 0, GdsAllocationBytes); gdsShared.store(true, std::memory_order_release); gdsImportable.store(true, std::memory_order_release); return reinterpret_cast(shared); } } } - void* mapped = mmap_nid_postfix(nullptr, GdsBytes, ReadWrite, PrivateAnonymous, -1, 0); + void* mapped = mmap_nid_postfix(nullptr, GdsAllocationBytes, ReadWrite, PrivateAnonymous, -1, 0); if (mapped == nullptr || mapped == reinterpret_cast(static_cast(-1))) throw std::runtime_error("cannot allocate the global data share"); return reinterpret_cast(mapped); }(); diff --git a/core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp b/core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp index 518c96818d08..5d500de90cd2 100644 --- a/core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp +++ b/core/libs/prx/libSceAgcDriver/Execution/src/VulkanDevice.cpp @@ -2714,7 +2714,7 @@ VulkanDevice::VulkanDevice(const PresentationWindow* window, bool compileOnly) : std::ranges::fill(state->emptyBuffer->Bytes(), std::byte{0}); state->oversizedBuffer = std::make_unique(graphicsContext(), Graphics::EmptyBufferBytes, VK_BUFFER_USAGE_STORAGE_BUFFER_BIT); std::ranges::fill(state->oversizedBuffer->Bytes(), std::byte{0}); - if (!compileOnly && Pm4::GdsImportable() && Graphics::HostImportFor(graphicsContext(), Pm4::GdsAddress(), Pm4::GdsBytes, Graphics::ImportRequester::Map) == nullptr) Pm4::RejectGdsImport(); + if (!compileOnly && Pm4::GdsImportable() && Graphics::HostImportFor(graphicsContext(), Pm4::GdsAddress(), Pm4::GdsAllocationBytes, Graphics::ImportRequester::Map) == nullptr) Pm4::RejectGdsImport(); if (!state->imageInt64Atomics || !state->bufferInt64Atomics) { state->atomicLockTable = std::make_unique(graphicsContext(), ShaderRecompiler::RuntimeAbi::AtomicLockCount * sizeof(std::uint32_t), VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT); const auto words = state->atomicLockTable->Bytes(); @@ -6050,6 +6050,14 @@ void VulkanDevice::recordDispatch(RecordedDispatch& record) { if (record.pushStages != 0) { context.Resolved(&Graphics::DeviceFunctions::cmdPushConstants, "vkCmdPushConstants")(commands, record.objects->layout, VK_SHADER_STAGE_COMPUTE_BIT, 0, Graphics::ComputePushConstantBytes, record.pushBytes->data()); } + const auto orderedTurn = record.shader->program->orderedAppend ? std::optional(resources.guestFillTarget(Pm4::GdsAddress() + Pm4::GdsOrderedTurnOffset, sizeof(std::uint32_t))) : std::nullopt; + const auto resetOrderedTurn = [&] { + if (!orderedTurn.has_value()) return; + Graphics::RecordMemoryBarrier(context, commands, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT, VK_ACCESS_TRANSFER_WRITE_BIT); + context.Resolved(&Graphics::DeviceFunctions::cmdFillBuffer, "vkCmdFillBuffer")(commands, orderedTurn->buffer, orderedTurn->offset, orderedTurn->range, 0u); + Graphics::RecordMemoryBarrier(context, commands, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT); + }; + resetOrderedTurn(); static const bool reportingDispatch = LibcRunReportEnabled_nid_no_patch(); if (reportingDispatch) recorder.NoteGuestWork(commands); const auto gpuTiming = recorder.BeginGpuTiming(record.programAddress != 0 ? record.programAddress : record.shader->program->variantId); @@ -6122,6 +6130,7 @@ void VulkanDevice::recordDispatch(RecordedDispatch& record) { if (!firstChunk) { Graphics::RecordMemoryBarrier(context, commands, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VK_ACCESS_SHADER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT); context.BindComputePipeline(commands, splitComputePipeline(context, *record.shader->program, *record.objects, {xBase, yBase, zBase})); + resetOrderedTurn(); } firstChunk = false; dispatchChunk(commands, std::min(limit[0], record.x - xBase), std::min(limit[1], record.y - yBase), std::min(limit[2], record.z - zBase)); diff --git a/core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp b/core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp index fe69164a7663..1faed66a9ee2 100644 --- a/core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp +++ b/core/libs/prx/libSceAgcDriver/Graphics/include/GuestBufferMemory.hpp @@ -385,6 +385,7 @@ class GuestBufferMemory { // element the shader updates atomically (DescriptorBinding::bufferAtomic), staged in device // memory whatever its size (see AllowDeviceStaging). void AddWritable(std::uint64_t address, std::size_t bytes, bool atomic = false, bool swept = false); + void AddFillTarget(std::uint64_t address, std::size_t bytes); void AddReadable(std::uint64_t address, std::size_t bytes); // Device-local staging of written and atomic elements inside host imports (see // GuestBufferMemory.cpp): allowed only for a build whose every use records its work and then @@ -415,6 +416,7 @@ class GuestBufferMemory { void UploadPrepare(bool addressable); void UploadFinish(bool addressable, std::optional> htileClear = std::nullopt); VkDescriptorBufferInfo Descriptor(std::uint64_t address, std::size_t bytes, std::uint32_t& adjustment) const; + VkDescriptorBufferInfo FillTarget(std::uint64_t address, std::size_t bytes) const; static std::uint64_t ViewBytes(std::uint64_t bytes, std::uint32_t adjustment); std::vector AddressRanges() const; // The BDA table of the cached address space when it serves this upload alone (an address-based @@ -648,6 +650,7 @@ class GuestBufferMemory { bool regionsSorted = false; bool regionsOverlap = false; std::vector> writes; + std::vector> fillTargets; std::vector> reads; std::vector> readsOverBase; std::vector> servedInsideBase; diff --git a/core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp b/core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp index dadd3172f159..df6dac35aeac 100644 --- a/core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp +++ b/core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hpp @@ -304,6 +304,7 @@ class ShaderResources { void CopyBacksAfterRun(std::shared_ptr self) { afterRunSelf = std::move(self); } void RunAccesses(std::vector>& out) const; bool HoldsLease() const { return guestMemory.HoldsLease(); } + VkDescriptorBufferInfo guestFillTarget(std::uint64_t address, std::size_t bytes) const { return guestMemory.FillTarget(address, bytes); } bool SpaceReuse() const { return spaceReuse; } static bool SpaceReuseDisabled(); bool BdaReadOnly() const { return usesBda && bdaReadOnly; } diff --git a/core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp b/core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp index 7a051a623b40..414541f57c0b 100644 --- a/core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp +++ b/core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp @@ -5940,6 +5940,10 @@ void GuestBufferMemory::AddWritable(std::uint64_t address, std::size_t bytes, bo writes.emplace_back(address, address + bytes); } +void GuestBufferMemory::AddFillTarget(std::uint64_t address, std::size_t bytes) { + fillTargets.emplace_back(address, address + bytes); +} + void GuestBufferMemory::AddReadable(std::uint64_t address, std::size_t bytes) { // Not in `writes`: no reference copy (copyRegion), no write-back, no pending-write note, no // direct-write mark, and UploadPrepare copies it without the device lock. A written descriptor @@ -7026,7 +7030,8 @@ void GuestBufferMemory::UploadFinish(bool addressable, std::optionalmirror == nullptr, "a guest fill target served by an image mirror is not implemented"); + std::uint32_t adjustment = 0; + const auto info = Descriptor(address, bytes, adjustment); + return {info.buffer, info.offset + adjustment, bytes}; +} + std::uint64_t GuestBufferMemory::ViewBytes(std::uint64_t bytes, std::uint32_t adjustment) { if (adjustment % 4 == 0) return bytes + adjustment; const auto dwords = adjustment / 4 + bytes / 4 + (adjustment % 4 + bytes % 4 + 3) / 4; diff --git a/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp b/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp index 09ad266db200..bc6d051aad9f 100644 --- a/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp +++ b/core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cpp @@ -2575,9 +2575,10 @@ void ShaderResources::buildPrepare(std::span shaders, cons } else if (binding.role == ShaderRecompiler::DescriptorRole::Gds) { Require(binding.count == 1 && binding.guestDescriptor.empty(), "invalid GDS descriptor contract"); const auto gds = Pm4::GdsAddress(); - guestMemory.AddWritable(gds, Pm4::GdsBytes, true); + guestMemory.AddWritable(gds, Pm4::GdsBindingBytes, true); + guestMemory.AddFillTarget(gds + Pm4::GdsOrderedTurnOffset, sizeof(std::uint32_t)); item.allocations.push_back(allocations.size()); - allocations.push_back({gds, Pm4::GdsBytes, true, nullptr, ShaderRecompiler::DescriptorRole::ShaderData, true}); + allocations.push_back({gds, Pm4::GdsBindingBytes, true, nullptr, ShaderRecompiler::DescriptorRole::ShaderData, true}); } else { Require(binding.count == 1, "shader data and flattened SRT descriptors must not be arrays"); Require(!binding.guestDescriptor.empty(), "empty shader data descriptor"); diff --git a/core/libs/prx/libSceAgcDriver/tests/GuardedMemoryLoads.cpp b/core/libs/prx/libSceAgcDriver/tests/GuardedMemoryLoads.cpp index 4b7974157068..36983ea3ee0e 100644 --- a/core/libs/prx/libSceAgcDriver/tests/GuardedMemoryLoads.cpp +++ b/core/libs/prx/libSceAgcDriver/tests/GuardedMemoryLoads.cpp @@ -1,6 +1,7 @@ #define SPV_ENABLE_UTILITY_CODE #include #undef SPV_ENABLE_UTILITY_CODE +#include "RuntimeAbi.hpp" #include "IntermediateRepresentation/IrProgram.hpp" #include "Optimization/ShaderStageInputInfo.hpp" #include "SpirvBackend/SpirvEmitter.hpp" @@ -262,7 +263,7 @@ class AccessTrace { case spv::OpLogicalNot: return !argument(3); case spv::OpArrayLength: require(isGuestPointer(instruction[3]), "unknown array length in access fixture"); - return rootName(instruction[3]) == "scratch_pool" ? PoolDwords : 16; + return rootName(instruction[3]) == "scratch_pool" ? PoolDwords : rootName(instruction[3]) == "gds" ? 16 + RuntimeAbi::GdsMetadataDwords : 16; case spv::OpUDiv: return argument(3) / argument(4); case spv::OpAtomicIDecrement: return 0; case spv::OpLoad: diff --git a/core/libs/prx/libSceAgcDriver/tests/Pm4.cpp b/core/libs/prx/libSceAgcDriver/tests/Pm4.cpp index 9df8da5dd508..c9149901ca61 100644 --- a/core/libs/prx/libSceAgcDriver/tests/Pm4.cpp +++ b/core/libs/prx/libSceAgcDriver/tests/Pm4.cpp @@ -2908,6 +2908,19 @@ int main(int argc, char** argv) { std::puts("PM4 asynchronous memory failure propagated to idle, suspend, submit and shutdown"); return 0; } + if (argc == 2 && std::string(argv[1]) == "shared-gds-pages") { + AgcDriver::Pm4::RequestImportableGds(true); + const auto gds = AgcDriver::Pm4::GdsAddress(); + if (!AgcDriver::Pm4::GdsShared()) { + std::puts("shared memory is unavailable, so the shared GDS mapping is not checked"); + return 77; + } + constexpr std::size_t unit = 0x10000; + const auto covered = (AgcDriver::Pm4::GdsBindingBytes + unit - 1) & ~(unit - 1); + check(AgcDriver::GuestMemory::Accessible(reinterpret_cast(gds), covered, true), "the shared GDS mapping does not cover the whole 64 KiB unit that holds its binding, so a host import of it runs past the end of its file"); + std::puts("PM4 shared GDS pages test passed"); + return 0; + } if (argc == 2 && std::string(argv[1]) == "priority-refused") { testRefusedWorkerPriority(); std::puts("PM4 refused queue worker priority propagated to idle and shutdown"); diff --git a/core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_gds_append_consume_tests.cmake b/core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_gds_append_consume_tests.cmake new file mode 100644 index 000000000000..2524f21f4097 --- /dev/null +++ b/core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_gds_append_consume_tests.cmake @@ -0,0 +1,8 @@ +if(BUILD_TESTING) + add_test(NAME agc_driver_gds_append_consume_copied COMMAND agc_driver_gds_append_consume_tests) + set_tests_properties(agc_driver_gds_append_consume_copied PROPERTIES TIMEOUT 60 ENVIRONMENT "ANYPS5_NO_SHADER_CACHE=1;APS5_NO_HOST_IMPORT=1;APS5_NO_SHARED_GDS=1" SKIP_RETURN_CODE 77 WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}") + if(WIN32) + set_tests_properties(agc_driver_gds_append_consume_copied PROPERTIES ENVIRONMENT_MODIFICATION + "PATH=path_list_prepend:$") + endif() +endif() diff --git a/core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_graphics_tests.cmake b/core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_graphics_tests.cmake index 85bee544432b..98e3d8553e99 100644 --- a/core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_graphics_tests.cmake +++ b/core/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_graphics_tests.cmake @@ -212,6 +212,8 @@ if(BUILD_TESTING) endif() add_test(NAME agc_driver_pm4_failure COMMAND agc_driver_pm4_tests failure) set_tests_properties(agc_driver_pm4_failure PROPERTIES ENVIRONMENT "ANYPS5_NO_SHADER_CACHE=1" SKIP_RETURN_CODE 77 TIMEOUT 30) + add_test(NAME agc_driver_pm4_shared_gds_pages COMMAND agc_driver_pm4_tests shared-gds-pages) + set_tests_properties(agc_driver_pm4_shared_gds_pages PROPERTIES ENVIRONMENT "ANYPS5_NO_SHADER_CACHE=1" SKIP_RETURN_CODE 77 TIMEOUT 30) set(pm4RingCases "ring|APS5_PM4_RING=4" "ring-empty|APS5_PM4_RING=16" "ring-disabled|APS5_PM4_RING=0" "ring-invalid|APS5_PM4_RING=4x" "ring-report|APS5_PM4_RING=2" "stall-watchdog|APS5_STALL_WATCHDOG_SECS=1" "stall-watchdog-invalid|APS5_STALL_WATCHDOG_SECS=1x" "stall-watchdog-rewind|APS5_STALL_WATCHDOG_SECS=1" "stall-watchdog-order|APS5_STALL_WATCHDOG_SECS=1" "stall-clock|APS5_STALL_WATCHDOG_SECS=1" "stall-prompt-invalid|ANYPS5_STALL_PROMPT=2" "stall-prompt-off|APS5_STALL_WATCHDOG_SECS=1" "stall-prompt-zero|APS5_STALL_WATCHDOG_SECS=1,ANYPS5_STALL_PROMPT=0" "stall-prompt-rearm|APS5_STALL_WATCHDOG_SECS=1,ANYPS5_STALL_PROMPT=1" "stall-prompt-real|APS5_STALL_WATCHDOG_SECS=1,ANYPS5_STALL_PROMPT=1" "stall-prompt-reentry|APS5_STALL_WATCHDOG_SECS=1,ANYPS5_STALL_PROMPT=1" "stall-prompt-quit|APS5_STALL_WATCHDOG_SECS=1,ANYPS5_STALL_PROMPT=1" diff --git a/core/libs/prx/libSceAgcDriver/tests/execution/GdsAppendConsume.cpp b/core/libs/prx/libSceAgcDriver/tests/execution/GdsAppendConsume.cpp index 08d1c787778c..6348484b1670 100644 --- a/core/libs/prx/libSceAgcDriver/tests/execution/GdsAppendConsume.cpp +++ b/core/libs/prx/libSceAgcDriver/tests/execution/GdsAppendConsume.cpp @@ -65,6 +65,98 @@ alignas(256) auto OrderedCode = std::to_array({ 0xbf810000, }); +constexpr std::uint32_t OrderedGroups = 64; +constexpr std::uint32_t OrderedGroupLanes = 32; +constexpr std::uint32_t OrderedGroupPasses = 8; +constexpr std::uint32_t MultiWaveGroups = 16; +constexpr std::uint32_t MultiWaveGroupLanes = 128; +constexpr std::uint32_t TimeoutGroups = 4; +constexpr std::uint32_t SkippedGroup = 1; +constexpr std::size_t GroupShiftLiteral = 2; +constexpr std::uint32_t SingleWaveShift = 0x8f058704u; +constexpr std::uint32_t MultiWaveShift = 0x8f058904u; +alignas(256) std::array GroupOutput{}; + +alignas(256) auto OrderedGroupCode = std::to_array({ + 0x7e0a02ff, UntouchedOrdered, + 0x8f058704, + 0xbefc03ff, 0x0000ffff, + 0x7e0202ff, 0x00000001, + OrderedAdd, 0x05000001, + 0xbf8cc07f, + 0xe0702000, 0x05000500, + 0xbf810000, +}); + +alignas(256) auto DelayedFirstGroupCode = std::to_array({ + 0x7e0a02ff, UntouchedOrdered, + SingleWaveShift, + 0xbefc03ff, 0x0000ffff, + 0xbe860380, + 0xbf078004, + 0xbf850005, + 0xbe8603ff, 0x00040000, + 0x80868106, + 0xbf078006, + 0xbf85fffd, + 0x7e0202ff, 0x00000001, + 0x4a020206, + OrderedAdd, 0x05000001, + 0xbf8cc07f, + 0xe0702000, 0x05000500, + 0xbf810000, +}); + +alignas(256) auto SkippedGroupCode = std::to_array({ + 0x7e0a02ff, UntouchedOrdered, + SingleWaveShift, + 0xbefc03ff, 0x0000ffff, + 0x7e0202ff, 0x00000001, + 0xbf060004u | (SkippedGroup + 0x80u) << 8u, + 0xbf850002, + OrderedAdd, 0x05000001, + 0xbf8cc07f, + 0xe0702000, 0x05000500, + 0xbf810000, +}); + +constexpr std::uint32_t LastGuestDword = AgcDriver::Pm4::GdsBytes - 4u; +constexpr std::uint32_t LastGuestValue = 0x1234u; +constexpr std::uint32_t TurnSentinel = 0x7777u; + +alignas(256) auto BoundaryCode = std::to_array({ + 0x34120082, + 0xbefc03ff, 0x0000ffff, + 0x7e1002ff, LastGuestDword, + 0x7e0602ff, AgcDriver::Pm4::GdsBytes, + 0x7e0802ff, 0x00000bad, + 0x7e0e0281, + 0xd8da0000, 0x01000008, + 0xd8da0000, 0x02000003, + 0xd8360000, 0x00000403, + 0xd8820000, 0x05000403, + 0xd8820000, 0x06000708, + 0xbf8cc07f, + 0xe0702000, 0x80000109, 0xe0702004, 0x80000209, 0xe0702008, 0x80000509, 0xe070200c, 0x80000609, + 0xbf810000, +}); + +constexpr std::uint32_t ChunkSkippedRow = 1; +alignas(256) std::array ChunkOutput{}; + +alignas(256) auto ChunkSkipCode = std::to_array({ + 0x7e0a02ff, UntouchedOrdered, + 0x8f068705, + 0xbefc03ff, 0x0000ffff, + 0x7e0202ff, 0x00000001, + 0xbf060005u | (ChunkSkippedRow + 0x80u) << 8u, + 0xbf850002, + OrderedAdd, 0x05000001, + 0xbf8cc07f, + 0xe0702000, 0x06000500, + 0xbf810000, +}); + struct OrderedRun { std::uint32_t m0; std::uint32_t firstLaneEighths; @@ -130,6 +222,154 @@ void Run(AgcDriver::VulkanDevice& device, const Workgroup& workgroup, std::span< device.WaitIdle(); } +std::uint32_t OrderedTimeouts() { + return *reinterpret_cast(AgcDriver::Pm4::GdsAddress() + AgcDriver::Pm4::GdsOrderedTimeoutsOffset); +} + +void RunGroups(AgcDriver::VulkanDevice& device, std::span code, std::uint32_t groups = OrderedGroups, std::uint32_t lanes = OrderedGroupLanes) { + GroupOutput.fill(0xdeadbeefu); + std::vector userData(4, 0u); + const auto output = BufferDescriptor(GroupOutput.data(), static_cast(GroupOutput.size())); + std::copy(output.begin(), output.end(), userData.begin()); + const std::array memory{{{reinterpret_cast(code.data()), std::as_bytes(code)}}}; + const ShaderRecompiler::ShaderComputeStageInfo compute{{lanes, 1, 1}, 0, {true, false, false}, false, 1}; + ShaderRecompiler::RecompileRequest request{ + {ShaderStage::Compute, reinterpret_cast(code.data()), code, 0, {}}, + {32, 0, userData, compute, std::nullopt, std::nullopt, memory}, + device.Target(), + {0, 0, 0, 128} + }; + request.useCache = false; + const auto result = ShaderRecompiler::Recompile(request); + device.Dispatch(result, groups, 1, 1, {}, reinterpret_cast(code.data())); + device.WaitIdle(); +} + +void CheckOrderedGroups(const std::string& what, std::uint32_t start, const std::array& counters, std::uint32_t timeoutsBefore, std::uint32_t groups = OrderedGroups, std::uint32_t lanes = OrderedGroupLanes) { + const auto waves = lanes / OrderedGroupLanes; + for (std::uint32_t group = 0; group < groups; ++group) { + for (std::uint32_t lane = 0; lane < lanes; ++lane) { + const auto actual = GroupOutput[group * lanes + lane]; + const auto expected = start + group * waves + lane / OrderedGroupLanes; + Require(actual == expected, what + ": group " + std::to_string(group) + " lane " + std::to_string(lane) + " returned " + std::to_string(actual) + ", expected " + std::to_string(expected) + " (the counter in launch order)"); + } + } + Require(counters[0] == start + groups * waves, what + ": GDS counter 0 is " + std::to_string(counters[0]) + ", expected " + std::to_string(start + groups * waves)); + Require(OrderedTimeouts() == timeoutsBefore, what + ": " + std::to_string(OrderedTimeouts() - timeoutsBefore) + " waves gave up waiting for their turn"); +} + +void CheckSkippedGroup(std::uint32_t start, const std::array& counters, std::uint32_t timeoutsBefore) { + const auto what = std::to_string(TimeoutGroups) + " single-wave groups, group " + std::to_string(SkippedGroup) + " skips ds_ordered_count"; + std::vector seen; + std::vector expected; + for (std::uint32_t group = 0; group < TimeoutGroups; ++group) { + const auto value = GroupOutput[group * OrderedGroupLanes]; + for (std::uint32_t lane = 0; lane < OrderedGroupLanes; ++lane) { + const auto actual = GroupOutput[group * OrderedGroupLanes + lane]; + Require(actual == value, what + ": group " + std::to_string(group) + " lane " + std::to_string(lane) + " returned " + std::to_string(actual) + ", its lane 0 " + std::to_string(value)); + } + if (group < SkippedGroup) { + Require(value == start + group, what + ": group " + std::to_string(group) + " before the skipped one returned " + std::to_string(value) + ", expected " + std::to_string(start + group)); + } else if (group == SkippedGroup) { + Require(value == UntouchedOrdered, what + ": the skipped group was written " + std::to_string(value)); + } else { + seen.push_back(value); + expected.push_back(start + group - 1u); + } + } + std::sort(seen.begin(), seen.end()); + Require(seen == expected, what + ": the groups after the skipped one did not each get one of the remaining counter values"); + Require(counters[0] == start + TimeoutGroups - 1u, what + ": GDS counter 0 is " + std::to_string(counters[0]) + ", expected " + std::to_string(start + TimeoutGroups - 1u)); + const auto timeouts = OrderedTimeouts() - timeoutsBefore; + Require(timeouts == TimeoutGroups - SkippedGroup - 1u, what + ": " + std::to_string(timeouts) + " waves gave up waiting for their turn, expected " + std::to_string(TimeoutGroups - SkippedGroup - 1u) + " (every wave after the skipped one, none of them passing the turn on)"); +} + +volatile std::uint32_t& GdsMetadata(std::size_t offset) { + return *reinterpret_cast(AgcDriver::Pm4::GdsAddress() + offset); +} + +std::uint32_t ReadGdsDword(AgcDriver::QueueState& queue, std::uint32_t offset) { + CounterReadback.fill(0xdeadbeefu); + const auto address = reinterpret_cast(CounterReadback.data()); + Execute(queue, Packet(0x50, {0x20000000u, offset, 0, static_cast(address), static_cast(address >> 32u), 4u})); + return CounterReadback[0]; +} + +void CheckBoundary(AgcDriver::VulkanDevice& device, AgcDriver::QueueState& queue) { + const std::string what = "ordinary GDS accesses at the last guest dword and one past it"; + Execute(queue, Packet(0x50, {0x40100000u, LastGuestValue, 0, LastGuestDword, 0, 4})); + GdsMetadata(AgcDriver::Pm4::GdsOrderedTurnOffset) = TurnSentinel; + const std::uint32_t timeouts = OrderedTimeouts(); + Run(device, Workgroups[0], BoundaryCode); + std::vector added; + for (std::uint32_t lane = 0; lane < Workgroups[0].threads; ++lane) { + const auto* result = &Output[lane * Results]; + Require(result[0] == LastGuestValue, what + ": lane " + std::to_string(lane) + " read " + std::to_string(result[0]) + " at the last guest dword, expected " + std::to_string(LastGuestValue)); + Require(result[1] == 0u, what + ": lane " + std::to_string(lane) + " read " + std::to_string(result[1]) + " past the guest GDS, expected 0"); + Require(result[2] == 0u, what + ": lane " + std::to_string(lane) + "'s atomic add past the guest GDS returned " + std::to_string(result[2]) + ", expected 0"); + added.push_back(result[3]); + } + std::sort(added.begin(), added.end()); + for (std::uint32_t lane = 0; lane < added.size(); ++lane) Require(added[lane] == LastGuestValue + lane, what + ": the atomic adds at the last guest dword did not each return one of the values in turn"); + const auto last = ReadGdsDword(queue, LastGuestDword); + Require(last == LastGuestValue + Workgroups[0].threads, what + ": the last guest dword is " + std::to_string(last) + " after the adds, expected " + std::to_string(LastGuestValue + Workgroups[0].threads)); + Require(GdsMetadata(AgcDriver::Pm4::GdsOrderedTurnOffset) == TurnSentinel, what + ": a write or atomic past the guest GDS changed the ordered-append turn"); + Require(OrderedTimeouts() == timeouts, what + ": a write or atomic past the guest GDS changed the ordered-append timeout count"); +} + +std::string CheckChunkedRecovery(AgcDriver::VulkanDevice& device, AgcDriver::QueueState& queue) { + const auto limit = device.graphicsContext().limits.maxComputeWorkGroupCount[1]; + if (limit >= ChunkOutput.size() / OrderedGroupLanes) { + const auto note = "split-dispatch case skipped: the device dispatches " + std::to_string(limit) + " workgroups along y in one chunk"; + std::puts(note.c_str()); + return note; + } + const std::uint32_t rows = limit + 2u; + const std::string what = std::to_string(rows) + " single-wave groups along y in chunks of " + std::to_string(limit) + ", row " + std::to_string(ChunkSkippedRow) + " skips ds_ordered_count"; + SetCounters(queue); + const auto timeouts = OrderedTimeouts(); + ChunkOutput.fill(0xdeadbeefu); + std::vector userData(4, 0u); + const auto output = BufferDescriptor(ChunkOutput.data(), static_cast(ChunkOutput.size())); + std::copy(output.begin(), output.end(), userData.begin()); + const std::array memory{{{reinterpret_cast(ChunkSkipCode.data()), std::as_bytes(std::span(ChunkSkipCode))}}}; + const ShaderRecompiler::ShaderComputeStageInfo compute{{OrderedGroupLanes, 1, 1}, 0, {true, true, false}, false, 1}; + ShaderRecompiler::RecompileRequest request{ + {ShaderStage::Compute, reinterpret_cast(ChunkSkipCode.data()), ChunkSkipCode, 0, {}}, + {32, 0, userData, compute, std::nullopt, std::nullopt, memory}, + device.Target(), + {0, 0, 0, 128} + }; + request.useCache = false; + const auto result = ShaderRecompiler::Recompile(request); + device.Dispatch(result, 1, rows, 1, {}, reinterpret_cast(ChunkSkipCode.data())); + device.WaitIdle(); + const auto start = Starts[0]; + const auto rowZero = ChunkOutput[0]; + const bool lateStart = rowZero != start && rowZero > start + limit / 2u && rowZero < start + rows; + if (!lateStart) Require(rowZero == start, what + ": row 0 returned " + std::to_string(rowZero) + ", expected " + std::to_string(start)); + Require(ChunkOutput[ChunkSkippedRow * OrderedGroupLanes] == UntouchedOrdered, what + ": the skipped row was written"); + for (std::uint32_t row = limit; row < rows; ++row) { + const auto expected = start + row - 1u; + Require(ChunkOutput[row * OrderedGroupLanes] == expected, what + ": row " + std::to_string(row) + " in the second chunk returned " + std::to_string(ChunkOutput[row * OrderedGroupLanes]) + ", expected " + std::to_string(expected) + " (the second chunk is ordered after the reset)"); + } + const auto counters = ReadCounters(queue); + Require(counters[0] == start + rows - 1u, what + ": GDS counter 0 is " + std::to_string(counters[0]) + ", expected " + std::to_string(start + rows - 1u)); + const auto unordered = OrderedTimeouts() - timeouts; + if (!lateStart) { + Require(unordered == limit - ChunkSkippedRow - 1u, what + ": " + std::to_string(unordered) + " waves ran unordered, expected " + std::to_string(limit - ChunkSkippedRow - 1u) + " (the first chunk's rows after the skipped one, none of the second chunk's)"); + return {}; + } + std::uint32_t firstRow = rows; + for (std::uint32_t row = 0; row < rows && firstRow == rows; ++row) { + if (ChunkOutput[row * OrderedGroupLanes] == start) firstRow = row; + } + char note[320]; + std::snprintf(note, sizeof(note), "split-dispatch row 0 and unordered-count checks skipped: row 0 was served late (it returned %u, %u values were handed out before it, the first went to row %u, %u waves ran unordered); the ordering assumes waves start in WorkgroupId order, which Vulkan does not guarantee", rowZero, rowZero - start, firstRow, unordered); + std::puts(note); + return note; +} + void CheckWaves(const Workgroup& workgroup, std::uint32_t result, std::uint32_t start, bool append, bool masked) { const auto waves = workgroup.threads / workgroup.waveSize; std::vector values(waves); @@ -260,7 +500,38 @@ int main() { CheckOrderedSwap(workgroup, run.m0, firstLane, ReadCounters(queue)); } } - std::puts("gds append consume tests passed"); + SetCounters(queue); + for (std::uint32_t pass = 0; pass < OrderedGroupPasses; ++pass) { + const auto timeouts = OrderedTimeouts(); + RunGroups(*device, OrderedGroupCode); + CheckOrderedGroups(std::to_string(OrderedGroups) + " single-wave groups, dispatch " + std::to_string(pass + 1u) + ", ds_ordered_count", Starts[0] + pass * OrderedGroups, ReadCounters(queue), timeouts); + } + SetCounters(queue); + auto timeouts = OrderedTimeouts(); + DelayedFirstGroupCode[GroupShiftLiteral] = SingleWaveShift; + RunGroups(*device, DelayedFirstGroupCode); + CheckOrderedGroups(std::to_string(OrderedGroups) + " single-wave groups, group 0 delayed, ds_ordered_count", Starts[0], ReadCounters(queue), timeouts); + SetCounters(queue); + timeouts = OrderedTimeouts(); + DelayedFirstGroupCode[GroupShiftLiteral] = MultiWaveShift; + RunGroups(*device, DelayedFirstGroupCode, MultiWaveGroups, MultiWaveGroupLanes); + CheckOrderedGroups(std::to_string(MultiWaveGroups) + " groups of " + std::to_string(MultiWaveGroupLanes / OrderedGroupLanes) + " waves, group 0 delayed, ds_ordered_count", Starts[0], ReadCounters(queue), timeouts, MultiWaveGroups, MultiWaveGroupLanes); + SetCounters(queue); + timeouts = OrderedTimeouts(); + RunGroups(*device, SkippedGroupCode, TimeoutGroups); + CheckSkippedGroup(Starts[0], ReadCounters(queue), timeouts); + SetCounters(queue); + timeouts = OrderedTimeouts(); + RunGroups(*device, OrderedGroupCode); + CheckOrderedGroups(std::to_string(OrderedGroups) + " single-wave groups after a dispatch whose waves timed out, ds_ordered_count", Starts[0], ReadCounters(queue), timeouts); + const auto chunkNote = CheckChunkedRecovery(*device, queue); + SetCounters(queue); + timeouts = OrderedTimeouts(); + RunGroups(*device, OrderedGroupCode); + CheckOrderedGroups(std::to_string(OrderedGroups) + " single-wave groups after a split dispatch whose first chunk abandoned the turn, ds_ordered_count", Starts[0], ReadCounters(queue), timeouts); + CheckBoundary(*device, queue); + if (chunkNote.empty()) std::puts("gds append consume tests passed"); + else std::printf("gds append consume tests passed (%s)\n", chunkNote.c_str()); return 0; } catch (const std::exception& error) { std::cerr << error.what() << '\n'; diff --git a/core/shader/recompiler/IntermediateRepresentation/src/IrOpcode.cpp b/core/shader/recompiler/IntermediateRepresentation/src/IrOpcode.cpp index ef189a240860..59f3a9d80130 100644 --- a/core/shader/recompiler/IntermediateRepresentation/src/IrOpcode.cpp +++ b/core/shader/recompiler/IntermediateRepresentation/src/IrOpcode.cpp @@ -489,8 +489,8 @@ constexpr std::array(IrOpcode::Count)> Meta makeMeta("SharedAtomicMskor64", U64, U32, U64, U64, U1), makeMeta("DataAppend", U32, U32, U1, U32, U32), makeMeta("DataConsume", U32, U32, U1, U32, U32), - makeMeta("DataOrderedCount", U32, U32, U1, U32, U32, U32), - makeMeta("DataOrderedSwap", U32, U32, U1, U32, U32, U32), + makeMeta("DataOrderedCount", U32, U32, U1, U32, U32, U32, U32), + makeMeta("DataOrderedSwap", U32, U32, U1, U32, U32, U32, U32), makeMeta("SwizzleU32", U32, U32, U32, U1), makeMeta("ImageQueryDimensions", U32x4, ImageResource, ImageAddress, U1), makeMeta("ImageQueryLod", U32x4, ImageResource, SamplerResource, ImageAddress, U1), diff --git a/core/shader/recompiler/Recompiler.cpp b/core/shader/recompiler/Recompiler.cpp index 4b23e77588aa..1997591b2316 100644 --- a/core/shader/recompiler/Recompiler.cpp +++ b/core/shader/recompiler/Recompiler.cpp @@ -926,6 +926,7 @@ CompiledVariant emitVariant(const RecompileRequest& request, IrProgram& program) result.functionLdsBuffer = emitted.functionLdsBuffer; result.meshWindowBuffer = emitted.meshWindowBuffer; result.scratchPoolSlotDwords = emitted.scratchPoolSlotDwords; + result.orderedAppend = emitted.orderedAppend; result.vertexOffsetSgpr = program.Info().vertexOffsetSgpr; result.instanceOffsetSgpr = program.Info().instanceOffsetSgpr; result.vertexOffsetShared = program.Info().vertexOffsetShared; @@ -1393,6 +1394,7 @@ RecompileResult materializeResult(const CompiledVariant& variant, const Recompil .fullSubgroups = artifact.fullSubgroups, .functionLdsBuffer = artifact.functionLdsBuffer, .meshWindowBuffer = artifact.meshWindowBuffer, + .orderedAppend = artifact.orderedAppend, .scratchPoolSlotDwords = artifact.scratchPoolSlotDwords, .parameterExports = artifact.parameterExports, .fragmentParameters = artifact.fragmentParameters, diff --git a/core/shader/recompiler/Recompiler.hpp b/core/shader/recompiler/Recompiler.hpp index c46af2af968d..47cea92aab2e 100644 --- a/core/shader/recompiler/Recompiler.hpp +++ b/core/shader/recompiler/Recompiler.hpp @@ -928,6 +928,7 @@ struct CompiledShaderArtifact { bool fullSubgroups = false; bool functionLdsBuffer = false; bool meshWindowBuffer = false; + bool orderedAppend = false; std::uint32_t scratchPoolSlotDwords = 0; std::vector parameterExports; std::vector fragmentParameters; diff --git a/core/shader/recompiler/RuntimeAbi.hpp b/core/shader/recompiler/RuntimeAbi.hpp index 8091a03d013a..5753af0d5730 100644 --- a/core/shader/recompiler/RuntimeAbi.hpp +++ b/core/shader/recompiler/RuntimeAbi.hpp @@ -18,6 +18,7 @@ inline constexpr std::uint32_t FirstImageBinding = 1u; inline constexpr std::uint32_t FirstComparisonImageBinding = 22u; inline constexpr std::uint32_t FirstStorageImageBinding = 29u; inline constexpr std::uint32_t ImageBindingCount = 56u; +inline constexpr std::uint32_t GdsMetadataDwords = 2u; enum class Binding : std::uint32_t { Buffers = 0u, diff --git a/core/shader/recompiler/ShaderDiskCache.cpp b/core/shader/recompiler/ShaderDiskCache.cpp index 6280a2b45153..e26d05b1c83b 100644 --- a/core/shader/recompiler/ShaderDiskCache.cpp +++ b/core/shader/recompiler/ShaderDiskCache.cpp @@ -550,6 +550,7 @@ void encodeArtifact(Writer& writer, const CompiledShaderArtifact& result) { writer.Value(result.functionLdsBuffer); writer.Value(result.meshWindowBuffer); writer.Value(result.scratchPoolSlotDwords); + writer.Value(result.orderedAppend); writer.Values(std::span(result.parameterExports)); writer.List(result.fragmentParameters, [](Writer& out, const FragmentParameter& parameter) { out.Value(parameter.location); @@ -617,6 +618,7 @@ void decodeArtifact(Reader& reader, CompiledShaderArtifact& result) { reader.Value(result.functionLdsBuffer); reader.Value(result.meshWindowBuffer); reader.Value(result.scratchPoolSlotDwords); + reader.Value(result.orderedAppend); reader.Values(result.parameterExports); reader.List(result.fragmentParameters, 10, [](Reader& in, FragmentParameter& parameter) { in.Value(parameter.location); diff --git a/core/shader/recompiler/ShaderDiskCache.hpp b/core/shader/recompiler/ShaderDiskCache.hpp index 35c3721375fb..a38df2fd9726 100644 --- a/core/shader/recompiler/ShaderDiskCache.hpp +++ b/core/shader/recompiler/ShaderDiskCache.hpp @@ -13,7 +13,7 @@ namespace ShaderRecompiler::ShaderDiskCache { -inline constexpr std::uint32_t FormatVersion = 90; +inline constexpr std::uint32_t FormatVersion = 92; enum class LoadStatus { Loaded, diff --git a/core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvAnalysis.hpp b/core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvAnalysis.hpp index 6d0af6595149..b4bd94ea55aa 100644 --- a/core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvAnalysis.hpp +++ b/core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvAnalysis.hpp @@ -20,6 +20,7 @@ struct SpirvRequirements { bool imageGatherExtended = false; bool functionLds = false; bool ldsLock = false; + bool orderedAppend = false; bool ldsBufferInt64Atomics = false; std::uint32_t functionLdsDwords = 0; std::unordered_map functionLdsAddresses; diff --git a/core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitter.hpp b/core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitter.hpp index 883bbc4c70c0..d74d6cfd1a8f 100644 --- a/core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitter.hpp +++ b/core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitter.hpp @@ -58,6 +58,7 @@ struct SpirvEmitInfo { bool functionLdsBuffer = false; bool meshWindowBuffer = false; std::uint32_t scratchPoolSlotDwords = 0; + bool orderedAppend = false; bool anySubgroupSize = false; }; diff --git a/core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp b/core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp index 6b4ecc0694c0..0a812e0de7da 100644 --- a/core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp +++ b/core/shader/recompiler/SpirvBackend/include/SpirvBackend/SpirvEmitterState.hpp @@ -231,6 +231,7 @@ struct SpirvEmitterState { std::uint32_t gdsU64Variable = 0; std::uint32_t gdsVariable = 0; std::uint32_t gdsLength = 0; + std::uint32_t gdsGuestLength = 0; std::uint32_t pushConstantVariable = 0; std::uint32_t shaderDataStorageVariable = 0; std::uint32_t flattenedSrtVariable = 0; diff --git a/core/shader/recompiler/SpirvBackend/src/SpirvAnalysis.cpp b/core/shader/recompiler/SpirvBackend/src/SpirvAnalysis.cpp index 35575619923d..b57afe847040 100644 --- a/core/shader/recompiler/SpirvBackend/src/SpirvAnalysis.cpp +++ b/core/shader/recompiler/SpirvBackend/src/SpirvAnalysis.cpp @@ -508,6 +508,9 @@ SpirvRequirements AnalyzeProgramRequirements(const IrProgram& program) { requirements.ldsLock = true; requirements.subgroupBallot = true; } + if ((inst->Opcode() == IrOpcode::DataOrderedCount || inst->Opcode() == IrOpcode::DataOrderedSwap) && kind == ResourceKind::Gds && program.Resources().stage == IrShaderStage::Compute) { + requirements.orderedAppend = true; + } if (sharedAccess == SharedAccess::Append || sharedAccess == SharedAccess::Consume) { requirements.subgroupBallot = true; requirements.subgroupShuffle = true; diff --git a/core/shader/recompiler/SpirvBackend/src/SpirvEmitter.cpp b/core/shader/recompiler/SpirvBackend/src/SpirvEmitter.cpp index b93a20b0d622..acb2a929e7bd 100644 --- a/core/shader/recompiler/SpirvBackend/src/SpirvEmitter.cpp +++ b/core/shader/recompiler/SpirvBackend/src/SpirvEmitter.cpp @@ -357,6 +357,7 @@ std::vector SpirvEmitter::Emit(const IrProgram& program, const Sh info->functionLdsBuffer = state.pixelFunctionLdsBuffer; info->meshWindowBuffer = state.meshWindowBuffer; info->scratchPoolSlotDwords = ScratchPoolActive(state) ? ScratchPoolSlotDwords(state) : 0u; + info->orderedAppend = state.requirements.orderedAppend; info->anySubgroupSize = state.spannedAnySubgroup; } VerifyScratchPoolReturns(state, words); diff --git a/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvBufferAccess.cpp b/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvBufferAccess.cpp index 99a53e4d1b05..c8093808c28b 100644 --- a/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvBufferAccess.cpp +++ b/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvBufferAccess.cpp @@ -211,7 +211,7 @@ MemoryResourceAccess PrepareMemoryResourceAccess(SpirvEmitterState& state, const FailEmit("GDS length was not prepared at function entry"); } access.objectPointer = state.gdsVariable; - access.length = state.gdsLength; + access.length = state.gdsGuestLength; return access; case ResourceKind::Scratch: if (ScratchPoolActive(state)) { diff --git a/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cpp b/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cpp index 820185257e51..0a7f0ecf3498 100644 --- a/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cpp +++ b/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvEmitterHelpers.cpp @@ -9,6 +9,7 @@ #include "SpirvBackend/SpirvMemory/SpirvInputOutput.hpp" #include #include +#include #include #include #include @@ -240,6 +241,17 @@ void DefineInputs(SpirvEmitterState& state) { state.numWorkgroupsVariable = DefineInterfaceVariable(state, TypeU32Vector(state, 3u), spv::StorageClassInput, "gl_NumWorkGroups"); state.module.AddAnnotation(spv::OpDecorate, state.numWorkgroupsVariable, spv::DecorationBuiltIn, spv::BuiltInNumWorkgroups); } + if (state.requirements.orderedAppend) { + for (const auto& [kind, components, name] : {std::tuple{StageInputKind::WorkgroupId, 3u, "gl_WorkGroupID"}, std::tuple{StageInputKind::LocalInvocationIndex, 1u, "gl_LocalInvocationIndex"}}) { + if (std::none_of(state.inputs.begin(), state.inputs.end(), [kind](const SpirvInputBinding& input) { return input.kind == kind; })) { + state.inputs.push_back(SpirvInputBinding {{kind, 0u, components, name, false}}); + } + } + if (state.numWorkgroupsVariable == 0u) { + state.numWorkgroupsVariable = DefineInterfaceVariable(state, TypeU32Vector(state, 3u), spv::StorageClassInput, "gl_NumWorkGroups"); + state.module.AddAnnotation(spv::OpDecorate, state.numWorkgroupsVariable, spv::DecorationBuiltIn, spv::BuiltInNumWorkgroups); + } + } const bool pixelStage = state.program.Resources().stage == IrShaderStage::Pixel; const bool emulated = pixelStage && state.program.Metadata().barycentricEmulation; BarycentricEmulationLayout emulation; diff --git a/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvMemoryInstructions.cpp b/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvMemoryInstructions.cpp index 677687f81756..2b1c573fce72 100644 --- a/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvMemoryInstructions.cpp +++ b/core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvMemoryInstructions.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -1369,6 +1370,67 @@ std::uint32_t AddressAtomic(SpirvValueEmitContext& ctx, const IrValue& inst) { }); } +std::uint32_t OrderedFlags(const IrValue& inst) { + const auto* flags = inst.Arguments().size() > 5u ? inst.Argument(5) : nullptr; + return flags != nullptr && flags->HasImmediate() ? flags->ImmediateU32() : 0u; +} + +constexpr std::uint32_t OrderedTurnWaitLimit = 1u << 20u; +constexpr std::uint32_t OrderedTurnAbandoned = 0xffffffffu; + +struct OrderedTurn { + std::uint32_t pointer; + std::uint32_t timeouts; + std::uint32_t launch; + std::uint32_t wrapped; + bool release; +}; + +template +std::uint32_t EmitOrderedTurn(SpirvEmitterState& state, const OrderedTurn& turn, std::uint32_t actor, std::uint32_t condition, TAtomic&& atomic) { + const auto entry = state.currentLabel; + const auto header = state.module.AllocateId(); + const auto body = state.module.AllocateId(); + const auto cont = state.module.AllocateId(); + const auto merge = state.module.AllocateId(); + const auto tries = state.module.AllocateId(); + const auto triesNext = state.module.AllocateId(); + state.module.AddFunction(spv::OpBranch, header); + EmitLabel(state, header); + state.module.AddFunction(spv::OpPhi, TypeU32(state), tries, ConstantU32(state, 0u), entry, triesNext, cont); + state.module.AddFunction(spv::OpLoopMerge, merge, cont, spv::LoopControlMaskNone); + state.module.AddFunction(spv::OpBranch, body); + EmitLabel(state, body); + const auto loaded = state.module.AllocateId(); + state.module.AddFunction(spv::OpAtomicLoad, TypeU32(state), loaded, turn.pointer, ConstantU32(state, spv::ScopeDevice), ConstantU32(state, spv::MemorySemanticsAcquireMask | spv::MemorySemanticsUniformMemoryMask)); + state.module.AddFunction(spv::OpIAdd, TypeU32(state), triesNext, tries, ConstantU32(state, 1u)); + const auto ready = AndCondition(state, actor, Binary(state, spv::OpIEqual, TypeBool(state), loaded, turn.launch)); + const auto abandoned = Binary(state, spv::OpIEqual, TypeBool(state), loaded, ConstantU32(state, OrderedTurnAbandoned)); + const auto exhausted = AndCondition(state, actor, Binary(state, spv::OpUGreaterThanEqual, TypeBool(state), triesNext, ConstantU32(state, OrderedTurnWaitLimit))); + const auto unordered = AndCondition(state, Unary(state, spv::OpLogicalNot, TypeBool(state), ready), Binary(state, spv::OpLogicalOr, TypeBool(state), exhausted, AndCondition(state, actor, abandoned))); + const auto finish = Binary(state, spv::OpLogicalOr, TypeBool(state), ready, unordered); + const auto value = EmitValueOrZeroIfCondition(state, AndCondition(state, finish, condition), atomic); + EmitIfCondition(state, unordered, [&] { + const auto counted = state.module.AllocateId(); + state.module.AddFunction(spv::OpAtomicIAdd, TypeU32(state), counted, turn.timeouts, ConstantU32(state, spv::ScopeDevice), ConstantU32(state, spv::MemorySemanticsMaskNone), ConstantU32(state, 1u)); + EmitIfCondition(state, Unary(state, spv::OpLogicalNot, TypeBool(state), abandoned), [&] { + state.module.AddFunction(spv::OpAtomicStore, turn.pointer, ConstantU32(state, spv::ScopeDevice), ConstantU32(state, spv::MemorySemanticsMaskNone), ConstantU32(state, OrderedTurnAbandoned)); + }); + }); + if (turn.release) { + EmitIfCondition(state, ready, [&] { + const auto previous = state.module.AllocateId(); + state.module.AddFunction(spv::OpAtomicCompareExchange, TypeU32(state), previous, turn.pointer, ConstantU32(state, spv::ScopeDevice), ConstantU32(state, spv::MemorySemanticsReleaseMask | spv::MemorySemanticsUniformMemoryMask), ConstantU32(state, spv::MemorySemanticsMaskNone), turn.wrapped, turn.launch); + }); + } + const auto done = Binary(state, spv::OpLogicalOr, TypeBool(state), finish, Unary(state, spv::OpLogicalNot, TypeBool(state), actor)); + state.module.AddFunction(spv::OpBranchConditional, done, merge, cont); + EmitLabel(state, cont); + state.module.AddFunction(spv::OpBranch, header); + EmitLabel(state, merge); + return value; +} + std::uint32_t AppendConsume(SpirvValueEmitContext& ctx, const IrValue& inst, bool append, bool ordered = false, bool swap = false) { auto& state = ctx.state; if (ctx.half == 1u) { @@ -1408,14 +1470,50 @@ std::uint32_t AppendConsume(SpirvValueEmitContext& ctx, const IrValue& inst, boo const auto bounds = m0Address ? AndCondition(state, storageBounds, m0Bounds) : storageBounds; const auto lanesActive = wave64 ? Binary(state, spv::OpINotEqual, TypeBool(state), count, ConstantU32(state, 0u)) : exec; const auto condition = AndCondition(state, isFirst, AndCondition(state, lanesActive, bounds)); - const auto atomic = EmitValueOrZeroIfCondition(state, condition, [&]() { + const bool turn = ordered && gds && state.requirements.orderedAppend && !InFunctionStorage(state, mem.kind); + std::optional orderedTurn; + if (turn) { + const auto* workgroup = ShaderWorkgroupInput(state); + if (workgroup == nullptr) { + ctx.Fail(inst, "orders its waves without the compute workgroup size"); + } + std::uint32_t threads = 1u; + for (const auto count : workgroup->threadsNum) threads *= std::max(count, 1u); + const std::uint32_t guestWave = state.program.WaveSize(); + const std::uint32_t wavesPerGroup = (threads + guestWave - 1u) / guestWave; + const auto groups = [&](std::uint32_t component) { + const auto pointer = state.module.AllocateId(); + const auto value = state.module.AllocateId(); + state.module.AddFunction(spv::OpAccessChain, TypePointer(state, spv::StorageClassInput, TypeU32(state)), pointer, state.numWorkgroupsVariable, ConstantU32(state, component)); + state.module.AddFunction(spv::OpLoad, TypeU32(state), value, pointer); + return value; + }; + const auto group = [&](std::uint32_t component) { return EmitInputComponentU32(state, StageInputKind::WorkgroupId, component); }; + const auto plane = EmitAddU32(state, EmitBinaryU32(state, spv::OpIMul, group(2u), groups(1u)), group(1u)); + const auto linear = EmitAddU32(state, EmitBinaryU32(state, spv::OpIMul, plane, groups(0u)), group(0u)); + const auto waveInGroup = EmitBinaryU32(state, spv::OpUDiv, EmitLocalInvocationIndex(state), ConstantU32(state, guestWave)); + const auto launch = EmitAddU32(state, EmitBinaryU32(state, spv::OpIMul, linear, ConstantU32(state, wavesPerGroup)), waveInGroup); + const auto waves = EmitBinaryU32(state, spv::OpIMul, EmitBinaryU32(state, spv::OpIMul, EmitBinaryU32(state, spv::OpIMul, groups(0u), groups(1u)), groups(2u)), ConstantU32(state, wavesPerGroup)); + const auto element = [&](std::uint32_t metadata) { return EmitMemoryElementPointer(state, access, EmitMemoryElementIndex(state, access, EmitAddU32(state, access.length, ConstantU32(state, metadata)))); }; + const auto next = EmitAddU32(state, launch, ConstantU32(state, 1u)); + orderedTurn = OrderedTurn{element(0u), element(1u), launch, Select(state, TypeU32(state), Binary(state, spv::OpIEqual, TypeBool(state), next, waves), ConstantU32(state, 0u), next), (OrderedFlags(inst) & 2u) != 0u}; + } + const auto update = [&]() { if (InFunctionStorage(state, mem.kind)) { return UpdateFunctionElement(state, EmitMemoryElementPointer(state, access, index), [&](std::uint32_t old) { return swap ? amount : Binary(state, append ? spv::OpIAdd : spv::OpISub, TypeU32(state), old, count); }); } const auto value = state.module.AllocateId(); state.module.AddFunction(swap ? spv::OpAtomicExchange : append ? spv::OpAtomicIAdd : spv::OpAtomicISub, TypeU32(state), value, EmitMemoryElementPointer(state, access, index), ConstantU32(state, gds ? spv::ScopeDevice : spv::ScopeWorkgroup), ConstantU32(state, spv::MemorySemanticsMaskNone), amount); return value; - }); + }; + std::uint32_t atomic = 0; + if (orderedTurn.has_value()) { + const auto anyActive = Binary(state, spv::OpINotEqual, TypeBool(state), count, ConstantU32(state, 0u)); + const auto waveLeader = Binary(state, spv::OpIEqual, TypeBool(state), EmitSubgroupLocalInvocationId(state), ConstantU32(state, 0u)); + atomic = EmitOrderedTurn(state, *orderedTurn, Select(state, TypeBool(state), anyActive, isFirst, waveLeader), condition, update); + } else { + atomic = EmitValueOrZeroIfCondition(state, condition, update); + } const auto result = state.module.AllocateId(); EmitSubgroupShuffle(state, TypeU32(state), result, atomic, EmitHostSubgroupLane(state, sourceLane)); return result; diff --git a/core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp b/core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp index 5e4822cbf3a4..45ccea01b90c 100644 --- a/core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp +++ b/core/shader/recompiler/SpirvBackend/src/SpirvModuleEmitter.cpp @@ -1990,6 +1990,8 @@ void EmitProgram(SpirvEmitterState& state) { if (state.gdsVariable != 0u) { state.gdsLength = state.module.AllocateId(); state.module.AddFunction(spv::OpArrayLength, TypeU32(state), state.gdsLength, state.gdsVariable, 0u); + state.gdsGuestLength = state.module.AllocateId(); + state.module.AddFunction(spv::OpISub, TypeU32(state), state.gdsGuestLength, state.gdsLength, ConstantU32(state, RuntimeAbi::GdsMetadataDwords)); } if (state.pixelValidMaskVariable != 0u) { state.module.AddFunction(spv::OpStore, state.pixelValidMaskVariable, ConstantU32(state, 1u)); diff --git a/core/shader/recompiler/Translation/src/MemoryInstructions/SharedMemoryInstructions.cpp b/core/shader/recompiler/Translation/src/MemoryInstructions/SharedMemoryInstructions.cpp index 841aef3f57f1..f6640d7a0da8 100644 --- a/core/shader/recompiler/Translation/src/MemoryInstructions/SharedMemoryInstructions.cpp +++ b/core/shader/recompiler/Translation/src/MemoryInstructions/SharedMemoryInstructions.cpp @@ -287,7 +287,7 @@ bool TranslationContext::dsOrderedCount(const RdnaInstruction& inst) { IrValue& activeLo = ir.GetExecLo(); IrValue& activeHi = ir.GetExecHi(); const auto opcode = (flags & 0x10u) != 0u ? IrOpcode::DataOrderedSwap : IrOpcode::DataOrderedCount; - IrValue& result = ir.Emit(opcode, IrOpcodeType(opcode), {&address, &active, &activeLo, &activeHi, &amount.Value()}, addMemoryInfo(memory, inst.programCounter)); + IrValue& result = ir.Emit(opcode, IrOpcodeType(opcode), {&address, &active, &activeLo, &activeHi, &amount.Value(), &ir.Constant(flags)}, addMemoryInfo(memory, inst.programCounter)); writeOperand(inst.destination, &result); return true; } diff --git a/docs/dev/debt/shader.md b/docs/dev/debt/shader.md index b83680e1ec03..94711f242851 100644 --- a/docs/dev/debt/shader.md +++ b/docs/dev/debt/shader.md @@ -244,7 +244,8 @@ - [Raw `buffer_load_dwordx2`](../../../core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvMemoryInstructions.cpp) is one 64-bit access on the hardware (with or without glc), so it never sees half of a `buffer_atomic_swap_x2`. Only a glc load that is 8-byte aligned and in bounds, in a program that has the 64-bit storage view (it uses 64-bit buffer atomics), is read with one 64-bit atomic load; every other dwordx2 load is two dword loads and can tear against a concurrent 64-bit write: loads without glc, and loads in a program without 64-bit buffer atomics while another shader writes the pair with `swap_x2`. - [Buffer loads without GLC or DLC](../../../core/shader/recompiler/SpirvBackend/src/SpirvAnalysis.cpp) (shader recompiler) are not coherent in a program that has GLC or DLC buffer accesses and no `buffer_gl0_inv`, `buffer_gl1_inv`, `s_gl1_inv` or `s_dcache_inv`: only its GLC and DLC loads, stores and atomics use the `Coherent` buffer view, so a plain load can return a value cached before another work-group's write. This follows the [LLVM AMDGPU memory model for GFX10](https://llvm.org/docs/AMDGPUUsage.html#memory-model-gfx10-gfx11), in which a load-acquire is a GLC DLC load followed by `buffer_gl1_inv` and `buffer_gl0_inv`; it is not measured on the console or on RDNA hardware. - [DS src2 operations](../../../core/shader/recompiler/Translation/src/MemoryInstructions/SharedMemoryInstructions.cpp) (`ds_*_src2_*`, GFX10.1 only) read `DS[B]`, with `B = A + 4 * sext(offset1[6:0]:offset0)`, and then update `DS[A]` with the matching 32-bit atomic, so the read of `B` is not atomic with the update of `A`. The form that takes the offset from the address (`offset1[7]` set), the 64-bit forms and GDS throw: whether the LDS address keeps `A[31:17]` in that form, and whether the 64-bit forms scale the offset by 4 or 8, is not documented. `ds_min_src2_f32`, `ds_max_src2_f32` and `ds_add_src2_f32` follow the LDS float atomics rule above, inferred from `ds_min_f32`, `ds_max_f32` and `ds_add_f32` measured on RDNA2 (gfx1035), which has no src2 opcodes; the f32 src2 forms were not measured on GFX10.1. -- [`ds_ordered_count`](../../../core/shader/recompiler/Translation/src/MemoryInstructions/SharedMemoryInstructions.cpp) (GDS only) reads its operand fields as LLVM encodes them for `llvm.amdgcn.ds.ordered.add` ([SIISelLowering.cpp](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/AMDGPU/SIISelLowering.cpp#L8844-L8894)): `offset0` is the counter's byte offset (index times 4) and the whole GDS address, `offset1` bit 0 wave release, bit 1 wave done, bits 2-3 the shader type, bit 4 swap instead of add and bits 6-7 the dword count less one. `M0` holds the ordered wave ID, not a GDS address as for `ds_append` (radeonsi passes `TG_SIZE` bits 6-17 as the intrinsic's pointer in [si_compute_prim_discard.c](https://gitlab.freedesktop.org/mesa/mesa/-/blob/mesa-20.3.0/src/gallium/drivers/radeonsi/si_compute_prim_discard.c) and `gs_tg_info` bits 0-11 in [gfx10_shader_ngg.c](https://gitlab.freedesktop.org/mesa/mesa/-/blob/mesa-21.3.0/src/gallium/drivers/radeonsi/gfx10_shader_ngg.c), with "The GDS address is always 0 with ordered append"); it only orders the waves, which is not modeled, so it is ignored. Each wave adds the value of its first active lane to the counter with one device-scope atomic and every active lane gets the counter's previous value (the `ORDERED_APPEND_ENBL` dispatch modifier is accepted for it). The hardware also serializes the waves of a dispatch in launch order, which is not modeled: the waves add in any order, so counters a title reads back as ordered offsets give the same totals but may hand out ranges in another order. Which lane's value is added is not documented; the first active lane is assumed and not measured on hardware. A swap (`offset1` bit 4) stores the first active lane's value in place of the counter with one device-scope atomic exchange and returns the counter's previous value to every active lane; with the waves unordered, which wave's value the counter keeps and which previous value each wave gets need not follow the launch order the hardware gives. Counts of more than one dword and LDS forms throw. Covered by [GdsAppendConsume.cpp](../../../core/libs/prx/libSceAgcDriver/tests/execution/GdsAppendConsume.cpp). +- [`ds_ordered_count`](../../../core/shader/recompiler/Translation/src/MemoryInstructions/SharedMemoryInstructions.cpp) (GDS only) reads its fields as LLVM encodes `llvm.amdgcn.ds.ordered.add` ([SIISelLowering.cpp](https://github.com/llvm/llvm-project/blob/llvmorg-19.1.0/llvm/lib/Target/AMDGPU/SIISelLowering.cpp#L8844-L8894)): `offset0` is the counter's byte offset, `offset1` bit 0 wave release, bit 1 wave done, bits 2-3 shader type, bit 4 swap, bits 6-7 dword count minus one. `M0` holds the ordered wave ID, not a GDS address (radeonsi, [si_compute_prim_discard.c](https://gitlab.freedesktop.org/mesa/mesa/-/blob/mesa-20.3.0/src/gallium/drivers/radeonsi/si_compute_prim_discard.c)); the order comes from the launch index, so `M0` is ignored. Which lane's value is added or swapped in is unmeasured (the first active lane is assumed). Counts over one dword and LDS forms throw. +- [`ds_ordered_count` order](../../../core/shader/recompiler/SpirvBackend/src/SpirvMemory/SpirvMemoryInstructions.cpp) (compute only): waves take turns by `WorkgroupId` on a dword past the guest GDS, assuming that start order and progress, which Vulkan does not guarantee: on AMD's Windows driver (RX 9070 XT) row 0 of the first 65535-row chunk was served about 65,300 places late, read as a late start (the split test then skips its row 0 and unordered-count checks). A wave passes the turn on at wave done (`offset1` bit 1), not at wave release (bit 0), unmeasured on hardware. The driver zeroes the turn before each ordering dispatch and each chunk of a split one, so chunks are ordered by the barrier between them. A wave waiting 2^20 reads adds unordered and marks the turn abandoned, so the rest runs unordered (counted at `Pm4::GdsOrderedTimeoutsOffset`). Graphics stays unordered. Covered by [GdsAppendConsume.cpp](../../../core/libs/prx/libSceAgcDriver/tests/execution/GdsAppendConsume.cpp). - [s_swappc_b64](../../../core/shader/recompiler/Translation/src/ControlFlowInstructions.cpp) writes the link pair with the same model as `s_getpc_b64`: the guest return address `pc + 4` as a byte offset over `GetShaderBase`. Any other use of the link pair (arithmetic, hash, store) throws, apart from the overwrites, SOPC compares and shared links that [static scalar calls](../../../core/shader/recompiler/ControlFlow/src/GraphBuilder.cpp) allow; constant-offset folding over the link is not modeled. The special encoding `s_swappc_b64` with SDST 125 still decodes as `s_setpc_b64`, which matches the hardware: measured on RDNA2 (gfx1036) in wave32 and wave64, it branches to the source pair and leaves a marker SGPR pair untouched, and with an SGPR destination the link is `PC + 4`. - [2D biased sampling through a one-slice, single-level 3D T#](../../../core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp) supplies a zero third coordinate and retains the bias operation, with normalized point minification and magnification and no linear mip filtering. Measured on RDNA2 (AMD integrated gfx1036, driver 32.0.21036.18, Windows 11) by running an OpenCL-loaded native kernel with `image_sample_b` DIM 2D against 16x16x1 R32_UINT and RGBA8_UNORM 3D images: biases -16, -0.5, 0, 0.5 and 16 read the (u,v) texel in slice zero, including wrapped coordinates, point min/max reduction and the title's sampler with Z border addressing. Wave32, IEEE off, DX10 clamp on, denormals preserved, round to nearest even, FP16 overflow off; on a second gfx1036 rig (driver 31.0.22044.1) wave64 matches wave32 for 8_8_8_8_UNORM, 8_8_8_8_UINT and 32_UINT, wrap and clamp addressing, and biases -16 to 16; point min/max reduction, Z border addressing and the PS5's gfx1013 remain unmeasured at wave64. Pixel-stage, direct, non-depth, unpacked samples whose only use is the plain 32-bit bias form are accepted; extra slices, any nonzero mip range, linear or anisotropic filtering and unnormalized coordinates throw. Vulkan readback is checked on NVIDIA RTX 5070 and AMD integrated graphics for positive and negative bias and point weighted-average/min/max reduction. - [FORCE_DEGAMMA on RGBA8_UINT](../../../core/shader/recompiler/Optimization/src/ResourceMaterializer.cpp) materializes a direct image sampled only by plain biased pixel accesses as RGBA8_SRGB when every paired sampler forces degamma. Measured on AMD integrated RDNA2 gfx1036 (driver 32.0.21036.18, Windows 11, wave32, IEEE off, DX10 clamp on, denormals preserved, round to nearest even, FP16 overflow off): a native `image_sample_b` DIM 2D on a 16x16x1 RGBA8_UINT 3D T# returns integer channels without the bit, but the same floating-point decoded values as RGBA8_UNORM with it, including point min/max reduction and the title's exact sampler. The metadata and image view must both become floating-point sRGB; ignoring the sampler bit or retaining a UINT heap is incorrect. The accepted case requires one slice, mip zero, normalized point sampling and uniform FORCE_DEGAMMA across its samplers. Other image accesses, mixed sampler states, indirect descriptors and other integer formats remain refused. Wave64 matches wave32 for a 2D descriptor; the one-slice 3D descriptor, other filtering modes and the PS5's gfx1013 are not measured.