[D3D12] Use typed buffers for texture untiling, calculate guest address once per thread
This commit is contained in:
@@ -1,18 +1,38 @@
|
||||
#include "texture_load.hlsli"
|
||||
|
||||
[numthreads(16, 16, 1)]
|
||||
Buffer<uint4> xe_texture_load_source : register(t0);
|
||||
RWBuffer<uint4> xe_texture_load_dest : register(u0);
|
||||
|
||||
[numthreads(4, 32, 1)]
|
||||
void main(uint3 xe_thread_id : SV_DispatchThreadID) {
|
||||
// 1 thread = 1 uint guest texel.
|
||||
[branch] if (any(xe_thread_id >= xe_texture_load_size_blocks)) {
|
||||
// 1 thread = 8 blocks.
|
||||
uint3 block_index = xe_thread_id << uint3(3, 0, 0);
|
||||
[branch] if (any(block_index >= xe_texture_load_size_blocks)) {
|
||||
return;
|
||||
}
|
||||
uint4 blocks = xe_texture_load_source.Load4(
|
||||
XeTextureLoadGuestBlockOffsets(xe_thread_id, 4u, 2u).x << 2u);
|
||||
blocks = XeByteSwap(blocks, xe_texture_load_endianness);
|
||||
uint block_offset_host = XeTextureHostLinearOffset(
|
||||
xe_thread_id << uint3(1u, 1u, 0u), xe_texture_load_size_blocks.y << 1u,
|
||||
xe_texture_load_host_pitch, 4u) + xe_texture_load_host_base;
|
||||
xe_texture_load_dest.Store2(block_offset_host, blocks.xy);
|
||||
xe_texture_load_dest.Store2(block_offset_host + xe_texture_load_host_pitch,
|
||||
blocks.zw);
|
||||
int block_offset_host =
|
||||
(XeTextureHostLinearOffset(int3(block_index) << int3(1, 1, 0),
|
||||
xe_texture_load_size_blocks.y << 1,
|
||||
xe_texture_load_host_pitch, 4u) +
|
||||
xe_texture_load_host_base) >> 4;
|
||||
int elements_pitch_host = xe_texture_load_host_pitch >> 4;
|
||||
int block_offset_guest =
|
||||
XeTextureLoadGuestBlockOffset(int3(block_index), 4u, 2u) >> (4 - 2);
|
||||
uint endian = XeTextureLoadEndian();
|
||||
int i;
|
||||
[unroll] for (i = 0; i < 8; i += 2) {
|
||||
if (i == 4 && XeTextureLoadIsTiled()) {
|
||||
// Odd 4 blocks start = even 4 blocks end + 16 guest bytes when tiled.
|
||||
block_offset_guest += 1 << 2;
|
||||
}
|
||||
// TTBB TTBB -> TTTT on the top row, BBBB on the bottom row.
|
||||
uint4 block_0 = XeByteSwap(xe_texture_load_source[block_offset_guest++],
|
||||
endian);
|
||||
uint4 block_1 = XeByteSwap(xe_texture_load_source[block_offset_guest++],
|
||||
endian);
|
||||
xe_texture_load_dest[block_offset_host] = uint4(block_0.xy, block_1.xy);
|
||||
xe_texture_load_dest[block_offset_host + elements_pitch_host] =
|
||||
uint4(block_0.zw, block_1.zw);
|
||||
++block_offset_host;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user