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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ After the full [Windows build](#first-build), run one comparison from the reposi
| PE 32/64-bit base fixups against Windows | `ctest --preset dev --no-tests=error -R '^cpu_native_highlow$' -V` · [scope and controls](docs/experiments.md#highlow-and-mixed-width-base-relocations) |
| [CPU counted cache-line zero loops](docs/experiments.md#counted-cache-line-zero-loops) | `ctest --preset release --no-tests=error -R '^cpu_counted_clzero$' -V` |
| [Experimental startup stand-ins and debugger (trap-by-default DLLs)](docs/startup-runtime.md) | `ctest --preset release --no-tests=error -R '^startup_stubs$' -V` |
| [Sample a texture by address in a translated draw](docs/startup-runtime.md#textures-published-by-address-device-slot-70) | `ctest --preset release --no-tests=error -R '^startup_address_console_' -V` |
| [Desktop audio render sink and its three-case fixture (WASAPI)](docs/experiments.md#desktop-audio-render-sink) | `ctest --preset release --no-tests=error -R '^startup_audio_output$' -V` |

The control-flow CPU translator supports [source-built string memory transfers](docs/experiments.md#string-memory-transfers-in-the-control-flow-cpu-lifter). MOVS and STOS, with and without REP, copy and fill 1-, 2-, 4- and 8-byte elements in either direction.
Expand Down
6 changes: 3 additions & 3 deletions docs/experiments.md
Original file line number Diff line number Diff line change
Expand Up @@ -12406,8 +12406,8 @@ The accepted descriptions, views, limits and log lines are listed in `docs/start
one-pipe equations of AMD addrlib's `GFX10_SW_{256,4K,64K}_{S,D}_PATINFO` rows written out in the test
(five element sizes for each of the six modes), with `bc7_4k_s.h` on five 4 KiB surfaces, with
`bc64_chain.h` on eight 64 KiB chains and with `tile64_plan.h` on ten tile plans; it tiles and
detiles nine textures back to their bytes, and lists 11 refused layouts, 15 slot 70 descriptions and
16 views on each side of the accepted set. `startup_gfx10_layout_display_control` reads the `0x10a`
detiles nine textures back to their bytes, and lists 11 refused layouts, 19 slot 70 descriptions and
21 views on each side of the accepted set. `startup_gfx10_layout_display_control` reads the `0x10a`
order as `0x109` and must fail. The addrlib reference is the revision `tools/fetch_addrlib.py` pins
(Mesa 25.1.0, commit `5c142e46f3f6e752ed745fd48912ebb8fad67145`, `src/amd/addrlib`, MIT); the files
and their notice ("Copyright (C) 2007-2024 Advanced Micro Devices, Inc. All rights reserved.",
Expand All @@ -12430,7 +12430,7 @@ a partial-tile BC view does after a later row copy.
An upload of a console-layout texture owns its upload buffer. The buffer and the texture stay referenced
by the recording and by each submit of it until the queue has completed that submit; the shared
upload ring, which is reused without waiting for a queue, is not used. `startup_address_console_gate_{warp,hardware}`
makes the queue wait on a fence the fixture holds (queue slot 17), then records and submits eighteen
starts by closing and resetting an unsubmitted recording of payload 0, then records the identical bytes again. It makes the queue wait on a fence the fixture holds (queue slot 17), then records and submits eighteen
lists on one list object, resetting the allocator and the list between them. Each republishes one
2048 by 2048 RGBA8 texture at `0x109` (16 MiB) from the same address with a new payload and draws it,
payload 0 over the left half of the target and the others over the right half. No submit may complete
Expand Down
3 changes: 1 addition & 2 deletions docs/startup-runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -2116,8 +2116,7 @@ after AMD addrlib, Mesa 25.1.0, `src/amd/addrlib`, MIT). A 256 B layout is taken

The description must be two-dimensional, at most 16384 texels a side, with 1 to 15 mips, one sample,
no target, depth or unordered-access flag, and a format with a known element size (8- to 128-bit
texels and BC1 to BC7, whose largest mip must then be whole 4x4 blocks). The view must be a 2D or
2D-array view of the same typeless family whose mip and slice ranges stay inside the texture.
texels and BC1 to BC7, whose largest mip must then be whole 4x4 blocks). The view must use a supported typed format that matches the storage format or belongs to its typeless parent. The 2D or 2D-array view must fit the mip and slice ranges. A mismatched or interior view overlapping a live resource preserves the destination descriptor.
Anything else is refused as before and leaves the destination descriptor unchanged: layout `0` and
the linear mode `0x100` without a live texture, three-dimensional and cube views, multisampled
textures, the XOR swizzle modes and every other layout value. The texels must be readable and span
Expand Down
75 changes: 56 additions & 19 deletions src/startup_stubs/address_texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,82 @@
#include "startup_stubs/gfx10_layout.h"

namespace x2w_startup {
inline bool address_depth_format(DXGI_FORMAT format)
{
return (format >= DXGI_FORMAT_R32G8X24_TYPELESS && format <= DXGI_FORMAT_X32_TYPELESS_G8X24_UINT) ||
(format >= DXGI_FORMAT_R24G8_TYPELESS && format <= DXGI_FORMAT_X24_TYPELESS_G8_UINT) ||
format == DXGI_FORMAT_D32_FLOAT || format == DXGI_FORMAT_D16_UNORM;
}

inline bool console_address_texture(const D3D12_RESOURCE_DESC& r)
{
// Each flag is cast on its own: with MinGW-w64 headers the flag enum's operator| is not constexpr.
constexpr UINT not_sampled_only = static_cast<UINT>(D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET) |
static_cast<UINT>(D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL) |
static_cast<UINT>(D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS) |
static_cast<UINT>(D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE);
constexpr UINT incompatible_flags = static_cast<UINT>(D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET) |
static_cast<UINT>(D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL) |
static_cast<UINT>(D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS) |
static_cast<UINT>(D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE) |
static_cast<UINT>(D3D12_RESOURCE_FLAG_ALLOW_CROSS_ADAPTER);
if (!gfx10::supports(r) || r.SampleDesc.Quality || (static_cast<UINT>(r.Flags) & incompatible_flags) ||
r.DepthOrArraySize > D3D12_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION ||
!((std::max)(r.Width, UINT64{r.Height}) >> (r.MipLevels - 1)) ||
(r.Alignment && r.Alignment != D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT &&
r.Alignment != D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT) ||
address_depth_format(r.Format))
return false;

// A desktop block-compressed texture needs whole 4x4 blocks in its largest mip.
const UINT texels = gfx10::element_of(r.Format).texels;
return r.SampleDesc.Quality == 0 && !(static_cast<UINT>(r.Flags) & not_sampled_only) && gfx10::supports(r) &&
r.Width % texels == 0 && r.Height % texels == 0;
return r.Width % texels == 0 && r.Height % texels == 0;
}

// Formats with one typeless parent hold the same bytes; a view may name any of them.
inline UINT format_family(DXGI_FORMAT format)
// A colour format's fully typeless parent, when the format has one.
inline DXGI_FORMAT address_format_family(DXGI_FORMAT format)
{
const UINT f = static_cast<UINT>(format);
constexpr UINT first[] = {1, 5, 9, 15, 19, 23, 27, 33, 39, 44, 48, 53, 60, 70, 73, 76, 79, 82, 94, 97};
constexpr UINT last[] = {4, 8, 14, 18, 22, 25, 32, 38, 43, 47, 52, 59, 64, 72, 75, 78, 81, 84, 96, 99};
constexpr UINT first[] = {1, 5, 9, 15, 23, 27, 33, 39, 48, 53, 60, 70, 73, 76, 79, 82, 94, 97};
constexpr UINT last[] = {4, 8, 14, 18, 25, 32, 38, 43, 52, 59, 64, 72, 75, 78, 81, 84, 96, 99};
for (UINT i = 0; i < sizeof(first) / sizeof(first[0]); ++i)
if (f >= first[i] && f <= last[i]) return first[i];
if (f == 87 || f == 90 || f == 91) return 90; // B8G8R8A8
if (f == 88 || f == 92 || f == 93) return 92; // B8G8R8X8
return f;
if (f >= first[i] && f <= last[i]) return static_cast<DXGI_FORMAT>(first[i]);
if (f == 87 || f == 90 || f == 91) return DXGI_FORMAT_B8G8R8A8_TYPELESS;
if (f == 88 || f == 92 || f == 93) return DXGI_FORMAT_B8G8R8X8_TYPELESS;
return DXGI_FORMAT_UNKNOWN;
}

inline bool address_view_format(DXGI_FORMAT storage, DXGI_FORMAT view)
{
if (!gfx10::element_of(view).bytes || address_depth_format(view)) return false;
const auto parent = address_format_family(view);
return view != parent && (view == storage || (parent != DXGI_FORMAT_UNKNOWN && storage == parent));
}

inline bool address_component_mapping(UINT mapping)
{
constexpr UINT required = D3D12_SHADER_COMPONENT_MAPPING_ALWAYS_SET_BIT_AVOIDING_ZEROMEM_MISTAKES;
if (mapping < required || mapping >= required * 2) return false;
for (UINT channel = 0; channel < 4; ++channel)
if (D3D12_DECODE_SHADER_4_COMPONENT_MAPPING(channel, mapping) > D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_1)
return false;
return true;
}

// A two-dimensional or array view that stays inside the texture and reads its texels as stored.
inline bool address_view_fits(const D3D12_RESOURCE_DESC& r, const D3D12_SHADER_RESOURCE_VIEW_DESC& v)
{
if (format_family(v.Format) != format_family(r.Format)) return false;
if (!address_view_format(r.Format, v.Format) || !address_component_mapping(v.Shader4ComponentMapping))
return false;
const auto inside = [](UINT first, UINT count, UINT total) {
return first < total && (count == ~0u || (count && count <= total - first));
return first < total && count && count <= total - first;
};
const auto mips_fit = [&](UINT first, UINT count) {
return count == ~0u ? first < r.MipLevels : inside(first, count, r.MipLevels);
};
if (v.ViewDimension == D3D12_SRV_DIMENSION_TEXTURE2D)
return inside(v.Texture2D.MostDetailedMip, v.Texture2D.MipLevels, r.MipLevels) && !v.Texture2D.PlaneSlice;
return r.DepthOrArraySize == 1 && mips_fit(v.Texture2D.MostDetailedMip, v.Texture2D.MipLevels) &&
!v.Texture2D.PlaneSlice && v.Texture2D.ResourceMinLODClamp == 0.0f;
if (v.ViewDimension == D3D12_SRV_DIMENSION_TEXTURE2DARRAY)
return inside(v.Texture2DArray.MostDetailedMip, v.Texture2DArray.MipLevels, r.MipLevels) &&
return mips_fit(v.Texture2DArray.MostDetailedMip, v.Texture2DArray.MipLevels) &&
inside(v.Texture2DArray.FirstArraySlice, v.Texture2DArray.ArraySize, r.DepthOrArraySize) &&
!v.Texture2DArray.PlaneSlice;
!v.Texture2DArray.PlaneSlice && v.Texture2DArray.ResourceMinLODClamp == 0.0f;
return false;
}
} // namespace x2w_startup
Loading
Loading