summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp59
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.h1
2 files changed, 31 insertions, 29 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 824863561..976f64c24 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -102,8 +102,9 @@ struct FramebufferCacheKey {
102 102
103RasterizerOpenGL::RasterizerOpenGL(Core::Frontend::EmuWindow& window, Core::System& system, 103RasterizerOpenGL::RasterizerOpenGL(Core::Frontend::EmuWindow& window, Core::System& system,
104 ScreenInfo& info) 104 ScreenInfo& info)
105 : res_cache{*this}, shader_cache{*this, system}, global_cache{*this}, emu_window{window}, 105 : res_cache{*this}, shader_cache{*this, system}, global_cache{*this},
106 screen_info{info}, buffer_cache(*this, STREAM_BUFFER_SIZE) { 106 emu_window{window}, system{system}, screen_info{info},
107 buffer_cache(*this, STREAM_BUFFER_SIZE) {
107 // Create sampler objects 108 // Create sampler objects
108 for (std::size_t i = 0; i < texture_samplers.size(); ++i) { 109 for (std::size_t i = 0; i < texture_samplers.size(); ++i) {
109 texture_samplers[i].Create(); 110 texture_samplers[i].Create();
@@ -138,7 +139,7 @@ void RasterizerOpenGL::CheckExtensions() {
138} 139}
139 140
140GLuint RasterizerOpenGL::SetupVertexFormat() { 141GLuint RasterizerOpenGL::SetupVertexFormat() {
141 auto& gpu = Core::System::GetInstance().GPU().Maxwell3D(); 142 auto& gpu = system.GPU().Maxwell3D();
142 const auto& regs = gpu.regs; 143 const auto& regs = gpu.regs;
143 144
144 if (!gpu.dirty_flags.vertex_attrib_format) { 145 if (!gpu.dirty_flags.vertex_attrib_format) {
@@ -207,7 +208,7 @@ GLuint RasterizerOpenGL::SetupVertexFormat() {
207} 208}
208 209
209void RasterizerOpenGL::SetupVertexBuffer(GLuint vao) { 210void RasterizerOpenGL::SetupVertexBuffer(GLuint vao) {
210 auto& gpu = Core::System::GetInstance().GPU().Maxwell3D(); 211 auto& gpu = system.GPU().Maxwell3D();
211 const auto& regs = gpu.regs; 212 const auto& regs = gpu.regs;
212 213
213 if (gpu.dirty_flags.vertex_array.none()) 214 if (gpu.dirty_flags.vertex_array.none())
@@ -248,7 +249,7 @@ void RasterizerOpenGL::SetupVertexBuffer(GLuint vao) {
248} 249}
249 250
250DrawParameters RasterizerOpenGL::SetupDraw() { 251DrawParameters RasterizerOpenGL::SetupDraw() {
251 const auto& gpu = Core::System::GetInstance().GPU().Maxwell3D(); 252 const auto& gpu = system.GPU().Maxwell3D();
252 const auto& regs = gpu.regs; 253 const auto& regs = gpu.regs;
253 const bool is_indexed = accelerate_draw == AccelDraw::Indexed; 254 const bool is_indexed = accelerate_draw == AccelDraw::Indexed;
254 255
@@ -297,7 +298,7 @@ DrawParameters RasterizerOpenGL::SetupDraw() {
297 298
298void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) { 299void RasterizerOpenGL::SetupShaders(GLenum primitive_mode) {
299 MICROPROFILE_SCOPE(OpenGL_Shader); 300 MICROPROFILE_SCOPE(OpenGL_Shader);
300 auto& gpu = Core::System::GetInstance().GPU().Maxwell3D(); 301 auto& gpu = system.GPU().Maxwell3D();
301 302
302 BaseBindings base_bindings; 303 BaseBindings base_bindings;
303 std::array<bool, Maxwell::NumClipDistances> clip_distances{}; 304 std::array<bool, Maxwell::NumClipDistances> clip_distances{};
@@ -413,7 +414,7 @@ void RasterizerOpenGL::SetupCachedFramebuffer(const FramebufferCacheKey& fbkey,
413} 414}
414 415
415std::size_t RasterizerOpenGL::CalculateVertexArraysSize() const { 416std::size_t RasterizerOpenGL::CalculateVertexArraysSize() const {
416 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 417 const auto& regs = system.GPU().Maxwell3D().regs;
417 418
418 std::size_t size = 0; 419 std::size_t size = 0;
419 for (u32 index = 0; index < Maxwell::NumVertexArrays; ++index) { 420 for (u32 index = 0; index < Maxwell::NumVertexArrays; ++index) {
@@ -431,7 +432,7 @@ std::size_t RasterizerOpenGL::CalculateVertexArraysSize() const {
431} 432}
432 433
433std::size_t RasterizerOpenGL::CalculateIndexBufferSize() const { 434std::size_t RasterizerOpenGL::CalculateIndexBufferSize() const {
434 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 435 const auto& regs = system.GPU().Maxwell3D().regs;
435 436
436 return static_cast<std::size_t>(regs.index_array.count) * 437 return static_cast<std::size_t>(regs.index_array.count) *
437 static_cast<std::size_t>(regs.index_array.FormatSizeInBytes()); 438 static_cast<std::size_t>(regs.index_array.FormatSizeInBytes());
@@ -487,7 +488,7 @@ std::pair<bool, bool> RasterizerOpenGL::ConfigureFramebuffers(
487 OpenGLState& current_state, bool using_color_fb, bool using_depth_fb, bool preserve_contents, 488 OpenGLState& current_state, bool using_color_fb, bool using_depth_fb, bool preserve_contents,
488 std::optional<std::size_t> single_color_target) { 489 std::optional<std::size_t> single_color_target) {
489 MICROPROFILE_SCOPE(OpenGL_Framebuffer); 490 MICROPROFILE_SCOPE(OpenGL_Framebuffer);
490 auto& gpu = Core::System::GetInstance().GPU().Maxwell3D(); 491 auto& gpu = system.GPU().Maxwell3D();
491 const auto& regs = gpu.regs; 492 const auto& regs = gpu.regs;
492 493
493 const FramebufferConfigState fb_config_state{using_color_fb, using_depth_fb, preserve_contents, 494 const FramebufferConfigState fb_config_state{using_color_fb, using_depth_fb, preserve_contents,
@@ -581,7 +582,7 @@ void RasterizerOpenGL::Clear() {
581 const auto prev_state{state}; 582 const auto prev_state{state};
582 SCOPE_EXIT({ prev_state.Apply(); }); 583 SCOPE_EXIT({ prev_state.Apply(); });
583 584
584 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 585 const auto& regs = system.GPU().Maxwell3D().regs;
585 bool use_color{}; 586 bool use_color{};
586 bool use_depth{}; 587 bool use_depth{};
587 bool use_stencil{}; 588 bool use_stencil{};
@@ -672,7 +673,7 @@ void RasterizerOpenGL::DrawArrays() {
672 return; 673 return;
673 674
674 MICROPROFILE_SCOPE(OpenGL_Drawing); 675 MICROPROFILE_SCOPE(OpenGL_Drawing);
675 auto& gpu = Core::System::GetInstance().GPU().Maxwell3D(); 676 auto& gpu = system.GPU().Maxwell3D();
676 const auto& regs = gpu.regs; 677 const auto& regs = gpu.regs;
677 678
678 ConfigureFramebuffers(state); 679 ConfigureFramebuffers(state);
@@ -892,7 +893,7 @@ void RasterizerOpenGL::SetupConstBuffers(Tegra::Engines::Maxwell3D::Regs::Shader
892 const Shader& shader, GLuint program_handle, 893 const Shader& shader, GLuint program_handle,
893 BaseBindings base_bindings) { 894 BaseBindings base_bindings) {
894 MICROPROFILE_SCOPE(OpenGL_UBO); 895 MICROPROFILE_SCOPE(OpenGL_UBO);
895 const auto& gpu = Core::System::GetInstance().GPU(); 896 const auto& gpu = system.GPU();
896 const auto& maxwell3d = gpu.Maxwell3D(); 897 const auto& maxwell3d = gpu.Maxwell3D();
897 const auto& shader_stage = maxwell3d.state.shader_stages[static_cast<std::size_t>(stage)]; 898 const auto& shader_stage = maxwell3d.state.shader_stages[static_cast<std::size_t>(stage)];
898 const auto& entries = shader->GetShaderEntries().const_buffers; 899 const auto& entries = shader->GetShaderEntries().const_buffers;
@@ -971,7 +972,7 @@ void RasterizerOpenGL::SetupGlobalRegions(Tegra::Engines::Maxwell3D::Regs::Shade
971void RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, const Shader& shader, 972void RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, const Shader& shader,
972 GLuint program_handle, BaseBindings base_bindings) { 973 GLuint program_handle, BaseBindings base_bindings) {
973 MICROPROFILE_SCOPE(OpenGL_Texture); 974 MICROPROFILE_SCOPE(OpenGL_Texture);
974 const auto& gpu = Core::System::GetInstance().GPU(); 975 const auto& gpu = system.GPU();
975 const auto& maxwell3d = gpu.Maxwell3D(); 976 const auto& maxwell3d = gpu.Maxwell3D();
976 const auto& entries = shader->GetShaderEntries().samplers; 977 const auto& entries = shader->GetShaderEntries().samplers;
977 978
@@ -998,7 +999,7 @@ void RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, const Shader& s
998} 999}
999 1000
1000void RasterizerOpenGL::SyncViewport(OpenGLState& current_state) { 1001void RasterizerOpenGL::SyncViewport(OpenGLState& current_state) {
1001 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1002 const auto& regs = system.GPU().Maxwell3D().regs;
1002 const bool geometry_shaders_enabled = 1003 const bool geometry_shaders_enabled =
1003 regs.IsShaderConfigEnabled(static_cast<size_t>(Maxwell::ShaderProgram::Geometry)); 1004 regs.IsShaderConfigEnabled(static_cast<size_t>(Maxwell::ShaderProgram::Geometry));
1004 const std::size_t viewport_count = 1005 const std::size_t viewport_count =
@@ -1021,7 +1022,7 @@ void RasterizerOpenGL::SyncViewport(OpenGLState& current_state) {
1021void RasterizerOpenGL::SyncClipEnabled( 1022void RasterizerOpenGL::SyncClipEnabled(
1022 const std::array<bool, Maxwell::Regs::NumClipDistances>& clip_mask) { 1023 const std::array<bool, Maxwell::Regs::NumClipDistances>& clip_mask) {
1023 1024
1024 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1025 const auto& regs = system.GPU().Maxwell3D().regs;
1025 const std::array<bool, Maxwell::Regs::NumClipDistances> reg_state{ 1026 const std::array<bool, Maxwell::Regs::NumClipDistances> reg_state{
1026 regs.clip_distance_enabled.c0 != 0, regs.clip_distance_enabled.c1 != 0, 1027 regs.clip_distance_enabled.c0 != 0, regs.clip_distance_enabled.c1 != 0,
1027 regs.clip_distance_enabled.c2 != 0, regs.clip_distance_enabled.c3 != 0, 1028 regs.clip_distance_enabled.c2 != 0, regs.clip_distance_enabled.c3 != 0,
@@ -1038,7 +1039,7 @@ void RasterizerOpenGL::SyncClipCoef() {
1038} 1039}
1039 1040
1040void RasterizerOpenGL::SyncCullMode() { 1041void RasterizerOpenGL::SyncCullMode() {
1041 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1042 const auto& regs = system.GPU().Maxwell3D().regs;
1042 1043
1043 state.cull.enabled = regs.cull.enabled != 0; 1044 state.cull.enabled = regs.cull.enabled != 0;
1044 1045
@@ -1062,14 +1063,14 @@ void RasterizerOpenGL::SyncCullMode() {
1062} 1063}
1063 1064
1064void RasterizerOpenGL::SyncPrimitiveRestart() { 1065void RasterizerOpenGL::SyncPrimitiveRestart() {
1065 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1066 const auto& regs = system.GPU().Maxwell3D().regs;
1066 1067
1067 state.primitive_restart.enabled = regs.primitive_restart.enabled; 1068 state.primitive_restart.enabled = regs.primitive_restart.enabled;
1068 state.primitive_restart.index = regs.primitive_restart.index; 1069 state.primitive_restart.index = regs.primitive_restart.index;
1069} 1070}
1070 1071
1071void RasterizerOpenGL::SyncDepthTestState() { 1072void RasterizerOpenGL::SyncDepthTestState() {
1072 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1073 const auto& regs = system.GPU().Maxwell3D().regs;
1073 1074
1074 state.depth.test_enabled = regs.depth_test_enable != 0; 1075 state.depth.test_enabled = regs.depth_test_enable != 0;
1075 state.depth.write_mask = regs.depth_write_enabled ? GL_TRUE : GL_FALSE; 1076 state.depth.write_mask = regs.depth_write_enabled ? GL_TRUE : GL_FALSE;
@@ -1081,7 +1082,7 @@ void RasterizerOpenGL::SyncDepthTestState() {
1081} 1082}
1082 1083
1083void RasterizerOpenGL::SyncStencilTestState() { 1084void RasterizerOpenGL::SyncStencilTestState() {
1084 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1085 const auto& regs = system.GPU().Maxwell3D().regs;
1085 state.stencil.test_enabled = regs.stencil_enable != 0; 1086 state.stencil.test_enabled = regs.stencil_enable != 0;
1086 1087
1087 if (!regs.stencil_enable) { 1088 if (!regs.stencil_enable) {
@@ -1115,7 +1116,7 @@ void RasterizerOpenGL::SyncStencilTestState() {
1115} 1116}
1116 1117
1117void RasterizerOpenGL::SyncColorMask() { 1118void RasterizerOpenGL::SyncColorMask() {
1118 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1119 const auto& regs = system.GPU().Maxwell3D().regs;
1119 const std::size_t count = 1120 const std::size_t count =
1120 regs.independent_blend_enable ? Tegra::Engines::Maxwell3D::Regs::NumRenderTargets : 1; 1121 regs.independent_blend_enable ? Tegra::Engines::Maxwell3D::Regs::NumRenderTargets : 1;
1121 for (std::size_t i = 0; i < count; i++) { 1122 for (std::size_t i = 0; i < count; i++) {
@@ -1129,18 +1130,18 @@ void RasterizerOpenGL::SyncColorMask() {
1129} 1130}
1130 1131
1131void RasterizerOpenGL::SyncMultiSampleState() { 1132void RasterizerOpenGL::SyncMultiSampleState() {
1132 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1133 const auto& regs = system.GPU().Maxwell3D().regs;
1133 state.multisample_control.alpha_to_coverage = regs.multisample_control.alpha_to_coverage != 0; 1134 state.multisample_control.alpha_to_coverage = regs.multisample_control.alpha_to_coverage != 0;
1134 state.multisample_control.alpha_to_one = regs.multisample_control.alpha_to_one != 0; 1135 state.multisample_control.alpha_to_one = regs.multisample_control.alpha_to_one != 0;
1135} 1136}
1136 1137
1137void RasterizerOpenGL::SyncFragmentColorClampState() { 1138void RasterizerOpenGL::SyncFragmentColorClampState() {
1138 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1139 const auto& regs = system.GPU().Maxwell3D().regs;
1139 state.fragment_color_clamp.enabled = regs.frag_color_clamp != 0; 1140 state.fragment_color_clamp.enabled = regs.frag_color_clamp != 0;
1140} 1141}
1141 1142
1142void RasterizerOpenGL::SyncBlendState() { 1143void RasterizerOpenGL::SyncBlendState() {
1143 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1144 const auto& regs = system.GPU().Maxwell3D().regs;
1144 1145
1145 state.blend_color.red = regs.blend_color.r; 1146 state.blend_color.red = regs.blend_color.r;
1146 state.blend_color.green = regs.blend_color.g; 1147 state.blend_color.green = regs.blend_color.g;
@@ -1182,7 +1183,7 @@ void RasterizerOpenGL::SyncBlendState() {
1182} 1183}
1183 1184
1184void RasterizerOpenGL::SyncLogicOpState() { 1185void RasterizerOpenGL::SyncLogicOpState() {
1185 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1186 const auto& regs = system.GPU().Maxwell3D().regs;
1186 1187
1187 state.logic_op.enabled = regs.logic_op.enable != 0; 1188 state.logic_op.enabled = regs.logic_op.enable != 0;
1188 1189
@@ -1196,7 +1197,7 @@ void RasterizerOpenGL::SyncLogicOpState() {
1196} 1197}
1197 1198
1198void RasterizerOpenGL::SyncScissorTest(OpenGLState& current_state) { 1199void RasterizerOpenGL::SyncScissorTest(OpenGLState& current_state) {
1199 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1200 const auto& regs = system.GPU().Maxwell3D().regs;
1200 const bool geometry_shaders_enabled = 1201 const bool geometry_shaders_enabled =
1201 regs.IsShaderConfigEnabled(static_cast<size_t>(Maxwell::ShaderProgram::Geometry)); 1202 regs.IsShaderConfigEnabled(static_cast<size_t>(Maxwell::ShaderProgram::Geometry));
1202 const std::size_t viewport_count = 1203 const std::size_t viewport_count =
@@ -1218,17 +1219,17 @@ void RasterizerOpenGL::SyncScissorTest(OpenGLState& current_state) {
1218} 1219}
1219 1220
1220void RasterizerOpenGL::SyncTransformFeedback() { 1221void RasterizerOpenGL::SyncTransformFeedback() {
1221 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1222 const auto& regs = system.GPU().Maxwell3D().regs;
1222 UNIMPLEMENTED_IF_MSG(regs.tfb_enabled != 0, "Transform feedbacks are not implemented"); 1223 UNIMPLEMENTED_IF_MSG(regs.tfb_enabled != 0, "Transform feedbacks are not implemented");
1223} 1224}
1224 1225
1225void RasterizerOpenGL::SyncPointState() { 1226void RasterizerOpenGL::SyncPointState() {
1226 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1227 const auto& regs = system.GPU().Maxwell3D().regs;
1227 state.point.size = regs.point_size; 1228 state.point.size = regs.point_size;
1228} 1229}
1229 1230
1230void RasterizerOpenGL::SyncPolygonOffset() { 1231void RasterizerOpenGL::SyncPolygonOffset() {
1231 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1232 const auto& regs = system.GPU().Maxwell3D().regs;
1232 state.polygon_offset.fill_enable = regs.polygon_offset_fill_enable != 0; 1233 state.polygon_offset.fill_enable = regs.polygon_offset_fill_enable != 0;
1233 state.polygon_offset.line_enable = regs.polygon_offset_line_enable != 0; 1234 state.polygon_offset.line_enable = regs.polygon_offset_line_enable != 0;
1234 state.polygon_offset.point_enable = regs.polygon_offset_point_enable != 0; 1235 state.polygon_offset.point_enable = regs.polygon_offset_point_enable != 0;
@@ -1238,7 +1239,7 @@ void RasterizerOpenGL::SyncPolygonOffset() {
1238} 1239}
1239 1240
1240void RasterizerOpenGL::CheckAlphaTests() { 1241void RasterizerOpenGL::CheckAlphaTests() {
1241 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1242 const auto& regs = system.GPU().Maxwell3D().regs;
1242 UNIMPLEMENTED_IF_MSG(regs.alpha_test_enabled != 0 && regs.rt_control.count > 1, 1243 UNIMPLEMENTED_IF_MSG(regs.alpha_test_enabled != 0 && regs.rt_control.count > 1,
1243 "Alpha Testing is enabled with more than one rendertarget"); 1244 "Alpha Testing is enabled with more than one rendertarget");
1244} 1245}
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h
index 7e63f8008..ca3de0592 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer.h
@@ -215,6 +215,7 @@ private:
215 GlobalRegionCacheOpenGL global_cache; 215 GlobalRegionCacheOpenGL global_cache;
216 216
217 Core::Frontend::EmuWindow& emu_window; 217 Core::Frontend::EmuWindow& emu_window;
218 Core::System& system;
218 219
219 ScreenInfo& screen_info; 220 ScreenInfo& screen_info;
220 221