From e7574bca1d2d9c35880ff640471931ef9188655d Mon Sep 17 00:00:00 2001 From: Luke Benstead Date: Wed, 31 May 2023 18:27:17 +0100 Subject: [PATCH] Fix issues with GL_QUADS --- GL/draw.c | 14 ++++++-------- GL/draw_fastpath.inc | 24 ++++++++++++------------ 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/GL/draw.c b/GL/draw.c index 3c722e3..2fa6d88 100644 --- a/GL/draw.c +++ b/GL/draw.c @@ -815,17 +815,15 @@ static void generateElementsFastPath( #define POLYMODE QUADS #define PROCESS_VERTEX_FLAGS(it, i) { \ - if((i + 1) % 4 == 0) { \ - Vertex* prev = ((it) - 1); \ - Vertex t = (*prev); \ - *(prev) = *((it)); \ - *((it)) = t; \ - prev->flags = GPU_CMD_VERTEX; \ + it->flags = GPU_CMD_VERTEX; \ + if(((i + 1) % 4) == 0) { \ + Vertex t = *it; \ + *it = *(it - 1); \ + *(it - 1) = t; \ it->flags = GPU_CMD_VERTEX_EOL; \ - } else { \ - it->flags = GPU_CMD_VERTEX; \ } \ } + #include "draw_fastpath.inc" #undef PROCESS_VERTEX_FLAGS #undef POLYMODE diff --git a/GL/draw_fastpath.inc b/GL/draw_fastpath.inc index d483b9d..8ea3514 100644 --- a/GL/draw_fastpath.inc +++ b/GL/draw_fastpath.inc @@ -29,18 +29,6 @@ MAKE_FUNC(POLYMODE) const int_fast32_t loop = ((min + BATCH_SIZE) > count) ? count - min : BATCH_SIZE; const int offset = (first + min); - stride = ATTRIB_POINTERS.vertex.stride; - ptr = ATTRIB_POINTERS.vertex.ptr + (offset * stride); - it = (Vertex*) start; - - PREFETCH(ptr); - for(int_fast32_t i = 0; i < loop; ++i, ++it) { - PREFETCH(ptr + stride); - TransformVertex((const float*) ptr, &w, it->xyz, &it->w); - PROCESS_VERTEX_FLAGS(it, min + i); - ptr += stride; - } - stride = ATTRIB_POINTERS.uv.stride; ptr = (ENABLED_VERTEX_ATTRIBUTES & UV_ENABLED_FLAG) ? ATTRIB_POINTERS.uv.ptr + ((first + min) * stride) : NULL; it = (Vertex*) start; @@ -80,6 +68,18 @@ MAKE_FUNC(POLYMODE) } } + stride = ATTRIB_POINTERS.vertex.stride; + ptr = ATTRIB_POINTERS.vertex.ptr + (offset * stride); + it = (Vertex*) start; + + PREFETCH(ptr); + for(int_fast32_t i = 0; i < loop; ++i, ++it) { + PREFETCH(ptr + stride); + TransformVertex((const float*) ptr, &w, it->xyz, &it->w); + PROCESS_VERTEX_FLAGS(it, min + i); + ptr += stride; + } + start = aligned_vector_at(target->extras, min); stride = ATTRIB_POINTERS.st.stride;