[GPU/WGF] Use ByteAddressBuffer in precompiled shaders

Drivers and hardware may provide more optimal paths for untyped buffers
compared to typed.

Also, ByteAddressBuffer may be bound via a root descriptor in Direct3D 12,
greatly simplifying the binding logic.

ByteAddressBuffer also doesn't have the 128 * 2^20 element count limit that
typed and structured buffers have, and doesn't require the structure stride
to be specified at resource creation time in Direct3D 11.
This commit is contained in:
Triang3l
2026-02-09 21:29:18 +03:00
parent c7f61342d7
commit 80dad41454
211 changed files with 121690 additions and 123176 deletions

View File

@@ -10,19 +10,7 @@
#include "pixel_formats.xesli"
#include "texture_load.xesli"
array_buffer_wo_declare_xe(uint4_xe, xe_texture_load_dest, set=0, binding=0, u0,
space0)
array_buffer_declare_xe(uint4_xe, xe_texture_load_source, set=1, binding=0, t0,
space0)
entry_bindings_begin_compute_xe
XE_TEXTURE_LOAD_PUSH_CONST_BINDING
entry_binding_next_xe
array_buffer_wo_binding_xe(uint4_xe, xe_texture_load_dest, buffer(1))
entry_binding_next_xe
array_buffer_binding_xe(uint4_xe, xe_texture_load_source, buffer(2))
entry_bindings_end_inputs_begin_compute_xe
entry_in_global_thread_id_xe
entry_inputs_end_code_begin_compute_xe
XE_TEXTURE_LOAD_ENTRY(16)
{
// 1 thread = 4 DXT3A blocks to 16x4 R8 texels (no need to convert to DXT3
// because the overhead is the same, 2x, but the size must be 4-aligned on
@@ -34,38 +22,37 @@ entry_inputs_end_code_begin_compute_xe
return;
}
uint3_xe texel_index_host = block_index << uint3_xe(2u, 2u, 0u);
uint block_offset_host = uint(
(XeTextureHostLinearOffset(int3_xe(texel_index_host),
load_info.host_pitch, load_info.height_texels,
1u) +
load_info.host_offset) >> 4u);
uint elements_pitch_host = load_info.host_pitch >> 4u;
uint block_offset_host =
load_info.host_offset +
uint(XeTextureHostLinearOffset(int3_xe(texel_index_host),
load_info.host_pitch,
load_info.height_texels, 1u));
uint block_offset_guest =
XeTextureLoadSourceAddress(load_info, block_index, 3u) >> 4u;
XeTextureLoadSourceAddress(load_info, block_index, 3u);
uint4_xe blocks_01 = XeEndianSwap32(
array_buffer_load_xe(xe_texture_load_source, block_offset_guest),
byte_buffer_align16_load16_xe(xe_texture_load_source, block_offset_guest),
load_info.endian_32);
// Odd 2 blocks = even 2 blocks + 32 bytes when tiled.
block_offset_guest += load_info.is_tiled ? 2u : 1u;
block_offset_guest += XeTextureLoadLocalXAddressXor(2u, 3u,
load_info.is_tiled);
uint4_xe blocks_23 = XeEndianSwap32(
array_buffer_load_xe(xe_texture_load_source, block_offset_guest),
byte_buffer_align16_load16_xe(xe_texture_load_source, block_offset_guest),
load_info.endian_32);
array_buffer_store_xe(
byte_buffer_align16_store16_xe(
xe_texture_load_dest, block_offset_host,
XeDXT3FourBlocksRowToA8(uint4_xe(blocks_01.xz, blocks_23.xz)));
dont_flatten_xe if (++texel_index_host.y < load_info.height_texels) {
block_offset_host += elements_pitch_host;
array_buffer_store_xe(
block_offset_host += load_info.host_pitch;
byte_buffer_align16_store16_xe(
xe_texture_load_dest, block_offset_host,
XeDXT3FourBlocksRowToA8(uint4_xe(blocks_01.xz, blocks_23.xz) >> 16u));
dont_flatten_xe if (++texel_index_host.y < load_info.height_texels) {
block_offset_host += elements_pitch_host;
array_buffer_store_xe(
block_offset_host += load_info.host_pitch;
byte_buffer_align16_store16_xe(
xe_texture_load_dest, block_offset_host,
XeDXT3FourBlocksRowToA8(uint4_xe(blocks_01.yw, blocks_23.yw)));
dont_flatten_xe if (++texel_index_host.y < load_info.height_texels) {
block_offset_host += elements_pitch_host;
array_buffer_store_xe(
block_offset_host += load_info.host_pitch;
byte_buffer_align16_store16_xe(
xe_texture_load_dest, block_offset_host,
XeDXT3FourBlocksRowToA8(
uint4_xe(blocks_01.yw, blocks_23.yw) >> 16u));