Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/experiments/native-compile-dxil-refusals.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@
exit: a zero group dimension, root constants above parameter 15 or more than 8 in one parameter,
more than 32 user data words, a resource or sampler heap view, a view above root parameter 15,
non-contiguous SRV or UAV registers, an SRV or UAV kind with no manifest line (the kind, and for
images the dimension and `array`; a texture SRV of dimension 1D, 2D, 3D or 2D array has a line, a
cube or multisampled one does not), more than 32 SRVs or 8 UAVs, a comparison sampler, and stride
images the dimension and `array`; a texture SRV of dimension 1D, 2D, 3D or 2D array has a line, as
has a cube sample of one cube (`srv N texcubearr table R B`); an `image_load` on a cube, a cube
comparison, a cube array and a multisampled one do not), more than 32 SRVs or 8 UAVs, a comparison sampler, and stride
words from a view that is not one raw vector SRV. No register numbers, offsets or keys.
- `--requests` still publishes `<key>.cs.cso` and no `<key>.txt`, still counts the request as
compiled and still removes `<key>.fail`. It prints the reason in that job's report as
Expand Down
17 changes: 16 additions & 1 deletion docs/experiments/startup-compute-native-dispatch.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,22 @@ ctest --preset dev --no-tests=error -V -R '^(startup_compute_dispatch(_.*)?|star
and 3D the title's view must be described, have the manifest's dimension and fit its texture, otherwise the
Dispatch is refused (on a dimension mismatch the draw path binds a null view instead). "Fits" is
`address_view_fits`: the view format is the storage format or a member of its typeless family, the mip and
slice range lie inside the texture, and ResourceMinLODClamp is 0. Cube texture SRVs are not published.
slice range lie inside the texture, and ResourceMinLODClamp is 0.
- A cube sample or gather (`image_sample*` or `image_gather4*` with the cube dimension) is published as
`srv N texcubearr table R B`, because the translator declares a TextureCubeArray (DXIL resource kind 9; the layer is `face >> 3`). The title's view must be a
described TEXTURECUBE of a six-slice 2D texture: a view of another dimension (a TEXTURECUBEARRAY or TEXTURE2DARRAY
view included) is refused as "an input texture view is not cube", a missing description as "an input cube texture
has no recorded view description", and a view that does not fit as for the other dimensions. The Dispatch then
creates the view as a TEXTURECUBEARRAY of one cube (First2DArrayFace 0, NumCubes 1, the title's mips and format).
A face id of 8 or more addresses layer `face >> 3` of that one-cube view, which is not tested here; cube arrays
in the program, `image_load` on a cube (a plain `texture_srv` of the cube dimension), cube comparison samples and
descriptor arrays stay refused by name at publication. `gfx2hlsl.py` still refuses a cube in a compute program.
The fixture is `startup_compute_dispatch_cube_check.py`: 24 texels (6 faces of 2x2) sampled at face coordinates
(+-0.5, +-0.5) against a D3D face mapping written in the test. On hardware the translator's DXIL runs; WARP cannot
create its `[WaveSize(32)]` shader, so on WARP the test substitutes an HLSL equivalent for the compiled shader and
covers the manifest and the reader only. Gather on a cube is published the same way but not run by the fixture.
The TEXTURECUBEARRAY rewrite follows the declared resource kind; with it removed, WARP and hardware gave the same
words and no debug-layer message, so no run here tells the two apart.
- One descriptor shape was dispatched: stride 4 and 320 records, for the input and for the output.
- An indirect Dispatch of a natively translated program was not run.
- A captured request starts with a 36-byte prefix of `v_nop` words before `s_inst_prefetch`. The route passes
Expand Down
4 changes: 3 additions & 1 deletion docs/experiments/startup-image-cube.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ The translator emits a helper `x2w_cube_dir(s, t, face)` that rebuilds a directi

- `image_load` and `image_load_mip` on a cube (`Load is not defined on a TextureCube`), `image_sample_d`
(cube derivatives are not converted), `image_get_lod`, `a16` and `d16`.
- A cube in a compute program: the compute dispatch has no `texcube` view binding.
- A cube in a compute program through `gfx2hlsl.py`: the compute dispatch has no `texcube` view binding. The
published native route (`compile_dxil --requests`) names a cube sample `srv N texcubearr table R B` and binds the
title's TEXTURECUBE view as a one-cube TEXTURECUBEARRAY (docs/experiments/startup-compute-native-dispatch.md).
- A constant sampler with `DISABLE_CUBE_WRAP` (`SQ_IMG_SAMP_WORD0` bit 28, Mesa
`src/amd/registers/gfx10-rsrc.json`): the guest then filters without crossing face edges, while a D3D12 cube
always filters across them. With the bit clear both cross.
Expand Down
4 changes: 3 additions & 1 deletion docs/startup-runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -1010,7 +1010,9 @@ and raw table buffers stored to, with their descriptors in 32-byte table records
scalar buffer load, a texture, a sampler, a typed or indexed view, an instruction the compiler does
not lower) is refused. Programs published as `<key>.txt` also bind 1D, 2D, 2D-array and 3D texture SRVs
(`srv N tex1d|tex2d|tex2da|tex3d table R B`) from the title's described view of that dimension, or are
refused by name; cube texture SRVs are not published. The first 16 refusals of a process are logged as
refused by name. A cube sample is published as `srv N texcubearr table R B` (the program declares a
TextureCubeArray) and bound from the title's described TEXTURECUBE view of a six-slice texture, created as a
one-cube TEXTURECUBEARRAY; `image_load` on a cube, cube comparison and cube arrays are not published. The first 16 refusals of a process are logged as
`compute pipeline <key> not translated natively: <reason>`. A refused key is left to the
published translations, so `-Translate` can run beside it for those pipelines. A direct module declares
wave size 32, so an adapter without 32-lane waves refuses every program by that name. The in-process
Expand Down
5 changes: 5 additions & 0 deletions src/direct_compute_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,11 @@ std::optional<std::string> format_compute_runtime_manifest(const NativeComputeSh
: "tex2da";
srv_lines << "srv " << b.shader_register << ' ' << tex << " table " << b.root_parameter << ' '
<< b.byte_offset << '\n';
} else if (b.kind == ComputeViewKind::cube_sample_srv && b.array_count == 1 && b.image_dimension == 3) {
// The program declares a TextureCubeArray (resource kind 9); the runtime binds the title's cube view
// as a one-cube array. `texcube` keeps its draw meaning (TextureCube).
srv_lines << "srv " << b.shader_register << " texcubearr table " << b.root_parameter << ' '
<< b.byte_offset << '\n';
} else {
return refuse(view_shape("SRV", b));
}
Expand Down
26 changes: 22 additions & 4 deletions src/startup_stubs/d3d12_compute_dispatch.inl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// buffers (`srv <i> buf table <param> <byte>` and `srv <i> buf root <param>` inputs, `uav <i> table <param> <byte>`
// outputs, or `uav <i> bufhalf table <param> <byte> bytes <stride>` for typed half stores)
// named by hardware buffer descriptors or 64-bit root SRV addresses, and textures
// (`srv <i> tex1d|tex2d|tex2da|tex3d table <param> <byte>` inputs, `uav <i> tex1d/tex2d/tex2da/tex3d float table <param> <byte> channels <n>` outputs) named
// (`srv <i> tex1d|tex2d|tex2da|tex3d|texcubearr table <param> <byte>` inputs, `uav <i> tex1d/tex2d/tex2da/tex3d float table <param> <byte> channels <n>` 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
// bound from: its stride and word 3 (`stride`, `descword3`), and word 3, the upper half of word 1 and the record
Expand Down Expand Up @@ -182,6 +182,8 @@ const char* load_compute_translation(ComputeTranslation& tr)
if (!std::strcmp(name, "tex2d")) return D3D12_SRV_DIMENSION_TEXTURE2D;
if (!std::strcmp(name, "tex2da")) return D3D12_SRV_DIMENSION_TEXTURE2DARRAY;
if (!std::strcmp(name, "tex3d")) return D3D12_SRV_DIMENSION_TEXTURE3D;
// The program declares a TextureCubeArray; the title's TEXTURECUBE view is bound as a one-cube array.
if (!std::strcmp(name, "texcubearr")) return D3D12_SRV_DIMENSION_TEXTURECUBE;
return D3D12_SRV_DIMENSION_UNKNOWN;
};
if (line.empty() || (std::sscanf(line.c_str(), "group %u %u %u%n", &x, &y, &z, &used) == 3 && whole())) continue;
Expand Down Expand Up @@ -245,7 +247,7 @@ const char* load_compute_translation(ComputeTranslation& tr)
std::sscanf(line.c_str(), "smpc %u %x %x %x %x%n", &i, &x, &y, &z, &w, &used) == 5) && whole() &&
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 1D/2D/2D-array/3D texture"
else return line.rfind("srv", 0) == 0 ? "a resource that is not a raw table buffer or a 1D/2D/2D-array/3D/cube 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";
Expand Down Expand Up @@ -554,19 +556,35 @@ const char* record_translated_dispatch(Wrapper* self, const TranslatedDispatch&
else if (!texture || (resource.Flags & D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE))
reason = "an input texture has no desktop texture to sample";
else if (slot.srv_dimension != D3D12_SRV_DIMENSION_TEXTURE2D) {
// 1D, 2D array and 3D: only the title's own described view of that dimension, inside its texture.
// 1D, 2D array, 3D and cube: only the title's own described view of that dimension, inside its texture.
const bool one = slot.srv_dimension == D3D12_SRV_DIMENSION_TEXTURE1D;
const bool array = slot.srv_dimension == D3D12_SRV_DIMENSION_TEXTURE2DARRAY;
const bool cube = slot.srv_dimension == D3D12_SRV_DIMENSION_TEXTURECUBE;
if (!described)
reason = one ? "an input 1D texture has no recorded view description"
: array ? "an input 2D array texture has no recorded view description"
: cube ? "an input cube texture has no recorded view description"
: "an input 3D texture has no recorded view description";
else if (desc.ViewDimension != slot.srv_dimension)
reason = one ? "an input texture view is not 1D" : array ? "an input texture view is not 2D array"
: "an input texture view is not 3D";
: cube ? "an input texture view is not cube" : "an input texture view is not 3D";
else if (!x2w_startup::address_view_fits(resource, desc))
reason = "an input texture view does not fit its texture";
else if (x2w_startup::packed_target_format(desc.Format)) reason = "an input texture view has a packed format";
else if (cube) {
// The program declares a TextureCubeArray (manifest `texcubearr`), and a view must match the declared
// dimension: the title's cube becomes a one-cube array of the same mips and format. The fit check
// above ran on the title's view, which only a TEXTURECUBE of exactly six slices passes.
// The two views share a union: the mips are read before the rewrite, and First2DArrayFace takes the
// place of TextureCube.ResourceMinLODClamp, which the fit check already required to be 0.
const UINT most_detailed = desc.TextureCube.MostDetailedMip, levels = desc.TextureCube.MipLevels;
desc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBEARRAY;
desc.TextureCubeArray.MostDetailedMip = most_detailed;
desc.TextureCubeArray.MipLevels = levels;
desc.TextureCubeArray.First2DArrayFace = 0;
desc.TextureCubeArray.NumCubes = 1;
desc.TextureCubeArray.ResourceMinLODClamp = 0.0f;
}
}
else if (described ? desc.ViewDimension != D3D12_SRV_DIMENSION_TEXTURE2D
: resource.Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE2D || resource.DepthOrArraySize != 1)
Expand Down
17 changes: 17 additions & 0 deletions tests/cmake/startup_compute_dispatch_cube.cmake
Original file line number Diff line number Diff line change
@@ -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_dispatch_cube_controls COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_compute_dispatch_cube_check.py" compile
"$<TARGET_FILE:compile_dxil>" "${DXC_BIN_DIR}")
set_tests_properties(startup_compute_dispatch_cube_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_dispatch_cube_${adapter} COMMAND "${INTAKE_PYTHON}" -B
"${CMAKE_CURRENT_SOURCE_DIR}/tests/startup_compute_dispatch_cube_check.py"
"$<TARGET_FILE:compile_dxil>" "$<TARGET_FILE:startup_stream_consumer>" "$<TARGET_FILE:offscreen_check>"
"${DXC_BIN_DIR}" ${adapter})
set_tests_properties(startup_compute_dispatch_cube_${adapter} PROPERTIES TIMEOUT 180 SKIP_RETURN_CODE 77)
endforeach()
endif()
28 changes: 22 additions & 6 deletions tests/native_compute_manifest_reasons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ int main() {
p.bindings[0].kind = K::texture_srv;
p.bindings[0].array_count = 4;
}},
{"SRV kind cube_comparison_srv cube", [](auto &p) {
p.bindings[0].kind = K::cube_comparison_srv;
p.bindings[0].image_dimension = 3;
}},
{"SRV kind cube_sample_srv cube array", [](auto &p) {
p.bindings[0].kind = K::cube_sample_srv;
p.bindings[0].image_dimension = 3;
p.bindings[0].array_count = 2;
}},
{"SRV kind cube_sample_srv 2d", [](auto &p) {
p.bindings[0].kind = K::cube_sample_srv;
p.bindings[0].image_dimension = 1;
}},
{"UAV kind typed_buffer_uav", [](auto &p) { p.bindings[1].kind = K::typed_buffer_uav; }},
{"UAV kind texture_uav cube", [](auto &p) {
p.bindings[1].kind = K::texture_uav;
Expand All @@ -93,19 +106,22 @@ int main() {
ok ? "" : manifest ? "a manifest" : reason.c_str());
failures += !ok;
}
// A texture SRV is published under the name of its dimension: the line the runtime's reader takes.
// A texture SRV is published under the name of its dimension: the line the runtime's reader takes. A cube sample
// names `texcubearr`: the program declares a TextureCubeArray (`texcube` stays the draw route's TextureCube).
const struct {
K kind;
unsigned image_dimension;
const char *line;
} published[] = {
{0, "srv 0 tex1d table 1 64\n"},
{1, "srv 0 tex2d table 1 64\n"},
{2, "srv 0 tex3d table 1 64\n"},
{5, "srv 0 tex2da table 1 64\n"},
{K::texture_srv, 0, "srv 0 tex1d table 1 64\n"},
{K::texture_srv, 1, "srv 0 tex2d table 1 64\n"},
{K::texture_srv, 2, "srv 0 tex3d table 1 64\n"},
{K::texture_srv, 5, "srv 0 tex2da table 1 64\n"},
{K::cube_sample_srv, 3, "srv 0 texcubearr table 1 64\n"},
};
for (const auto &c : published) {
auto program = base();
program.bindings[0].kind = K::texture_srv;
program.bindings[0].kind = c.kind;
program.bindings[0].image_dimension = c.image_dimension;
reason = "unset";
const auto manifest = format_compute_runtime_manifest(program, &reason);
Expand Down
Loading