From 6dee0421faf3fcdfbbcf7174fa9bad1dc7f366c2 Mon Sep 17 00:00:00 2001 From: RonLogic <307541314+RonLogic@users.noreply.github.com> Date: Sat, 28 Nov 2026 08:40:50 +0200 Subject: [PATCH] runtime: bind published D16 buffer stores to typed UAVs --- .../compute-output-buffer-reasons.md | 29 ++++ src/direct_compute_cache.cpp | 4 + src/native_buffer_store_view.h | 14 +- src/startup_stubs/d3d12_compute_dispatch.inl | 55 ++++++- .../startup_compute_half_buffer_uav.cmake | 17 +++ .../startup_compute_half_buffer_uav_check.py | 135 ++++++++++++++++++ tests/startup_stream_consumer.cpp | 7 +- 7 files changed, 250 insertions(+), 11 deletions(-) create mode 100644 tests/cmake/startup_compute_half_buffer_uav.cmake create mode 100644 tests/startup_compute_half_buffer_uav_check.py diff --git a/docs/experiments/compute-output-buffer-reasons.md b/docs/experiments/compute-output-buffer-reasons.md index 7e6211cc79..0ccfcba270 100644 --- a/docs/experiments/compute-output-buffer-reasons.md +++ b/docs/experiments/compute-output-buffer-reasons.md @@ -67,3 +67,32 @@ No key had `an output view token is not a buffer UAV of a desktop resource` as i the 12 translated keys, and the first refused dispatch of each of the other 11, named a buffer unordered access view of a desktop resource. That run made 2,453,727 compute dispatches, so dispatch counts compare only within one run. Whether the 12 translated keys write the right values was not checked. + +## Published half-width buffer stores + +A native slot 67 request with a `half_buffer_uav` now publishes +`uav bufhalf table bytes `. The +stride selects a typed buffer view of `R16_FLOAT`, `R16G16_FLOAT` or +`R16G16B16A16_FLOAT` for 2, 4 or 8 bytes respectively. The runtime +requires the matching gfx10 buffer format, identity selects over the +written components and structured out-of-bounds mode. It binds the +descriptor's record count and element-aligned offset into an aliased +placed buffer after checking typed-store support. The typed range can +end on a halfword. Raw outputs keep their dword and 16-byte alignment +checks. Buffer UAV tokens are tracked in #2961. + +The source-built check compiles a D16 store for each width with +`compile_dxil --requests`, then runs the published translation through +slot 14. Each dispatch attempts more stores than the view has records. +The reference checks 13 records at a nonzero view offset, plus the +full prefix and suffix. Invalid formats, selectors, strides, swizzle, +out-of-bounds mode and ranges are refused before a dispatch is recorded. + +```powershell +ctest --preset release --no-tests=error -R '^startup_compute_half_buffer_uav_' -V +``` + +The descriptor checks follow the buffer resource format in the +[AMD RDNA 2 ISA](https://docs.amd.com/v/u/en-US/rdna2-shader-instruction-set-architecture). +The matching desktop view uses `FirstElement` and `NumElements` from +the [D3D12 buffer UAV contract](https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_buffer_uav). diff --git a/src/direct_compute_cache.cpp b/src/direct_compute_cache.cpp index 2c4ad29e47..f8f719ef7f 100644 --- a/src/direct_compute_cache.cpp +++ b/src/direct_compute_cache.cpp @@ -809,6 +809,10 @@ std::optional format_compute_runtime_manifest(const NativeComputeSh if (b.kind == ComputeViewKind::raw_buffer_uav) { uav_lines << "uav " << b.shader_register << " table " << b.root_parameter << ' ' << b.byte_offset << '\n'; + } else if (b.kind == ComputeViewKind::half_buffer_uav && b.array_count == 1 && + (b.required_bytes == 2 || b.required_bytes == 4 || b.required_bytes == 8)) { + uav_lines << "uav " << b.shader_register << " bufhalf table " << b.root_parameter << ' ' + << b.byte_offset << " bytes " << b.required_bytes << '\n'; } else if (b.kind == ComputeViewKind::uint_texture_uav && b.image_dimension == 1 && b.array_count == 1) { uav_lines << "uav " << b.shader_register << " tex2d uint table " << b.root_parameter << ' ' << b.byte_offset << " channels 1\n"; diff --git a/src/native_buffer_store_view.h b/src/native_buffer_store_view.h index adda2c12a4..b01d98e6a6 100644 --- a/src/native_buffer_store_view.h +++ b/src/native_buffer_store_view.h @@ -5,6 +5,15 @@ // Preserve the guest view window. The HLSL resource type determines the desktop component type. namespace x2w { +inline DXGI_FORMAT native_half_buffer_format(unsigned bytes) { + switch (bytes) { + case 2: return DXGI_FORMAT_R16_FLOAT; + case 4: return DXGI_FORMAT_R16G16_FLOAT; + case 8: return DXGI_FORMAT_R16G16B16A16_FLOAT; + default: return DXGI_FORMAT_UNKNOWN; + } +} + inline bool native_buffer_store_view(const ComputeViewBinding &binding, D3D12_UNORDERED_ACCESS_VIEW_DESC &view, UINT64 resource_bytes, IndexedAtomicView *atomic = nullptr) { if (view.ViewDimension != D3D12_UAV_DIMENSION_BUFFER || view.Buffer.CounterOffsetInBytes || @@ -53,9 +62,8 @@ inline bool native_buffer_store_view(const ComputeViewBinding &binding, D3D12_UN } else if (view.Buffer.Flags) { return false; } else if (binding.kind == ComputeViewKind::half_buffer_uav) { - if (!((stride == 2 && view.Format == DXGI_FORMAT_R16_FLOAT) || - (stride == 4 && view.Format == DXGI_FORMAT_R16G16_FLOAT) || - (stride == 8 && view.Format == DXGI_FORMAT_R16G16B16A16_FLOAT))) + const auto format = native_half_buffer_format(stride); + if (format == DXGI_FORMAT_UNKNOWN || view.Format != format) return false; } else if (binding.kind == ComputeViewKind::typed_buffer_uav) { const DXGI_FORMAT formats[][3] = { diff --git a/src/startup_stubs/d3d12_compute_dispatch.inl b/src/startup_stubs/d3d12_compute_dispatch.inl index e0cb2a5a3c..53f43c55b9 100644 --- a/src/startup_stubs/d3d12_compute_dispatch.inl +++ b/src/startup_stubs/d3d12_compute_dispatch.inl @@ -2,7 +2,8 @@ // the key of its published request; gfx2hlsl.py --pending answers the request with .txt (`stage cs`) and // .cs.cso. Bound from the compute tables recorded by slot 35 and compute root SRVs recorded by slot 43: raw // buffers (`srv buf table ` and `srv buf root ` inputs, `uav table ` -// outputs) named by hardware buffer descriptors or 64-bit root SRV addresses, and textures +// outputs, or `uav bufhalf table bytes ` for typed half stores) +// named by hardware buffer descriptors or 64-bit root SRV addresses, and textures // (`srv tex2d table ` inputs, `uav tex1d/tex2d/tex2da/tex3d float table channels ` outputs) named // by the token of a view the title created (device slots 18 and 19). `smp`, `smpl` and `smpc` lines become static samplers. Entry // values come from the compute root constants of slots 37 and 39, or from the descriptor a buffer input or output is @@ -37,6 +38,7 @@ struct ComputeTranslation { bool root = false; bool atomic_uint_texture = false; unsigned channels = 4; + unsigned half_buffer_bytes = 0; }; u64 key = 0; int state = 0; // 0 not loaded, 1 ready, 2 unavailable @@ -82,6 +84,16 @@ unsigned float_output_channels(DXGI_FORMAT format) return 0; } } + +bool half_buffer_descriptor_matches(const std::uint32_t* words, unsigned bytes) +{ + // gfx10 V# with identity selectors for each stored component and structured + // bounds (OOB_SELECT=0). Swizzled or padded records need a different view. + const unsigned format = bytes == 2 ? 13 : bytes == 4 ? 29 : 71; + const unsigned selectors = (1u << (3 * (bytes / 2))) - 1; + return (words[1] >> 16) == bytes && (words[3] & (0xfffff000u | selectors)) == + (0x01000000u | (format << 12) | (0xfacu & selectors)); +} std::unordered_map& compute_translations() { static std::unordered_map m; return m; } LONG compute_dispatches_translated, compute_dispatches_refused, compute_dispatches_untranslated, compute_dispatches_unmodelled; LONG compute_inputs_gpu_copied, compute_inputs_snapshot, compute_inputs_snapshot_kib; // inputs by path: this list's GPU copy, a title snapshot @@ -188,6 +200,11 @@ const char* load_compute_translation(ComputeTranslation& tr) tr.srvs.push_back({c, d, false, true, a, b, x, y}); else if (std::sscanf(line.c_str(), "uav %u table %d %d%n", &i, &a, &b, &used) == 3 && whole() && i == tr.uavs.size()) tr.uavs.push_back({a, b}); + else if (std::sscanf(line.c_str(), "uav %u bufhalf table %d %d bytes %u%n", &i, &a, &b, &x, &used) == 4 && + whole() && i == tr.uavs.size() && x2w::native_half_buffer_format(x) != DXGI_FORMAT_UNKNOWN) { + tr.uavs.push_back({a, b}); + tr.uavs.back().half_buffer_bytes = x; + } else if (std::sscanf(line.c_str(), "uav %u tex2d uint table %d %d channels 1%n", &i, &a, &b, &used) == 3 && whole() && i == tr.uavs.size()) { tr.uavs.push_back({a, b, true}); @@ -212,7 +229,7 @@ const char* load_compute_translation(ComputeTranslation& tr) i == tr.samplers.statics.size()) tr.samplers.read_manifest_line(line.c_str()); else return line.rfind("srv", 0) == 0 ? "a resource that is not a raw table buffer or a 2D texture" - : line.rfind("uav", 0) == 0 ? "an output that is not a raw table buffer or a 1D/2D/2D-array/3D float texture" + : line.rfind("uav", 0) == 0 ? "an unsupported compute output view" : line.rfind("udsrc", 0) == 0 ? "an entry value that is not a root constant or a buffer descriptor word" : line.rfind("smp", 0) == 0 ? "a sampler that is not a plain static one" : "an unknown manifest line"; } @@ -399,7 +416,7 @@ const char* record_translated_dispatch(Wrapper* self, const TranslatedDispatch& union { D3D12_SHADER_RESOURCE_VIEW_DESC srv; D3D12_UNORDERED_ACCESS_VIEW_DESC uav; - } desc; // a texture view's description, as the title gave it with a desktop format + } desc; // a described desktop texture or typed buffer view Wrapper* wrapper; std::uint32_t words[4]; // a buffer's descriptor words as it was bound from, and its stride UINT stride; @@ -618,25 +635,49 @@ const char* record_translated_dispatch(Wrapper* self, const TranslatedDispatch& // Each refused condition has its own reason. const u64 address = words[0] | (u64{words[1] & 0xffff} << 32); const UINT stride = (words[1] >> 16) & 0x3fff; + const unsigned half_bytes = slot.half_buffer_bytes; + const unsigned alignment = half_bytes ? half_bytes : D3D12_RAW_UAV_SRV_BYTE_ALIGNMENT; const u64 bytes = u64{stride ? stride : 1} * words[2]; - const bool sized = words[0] != view_token_magic && bytes && bytes % 4 == 0 && bytes <= (16u << 20); + const bool sized = words[0] != view_token_magic && bytes && (half_bytes || bytes % 4 == 0) && bytes <= (16u << 20); const auto placed = sized ? placed_buffer_range(self->own().list_device, address, bytes) : PlacedVertexView{}; const ResourceInfo* info = placed.alias ? resource_info(placed.owner) : nullptr; const u64 offset = placed.alias ? address - reinterpret_cast(placed.owner->own().title_memory) : 0; if (words[0] == view_token_magic) reason = "an output buffer descriptor is a view token"; + else if (half_bytes && !half_buffer_descriptor_matches(words, half_bytes)) + reason = "a half buffer store requires matching format, stride and structured bounds"; else if (!bytes) reason = "an output buffer descriptor has zero records"; - else if (!sized) reason = "an output buffer range is over 16 MiB or not whole dwords"; + else if (!sized) reason = half_bytes ? "an output half buffer range is over 16 MiB" + : "an output buffer range is over 16 MiB or not whole dwords"; else if (placed.reject) reason = "an output range crosses the end of a placed buffer"; else if (!placed.owner) reason = "an output is in title memory outside any placed buffer"; else if (!placed.alias) reason = "an output is in a placed buffer that does not alias title memory"; else if (!info || info->initial_state != D3D12_RESOURCE_STATE_COMMON) reason = "an output buffer's resource was not created in the common state"; - else if (offset % D3D12_RAW_UAV_SRV_BYTE_ALIGNMENT) reason = "an output buffer range is not 16-byte aligned in its resource"; + else if (offset % alignment) reason = half_bytes ? "an output half buffer is not element-aligned in its resource" + : "an output buffer range is not 16-byte aligned in its resource"; else if (!(placed.alias->GetDesc().Flags & D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS)) reason = "an output buffer has no unordered access"; for (std::size_t input = 0; input < inputs && !reason; ++input) if (views[input].resource == placed.alias) reason = "an output buffer is also an input"; views[i] = {placed.alias, offset, bytes, true}; + if (!reason && half_bytes) { + const auto format = x2w::native_half_buffer_format(half_bytes); + D3D12_FEATURE_DATA_FORMAT_SUPPORT support{format}; + constexpr UINT required = D3D12_FORMAT_SUPPORT1_BUFFER | D3D12_FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEW; + if (FAILED(device_of(the_device)->CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT, &support, sizeof(support))) || + (support.Support1 & required) != required || + !(support.Support2 & D3D12_FORMAT_SUPPORT2_UAV_TYPED_STORE)) { + reason = "an output half buffer format does not support typed UAV stores"; + } else { + views[i].described = true; + D3D12_UNORDERED_ACCESS_VIEW_DESC desc{}; + desc.Format = format; + desc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER; + desc.Buffer.FirstElement = offset / half_bytes; + desc.Buffer.NumElements = words[2]; + views[i].desc.uav = desc; + } + } std::memcpy(views[i].words, words, sizeof(views[i].words)); } if (dispatch.argument) @@ -707,7 +748,7 @@ const char* record_translated_dispatch(Wrapper* self, const TranslatedDispatch& continue; } require_state(self, view.resource, D3D12_RESOURCE_STATE_UNORDERED_ACCESS); - if (view.texture) { + if (view.texture || view.described) { device_of(the_device)->CreateUnorderedAccessView(view.resource, nullptr, view.described ? &view.desc.uav : nullptr, dest); continue; diff --git a/tests/cmake/startup_compute_half_buffer_uav.cmake b/tests/cmake/startup_compute_half_buffer_uav.cmake new file mode 100644 index 0000000000..591700ac8f --- /dev/null +++ b/tests/cmake/startup_compute_half_buffer_uav.cmake @@ -0,0 +1,17 @@ +if(TARGET compile_dxil AND EXISTS "${INTAKE_PYTHON}" + AND EXISTS "${DXC_BIN_DIR}/dxcompiler.dll" AND EXISTS "${DXC_BIN_DIR}/dxil.dll") + add_test(NAME startup_compute_half_buffer_uav_controls COMMAND "${INTAKE_PYTHON}" -B + "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_compute_half_buffer_uav_check.py" compile + "$" "${DXC_BIN_DIR}") + set_tests_properties(startup_compute_half_buffer_uav_controls PROPERTIES TIMEOUT 60) +endif() +if(TARGET compile_dxil AND TARGET startup_stream_consumer AND TARGET offscreen_check AND EXISTS "${INTAKE_PYTHON}" + AND EXISTS "${DXC_BIN_DIR}/dxcompiler.dll" AND EXISTS "${DXC_BIN_DIR}/dxil.dll") + foreach(adapter IN ITEMS warp hardware) + add_test(NAME startup_compute_half_buffer_uav_${adapter} COMMAND "${INTAKE_PYTHON}" -B + "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_compute_half_buffer_uav_check.py" + "$" "$" "$" + "${DXC_BIN_DIR}" ${adapter}) + set_tests_properties(startup_compute_half_buffer_uav_${adapter} PROPERTIES TIMEOUT 120 SKIP_RETURN_CODE 77) + endforeach() +endif() diff --git a/tests/startup_compute_half_buffer_uav_check.py b/tests/startup_compute_half_buffer_uav_check.py new file mode 100644 index 0000000000..e941d3aeb1 --- /dev/null +++ b/tests/startup_compute_half_buffer_uav_check.py @@ -0,0 +1,135 @@ +"""Publish a synthetic D16 slot 67 program and check its typed buffer output.""" + +from pathlib import Path +import struct +import subprocess +import sys +from tempfile import TemporaryDirectory + +from native_dpp_mirror_check import vop2 +from native_gather_lod_check import render +from native_scalar_lds_check import scalar, sop1 +from startup_compute_dispatch_check import dispatch, lines, prepare_case +from startup_compute_translate_check import state_a, write_request +from startup_gfx2hlsl_compute_check import SENTINEL, TGID_X, TGID_Y, TGID_Z, USER7, WORDS, root_blob + + +FORMAT_WIDTHS = ((1, 13), (2, 29), (4, 71)) +OFFSET = 8 +RECORDS = 13 +MODE = 'dispatch-records32-output-offset' +STATE = state_a((32, 1, 1), USER7 | TGID_X | TGID_Y | TGID_Z) + + +def program(channels): + opcode = 0x84 + channels - 1 + words = [ + sop1(3, 20, 6), sop1(3, 21, 128), + 0xf408080a, 0xfa000020, # output descriptor s[32:35], table byte 32 + 0xbf8cc07f, + scalar(0x26, 8, 8, 131), # 3 * group.y + scalar(0x26, 9, 9, 134), # 6 * group.z + scalar(0, 11, 7, 8), scalar(0, 11, 11, 9), + scalar(0x1e, 11, 11, 133), # 32 * flat group index + vop2(0x25, 8, 11, 0), # v8 = element index within the view + vop2(0x1d, 1, 255, 0), 0xc0003c00, # v1 = packed [-2, 1 + lane/1024] + 0x7e0402ff, 0xbc003800, # v2 = packed [-1, 0.5] + 0xe0002000 | (opcode << 18), 0x80080108, + 0xbf810000, + ] + return struct.pack('<%dI' % len(words), *words) + + +def expected(channels): + data = bytearray(struct.pack('<%dI' % WORDS, *([SENTINEL] * WORDS))) + for lane in range(RECORDS): + halves = (0x3c00 + lane, 0xc000, 0x3800, 0xbc00) + struct.pack_into('<%dH' % channels, data, OFFSET + lane * channels * 2, *halves[:channels]) + return list(struct.unpack('<%dI' % WORDS, data)) + + +def check_words(got, want, label): + first = next(((i, a, b) for i, (a, b) in enumerate(zip(got, want)) if a != b), None) + if first is not None: + word, actual, expected_word = first + raise AssertionError(f'{label}: word {word} expected {expected_word:08x}, read {actual:08x}') + + +def publish(compile_dxil, sdk, cache, key, stride): + result = subprocess.run([compile_dxil, sdk, cache.parent / 'native', 'gfx1013-direct-cs@0', + '--requests', cache, cache], capture_output=True, text=True, timeout=30) + manifest = cache / f'{key}.txt' + assert result.returncode == 0 and manifest.is_file(), (result.stdout, result.stderr) + text = manifest.read_text() + assert f'uav 0 bufhalf table 1 32 bytes {stride}' in text.splitlines(), text + assert not (cache / f'{key}.cs.hlsl').exists(), 'expected native publication' + + +def check_compiler(compile_dxil, sdk): + with TemporaryDirectory() as directory: + for channels, _ in FORMAT_WIDTHS: + cache = Path(directory) / str(channels) + cache.mkdir() + key = write_request(cache, program(channels), STATE, root=root_blob(table_range=True)) + publish(compile_dxil, sdk, cache, f'{key:016x}', channels * 2) + + +def check(compile_dxil, consumer, sdk, work, adapter, channels, format_code): + cache, env = prepare_case(work, adapter) + env.pop('X2W_NATIVE_SHADERS', None) + env.pop('X2W_NATIVE_SHADERS_ONLY', None) + (work / 'program').write_bytes(program(channels)) + (work / 'state').write_bytes(STATE) + fields = work / 'fields.bin' + env['X2W_TEST_DISPATCH_FIELDS'] = str(fields) + stride = channels * 2 + word3 = 0x01000fac | (format_code << 12) + untouched = [SENTINEL] * WORDS + + def run(view_stride=stride, records=RECORDS, descriptor_word=word3, *, probe=False): + fields.write_bytes(struct.pack('<6I', 4, WORDS, 0, view_stride, records, descriptor_word)) + return dispatch(work, consumer, env, MODE, probe=probe) + + got, result = run(probe=True) + check_words(got, untouched, 'before translation') + assert lines(result, 'Dispatch(3, 2, 2) refused: no translation'), result.stderr[-3000:] + [request] = cache.glob('req_*.c67') + key = request.stem.removeprefix('req_') + publish(compile_dxil, sdk, cache, key, stride) + got, result = run() + check_words(got, expected(channels), f'{channels} channels') + assert len(lines(result, 'Dispatch(3, 2, 2) translated')) == 1 and not lines(result, 'refused:'), result.stderr[-3000:] + assert not [line for line in lines(result, 'x2w-d3d12-debug ') if ' sev=0 ' in line or ' sev=1 ' in line] + layers = lines(result, 'x2w-d3d12 debug layer: ') + layer = 'enabled' if layers and '0x00000000' in layers[0] else 'unavailable' + print(f'{channels} channels: {RECORDS} typed records at byte {OFFSET} and all guards match on {adapter} ' + f'(debug layer {layer})') + + wrong_shape = 'a half buffer store requires matching format, stride and structured bounds' + for options, reason in ( + ({'view_stride': stride + 2}, wrong_shape), + ({'view_stride': stride | 0x8000}, wrong_shape), + ({'descriptor_word': 0x01016fac}, wrong_shape), + ({'descriptor_word': word3 ^ 1}, wrong_shape), + ({'descriptor_word': word3 | 1 << 28}, wrong_shape), + ({'records': WORDS * 4 // stride}, 'an output range crosses the end of a placed buffer'), + ): + got, result = run(**options) + check_words(got, untouched, options) + assert len(lines(result, 'Dispatch(3, 2, 2) refused: ' + reason)) == 1, (options, result.stderr[-3000:]) + print(f'{channels} channels: invalid views refused and output remained untouched') + + +def main(compile_dxil, consumer, renderer, sdk, adapter): + wave = render(renderer, adapter, '--shader-wave32') + assert wave.returncode == 0, wave.stdout + wave.stderr + with TemporaryDirectory() as directory: + for channels, format_code in FORMAT_WIDTHS: + check(compile_dxil, consumer, sdk, Path(directory) / str(channels), adapter, channels, format_code) + + +if __name__ == '__main__': + if sys.argv[1] == 'compile': + check_compiler(*sys.argv[2:]) + else: + main(*sys.argv[1:]) diff --git a/tests/startup_stream_consumer.cpp b/tests/startup_stream_consumer.cpp index 9a89c3dfe1..77eb0ac743 100644 --- a/tests/startup_stream_consumer.cpp +++ b/tests/startup_stream_consumer.cpp @@ -242,6 +242,7 @@ static int dispatch_slot67(IDXGIAdapter* adapter, void* device, const std::strin const bool long_run = keep_closed || mode == "dispatch-input-snapshot-long"; constexpr UINT long_records = 2u << 20, long_frames = 48; const bool shared_uav = mode == "dispatch-read-write-uav"; + const bool typed_output_offset = mode == "dispatch-records32-output-offset"; const bool indirect = mode.rfind("dispatch-indirect-", 0) == 0; const bool pixel = mode.rfind("dispatch-indirect-pixel-", 0) == 0; const bool write_zero = mode == "dispatch-indirect-pixel-zero"; @@ -322,6 +323,10 @@ static int dispatch_slot67(IDXGIAdapter* adapter, void* device, const std::strin } else if (mode == "dispatch-output-unaligned") { descriptors[1][0] += 8; // still inside the buffer: 318 records descriptors[1][2] = words - 2; + } else if (typed_output_offset) { + const UINT64 address = reinterpret_cast(buffers[1]) + 8; + descriptors[1][0] = static_cast(address); + descriptors[1][1] = static_cast(address >> 32) | fields[1][0] << 16; } const struct { D3D12_DESCRIPTOR_HEAP_DESC desc; @@ -359,7 +364,7 @@ static int dispatch_slot67(IDXGIAdapter* adapter, void* device, const std::strin } else { std::memcpy(reinterpret_cast(cpu), descriptors, sizeof(descriptors)); } - if (mode == "dispatch-records32" || shared_uav) { // the output's descriptor at table byte 32, none at byte 16 + if (mode == "dispatch-records32" || typed_output_offset || shared_uav) { // output at byte 32, none at byte 16 std::memset(reinterpret_cast(cpu + sizeof(descriptors[0])), 0, sizeof(descriptors[1])); std::memcpy(reinterpret_cast(cpu + 32), descriptors[1], sizeof(descriptors[1])); }