forked from suyu/suyu
Merge pull request #1356 from degasus/hotfix
gl_rasterizer: Fix StartAddress handling with indexed draw calls.
This commit is contained in:
commit
52fb86c65c
1 changed files with 7 additions and 6 deletions
|
@ -484,8 +484,13 @@ void RasterizerOpenGL::DrawArrays() {
|
||||||
GLintptr index_buffer_offset = 0;
|
GLintptr index_buffer_offset = 0;
|
||||||
if (is_indexed) {
|
if (is_indexed) {
|
||||||
MICROPROFILE_SCOPE(OpenGL_Index);
|
MICROPROFILE_SCOPE(OpenGL_Index);
|
||||||
index_buffer_offset =
|
|
||||||
buffer_cache.UploadMemory(regs.index_array.StartAddress(), index_buffer_size);
|
// Adjust the index buffer offset so it points to the first desired index.
|
||||||
|
auto index_start = regs.index_array.StartAddress();
|
||||||
|
index_start += static_cast<size_t>(regs.index_array.first) *
|
||||||
|
static_cast<size_t>(regs.index_array.FormatSizeInBytes());
|
||||||
|
|
||||||
|
index_buffer_offset = buffer_cache.UploadMemory(index_start, index_buffer_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetupShaders();
|
SetupShaders();
|
||||||
|
@ -499,10 +504,6 @@ void RasterizerOpenGL::DrawArrays() {
|
||||||
if (is_indexed) {
|
if (is_indexed) {
|
||||||
const GLint base_vertex{static_cast<GLint>(regs.vb_element_base)};
|
const GLint base_vertex{static_cast<GLint>(regs.vb_element_base)};
|
||||||
|
|
||||||
// Adjust the index buffer offset so it points to the first desired index.
|
|
||||||
index_buffer_offset += static_cast<GLintptr>(regs.index_array.first) *
|
|
||||||
static_cast<GLintptr>(regs.index_array.FormatSizeInBytes());
|
|
||||||
|
|
||||||
if (gpu.state.current_instance > 0) {
|
if (gpu.state.current_instance > 0) {
|
||||||
glDrawElementsInstancedBaseVertexBaseInstance(
|
glDrawElementsInstancedBaseVertexBaseInstance(
|
||||||
primitive_mode, regs.index_array.count,
|
primitive_mode, regs.index_array.count,
|
||||||
|
|
Loading…
Reference in a new issue