[D3D12] 64bpp resolve and clear - GTA IV ingame

This commit is contained in:
Triang3l
2018-09-16 17:14:21 +03:00
parent 5f0df6d1fa
commit 5997ec6668
7 changed files with 88 additions and 8 deletions

View File

@@ -0,0 +1,25 @@
#define XE_EDRAM_WRITE_ONLY
#include "edram_load_store.hlsli"
// Load4/Store4 aren't needed here, but 80x16 threads is over the limit.
[numthreads(40, 16, 1)]
void main(uint3 xe_group_id : SV_GroupID,
uint3 xe_group_thread_id : SV_GroupThreadID,
uint3 xe_thread_id : SV_DispatchThreadID) {
uint4 clear_rect;
clear_rect.xz = xe_edram_clear_rect & 0xFFFFu;
clear_rect.yw = xe_edram_clear_rect >> 16u;
uint2 sample_index = xe_thread_id.xy;
sample_index.x *= 2u;
[branch] if (any(sample_index < clear_rect.xy) ||
any(sample_index >= clear_rect.zw)) {
return;
}
uint2 tile_sample_index = xe_group_thread_id.xy;
tile_sample_index.x *= 2u;
uint edram_offset = XeEDRAMOffset64bpp(xe_group_id.xy, tile_sample_index);
xe_edram_load_store_dest.Store2(edram_offset, xe_edram_clear_color64);
if (sample_index.x + 1u < clear_rect.z) {
xe_edram_load_store_dest.Store2(edram_offset + 8u, xe_edram_clear_color64);
}
}

View File

@@ -14,7 +14,7 @@ void main(uint3 xe_thread_id : SV_DispatchThreadID) {
uint4 texels = xe_texture_tile_source.Load4(
xe_texture_tile_host_base + texel_index.y * xe_texture_tile_host_pitch +
texel_index.x * 4u);
texels = XeByteSwap(texels, xe_texture_tile_endian_guest_pitch & 7u);
texels = XeByteSwap(texels, xe_texture_tile_endian_guest_pitch);
uint4 texel_addresses = xe_texture_tile_guest_base + XeTextureTiledOffset2D(
texel_index, xe_texture_tile_endian_guest_pitch >> 3u, 2u);
xe_texture_tile_dest.Store(texel_addresses.x, texels.x);

View File

@@ -0,0 +1,37 @@
#include "texture_tile.hlsli"
RWByteAddressBuffer xe_texture_tile_dest : register(u0);
[numthreads(8, 32, 1)]
void main(uint3 xe_thread_id : SV_DispatchThreadID) {
// 1 thread = 4 texels.
uint2 texture_size = (xe_texture_tile_size >> uint2(0u, 16u)) & 0xFFFFu;
uint2 texel_index = xe_thread_id.xy;
texel_index.x <<= 2u;
[branch] if (any(texel_index >= texture_size)) {
return;
}
uint4 texel_addresses = xe_texture_tile_guest_base + XeTextureTiledOffset2D(
texel_index, xe_texture_tile_endian_guest_pitch >> 3u, 3u);
bool3 texels_inside = uint3(1u, 2u, 3u) + texel_index.x < texture_size.x;
uint texels_source_offset = xe_texture_tile_host_base + texel_index.y *
xe_texture_tile_host_pitch + texel_index.x * 8u;
uint4 texels = XeByteSwap64(
xe_texture_tile_source.Load4(texels_source_offset),
xe_texture_tile_endian_guest_pitch);
xe_texture_tile_dest.Store2(texel_addresses.x, texels.xy);
[branch] if (texels_inside.x) {
xe_texture_tile_dest.Store2(texel_addresses.y, texels.zw);
[branch] if (texels_inside.y) {
texels = XeByteSwap64(
xe_texture_tile_source.Load4(texels_source_offset + 16u),
xe_texture_tile_endian_guest_pitch);
xe_texture_tile_dest.Store2(texel_addresses.z, texels.xy);
[branch] if (texels_inside.z) {
xe_texture_tile_dest.Store2(texel_addresses.w, texels.zw);
}
}
}
}