summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl
diff options
context:
space:
mode:
authorSubv <subv2112@gmail.com>2018-08-18 21:42:26 +0200
committerSubv <subv2112@gmail.com>2018-08-18 21:42:26 +0200
commite0f66c1fbfa7874df9970c2d269bd61e05758309 (patch)
treeadeffbdf54c36072ed820d56b9d55c073da3bd08 /src/video_core/renderer_opengl
parentMerge pull request #1100 from ogniK5377/missing-pred (diff)
downloadyuzu-e0f66c1fbfa7874df9970c2d269bd61e05758309.tar
yuzu-e0f66c1fbfa7874df9970c2d269bd61e05758309.tar.gz
yuzu-e0f66c1fbfa7874df9970c2d269bd61e05758309.tar.bz2
yuzu-e0f66c1fbfa7874df9970c2d269bd61e05758309.tar.lz
yuzu-e0f66c1fbfa7874df9970c2d269bd61e05758309.tar.xz
yuzu-e0f66c1fbfa7874df9970c2d269bd61e05758309.tar.zst
yuzu-e0f66c1fbfa7874df9970c2d269bd61e05758309.zip
Diffstat (limited to 'src/video_core/renderer_opengl')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 93eadde7a..fe1f55e85 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -98,7 +98,8 @@ RasterizerOpenGL::~RasterizerOpenGL() {}
std::pair<u8*, GLintptr> RasterizerOpenGL::SetupVertexArrays(u8* array_ptr,
GLintptr buffer_offset) {
MICROPROFILE_SCOPE(OpenGL_VAO);
- const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs;
+ const auto& gpu = Core::System::GetInstance().GPU().Maxwell3D();
+ const auto& regs = gpu.regs;
state.draw.vertex_array = hw_vao.handle;
state.draw.vertex_buffer = stream_buffer.GetHandle();
@@ -110,9 +111,13 @@ std::pair<u8*, GLintptr> RasterizerOpenGL::SetupVertexArrays(u8* array_ptr,
if (!vertex_array.IsEnabled())
continue;
- const Tegra::GPUVAddr start = vertex_array.StartAddress();
+ Tegra::GPUVAddr start = vertex_array.StartAddress();
const Tegra::GPUVAddr end = regs.vertex_array_limit[index].LimitAddress();
+ if (regs.instanced_arrays.IsInstancingEnabled(index) && vertex_array.divisor != 0) {
+ start += vertex_array.stride * (gpu.state.current_instance / vertex_array.divisor);
+ }
+
ASSERT(end > start);
u64 size = end - start + 1;
@@ -124,7 +129,15 @@ std::pair<u8*, GLintptr> RasterizerOpenGL::SetupVertexArrays(u8* array_ptr,
glBindVertexBuffer(index, stream_buffer.GetHandle(), vertex_buffer_offset,
vertex_array.stride);
- ASSERT_MSG(vertex_array.divisor == 0, "Instanced vertex arrays are not supported");
+ if (regs.instanced_arrays.IsInstancingEnabled(index) && vertex_array.divisor != 0) {
+ // Tell OpenGL that this is an instanced vertex buffer to prevent accessing different
+ // indexes on each vertex. We do the instance indexing manually by incrementing the
+ // start address of the vertex buffer.
+ glVertexBindingDivisor(index, 1);
+ } else {
+ // Disable the vertex buffer instancing.
+ glVertexBindingDivisor(index, 0);
+ }
}
// Use the vertex array as-is, assumes that the data is formatted correctly for OpenGL.