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
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,14 @@ add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/ProbeArrayAtomics.h" COMM
"${CMAKE_CURRENT_SOURCE_DIR}/tests/gpu_alias_writes.hlsl" DEPENDS tests/gpu_alias_writes.hlsl src/title_va_lookup.hlsli
BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/ProbeArrayAtomics.cso" VERBATIM)
target_sources(offscreen_check PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/ProbeArrayAtomics.h")
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/ProbeArrayAtomicsWaterfall.h" COMMAND "${DXC_EXECUTABLE}" -T cs_6_0
-E ProbeArrayAtomicsWaterfall -Vn ProbeArrayAtomicsWaterfall
-Fh "${CMAKE_CURRENT_BINARY_DIR}/ProbeArrayAtomicsWaterfall.h"
-Fo "${CMAKE_CURRENT_BINARY_DIR}/ProbeArrayAtomicsWaterfall.cso"
"${CMAKE_CURRENT_SOURCE_DIR}/tests/gpu_alias_atomic_waterfall.hlsl"
DEPENDS tests/gpu_alias_atomic_waterfall.hlsl
BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/ProbeArrayAtomicsWaterfall.cso" VERBATIM)
target_sources(offscreen_check PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/ProbeArrayAtomicsWaterfall.h")
target_include_directories(offscreen_check PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src")
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/AliasTransform.h" COMMAND "${DXC_EXECUTABLE}" -T cs_6_0
-E AliasTransform -Vn AliasTransform -Fh "${CMAKE_CURRENT_BINARY_DIR}/AliasTransform.h"
Expand Down
20 changes: 20 additions & 0 deletions docs/experiments.md
Original file line number Diff line number Diff line change
Expand Up @@ -3310,6 +3310,26 @@ Measured at commit `55cea41` on Windows 11 build 26300, with the debug layer una
- At commit `65492448` on Windows 10 22H2 (build 19045.6456, MSVC 19.44.35230.0, Windows SDK 10.0.26100.0 DXC, debug layer enabled on both backends), a GTX 1060 6 GB (driver 32.0.15.6094) reads 64 in all four probe buffers in 3/3 runs, and the in-box WARP 10.0.19041.5794 on the same host reproduces the Windows 10 behavior above: each buffer reads 256 in 3/3 runs, with the fixture reporting the shared add and sub words as the only two mismatches. Both backends matched all 1,047 per-record results and the other 147,454 words, with zero debug errors or warnings ([report](https://github.com/R0Y00/Xbox2Windows/issues/369#issuecomment-7071770464)).
- At commit `185b9d6c` on Windows 11 build 26200 with the debug layer enabled, an RDNA 3 adapter reproduces the same probe failure: an AMD Radeon RX 7900 XTX (device `744c`, driver 32.0.32029.2010) reads 256 in each of the four buffers, with the title-address fixture recording zero mismatches across all 1,047 records and 147,454 checked words and zero D3D12 debug errors or warnings ([report](https://github.com/R0Y00/Xbox2Windows/issues/369)).

- The [RX 6500 report](https://github.com/R0Y00/Xbox2Windows/pull/793) used
commit `a4ade3032fec08767ed411cc83834a3543c626f2`, driver 32.0.21045.29003,
Windows 11 build 26300 and the debug layer. The direct probe read
`256,256,256,256` instead of `64,64,64,64`; its title-address lookup/write
comparisons still matched. The separate wave diagnostic read
`64,64,64,64` in four runs on the RX 6500 and passed on WARP
10.0.26100.10068. These measurements leave the cause open.

The wave diagnostic is run explicitly, with the same dispatch sizes, resource
setup and readback as the direct probe. Run both from the build directory:

```powershell
.\offscreen_check.exe hardware --gpu-alias-lookup-writes
.\offscreen_check.exe hardware --gpu-alias-atomic-waterfall
.\offscreen_check.exe warp --gpu-alias-atomic-waterfall
```

An incorrect readback or setup failure fails the diagnostic. Exit 77 denotes
an adapter without the required SM 6.0 or WaveOps capability.

## Offscreen rendering and readback

`offscreen_hardware` selects a high-performance adapter. `offscreen_warp` selects Microsoft's software rasterizer. Both draw the same DXC-compiled triangle to a 64×64 RGBA8 texture. After GPU completion the test reads the texture using its row pitch and compares colors and coverage pixel by pixel. Outputs are `triangle_hardware.bmp` and `triangle_warp.bmp` in the build directory. `ctest --preset dev -V` reports the adapter, driver, debug layer and pixel differences. Error or corruption messages from an available debug layer fail the test.
Expand Down
1 change: 1 addition & 0 deletions tests/desktop_gpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ bool check_bvh_waves(ID3D12Device* device, bool force64);
bool check_gpu_alias(ID3D12Device* device);
bool check_gpu_alias_lookup(ID3D12Device* device);
bool check_gpu_alias_lookup_writes(ID3D12Device* device);
bool check_gpu_alias_atomic_waterfall(ID3D12Device* device);
bool check_gpu_alias_registry(ID3D12Device* device);
bool check_wave_shuffle(ID3D12Device* device);
bool check_dxr_rays(ID3D12Device* device, bool usePipeline);
Expand Down
42 changes: 42 additions & 0 deletions tests/gpu_alias_atomic_waterfall.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#define ProbeRoot "DescriptorTable(UAV(u0, space = 1, numDescriptors = 8)), RootConstants(num32BitConstants = 2, b0)"

RWByteAddressBuffer Aliases[8] : register(u0, space1);

cbuffer Counts : register(b0)
{
uint rangeCount;
uint threadCount;
};

[RootSignature(ProbeRoot)]
[numthreads(64, 1, 1)]
void ProbeArrayAtomicsWaterfall(uint id : SV_DispatchThreadID)
{
if (id >= threadCount) return;

uint selected = id % rangeCount;
bool remaining = true;

while (WaveActiveAnyTrue(remaining))
{
uint leaderLane = WaveActiveMin(
remaining ? WaveGetLaneIndex() : 0xffffffff
);

uint groupIndex = WaveReadLaneAt(selected, leaderLane);
uint groupCount = WaveActiveCountBits(
remaining && selected == groupIndex
);

if (remaining && WaveGetLaneIndex() == leaderLane)
{
uint previous;
Aliases[NonUniformResourceIndex(groupIndex)].InterlockedAdd(
0, groupCount, previous
);
}

if (remaining && selected == groupIndex)
remaining = false;
}
}
16 changes: 11 additions & 5 deletions tests/gpu_alias_lookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "era_title_va.h"
#include "LookupTitleAddresses.h"
#include "ProbeArrayAtomics.h"
#include "ProbeArrayAtomicsWaterfall.h"
#include "WriteTitleAddresses.h"

#include <algorithm>
Expand Down Expand Up @@ -194,10 +195,10 @@ Word float_bits(float value)
// aliases under test. 256 threads each add 1 to word 0 of one of four zeroed buffers, 64 threads
// per buffer. Prints the expected and actual counts. The in-box WARP of Windows 10 (10.0.19041)
// applies each such add four times, which is a wrong result, not a missing capability.
bool array_atomics_exact(ID3D12Device* device)
bool array_atomics_exact(ID3D12Device* device, D3D12_SHADER_BYTECODE shader, const char* name)
{
constexpr UINT targets = 4, threads = 256;
Kernel kernel(device, {ProbeArrayAtomics, sizeof(ProbeArrayAtomics)});
Kernel kernel(device, shader);
D3D12_DESCRIPTOR_HEAP_DESC heap_desc{D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, descriptor_count,
D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE, 0};
ComPtr<ID3D12DescriptorHeap> heap;
Expand Down Expand Up @@ -242,12 +243,16 @@ bool array_atomics_exact(ID3D12Device* device)
cmd.submit_and_wait(device);
const auto counts = read(back.Get(), targets);
const Word expected = threads / targets;
std::printf("array_atomics threads=%u buffers=%u expected=%u actual=%u,%u,%u,%u\n", threads, targets, expected,
std::printf("%s threads=%u buffers=%u expected=%u actual=%u,%u,%u,%u\n", name, threads, targets, expected,
counts[0], counts[1], counts[2], counts[3]);
return std::all_of(counts.begin(), counts.end(), [=](Word count) { return count == expected; });
}
}

bool check_gpu_alias_atomic_waterfall(ID3D12Device* device)
{
return array_atomics_exact(device, {ProbeArrayAtomicsWaterfall, sizeof(ProbeArrayAtomicsWaterfall)},
"array_atomics_waterfall");
}
bool check_gpu_alias_lookup(ID3D12Device* device)
{
AliasFixture fixture;
Expand Down Expand Up @@ -312,7 +317,8 @@ bool check_gpu_alias_lookup_writes(ID3D12Device* device)
if (!fixture.open(device)) return false;
// Measured first and always printed. Wrong counts fail the test at the end, after the whole
// fixture has run, so the output separates the add and sub words from every other check.
const bool atomics_exact = array_atomics_exact(device);
const bool atomics_exact = array_atomics_exact(device, {ProbeArrayAtomics, sizeof(ProbeArrayAtomics)},
"array_atomics");
enum : Word { Store = 0, Add = 1, Sub = 2, MinFloat = 3, MaxFloat = 4 };
struct Record {
std::uint64_t address;
Expand Down
11 changes: 11 additions & 0 deletions tests/offscreen_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,12 @@ OperationResult run_gpu_alias_lookup_writes(const OperationContext& ctx)
return skip_if_false(check_gpu_alias_lookup_writes(ctx.device));
}

OperationResult run_gpu_alias_atomic_waterfall(const OperationContext& ctx)
{
if (!check_gpu_alias_atomic_waterfall(ctx.device))
return {OutcomeKind::fail, "Waterfall atomic counts differ from the reference"};
return {OutcomeKind::pass, nullptr};
}
OperationResult run_gpu_alias_registry(const OperationContext& ctx)
{
return skip_if_false(check_gpu_alias_registry(ctx.device));
Expand Down Expand Up @@ -905,6 +911,10 @@ constexpr CapabilityGate kGateSm66Ballot{
D3D_SHADER_MODEL_6_6, false, false, 0,
"skip: ballot fixture requires SM 6.6",
CapsDiagnostic::none};
constexpr CapabilityGate kGateSm60AtomicWaterfall{
D3D_SHADER_MODEL_6_0, false, true, 0,
"skip: atomic waterfall diagnostic requires SM 6.0 and WaveOps",
CapsDiagnostic::none};
constexpr CapabilityGate kGateSm60Compaction{
D3D_SHADER_MODEL_6_0, false, true, 0,
"skip: subgroup compaction fixture requires SM 6.0 and WaveOps",
Expand Down Expand Up @@ -992,6 +1002,7 @@ const OperationSpec kOperations[] = {
{"--gpu-alias", 3, 3, nullptr, kNoGate, run_gpu_alias},
{"--gpu-alias-lookup", 3, 3, nullptr, kNoGate, run_gpu_alias_lookup},
{"--gpu-alias-lookup-writes", 3, 3, nullptr, kNoGate, run_gpu_alias_lookup_writes},
{"--gpu-alias-atomic-waterfall", 3, 3, nullptr, kGateSm60AtomicWaterfall, run_gpu_alias_atomic_waterfall},
{"--gpu-alias-registry", 3, 3, nullptr, kNoGate, run_gpu_alias_registry},
{"--buffer-ops", 3, 3, nullptr, kGateSm60BufferOps, run_buffer_ops},
{"--wave-shuffle", 3, 3, nullptr, kGateWaveShuffle, run_wave_shuffle},
Expand Down
Loading