diff options
| -rw-r--r-- | src/video_core/engines/maxwell_3d.h | 1 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.h | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_manager.h | 3 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_state.cpp | 24 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_state.h | 3 |
5 files changed, 25 insertions, 8 deletions
diff --git a/src/video_core/engines/maxwell_3d.h b/src/video_core/engines/maxwell_3d.h index 16cdfc7e2..cd26c7216 100644 --- a/src/video_core/engines/maxwell_3d.h +++ b/src/video_core/engines/maxwell_3d.h | |||
| @@ -41,6 +41,7 @@ public: | |||
| 41 | static constexpr std::size_t NumCBData = 16; | 41 | static constexpr std::size_t NumCBData = 16; |
| 42 | static constexpr std::size_t NumVertexArrays = 32; | 42 | static constexpr std::size_t NumVertexArrays = 32; |
| 43 | static constexpr std::size_t NumVertexAttributes = 32; | 43 | static constexpr std::size_t NumVertexAttributes = 32; |
| 44 | static constexpr std::size_t NumTextureSamplers = 32; | ||
| 44 | static constexpr std::size_t MaxShaderProgram = 6; | 45 | static constexpr std::size_t MaxShaderProgram = 6; |
| 45 | static constexpr std::size_t MaxShaderStage = 5; | 46 | static constexpr std::size_t MaxShaderStage = 5; |
| 46 | // Maximum number of const buffers per shader stage. | 47 | // Maximum number of const buffers per shader stage. |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index c3f1e14bf..b64c93b81 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h | |||
| @@ -184,7 +184,7 @@ private: | |||
| 184 | OGLVertexArray> | 184 | OGLVertexArray> |
| 185 | vertex_array_cache; | 185 | vertex_array_cache; |
| 186 | 186 | ||
| 187 | std::array<SamplerInfo, GLShader::NumTextureSamplers> texture_samplers; | 187 | std::array<SamplerInfo, Tegra::Engines::Maxwell3D::Regs::NumTextureSamplers> texture_samplers; |
| 188 | 188 | ||
| 189 | static constexpr std::size_t STREAM_BUFFER_SIZE = 128 * 1024 * 1024; | 189 | static constexpr std::size_t STREAM_BUFFER_SIZE = 128 * 1024 * 1024; |
| 190 | OGLBufferCache buffer_cache; | 190 | OGLBufferCache buffer_cache; |
diff --git a/src/video_core/renderer_opengl/gl_shader_manager.h b/src/video_core/renderer_opengl/gl_shader_manager.h index b86cd96e8..3de15ba9b 100644 --- a/src/video_core/renderer_opengl/gl_shader_manager.h +++ b/src/video_core/renderer_opengl/gl_shader_manager.h | |||
| @@ -11,9 +11,6 @@ | |||
| 11 | 11 | ||
| 12 | namespace OpenGL::GLShader { | 12 | namespace OpenGL::GLShader { |
| 13 | 13 | ||
| 14 | /// Number of OpenGL texture samplers that can be used in the fragment shader | ||
| 15 | static constexpr std::size_t NumTextureSamplers = 32; | ||
| 16 | |||
| 17 | using Tegra::Engines::Maxwell3D; | 14 | using Tegra::Engines::Maxwell3D; |
| 18 | 15 | ||
| 19 | /// Uniform structure for the Uniform Buffer Object, all vectors must be 16-byte aligned | 16 | /// Uniform structure for the Uniform Buffer Object, all vectors must be 16-byte aligned |
diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp index e5173e20a..e494b3f16 100644 --- a/src/video_core/renderer_opengl/gl_state.cpp +++ b/src/video_core/renderer_opengl/gl_state.cpp | |||
| @@ -205,9 +205,6 @@ void OpenGLState::Apply() const { | |||
| 205 | glActiveTexture(TextureUnits::MaxwellTexture(static_cast<int>(i)).Enum()); | 205 | glActiveTexture(TextureUnits::MaxwellTexture(static_cast<int>(i)).Enum()); |
| 206 | glBindTexture(texture_unit.target, texture_unit.texture); | 206 | glBindTexture(texture_unit.target, texture_unit.texture); |
| 207 | } | 207 | } |
| 208 | if (texture_unit.sampler != cur_state_texture_unit.sampler) { | ||
| 209 | glBindSampler(static_cast<GLuint>(i), texture_unit.sampler); | ||
| 210 | } | ||
| 211 | // Update the texture swizzle | 208 | // Update the texture swizzle |
| 212 | if (texture_unit.swizzle.r != cur_state_texture_unit.swizzle.r || | 209 | if (texture_unit.swizzle.r != cur_state_texture_unit.swizzle.r || |
| 213 | texture_unit.swizzle.g != cur_state_texture_unit.swizzle.g || | 210 | texture_unit.swizzle.g != cur_state_texture_unit.swizzle.g || |
| @@ -219,6 +216,27 @@ void OpenGLState::Apply() const { | |||
| 219 | } | 216 | } |
| 220 | } | 217 | } |
| 221 | 218 | ||
| 219 | // Samplers | ||
| 220 | { | ||
| 221 | bool has_delta{}; | ||
| 222 | std::size_t first{}, last{}; | ||
| 223 | std::array<GLuint, Tegra::Engines::Maxwell3D::Regs::NumTextureSamplers> samplers; | ||
| 224 | for (std::size_t i = 0; i < std::size(samplers); ++i) { | ||
| 225 | samplers[i] = texture_units[i].sampler; | ||
| 226 | if (samplers[i] != cur_state.texture_units[i].sampler) { | ||
| 227 | if (!has_delta) { | ||
| 228 | first = i; | ||
| 229 | has_delta = true; | ||
| 230 | } | ||
| 231 | last = i; | ||
| 232 | } | ||
| 233 | } | ||
| 234 | if (has_delta) { | ||
| 235 | glBindSamplers(static_cast<GLuint>(first), static_cast<GLsizei>(last - first + 1), | ||
| 236 | samplers.data()); | ||
| 237 | } | ||
| 238 | } | ||
| 239 | |||
| 222 | // Framebuffer | 240 | // Framebuffer |
| 223 | if (draw.read_framebuffer != cur_state.draw.read_framebuffer) { | 241 | if (draw.read_framebuffer != cur_state.draw.read_framebuffer) { |
| 224 | glBindFramebuffer(GL_READ_FRAMEBUFFER, draw.read_framebuffer); | 242 | glBindFramebuffer(GL_READ_FRAMEBUFFER, draw.read_framebuffer); |
diff --git a/src/video_core/renderer_opengl/gl_state.h b/src/video_core/renderer_opengl/gl_state.h index 9a93029d8..49f30b111 100644 --- a/src/video_core/renderer_opengl/gl_state.h +++ b/src/video_core/renderer_opengl/gl_state.h | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | 6 | ||
| 7 | #include <array> | 7 | #include <array> |
| 8 | #include <glad/glad.h> | 8 | #include <glad/glad.h> |
| 9 | #include "video_core/engines/maxwell_3d.h" | ||
| 9 | 10 | ||
| 10 | namespace OpenGL { | 11 | namespace OpenGL { |
| 11 | 12 | ||
| @@ -114,7 +115,7 @@ public: | |||
| 114 | target = GL_TEXTURE_2D; | 115 | target = GL_TEXTURE_2D; |
| 115 | } | 116 | } |
| 116 | }; | 117 | }; |
| 117 | std::array<TextureUnit, 32> texture_units; | 118 | std::array<TextureUnit, Tegra::Engines::Maxwell3D::Regs::NumTextureSamplers> texture_units; |
| 118 | 119 | ||
| 119 | struct { | 120 | struct { |
| 120 | GLuint read_framebuffer; // GL_READ_FRAMEBUFFER_BINDING | 121 | GLuint read_framebuffer; // GL_READ_FRAMEBUFFER_BINDING |