summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp25
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.h1
-rw-r--r--src/yuzu/main.cpp2
-rw-r--r--src/yuzu_cmd/emu_window/emu_window_sdl2.cpp2
4 files changed, 27 insertions, 3 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index c59f3af1b..7e1bba67d 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -3,6 +3,7 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <algorithm> 5#include <algorithm>
6#include <array>
6#include <memory> 7#include <memory>
7#include <string> 8#include <string>
8#include <string_view> 9#include <string_view>
@@ -58,6 +59,8 @@ RasterizerOpenGL::RasterizerOpenGL(Core::Frontend::EmuWindow& window, ScreenInfo
58 59
59 if (extension == "GL_ARB_direct_state_access") { 60 if (extension == "GL_ARB_direct_state_access") {
60 has_ARB_direct_state_access = true; 61 has_ARB_direct_state_access = true;
62 } else if (extension == "GL_ARB_multi_bind") {
63 has_ARB_multi_bind = true;
61 } else if (extension == "GL_ARB_separate_shader_objects") { 64 } else if (extension == "GL_ARB_separate_shader_objects") {
62 has_ARB_separate_shader_objects = true; 65 has_ARB_separate_shader_objects = true;
63 } else if (extension == "GL_ARB_vertex_attrib_binding") { 66 } else if (extension == "GL_ARB_vertex_attrib_binding") {
@@ -644,12 +647,23 @@ u32 RasterizerOpenGL::SetupConstBuffers(Maxwell::ShaderStage stage, Shader& shad
644 const auto& shader_stage = maxwell3d.state.shader_stages[static_cast<size_t>(stage)]; 647 const auto& shader_stage = maxwell3d.state.shader_stages[static_cast<size_t>(stage)];
645 const auto& entries = shader->GetShaderEntries().const_buffer_entries; 648 const auto& entries = shader->GetShaderEntries().const_buffer_entries;
646 649
650 constexpr u64 max_binds = Tegra::Engines::Maxwell3D::Regs::MaxConstBuffers;
651 std::array<GLuint, max_binds> bind_buffers;
652 std::array<GLintptr, max_binds> bind_offsets;
653 std::array<GLsizeiptr, max_binds> bind_sizes;
654
655 ASSERT_MSG(entries.size() <= max_binds, "Exceeded expected number of binding points.");
656
647 // Upload only the enabled buffers from the 16 constbuffers of each shader stage 657 // Upload only the enabled buffers from the 16 constbuffers of each shader stage
648 for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) { 658 for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) {
649 const auto& used_buffer = entries[bindpoint]; 659 const auto& used_buffer = entries[bindpoint];
650 const auto& buffer = shader_stage.const_buffers[used_buffer.GetIndex()]; 660 const auto& buffer = shader_stage.const_buffers[used_buffer.GetIndex()];
651 661
652 if (!buffer.enabled) { 662 if (!buffer.enabled) {
663 // With disabled buffers set values as zero to unbind them
664 bind_buffers[bindpoint] = 0;
665 bind_offsets[bindpoint] = 0;
666 bind_sizes[bindpoint] = 0;
653 continue; 667 continue;
654 } 668 }
655 669
@@ -677,15 +691,20 @@ u32 RasterizerOpenGL::SetupConstBuffers(Maxwell::ShaderStage stage, Shader& shad
677 GLintptr const_buffer_offset = buffer_cache.UploadMemory( 691 GLintptr const_buffer_offset = buffer_cache.UploadMemory(
678 buffer.address, size, static_cast<size_t>(uniform_buffer_alignment)); 692 buffer.address, size, static_cast<size_t>(uniform_buffer_alignment));
679 693
680 glBindBufferRange(GL_UNIFORM_BUFFER, current_bindpoint + bindpoint,
681 buffer_cache.GetHandle(), const_buffer_offset, size);
682
683 // Now configure the bindpoint of the buffer inside the shader 694 // Now configure the bindpoint of the buffer inside the shader
684 glUniformBlockBinding(shader->GetProgramHandle(), 695 glUniformBlockBinding(shader->GetProgramHandle(),
685 shader->GetProgramResourceIndex(used_buffer), 696 shader->GetProgramResourceIndex(used_buffer),
686 current_bindpoint + bindpoint); 697 current_bindpoint + bindpoint);
698
699 // Prepare values for multibind
700 bind_buffers[bindpoint] = buffer_cache.GetHandle();
701 bind_offsets[bindpoint] = const_buffer_offset;
702 bind_sizes[bindpoint] = size;
687 } 703 }
688 704
705 glBindBuffersRange(GL_UNIFORM_BUFFER, current_bindpoint, static_cast<GLsizei>(entries.size()),
706 bind_buffers.data(), bind_offsets.data(), bind_sizes.data());
707
689 return current_bindpoint + static_cast<u32>(entries.size()); 708 return current_bindpoint + static_cast<u32>(entries.size());
690} 709}
691 710
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h
index 745c3dc0c..163412882 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer.h
@@ -159,6 +159,7 @@ private:
159 void SyncLogicOpState(); 159 void SyncLogicOpState();
160 160
161 bool has_ARB_direct_state_access = false; 161 bool has_ARB_direct_state_access = false;
162 bool has_ARB_multi_bind = false;
162 bool has_ARB_separate_shader_objects = false; 163 bool has_ARB_separate_shader_objects = false;
163 bool has_ARB_vertex_attrib_binding = false; 164 bool has_ARB_vertex_attrib_binding = false;
164 165
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp
index 05a4a55e8..22a317737 100644
--- a/src/yuzu/main.cpp
+++ b/src/yuzu/main.cpp
@@ -449,6 +449,8 @@ QStringList GMainWindow::GetUnsupportedGLExtensions() {
449 unsupported_ext.append("ARB_base_instance"); 449 unsupported_ext.append("ARB_base_instance");
450 if (!GLAD_GL_ARB_texture_storage) 450 if (!GLAD_GL_ARB_texture_storage)
451 unsupported_ext.append("ARB_texture_storage"); 451 unsupported_ext.append("ARB_texture_storage");
452 if (!GLAD_GL_ARB_multi_bind)
453 unsupported_ext.append("ARB_multi_bind");
452 454
453 // Extensions required to support some texture formats. 455 // Extensions required to support some texture formats.
454 if (!GLAD_GL_EXT_texture_compression_s3tc) 456 if (!GLAD_GL_EXT_texture_compression_s3tc)
diff --git a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp
index d213929bd..0733301b2 100644
--- a/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp
+++ b/src/yuzu_cmd/emu_window/emu_window_sdl2.cpp
@@ -96,6 +96,8 @@ bool EmuWindow_SDL2::SupportsRequiredGLExtensions() {
96 unsupported_ext.push_back("ARB_base_instance"); 96 unsupported_ext.push_back("ARB_base_instance");
97 if (!GLAD_GL_ARB_texture_storage) 97 if (!GLAD_GL_ARB_texture_storage)
98 unsupported_ext.push_back("ARB_texture_storage"); 98 unsupported_ext.push_back("ARB_texture_storage");
99 if (!GLAD_GL_ARB_multi_bind)
100 unsupported_ext.push_back("ARB_multi_bind");
99 101
100 // Extensions required to support some texture formats. 102 // Extensions required to support some texture formats.
101 if (!GLAD_GL_EXT_texture_compression_s3tc) 103 if (!GLAD_GL_EXT_texture_compression_s3tc)