Start refactoring the submission process

This commit is contained in:
Luke Benstead 2018-08-20 21:19:12 +01:00
parent 80c65d4aff
commit bccd1aa788
4 changed files with 25 additions and 32 deletions

View File

@ -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];

View File

@ -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;
}
}

View File

@ -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() {

View File

@ -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 {