summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video_core/engines/maxwell_3d.h10
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp16
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.h4
-rw-r--r--src/video_core/renderer_opengl/gl_state.cpp32
-rw-r--r--src/video_core/renderer_opengl/gl_state.h6
5 files changed, 58 insertions, 10 deletions
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h
index 84471f181..2e896e5f2 100644
--- a/src/video_core/engines/maxwell_3d.h
+++ b/src/video_core/engines/maxwell_3d.h
@@ -902,8 +902,15 @@ public:
902 902
903 u32 viewport_transform_enabled; 903 u32 viewport_transform_enabled;
904 904
905 INSERT_PADDING_WORDS(0x25); 905 INSERT_PADDING_WORDS(0x3);
906
907 union {
908 BitField<0, 1, u32> depth_range_0_1;
909 BitField<3, 1, u32> depth_clamp_near;
910 BitField<4, 1, u32> depth_clamp_far;
911 } view_volume_clip_control;
906 912
913 INSERT_PADDING_WORDS(0x21);
907 struct { 914 struct {
908 u32 enable; 915 u32 enable;
909 LogicOperation operation; 916 LogicOperation operation;
@@ -1224,6 +1231,7 @@ ASSERT_REG_POSITION(instanced_arrays, 0x620);
1224ASSERT_REG_POSITION(cull, 0x646); 1231ASSERT_REG_POSITION(cull, 0x646);
1225ASSERT_REG_POSITION(pixel_center_integer, 0x649); 1232ASSERT_REG_POSITION(pixel_center_integer, 0x649);
1226ASSERT_REG_POSITION(viewport_transform_enabled, 0x64B); 1233ASSERT_REG_POSITION(viewport_transform_enabled, 0x64B);
1234ASSERT_REG_POSITION(view_volume_clip_control, 0x64F);
1227ASSERT_REG_POSITION(logic_op, 0x671); 1235ASSERT_REG_POSITION(logic_op, 0x671);
1228ASSERT_REG_POSITION(clear_buffers, 0x674); 1236ASSERT_REG_POSITION(clear_buffers, 0x674);
1229ASSERT_REG_POSITION(color_mask, 0x680); 1237ASSERT_REG_POSITION(color_mask, 0x680);
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 82b7a0649..5c8fe002b 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -113,10 +113,24 @@ RasterizerOpenGL::RasterizerOpenGL(Core::Frontend::EmuWindow& window, ScreenInfo
113 glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &uniform_buffer_alignment); 113 glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &uniform_buffer_alignment);
114 114
115 LOG_CRITICAL(Render_OpenGL, "Sync fixed function OpenGL state here!"); 115 LOG_CRITICAL(Render_OpenGL, "Sync fixed function OpenGL state here!");
116 CheckExtensions();
116} 117}
117 118
118RasterizerOpenGL::~RasterizerOpenGL() {} 119RasterizerOpenGL::~RasterizerOpenGL() {}
119 120
121void RasterizerOpenGL::CheckExtensions() {
122 if (!GLAD_GL_ARB_texture_filter_anisotropic && !GLAD_GL_EXT_texture_filter_anisotropic) {
123 LOG_WARNING(
124 Render_OpenGL,
125 "Anisotropic filter is not supported! This can cause graphical issues in some games.");
126 }
127 if (!GLAD_GL_ARB_buffer_storage) {
128 LOG_WARNING(
129 Render_OpenGL,
130 "Buffer storage control is not supported! This can cause performance degradation.");
131 }
132}
133
120void RasterizerOpenGL::SetupVertexFormat() { 134void RasterizerOpenGL::SetupVertexFormat() {
121 auto& gpu = Core::System::GetInstance().GPU().Maxwell3D(); 135 auto& gpu = Core::System::GetInstance().GPU().Maxwell3D();
122 const auto& regs = gpu.regs; 136 const auto& regs = gpu.regs;
@@ -1007,6 +1021,8 @@ void RasterizerOpenGL::SyncViewport(OpenGLState& current_state) {
1007 viewport.depth_range_far = regs.viewports[i].depth_range_far; 1021 viewport.depth_range_far = regs.viewports[i].depth_range_far;
1008 viewport.depth_range_near = regs.viewports[i].depth_range_near; 1022 viewport.depth_range_near = regs.viewports[i].depth_range_near;
1009 } 1023 }
1024 state.depth_clamp.far_plane = regs.view_volume_clip_control.depth_clamp_far != 0;
1025 state.depth_clamp.near_plane = regs.view_volume_clip_control.depth_clamp_near != 0;
1010} 1026}
1011 1027
1012void RasterizerOpenGL::SyncClipEnabled() { 1028void RasterizerOpenGL::SyncClipEnabled() {
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h
index dfb4616f2..7ec9746b1 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer.h
@@ -189,6 +189,10 @@ private:
189 /// Check asserts for alpha testing. 189 /// Check asserts for alpha testing.
190 void CheckAlphaTests(); 190 void CheckAlphaTests();
191 191
192 /// Check for extension that are not strictly required
193 /// but are needed for correct emulation
194 void CheckExtensions();
195
192 bool has_ARB_direct_state_access = false; 196 bool has_ARB_direct_state_access = false;
193 bool has_ARB_multi_bind = false; 197 bool has_ARB_multi_bind = false;
194 198
diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp
index b3bfad6a0..dc0a5ed5e 100644
--- a/src/video_core/renderer_opengl/gl_state.cpp
+++ b/src/video_core/renderer_opengl/gl_state.cpp
@@ -92,7 +92,8 @@ OpenGLState::OpenGLState() {
92 92
93 point.size = 1; 93 point.size = 1;
94 fragment_color_clamp.enabled = false; 94 fragment_color_clamp.enabled = false;
95 95 depth_clamp.far_plane = false;
96 depth_clamp.near_plane = false;
96 polygon_offset.fill_enable = false; 97 polygon_offset.fill_enable = false;
97 polygon_offset.line_enable = false; 98 polygon_offset.line_enable = false;
98 polygon_offset.point_enable = false; 99 polygon_offset.point_enable = false;
@@ -147,7 +148,7 @@ void OpenGLState::ApplyCulling() const {
147} 148}
148 149
149void OpenGLState::ApplyColorMask() const { 150void OpenGLState::ApplyColorMask() const {
150 if (GLAD_GL_ARB_viewport_array && independant_blend.enabled) { 151 if (independant_blend.enabled) {
151 for (size_t i = 0; i < Tegra::Engines::Maxwell3D::Regs::NumRenderTargets; i++) { 152 for (size_t i = 0; i < Tegra::Engines::Maxwell3D::Regs::NumRenderTargets; i++) {
152 const auto& updated = color_mask[i]; 153 const auto& updated = color_mask[i];
153 const auto& current = cur_state.color_mask[i]; 154 const auto& current = cur_state.color_mask[i];
@@ -264,7 +265,7 @@ void OpenGLState::EmulateViewportWithScissor() {
264} 265}
265 266
266void OpenGLState::ApplyViewport() const { 267void OpenGLState::ApplyViewport() const {
267 if (GLAD_GL_ARB_viewport_array && geometry_shaders.enabled) { 268 if (geometry_shaders.enabled) {
268 for (GLuint i = 0; i < static_cast<GLuint>(Tegra::Engines::Maxwell3D::Regs::NumViewports); 269 for (GLuint i = 0; i < static_cast<GLuint>(Tegra::Engines::Maxwell3D::Regs::NumViewports);
269 i++) { 270 i++) {
270 const auto& current = cur_state.viewports[i]; 271 const auto& current = cur_state.viewports[i];
@@ -525,6 +526,21 @@ void OpenGLState::ApplyVertexBufferState() const {
525 } 526 }
526} 527}
527 528
529void OpenGLState::ApplyDepthClamp() const {
530 if (depth_clamp.far_plane == cur_state.depth_clamp.far_plane &&
531 depth_clamp.near_plane == cur_state.depth_clamp.near_plane) {
532 return;
533 }
534 if (depth_clamp.far_plane != depth_clamp.near_plane) {
535 UNIMPLEMENTED_MSG("Unimplemented Depth Clamp Separation!");
536 }
537 if (depth_clamp.far_plane || depth_clamp.near_plane) {
538 glEnable(GL_DEPTH_CLAMP);
539 } else {
540 glDisable(GL_DEPTH_CLAMP);
541 }
542}
543
528void OpenGLState::Apply() const { 544void OpenGLState::Apply() const {
529 ApplyFramebufferState(); 545 ApplyFramebufferState();
530 ApplyVertexBufferState(); 546 ApplyVertexBufferState();
@@ -556,11 +572,9 @@ void OpenGLState::Apply() const {
556 if (point.size != cur_state.point.size) { 572 if (point.size != cur_state.point.size) {
557 glPointSize(point.size); 573 glPointSize(point.size);
558 } 574 }
559 if (GLAD_GL_ARB_color_buffer_float) { 575 if (fragment_color_clamp.enabled != cur_state.fragment_color_clamp.enabled) {
560 if (fragment_color_clamp.enabled != cur_state.fragment_color_clamp.enabled) { 576 glClampColor(GL_CLAMP_FRAGMENT_COLOR_ARB,
561 glClampColor(GL_CLAMP_FRAGMENT_COLOR_ARB, 577 fragment_color_clamp.enabled ? GL_TRUE : GL_FALSE);
562 fragment_color_clamp.enabled ? GL_TRUE : GL_FALSE);
563 }
564 } 578 }
565 if (multisample_control.alpha_to_coverage != cur_state.multisample_control.alpha_to_coverage) { 579 if (multisample_control.alpha_to_coverage != cur_state.multisample_control.alpha_to_coverage) {
566 if (multisample_control.alpha_to_coverage) { 580 if (multisample_control.alpha_to_coverage) {
@@ -576,7 +590,7 @@ void OpenGLState::Apply() const {
576 glDisable(GL_SAMPLE_ALPHA_TO_ONE); 590 glDisable(GL_SAMPLE_ALPHA_TO_ONE);
577 } 591 }
578 } 592 }
579 593 ApplyDepthClamp();
580 ApplyColorMask(); 594 ApplyColorMask();
581 ApplyViewport(); 595 ApplyViewport();
582 ApplyStencilTest(); 596 ApplyStencilTest();
diff --git a/src/video_core/renderer_opengl/gl_state.h b/src/video_core/renderer_opengl/gl_state.h
index 0bf19ed07..a486d1654 100644
--- a/src/video_core/renderer_opengl/gl_state.h
+++ b/src/video_core/renderer_opengl/gl_state.h
@@ -49,6 +49,11 @@ public:
49 } fragment_color_clamp; 49 } fragment_color_clamp;
50 50
51 struct { 51 struct {
52 bool far_plane;
53 bool near_plane;
54 } depth_clamp; // GL_DEPTH_CLAMP
55
56 struct {
52 bool enabled; // viewports arrays are only supported when geometry shaders are enabled. 57 bool enabled; // viewports arrays are only supported when geometry shaders are enabled.
53 } geometry_shaders; 58 } geometry_shaders;
54 59
@@ -235,6 +240,7 @@ private:
235 void ApplyLogicOp() const; 240 void ApplyLogicOp() const;
236 void ApplyTextures() const; 241 void ApplyTextures() const;
237 void ApplySamplers() const; 242 void ApplySamplers() const;
243 void ApplyDepthClamp() const;
238 void ApplyPolygonOffset() const; 244 void ApplyPolygonOffset() const;
239}; 245};
240 246