[D3D12] Add red/blue swap to EDRAM loads and describe resolve modes
This commit is contained in:
@@ -8,6 +8,15 @@ void main(uint3 xe_group_id : SV_GroupID,
|
||||
tile_dword_index.x *= 4u;
|
||||
uint4 pixels = xe_edram_load_store_source.Load4(
|
||||
XeEDRAMOffset(xe_group_id.xy, tile_dword_index));
|
||||
if (xe_edram_swap_red_blue != 0u) {
|
||||
// Not a very long shift, just 16 or 20.
|
||||
uint blue_shift = xe_edram_swap_red_blue >> 16u;
|
||||
uint red_mask = xe_edram_swap_red_blue & 0xFFFFu;
|
||||
uint blue_mask = red_mask << blue_shift;
|
||||
pixels = (pixels & ~(red_mask | blue_mask)) |
|
||||
((pixels & red_mask) << blue_shift) |
|
||||
((pixels >> blue_shift) & red_mask);
|
||||
}
|
||||
uint rt_offset = xe_thread_id.y * xe_edram_rt_color_depth_pitch +
|
||||
xe_thread_id.x * 16u;
|
||||
xe_edram_load_store_dest.Store4(rt_offset, pixels);
|
||||
|
||||
@@ -13,6 +13,11 @@ void main(uint3 xe_group_id : SV_GroupID,
|
||||
}
|
||||
uint4 pixels = xe_edram_load_store_source.Load4(
|
||||
XeEDRAMOffset(xe_group_id.xy, tile_dword_index));
|
||||
if (xe_edram_swap_red_blue != 0u) {
|
||||
// The only 64-bit formats with a blue component are 16_16_16_16 and
|
||||
// 16_16_16_16_FLOAT.
|
||||
pixels = (pixels.yxwz & 0xFFFFu) | (pixels & 0xFFFF0000u);
|
||||
}
|
||||
uint rt_offset = xe_thread_id.y * xe_edram_rt_color_depth_pitch +
|
||||
xe_thread_id.x * 16u;
|
||||
xe_edram_load_store_dest.Store4(rt_offset, pixels);
|
||||
|
||||
@@ -14,6 +14,10 @@ void main(uint3 xe_group_id : SV_GroupID,
|
||||
uint4 pixels_f16u32_packed =
|
||||
uint4(pixel_0_f16u32.xz, pixel_1_f16u32.xz) |
|
||||
(uint4(pixel_0_f16u32.yw, pixel_1_f16u32.yw) << 16u);
|
||||
if (xe_edram_swap_red_blue != 0u) {
|
||||
pixels_f16u32_packed = (pixels_f16u32_packed.yxwz & 0xFFFFu) |
|
||||
(pixels_f16u32_packed & 0xFFFF0000u);
|
||||
}
|
||||
uint rt_offset = xe_thread_id.y * xe_edram_rt_color_depth_pitch +
|
||||
xe_thread_id.x * 16u;
|
||||
xe_edram_load_store_dest.Store4(rt_offset, pixels_f16u32_packed);
|
||||
|
||||
@@ -5,9 +5,13 @@ cbuffer XeEDRAMLoadStoreConstants : register(b0) {
|
||||
uint xe_edram_base_tiles;
|
||||
uint xe_edram_pitch_tiles;
|
||||
uint xe_edram_rt_color_depth_pitch;
|
||||
uint xe_edram_rt_stencil_offset;
|
||||
uint xe_edram_rt_stencil_offset_or_swap_red_blue;
|
||||
uint xe_edram_rt_stencil_pitch;
|
||||
};
|
||||
#define xe_edram_rt_stencil_offset xe_edram_rt_stencil_offset_or_swap_red_blue
|
||||
// For loads only. How exactly it's handled depends on the specific load shader,
|
||||
// but 0 always means red and blue shouldn't be swapped.
|
||||
#define xe_edram_swap_red_blue xe_edram_rt_stencil_offset_or_swap_red_blue
|
||||
|
||||
ByteAddressBuffer xe_edram_load_store_source : register(t0);
|
||||
RWByteAddressBuffer xe_edram_load_store_dest : register(u0);
|
||||
|
||||
Reference in New Issue
Block a user