Move perspective divide to the submission loop
This commit is contained in:
parent
952c915ee8
commit
40aedc2530
20
GL/draw.c
20
GL/draw.c
|
@ -925,25 +925,6 @@ static void light(SubmissionTarget* target) {
|
||||||
_glPerformLighting(vertex, ES, target->count);
|
_glPerformLighting(vertex, ES, target->count);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PVR_MIN_Z 0.2f
|
|
||||||
#define PVR_MAX_Z 1.0 + PVR_MIN_Z
|
|
||||||
|
|
||||||
GL_FORCE_INLINE void divide(SubmissionTarget* target) {
|
|
||||||
TRACE();
|
|
||||||
|
|
||||||
/* Perform perspective divide on each vertex */
|
|
||||||
Vertex* vertex = _glSubmissionTargetStart(target);
|
|
||||||
|
|
||||||
ITERATE(target->count) {
|
|
||||||
float f = MATH_Fast_Invert(vertex->w);
|
|
||||||
vertex->xyz[0] *= f;
|
|
||||||
vertex->xyz[1] *= f;
|
|
||||||
vertex->xyz[2] *= f;
|
|
||||||
vertex->xyz[2] = MAX(1.0f - (vertex->xyz[2] * 0.5f + 0.5f), 0.0001f);
|
|
||||||
++vertex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
GL_FORCE_INLINE void push(PVRHeader* header, GLboolean multiTextureHeader, PolyList* activePolyList, GLshort textureUnit) {
|
GL_FORCE_INLINE void push(PVRHeader* header, GLboolean multiTextureHeader, PolyList* activePolyList, GLshort textureUnit) {
|
||||||
TRACE();
|
TRACE();
|
||||||
|
|
||||||
|
@ -1088,7 +1069,6 @@ GL_FORCE_INLINE void submitVertices(GLenum mode, GLsizei first, GLuint count, GL
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
divide(target);
|
|
||||||
push(_glSubmissionTargetHeader(target), GL_FALSE, target->output, 0);
|
push(_glSubmissionTargetHeader(target), GL_FALSE, target->output, 0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
19
GL/flush.c
19
GL/flush.c
|
@ -45,6 +45,21 @@ static inline ListIterator* begin(void* src, int n) {
|
||||||
return (n) ? it : NULL;
|
return (n) ? it : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GL_FORCE_INLINE isVertex(const Vertex* vertex) {
|
||||||
|
return (
|
||||||
|
vertex->flags == PVR_CMD_VERTEX ||
|
||||||
|
vertex->flags == PVR_CMD_VERTEX_EOL
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void perspective_divide(Vertex* vertex) {
|
||||||
|
float f = MATH_Fast_Invert(vertex->w);
|
||||||
|
vertex->xyz[0] *= f;
|
||||||
|
vertex->xyz[1] *= f;
|
||||||
|
vertex->xyz[2] *= f;
|
||||||
|
vertex->xyz[2] = MAX(1.0f - (vertex->xyz[2] * 0.5f + 0.5f), 0.0001f);
|
||||||
|
}
|
||||||
|
|
||||||
static void pvr_list_submit(void *src, int n) {
|
static void pvr_list_submit(void *src, int n) {
|
||||||
GLuint *d = TA_SQ_ADDR;
|
GLuint *d = TA_SQ_ADDR;
|
||||||
|
|
||||||
|
@ -53,6 +68,10 @@ static void pvr_list_submit(void *src, int n) {
|
||||||
while(it) {
|
while(it) {
|
||||||
__asm__("pref @%0" : : "r"(it->current + 1)); /* prefetch 64 bytes for next loop */
|
__asm__("pref @%0" : : "r"(it->current + 1)); /* prefetch 64 bytes for next loop */
|
||||||
if(it->current->flags != DEAD) {
|
if(it->current->flags != DEAD) {
|
||||||
|
if(isVertex(it->current)) {
|
||||||
|
perspective_divide(it->current);
|
||||||
|
}
|
||||||
|
|
||||||
GLuint* s = (GLuint*) it->current;
|
GLuint* s = (GLuint*) it->current;
|
||||||
|
|
||||||
d[0] = *(s++);
|
d[0] = *(s++);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user