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
1 change: 1 addition & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ jobs:
(["tests/pixel_attribute_sampled_check.py", *COMMON_LLVM], {}),
(["tests/compute_mimg_msaa_check.py", "--binary", "llvm-mc-15", "llvm-objcopy-15", "libLLVM-15.so.1"], {}),
(["tests/compute_mimg_float_store_check.py", "--binary", "llvm-mc-15", "llvm-objcopy-15", "--llvm", "libLLVM-15.so.1"], {}),
(["tests/compute_mimg_image_uav_load_check.py", "--binary", "llvm-mc-15", "llvm-objcopy-15", "--llvm", "libLLVM-15.so.1"], {}),
(["tests/compute_mimg_float_store_d16_check.py", "--binary", "llvm-mc-15", "llvm-objcopy-15", "--llvm", "libLLVM-15.so.1"], {}),
(["tests/compute_image_atomics_gfx1013_check.py", "--binary", "llvm-mc-15", "llvm-objcopy-15", "--llvm", "libLLVM-15.so.1"], {}),
(["tests/mesh_indexed_check.py", *COMMON_LLVM], {}),
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7298,6 +7298,11 @@ if(EXISTS "${INTAKE_PYTHON}")
"$<TARGET_FILE:offscreen_check>" ${adapter})
set_tests_properties(compute_store_aot_gfx1013_image_store_${adapter} PROPERTIES TIMEOUT 60 SKIP_RETURN_CODE 77
ENVIRONMENT "FORM_COVERAGE_RECORD=${CMAKE_BINARY_DIR}/form_coverage/compute_store_aot_gfx1013_image_store_${adapter}.txt")
add_test(NAME compute_store_aot_gfx1013_image_uav_load_${adapter} COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_SOURCE_DIR}/tests/compute_mimg_image_uav_load_check.py" --draw "${DXC_EXECUTABLE}"
"$<TARGET_FILE:offscreen_check>" ${adapter})
set_tests_properties(compute_store_aot_gfx1013_image_uav_load_${adapter} PROPERTIES TIMEOUT 60 SKIP_RETURN_CODE 77
ENVIRONMENT "FORM_COVERAGE_RECORD=${CMAKE_BINARY_DIR}/form_coverage/compute_store_aot_gfx1013_image_uav_load_${adapter}.txt")
add_test(NAME compute_store_aot_gfx1013_image_store_d16_${adapter} COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_SOURCE_DIR}/tests/compute_mimg_float_store_d16_check.py" --draw "${DXC_EXECUTABLE}"
"$<TARGET_FILE:offscreen_check>" ${adapter})
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ The control-flow CPU translator supports [source-built string memory transfers](
| gfx1030 atomic buffer counters | Lower [fixed-address MUBUF bounded increment and decrement](docs/experiments.md#gfx1030-fixed-address-mubuf-atomic-counters) for 32 and 64 bits. | `ctest --preset dev --no-tests=error -R '^compute_store_aot_mubuf_counter'` |
| gfx1030 atomic buffer reductions | Lower [fixed-address MUBUF integer reductions](docs/experiments.md#gfx1030-fixed-address-mubuf-atomic-reductions) and verify the final value under lane contention. | `ctest --preset dev --no-tests=error -R '^compute_store_aot_mubuf_reduction_'` |
| gfx1030 raw vector reads | Lower [indexed `buffer_load_dwordx2/x3/x4`](docs/experiments.md#indexed-gfx1030-raw-vector-reads) and verify channel order, destination/index aliasing and untouched output. | `ctest --preset dev --no-tests=error -R '^compute_store_aot_mubuf_vector_'` |
| gfx1013 float image stores | Lower [full-mask 2D RGBA32 FLOAT stores and explicit-mip SRV reads](docs/experiments.md#gfx1013-2d-float-image-stores-and-mip-loads) and [D16 stores to RGBA16 FLOAT](docs/experiments.md#gfx1013-2d-d16-float-image-stores). Compare all three destination mips, including untouched texels. | `ctest --preset dev --no-tests=error -R '^compute_store_aot_gfx1013_image_store_'` |
| gfx1013 float image stores | Lower [full-mask 2D RGBA32 FLOAT stores and explicit-mip SRV reads](docs/experiments.md#gfx1013-2d-float-image-stores-and-mip-loads) [D16 stores to RGBA16 FLOAT](docs/experiments.md#gfx1013-2d-d16-float-image-stores) and [same-texel UAV loads](docs/experiments.md#gfx1013-same-texel-uav-loads). Compare all three destination mips, including untouched texels. | `ctest --preset dev --no-tests=error -R '^compute_store_aot_gfx1013_image_(store\|uav_load)_'` |
| gfx1013 image atomics | Lower [2D `R32_UINT` `image_atomic_add`, `umax` and `cmpswap`](docs/experiments.md#gfx1013-2d-image-atomics) with the gfx1030 lowering and compare every texel of a three-mip texture, including contended adds. | `ctest --preset dev --no-tests=error -R '^compute_store_aot_gfx1013_image_atomics_'` |
| gfx1030 image loads | Lower [typed RGBA32 and packed RGBA8 2D reads](docs/experiments.md#gfx1030-2d-image-loads), including explicit mip levels, with 32-bit or `a16` addresses and nonzero `dmask` values. Compare the UAV readback against a CPU reference. | `ctest --preset dev --no-tests=error -R '^compute_store_aot_mimg_(load|mip|packed)_'` |
| gfx1030 image queries | Lower [2D mip dimensions and level count](docs/experiments.md#gfx1030-2d-image-resource-queries) for `image_get_resinfo`. | `ctest --preset dev --no-tests=error -R '^compute_store_aot_mimg_resinfo_'` |
Expand Down
39 changes: 37 additions & 2 deletions docs/experiments.md
Original file line number Diff line number Diff line change
Expand Up @@ -3664,8 +3664,8 @@ For a raw UAV output, `--image-descriptor` names this SRV. For a typed image
output, `--image-srv-descriptor` declares a distinct eight-word SRV descriptor.
The caller supplies distinct, non-aliasing desktop resources in that combined
case. Wait for descriptors with `lgkmcnt(0)` and the load with `vmcnt(0)`.
This profile refuses same-descriptor reads and writes, sample instructions,
atomics, A16, D16 and non-2D dimensions.
The explicit-mip SRV path refuses sample instructions, atomics, A16, D16 and
non-2D dimensions.

The source-built fixture loads red and blue from mip 1 into consecutive VGPRs.
A full store writes those two words and two distinct constants into 16 unique
Expand All @@ -3692,6 +3692,41 @@ ctest --preset dev --no-tests=error -j 1 -R '^compute_store_aot_gfx1013_image_st
python3 -B tests/compute_mimg_float_store_check.py --binary llvm-mc-15 llvm-objcopy-15 --llvm libLLVM-15.so.1
```

### gfx1013 same-texel UAV loads

For a 2D `R32G32B32A32_FLOAT` image bound at `u0` with `--image-uav-mip 0`,
one plain `image_load` can read the same descriptor as the store. Both
instructions use DMASK `0xf`. The load lowers to
`asuint(outputData[uint2(x, y)])`. Its result VGPRs become available after
`s_waitcnt vmcnt(0)` under the existing wait rules.

The load must precede the store and name the same two coordinate VGPRs with
the same values. The translator requires the dispatch X and Y IDs and local
Z size 1. The caller must dispatch a single Z group and keep accesses in
bounds. Each lane then reads and writes its own texel. The profile refuses
neighbour reads, shared destinations, a second UAV load, sparse masks, a16,
d16, array and volume views, and explicit-mip reads from the UAV descriptor.
The separate SRV path continues to require a distinct descriptor and resource.

The fixture rotates RGBA to GBAR in 16 texels and compares every word of all
three destination mips. It checks 1,344 words, including 1,280 unchanged
sentinels. Replacing the load with zero causes 64 mismatches. The fixture
requires `TypedUAVLoadAdditionalFormats` and typed-load and typed-store support
for this format. A missing capability reports skip 77. The readback uses
normal binary32 values. NaNs, denormals, out-of-bounds behavior and native
console execution are outside the measurement.
[D3D12 typed UAV loads](https://learn.microsoft.com/en-us/windows/win32/direct3d12/typed-unordered-access-view-loads)

```powershell
cmake --build --preset dev --target offscreen_check -j 2
ctest --preset dev --no-tests=error -j 1 -R '^compute_store_aot_gfx1013_image_uav_load_(warp|hardware)$' -V
```

```bash
python3 -B tests/compute_mimg_image_uav_load_check.py
python3 -B tests/compute_mimg_image_uav_load_check.py --binary llvm-mc-15 llvm-objcopy-15 --llvm libLLVM-15.so.1
```

### gfx1013 2D D16 float image stores

Declare `--image-format R16G16B16A16_FLOAT` and `--image-uav-mip 0`
Expand Down
22 changes: 19 additions & 3 deletions tests/compute_check.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ constexpr UINT texture_atomic_mask = texture_atomic_uint_flag | texture_atomic_s
texture_atomic_uint_minmax_flag | texture_atomic_exchange_flag |
texture_atomic_cas_flag;
constexpr UINT texture_rgba32_float_flag = 1u << 30;
// Texture-store cases use scalar X group counts of 1 or 2, leaving bit 22 free.
// Texture-store cases use only scalar X group counts of 1 or 2, leaving bits 21 and 22
// free below the format and view selectors.
constexpr UINT texture_uav_load_flag = 1u << 21;
constexpr UINT texture_rgba16_float_flag = 1u << 22;
constexpr UINT texture_format_mask = texture_rgba8_flag | texture_atomic_mask | texture_rgba32_float_flag |
texture_rgba16_float_flag;
texture_rgba16_float_flag | texture_uav_load_flag;
constexpr UINT texture_width = 32, texture_height = 8, texture_channels = 4;
constexpr UINT texture_mip_levels = 3;

Expand Down Expand Up @@ -472,6 +474,10 @@ bool check_compute_texture_store_file(ID3D12Device* device, const char* path, co
switch (selector) {
case 0: break;
case texture_rgba32_float_flag: format = DXGI_FORMAT_R32G32B32A32_FLOAT; break;
case texture_uav_load_flag:
format = DXGI_FORMAT_R32G32B32A32_FLOAT;
required |= D3D12_FORMAT_SUPPORT2_UAV_TYPED_LOAD;
break;
case texture_rgba16_float_flag: format = DXGI_FORMAT_R16G16B16A16_FLOAT; break;
case texture_rgba8_flag: format = DXGI_FORMAT_R8G8B8A8_UINT; break;
case texture_atomic_uint_flag:
Expand Down Expand Up @@ -499,6 +505,7 @@ bool check_compute_texture_store_file(ID3D12Device* device, const char* path, co
default: throw std::runtime_error("Invalid compute image store format selector");
}
const bool float_image = selector == texture_rgba32_float_flag;
const bool uav_load = selector == texture_uav_load_flag;
const bool half_image = selector == texture_rgba16_float_flag;
const UINT words_per_texel = texture_words_per_texel(format);
const UINT base_words = texture_width * texture_height * words_per_texel;
Expand All @@ -509,12 +516,21 @@ bool check_compute_texture_store_file(ID3D12Device* device, const char* path, co
std::vector<UINT> input_texels(float_image ? all_words : 0);
if (float_image) source.read(reinterpret_cast<char*>(input_texels.data()), all_words * sizeof(UINT));
if (!source || source.peek() != std::char_traits<char>::eof() || !groups || groups > 2 || mip >= texture_mip_levels
|| ((selector & texture_atomic_mask) && mip != 0))
|| (((selector & texture_atomic_mask) || uav_load) && mip != 0))
throw std::runtime_error("Invalid compute image store reference");

D3D12_FEATURE_DATA_FORMAT_SUPPORT support{format};
check(device->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT, &support, sizeof(support)),
"Check texture UAV format");
if (uav_load) {
D3D12_FEATURE_DATA_D3D12_OPTIONS options{};
check(device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, &options, sizeof(options)),
"Check typed UAV loads for additional formats");
if (!options.TypedUAVLoadAdditionalFormats) {
std::puts("R32G32B32A32_FLOAT requires TypedUAVLoadAdditionalFormats");
return false;
}
}
if ((support.Support2 & required) != required) {
std::printf("format=%u required_support2=0x%x support1=0x%x support2=0x%x\n",
static_cast<UINT>(format), required, static_cast<UINT>(support.Support1),
Expand Down
14 changes: 14 additions & 0 deletions tests/compute_mimg_image_uav_load.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
s_mov_b32 s12, s7
s_mov_b32 s13, 0
s_load_dwordx8 s[24:31], s[12:13], 0x40
v_lshl_add_u32 v8, s10, 2, v0
v_lshl_add_u32 v9, s11, 1, v1
s_waitcnt lgkmcnt(0)
image_load v[14:17], v[8:9], s[24:31] dmask:0xf dim:SQ_RSRC_IMG_2D
s_waitcnt vmcnt(0)
v_mov_b32_e32 v18, v15
v_mov_b32_e32 v19, v16
v_mov_b32_e32 v20, v17
v_mov_b32_e32 v21, v14
image_store v[18:21], v[8:9], s[24:31] dmask:0xf dim:SQ_RSRC_IMG_2D
s_endpgm
Loading
Loading