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 301562ff6..bf03db102 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);
@@ -909,7 +910,7 @@ void RasterizerOpenGL::SetupConstBuffers(Tegra::Engines::Maxwell3D::Regs::Shader
909 const Shader& shader, GLuint program_handle, 910 const Shader& shader, GLuint program_handle,
910 BaseBindings base_bindings) { 911 BaseBindings base_bindings) {
911 MICROPROFILE_SCOPE(OpenGL_UBO); 912 MICROPROFILE_SCOPE(OpenGL_UBO);
912 const auto& gpu = Core::System::GetInstance().GPU(); 913 const auto& gpu = system.GPU();
913 const auto& maxwell3d = gpu.Maxwell3D(); 914 const auto& maxwell3d = gpu.Maxwell3D();
914 const auto& shader_stage = maxwell3d.state.shader_stages[static_cast<std::size_t>(stage)]; 915 const auto& shader_stage = maxwell3d.state.shader_stages[static_cast<std::size_t>(stage)];
915 const auto& entries = shader->GetShaderEntries().const_buffers; 916 const auto& entries = shader->GetShaderEntries().const_buffers;
@@ -988,7 +989,7 @@ void RasterizerOpenGL::SetupGlobalRegions(Tegra::Engines::Maxwell3D::Regs::Shade
988void RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, const Shader& shader, 989void RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, const Shader& shader,
989 GLuint program_handle, BaseBindings base_bindings) { 990 GLuint program_handle, BaseBindings base_bindings) {
990 MICROPROFILE_SCOPE(OpenGL_Texture); 991 MICROPROFILE_SCOPE(OpenGL_Texture);
991 const auto& gpu = Core::System::GetInstance().GPU(); 992 const auto& gpu = system.GPU();
992 const auto& maxwell3d = gpu.Maxwell3D(); 993 const auto& maxwell3d = gpu.Maxwell3D();
993 const auto& entries = shader->GetShaderEntries().samplers; 994 const auto& entries = shader->GetShaderEntries().samplers;
994 995
@@ -1015,7 +1016,7 @@ void RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, const Shader& s
1015} 1016}
1016 1017
1017void RasterizerOpenGL::SyncViewport(OpenGLState& current_state) { 1018void RasterizerOpenGL::SyncViewport(OpenGLState& current_state) {
1018 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1019 const auto& regs = system.GPU().Maxwell3D().regs;
1019 const bool geometry_shaders_enabled = 1020 const bool geometry_shaders_enabled =
1020 regs.IsShaderConfigEnabled(static_cast<size_t>(Maxwell::ShaderProgram::Geometry)); 1021 regs.IsShaderConfigEnabled(static_cast<size_t>(Maxwell::ShaderProgram::Geometry));
1021 const std::size_t viewport_count = 1022 const std::size_t viewport_count =
@@ -1038,7 +1039,7 @@ void RasterizerOpenGL::SyncViewport(OpenGLState& current_state) {
1038void RasterizerOpenGL::SyncClipEnabled( 1039void RasterizerOpenGL::SyncClipEnabled(
1039 const std::array<bool, Maxwell::Regs::NumClipDistances>& clip_mask) { 1040 const std::array<bool, Maxwell::Regs::NumClipDistances>& clip_mask) {
1040 1041
1041 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1042 const auto& regs = system.GPU().Maxwell3D().regs;
1042 const std::array<bool, Maxwell::Regs::NumClipDistances> reg_state{ 1043 const std::array<bool, Maxwell::Regs::NumClipDistances> reg_state{
1043 regs.clip_distance_enabled.c0 != 0, regs.clip_distance_enabled.c1 != 0, 1044 regs.clip_distance_enabled.c0 != 0, regs.clip_distance_enabled.c1 != 0,
1044 regs.clip_distance_enabled.c2 != 0, regs.clip_distance_enabled.c3 != 0, 1045 regs.clip_distance_enabled.c2 != 0, regs.clip_distance_enabled.c3 != 0,
@@ -1055,7 +1056,7 @@ void RasterizerOpenGL::SyncClipCoef() {
1055} 1056}
1056 1057
1057void RasterizerOpenGL::SyncCullMode() { 1058void RasterizerOpenGL::SyncCullMode() {
1058 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1059 const auto& regs = system.GPU().Maxwell3D().regs;
1059 1060
1060 state.cull.enabled = regs.cull.enabled != 0; 1061 state.cull.enabled = regs.cull.enabled != 0;
1061 1062
@@ -1079,14 +1080,14 @@ void RasterizerOpenGL::SyncCullMode() {
1079} 1080}
1080 1081
1081void RasterizerOpenGL::SyncPrimitiveRestart() { 1082void RasterizerOpenGL::SyncPrimitiveRestart() {
1082 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1083 const auto& regs = system.GPU().Maxwell3D().regs;
1083 1084
1084 state.primitive_restart.enabled = regs.primitive_restart.enabled; 1085 state.primitive_restart.enabled = regs.primitive_restart.enabled;
1085 state.primitive_restart.index = regs.primitive_restart.index; 1086 state.primitive_restart.index = regs.primitive_restart.index;
1086} 1087}
1087 1088
1088void RasterizerOpenGL::SyncDepthTestState() { 1089void RasterizerOpenGL::SyncDepthTestState() {
1089 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1090 const auto& regs = system.GPU().Maxwell3D().regs;
1090 1091
1091 state.depth.test_enabled = regs.depth_test_enable != 0; 1092 state.depth.test_enabled = regs.depth_test_enable != 0;
1092 state.depth.write_mask = regs.depth_write_enabled ? GL_TRUE : GL_FALSE; 1093 state.depth.write_mask = regs.depth_write_enabled ? GL_TRUE : GL_FALSE;
@@ -1098,7 +1099,7 @@ void RasterizerOpenGL::SyncDepthTestState() {
1098} 1099}
1099 1100
1100void RasterizerOpenGL::SyncStencilTestState() { 1101void RasterizerOpenGL::SyncStencilTestState() {
1101 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1102 const auto& regs = system.GPU().Maxwell3D().regs;
1102 state.stencil.test_enabled = regs.stencil_enable != 0; 1103 state.stencil.test_enabled = regs.stencil_enable != 0;
1103 1104
1104 if (!regs.stencil_enable) { 1105 if (!regs.stencil_enable) {
@@ -1132,7 +1133,7 @@ void RasterizerOpenGL::SyncStencilTestState() {
1132} 1133}
1133 1134
1134void RasterizerOpenGL::SyncColorMask() { 1135void RasterizerOpenGL::SyncColorMask() {
1135 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1136 const auto& regs = system.GPU().Maxwell3D().regs;
1136 const std::size_t count = 1137 const std::size_t count =
1137 regs.independent_blend_enable ? Tegra::Engines::Maxwell3D::Regs::NumRenderTargets : 1; 1138 regs.independent_blend_enable ? Tegra::Engines::Maxwell3D::Regs::NumRenderTargets : 1;
1138 for (std::size_t i = 0; i < count; i++) { 1139 for (std::size_t i = 0; i < count; i++) {
@@ -1146,18 +1147,18 @@ void RasterizerOpenGL::SyncColorMask() {
1146} 1147}
1147 1148
1148void RasterizerOpenGL::SyncMultiSampleState() { 1149void RasterizerOpenGL::SyncMultiSampleState() {
1149 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1150 const auto& regs = system.GPU().Maxwell3D().regs;
1150 state.multisample_control.alpha_to_coverage = regs.multisample_control.alpha_to_coverage != 0; 1151 state.multisample_control.alpha_to_coverage = regs.multisample_control.alpha_to_coverage != 0;
1151 state.multisample_control.alpha_to_one = regs.multisample_control.alpha_to_one != 0; 1152 state.multisample_control.alpha_to_one = regs.multisample_control.alpha_to_one != 0;
1152} 1153}
1153 1154
1154void RasterizerOpenGL::SyncFragmentColorClampState() { 1155void RasterizerOpenGL::SyncFragmentColorClampState() {
1155 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1156 const auto& regs = system.GPU().Maxwell3D().regs;
1156 state.fragment_color_clamp.enabled = regs.frag_color_clamp != 0; 1157 state.fragment_color_clamp.enabled = regs.frag_color_clamp != 0;
1157} 1158}
1158 1159
1159void RasterizerOpenGL::SyncBlendState() { 1160void RasterizerOpenGL::SyncBlendState() {
1160 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1161 const auto& regs = system.GPU().Maxwell3D().regs;
1161 1162
1162 state.blend_color.red = regs.blend_color.r; 1163 state.blend_color.red = regs.blend_color.r;
1163 state.blend_color.green = regs.blend_color.g; 1164 state.blend_color.green = regs.blend_color.g;
@@ -1199,7 +1200,7 @@ void RasterizerOpenGL::SyncBlendState() {
1199} 1200}
1200 1201
1201void RasterizerOpenGL::SyncLogicOpState() { 1202void RasterizerOpenGL::SyncLogicOpState() {
1202 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1203 const auto& regs = system.GPU().Maxwell3D().regs;
1203 1204
1204 state.logic_op.enabled = regs.logic_op.enable != 0; 1205 state.logic_op.enabled = regs.logic_op.enable != 0;
1205 1206
@@ -1213,7 +1214,7 @@ void RasterizerOpenGL::SyncLogicOpState() {
1213} 1214}
1214 1215
1215void RasterizerOpenGL::SyncScissorTest(OpenGLState& current_state) { 1216void RasterizerOpenGL::SyncScissorTest(OpenGLState& current_state) {
1216 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1217 const auto& regs = system.GPU().Maxwell3D().regs;
1217 const bool geometry_shaders_enabled = 1218 const bool geometry_shaders_enabled =
1218 regs.IsShaderConfigEnabled(static_cast<size_t>(Maxwell::ShaderProgram::Geometry)); 1219 regs.IsShaderConfigEnabled(static_cast<size_t>(Maxwell::ShaderProgram::Geometry));
1219 const std::size_t viewport_count = 1220 const std::size_t viewport_count =
@@ -1235,17 +1236,17 @@ void RasterizerOpenGL::SyncScissorTest(OpenGLState& current_state) {
1235} 1236}
1236 1237
1237void RasterizerOpenGL::SyncTransformFeedback() { 1238void RasterizerOpenGL::SyncTransformFeedback() {
1238 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1239 const auto& regs = system.GPU().Maxwell3D().regs;
1239 UNIMPLEMENTED_IF_MSG(regs.tfb_enabled != 0, "Transform feedbacks are not implemented"); 1240 UNIMPLEMENTED_IF_MSG(regs.tfb_enabled != 0, "Transform feedbacks are not implemented");
1240} 1241}
1241 1242
1242void RasterizerOpenGL::SyncPointState() { 1243void RasterizerOpenGL::SyncPointState() {
1243 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1244 const auto& regs = system.GPU().Maxwell3D().regs;
1244 state.point.size = regs.point_size; 1245 state.point.size = regs.point_size;
1245} 1246}
1246 1247
1247void RasterizerOpenGL::SyncPolygonOffset() { 1248void RasterizerOpenGL::SyncPolygonOffset() {
1248 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1249 const auto& regs = system.GPU().Maxwell3D().regs;
1249 state.polygon_offset.fill_enable = regs.polygon_offset_fill_enable != 0; 1250 state.polygon_offset.fill_enable = regs.polygon_offset_fill_enable != 0;
1250 state.polygon_offset.line_enable = regs.polygon_offset_line_enable != 0; 1251 state.polygon_offset.line_enable = regs.polygon_offset_line_enable != 0;
1251 state.polygon_offset.point_enable = regs.polygon_offset_point_enable != 0; 1252 state.polygon_offset.point_enable = regs.polygon_offset_point_enable != 0;
@@ -1255,7 +1256,7 @@ void RasterizerOpenGL::SyncPolygonOffset() {
1255} 1256}
1256 1257
1257void RasterizerOpenGL::CheckAlphaTests() { 1258void RasterizerOpenGL::CheckAlphaTests() {
1258 const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; 1259 const auto& regs = system.GPU().Maxwell3D().regs;
1259 UNIMPLEMENTED_IF_MSG(regs.alpha_test_enabled != 0 && regs.rt_control.count > 1, 1260 UNIMPLEMENTED_IF_MSG(regs.alpha_test_enabled != 0 && regs.rt_control.count > 1,
1260 "Alpha Testing is enabled with more than one rendertarget"); 1261 "Alpha Testing is enabled with more than one rendertarget");
1261} 1262}
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h
index 2f0524f85..e566fe8a1 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer.h
@@ -214,6 +214,7 @@ private:
214 GlobalRegionCacheOpenGL global_cache; 214 GlobalRegionCacheOpenGL global_cache;
215 215
216 Core::Frontend::EmuWindow& emu_window; 216 Core::Frontend::EmuWindow& emu_window;
217 Core::System& system;
217 218
218 ScreenInfo& screen_info; 219 ScreenInfo& screen_info;
219 220