fix: accept

This commit is contained in:
Hayden Kowalchuk 2019-09-18 20:14:39 -04:00
parent be7781de75
commit 000d6dae7d
2 changed files with 59 additions and 18 deletions

View File

@ -92,7 +92,7 @@ void _glClipTriangle(const Triangle* triangle, const uint8_t visible, Submission
const VertexExtra* extras = triangle->extra;
/* Used when flat shading is enabled */
uint32_t finalColour = vertices[2].color.packed;
uint32_t finalColour = *((uint32_t*) vertices[2].bgra);
for(i = 0; i < 4; ++i) {
uint8_t thisIndex = (i == 3) ? 0 : i;
@ -123,9 +123,9 @@ void _glClipTriangle(const Triangle* triangle, const uint8_t visible, Submission
interpolateVec2(ve1->st, ve2->st, t, veNext.st);
if(flatShade) {
next.color.packed = finalColour;
*((uint32_t*) next.bgra) = finalColour;
} else {
interpolateColour(v1->color.bgra, v2->color.bgra, t, next.color.bgra);
interpolateColour(v1->bgra, v2->bgra, t, next.bgra);
}
/* Push back the new vertices to the end of both the ClipVertex and VertexExtra lists */

View File

@ -739,19 +739,19 @@ static inline void _readDiffuseData(const GLuint first, const GLuint count, Vert
if(DIFFUSE_POINTER.size == 3) {
switch(DIFFUSE_POINTER.type) {
case GL_FLOAT:
_readVertexData3fARGB(cptr, count, cstride, output[0].color.bgra);
_readVertexData3fARGB(cptr, count, cstride, output[0].bgra);
break;
case GL_BYTE:
case GL_UNSIGNED_BYTE:
_readVertexData3ubARGB(cptr, count, cstride, output[0].color.bgra);
_readVertexData3ubARGB(cptr, count, cstride, output[0].bgra);
break;
case GL_SHORT:
case GL_UNSIGNED_SHORT:
_readVertexData3usARGB(cptr, count, cstride, output[0].color.bgra);
_readVertexData3usARGB(cptr, count, cstride, output[0].bgra);
break;
case GL_INT:
case GL_UNSIGNED_INT:
_readVertexData3uiARGB(cptr, count, cstride, output[0].color.bgra);
_readVertexData3uiARGB(cptr, count, cstride, output[0].bgra);
break;
default:
assert(0 && "Not Implemented");
@ -759,19 +759,19 @@ static inline void _readDiffuseData(const GLuint first, const GLuint count, Vert
} else if(DIFFUSE_POINTER.size == 4) {
switch(DIFFUSE_POINTER.type) {
case GL_FLOAT:
_readVertexData4fARGB(cptr, count, cstride, output[0].color.bgra);
_readVertexData4fARGB(cptr, count, cstride, output[0].bgra);
break;
case GL_BYTE:
case GL_UNSIGNED_BYTE:
_readVertexData4ubARGB(cptr, count, cstride, output[0].color.bgra);
_readVertexData4ubARGB(cptr, count, cstride, output[0].bgra);
break;
case GL_SHORT:
case GL_UNSIGNED_SHORT:
_readVertexData4usARGB(cptr, count, cstride, output[0].color.bgra);
_readVertexData4usARGB(cptr, count, cstride, output[0].bgra);
break;
case GL_INT:
case GL_UNSIGNED_INT:
_readVertexData4uiARGB(cptr, count, cstride, output[0].color.bgra);
_readVertexData4uiARGB(cptr, count, cstride, output[0].bgra);
break;
default:
assert(0 && "Not Implemented");
@ -789,6 +789,44 @@ static void generate(SubmissionTarget* target, const GLenum mode, const GLsizei
const GLsizei istride = byte_size(type);
if(!indices) {
if( ((ENABLED_VERTEX_ATTRIBUTES & DIFFUSE_ENABLED_FLAG) == DIFFUSE_ENABLED_FLAG ) && (DIFFUSE_POINTER.type == GL_UNSIGNED_BYTE ) && ( VERTEX_POINTER.stride == 32 ) ){
profiler_push(__func__);
Vertex* start = _glSubmissionTargetStart(target);
Vertex* it = start;
sq_cpy(start, VERTEX_POINTER.ptr - ( sizeof(unsigned int) * 1 ), count * sizeof(Vertex) );
ITERATE(count) {
it->flags = PVR_CMD_VERTEX;
++it;
}
profiler_checkpoint("flags");
// Drawing arrays
switch(mode) {
case GL_TRIANGLES:
genTriangles(start, count);
break;
case GL_QUADS:
genQuads(start, count);
break;
case GL_TRIANGLE_FAN:
genTriangleFan(start, count);
break;
case GL_TRIANGLE_STRIP:
genTriangleStrip(_glSubmissionTargetStart(target), count);
break;
default:
assert(0 && "Not Implemented");
}
profiler_checkpoint("quads");
profiler_pop();
}else {
profiler_push(__func__);
Vertex* start = _glSubmissionTargetStart(target);
@ -798,7 +836,7 @@ static void generate(SubmissionTarget* target, const GLenum mode, const GLsizei
if((ENABLED_VERTEX_ATTRIBUTES & DIFFUSE_ENABLED_FLAG) != DIFFUSE_ENABLED_FLAG) {
/* Just fill the whole thing white if the attribute is disabled */
_fillWhiteARGB(count, start[0].color.bgra);
_fillWhiteARGB(count, start[0].bgra);
} else {
_readDiffuseData(first, count, start);
}
@ -841,6 +879,7 @@ static void generate(SubmissionTarget* target, const GLenum mode, const GLsizei
profiler_checkpoint("quads");
profiler_pop();
}
} else {
const IndexParseFunc indexFunc = _calcParseIndexFunc(type);
GLuint j;
@ -999,7 +1038,7 @@ static void light(SubmissionTarget* target) {
GLubyte j;
for(j = 0; j < MAX_LIGHTS; ++j) {
if(_glIsLightEnabled(j)) {
_glCalculateLightingContribution(j, ES->xyz, ES->n, vertex->color.bgra, to_add);
_glCalculateLightingContribution(j, ES->xyz, ES->n, vertex->bgra, to_add);
total[0] += to_add[0];
total[1] += to_add[1];
@ -1008,10 +1047,10 @@ static void light(SubmissionTarget* target) {
}
}
vertex->color.bgra[A8IDX] = (GLubyte) (255.0f * fminf(total[3], 1.0f));
vertex->color.bgra[R8IDX] = (GLubyte) (255.0f * fminf(total[0], 1.0f));
vertex->color.bgra[G8IDX] = (GLubyte) (255.0f * fminf(total[1], 1.0f));
vertex->color.bgra[B8IDX] = (GLubyte) (255.0f * fminf(total[2], 1.0f));
vertex->bgra[A8IDX] = (GLubyte) (255.0f * fminf(total[3], 1.0f));
vertex->bgra[R8IDX] = (GLubyte) (255.0f * fminf(total[0], 1.0f));
vertex->bgra[G8IDX] = (GLubyte) (255.0f * fminf(total[1], 1.0f));
vertex->bgra[B8IDX] = (GLubyte) (255.0f * fminf(total[2], 1.0f));
}
}
@ -1139,7 +1178,7 @@ static void submitVertices(GLenum mode, GLsizei first, GLuint count, GLenum type
aligned_vector_extend(&target->output->vector, target->count + 1);
profiler_checkpoint("allocate");
#if 0
if( ((ENABLED_VERTEX_ATTRIBUTES & DIFFUSE_ENABLED_FLAG) == DIFFUSE_ENABLED_FLAG ) && (DIFFUSE_POINTER.type == GL_UNSIGNED_BYTE ) && (DIFFUSE_POINTER.ptr - VERTEX_POINTER.ptr) == (sizeof(GLfloat) * 5)){
Vertex* start = _glSubmissionTargetStart(target);
@ -1175,6 +1214,8 @@ static void submitVertices(GLenum mode, GLsizei first, GLuint count, GLenum type
}else {
generate(target, mode, first, count, (GLubyte*) indices, type, doTexture, doMultitexture, doLighting);
}
#endif
generate(target, mode, first, count, (GLubyte*) indices, type, doTexture, doMultitexture, doLighting);
profiler_checkpoint("generate");
extern GLboolean LIGHTING_ENABLED;