[GPU/UI] XeSL readability improvements + float suffix

Use the _xe suffix instead of the xesl_ prefix for quicker visual
recognition of identifiers, also switch to snake_case for consistency.

Also add the f suffix to float32 literals because the Metal Shading
Language is based on C++.
This commit is contained in:
Triang3l
2025-08-19 21:36:06 +03:00
parent 3b4b04c371
commit 04d5c40d0d
201 changed files with 90552 additions and 92369 deletions

View File

@@ -9,81 +9,82 @@
#include "texture_load.xesli"
xesl_writeTypedStorageBuffer_declare(xesl_uint4, xe_texture_load_dest, set=0,
binding=0, u0, space0)
xesl_typedStorageBuffer_declare(xesl_uint4, xe_texture_load_source, set=1,
binding=0, t0, space0)
xesl_entry_bindings_begin_compute
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_CONSTANT_BUFFER_BINDING
xesl_entry_binding_next
xesl_writeTypedStorageBuffer_binding(xesl_uint4, xe_texture_load_dest,
buffer(1))
xesl_entry_binding_next
xesl_typedStorageBuffer_binding(xesl_uint4, xe_texture_load_source, buffer(2))
xesl_entry_bindings_end_inputs_begin_compute
xesl_entry_input_globalInvocationID
xesl_entry_inputs_end_code_begin_compute
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
{
// 1 thread = 4 DXT3A-as-1111 blocks to 16x4 16bpp texels passed through an
// externally provided
// `uint4 XE_TEXTURE_LOAD_DXT3A_AS_1_1_1_1_TO_16BPP(uint2 halfblocks)`
// conversion function.
XeTextureLoadInfo load_info = XeTextureLoadGetInfo(
xesl_function_call_constantBuffer(xe_texture_load_constants));
xesl_uint3 block_index = xesl_GlobalInvocationID << xesl_uint3(2u, 0u, 0u);
xesl_dont_flatten
if (any(xesl_greaterThanEqual(block_index.xy, load_info.size_blocks.xy))) {
pass_const_buffer_xe(xe_texture_load_constants));
uint3_xe block_index = in_global_thread_id_xe << uint3_xe(2u, 0u, 0u);
dont_flatten_xe
if (any(greater_than_equal_xe(block_index.xy, load_info.size_blocks.xy))) {
return;
}
xesl_uint3 texel_index_host = block_index << xesl_uint3(2u, 2u, 0u);
uint3_xe texel_index_host = block_index << uint3_xe(2u, 2u, 0u);
uint block_offset_host = uint(
(XeTextureHostLinearOffset(xesl_int3(texel_index_host),
(XeTextureHostLinearOffset(int3_xe(texel_index_host),
load_info.host_pitch, load_info.height_texels,
2u) +
load_info.host_offset) >> 4u);
uint elements_pitch_host = load_info.host_pitch >> 4u;
uint block_offset_guest =
XeTextureLoadGuestBlockOffset(load_info, block_index, 8u, 3u) >> 4u;
xesl_uint4 blocks_01 = XeEndianSwap32(
xesl_typedStorageBufferLoad(xe_texture_load_source, block_offset_guest),
uint4_xe blocks_01 = XeEndianSwap32(
array_buffer_load_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;
xesl_uint4 blocks_23 = XeEndianSwap32(
xesl_typedStorageBufferLoad(xe_texture_load_source, block_offset_guest),
uint4_xe blocks_23 = XeEndianSwap32(
array_buffer_load_xe(xe_texture_load_source, block_offset_guest),
load_info.endian_32);
xesl_typedStorageBufferStore(
array_buffer_store_xe(
xe_texture_load_dest, block_offset_host,
XE_TEXTURE_LOAD_DXT3A_AS_1_1_1_1_TO_16BPP(blocks_01.xz));
xesl_typedStorageBufferStore(
array_buffer_store_xe(
xe_texture_load_dest, block_offset_host + 1u,
XE_TEXTURE_LOAD_DXT3A_AS_1_1_1_1_TO_16BPP(blocks_23.xz));
xesl_dont_flatten if (++texel_index_host.y < load_info.height_texels) {
dont_flatten_xe if (++texel_index_host.y < load_info.height_texels) {
block_offset_host += elements_pitch_host;
xesl_uint4 high_halfblocks = xesl_uint4(blocks_01.xz, blocks_23.xz) >> 16u;
xesl_typedStorageBufferStore(
uint4_xe high_halfblocks = uint4_xe(blocks_01.xz, blocks_23.xz) >> 16u;
array_buffer_store_xe(
xe_texture_load_dest, block_offset_host,
XE_TEXTURE_LOAD_DXT3A_AS_1_1_1_1_TO_16BPP(high_halfblocks.xy));
xesl_typedStorageBufferStore(
array_buffer_store_xe(
xe_texture_load_dest, block_offset_host + 1u,
XE_TEXTURE_LOAD_DXT3A_AS_1_1_1_1_TO_16BPP(high_halfblocks.zw));
xesl_dont_flatten if (++texel_index_host.y < load_info.height_texels) {
dont_flatten_xe if (++texel_index_host.y < load_info.height_texels) {
block_offset_host += elements_pitch_host;
xesl_typedStorageBufferStore(
array_buffer_store_xe(
xe_texture_load_dest, block_offset_host,
XE_TEXTURE_LOAD_DXT3A_AS_1_1_1_1_TO_16BPP(blocks_01.yw));
xesl_typedStorageBufferStore(
array_buffer_store_xe(
xe_texture_load_dest, block_offset_host + 1u,
XE_TEXTURE_LOAD_DXT3A_AS_1_1_1_1_TO_16BPP(blocks_23.yw));
xesl_dont_flatten if (++texel_index_host.y < load_info.height_texels) {
dont_flatten_xe if (++texel_index_host.y < load_info.height_texels) {
block_offset_host += elements_pitch_host;
high_halfblocks = xesl_uint4(blocks_01.yw, blocks_23.yw) >> 16u;
xesl_typedStorageBufferStore(
high_halfblocks = uint4_xe(blocks_01.yw, blocks_23.yw) >> 16u;
array_buffer_store_xe(
xe_texture_load_dest, block_offset_host,
XE_TEXTURE_LOAD_DXT3A_AS_1_1_1_1_TO_16BPP(high_halfblocks.xy));
xesl_typedStorageBufferStore(
array_buffer_store_xe(
xe_texture_load_dest, block_offset_host + 1u,
XE_TEXTURE_LOAD_DXT3A_AS_1_1_1_1_TO_16BPP(high_halfblocks.zw));
}
}
}
xesl_entry_code_end_compute
}
entry_code_end_compute_xe