mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-20 22:05:12 +00:00
gl: Fix D24X8 accelerated encode/decode
- PS3 D24X8 is swapped as a full word, unlike PC. - Add missing paths to handle custom swap behavior.
This commit is contained in:
parent
81fa3da101
commit
362a26a404
5 changed files with 76 additions and 33 deletions
|
|
@ -14,8 +14,8 @@ R"(
|
|||
#define FMT_GL_BGR5_A1 0x99F0
|
||||
#define FMT_GL_RGBA4 0x8056
|
||||
|
||||
#define bswap_u16(bits) (bits & 0xFF) << 8 | (bits & 0xFF00) >> 8 | (bits & 0xFF0000) << 8 | (bits & 0xFF000000) >> 8
|
||||
#define bswap_u32(bits) (bits & 0xFF) << 24 | (bits & 0xFF00) << 8 | (bits & 0xFF0000) >> 8 | (bits & 0xFF000000) >> 24
|
||||
#define bswap_u16(bits) (bits & 0xFFu) << 8u | (bits & 0xFF00u) >> 8u | (bits & 0xFF0000u) << 8u | (bits & 0xFF000000u) >> 8u
|
||||
#define bswap_u32(bits) (bits & 0xFFu) << 24u | (bits & 0xFF00u) << 8u | (bits & 0xFF0000u) >> 8u | (bits & 0xFF000000u) >> 24u
|
||||
|
||||
layout(location=0) out vec4 outColor;
|
||||
|
||||
|
|
@ -73,18 +73,10 @@ uint readUint32(const in uint address)
|
|||
|
||||
uvec2 readUint24_8(const in uint address)
|
||||
{
|
||||
const uint raw_value = data[address];
|
||||
const uint stencil = bitfieldExtract(raw_value, 0, 8);
|
||||
|
||||
if (swap_bytes != 0)
|
||||
{
|
||||
const uint depth = min(bswap_u32(raw_value), 0xffffff);
|
||||
return uvec2(depth, stencil);
|
||||
}
|
||||
|
||||
const uint raw_value = readUint32(address);
|
||||
return uvec2(
|
||||
bitfieldExtract(raw_value, 8, 24),
|
||||
stencil
|
||||
bitfieldExtract(raw_value, 0, 8)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@ layout(local_size_x = %ws, local_size_y = 1, local_size_z = 1) in;
|
|||
#define IMAGE_LOCATION(x) (x + %loc)
|
||||
#define SSBO_LOCATION IMAGE_LOCATION(2)
|
||||
|
||||
#define bswap_u32(bits) (bits & 0xFFu) << 24u | (bits & 0xFF00u) << 8u | (bits & 0xFF0000u) >> 8u | (bits & 0xFF000000u) >> 24u
|
||||
|
||||
layout(%set, binding=IMAGE_LOCATION(0)) uniform sampler2D depthData;
|
||||
layout(%set, binding=IMAGE_LOCATION(1)) uniform usampler2D stencilData;
|
||||
|
||||
|
|
@ -62,13 +64,15 @@ void main()
|
|||
float depth = texelFetch(depthData, coord, 0).x;
|
||||
uint stencil = texelFetch(stencilData, coord, 0).x;
|
||||
uint depth_bytes = uint(depth * 0xffffff);
|
||||
uint value = (depth_bytes << 8) | stencil;
|
||||
|
||||
if (swap_bytes != 0)
|
||||
{
|
||||
depth_bytes = (bitfieldExtract(depth_bytes, 0, 8) << 16u) | (bitfieldExtract(depth_bytes, 16, 8) << 0u) | depth_bytes & 0xFF00u;
|
||||
// PS3-style byteswap (full word). PC byteswap is slightly different.
|
||||
value = bswap_u32(value);
|
||||
}
|
||||
|
||||
data[input_coord_to_output_id(coord)] = (depth_bytes << 8) | stencil;
|
||||
data[input_coord_to_output_id(coord)] = value;
|
||||
}
|
||||
}
|
||||
)"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue