mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-21 12:05:23 +00:00
gl: Fix clip-space -> depth conversion. Fixes remaining depth read issues
- Also set some default values for samplers in a cleaner way using their 'natural' float values
This commit is contained in:
parent
b50d5107b3
commit
69d3d47901
4 changed files with 18 additions and 6 deletions
|
@ -205,7 +205,6 @@ void GLGSRender::begin()
|
|||
if (__glcheck enable(rsx::method_registers.depth_test_enabled(), GL_DEPTH_TEST))
|
||||
{
|
||||
__glcheck glDepthFunc(comparison_op(rsx::method_registers.depth_func()));
|
||||
__glcheck glDepthMask(rsx::method_registers.depth_write_enabled());
|
||||
}
|
||||
|
||||
if (glDepthBoundsEXT && (__glcheck enable(rsx::method_registers.depth_bounds_test_enabled(), GL_DEPTH_BOUNDS_TEST_EXT)))
|
||||
|
|
|
@ -178,6 +178,7 @@ OPENGL_PROC(PFNGLGENSAMPLERSPROC, GenSamplers);
|
|||
OPENGL_PROC(PFNGLDELETESAMPLERSPROC, DeleteSamplers);
|
||||
OPENGL_PROC(PFNGLBINDSAMPLERPROC, BindSampler);
|
||||
OPENGL_PROC(PFNGLSAMPLERPARAMETERIPROC, SamplerParameteri);
|
||||
OPENGL_PROC(PFNGLSAMPLERPARAMETERFPROC, SamplerParameterf);
|
||||
OPENGL_PROC(PFNGLSAMPLERPARAMETERFVPROC, SamplerParameterfv);
|
||||
|
||||
//Texture Buffers
|
||||
|
|
|
@ -162,14 +162,14 @@ namespace gl
|
|||
}
|
||||
|
||||
glSamplerParameteri(samplerHandle, GL_TEXTURE_MIN_FILTER, min_filter);
|
||||
glSamplerParameteri(samplerHandle, GL_TEXTURE_LOD_BIAS, 0.);
|
||||
glSamplerParameteri(samplerHandle, GL_TEXTURE_MIN_LOD, 0);
|
||||
glSamplerParameteri(samplerHandle, GL_TEXTURE_MAX_LOD, 0);
|
||||
glSamplerParameterf(samplerHandle, GL_TEXTURE_LOD_BIAS, 0.f);
|
||||
glSamplerParameterf(samplerHandle, GL_TEXTURE_MIN_LOD, -1000.f);
|
||||
glSamplerParameterf(samplerHandle, GL_TEXTURE_MAX_LOD, 1000.f);
|
||||
}
|
||||
else
|
||||
{
|
||||
glSamplerParameteri(samplerHandle, GL_TEXTURE_MIN_FILTER, tex_min_filter(tex.min_filter()));
|
||||
glSamplerParameteri(samplerHandle, GL_TEXTURE_LOD_BIAS, tex.bias());
|
||||
glSamplerParameterf(samplerHandle, GL_TEXTURE_LOD_BIAS, tex.bias());
|
||||
glSamplerParameteri(samplerHandle, GL_TEXTURE_MIN_LOD, (tex.min_lod() >> 8));
|
||||
glSamplerParameteri(samplerHandle, GL_TEXTURE_MAX_LOD, (tex.max_lod() >> 8));
|
||||
}
|
||||
|
|
|
@ -523,7 +523,19 @@ namespace rsx
|
|||
|
||||
float scale_z = rsx::method_registers.viewport_scale_z();
|
||||
float offset_z = rsx::method_registers.viewport_offset_z();
|
||||
if (symmetrical_z) offset_z -= .5;
|
||||
|
||||
if (symmetrical_z)
|
||||
{
|
||||
//Since our clip_space is symetrical [-1, 1] we map it to linear space using the eqn:
|
||||
//ln = (clip * 2) - 1 to fully utilize the 0-1 range of the depth buffer
|
||||
//RSX matrices passed already map to the [0, 1] range but mapping to classic OGL
|
||||
//Requires that we undo this step
|
||||
//This can be made unnecessary using the call glClipControl(GL_LOWER_LEFT, GL_ZERO_TO_ONE).
|
||||
//However, ClipControl only made it to opengl core in ver 4.5 though, so this is a workaround.
|
||||
|
||||
offset_z -= 1.f;
|
||||
scale_z *= 2.f;
|
||||
}
|
||||
|
||||
float one = 1.f;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue