aboutsummaryrefslogtreecommitdiff
path: root/src/video_core/renderer_opengl
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2019-05-08 17:45:59 -0400
committerReinUsesLisp <reinuseslisp@airmail.cc>2019-06-20 21:36:12 -0300
commit4e2071b6d9b414fa0152deb5e9d55674d636afe4 (patch)
treede07e334d6d345852d289903be961f494b70b2a1 /src/video_core/renderer_opengl
parentba677ccb5a8ae0c889751fcdd40b0c9e818ad992 (diff)
texture_cache: Correct premature texceptions
Due to our current infrastructure, it is possible for a mipmap to be set on as a render target before a texception of that mipmap's superset be set afterwards. This is problematic as we rely on texture views to set up texceptions and protecting render targets targets for 3D texture rendering. One simple solution is to configure framebuffers after texture setup but this brings other problems. This solution, forces a reconfiguration of the framebuffers after such event happens.
Diffstat (limited to 'src/video_core/renderer_opengl')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp15
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.h7
2 files changed, 15 insertions, 7 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 63ee83391..3baf1522d 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -461,15 +461,15 @@ void RasterizerOpenGL::LoadDiskResources(const std::atomic_bool& stop_loading,
}
std::pair<bool, bool> RasterizerOpenGL::ConfigureFramebuffers(
- OpenGLState& current_state, bool using_color_fb, bool using_depth_fb, bool preserve_contents,
- std::optional<std::size_t> single_color_target) {
+ OpenGLState& current_state, bool must_reconfigure, bool using_color_fb, bool using_depth_fb,
+ bool preserve_contents, std::optional<std::size_t> single_color_target) {
MICROPROFILE_SCOPE(OpenGL_Framebuffer);
auto& gpu = system.GPU().Maxwell3D();
const auto& regs = gpu.regs;
const FramebufferConfigState fb_config_state{using_color_fb, using_depth_fb, preserve_contents,
single_color_target};
- if (fb_config_state == current_framebuffer_config_state &&
+ if (!must_reconfigure && fb_config_state == current_framebuffer_config_state &&
gpu.dirty_flags.color_buffer.none() && !gpu.dirty_flags.zeta_buffer) {
// Only skip if the previous ConfigureFramebuffers call was from the same kind (multiple or
// single color targets). This is done because the guest registers may not change but the
@@ -622,8 +622,9 @@ void RasterizerOpenGL::Clear() {
return;
}
- const auto [clear_depth, clear_stencil] = ConfigureFramebuffers(
- clear_state, use_color, use_depth || use_stencil, false, regs.clear_buffers.RT.Value());
+ const auto [clear_depth, clear_stencil] =
+ ConfigureFramebuffers(clear_state, false, use_color, use_depth || use_stencil, false,
+ regs.clear_buffers.RT.Value());
if (regs.clear_flags.scissor) {
SyncScissorTest(clear_state);
}
@@ -705,6 +706,10 @@ void RasterizerOpenGL::DrawArrays() {
DrawParameters params = SetupDraw();
SetupShaders(params.primitive_mode);
+ if (texture_cache.ConsumeReconfigurationFlag()) {
+ ConfigureFramebuffers(state, true);
+ }
+
buffer_cache.Unmap();
shader_program_manager->ApplyTo(state);
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h
index d872e5110..970637efa 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer.h
@@ -101,6 +101,8 @@ private:
/**
* Configures the color and depth framebuffer states.
+ * @param must_reconfigure If true, tells the framebuffer to skip the cache and reconfigure
+ * again. Used by the texture cache to solve texception conflicts
* @param use_color_fb If true, configure color framebuffers.
* @param using_depth_fb If true, configure the depth/stencil framebuffer.
* @param preserve_contents If true, tries to preserve data from a previously used framebuffer.
@@ -109,8 +111,9 @@ private:
* (requires using_depth_fb to be true)
*/
std::pair<bool, bool> ConfigureFramebuffers(
- OpenGLState& current_state, bool use_color_fb = true, bool using_depth_fb = true,
- bool preserve_contents = true, std::optional<std::size_t> single_color_target = {});
+ OpenGLState& current_state, bool must_reconfigure = false, bool use_color_fb = true,
+ bool using_depth_fb = true, bool preserve_contents = true,
+ std::optional<std::size_t> single_color_target = {});
/// Configures the current constbuffers to use for the draw command.
void SetupDrawConstBuffers(Tegra::Engines::Maxwell3D::Regs::ShaderStage stage,