summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl/gl_rasterizer.cpp
diff options
context:
space:
mode:
authorReinUsesLisp <reinuseslisp@airmail.cc>2019-12-29 05:28:53 +0100
committerReinUsesLisp <reinuseslisp@airmail.cc>2020-02-28 21:56:42 +0100
commit758ad3f75d49be811237c297265038f80c16ee8c (patch)
tree71f3fd600b58f241f8caa9e09caf6ed9a630c693 /src/video_core/renderer_opengl/gl_rasterizer.cpp
parentmaxwell_3d: Change write dirty flags to a bitset (diff)
downloadyuzu-758ad3f75d49be811237c297265038f80c16ee8c.tar
yuzu-758ad3f75d49be811237c297265038f80c16ee8c.tar.gz
yuzu-758ad3f75d49be811237c297265038f80c16ee8c.tar.bz2
yuzu-758ad3f75d49be811237c297265038f80c16ee8c.tar.lz
yuzu-758ad3f75d49be811237c297265038f80c16ee8c.tar.xz
yuzu-758ad3f75d49be811237c297265038f80c16ee8c.tar.zst
yuzu-758ad3f75d49be811237c297265038f80c16ee8c.zip
Diffstat (limited to 'src/video_core/renderer_opengl/gl_rasterizer.cpp')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp51
1 files changed, 29 insertions, 22 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 211b11489..bb89985cc 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -164,12 +164,22 @@ void RasterizerOpenGL::SetupVertexFormat() {
void RasterizerOpenGL::SetupVertexBuffer() {
auto& gpu = system.GPU().Maxwell3D();
- const auto& regs = gpu.regs;
+ auto& flags = gpu.dirty.flags;
+ if (!flags[Dirty::VertexBuffers]) {
+ return;
+ }
+ flags[Dirty::VertexBuffers] = false;
MICROPROFILE_SCOPE(OpenGL_VB);
// Upload all guest vertex arrays sequentially to our buffer
- for (u32 index = 0; index < Maxwell::NumVertexArrays; ++index) {
+ const auto& regs = gpu.regs;
+ for (std::size_t index = 0; index < Maxwell::NumVertexArrays; ++index) {
+ if (!flags[Dirty::VertexBuffer0 + index]) {
+ continue;
+ }
+ flags[Dirty::VertexBuffer0 + index] = false;
+
const auto& vertex_array = regs.vertex_array[index];
if (!vertex_array.IsEnabled()) {
continue;
@@ -183,33 +193,30 @@ void RasterizerOpenGL::SetupVertexBuffer() {
const auto [vertex_buffer, vertex_buffer_offset] = buffer_cache.UploadMemory(start, size);
// Bind the vertex array to the buffer at the current offset.
- vertex_array_pushbuffer.SetVertexBuffer(index, vertex_buffer, vertex_buffer_offset,
- vertex_array.stride);
-
- if (regs.instanced_arrays.IsInstancingEnabled(index) && vertex_array.divisor != 0) {
- // Enable vertex buffer instancing with the specified divisor.
- glVertexBindingDivisor(index, vertex_array.divisor);
- } else {
- // Disable the vertex buffer instancing.
- glVertexBindingDivisor(index, 0);
- }
+ vertex_array_pushbuffer.SetVertexBuffer(static_cast<GLuint>(index), vertex_buffer,
+ vertex_buffer_offset, vertex_array.stride);
}
}
void RasterizerOpenGL::SetupVertexInstances() {
auto& gpu = system.GPU().Maxwell3D();
- const auto& regs = gpu.regs;
+ auto& flags = gpu.dirty.flags;
+ if (!flags[Dirty::VertexInstances]) {
+ return;
+ }
+ flags[Dirty::VertexInstances] = 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.
- glVertexBindingDivisor(index, regs.vertex_array[index].divisor);
- } else {
- // Disable the vertex buffer instancing.
- glVertexBindingDivisor(index, 0);
+ const auto& regs = gpu.regs;
+ for (std::size_t index = 0; index < 16; ++index) {
+ if (!flags[Dirty::VertexInstance0 + index]) {
+ continue;
}
+ flags[Dirty::VertexInstance0 + index] = false;
+
+ const auto gl_index = static_cast<GLuint>(index);
+ const bool instancing_enabled = regs.instanced_arrays.IsInstancingEnabled(gl_index);
+ const GLuint divisor = instancing_enabled ? regs.vertex_array[index].divisor : 0;
+ glVertexBindingDivisor(gl_index, divisor);
}
}