From 89fd41b02b8f6c8a16b282c16925f6c4bfd76e8d Mon Sep 17 00:00:00 2001 From: saii <120340942+Not-Saii@users.noreply.github.com> Date: Sat, 28 Nov 2026 19:51:27 +0200 Subject: [PATCH 1/6] runtime: bind published typed buffer inputs with 32-bit components format_compute_runtime_manifest writes `srv typed table bytes ` for a typed_buffer_srv (buffer_load_format_*, read as Buffer), n being the widest load. The stand-in resolves the title's hardware descriptor or slot 18 typed buffer view token as a buffer range and binds a UINT view of its 32-bit components; every other shape is refused with a named reason. Refs #3224 Co-Authored-By: Claude Opus 5.5 --- src/direct_compute_cache.cpp | 5 + src/startup_stubs/d3d12_compute_dispatch.inl | 85 +++++++++- .../startup_compute_typed_buffer_srv.cmake | 18 ++ .../startup_compute_typed_buffer_srv_check.py | 160 ++++++++++++++++++ tests/startup_stream_consumer.cpp | 8 + 5 files changed, 274 insertions(+), 2 deletions(-) create mode 100644 tests/cmake/startup_compute_typed_buffer_srv.cmake create mode 100644 tests/startup_compute_typed_buffer_srv_check.py diff --git a/src/direct_compute_cache.cpp b/src/direct_compute_cache.cpp index 79dcc6b3c5..ad604dda5c 100644 --- a/src/direct_compute_cache.cpp +++ b/src/direct_compute_cache.cpp @@ -957,6 +957,11 @@ std::optional format_compute_runtime_manifest(const NativeComputeSh b.kind == ComputeViewKind::byte_window_srv) { srv_lines << "srv " << b.shader_register << " buf table " << b.root_parameter << ' ' << b.byte_offset << '\n'; + } else if (b.kind == ComputeViewKind::typed_buffer_srv && b.array_count == 1 && b.required_bytes && + b.required_bytes <= 16 && b.required_bytes % 4 == 0) { + // buffer_load_format_*: read as Buffer; bytes is the widest load (4 per component). + srv_lines << "srv " << b.shader_register << " typed table " << b.root_parameter << ' ' << b.byte_offset + << " bytes " << b.required_bytes << '\n'; } else if (b.kind == ComputeViewKind::texture_srv && b.array_count == 1 && (b.image_dimension == 0 || b.image_dimension == 1 || b.image_dimension == 2 || b.image_dimension == 5)) { diff --git a/src/startup_stubs/d3d12_compute_dispatch.inl b/src/startup_stubs/d3d12_compute_dispatch.inl index ce571a0f8f..e4de460034 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, or `uav bufhalf table bytes ` for typed half stores) +// outputs, or `uav bufhalf table bytes ` for typed half stores; `srv typed table +// bytes ` inputs are read through a UINT view of 32-bit components) // named by hardware buffer descriptors or 64-bit root SRV addresses, and textures // (`srv tex1d|tex2d|tex2da|tex3d 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 @@ -44,6 +45,7 @@ struct ComputeTranslation { unsigned channels = 4; D3D12_SRV_DIMENSION srv_dimension = D3D12_SRV_DIMENSION_UNKNOWN; unsigned half_buffer_bytes = 0; + unsigned typed_bytes = 0; // `srv typed`: the widest formatted load, 4 bytes per component }; u64 key = 0; int state = 0; // 0 not loaded, 1 ready, 2 unavailable @@ -101,6 +103,65 @@ bool half_buffer_descriptor_matches(const std::uint32_t* words, unsigned bytes) return (words[1] >> 16) == bytes && (words[3] & (0xfffff000u | selectors)) == (0x01000000u | (format << 12) | (0xfacu & selectors)); } +// Channels of a gfx10 unified buffer FORMAT with 32-bit components (UINT, SINT or FLOAT; tools/startup/gfx2hlsl.py +// names the codes): a UINT view of that width reads the bits buffer_load_format returns. 0 for any other FORMAT. +unsigned typed_dword_format_channels(std::uint32_t code) +{ + switch (code) { + case 20: case 21: case 22: return 1; + case 62: case 63: case 64: return 2; + case 72: case 73: case 74: return 3; + case 75: case 76: case 77: return 4; + default: return 0; + } +} + +// The view a translated buffer_load_format_* reads (`srv typed`, a Buffer): the title's descriptor +// resolved as a buffer range, retyped to the UINT format of its 32-bit components. Returns the refusal or null. +const char* typed_dword_input_view(Wrapper* self, const std::uint32_t* words, unsigned typed_bytes, + IndirectBufferView& range, D3D12_SHADER_RESOURCE_VIEW_DESC& view) +{ + UINT channels = 0; + if (words[0] == view_token_magic) { + ViewRecord record{}; + AcquireSRWLockShared(¬e_lock); + const bool known = words[1] < view_records().size(); + if (known) record = view_records()[words[1]]; + ReleaseSRWLockShared(¬e_lock); + D3D12_SHADER_RESOURCE_VIEW_DESC desc{}; + if (known && record.slot == 18 && record.desc_bytes >= ViewRecord::srv_desc_bytes) + std::memcpy(&desc, record.desc, ViewRecord::srv_desc_bytes); + if (desc.Format) desc.Format = desktop_format(desc.Format); + channels = x2w_startup::typed_dword_channels(desc); + if (!channels) return "a typed input token is not a typed buffer view with 32-bit channels"; + } else if (words[0] || words[1] || words[2] || words[3]) { + // An all-zero descriptor is a null buffer: indirect_table_buffer gives it zeros, read as the program's width. + channels = typed_dword_format_channels(x2w_startup::formatted_buffer_code(words[3])); + if (!channels) return "a typed input FORMAT is not 32 bits per channel"; + if (((words[1] >> 16) & 0x3fff) != channels * 4) return "a typed input stride is not its element size"; + for (unsigned c = 0; c < typed_bytes / 4; ++c) + if (((words[3] >> (3 * c)) & 7) != 4 + c) return "a typed input DST_SEL is not the identity"; + // Unified FORMAT (RESOURCE_LEVEL 1), structured bounds (OOB_SELECT 0), no swizzle, index stride or ADD_TID. + if ((words[1] >> 30) || (words[3] & 0xfff80000u) != 0x01000000u) + return "a typed input descriptor is swizzled or not bounds-checked by record"; + } else { + channels = 4; // the 16 zero bytes indirect_table_buffer gives a null buffer, one element + } + if (channels * 4 < typed_bytes) return "a typed input has fewer channels than the program reads"; + const char* reason = nullptr; + range = indirect_table_buffer(self, words, false, &reason, 16u << 20, 4, true); + if (reason) return reason; + const UINT element = channels * 4; + if (range.offset % element || range.bytes < element) return "a typed input range does not start at a whole element"; + view = {}; + view.Format = x2w_startup::typed_dword_uint_format(channels); + view.ViewDimension = D3D12_SRV_DIMENSION_BUFFER; + view.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; + view.Buffer.FirstElement = range.offset / element; + view.Buffer.NumElements = static_cast(range.bytes / element); + return nullptr; +} + 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 @@ -202,6 +263,11 @@ const char* load_compute_translation(ComputeTranslation& tr) tr.uds.push_back({a, 0, false, false, -1, 0, 0, 0, source()}); else if (std::sscanf(line.c_str(), "srv %u buf table %d %d%n", &i, &a, &b, &used) == 3 && whole() && i == tr.srvs.size()) tr.srvs.push_back({a, b}); + else if (std::sscanf(line.c_str(), "srv %u typed table %d %d bytes %u%n", &i, &a, &b, &x, &used) == 4 && whole() && + i == tr.srvs.size() && x && x <= 16 && x % 4 == 0) { + tr.srvs.push_back({a, b}); + tr.srvs.back().typed_bytes = x; + } else if (std::sscanf(line.c_str(), "srv %u buf root %d%n", &i, &a, &used) == 2 && whole() && a >= 0 && i == tr.srvs.size()) { tr.srvs.push_back({a, 0}); @@ -605,7 +671,7 @@ const char* record_translated_dispatch(Wrapper* self, const TranslatedDispatch& for (std::size_t i = 0; i < count && !reason; ++i) { const bool output = i >= inputs; const ComputeTranslation::Slot slot = output ? tr->uavs[i - inputs] : tr->srvs[i]; - if (dispatch.signature && (slot.heap || slot.texture || slot.root)) { + if (dispatch.signature && (slot.heap || slot.texture || slot.root || slot.typed_bytes)) { reason = "translated indirect Dispatch requires fixed-table raw buffers"; break; } @@ -772,6 +838,16 @@ const char* record_translated_dispatch(Wrapper* self, const TranslatedDispatch& views[i].wrapper = wrapper; continue; } + if (!output && slot.typed_bytes) { + IndirectBufferView range{}; + D3D12_SHADER_RESOURCE_VIEW_DESC typed{}; + reason = typed_dword_input_view(self, words, slot.typed_bytes, range, typed); + views[i] = {range.resource, range.offset, range.bytes, !range.upload, false, true}; + views[i].desc.srv = typed; + views[i].stride = range.stride; + std::memcpy(views[i].words, words, sizeof(views[i].words)); + continue; + } if (!output) { // Each condition of a complete GPU-backed buffer range has its own reason. auto view = indirect_table_buffer(self, words, false, &reason, 16u << 20, D3D12_RAW_UAV_SRV_BYTE_ALIGNMENT, true); @@ -992,6 +1068,11 @@ const char* record_translated_dispatch(Wrapper* self, const TranslatedDispatch& view.described ? &view.desc.srv : nullptr, dest); continue; } + if (i < inputs && view.described) { // a typed buffer input + if (view.transition) require_state(self, view.resource, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); + device_of(the_device)->CreateShaderResourceView(view.resource, &view.desc.srv, dest); + continue; + } if (i < inputs || i >= count) { if (view.transition) require_state(self, view.resource, D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); buffer_view(dest, view.resource, view.offset, static_cast(view.bytes)); diff --git a/tests/cmake/startup_compute_typed_buffer_srv.cmake b/tests/cmake/startup_compute_typed_buffer_srv.cmake new file mode 100644 index 0000000000..aedb10f630 --- /dev/null +++ b/tests/cmake/startup_compute_typed_buffer_srv.cmake @@ -0,0 +1,18 @@ +# Typed buffer inputs (buffer_load_format_*) on the published compute route (#3224). +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_typed_buffer_srv_controls COMMAND "${INTAKE_PYTHON}" -B + "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_compute_typed_buffer_srv_check.py" compile + "$" "${DXC_BIN_DIR}") + set_tests_properties(startup_compute_typed_buffer_srv_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_typed_buffer_srv_${adapter} COMMAND "${INTAKE_PYTHON}" -B + "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_compute_typed_buffer_srv_check.py" + "$" "$" "$" + "${DXC_BIN_DIR}" ${adapter}) + set_tests_properties(startup_compute_typed_buffer_srv_${adapter} PROPERTIES TIMEOUT 180 SKIP_RETURN_CODE 77) + endforeach() +endif() diff --git a/tests/startup_compute_typed_buffer_srv_check.py b/tests/startup_compute_typed_buffer_srv_check.py new file mode 100644 index 0000000000..8403311fba --- /dev/null +++ b/tests/startup_compute_typed_buffer_srv_check.py @@ -0,0 +1,160 @@ +"""Publish a synthetic slot 67 program with buffer_load_format_* and check its typed buffer input (#3224). + +The program reads input element `index` with buffer_load_format_ (IDXEN) from table byte 0 and stores the n +dwords raw at output byte 4 * n * index (table byte 16). compile_dxil publishes `srv 0 typed table 1 0 bytes 4n`; +the stand-in binds a UINT view of the title's 32-bit components. Fewer records than lanes checks the zeros past +the view's last element. + +usage: + startup_compute_typed_buffer_srv_check.py compile + startup_compute_typed_buffer_srv_check.py +""" + +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 + +STATE = state_a((32, 1, 1), USER7 | TGID_X | TGID_Y | TGID_Z) +FLOAT_FORMATS = {1: 22, 2: 64, 3: 74, 4: 77} # gfx10 BUF_FMT_32[_32[_32[_32]]]_FLOAT +STORES = {1: 0x1c, 2: 0x1d, 3: 0x1f, 4: 0x1e} # buffer_store_dword[x2|x3|x4] +RECORDS = 50 +INPUT = [(0x8b02a7f1 + i * 0x413b1) & 0xffffffff for i in range(WORDS)] # the consumer's input words +DXGI_R32G32B32A32_FLOAT, DXGI_R8G8B8A8_UNORM = 2, 28 + + +def program(channels): + offset = (vop2(0x0b, 9, 128 + 12, 8) if channels == 3 else # v9 = 12 * v8 + vop2(0x1a, 9, 128 + {1: 2, 2: 3, 4: 4}[channels], 8)) # v9 = v8 << log2(4n) + words = [ + sop1(3, 20, 6), sop1(3, 21, 128), + 0xf408080a, 0xfa000010, # output descriptor s[32:35], table byte 16 + 0xf408090a, 0xfa000000, # input descriptor s[36:39], table byte 0 + 0xbf8cc07f, # s_waitcnt lgkmcnt(0) + 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 + 0xe0002000 | (channels - 1) << 18, 0x80090108, # buffer_load_format_ v[1:n], v8, s[36:39] idxen + 0xbf8c3f70, # s_waitcnt vmcnt(0) + offset, + 0xe0001000 | STORES[channels] << 18, 0x80080109, # buffer_store_dword v[1:n], v9, s[32:35] offen + 0xbf810000, + ] + return struct.pack('<%dI' % len(words), *words) + + +def output_records(channels): + return WORDS // channels * channels # no store crosses the end of the output view + + +def expected(channels): + return [INPUT[k] if k < RECORDS * channels else 0 if k < output_records(channels) else SENTINEL + for k in range(WORDS)] + + +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, channels): + result = subprocess.run([compile_dxil, sdk, cache.parent / 'native', 'gfx1013-direct-cs@0', + '--requests', cache, cache], capture_output=True, text=True, timeout=60) + manifest = cache / f'{key}.txt' + assert result.returncode == 0 and manifest.is_file(), (result.stdout, result.stderr) + text = manifest.read_text().splitlines() + assert f'srv 0 typed table 1 0 bytes {4 * channels}' in text and 'uav 0 table 1 16' in text, text + + +def check_compiler(compile_dxil, sdk): + with TemporaryDirectory() as directory: + for channels in FLOAT_FORMATS: + 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) + print('compile_dxil publishes srv typed lines for 1 to 4 components') + + +def check(compile_dxil, consumer, sdk, work, adapter, channels): + 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) + word3 = 0x01000fac | FLOAT_FORMATS[channels] << 12 + untouched = [SENTINEL] * WORDS + + def run(stride=4 * channels, records=RECORDS, descriptor_word=word3, mode='dispatch', *, probe=False): + fields.write_bytes(struct.pack('<6I', stride, records, descriptor_word, 4, output_records(channels), 0)) + 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, channels) + + def translated(label, **options): + got, result = run(**options) + check_words(got, expected(channels), label) + 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] + return result + + result = translated(f'{channels} channels') + layers = lines(result, 'x2w-d3d12 debug layer: ') + layer = 'enabled' if layers and '0x00000000' in layers[0] else 'unavailable' + print(f'{channels} channels: {RECORDS} typed elements, then zeros, on {adapter} (debug layer {layer})') + + refusals = [ + ({'descriptor_word': 0x01038fac}, 'a typed input FORMAT is not 32 bits per channel'), # 8_8_8_8_UNORM + ({'stride': 4 * channels + 4}, 'a typed input stride is not its element size'), + ({'descriptor_word': word3 | 3 << 28}, 'a typed input descriptor is swizzled or not bounds-checked by record'), + ({'descriptor_word': word3 & ~0x01000000}, 'a typed input descriptor is swizzled or not bounds-checked by record'), + ] + if channels > 1: + refusals.append(({'descriptor_word': word3 & ~0xfff | 0xfa5}, 'a typed input DST_SEL is not the identity')) # X, Y swapped + narrow = 0x01000fac | FLOAT_FORMATS[channels - 1] << 12 + refusals.append(({'descriptor_word': narrow, 'stride': 4 * (channels - 1)}, + 'a typed input has fewer channels than the program reads')) + if channels == 4: + translated('view token', mode='dispatch-srv-token-typed', descriptor_word=DXGI_R32G32B32A32_FLOAT) + refusals.append(({'mode': 'dispatch-srv-token-typed', 'descriptor_word': DXGI_R8G8B8A8_UNORM}, + 'a typed input token is not a typed buffer view with 32-bit channels')) + print('4 channels: a slot 18 typed buffer view token reads the same elements') + for options, reason in refusals: + 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: {len(refusals)} invalid inputs refused and the 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 in FLOAT_FORMATS: + check(compile_dxil, consumer, sdk, Path(directory) / str(channels), adapter, channels) + + +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 092b6e91e0..d5ef25bfd5 100644 --- a/tests/startup_stream_consumer.cpp +++ b/tests/startup_stream_consumer.cpp @@ -436,6 +436,14 @@ static int dispatch_slot67(IDXGIAdapter* adapter, void* device, const std::strin if (mode == "dispatch-uav-token-wrong-slot") reinterpret_cast(cpu + 32)[2] = 18; } + if (mode == "dispatch-srv-token-typed") { + // dispatch-srv-token-typed: the input descriptor is the token of a typed buffer view (device slot 18) of the + // input buffer; for this mode the input's word 3 field is the view's DXGI format, its records field the elements. + D3D12_SHADER_RESOURCE_VIEW_DESC view{static_cast(fields[0][2]), D3D12_SRV_DIMENSION_BUFFER, + D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING}; + view.Buffer.NumElements = fields[0][1]; + invoke(device, 18, word(placed[0]), word(&view), cpu); + } const bool heap_record = mode.rfind("dispatch-heap", 0) == 0 && !heap_waterfall; if (heap_record) for (const UINT at : {0u, 32u, 64u}) From 9a414d1735a1072a4dc673bd6b2e8eba8386a5c3 Mon Sep 17 00:00:00 2001 From: saii <120340942+Not-Saii@users.noreply.github.com> Date: Sat, 28 Nov 2026 19:58:44 +0200 Subject: [PATCH 2/6] tests: put the typed buffer fixture's output at table byte 32 Co-Authored-By: Claude Opus 5.5 --- tests/startup_compute_typed_buffer_srv_check.py | 8 ++++---- tests/startup_stream_consumer.cpp | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/startup_compute_typed_buffer_srv_check.py b/tests/startup_compute_typed_buffer_srv_check.py index 8403311fba..13bbaa34ce 100644 --- a/tests/startup_compute_typed_buffer_srv_check.py +++ b/tests/startup_compute_typed_buffer_srv_check.py @@ -1,7 +1,7 @@ """Publish a synthetic slot 67 program with buffer_load_format_* and check its typed buffer input (#3224). The program reads input element `index` with buffer_load_format_ (IDXEN) from table byte 0 and stores the n -dwords raw at output byte 4 * n * index (table byte 16). compile_dxil publishes `srv 0 typed table 1 0 bytes 4n`; +dwords raw at output byte 4 * n * index (table byte 32). compile_dxil publishes `srv 0 typed table 1 0 bytes 4n`; the stand-in binds a UINT view of the title's 32-bit components. Fewer records than lanes checks the zeros past the view's last element. @@ -36,7 +36,7 @@ def program(channels): vop2(0x1a, 9, 128 + {1: 2, 2: 3, 4: 4}[channels], 8)) # v9 = v8 << log2(4n) words = [ sop1(3, 20, 6), sop1(3, 21, 128), - 0xf408080a, 0xfa000010, # output descriptor s[32:35], table byte 16 + 0xf408080a, 0xfa000020, # output descriptor s[32:35], table byte 32 0xf408090a, 0xfa000000, # input descriptor s[36:39], table byte 0 0xbf8cc07f, # s_waitcnt lgkmcnt(0) scalar(0x26, 8, 8, 131), # 3 * group.y @@ -75,7 +75,7 @@ def publish(compile_dxil, sdk, cache, key, channels): manifest = cache / f'{key}.txt' assert result.returncode == 0 and manifest.is_file(), (result.stdout, result.stderr) text = manifest.read_text().splitlines() - assert f'srv 0 typed table 1 0 bytes {4 * channels}' in text and 'uav 0 table 1 16' in text, text + assert f'srv 0 typed table 1 0 bytes {4 * channels}' in text and 'uav 0 table 1 32' in text, text def check_compiler(compile_dxil, sdk): @@ -99,7 +99,7 @@ def check(compile_dxil, consumer, sdk, work, adapter, channels): word3 = 0x01000fac | FLOAT_FORMATS[channels] << 12 untouched = [SENTINEL] * WORDS - def run(stride=4 * channels, records=RECORDS, descriptor_word=word3, mode='dispatch', *, probe=False): + def run(stride=4 * channels, records=RECORDS, descriptor_word=word3, mode='dispatch-records32', *, probe=False): fields.write_bytes(struct.pack('<6I', stride, records, descriptor_word, 4, output_records(channels), 0)) return dispatch(work, consumer, env, mode, probe=probe) diff --git a/tests/startup_stream_consumer.cpp b/tests/startup_stream_consumer.cpp index d5ef25bfd5..ff22023047 100644 --- a/tests/startup_stream_consumer.cpp +++ b/tests/startup_stream_consumer.cpp @@ -397,7 +397,8 @@ static int dispatch_slot67(IDXGIAdapter* adapter, void* device, const std::strin std::memcpy(reinterpret_cast(cpu + 64), window, sizeof(window)); std::memcpy(reinterpret_cast(cpu + 32), descriptors[1], sizeof(descriptors[1])); } - if (mode == "dispatch-records32" || typed_output_offset || shared_uav) { // output at byte 32, none at byte 16 + if (mode == "dispatch-records32" || typed_output_offset || shared_uav || + mode == "dispatch-srv-token-typed") { // 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])); } From 4a2720e0eead27ab79971185d9872e488f7b9edd Mon Sep 17 00:00:00 2001 From: saii <120340942+Not-Saii@users.noreply.github.com> Date: Sat, 28 Nov 2026 20:00:04 +0200 Subject: [PATCH 3/6] docs: note the published typed buffer input contract and measurements Co-Authored-By: Claude Opus 5.5 --- .../compute-typed-buffer-inputs.md | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 docs/experiments/compute-typed-buffer-inputs.md diff --git a/docs/experiments/compute-typed-buffer-inputs.md b/docs/experiments/compute-typed-buffer-inputs.md new file mode 100644 index 0000000000..aaf9d9f6be --- /dev/null +++ b/docs/experiments/compute-typed-buffer-inputs.md @@ -0,0 +1,56 @@ +# Published typed buffer inputs (`srv typed`) + +Part of #3224. The direct compiler reads `buffer_load_format_x` to `_xyzw` (MUBUF, element index only) as a +`Buffer` (`typed_buffer_srv`). `format_compute_runtime_manifest` now publishes it as +`srv typed table bytes `, where `n` is 4 bytes per component of the widest load +of that binding. + +The stand-in (`src/startup_stubs/d3d12_compute_dispatch.inl`) resolves the table entry with the existing input +range rules and binds a UINT buffer view of the title's 32-bit components: `R32_UINT` to `R32G32B32A32_UINT`. A +UINT view returns the same bits as the guest format unit only for 32-bit UINT, SINT and FLOAT components, so only +those are bound: + +- **Hardware descriptor:** FORMAT 20-22, 62-64, 72-74 or 75-77 (gfx10 `BUF_FMT_32*`), stride equal to the + element size, identity DST_SEL over the components read, unified FORMAT (RESOURCE_LEVEL 1), structured bounds + (OOB_SELECT 0), and no swizzle, index stride or ADD_TID. +- **Slot 18 view token:** a typed buffer view with 32-bit channels and the default component mapping, read through + the UINT format of the same width (`typed_dword_channels` / `typed_dword_uint_format` in + `src/startup_stubs/native_buffer_stride.h`). +- **All four words zero:** a null buffer that reads zeros, as for raw inputs. + +Each other shape is refused before a dispatch is recorded, with one of these reasons: + +- `a typed input FORMAT is not 32 bits per channel` +- `a typed input stride is not its element size` +- `a typed input DST_SEL is not the identity` +- `a typed input descriptor is swizzled or not bounds-checked by record` +- `a typed input has fewer channels than the program reads` +- `a typed input token is not a typed buffer view with 32-bit channels` +- `a typed input range does not start at a whole element` + +The range checks of raw inputs also apply. A typed input on an indirect Dispatch is refused, and the in-process +`X2W_NATIVE_SHADERS` route is unchanged. 8- and 16-bit formats, UNORM, SNORM and 16-bit FLOAT need a conversion +that a UINT view does not do. + +## Test + +`tests/startup_compute_typed_buffer_srv_check.py` publishes a source-built program for 1 to 4 components with +`compile_dxil --requests`. It then dispatches it through slot 14 with a 32-bit FLOAT descriptor of 50 elements. +The 384 lanes store what they read, so the lanes past element 49 must read zeros. The 4-component case also reads +through a slot 18 `R32G32B32A32_FLOAT` view token (consumer mode `dispatch-srv-token-typed`). Each invalid shape +above must be refused with the output untouched. Before publication the dispatch reports `no translation`. + +```powershell +ctest --preset dev --no-tests=error -R '^startup_compute_typed_buffer_srv_' -V +``` + +Measured at `d418f70e` plus this change, on Windows 11 build 26300 with the Windows SDK 10.0.26100 DXC, Debug, +with the D3D12 debug layer enabled: + +- **NVIDIA GeForce RTX 4090, driver 32.0.16.1088:** passed for 1, 2, 3 and 4 components, the token, and 4, 6, 6 + and 7 refusal controls. +- **WARP 10.0.26100.9818:** capability skip (77). WARP reports 4-lane waves and the direct module needs 32. +- **Negative control:** with the runtime's parse of the `typed` line disabled, the published manifest is not + bound and the hardware check reads the sentinel at word 0. + +Not measured: how many of the cohort's typed inputs have a 32-bit FORMAT. The census re-measure answers that. From da4fe59c0b5ca772c2044844302daf9982777dee Mon Sep 17 00:00:00 2001 From: saii <120340942+Not-Saii@users.noreply.github.com> Date: Sat, 28 Nov 2026 22:12:03 +0200 Subject: [PATCH 4/6] tests: cover typed input offsets, integer FORMATs and word 1 swizzle bits Review of #3386: four mutations of the typed input view still passed. The hardware check now also reads each width through its UINT and SINT FORMATs and through a descriptor based one element into the buffer (new consumer mode dispatch-records32-input-at-), and refuses a base 4 bytes in (2 or more components) and a stride field with bit 30. Refs #3224 Co-Authored-By: Claude Opus 5.5 --- docs/experiments/compute-typed-buffer-inputs.md | 6 ++++-- tests/startup_compute_typed_buffer_srv_check.py | 16 ++++++++++++---- tests/startup_stream_consumer.cpp | 9 ++++++++- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/docs/experiments/compute-typed-buffer-inputs.md b/docs/experiments/compute-typed-buffer-inputs.md index aaf9d9f6be..b46968f016 100644 --- a/docs/experiments/compute-typed-buffer-inputs.md +++ b/docs/experiments/compute-typed-buffer-inputs.md @@ -37,8 +37,10 @@ that a UINT view does not do. `tests/startup_compute_typed_buffer_srv_check.py` publishes a source-built program for 1 to 4 components with `compile_dxil --requests`. It then dispatches it through slot 14 with a 32-bit FLOAT descriptor of 50 elements. The 384 lanes store what they read, so the lanes past element 49 must read zeros. The 4-component case also reads -through a slot 18 `R32G32B32A32_FLOAT` view token (consumer mode `dispatch-srv-token-typed`). Each invalid shape -above must be refused with the output untouched. Before publication the dispatch reports `no translation`. +through a slot 18 `R32G32B32A32_FLOAT` view token (consumer mode `dispatch-srv-token-typed`). Each width also +reads through its UINT and SINT FORMATs, and through a descriptor based one element into the buffer (consumer mode +`dispatch-records32-input-at-`), which shifts the words read by one element. Each invalid shape above must +be refused with the output untouched, including a base 4 bytes in for 2 or more components and word 1 bit 30. Before publication the dispatch reports `no translation`. ```powershell ctest --preset dev --no-tests=error -R '^startup_compute_typed_buffer_srv_' -V diff --git a/tests/startup_compute_typed_buffer_srv_check.py b/tests/startup_compute_typed_buffer_srv_check.py index 13bbaa34ce..2d568e38d7 100644 --- a/tests/startup_compute_typed_buffer_srv_check.py +++ b/tests/startup_compute_typed_buffer_srv_check.py @@ -25,6 +25,7 @@ STATE = state_a((32, 1, 1), USER7 | TGID_X | TGID_Y | TGID_Z) FLOAT_FORMATS = {1: 22, 2: 64, 3: 74, 4: 77} # gfx10 BUF_FMT_32[_32[_32[_32]]]_FLOAT +INTEGER_FORMATS = {1: (20, 21), 2: (62, 63), 3: (72, 73), 4: (75, 76)} # the _UINT and _SINT codes of each width STORES = {1: 0x1c, 2: 0x1d, 3: 0x1f, 4: 0x1e} # buffer_store_dword[x2|x3|x4] RECORDS = 50 INPUT = [(0x8b02a7f1 + i * 0x413b1) & 0xffffffff for i in range(WORDS)] # the consumer's input words @@ -57,8 +58,9 @@ def output_records(channels): return WORDS // channels * channels # no store crosses the end of the output view -def expected(channels): - return [INPUT[k] if k < RECORDS * channels else 0 if k < output_records(channels) else SENTINEL +def expected(channels, first=0): + # first: the element the descriptor starts at; its records follow. + return [INPUT[first * channels + k] if k < RECORDS * channels else 0 if k < output_records(channels) else SENTINEL for k in range(WORDS)] @@ -110,9 +112,9 @@ def run(stride=4 * channels, records=RECORDS, descriptor_word=word3, mode='dispa key = request.stem.removeprefix('req_') publish(compile_dxil, sdk, cache, key, channels) - def translated(label, **options): + def translated(label, first=0, **options): got, result = run(**options) - check_words(got, expected(channels), label) + check_words(got, expected(channels, first), label) 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] return result @@ -121,18 +123,24 @@ def translated(label, **options): layers = lines(result, 'x2w-d3d12 debug layer: ') layer = 'enabled' if layers and '0x00000000' in layers[0] else 'unavailable' print(f'{channels} channels: {RECORDS} typed elements, then zeros, on {adapter} (debug layer {layer})') + for code in INTEGER_FORMATS[channels]: + translated(f'{channels} channels, FORMAT {code}', descriptor_word=0x01000fac | code << 12) + translated(f'{channels} channels, base one element in', first=1, mode=f'dispatch-records32-input-at-{4 * channels}') + print(f'{channels} channels: the UINT and SINT FORMATs read the same words, and a base one element in shifts them') refusals = [ ({'descriptor_word': 0x01038fac}, 'a typed input FORMAT is not 32 bits per channel'), # 8_8_8_8_UNORM ({'stride': 4 * channels + 4}, 'a typed input stride is not its element size'), ({'descriptor_word': word3 | 3 << 28}, 'a typed input descriptor is swizzled or not bounds-checked by record'), ({'descriptor_word': word3 & ~0x01000000}, 'a typed input descriptor is swizzled or not bounds-checked by record'), + ({'stride': 0x4000 | 4 * channels}, 'a typed input descriptor is swizzled or not bounds-checked by record'), # word 1 bit 30 ] if channels > 1: refusals.append(({'descriptor_word': word3 & ~0xfff | 0xfa5}, 'a typed input DST_SEL is not the identity')) # X, Y swapped narrow = 0x01000fac | FLOAT_FORMATS[channels - 1] << 12 refusals.append(({'descriptor_word': narrow, 'stride': 4 * (channels - 1)}, 'a typed input has fewer channels than the program reads')) + refusals.append(({'mode': 'dispatch-records32-input-at-4'}, 'a typed input range does not start at a whole element')) if channels == 4: translated('view token', mode='dispatch-srv-token-typed', descriptor_word=DXGI_R32G32B32A32_FLOAT) refusals.append(({'mode': 'dispatch-srv-token-typed', 'descriptor_word': DXGI_R8G8B8A8_UNORM}, diff --git a/tests/startup_stream_consumer.cpp b/tests/startup_stream_consumer.cpp index ff22023047..442f6676eb 100644 --- a/tests/startup_stream_consumer.cpp +++ b/tests/startup_stream_consumer.cpp @@ -243,6 +243,9 @@ static int dispatch_slot67(IDXGIAdapter* adapter, void* device, const std::strin 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"; + // dispatch-records32-input-at-: dispatch-records32 with the input descriptor that many bytes into its buffer. + const std::string input_at = "dispatch-records32-input-at-"; + const UINT input_offset = mode.rfind(input_at, 0) == 0 ? static_cast(std::stoul(mode.substr(input_at.size()))) : 0; const bool indirect = mode.rfind("dispatch-indirect-", 0) == 0; const bool heap_waterfall = mode.rfind("dispatch-heap-waterfall", 0) == 0; const bool pixel = mode.rfind("dispatch-indirect-pixel-", 0) == 0; @@ -344,6 +347,10 @@ static int dispatch_slot67(IDXGIAdapter* adapter, void* device, const std::strin 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; + } else if (input_offset) { + const UINT64 address = reinterpret_cast(buffers[0]) + input_offset; + descriptors[0][0] = static_cast(address); + descriptors[0][1] = static_cast(address >> 32) | fields[0][0] << 16; } const bool heap_short = mode == "dispatch-heap-waterfall-short"; const struct { @@ -397,7 +404,7 @@ static int dispatch_slot67(IDXGIAdapter* adapter, void* device, const std::strin std::memcpy(reinterpret_cast(cpu + 64), window, sizeof(window)); std::memcpy(reinterpret_cast(cpu + 32), descriptors[1], sizeof(descriptors[1])); } - if (mode == "dispatch-records32" || typed_output_offset || shared_uav || + if (mode == "dispatch-records32" || typed_output_offset || input_offset || shared_uav || mode == "dispatch-srv-token-typed") { // 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])); From a3854d64352861d05ce18571429ab7bc983b4a54 Mon Sep 17 00:00:00 2001 From: saii <120340942+Not-Saii@users.noreply.github.com> Date: Sun, 29 Nov 2026 16:05:20 +0200 Subject: [PATCH 5/6] runtime: read typed input tokens with token_view and cover the review cases The typed input reader took a slot-18 token's record by id, so a content token (X2W_D3D12_VIEW_CONTENT_TOKENS=1) was refused as not a typed buffer view. It now uses token_view, as the other buffer readers do. Tests for checks that no case reached: - word 1 bit 31, and word 3 INDEX_STRIDE and ADD_TID, are refused; - an all-zero input descriptor reads zeros (consumer mode dispatch-records32-input-null); - typed_buffer_srv wider than 16 bytes or not whole dwords gets no manifest; - an indirect Dispatch with an srv typed line is refused. The doc states that this binding is on the manifest route only, which a default run (X2W_NATIVE_SHADERS_ONLY=1 since #3449) does not take. Co-Authored-By: Claude Opus 5.5 --- .../compute-typed-buffer-inputs.md | 24 ++++++++++++++----- src/startup_stubs/d3d12_compute_dispatch.inl | 5 +--- tests/native_compute_manifest_reasons.cpp | 8 +++++++ .../startup_compute_typed_buffer_srv_check.py | 7 ++++++ .../startup_slot67_indirect_dispatch_check.py | 2 +- tests/startup_stream_consumer.cpp | 7 +++--- 6 files changed, 39 insertions(+), 14 deletions(-) diff --git a/docs/experiments/compute-typed-buffer-inputs.md b/docs/experiments/compute-typed-buffer-inputs.md index b46968f016..1feb612e64 100644 --- a/docs/experiments/compute-typed-buffer-inputs.md +++ b/docs/experiments/compute-typed-buffer-inputs.md @@ -15,7 +15,8 @@ those are bound: (OOB_SELECT 0), and no swizzle, index stride or ADD_TID. - **Slot 18 view token:** a typed buffer view with 32-bit channels and the default component mapping, read through the UINT format of the same width (`typed_dword_channels` / `typed_dword_uint_format` in - `src/startup_stubs/native_buffer_stride.h`). + `src/startup_stubs/native_buffer_stride.h`). The token is read with `token_view`, so content tokens + (`X2W_D3D12_VIEW_CONTENT_TOKENS=1`) are decoded as the other buffer readers decode them. - **All four words zero:** a null buffer that reads zeros, as for raw inputs. Each other shape is refused before a dispatch is recorded, with one of these reasons: @@ -28,9 +29,14 @@ Each other shape is refused before a dispatch is recorded, with one of these rea - `a typed input token is not a typed buffer view with 32-bit channels` - `a typed input range does not start at a whole element` -The range checks of raw inputs also apply. A typed input on an indirect Dispatch is refused, and the in-process -`X2W_NATIVE_SHADERS` route is unchanged. 8- and 16-bit formats, UNORM, SNORM and 16-bit FLOAT need a conversion -that a UINT view does not do. +The range checks of raw inputs also apply. A typed input on an indirect Dispatch is refused. 8- and 16-bit +formats, UNORM, SNORM and 16-bit FLOAT need a conversion that a UINT view does not do. + +This binding is on the manifest route only, which a default run does not take. Since #3449 the launchers set +`X2W_NATIVE_SHADERS_ONLY=1`, and `load_compute_translation` then returns before it reads `.txt`. The +in-process route (`translate_compute_natively`) is unchanged and still refuses `typed_buffer_srv` with +`view kind 1 is not bound for a natively translated program`. The `srv typed` line is bound only in runs with +`X2W_NATIVE_SHADERS_ONLY=0` and `compile_dxil` manifests. ## Test @@ -39,8 +45,14 @@ that a UINT view does not do. The 384 lanes store what they read, so the lanes past element 49 must read zeros. The 4-component case also reads through a slot 18 `R32G32B32A32_FLOAT` view token (consumer mode `dispatch-srv-token-typed`). Each width also reads through its UINT and SINT FORMATs, and through a descriptor based one element into the buffer (consumer mode -`dispatch-records32-input-at-`), which shifts the words read by one element. Each invalid shape above must -be refused with the output untouched, including a base 4 bytes in for 2 or more components and word 1 bit 30. Before publication the dispatch reports `no translation`. +`dispatch-records32-input-at-`), which shifts the words read by one element, and through an all-zero +descriptor (consumer mode `dispatch-records32-input-null`), which reads zeros. Each invalid shape above must be +refused with the output untouched, including a base 4 bytes in for 2 or more components, word 1 bit 30 or 31, and +word 3 INDEX_STRIDE or ADD_TID. Before publication the dispatch reports `no translation`. + +`tests/native_compute_manifest_reasons.cpp` checks that a `typed_buffer_srv` wider than 16 bytes or not whole +32-bit components is refused as `SRV kind typed_buffer_srv`. `tests/startup_slot67_indirect_dispatch_check.py` +replaces its manifest line with `srv 0 typed table 1 0 bytes 4` and expects the indirect Dispatch to be refused. ```powershell ctest --preset dev --no-tests=error -R '^startup_compute_typed_buffer_srv_' -V diff --git a/src/startup_stubs/d3d12_compute_dispatch.inl b/src/startup_stubs/d3d12_compute_dispatch.inl index eb88819982..5445003162 100644 --- a/src/startup_stubs/d3d12_compute_dispatch.inl +++ b/src/startup_stubs/d3d12_compute_dispatch.inl @@ -169,10 +169,7 @@ const char* typed_dword_input_view(Wrapper* self, const std::uint32_t* words, un UINT channels = 0; if (words[0] == view_token_magic) { ViewRecord record{}; - AcquireSRWLockShared(¬e_lock); - const bool known = words[1] < view_records().size(); - if (known) record = view_records()[words[1]]; - ReleaseSRWLockShared(¬e_lock); + const bool known = token_view(words, record); D3D12_SHADER_RESOURCE_VIEW_DESC desc{}; if (known && record.slot == 18 && record.desc_bytes >= ViewRecord::srv_desc_bytes) std::memcpy(&desc, record.desc, ViewRecord::srv_desc_bytes); diff --git a/tests/native_compute_manifest_reasons.cpp b/tests/native_compute_manifest_reasons.cpp index 157da59d4d..6c8fd613ab 100644 --- a/tests/native_compute_manifest_reasons.cpp +++ b/tests/native_compute_manifest_reasons.cpp @@ -67,6 +67,14 @@ int main() { p.bindings[0].kind = K::texture_srv; p.bindings[0].array_count = 4; }}, + {"SRV kind typed_buffer_srv", [](auto &p) { // wider than four 32-bit components + p.bindings[0].kind = K::typed_buffer_srv; + p.bindings[0].required_bytes = 20; + }}, + {"SRV kind typed_buffer_srv", [](auto &p) { // not whole 32-bit components + p.bindings[0].kind = K::typed_buffer_srv; + p.bindings[0].required_bytes = 6; + }}, {"UAV kind typed_buffer_uav", [](auto &p) { p.bindings[1].kind = K::typed_buffer_uav; }}, {"UAV kind packed_d16_x_uav", [](auto &p) { p.bindings[1].kind = K::packed_d16_x_uav; diff --git a/tests/startup_compute_typed_buffer_srv_check.py b/tests/startup_compute_typed_buffer_srv_check.py index 2d568e38d7..130dd4789e 100644 --- a/tests/startup_compute_typed_buffer_srv_check.py +++ b/tests/startup_compute_typed_buffer_srv_check.py @@ -127,6 +127,10 @@ def translated(label, first=0, **options): translated(f'{channels} channels, FORMAT {code}', descriptor_word=0x01000fac | code << 12) translated(f'{channels} channels, base one element in', first=1, mode=f'dispatch-records32-input-at-{4 * channels}') print(f'{channels} channels: the UINT and SINT FORMATs read the same words, and a base one element in shifts them') + got, result = run(mode='dispatch-records32-input-null') + check_words(got, [0 if k < output_records(channels) else SENTINEL for k in range(WORDS)], 'null input') + assert len(lines(result, 'Dispatch(3, 2, 2) translated')) == 1 and not lines(result, 'refused:'), result.stderr[-3000:] + print(f'{channels} channels: an all-zero input descriptor reads zeros') refusals = [ ({'descriptor_word': 0x01038fac}, 'a typed input FORMAT is not 32 bits per channel'), # 8_8_8_8_UNORM @@ -134,6 +138,9 @@ def translated(label, first=0, **options): ({'descriptor_word': word3 | 3 << 28}, 'a typed input descriptor is swizzled or not bounds-checked by record'), ({'descriptor_word': word3 & ~0x01000000}, 'a typed input descriptor is swizzled or not bounds-checked by record'), ({'stride': 0x4000 | 4 * channels}, 'a typed input descriptor is swizzled or not bounds-checked by record'), # word 1 bit 30 + ({'stride': 0x8000 | 4 * channels}, 'a typed input descriptor is swizzled or not bounds-checked by record'), # word 1 bit 31 + ({'descriptor_word': word3 | 1 << 21}, 'a typed input descriptor is swizzled or not bounds-checked by record'), # INDEX_STRIDE + ({'descriptor_word': word3 | 1 << 23}, 'a typed input descriptor is swizzled or not bounds-checked by record'), # ADD_TID ] if channels > 1: refusals.append(({'descriptor_word': word3 & ~0xfff | 0xfa5}, 'a typed input DST_SEL is not the identity')) # X, Y swapped diff --git a/tests/startup_slot67_indirect_dispatch_check.py b/tests/startup_slot67_indirect_dispatch_check.py index b40606dbac..8a10d5ac41 100644 --- a/tests/startup_slot67_indirect_dispatch_check.py +++ b/tests/startup_slot67_indirect_dispatch_check.py @@ -206,7 +206,7 @@ def main(consumer, dxc, adapter): text = manifest.read_text() buf = 'srv 0 buf table 1 0' assert text.count(buf) == 1 - for other in ('srv 0 tex2d table 1 0', 'srv 0 buf heap rootconst 0 0'): + for other in ('srv 0 tex2d table 1 0', 'srv 0 buf heap rootconst 0 0', 'srv 0 typed table 1 0 bytes 4'): manifest.write_text(text.replace(buf, other)) run = check(directory, consumer, env, '5', 5, 0) refusals = lines(run, 'ExecuteIndirect refused') diff --git a/tests/startup_stream_consumer.cpp b/tests/startup_stream_consumer.cpp index 840d65dfc0..e3c0e06fae 100644 --- a/tests/startup_stream_consumer.cpp +++ b/tests/startup_stream_consumer.cpp @@ -232,7 +232,8 @@ static void* make_committed(void* device, D3D12_HEAP_TYPE type, const D3D12_RESO // Input descriptors the dispatch refuses, one reason each: dispatch-input-empty has zero records (a nonzero base, // word 3 zero), dispatch-input-past ends 16 bytes past the input buffer, dispatch-input-unplaced names memory between // the two buffers, dispatch-input-copied a third buffer placed there at an offset the desktop cannot alias, and -// dispatch-input-null (all four words zero, an unbound buffer) is not refused and reads zeros; +// dispatch-input-null (all four words zero, an unbound buffer) is not refused and reads zeros +// (dispatch-records32-input-null: the same with the dispatch-records32 table); // dispatch-input-token writes the token of a texture view where the input descriptor was. // dispatch-input-token-typed and -raw replace it with a buffer view of the aliased input buffer (R32_UINT, or a raw // R32_TYPELESS view). dispatch-input-token-past records that typed view four elements past a custom-heap @@ -351,7 +352,7 @@ static int dispatch_slot67(IDXGIAdapter* adapter, void* device, const std::strin if (mode == "dispatch-input-empty") { const UINT view[4] = {0x32c, 0, 0, 0}; std::memcpy(descriptors[0], view, sizeof(view)); - } else if (mode == "dispatch-input-null") { + } else if (mode == "dispatch-input-null" || mode == "dispatch-records32-input-null") { std::memset(descriptors[0], 0, sizeof(descriptors[0])); // an unbound buffer: all four words zero } else if (mode == "dispatch-input-past") { descriptors[0][2] = words + 4; @@ -426,7 +427,7 @@ static int dispatch_slot67(IDXGIAdapter* adapter, void* device, const std::strin std::memcpy(reinterpret_cast(cpu + 32), descriptors[1], sizeof(descriptors[1])); } if (mode == "dispatch-records32" || typed_output_offset || input_offset || shared_uav || - mode == "dispatch-srv-token-typed") { // output at byte 32, none at byte 16 + mode == "dispatch-srv-token-typed" || mode == "dispatch-records32-input-null") { // 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])); } From 0663f6ed949f3f3855cf9b83e69025b94b0fe93c Mon Sep 17 00:00:00 2001 From: saii <120340942+Not-Saii@users.noreply.github.com> Date: Sun, 29 Nov 2026 16:18:13 +0200 Subject: [PATCH 6/6] docs: record the typed input measurements on main e3f9a64f Co-Authored-By: Claude Opus 5.5 --- docs/experiments/compute-typed-buffer-inputs.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/experiments/compute-typed-buffer-inputs.md b/docs/experiments/compute-typed-buffer-inputs.md index 1feb612e64..620a19a769 100644 --- a/docs/experiments/compute-typed-buffer-inputs.md +++ b/docs/experiments/compute-typed-buffer-inputs.md @@ -58,11 +58,12 @@ replaces its manifest line with `srv 0 typed table 1 0 bytes 4` and expects the ctest --preset dev --no-tests=error -R '^startup_compute_typed_buffer_srv_' -V ``` -Measured at `d418f70e` plus this change, on Windows 11 build 26300 with the Windows SDK 10.0.26100 DXC, Debug, -with the D3D12 debug layer enabled: +Measured at `main` `e3f9a64f` plus this change, on Windows 11 build 26300 with the Windows SDK 10.0.26100 DXC, +Debug, with the D3D12 debug layer enabled: -- **NVIDIA GeForce RTX 4090, driver 32.0.16.1088:** passed for 1, 2, 3 and 4 components, the token, and 4, 6, 6 - and 7 refusal controls. +- **NVIDIA GeForce RTX 4090, driver 32.0.16.1088:** passed for 1, 2, 3 and 4 components, the token, the null + descriptor, and 8, 11, 11 and 12 refusal controls. `native_compute_manifest_reasons` and + `startup_slot67_indirect_dispatch_hardware` passed. - **WARP 10.0.26100.9818:** capability skip (77). WARP reports 4-lane waves and the direct module needs 32. - **Negative control:** with the runtime's parse of the `typed` line disabled, the published manifest is not bound and the hardware check reads the sentinel at word 0.