summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2019-12-25 21:02:17 +0100
committerReinUsesLisp <reinuseslisp@airmail.cc>2020-02-28 20:39:27 +0100
commit96ac3d518a9882a2a040f319c47a567467c9266d (patch)
treed1465f931df28d12891b07e5ab8c1d921a396376 /src/video_core/renderer_opengl
parentcommon/math_util: Support float type rectangles (diff)
downloadyuzu-96ac3d518a9882a2a040f319c47a567467c9266d.tar
yuzu-96ac3d518a9882a2a040f319c47a567467c9266d.tar.gz
yuzu-96ac3d518a9882a2a040f319c47a567467c9266d.tar.bz2
yuzu-96ac3d518a9882a2a040f319c47a567467c9266d.tar.lz
yuzu-96ac3d518a9882a2a040f319c47a567467c9266d.tar.xz
yuzu-96ac3d518a9882a2a040f319c47a567467c9266d.tar.zst
yuzu-96ac3d518a9882a2a040f319c47a567467c9266d.zip
Diffstat (limited to '')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp70
-rw-r--r--src/video_core/renderer_opengl/gl_shader_cache.cpp4
-rw-r--r--src/video_core/renderer_opengl/gl_state.cpp20
-rw-r--r--src/video_core/renderer_opengl/gl_state.h31
-rw-r--r--src/video_core/renderer_opengl/gl_state_tracker.cpp0
-rw-r--r--src/video_core/renderer_opengl/gl_state_tracker.h0
-rw-r--r--src/video_core/renderer_opengl/gl_texture_cache.cpp2
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp14
8 files changed, 2 insertions, 139 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index e1965fb21..1d203fd08 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -117,11 +117,6 @@ GLuint RasterizerOpenGL::SetupVertexFormat() {
auto& gpu = system.GPU().Maxwell3D();
const auto& regs = gpu.regs;
- if (!gpu.dirty.vertex_attrib_format) {
- return state.draw.vertex_array;
- }
- gpu.dirty.vertex_attrib_format = false;
-
MICROPROFILE_SCOPE(OpenGL_VAO);
auto [iter, is_cache_miss] = vertex_array_cache.try_emplace(regs.vertex_attrib_format);
@@ -173,30 +168,18 @@ GLuint RasterizerOpenGL::SetupVertexFormat() {
}
}
- // Rebinding the VAO invalidates the vertex buffer bindings.
- gpu.dirty.ResetVertexArrays();
-
state.draw.vertex_array = vao_entry.handle;
return vao_entry.handle;
}
void RasterizerOpenGL::SetupVertexBuffer(GLuint vao) {
auto& gpu = system.GPU().Maxwell3D();
- if (!gpu.dirty.vertex_array_buffers)
- return;
- gpu.dirty.vertex_array_buffers = false;
-
const auto& regs = gpu.regs;
MICROPROFILE_SCOPE(OpenGL_VB);
// Upload all guest vertex arrays sequentially to our buffer
for (u32 index = 0; index < Maxwell::NumVertexArrays; ++index) {
- if (!gpu.dirty.vertex_array[index])
- continue;
- gpu.dirty.vertex_array[index] = false;
- gpu.dirty.vertex_instance[index] = false;
-
const auto& vertex_array = regs.vertex_array[index];
if (!vertex_array.IsEnabled())
continue;
@@ -224,19 +207,10 @@ void RasterizerOpenGL::SetupVertexBuffer(GLuint vao) {
void RasterizerOpenGL::SetupVertexInstances(GLuint vao) {
auto& gpu = system.GPU().Maxwell3D();
-
- if (!gpu.dirty.vertex_instances)
- return;
- gpu.dirty.vertex_instances = false;
-
const auto& regs = gpu.regs;
- // Upload all guest vertex arrays sequentially to our buffer
- for (u32 index = 0; index < Maxwell::NumVertexArrays; ++index) {
- if (!gpu.dirty.vertex_instance[index])
- continue;
-
- gpu.dirty.vertex_instance[index] = false;
+ // Upload all guest vertex arrays sequentially to our buffer
+ for (u32 index = 0; index < 16; ++index) {
if (regs.instanced_arrays.IsInstancingEnabled(index) &&
regs.vertex_array[index].divisor != 0) {
// Enable vertex buffer instancing with the specified divisor.
@@ -334,8 +308,6 @@ void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) {
}
SyncClipEnabled(clip_distances);
-
- gpu.dirty.shaders = false;
}
std::size_t RasterizerOpenGL::CalculateVertexArraysSize() const {
@@ -371,10 +343,6 @@ void RasterizerOpenGL::LoadDiskResources(const std::atomic_bool& stop_loading,
void RasterizerOpenGL::ConfigureFramebuffers() {
MICROPROFILE_SCOPE(OpenGL_Framebuffer);
auto& gpu = system.GPU().Maxwell3D();
- if (!gpu.dirty.render_settings) {
- return;
- }
- gpu.dirty.render_settings = false;
texture_cache.GuardRenderTargets(true);
@@ -453,7 +421,6 @@ void RasterizerOpenGL::Clear() {
OpenGLState prev_state{OpenGLState::GetCurState()};
SCOPE_EXIT({
- prev_state.AllDirty();
prev_state.Apply();
});
@@ -528,7 +495,6 @@ void RasterizerOpenGL::Clear() {
clear_state.EmulateViewportWithScissor();
}
- clear_state.AllDirty();
clear_state.Apply();
if (use_color) {
@@ -631,12 +597,6 @@ void RasterizerOpenGL::Draw(bool is_indexed, bool is_instanced) {
bind_ubo_pushbuffer.Bind();
bind_ssbo_pushbuffer.Bind();
- if (invalidate) {
- // As all cached buffers are invalidated, we need to recheck their state.
- gpu.dirty.ResetVertexArrays();
- }
- gpu.dirty.memory_general = false;
-
shader_program_manager->ApplyTo(state);
state.Apply();
@@ -1084,14 +1044,8 @@ void RasterizerOpenGL::SyncDepthTestState() {
void RasterizerOpenGL::SyncStencilTestState() {
auto& maxwell3d = system.GPU().Maxwell3D();
- if (!maxwell3d.dirty.stencil_test) {
- return;
- }
- maxwell3d.dirty.stencil_test = false;
-
const auto& regs = maxwell3d.regs;
state.stencil.test_enabled = regs.stencil_enable != 0;
- state.MarkDirtyStencilState();
if (!regs.stencil_enable) {
return;
@@ -1130,9 +1084,6 @@ void RasterizerOpenGL::SyncRasterizeEnable(OpenGLState& current_state) {
void RasterizerOpenGL::SyncColorMask() {
auto& maxwell3d = system.GPU().Maxwell3D();
- if (!maxwell3d.dirty.color_mask) {
- return;
- }
const auto& regs = maxwell3d.regs;
const std::size_t count =
@@ -1145,9 +1096,6 @@ void RasterizerOpenGL::SyncColorMask() {
dest.blue_enabled = (source.B == 0) ? GL_FALSE : GL_TRUE;
dest.alpha_enabled = (source.A == 0) ? GL_FALSE : GL_TRUE;
}
-
- state.MarkDirtyColorMask();
- maxwell3d.dirty.color_mask = false;
}
void RasterizerOpenGL::SyncMultiSampleState() {
@@ -1163,9 +1111,6 @@ void RasterizerOpenGL::SyncFragmentColorClampState() {
void RasterizerOpenGL::SyncBlendState() {
auto& maxwell3d = system.GPU().Maxwell3D();
- if (!maxwell3d.dirty.blend_state) {
- return;
- }
const auto& regs = maxwell3d.regs;
state.blend_color.red = regs.blend_color.r;
@@ -1189,8 +1134,6 @@ void RasterizerOpenGL::SyncBlendState() {
for (std::size_t i = 1; i < Tegra::Engines::Maxwell3D::Regs::NumRenderTargets; i++) {
state.blend[i].enabled = false;
}
- maxwell3d.dirty.blend_state = false;
- state.MarkDirtyBlendState();
return;
}
@@ -1207,9 +1150,6 @@ void RasterizerOpenGL::SyncBlendState() {
blend.src_a_func = MaxwellToGL::BlendFunc(src.factor_source_a);
blend.dst_a_func = MaxwellToGL::BlendFunc(src.factor_dest_a);
}
-
- state.MarkDirtyBlendState();
- maxwell3d.dirty.blend_state = false;
}
void RasterizerOpenGL::SyncLogicOpState() {
@@ -1264,9 +1204,6 @@ void RasterizerOpenGL::SyncPointState() {
void RasterizerOpenGL::SyncPolygonOffset() {
auto& maxwell3d = system.GPU().Maxwell3D();
- if (!maxwell3d.dirty.polygon_offset) {
- return;
- }
const auto& regs = maxwell3d.regs;
state.polygon_offset.fill_enable = regs.polygon_offset_fill_enable != 0;
@@ -1277,9 +1214,6 @@ void RasterizerOpenGL::SyncPolygonOffset() {
state.polygon_offset.units = regs.polygon_offset_units / 2.0f;
state.polygon_offset.factor = regs.polygon_offset_factor;
state.polygon_offset.clamp = regs.polygon_offset_clamp;
-
- state.MarkDirtyPolygonOffset();
- maxwell3d.dirty.polygon_offset = false;
}
void RasterizerOpenGL::SyncAlphaTest() {
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp
index 489eb143c..bef141f63 100644
--- a/src/video_core/renderer_opengl/gl_shader_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp
@@ -623,10 +623,6 @@ bool ShaderCacheOpenGL::GenerateUnspecializedShaders(
}
Shader ShaderCacheOpenGL::GetStageProgram(Maxwell::ShaderProgram program) {
- if (!system.GPU().Maxwell3D().dirty.shaders) {
- return last_shaders[static_cast<std::size_t>(program)];
- }
-
auto& memory_manager{system.GPU().MemoryManager()};
const GPUVAddr address{GetShaderAddress(system, program)};
diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp
index 7d3bc1a1f..732cb3a3c 100644
--- a/src/video_core/renderer_opengl/gl_state.cpp
+++ b/src/video_core/renderer_opengl/gl_state.cpp
@@ -189,11 +189,6 @@ void OpenGLState::ApplyRasterizerDiscard() {
}
void OpenGLState::ApplyColorMask() {
- if (!dirty.color_mask) {
- return;
- }
- dirty.color_mask = false;
-
for (std::size_t i = 0; i < Maxwell::NumRenderTargets; ++i) {
const auto& updated = color_mask[i];
auto& current = cur_state.color_mask[i];
@@ -232,11 +227,6 @@ void OpenGLState::ApplyPrimitiveRestart() {
}
void OpenGLState::ApplyStencilTest() {
- if (!dirty.stencil_state) {
- return;
- }
- dirty.stencil_state = false;
-
Enable(GL_STENCIL_TEST, cur_state.stencil.test_enabled, stencil.test_enabled);
const auto ConfigStencil = [](GLenum face, const auto& config, auto& current) {
@@ -351,11 +341,6 @@ void OpenGLState::ApplyTargetBlending(std::size_t target, bool force) {
}
void OpenGLState::ApplyBlending() {
- if (!dirty.blend_state) {
- return;
- }
- dirty.blend_state = false;
-
if (independant_blend.enabled) {
const bool force = independant_blend.enabled != cur_state.independant_blend.enabled;
for (std::size_t target = 0; target < Maxwell::NumRenderTargets; ++target) {
@@ -383,11 +368,6 @@ void OpenGLState::ApplyLogicOp() {
}
void OpenGLState::ApplyPolygonOffset() {
- if (!dirty.polygon_offset) {
- return;
- }
- dirty.polygon_offset = false;
-
Enable(GL_POLYGON_OFFSET_FILL, cur_state.polygon_offset.fill_enable,
polygon_offset.fill_enable);
Enable(GL_POLYGON_OFFSET_LINE, cur_state.polygon_offset.line_enable,
diff --git a/src/video_core/renderer_opengl/gl_state.h b/src/video_core/renderer_opengl/gl_state.h
index bce662f2c..5dda9e88f 100644
--- a/src/video_core/renderer_opengl/gl_state.h
+++ b/src/video_core/renderer_opengl/gl_state.h
@@ -212,39 +212,8 @@ public:
/// Viewport does not affects glClearBuffer so emulate viewport using scissor test
void EmulateViewportWithScissor();
- void MarkDirtyBlendState() {
- dirty.blend_state = true;
- }
-
- void MarkDirtyStencilState() {
- dirty.stencil_state = true;
- }
-
- void MarkDirtyPolygonOffset() {
- dirty.polygon_offset = true;
- }
-
- void MarkDirtyColorMask() {
- dirty.color_mask = true;
- }
-
- void AllDirty() {
- dirty.blend_state = true;
- dirty.stencil_state = true;
- dirty.polygon_offset = true;
- dirty.color_mask = true;
- }
-
private:
static OpenGLState cur_state;
-
- struct {
- bool blend_state;
- bool stencil_state;
- bool viewport_state;
- bool polygon_offset;
- bool color_mask;
- } dirty{};
};
static_assert(std::is_trivially_copyable_v<OpenGLState>);
diff --git a/src/video_core/renderer_opengl/gl_state_tracker.cpp b/src/video_core/renderer_opengl/gl_state_tracker.cpp
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/video_core/renderer_opengl/gl_state_tracker.cpp
diff --git a/src/video_core/renderer_opengl/gl_state_tracker.h b/src/video_core/renderer_opengl/gl_state_tracker.h
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/src/video_core/renderer_opengl/gl_state_tracker.h
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp
index cf934b0d8..942cc6c0a 100644
--- a/src/video_core/renderer_opengl/gl_texture_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp
@@ -522,7 +522,6 @@ void TextureCacheOpenGL::ImageBlit(View& src_view, View& dst_view,
OpenGLState prev_state{OpenGLState::GetCurState()};
SCOPE_EXIT({
- prev_state.AllDirty();
prev_state.Apply();
});
@@ -530,7 +529,6 @@ void TextureCacheOpenGL::ImageBlit(View& src_view, View& dst_view,
state.draw.read_framebuffer = src_framebuffer.handle;
state.draw.draw_framebuffer = dst_framebuffer.handle;
state.framebuffer_srgb.enabled = dst_params.srgb_conversion;
- state.AllDirty();
state.Apply();
u32 buffers{};
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp
index a4340b502..f71e23f9e 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -311,11 +311,6 @@ void RendererOpenGL::SwapBuffers(const Tegra::FramebufferConfig* framebuffer) {
return;
}
- // Maintain the rasterizer's state as a priority
- OpenGLState prev_state = OpenGLState::GetCurState();
- state.AllDirty();
- state.Apply();
-
PrepareRendertarget(framebuffer);
RenderScreenshot();
@@ -368,10 +363,6 @@ void RendererOpenGL::SwapBuffers(const Tegra::FramebufferConfig* framebuffer) {
m_current_frame++;
rasterizer->TickFrame();
}
-
- // Restore the rasterizer state
- prev_state.AllDirty();
- prev_state.Apply();
}
void RendererOpenGL::PrepareRendertarget(const Tegra::FramebufferConfig* framebuffer) {
@@ -445,7 +436,6 @@ void RendererOpenGL::InitOpenGLObjects() {
// Link shaders and get variable locations
shader.CreateFromSource(vertex_shader, nullptr, fragment_shader);
state.draw.shader_program = shader.handle;
- state.AllDirty();
state.Apply();
// Generate VBO handle for drawing
@@ -580,14 +570,12 @@ void RendererOpenGL::DrawScreenTriangles(const ScreenInfo& screen_info, float x,
state.textures[0] = screen_info.display_texture;
state.framebuffer_srgb.enabled = screen_info.display_srgb;
- state.AllDirty();
state.Apply();
glNamedBufferSubData(vertex_buffer.handle, 0, sizeof(vertices), std::data(vertices));
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
// Restore default state
state.framebuffer_srgb.enabled = false;
state.textures[0] = 0;
- state.AllDirty();
state.Apply();
}
@@ -658,7 +646,6 @@ void RendererOpenGL::RenderScreenshot() {
GLuint old_read_fb = state.draw.read_framebuffer;
GLuint old_draw_fb = state.draw.draw_framebuffer;
state.draw.read_framebuffer = state.draw.draw_framebuffer = screenshot_framebuffer.handle;
- state.AllDirty();
state.Apply();
Layout::FramebufferLayout layout{renderer_settings.screenshot_framebuffer_layout};
@@ -678,7 +665,6 @@ void RendererOpenGL::RenderScreenshot() {
screenshot_framebuffer.Release();
state.draw.read_framebuffer = old_read_fb;
state.draw.draw_framebuffer = old_draw_fb;
- state.AllDirty();
state.Apply();
glDeleteRenderbuffers(1, &renderbuffer);