summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid <25727384+ogniK5377@users.noreply.github.com>2019-09-22 15:10:07 +0200
committerGitHub <noreply@github.com>2019-09-22 15:10:07 +0200
commit3bfba233622da947efacf10a1ce1271a859b9939 (patch)
tree0751a9a153e0acc11ffa9ca12d8c21af56416f63 /src
parentMerge pull request #2893 from ogniK5377/revert-dlz (diff)
parentgl_rasterizer: Remove unused code paths from ConfigureFramebuffers (diff)
downloadyuzu-3bfba233622da947efacf10a1ce1271a859b9939.tar
yuzu-3bfba233622da947efacf10a1ce1271a859b9939.tar.gz
yuzu-3bfba233622da947efacf10a1ce1271a859b9939.tar.bz2
yuzu-3bfba233622da947efacf10a1ce1271a859b9939.tar.lz
yuzu-3bfba233622da947efacf10a1ce1271a859b9939.tar.xz
yuzu-3bfba233622da947efacf10a1ce1271a859b9939.tar.zst
yuzu-3bfba233622da947efacf10a1ce1271a859b9939.zip
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_framebuffer_cache.cpp27
-rw-r--r--src/video_core/renderer_opengl/gl_framebuffer_cache.h1
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp88
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.h38
4 files changed, 33 insertions, 121 deletions
diff --git a/src/video_core/renderer_opengl/gl_framebuffer_cache.cpp b/src/video_core/renderer_opengl/gl_framebuffer_cache.cpp
index 7c926bd48..a5d69d78d 100644
--- a/src/video_core/renderer_opengl/gl_framebuffer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_framebuffer_cache.cpp
@@ -35,21 +35,16 @@ OGLFramebuffer FramebufferCacheOpenGL::CreateFramebuffer(const FramebufferCacheK
local_state.draw.draw_framebuffer = framebuffer.handle;
local_state.ApplyFramebufferState();
- if (key.is_single_buffer) {
- if (key.color_attachments[0] != GL_NONE && key.colors[0]) {
- key.colors[0]->Attach(key.color_attachments[0], GL_DRAW_FRAMEBUFFER);
- glDrawBuffer(key.color_attachments[0]);
- } else {
- glDrawBuffer(GL_NONE);
- }
- } else {
- for (std::size_t index = 0; index < Maxwell::NumRenderTargets; ++index) {
- if (key.colors[index]) {
- key.colors[index]->Attach(GL_COLOR_ATTACHMENT0 + static_cast<GLenum>(index),
- GL_DRAW_FRAMEBUFFER);
- }
+ for (std::size_t index = 0; index < Maxwell::NumRenderTargets; ++index) {
+ if (key.colors[index]) {
+ key.colors[index]->Attach(GL_COLOR_ATTACHMENT0 + static_cast<GLenum>(index),
+ GL_DRAW_FRAMEBUFFER);
}
+ }
+ if (key.colors_count) {
glDrawBuffers(key.colors_count, key.color_attachments.data());
+ } else {
+ glDrawBuffer(GL_NONE);
}
if (key.zeta) {
@@ -67,9 +62,9 @@ std::size_t FramebufferCacheKey::Hash() const {
}
bool FramebufferCacheKey::operator==(const FramebufferCacheKey& rhs) const {
- return std::tie(is_single_buffer, stencil_enable, colors_count, color_attachments, colors,
- zeta) == std::tie(rhs.is_single_buffer, rhs.stencil_enable, rhs.colors_count,
- rhs.color_attachments, rhs.colors, rhs.zeta);
+ return std::tie(stencil_enable, colors_count, color_attachments, colors, zeta) ==
+ std::tie(rhs.stencil_enable, rhs.colors_count, rhs.color_attachments, rhs.colors,
+ rhs.zeta);
}
} // namespace OpenGL
diff --git a/src/video_core/renderer_opengl/gl_framebuffer_cache.h b/src/video_core/renderer_opengl/gl_framebuffer_cache.h
index a3a996353..424344c48 100644
--- a/src/video_core/renderer_opengl/gl_framebuffer_cache.h
+++ b/src/video_core/renderer_opengl/gl_framebuffer_cache.h
@@ -19,7 +19,6 @@
namespace OpenGL {
struct alignas(sizeof(u64)) FramebufferCacheKey {
- bool is_single_buffer = false;
bool stencil_enable = false;
u16 colors_count = 0;
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 4dd08bccb..a2c1473db 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -445,99 +445,51 @@ void RasterizerOpenGL::LoadDiskResources(const std::atomic_bool& stop_loading,
shader_cache.LoadDiskCache(stop_loading, callback);
}
-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) {
+void RasterizerOpenGL::ConfigureFramebuffers() {
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 && !gpu.dirty.render_settings) {
- // 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
- // host framebuffer may contain different attachments
- return current_depth_stencil_usage;
+ if (!gpu.dirty.render_settings) {
+ return;
}
gpu.dirty.render_settings = false;
- current_framebuffer_config_state = fb_config_state;
texture_cache.GuardRenderTargets(true);
- View depth_surface{};
- if (using_depth_fb) {
- depth_surface = texture_cache.GetDepthBufferSurface(preserve_contents);
- } else {
- texture_cache.SetEmptyDepthBuffer();
- }
+ View depth_surface = texture_cache.GetDepthBufferSurface(true);
+ const auto& regs = gpu.regs;
+ state.framebuffer_srgb.enabled = regs.framebuffer_srgb != 0;
UNIMPLEMENTED_IF(regs.rt_separate_frag_data == 0);
// Bind the framebuffer surfaces
- current_state.framebuffer_srgb.enabled = regs.framebuffer_srgb != 0;
-
FramebufferCacheKey fbkey;
+ for (std::size_t index = 0; index < Maxwell::NumRenderTargets; ++index) {
+ View color_surface{texture_cache.GetColorBufferSurface(index, true)};
- if (using_color_fb) {
- if (single_color_target) {
- // Used when just a single color attachment is enabled, e.g. for clearing a color buffer
- View color_surface{
- texture_cache.GetColorBufferSurface(*single_color_target, preserve_contents)};
-
- if (color_surface) {
- // Assume that a surface will be written to if it is used as a framebuffer, even if
- // the shader doesn't actually write to it.
- texture_cache.MarkColorBufferInUse(*single_color_target);
- }
-
- fbkey.is_single_buffer = true;
- fbkey.color_attachments[0] =
- GL_COLOR_ATTACHMENT0 + static_cast<GLenum>(*single_color_target);
- fbkey.colors[0] = color_surface;
- for (std::size_t index = 0; index < Maxwell::NumRenderTargets; ++index) {
- if (index != *single_color_target) {
- texture_cache.SetEmptyColorBuffer(index);
- }
- }
- } else {
- // Multiple color attachments are enabled
- for (std::size_t index = 0; index < Maxwell::NumRenderTargets; ++index) {
- View color_surface{texture_cache.GetColorBufferSurface(index, preserve_contents)};
-
- if (color_surface) {
- // Assume that a surface will be written to if it is used as a framebuffer, even
- // if the shader doesn't actually write to it.
- texture_cache.MarkColorBufferInUse(index);
- }
-
- fbkey.color_attachments[index] =
- GL_COLOR_ATTACHMENT0 + regs.rt_control.GetMap(index);
- fbkey.colors[index] = color_surface;
- }
- fbkey.is_single_buffer = false;
- fbkey.colors_count = regs.rt_control.count;
+ if (color_surface) {
+ // Assume that a surface will be written to if it is used as a framebuffer, even
+ // if the shader doesn't actually write to it.
+ texture_cache.MarkColorBufferInUse(index);
}
- } else {
- // No color attachments are enabled - leave them as zero
- fbkey.is_single_buffer = true;
+
+ fbkey.color_attachments[index] = GL_COLOR_ATTACHMENT0 + regs.rt_control.GetMap(index);
+ fbkey.colors[index] = std::move(color_surface);
}
+ fbkey.colors_count = regs.rt_control.count;
if (depth_surface) {
// Assume that a surface will be written to if it is used as a framebuffer, even if
// the shader doesn't actually write to it.
texture_cache.MarkDepthBufferInUse();
- fbkey.zeta = depth_surface;
fbkey.stencil_enable = depth_surface->GetSurfaceParams().type == SurfaceType::DepthStencil;
+ fbkey.zeta = std::move(depth_surface);
}
texture_cache.GuardRenderTargets(false);
- current_state.draw.draw_framebuffer = framebuffer_cache.GetFramebuffer(fbkey);
- SyncViewport(current_state);
-
- return current_depth_stencil_usage = {static_cast<bool>(depth_surface), fbkey.stencil_enable};
+ state.draw.draw_framebuffer = framebuffer_cache.GetFramebuffer(fbkey);
+ SyncViewport(state);
}
void RasterizerOpenGL::ConfigureClearFramebuffer(OpenGLState& current_state, bool using_color_fb,
@@ -757,7 +709,7 @@ void RasterizerOpenGL::DrawArrays() {
SetupShaders(params.primitive_mode);
texture_cache.GuardSamplers(false);
- ConfigureFramebuffers(state);
+ ConfigureFramebuffers();
// Signal the buffer cache that we are not going to upload more things.
const bool invalidate = buffer_cache.Unmap();
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h
index eada752e0..4f5c7f864 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer.h
@@ -77,39 +77,8 @@ public:
const VideoCore::DiskResourceLoadCallback& callback) override;
private:
- struct FramebufferConfigState {
- bool using_color_fb{};
- bool using_depth_fb{};
- bool preserve_contents{};
- std::optional<std::size_t> single_color_target;
-
- bool operator==(const FramebufferConfigState& rhs) const {
- return std::tie(using_color_fb, using_depth_fb, preserve_contents,
- single_color_target) == std::tie(rhs.using_color_fb, rhs.using_depth_fb,
- rhs.preserve_contents,
- rhs.single_color_target);
- }
- bool operator!=(const FramebufferConfigState& rhs) const {
- return !operator==(rhs);
- }
- };
-
- /**
- * Configures the color and depth framebuffer states.
- *
- * @param current_state The current OpenGL state.
- * @param using_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.
- * @param single_color_target Specifies if a single color buffer target should be used.
- *
- * @returns If depth (first) or stencil (second) are being stored in the bound zeta texture
- * (requires using_depth_fb to be true)
- */
- std::pair<bool, bool> ConfigureFramebuffers(
- OpenGLState& current_state, bool using_color_fb = true, bool using_depth_fb = true,
- bool preserve_contents = true, std::optional<std::size_t> single_color_target = {});
+ /// Configures the color and depth framebuffer states.
+ void ConfigureFramebuffers();
void ConfigureClearFramebuffer(OpenGLState& current_state, bool using_color_fb,
bool using_depth_fb, bool using_stencil_fb);
@@ -228,9 +197,6 @@ private:
OGLVertexArray>
vertex_array_cache;
- FramebufferConfigState current_framebuffer_config_state;
- std::pair<bool, bool> current_depth_stencil_usage{};
-
static constexpr std::size_t STREAM_BUFFER_SIZE = 128 * 1024 * 1024;
OGLBufferCache buffer_cache;