[GPU] XeSL texture load shaders + minor XeSL cleanup
This commit is contained in:
83
src/xenia/gpu/shaders/texture_load_dxt3aas1111.xesli
Normal file
83
src/xenia/gpu/shaders/texture_load_dxt3aas1111.xesli
Normal file
@@ -0,0 +1,83 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* Xenia : Xbox 360 Emulator Research Project *
|
||||
******************************************************************************
|
||||
* Copyright 2022 Ben Vanik. All rights reserved. *
|
||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
#include "texture_load.xesli"
|
||||
|
||||
xesl_entry
|
||||
xesl_writeTypedStorageBuffer(xesl_uint4, xe_texture_load_dest, set=0,
|
||||
binding=0, u0, space0)
|
||||
xesl_entry_binding_next
|
||||
xesl_typedStorageBuffer(xesl_uint4, xe_texture_load_source, set=1, binding=0,
|
||||
t0, space0)
|
||||
xesl_entry_bindings_end_local_size(8, 32, 1)
|
||||
xesl_input_global_invocation_id
|
||||
xesl_entry_signature_end
|
||||
// 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.
|
||||
xesl_uint3 block_index = xesl_GlobalInvocationID << xesl_uint3(2u, 0u, 0u);
|
||||
xesl_dont_flatten
|
||||
if (any(xesl_greaterThanEqual(block_index.xy,
|
||||
XeTextureLoadSizeBlocks().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;
|
||||
uint block_offset_guest =
|
||||
XeTextureLoadGuestBlockOffset(block_index, 8u, 3u) >> 4u;
|
||||
uint endian = XeTextureLoadEndian32();
|
||||
xesl_uint4 blocks_01 = XeEndianSwap32(
|
||||
xesl_typedStorageBufferLoad(xe_texture_load_source, block_offset_guest),
|
||||
endian);
|
||||
// Odd 2 blocks = even 2 blocks + 32 bytes when tiled.
|
||||
block_offset_guest += XeTextureLoadIsTiled() ? 2u : 1u;
|
||||
xesl_uint4 blocks_23 = XeEndianSwap32(
|
||||
xesl_typedStorageBufferLoad(xe_texture_load_source, block_offset_guest),
|
||||
endian);
|
||||
xesl_writeTypedStorageBufferStore(
|
||||
xe_texture_load_dest, block_offset_host,
|
||||
XE_TEXTURE_LOAD_DXT3A_AS_1_1_1_1_TO_16BPP(blocks_01.xz));
|
||||
xesl_writeTypedStorageBufferStore(
|
||||
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 < height_texels) {
|
||||
block_offset_host += elements_pitch_host;
|
||||
xesl_writeTypedStorageBufferStore(
|
||||
xe_texture_load_dest, block_offset_host,
|
||||
XE_TEXTURE_LOAD_DXT3A_AS_1_1_1_1_TO_16BPP(blocks_01.xz >> 16u));
|
||||
xesl_writeTypedStorageBufferStore(
|
||||
xe_texture_load_dest, block_offset_host + 1u,
|
||||
XE_TEXTURE_LOAD_DXT3A_AS_1_1_1_1_TO_16BPP(blocks_23.xz >> 16u));
|
||||
xesl_dont_flatten if (++texel_index_host.y < height_texels) {
|
||||
block_offset_host += elements_pitch_host;
|
||||
xesl_writeTypedStorageBufferStore(
|
||||
xe_texture_load_dest, block_offset_host,
|
||||
XE_TEXTURE_LOAD_DXT3A_AS_1_1_1_1_TO_16BPP(blocks_01.yw));
|
||||
xesl_writeTypedStorageBufferStore(
|
||||
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 < height_texels) {
|
||||
block_offset_host += elements_pitch_host;
|
||||
xesl_writeTypedStorageBufferStore(
|
||||
xe_texture_load_dest, block_offset_host,
|
||||
XE_TEXTURE_LOAD_DXT3A_AS_1_1_1_1_TO_16BPP(blocks_01.yw >> 16u));
|
||||
xesl_writeTypedStorageBufferStore(
|
||||
xe_texture_load_dest, block_offset_host + 1u,
|
||||
XE_TEXTURE_LOAD_DXT3A_AS_1_1_1_1_TO_16BPP(blocks_23.yw >> 16u));
|
||||
}
|
||||
}
|
||||
}
|
||||
xesl_entry_end
|
||||
Reference in New Issue
Block a user