summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp26
1 files changed, 14 insertions, 12 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 6e89fa6e3..19399fab8 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -152,13 +152,13 @@ void RasterizerOpenGL::SetupVertexArrays() {
152 const Tegra::GPUVAddr end = regs.vertex_array_limit[index].LimitAddress(); 152 const Tegra::GPUVAddr end = regs.vertex_array_limit[index].LimitAddress();
153 153
154 if (regs.instanced_arrays.IsInstancingEnabled(index) && vertex_array.divisor != 0) { 154 if (regs.instanced_arrays.IsInstancingEnabled(index) && vertex_array.divisor != 0) {
155 start += vertex_array.stride * (gpu.state.current_instance / vertex_array.divisor); 155 start += static_cast<Tegra::GPUVAddr>(vertex_array.stride) *
156 (gpu.state.current_instance / vertex_array.divisor);
156 } 157 }
157 158
158 ASSERT(end > start); 159 ASSERT(end > start);
159 u64 size = end - start + 1; 160 const u64 size = end - start + 1;
160 161 const GLintptr vertex_buffer_offset = buffer_cache.UploadMemory(start, size);
161 GLintptr vertex_buffer_offset = buffer_cache.UploadMemory(start, size);
162 162
163 // Bind the vertex array to the buffer at the current offset. 163 // Bind the vertex array to the buffer at the current offset.
164 glBindVertexBuffer(index, buffer_cache.GetHandle(), vertex_buffer_offset, 164 glBindVertexBuffer(index, buffer_cache.GetHandle(), vertex_buffer_offset,
@@ -178,7 +178,7 @@ void RasterizerOpenGL::SetupVertexArrays() {
178 178
179void RasterizerOpenGL::SetupShaders() { 179void RasterizerOpenGL::SetupShaders() {
180 MICROPROFILE_SCOPE(OpenGL_Shader); 180 MICROPROFILE_SCOPE(OpenGL_Shader);
181 auto& gpu = Core::System::GetInstance().GPU().Maxwell3D(); 181 const auto& gpu = Core::System::GetInstance().GPU().Maxwell3D();
182 182
183 // Next available bindpoints to use when uploading the const buffers and textures to the GLSL 183 // Next available bindpoints to use when uploading the const buffers and textures to the GLSL
184 // shaders. The constbuffer bindpoint starts after the shader stage configuration bind points. 184 // shaders. The constbuffer bindpoint starts after the shader stage configuration bind points.
@@ -186,7 +186,7 @@ void RasterizerOpenGL::SetupShaders() {
186 u32 current_texture_bindpoint = 0; 186 u32 current_texture_bindpoint = 0;
187 187
188 for (size_t index = 0; index < Maxwell::MaxShaderProgram; ++index) { 188 for (size_t index = 0; index < Maxwell::MaxShaderProgram; ++index) {
189 auto& shader_config = gpu.regs.shader_config[index]; 189 const auto& shader_config = gpu.regs.shader_config[index];
190 const Maxwell::ShaderProgram program{static_cast<Maxwell::ShaderProgram>(index)}; 190 const Maxwell::ShaderProgram program{static_cast<Maxwell::ShaderProgram>(index)};
191 191
192 // Skip stages that are not enabled 192 // Skip stages that are not enabled
@@ -198,7 +198,7 @@ void RasterizerOpenGL::SetupShaders() {
198 198
199 GLShader::MaxwellUniformData ubo{}; 199 GLShader::MaxwellUniformData ubo{};
200 ubo.SetFromRegs(gpu.state.shader_stages[stage]); 200 ubo.SetFromRegs(gpu.state.shader_stages[stage]);
201 GLintptr offset = buffer_cache.UploadHostMemory( 201 const GLintptr offset = buffer_cache.UploadHostMemory(
202 &ubo, sizeof(ubo), static_cast<size_t>(uniform_buffer_alignment)); 202 &ubo, sizeof(ubo), static_cast<size_t>(uniform_buffer_alignment));
203 203
204 // Bind the buffer 204 // Bind the buffer
@@ -436,7 +436,7 @@ void RasterizerOpenGL::DrawArrays() {
436 436
437 ScopeAcquireGLContext acquire_context{emu_window}; 437 ScopeAcquireGLContext acquire_context{emu_window};
438 438
439 auto [dirty_color_surface, dirty_depth_surface] = 439 const auto [dirty_color_surface, dirty_depth_surface] =
440 ConfigureFramebuffers(true, regs.zeta.Address() != 0 && regs.zeta_enable != 0, true); 440 ConfigureFramebuffers(true, regs.zeta.Address() != 0 && regs.zeta_enable != 0, true);
441 441
442 SyncDepthTestState(); 442 SyncDepthTestState();
@@ -450,7 +450,8 @@ void RasterizerOpenGL::DrawArrays() {
450 450
451 // Draw the vertex batch 451 // Draw the vertex batch
452 const bool is_indexed = accelerate_draw == AccelDraw::Indexed; 452 const bool is_indexed = accelerate_draw == AccelDraw::Indexed;
453 const u64 index_buffer_size{regs.index_array.count * regs.index_array.FormatSizeInBytes()}; 453 const u64 index_buffer_size{static_cast<u64>(regs.index_array.count) *
454 static_cast<u64>(regs.index_array.FormatSizeInBytes())};
454 455
455 state.draw.vertex_buffer = buffer_cache.GetHandle(); 456 state.draw.vertex_buffer = buffer_cache.GetHandle();
456 state.Apply(); 457 state.Apply();
@@ -493,7 +494,8 @@ void RasterizerOpenGL::DrawArrays() {
493 const GLint base_vertex{static_cast<GLint>(regs.vb_element_base)}; 494 const GLint base_vertex{static_cast<GLint>(regs.vb_element_base)};
494 495
495 // Adjust the index buffer offset so it points to the first desired index. 496 // Adjust the index buffer offset so it points to the first desired index.
496 index_buffer_offset += regs.index_array.first * regs.index_array.FormatSizeInBytes(); 497 index_buffer_offset += static_cast<GLintptr>(regs.index_array.first) *
498 static_cast<GLintptr>(regs.index_array.FormatSizeInBytes());
497 499
498 glDrawElementsBaseVertex(primitive_mode, regs.index_array.count, 500 glDrawElementsBaseVertex(primitive_mode, regs.index_array.count,
499 MaxwellToGL::IndexFormat(regs.index_array.format), 501 MaxwellToGL::IndexFormat(regs.index_array.format),
@@ -588,7 +590,7 @@ void RasterizerOpenGL::SamplerInfo::Create() {
588} 590}
589 591
590void RasterizerOpenGL::SamplerInfo::SyncWithConfig(const Tegra::Texture::TSCEntry& config) { 592void RasterizerOpenGL::SamplerInfo::SyncWithConfig(const Tegra::Texture::TSCEntry& config) {
591 GLuint s = sampler.handle; 593 const GLuint s = sampler.handle;
592 594
593 if (mag_filter != config.mag_filter) { 595 if (mag_filter != config.mag_filter) {
594 mag_filter = config.mag_filter; 596 mag_filter = config.mag_filter;
@@ -682,7 +684,7 @@ u32 RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, Shader& shader,
682 684
683 for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) { 685 for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) {
684 const auto& entry = entries[bindpoint]; 686 const auto& entry = entries[bindpoint];
685 u32 current_bindpoint = current_unit + bindpoint; 687 const u32 current_bindpoint = current_unit + bindpoint;
686 688
687 // Bind the uniform to the sampler. 689 // Bind the uniform to the sampler.
688 690