mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-21 12:05:23 +00:00
rsx: Fix depth-as-rgba read in fp
This commit is contained in:
parent
423fd4a388
commit
701728ecd7
3 changed files with 10 additions and 3 deletions
|
@ -185,13 +185,16 @@ void insert_d3d12_legacy_function(std::ostream& OS)
|
|||
OS << " return unpackSnorm2x16(val) * 6.1E+5;\n";
|
||||
OS << "}\n\n";
|
||||
|
||||
//NOTE: After testing with GOW, the w component is either the original depth or wraps around to the x component
|
||||
//Since component.r == depth_value with some precision loss, just use the precise depth value for now (further testing needed)
|
||||
//TODO: This function does not work as intended on DX12
|
||||
OS << "float4 texture2DReconstruct(float depth_value)\n";
|
||||
OS << "{\n";
|
||||
OS << " uint value = round(depth_value * 16777215);\n";
|
||||
OS << " uint b = (value & 0xff);\n";
|
||||
OS << " uint g = (value >> 8) & 0xff;\n";
|
||||
OS << " uint r = (value >> 16) & 0xff;\n";
|
||||
OS << " return float4(r/255., g/255., b/255., 1.);\n";
|
||||
OS << " return float4(r/255., g/255., b/255., depth_value);\n";
|
||||
OS << "}\n\n";
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -121,6 +121,8 @@ void insert_glsl_legacy_function(std::ostream& OS)
|
|||
OS << "}\n\n";
|
||||
|
||||
//NOTE: We lose precision if we just store depth value into 8-bit textures i.e (depth, 0, 0)
|
||||
//NOTE2: After testing with GOW, the w component is either the original depth or wraps around to the x component
|
||||
//Since component.r == depth_value with some precision loss, just use the precise depth value for now (further testing needed)
|
||||
OS << "vec4 texture2DReconstruct(sampler2D tex, vec2 coord)\n";
|
||||
OS << "{\n";
|
||||
OS << " float depth_value = texture(tex, coord.xy).r;\n";
|
||||
|
@ -128,6 +130,6 @@ void insert_glsl_legacy_function(std::ostream& OS)
|
|||
OS << " uint b = (value & 0xff);\n";
|
||||
OS << " uint g = (value >> 8) & 0xff;\n";
|
||||
OS << " uint r = (value >> 16) & 0xff;\n";
|
||||
OS << " return vec4(float(r)/255., float(g)/255., float(b)/255., 1.);\n";
|
||||
OS << " return vec4(float(r)/255., float(g)/255., float(b)/255., depth_value);\n";
|
||||
OS << "}\n\n";
|
||||
}
|
||||
|
|
|
@ -117,13 +117,15 @@ namespace vk
|
|||
OS << " return result;\n";
|
||||
OS << "}\n\n";
|
||||
|
||||
//NOTE: After testing with GOW, the w component is either the original depth or wraps around to the x component
|
||||
//Since component.r == depth_value with some precision loss, just use the precise depth value for now (further testing needed)
|
||||
OS << "vec4 decodeLinearDepth(float depth_value)\n";
|
||||
OS << "{\n";
|
||||
OS << " uint value = uint(depth_value * 16777215);\n";
|
||||
OS << " uint b = (value & 0xff);\n";
|
||||
OS << " uint g = (value >> 8) & 0xff;\n";
|
||||
OS << " uint r = (value >> 16) & 0xff;\n";
|
||||
OS << " return vec4(float(r)/255., float(g)/255., float(b)/255., 1.);\n";
|
||||
OS << " return vec4(float(r)/255., float(g)/255., float(b)/255., depth_value);\n";
|
||||
OS << "}\n\n";
|
||||
|
||||
OS << "vec4 texture2DReconstruct(sampler2D tex, vec2 coord)\n";
|
||||
|
|
Loading…
Add table
Reference in a new issue