summaryrefslogtreecommitdiff
path: root/src/video_core/renderer_opengl
diff options
context:
space:
mode:
authorGravatar Fernando S2022-12-08 12:41:39 +0100
committerGravatar GitHub2022-12-08 12:41:39 +0100
commit41461514d6f3ba59dc027dbc4a88c0ffb570ea49 (patch)
treec3cffc17ce63e66f5fa2921e4804c396140a9791 /src/video_core/renderer_opengl
parentMerge pull request #9365 from liamwhite/val (diff)
parentvideo_core: Implement maxwell3d draw manager and split draw logic (diff)
downloadyuzu-41461514d6f3ba59dc027dbc4a88c0ffb570ea49.tar.gz
yuzu-41461514d6f3ba59dc027dbc4a88c0ffb570ea49.tar.xz
yuzu-41461514d6f3ba59dc027dbc4a88c0ffb570ea49.zip
Merge pull request #9401 from vonchenplus/draw_manager
video_core: Implement maxwell3d draw manager and split draw logic
Diffstat (limited to 'src/video_core/renderer_opengl')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp16
-rw-r--r--src/video_core/renderer_opengl/gl_shader_cache.cpp6
2 files changed, 13 insertions, 9 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index f71a316b6..64ed6f628 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -224,16 +224,18 @@ void RasterizerOpenGL::Draw(bool is_indexed, u32 instance_count) {
224 224
225 SyncState(); 225 SyncState();
226 226
227 const GLenum primitive_mode = MaxwellToGL::PrimitiveTopology(maxwell3d->regs.draw.topology); 227 const auto& draw_state = maxwell3d->draw_manager->GetDrawState();
228
229 const GLenum primitive_mode = MaxwellToGL::PrimitiveTopology(draw_state.topology);
228 BeginTransformFeedback(pipeline, primitive_mode); 230 BeginTransformFeedback(pipeline, primitive_mode);
229 231
230 const GLuint base_instance = static_cast<GLuint>(maxwell3d->regs.global_base_instance_index); 232 const GLuint base_instance = static_cast<GLuint>(draw_state.base_instance);
231 const GLsizei num_instances = static_cast<GLsizei>(instance_count); 233 const GLsizei num_instances = static_cast<GLsizei>(instance_count);
232 if (is_indexed) { 234 if (is_indexed) {
233 const GLint base_vertex = static_cast<GLint>(maxwell3d->regs.global_base_vertex_index); 235 const GLint base_vertex = static_cast<GLint>(draw_state.base_index);
234 const GLsizei num_vertices = static_cast<GLsizei>(maxwell3d->regs.index_buffer.count); 236 const GLsizei num_vertices = static_cast<GLsizei>(draw_state.index_buffer.count);
235 const GLvoid* const offset = buffer_cache_runtime.IndexOffset(); 237 const GLvoid* const offset = buffer_cache_runtime.IndexOffset();
236 const GLenum format = MaxwellToGL::IndexFormat(maxwell3d->regs.index_buffer.format); 238 const GLenum format = MaxwellToGL::IndexFormat(draw_state.index_buffer.format);
237 if (num_instances == 1 && base_instance == 0 && base_vertex == 0) { 239 if (num_instances == 1 && base_instance == 0 && base_vertex == 0) {
238 glDrawElements(primitive_mode, num_vertices, format, offset); 240 glDrawElements(primitive_mode, num_vertices, format, offset);
239 } else if (num_instances == 1 && base_instance == 0) { 241 } else if (num_instances == 1 && base_instance == 0) {
@@ -252,8 +254,8 @@ void RasterizerOpenGL::Draw(bool is_indexed, u32 instance_count) {
252 base_instance); 254 base_instance);
253 } 255 }
254 } else { 256 } else {
255 const GLint base_vertex = static_cast<GLint>(maxwell3d->regs.vertex_buffer.first); 257 const GLint base_vertex = static_cast<GLint>(draw_state.vertex_buffer.first);
256 const GLsizei num_vertices = static_cast<GLsizei>(maxwell3d->regs.vertex_buffer.count); 258 const GLsizei num_vertices = static_cast<GLsizei>(draw_state.vertex_buffer.count);
257 if (num_instances == 1 && base_instance == 0) { 259 if (num_instances == 1 && base_instance == 0) {
258 glDrawArrays(primitive_mode, base_vertex, num_vertices); 260 glDrawArrays(primitive_mode, base_vertex, num_vertices);
259 } else if (base_instance == 0) { 261 } else if (base_instance == 0) {
diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp
index a38060100..a59d0d24e 100644
--- a/src/video_core/renderer_opengl/gl_shader_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp
@@ -22,6 +22,7 @@
22#include "shader_recompiler/frontend/maxwell/control_flow.h" 22#include "shader_recompiler/frontend/maxwell/control_flow.h"
23#include "shader_recompiler/frontend/maxwell/translate_program.h" 23#include "shader_recompiler/frontend/maxwell/translate_program.h"
24#include "shader_recompiler/profile.h" 24#include "shader_recompiler/profile.h"
25#include "video_core/engines/draw_manager.h"
25#include "video_core/engines/kepler_compute.h" 26#include "video_core/engines/kepler_compute.h"
26#include "video_core/engines/maxwell_3d.h" 27#include "video_core/engines/maxwell_3d.h"
27#include "video_core/memory_manager.h" 28#include "video_core/memory_manager.h"
@@ -327,7 +328,7 @@ GraphicsPipeline* ShaderCache::CurrentGraphicsPipeline() {
327 const auto& regs{maxwell3d->regs}; 328 const auto& regs{maxwell3d->regs};
328 graphics_key.raw = 0; 329 graphics_key.raw = 0;
329 graphics_key.early_z.Assign(regs.mandated_early_z != 0 ? 1 : 0); 330 graphics_key.early_z.Assign(regs.mandated_early_z != 0 ? 1 : 0);
330 graphics_key.gs_input_topology.Assign(regs.draw.topology.Value()); 331 graphics_key.gs_input_topology.Assign(maxwell3d->draw_manager->GetDrawState().topology);
331 graphics_key.tessellation_primitive.Assign(regs.tessellation.params.domain_type.Value()); 332 graphics_key.tessellation_primitive.Assign(regs.tessellation.params.domain_type.Value());
332 graphics_key.tessellation_spacing.Assign(regs.tessellation.params.spacing.Value()); 333 graphics_key.tessellation_spacing.Assign(regs.tessellation.params.spacing.Value());
333 graphics_key.tessellation_clockwise.Assign( 334 graphics_key.tessellation_clockwise.Assign(
@@ -371,7 +372,8 @@ GraphicsPipeline* ShaderCache::BuiltPipeline(GraphicsPipeline* pipeline) const n
371 // If games are using a small index count, we can assume these are full screen quads. 372 // If games are using a small index count, we can assume these are full screen quads.
372 // Usually these shaders are only used once for building textures so we can assume they 373 // Usually these shaders are only used once for building textures so we can assume they
373 // can't be built async 374 // can't be built async
374 if (maxwell3d->regs.index_buffer.count <= 6 || maxwell3d->regs.vertex_buffer.count <= 6) { 375 const auto& draw_state = maxwell3d->draw_manager->GetDrawState();
376 if (draw_state.index_buffer.count <= 6 || draw_state.vertex_buffer.count <= 6) {
375 return pipeline; 377 return pipeline;
376 } 378 }
377 return nullptr; 379 return nullptr;