From bccd1aa788de9709ae09aeae797e422ad405695a Mon Sep 17 00:00:00 2001 From: Luke Benstead Date: Mon, 20 Aug 2018 21:19:12 +0100 Subject: [PATCH] Start refactoring the submission process --- GL/clip.h | 4 ++++ GL/draw.c | 36 +++++++++--------------------------- GL/flush.c | 7 ++++--- GL/private.h | 10 ++++++++-- 4 files changed, 25 insertions(+), 32 deletions(-) diff --git a/GL/clip.h b/GL/clip.h index 58d379f..4035162 100644 --- a/GL/clip.h +++ b/GL/clip.h @@ -25,11 +25,15 @@ typedef enum { typedef struct { + /* Same 32 byte layout as pvr_vertex_t */ uint32_t flags; float xyz[3]; float uv[2]; uint8_t bgra[4]; + uint32_t oargb; + /* Important, we have 24 bytes here. That means when submitting to the SQs we need to + * increment the pointer by 6 */ float nxyz[3]; /* Normal */ float w; float st[2]; diff --git a/GL/draw.c b/GL/draw.c index 25783ea..8b72b0b 100644 --- a/GL/draw.c +++ b/GL/draw.c @@ -741,22 +741,14 @@ static void divide(AlignedVector* vertices) { } } -typedef struct { - unsigned int list_type; - pvr_poly_hdr_t hdr; -} ListToHeader; - - -#define MAX_LISTS 5 - static void push(const AlignedVector* vertices, PolyList* activePolyList, GLshort textureUnit) { /* Copy the vertices to the active poly list */ // Make room for the element + the header - PVRCommand* dst = (PVRCommand*) aligned_vector_extend(&activePolyList->vector, vertices->size); + ClipVertex* dst = (ClipVertex*) aligned_vector_extend(&activePolyList->vector, vertices->size + 1); // Store a pointer to the header - pvr_poly_hdr_t* hdr = (pvr_poly_hdr_t*) dst; + PVRHeader* header = (PVRHeader*) dst; // Compile pvr_poly_cxt_t cxt = *getPVRContext(); @@ -764,32 +756,22 @@ static void push(const AlignedVector* vertices, PolyList* activePolyList, GLshor _glUpdatePVRTextureContext(&cxt, textureUnit); - pvr_poly_compile(hdr, &cxt); + pvr_poly_compile(&header->hdr, &cxt); // Point dest at the first new vertex to populate, if we're not sending a header // we won't increment and instead overwrite the header we just created with the // first vertex dst++; - // Add one more to the list - aligned_vector_extend(&activePolyList->vector, 1); - - GLsizei i = vertices->size; ClipVertex* vin = aligned_vector_at(vertices, 0); - pvr_vertex_t* vout = (pvr_vertex_t*) dst; + ClipVertex* vout = dst; + GLuint i = vertices->size; while(i--) { - vout->flags = vin->flags; - vout->x = vin->xyz[0]; - vout->y = vin->xyz[1]; - vout->z = vin->xyz[2]; - vout->u = vin->uv[0]; - vout->v = vin->uv[1]; - vout->argb = *((uint32_t*) vin->bgra); - vout->oargb = 0; - - vin++; - vout++; + vin->oargb = 0; + *vout = *vin; + ++vout; + ++vin; } } diff --git a/GL/flush.c b/GL/flush.c index 116a317..f38f592 100644 --- a/GL/flush.c +++ b/GL/flush.c @@ -30,6 +30,7 @@ static void pvr_list_submit(void *src, int n) { d[7] = *(s++); __asm__("pref @%0" : : "r"(d)); d += 8; + s += CLIP_VERTEX_INT_PADDING; } /* Wait for both store queues to complete */ @@ -81,9 +82,9 @@ void APIENTRY glKosInit() { PT_LIST.list_type = PVR_LIST_PT_POLY; TR_LIST.list_type = PVR_LIST_TR_POLY; - aligned_vector_init(&OP_LIST.vector, sizeof(PVRCommand)); - aligned_vector_init(&PT_LIST.vector, sizeof(PVRCommand)); - aligned_vector_init(&TR_LIST.vector, sizeof(PVRCommand)); + aligned_vector_init(&OP_LIST.vector, sizeof(ClipVertex)); + aligned_vector_init(&PT_LIST.vector, sizeof(ClipVertex)); + aligned_vector_init(&TR_LIST.vector, sizeof(ClipVertex)); } void APIENTRY glKosSwapBuffers() { diff --git a/GL/private.h b/GL/private.h index 87d7674..c50f767 100644 --- a/GL/private.h +++ b/GL/private.h @@ -11,9 +11,12 @@ #define MAX_TEXTURE_SIZE 1024 +#define CLIP_VERTEX_INT_PADDING 6 + typedef struct { - unsigned int cmd[8]; -} PVRCommand; + pvr_poly_hdr_t hdr; + unsigned int padding[CLIP_VERTEX_INT_PADDING]; +} PVRHeader; typedef struct { unsigned int flags; /* Constant PVR_CMD_USERCLIP */ @@ -22,6 +25,9 @@ typedef struct { sy, /* Start y */ ex, /* End x */ ey; /* End y */ + + /* Padding to match clip vertex */ + unsigned int padding[CLIP_VERTEX_INT_PADDING]; } PVRTileClipCommand; /* Tile Clip command for the pvr */ typedef struct {