summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authortfarley <tfarleygithub@gmail.com>2016-01-04 00:46:54 +0100
committertfarley <tfarleygithub@gmail.com>2016-01-21 03:57:59 +0100
commitf53dbafdae6b6ca8ab718d2299437df469441389 (patch)
treeddf1b234c2440f8ade62be48ddf1e32ee22c8801 /src
parentMerge pull request #1327 from Subv/unmap_memblock (diff)
downloadyuzu-f53dbafdae6b6ca8ab718d2299437df469441389.tar
yuzu-f53dbafdae6b6ca8ab718d2299437df469441389.tar.gz
yuzu-f53dbafdae6b6ca8ab718d2299437df469441389.tar.bz2
yuzu-f53dbafdae6b6ca8ab718d2299437df469441389.tar.lz
yuzu-f53dbafdae6b6ca8ab718d2299437df469441389.tar.xz
yuzu-f53dbafdae6b6ca8ab718d2299437df469441389.tar.zst
yuzu-f53dbafdae6b6ca8ab718d2299437df469441389.zip
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp16
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.h6
-rw-r--r--src/video_core/renderer_opengl/gl_shader_gen.cpp4
3 files changed, 24 insertions, 2 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 092351dce..291ef737d 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -126,6 +126,7 @@ void RasterizerOpenGL::InitObjects() {
void RasterizerOpenGL::Reset() {
SyncCullMode();
+ SyncDepthModifiers();
SyncBlendEnabled();
SyncBlendFuncs();
SyncBlendColor();
@@ -194,6 +195,12 @@ void RasterizerOpenGL::NotifyPicaRegisterChanged(u32 id) {
SyncCullMode();
break;
+ // Depth modifiers
+ case PICA_REG_INDEX(viewport_depth_range):
+ case PICA_REG_INDEX(viewport_depth_far_plane):
+ SyncDepthModifiers();
+ break;
+
// Blending
case PICA_REG_INDEX(output_merger.alphablend_enable):
SyncBlendEnabled();
@@ -602,6 +609,15 @@ void RasterizerOpenGL::SyncCullMode() {
}
}
+void RasterizerOpenGL::SyncDepthModifiers() {
+ float depth_scale = -Pica::float24::FromRawFloat24(Pica::g_state.regs.viewport_depth_range).ToFloat32();
+ float depth_offset = Pica::float24::FromRawFloat24(Pica::g_state.regs.viewport_depth_far_plane).ToFloat32() / 2.0f;
+
+ // TODO: Implement scale modifier
+ uniform_block_data.data.depth_offset = depth_offset;
+ uniform_block_data.dirty = true;
+}
+
void RasterizerOpenGL::SyncBlendEnabled() {
state.blend.enabled = (Pica::g_state.regs.output_merger.alphablend_enable == 1);
}
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h
index 92b1f812e..c8a2d8f16 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer.h
@@ -197,7 +197,8 @@ private:
std::array<GLfloat, 4> const_color[6];
std::array<GLfloat, 4> tev_combiner_buffer_color;
GLint alphatest_ref;
- INSERT_PADDING_BYTES(12);
+ GLfloat depth_offset;
+ INSERT_PADDING_BYTES(8);
};
static_assert(sizeof(UniformData) == 0x80, "The size of the UniformData structure has changed, update the structure in the shader");
@@ -218,6 +219,9 @@ private:
/// Syncs the cull mode to match the PICA register
void SyncCullMode();
+ /// Syncs the depth scale and offset to match the PICA registers
+ void SyncDepthModifiers();
+
/// Syncs the blend enabled status to match the PICA register
void SyncBlendEnabled();
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp
index 38de5d469..22022f7f4 100644
--- a/src/video_core/renderer_opengl/gl_shader_gen.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp
@@ -334,6 +334,7 @@ layout (std140) uniform shader_data {
vec4 const_color[NUM_TEV_STAGES];
vec4 tev_combiner_buffer_color;
int alphatest_ref;
+ float depth_offset;
};
uniform sampler2D tex[3];
@@ -360,7 +361,8 @@ void main() {
out += ") discard;\n";
}
- out += "color = last_tex_env_out;\n}";
+ out += "color = last_tex_env_out;\n";
+ out += "gl_FragDepth = gl_FragCoord.z + depth_offset;\n}";
return out;
}