diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 7817ba0896..07483f254c 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -71,6 +71,7 @@ jobs: (["tests/startup_sampler_heap_check.py", "binary", "llvm-mc-15"], {}), (["tests/startup_image_sample_l_check.py", "binary", "llvm-mc-15"], {}), (["tests/startup_image_sample_c_check.py", "binary", "llvm-mc-15"], {}), + (["tests/startup_image_1d_check.py", "binary", "llvm-mc-15"], {}), (["tests/startup_image_3d_check.py", "binary", "llvm-mc-15"], {}), (["tests/startup_image_load_mip_check.py", "--llvm-mc", "llvm-mc-15"], {}), (["tests/startup_image_2d_array_check.py", "binary", "llvm-mc-15"], {}), @@ -167,6 +168,7 @@ jobs: tests/startup_sampler_heap_check.py \ tests/startup_image_sample_l_check.py \ tests/startup_image_sample_c_check.py \ + tests/startup_image_1d_check.py \ tests/startup_image_3d_check.py \ tests/startup_image_load_mip_check.py \ tests/startup_gfx2hlsl_operand_count_check.py \ diff --git a/CMakeLists.txt b/CMakeLists.txt index 771fc4f52a..04b45cb78b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1625,6 +1625,9 @@ if(EXISTS "${INTAKE_PYTHON}") "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_image_sample_l_check.py") add_test(NAME startup_image_sample_c COMMAND "${INTAKE_PYTHON}" -B "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_image_sample_c_check.py") + # 1D image_load, image_load_mip, image_sample_lz and image_sample_l: translation controls and llvm-mc words. + add_test(NAME startup_image_1d COMMAND "${INTAKE_PYTHON}" -B + "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_image_1d_check.py") # Rewrites for instructions the host processor lacks (tools/startup/host_cpu.py), run on the host. add_test(NAME startup_host_cpu COMMAND "${INTAKE_PYTHON}" -B "${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_host_cpu_check.py") diff --git a/docs/experiments.md b/docs/experiments.md index 97600f7c71..0d76d45bfb 100644 --- a/docs/experiments.md +++ b/docs/experiments.md @@ -19,6 +19,8 @@ nonempty component mask. The image draw test samples the alpha channel of a two- Texture1D at two coordinates and compares exact words. Selecting red changes both results. Run `ctest --preset dev -R startup_image_3d --no-tests=error` for this and the 3D controls. +The same lowering now covers the other 1D forms, which were refused with `unverified 1D image sample address or modifiers`. A 1D image takes one address component, x. `image_load` becomes `Texture1D.Load(int2(x, 0))`; `image_load_mip` takes x and then the mip and becomes `Load(int2(x, mip))`; `image_sample_lz` becomes `SampleLevel(smp, x, 0)`; `image_sample_l` takes x and then the level and becomes `SampleLevel(smp, x, level)`. The mip and the level are the last address register, so the NSA lists `[v3, v1]` and `[v3, v0]` read x from `v3`. Only the cache-policy bits `glc`, `slc` and `dlc` are accepted next to `dim` and `dmask`; `unorm`, `tfe`, `a16` and the other modifiers and an empty `dmask` are refused with `unverified 1D image address or modifiers`. `python -B tests/startup_image_1d_check.py` (CTest `startup_image_1d`) translates source-built fixtures whose words are checked against `llvm-mc` and requires the exact call; reading the mip as 0, taking the level from the first register, accepting `unorm` or binding the texture as 2D each make it fail. Not covered: no draw runs a 1D load, mip load or explicit-level sample on WARP or hardware, so those forms are checked on the generated HLSL text only (the plain `image_sample` draw above is unchanged). `image_sample_c`, gather and offset forms on a 1D image are still refused. + The runtime binds an explicit or default 1D view and uploads single-array-slice CPU-backed textures using their desktop copyable footprints. Run `ctest --preset dev -R '^startup_1d_srv_' --no-tests=error` to check RGBA8 texel and alpha values, rebinding, and a mismatched 2D view on hardware and WARP. @@ -10513,7 +10515,7 @@ measurement on hardware or in a Windows run backs the descriptions. `v_interp_p1 ## Startup translator: explicit-LOD image sampling -`tools/startup/gfx2hlsl.py` now lowers the gfx1013 `image_sample_l` form of a 2D or 3D texture sample to `tex.SampleLevel(smp, uv, level)`. The level is the last address register: the third for a contiguous 2D address, the fourth for 3D, and the last element of an NSA list. `tests/startup_image_sample_l_check.py` translates source-built fixtures (the words are checked against `llvm-mc`) and requires the level to come from that register; an address list `[v0, v1, v3]` must use `v3`, not the third consecutive register. Replacing the level with 0, replacing the call with implicit `Sample`, or reading the third register in every form each make the check fail. Offset (`_o`), compare (`_c_l`), gather, 1D, array, cube and multisample dimensions, an empty `dmask`, and the `unorm`, `r128`, `tfe`, `lwe`, `a16` and `d16` modifiers or any set reserved MIMG bit are refused with an `Unsupported` message; only the cache-policy bits `glc`, `slc` and `dlc` are accepted because they do not change the sampled value. The disassembler previously read `lwe` from reserved bit 14 of word 0; `llvm-mc` (19, gfx1013) encodes it in bit 17, and the check now has one `llvm-mc`-built fixture per refused modifier plus patched reserved-bit fixtures. Not measured: no draw samples a mip level on WARP or hardware through this lowering, so the level selection is checked on the generated HLSL text only. [HLSL SampleLevel](https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-to-samplelevel) +`tools/startup/gfx2hlsl.py` now lowers the gfx1013 `image_sample_l` form of a 2D or 3D texture sample (and a 1D one, see above) to `tex.SampleLevel(smp, uv, level)`. The level is the last address register: the third for a contiguous 2D address, the fourth for 3D, and the last element of an NSA list. `tests/startup_image_sample_l_check.py` translates source-built fixtures (the words are checked against `llvm-mc`) and requires the level to come from that register; an address list `[v0, v1, v3]` must use `v3`, not the third consecutive register. Replacing the level with 0, replacing the call with implicit `Sample`, or reading the third register in every form each make the check fail. Offset (`_o`), compare (`_c_l`), gather, array, cube and multisample dimensions, an empty `dmask`, and the `unorm`, `r128`, `tfe`, `lwe`, `a16` and `d16` modifiers or any set reserved MIMG bit are refused with an `Unsupported` message; only the cache-policy bits `glc`, `slc` and `dlc` are accepted because they do not change the sampled value. The disassembler previously read `lwe` from reserved bit 14 of word 0; `llvm-mc` (19, gfx1013) encodes it in bit 17, and the check now has one `llvm-mc`-built fixture per refused modifier plus patched reserved-bit fixtures. Not measured: no draw samples a mip level on WARP or hardware through this lowering, so the level selection is checked on the generated HLSL text only. [HLSL SampleLevel](https://learn.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-to-samplelevel) ## Startup translator: depth-comparison image sampling diff --git a/docs/startup-runtime.md b/docs/startup-runtime.md index 7d736f480c..f4d4a74b89 100644 --- a/docs/startup-runtime.md +++ b/docs/startup-runtime.md @@ -513,7 +513,7 @@ These are measured on one executable; treat them as hypotheses for others. column 1 at x=1.25, while the wrap control reads column 0. Run `ctest --preset release --no-tests=error -R "^startup_inline_sampler_"`. - **3D images.** `image_sample` with `dim:SQ_RSRC_IMG_3D` becomes a `Texture3D` sampled with - a `float3` of the three address registers in order; 1D images are refused. A source-built pixel + a `float3` of the three address registers in order. A source-built pixel stage draws one texel of a 2x2x2 texture on WARP and hardware with DXC and FXC (`ctest --preset release --no-tests=error -R "^startup_image_3d_"`). - **Explicit mip loads.** For 2D textures, 2D arrays and 3D textures, `image_load_mip` passes the final @@ -526,6 +526,13 @@ These are measured on one executable; treat them as hypotheses for others. draw of a 4x4 texture of two slices with three mips whose cells all differ, with mutants that exchange slice and mip, ignore the mip, or shift it by one. The draw was written without a Windows run. Cube maps are still refused for `image_load_mip`. +- **1D images.** `image_sample`, `image_sample_lz`, `image_sample_l`, `image_load` and `image_load_mip` with + `dim:SQ_RSRC_IMG_1D` use a `Texture1D` (manifest kind `tex1d`) addressed by one component, x; the + explicit-level and mip forms take the level or mip from the last address register (`Load(int2(x, mip))`, + `SampleLevel(smp, x, level)`). Before, only the implicit `image_sample` was lowered and the other forms were + refused. `python -B tests/startup_image_1d_check.py` translates the fixtures (words checked against `llvm-mc`). + No draw runs the load, mip and explicit-level forms yet, so they are not measured on WARP or hardware. Compare, + gather and offset forms on a 1D image stay refused. - **2D array images.** `image_sample`, `image_sample_lz`, `image_sample_l` and `image_load` with `dim:SQ_RSRC_IMG_2D_ARRAY` use a `Texture2DArray` (manifest kind `tex2da`). The slice is the third address component, as `float3(u, v, slice)` for a sample and `int4(x, y, slice, 0)` @@ -533,7 +540,7 @@ These are measured on one executable; treat them as hypotheses for others. Two source-built pixel stages draw one texel of a 2x2 texture with two slices on WARP and hardware with DXC and FXC; a slice fixed to 0 and exchanged coordinates fail it (`ctest --preset release --no-tests=error -R "^startup_image_2d_array_"`). Cube, multisampled - and 1D images are still refused. Not covered: binding a single-slice 2D view to an array declaration + images are still refused. Not covered: binding a single-slice 2D view to an array declaration in the draw path. - **Flat parameters.** `v_interp_mov_f32` reads a `nointerpolation uint4` copy written from the exported registers, so integer words reach the pixel stage unchanged. FXC folds `asfloat()` of a @@ -664,7 +671,7 @@ These are measured on one executable; treat them as hypotheses for others. The control expects all three axes to use the U field and must fail. - The startup shader translator lowers `image_sample_l` (explicit level, 2D and 3D, any `dmask`) to `SampleLevel(sampler, uv, level)`, taking the level from the last address register. Offset, compare, - gather, clamp, cube, 1D and `unorm` forms are refused. Only the translation is checked + gather, clamp, cube and `unorm` forms are refused; 1D is lowered (x, then the level). Only the translation is checked (`python -B tests/startup_image_sample_l_check.py`); a WARP readback of distinct mip levels is still open. - Slot 86 graphics streams can submit VS/PS requests to the offline cache. The fixture sends complete shader containers and a wrapped root through WARP, runs `gfx2hlsl.py --pending`, and diff --git a/tests/startup_image_1d_check.py b/tests/startup_image_1d_check.py new file mode 100644 index 0000000000..c019814e3b --- /dev/null +++ b/tests/startup_image_1d_check.py @@ -0,0 +1,181 @@ +"""One-dimensional image loads and explicit-level samples in tools/startup/gfx2hlsl.py. + + (no arguments) translation controls, pure Python + binary reassemble every fixture source and compare it with the recorded words + +A 1D image (dim:SQ_RSRC_IMG_1D) takes one address component: x. image_load reads Texture1D.Load(int2(x, 0)), +image_load_mip addresses x and then the mip and reads Load(int2(x, mip)), image_sample_lz samples level 0 at x, and +image_sample_l addresses x and then the level and reads SampleLevel(smp, x, level). The mip and the level are the +LAST address register, so the NSA lists [v3, v1] and [v3, v0] read x from v3, not from the first consecutive +register. The implicit-derivative image_sample on a 1D texture is checked by startup_image_3d_check.py. + +Each fixture is a source-built gfx1013 pixel stage that sets v0 = 0.5, v1 = 0.25, v2 = 1.0, v3 = 2.0 and runs one image +instruction on a texture from descriptor table 0 (and an all-zero constant sampler for the sampling forms). The +modifiers and shapes the lowering does not model are refused instead of being read at a wrong address; only the +cache-policy bits glc, slc and dlc, which never change the value, are accepted next to dim and dmask. +""" +import re +import sys +from pathlib import Path + +HERE = Path(__file__).resolve().parent +sys.path.insert(0, str(HERE.parent / 'tools' / 'startup')) +sys.path.insert(0, str(HERE)) +import gfx2hlsl as G # noqa: E402 +from startup_sampler_heap_check import VS_WORDS, assemble, root_blob # noqa: E402 + +PRE = """\ +s_load_dwordx8 s[16:23], s[8:9], 0x0 +s_mov_b32 s24, 0 +s_mov_b32 s25, 0 +s_mov_b32 s26, 0 +s_mov_b32 s27, 0 +v_mov_b32 v0, 0.5 +v_mov_b32 v1, 0x3e800000 +v_mov_b32 v2, 1.0 +v_mov_b32 v3, 2.0 +s_waitcnt lgkmcnt(0) +""" +POST = """\ +s_waitcnt vmcnt(0) +exp mrt0 v4, v5, v6, v7 done vm +s_endpgm +""" +SAMPLER = 's[16:23], s[24:27]' +IMAGE = { + 'load': 'image_load v[4:7], v0, s[16:23] dmask:0xf dim:SQ_RSRC_IMG_1D', + 'load_x': 'image_load v4, v0, s[16:23] dmask:0x1 dim:SQ_RSRC_IMG_1D', + 'load_mip': 'image_load_mip v[4:7], v[0:1], s[16:23] dmask:0xf dim:SQ_RSRC_IMG_1D', + 'load_mip_nsa': 'image_load_mip v[4:7], [v3, v1], s[16:23] dmask:0xf dim:SQ_RSRC_IMG_1D', + 'lz': 'image_sample_lz v[4:7], v0, ' + SAMPLER + ' dmask:0xf dim:SQ_RSRC_IMG_1D', + 'l': 'image_sample_l v[4:7], v[0:1], ' + SAMPLER + ' dmask:0xf dim:SQ_RSRC_IMG_1D', + 'l_nsa': 'image_sample_l v[4:7], [v3, v0], ' + SAMPLER + ' dmask:0xf dim:SQ_RSRC_IMG_1D', + 'l_glc': 'image_sample_l v[4:7], v[0:1], ' + SAMPLER + ' dmask:0xf dim:SQ_RSRC_IMG_1D glc', + 'load_unorm': 'image_load v[4:7], v0, s[16:23] dmask:0xf dim:SQ_RSRC_IMG_1D unorm', + 'load_tfe': 'image_load v[4:8], v0, s[16:23] dmask:0xf dim:SQ_RSRC_IMG_1D tfe', + 'lz_a16': 'image_sample_lz v[4:7], v0, ' + SAMPLER + ' dmask:0xf dim:SQ_RSRC_IMG_1D a16', + 'load_mip_unorm': 'image_load_mip v[4:7], v[0:1], s[16:23] dmask:0xf dim:SQ_RSRC_IMG_1D unorm', + 'l_dmask0': 'image_sample_l v4, v[0:1], ' + SAMPLER + ' dmask:0x0 dim:SQ_RSRC_IMG_1D', + 'load_dmask0': 'image_load v4, v0, s[16:23] dmask:0x0 dim:SQ_RSRC_IMG_1D', +} +WORDS = { + 'load': bytes.fromhex( + '04040cf4000000fa800398be800399be80039abe80039bbef002007eff02027e' + '0000803ef202047ef402067e7fc08cbf000f00f000040400703f8cbf0f1800f8' + '04050607000081bf'), + 'load_x': bytes.fromhex( + '04040cf4000000fa800398be800399be80039abe80039bbef002007eff02027e' + '0000803ef202047ef402067e7fc08cbf000100f000040400703f8cbf0f1800f8' + '04050607000081bf'), + 'load_mip': bytes.fromhex( + '04040cf4000000fa800398be800399be80039abe80039bbef002007eff02027e' + '0000803ef202047ef402067e7fc08cbf000f04f000040400703f8cbf0f1800f8' + '04050607000081bf'), + 'load_mip_nsa': bytes.fromhex( + '04040cf4000000fa800398be800399be80039abe80039bbef002007eff02027e' + '0000803ef202047ef402067e7fc08cbf020f04f00304040001000000703f8cbf' + '0f1800f804050607000081bf'), + 'lz': bytes.fromhex( + '04040cf4000000fa800398be800399be80039abe80039bbef002007eff02027e' + '0000803ef202047ef402067e7fc08cbf000f9cf00004c400703f8cbf0f1800f8' + '04050607000081bf'), + 'l': bytes.fromhex( + '04040cf4000000fa800398be800399be80039abe80039bbef002007eff02027e' + '0000803ef202047ef402067e7fc08cbf000f90f00004c400703f8cbf0f1800f8' + '04050607000081bf'), + 'l_nsa': bytes.fromhex( + '04040cf4000000fa800398be800399be80039abe80039bbef002007eff02027e' + '0000803ef202047ef402067e7fc08cbf020f90f00304c40000000000703f8cbf' + '0f1800f804050607000081bf'), + 'l_glc': bytes.fromhex( + '04040cf4000000fa800398be800399be80039abe80039bbef002007eff02027e' + '0000803ef202047ef402067e7fc08cbf002f90f00004c400703f8cbf0f1800f8' + '04050607000081bf'), + 'load_unorm': bytes.fromhex( + '04040cf4000000fa800398be800399be80039abe80039bbef002007eff02027e' + '0000803ef202047ef402067e7fc08cbf001f00f000040400703f8cbf0f1800f8' + '04050607000081bf'), + 'load_tfe': bytes.fromhex( + '04040cf4000000fa800398be800399be80039abe80039bbef002007eff02027e' + '0000803ef202047ef402067e7fc08cbf000f01f000040400703f8cbf0f1800f8' + '04050607000081bf'), + 'lz_a16': bytes.fromhex( + '04040cf4000000fa800398be800399be80039abe80039bbef002007eff02027e' + '0000803ef202047ef402067e7fc08cbf000f9cf00004c440703f8cbf0f1800f8' + '04050607000081bf'), + 'load_mip_unorm': bytes.fromhex( + '04040cf4000000fa800398be800399be80039abe80039bbef002007eff02027e' + '0000803ef202047ef402067e7fc08cbf001f04f000040400703f8cbf0f1800f8' + '04050607000081bf'), + 'l_dmask0': bytes.fromhex( + '04040cf4000000fa800398be800399be80039abe80039bbef002007eff02027e' + '0000803ef202047ef402067e7fc08cbf000090f00004c400703f8cbf0f1800f8' + '04050607000081bf'), + 'load_dmask0': bytes.fromhex( + '04040cf4000000fa800398be800399be80039abe80039bbef002007eff02027e' + '0000803ef202047ef402067e7fc08cbf000000f000040400703f8cbf0f1800f8' + '04050607000081bf'), +} + + +def source(name): + return PRE + IMAGE[name] + '\n' + POST + + +def stage(name): + return G.Pipeline(VS_WORDS, WORDS[name], root_blob(flags=0)) + + +def call(name): + """The one texture call of a lowered fixture, and its pipeline.""" + pipe = stage(name) + text = pipe.hlsl_ps() + calls = re.findall(r'^\s*t = (r0\.(?:Load|SampleLevel)\(.*\));$', text, re.M) + assert len(calls) == 1, (name, text) + assert 'Texture1D r0 : register(t0);' in text, text + assert 'srv 0 tex1d table 0 0' in pipe.manifest(), pipe.manifest() + return calls[0] + + +def refused(name): + try: + stage(name).hlsl_ps() + except G.Unsupported as error: + assert 'unverified 1D image address or modifiers' in str(error), (name, str(error)) + else: + raise AssertionError('%s was accepted' % name) + + +def controls(): + assert call('load') == 'r0.Load(int2(v0, 0))', call('load') + assert call('load_x') == 'r0.Load(int2(v0, 0))', call('load_x') + assert call('load_mip') == 'r0.Load(int2(v0, v1))', call('load_mip') # x v0, mip v1 + assert call('load_mip_nsa') == 'r0.Load(int2(v3, v1))', call('load_mip_nsa') # the list order, not v[n] + print('load: Load(int2(x, 0)); load_mip: Load(int2(x, mip)), also through an NSA list') + + assert re.fullmatch(r'r0\.SampleLevel\(q0, F\(v0\), 0\)', call('lz')), call('lz') + assert re.fullmatch(r'r0\.SampleLevel\(q0, F\(v0\), F\(v1\)\)', call('l')), call('l') + assert re.fullmatch(r'r0\.SampleLevel\(q0, F\(v3\), F\(v0\)\)', call('l_nsa')), call('l_nsa') + assert call('l_glc') == call('l'), call('l_glc') # a cache-policy bit does not change the value + print('sample_lz: level 0 at x; sample_l: level is the last address register (v1, NSA v0), x from the first') + + for name in ('load_unorm', 'load_tfe', 'lz_a16', 'load_mip_unorm', 'l_dmask0', 'load_dmask0'): + refused(name) + print('refused: unorm, tfe, a16, empty dmask') + + +def check_binary(llvm_mc): + for name in WORDS: + built = assemble(llvm_mc, source(name)) + if built != WORDS[name]: + raise AssertionError('%s fixture: assembled %s, recorded %s' % (name, built.hex(), WORDS[name].hex())) + print('fixture words match llvm-mc') + + +if __name__ == '__main__': + if len(sys.argv) == 1: + controls() + elif sys.argv[1] == 'binary' and len(sys.argv) == 3: + check_binary(sys.argv[2]) + else: + sys.exit(__doc__) diff --git a/tests/startup_image_sample_l_check.py b/tests/startup_image_sample_l_check.py index 8cb4316ed8..0d65062ddb 100644 --- a/tests/startup_image_sample_l_check.py +++ b/tests/startup_image_sample_l_check.py @@ -225,11 +225,10 @@ def controls(): refused('d16', 'image_sample_l modifier d16') # half-precision result layout refused('r128', 'image_sample_l modifier r128') # four-dword resource descriptor refused('dmask0', 'empty dmask') - refused('dim1d', 'unverified 1D image sample address or modifiers') refused('msaa', 'image dimension SQ_RSRC_IMG_') for name in RESERVED: refused(name, 'image_sample_l modifier reserved') # bits LLVM ignores must not be silently accepted - print('refused: offset, compare, gather, cube, 1D, MSAA, unorm, a16, tfe, lwe, d16, r128, dmask 0, reserved bits') + print('refused: offset, compare, gather, cube, MSAA, unorm, a16, tfe, lwe, d16, r128, dmask 0, reserved bits') # Cache-policy bits do not change the sampled value: same lowering as the plain form. for name in ('glc', 'slc', 'dlc'): diff --git a/tools/startup/gfx2hlsl.py b/tools/startup/gfx2hlsl.py index c04709cb3d..85124d84e0 100644 --- a/tools/startup/gfx2hlsl.py +++ b/tools/startup/gfx2hlsl.py @@ -699,14 +699,19 @@ def image(self, ops, mods, how): # Load on a Texture2DArray take it in the same place, so only the declared type differs. one = dim == 'SQ_RSRC_IMG_1D' three = dim in ('SQ_RSRC_IMG_3D', 'SQ_RSRC_IMG_2D_ARRAY') + axes = 1 if one else 3 if three else 2 # address components before the level of the explicit-level forms coords = ops[1] if coords.startswith('['): cs = [c.strip() for c in coords[1:-1].split(',')] else: r = reg_range(coords) cs = ['v%d' % n for n in range(r[1], r[2] + 1)] - if one and (how != 'sample' or len(cs) != 1 or not dmask or any(not m.startswith(('dim:', 'dmask:')) for m in mods)): - raise Unsupported('unverified 1D image sample address or modifiers') + # A 1D texture takes one address component (x), then the level for image_sample_l and image_load_mip. + # Only the cache-policy bits (glc, slc, dlc) are accepted next to dim and dmask; every other modifier would + # change the address or the result layout and is refused. + if one and (not dmask or any(not (m.startswith(('dim:', 'dmask:')) or m in ('dlc', 'glc', 'slc')) for m in mods) + or len(cs) != (2 if how in ('l', 'load_mip') else 1)): + raise Unsupported('unverified 1D image address or modifiers') lod = None if how == 'l': # Address dwords are the coordinates and then the explicit level; offsets, bias, clamp and derivatives @@ -719,14 +724,13 @@ def image(self, ops, mods, how): raise Unsupported('image_sample_l modifier %s' % m) if dmask == 0: raise Unsupported('image_sample_l with an empty dmask') - if len(cs) != (4 if three else 3): + if len(cs) != axes + 1: raise Unsupported('image_sample_l with %d address registers' % len(cs)) lod, cs = cs[-1], cs[:-1] tex = self.pipe.resource(self.descriptor(ops[2]), kinds[dim]) if how in ('load', 'load_mip'): # image_load_mip addresses x, y, [slice or z] and then the mip, so a 2D array is four registers # and Texture2DArray.Load takes int4(x, y, slice, mip) like a volume's int4(x, y, z, mip). - axes = 3 if three else 2 mip = '0' if how == 'load_mip': unsupported = [m for m in mods if not m.startswith(('dim:', 'dmask:'))