[XeSL] Metal Shading Language definitions

This commit is contained in:
Triang3l
2022-06-16 21:39:16 +03:00
parent 820b7ba217
commit 166be463be
176 changed files with 83740 additions and 83682 deletions

View File

@@ -10,42 +10,45 @@
#include "pixel_formats.xesli"
#include "texture_load.xesli"
xesl_entry
xesl_writeTypedStorageBuffer(xesl_uint4, xe_texture_load_dest, set=0,
binding=0, u0, space0)
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
XE_TEXTURE_LOAD_CONSTANT_BUFFER_BINDING
xesl_entry_binding_next
xesl_typedStorageBuffer(xesl_uint4, xe_texture_load_source, set=1, binding=0,
t0, space0)
xesl_entry_bindings_end_local_size(kXeTextureLoadGroupSizeX,
kXeTextureLoadGroupSizeY, 1)
xesl_input_global_invocation_id
xesl_entry_signature_end
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
// 1 thread = 2 DXN blocks to 8x4 R8G8 texels.
XeTextureLoadInfo load_info = XeTextureLoadGetInfo(
xesl_function_call_constantBuffer(xe_texture_load_constants));
xesl_uint3 block_index = xesl_GlobalInvocationID << xesl_uint3(1u, 0u, 0u);
xesl_dont_flatten
if (any(xesl_greaterThanEqual(block_index.xy,
XeTextureLoadSizeBlocks().xy))) {
if (any(xesl_greaterThanEqual(block_index.xy, load_info.size_blocks.xy))) {
return;
}
xesl_uint3 texel_index_host = block_index << xesl_uint3(2u, 2u, 0u);
uint blocks_pitch_host = XeTextureLoadHostPitch();
uint height_texels = XeTextureLoadHeightTexels();
uint block_offset_host = uint(
(XeTextureHostLinearOffset(xesl_int3(texel_index_host), blocks_pitch_host,
height_texels, 2u) +
XeTextureLoadHostOffset()) >> 4u);
uint elements_pitch_host = blocks_pitch_host >> 4u;
(XeTextureHostLinearOffset(xesl_int3(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(block_index, 16u, 4u) >> 4u;
uint endian = XeTextureLoadEndian32();
XeTextureLoadGuestBlockOffset(load_info, block_index, 16u, 4u) >> 4u;
xesl_uint4 block_0 = XeEndianSwap32(
xesl_typedStorageBufferLoad(xe_texture_load_source, block_offset_guest),
endian);
load_info.endian_32);
// Odd block = even block + 32 guest bytes when tiled.
block_offset_guest += XeTextureLoadIsTiled() ? 2u : 1u;
block_offset_guest += load_info.is_tiled ? 2u : 1u;
xesl_uint4 block_1 = XeEndianSwap32(
xesl_typedStorageBufferLoad(xe_texture_load_source, block_offset_guest),
endian);
load_info.endian_32);
xesl_uint4 end_0 = (block_0.xxzz >> xesl_uint4(0u, 8u, 0u, 8u)) & 0xFFu;
xesl_uint4 end_1 = (block_1.xxzz >> xesl_uint4(0u, 8u, 0u, 8u)) & 0xFFu;
xesl_uint4 weights = (xesl_uint4(block_0.xz, block_1.xz) >> 16u) |
@@ -60,7 +63,7 @@ xesl_entry_signature_end
(XeDXT5RowToA8In16(end_0.zw, weights.y) << 8u),
XeDXT5RowToA8In16(end_1.xy, weights.z) |
(XeDXT5RowToA8In16(end_1.zw, weights.w) << 8u)));
xesl_dont_flatten if (++texel_index_host.y < height_texels) {
xesl_dont_flatten if (++texel_index_host.y < load_info.height_texels) {
block_offset_host += elements_pitch_host;
weights >>= 12u;
xesl_writeTypedStorageBufferStore(
@@ -69,7 +72,7 @@ xesl_entry_signature_end
(XeDXT5RowToA8In16(end_0.zw, weights.y) << 8u),
XeDXT5RowToA8In16(end_1.xy, weights.z) |
(XeDXT5RowToA8In16(end_1.zw, weights.w) << 8u)));
xesl_dont_flatten if (++texel_index_host.y < height_texels) {
xesl_dont_flatten if (++texel_index_host.y < load_info.height_texels) {
block_offset_host += elements_pitch_host;
weights = xesl_uint4(block_0.yw, block_1.yw) >> 8u;
weights = xesl_uint4(XeDXT5HighAlphaWeights(end_0.xy, weights.x),
@@ -82,7 +85,7 @@ xesl_entry_signature_end
(XeDXT5RowToA8In16(end_0.zw, weights.y) << 8u),
XeDXT5RowToA8In16(end_1.xy, weights.z) |
(XeDXT5RowToA8In16(end_1.zw, weights.w) << 8u)));
xesl_dont_flatten if (++texel_index_host.y < height_texels) {
xesl_dont_flatten if (++texel_index_host.y < load_info.height_texels) {
block_offset_host += elements_pitch_host;
weights >>= 12u;
xesl_writeTypedStorageBufferStore(
@@ -94,4 +97,4 @@ xesl_entry_signature_end
}
}
}
xesl_entry_end
xesl_entry_code_end_compute