summaryrefslogtreecommitdiff
path: root/src/video_core/renderer_opengl
diff options
context:
space:
mode:
authorGravatar bunnei2018-11-26 18:33:22 -0500
committerGravatar GitHub2018-11-26 18:33:22 -0500
commit67a154e23da149da29e6bd04ce2fb95f3eb7675a (patch)
tree914026c2130ca51f929127e470608109890ba0a9 /src/video_core/renderer_opengl
parentGPU States: Implement Polygon Offset. This is used in SMO all the time. (#1784) (diff)
parentgl_rasterizer: Skip VB upload if the state is clean. (diff)
downloadyuzu-67a154e23da149da29e6bd04ce2fb95f3eb7675a.tar.gz
yuzu-67a154e23da149da29e6bd04ce2fb95f3eb7675a.tar.xz
yuzu-67a154e23da149da29e6bd04ce2fb95f3eb7675a.zip
Merge pull request #1723 from degasus/dirty_flags
gl_rasterizer: Skip VB upload if the state is clean.
Diffstat (limited to 'src/video_core/renderer_opengl')
-rw-r--r--src/video_core/renderer_opengl/gl_buffer_cache.cpp3
-rw-r--r--src/video_core/renderer_opengl/gl_buffer_cache.h2
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp24
3 files changed, 23 insertions, 6 deletions
diff --git a/src/video_core/renderer_opengl/gl_buffer_cache.cpp b/src/video_core/renderer_opengl/gl_buffer_cache.cpp
index 075192c3f..46a6c0308 100644
--- a/src/video_core/renderer_opengl/gl_buffer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_buffer_cache.cpp
@@ -76,7 +76,7 @@ std::tuple<u8*, GLintptr> OGLBufferCache::ReserveMemory(std::size_t size, std::s
76 return std::make_tuple(uploaded_ptr, uploaded_offset); 76 return std::make_tuple(uploaded_ptr, uploaded_offset);
77} 77}
78 78
79void OGLBufferCache::Map(std::size_t max_size) { 79bool OGLBufferCache::Map(std::size_t max_size) {
80 bool invalidate; 80 bool invalidate;
81 std::tie(buffer_ptr, buffer_offset_base, invalidate) = 81 std::tie(buffer_ptr, buffer_offset_base, invalidate) =
82 stream_buffer.Map(static_cast<GLsizeiptr>(max_size), 4); 82 stream_buffer.Map(static_cast<GLsizeiptr>(max_size), 4);
@@ -85,6 +85,7 @@ void OGLBufferCache::Map(std::size_t max_size) {
85 if (invalidate) { 85 if (invalidate) {
86 InvalidateAll(); 86 InvalidateAll();
87 } 87 }
88 return invalidate;
88} 89}
89 90
90void OGLBufferCache::Unmap() { 91void OGLBufferCache::Unmap() {
diff --git a/src/video_core/renderer_opengl/gl_buffer_cache.h b/src/video_core/renderer_opengl/gl_buffer_cache.h
index 91fca3f6c..c11acfb79 100644
--- a/src/video_core/renderer_opengl/gl_buffer_cache.h
+++ b/src/video_core/renderer_opengl/gl_buffer_cache.h
@@ -50,7 +50,7 @@ public:
50 /// Reserves memory to be used by host's CPU. Returns mapped address and offset. 50 /// Reserves memory to be used by host's CPU. Returns mapped address and offset.
51 std::tuple<u8*, GLintptr> ReserveMemory(std::size_t size, std::size_t alignment = 4); 51 std::tuple<u8*, GLintptr> ReserveMemory(std::size_t size, std::size_t alignment = 4);
52 52
53 void Map(std::size_t max_size); 53 bool Map(std::size_t max_size);
54 void Unmap(); 54 void Unmap();
55 55
56 GLuint GetHandle() const; 56 GLuint GetHandle() const;
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 2d5e65f41..1f9acda36 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -176,15 +176,25 @@ void RasterizerOpenGL::SetupVertexFormat() {
176 } 176 }
177 state.draw.vertex_array = VAO.handle; 177 state.draw.vertex_array = VAO.handle;
178 state.ApplyVertexBufferState(); 178 state.ApplyVertexBufferState();
179
180 // Rebinding the VAO invalidates the vertex buffer bindings.
181 gpu.dirty_flags.vertex_array = 0xFFFFFFFF;
179} 182}
180 183
181void RasterizerOpenGL::SetupVertexBuffer() { 184void RasterizerOpenGL::SetupVertexBuffer() {
182 MICROPROFILE_SCOPE(OpenGL_VB); 185 auto& gpu = Core::System::GetInstance().GPU().Maxwell3D();
183 const auto& gpu = Core::System::GetInstance().GPU().Maxwell3D();
184 const auto& regs = gpu.regs; 186 const auto& regs = gpu.regs;
185 187
188 if (!gpu.dirty_flags.vertex_array)
189 return;
190
191 MICROPROFILE_SCOPE(OpenGL_VB);
192
186 // Upload all guest vertex arrays sequentially to our buffer 193 // Upload all guest vertex arrays sequentially to our buffer
187 for (u32 index = 0; index < Maxwell::NumVertexArrays; ++index) { 194 for (u32 index = 0; index < Maxwell::NumVertexArrays; ++index) {
195 if (~gpu.dirty_flags.vertex_array & (1u << index))
196 continue;
197
188 const auto& vertex_array = regs.vertex_array[index]; 198 const auto& vertex_array = regs.vertex_array[index];
189 if (!vertex_array.IsEnabled()) 199 if (!vertex_array.IsEnabled())
190 continue; 200 continue;
@@ -211,6 +221,8 @@ void RasterizerOpenGL::SetupVertexBuffer() {
211 221
212 // Implicit set by glBindVertexBuffer. Stupid glstate handling... 222 // Implicit set by glBindVertexBuffer. Stupid glstate handling...
213 state.draw.vertex_buffer = buffer_cache.GetHandle(); 223 state.draw.vertex_buffer = buffer_cache.GetHandle();
224
225 gpu.dirty_flags.vertex_array = 0;
214} 226}
215 227
216DrawParameters RasterizerOpenGL::SetupDraw() { 228DrawParameters RasterizerOpenGL::SetupDraw() {
@@ -600,7 +612,7 @@ void RasterizerOpenGL::DrawArrays() {
600 return; 612 return;
601 613
602 MICROPROFILE_SCOPE(OpenGL_Drawing); 614 MICROPROFILE_SCOPE(OpenGL_Drawing);
603 const auto& gpu = Core::System::GetInstance().GPU().Maxwell3D(); 615 auto& gpu = Core::System::GetInstance().GPU().Maxwell3D();
604 const auto& regs = gpu.regs; 616 const auto& regs = gpu.regs;
605 617
606 ScopeAcquireGLContext acquire_context{emu_window}; 618 ScopeAcquireGLContext acquire_context{emu_window};
@@ -653,7 +665,11 @@ void RasterizerOpenGL::DrawArrays() {
653 // Add space for at least 18 constant buffers 665 // Add space for at least 18 constant buffers
654 buffer_size += Maxwell::MaxConstBuffers * (MaxConstbufferSize + uniform_buffer_alignment); 666 buffer_size += Maxwell::MaxConstBuffers * (MaxConstbufferSize + uniform_buffer_alignment);
655 667
656 buffer_cache.Map(buffer_size); 668 bool invalidate = buffer_cache.Map(buffer_size);
669 if (invalidate) {
670 // As all cached buffers are invalidated, we need to recheck their state.
671 gpu.dirty_flags.vertex_attrib_format = 0xFFFFFFFF;
672 }
657 673
658 SetupVertexFormat(); 674 SetupVertexFormat();
659 SetupVertexBuffer(); 675 SetupVertexBuffer();