chore: strict aliasing 2
This commit is contained in:
parent
6b4ac0bc61
commit
fca58f1f13
|
@ -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 = *((uint32_t*) vertices[2].bgra);
|
||||
uint32_t finalColour = vertices[2].color.packed;
|
||||
|
||||
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) {
|
||||
*((uint32_t*) next.bgra) = finalColour;
|
||||
next.color.packed = finalColour;
|
||||
} else {
|
||||
interpolateColour(v1->bgra, v2->bgra, t, next.bgra);
|
||||
interpolateColour(v1->color.bgra, v2->color.bgra, t, next.color.bgra);
|
||||
}
|
||||
|
||||
/* Push back the new vertices to the end of both the ClipVertex and VertexExtra lists */
|
||||
|
|
35
GL/draw.c
35
GL/draw.c
|
@ -367,12 +367,14 @@ static void _fillZero2f(GLuint count, GLfloat* output) {
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void _fillZero2fVE(GLuint count, GLfloat* output) {
|
||||
ITERATE(count) {
|
||||
output[0] = output[1] = 0.0f;
|
||||
output = (GLfloat*) (((GLubyte*) output) + sizeof(VertexExtra));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static void _readVertexData3usARGB(const GLushort* input, GLuint count, GLubyte stride, GLubyte* output) {
|
||||
assert(0 && "Not Implemented");
|
||||
|
@ -721,19 +723,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].bgra);
|
||||
_readVertexData3fARGB(cptr, count, cstride, output[0].color.bgra);
|
||||
break;
|
||||
case GL_BYTE:
|
||||
case GL_UNSIGNED_BYTE:
|
||||
_readVertexData3ubARGB(cptr, count, cstride, output[0].bgra);
|
||||
_readVertexData3ubARGB(cptr, count, cstride, output[0].color.bgra);
|
||||
break;
|
||||
case GL_SHORT:
|
||||
case GL_UNSIGNED_SHORT:
|
||||
_readVertexData3usARGB(cptr, count, cstride, output[0].bgra);
|
||||
_readVertexData3usARGB(cptr, count, cstride, output[0].color.bgra);
|
||||
break;
|
||||
case GL_INT:
|
||||
case GL_UNSIGNED_INT:
|
||||
_readVertexData3uiARGB(cptr, count, cstride, output[0].bgra);
|
||||
_readVertexData3uiARGB(cptr, count, cstride, output[0].color.bgra);
|
||||
break;
|
||||
default:
|
||||
assert(0 && "Not Implemented");
|
||||
|
@ -741,19 +743,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].bgra);
|
||||
_readVertexData4fARGB(cptr, count, cstride, output[0].color.bgra);
|
||||
break;
|
||||
case GL_BYTE:
|
||||
case GL_UNSIGNED_BYTE:
|
||||
_readVertexData4ubARGB(cptr, count, cstride, output[0].bgra);
|
||||
_readVertexData4ubARGB(cptr, count, cstride, output[0].color.bgra);
|
||||
break;
|
||||
case GL_SHORT:
|
||||
case GL_UNSIGNED_SHORT:
|
||||
_readVertexData4usARGB(cptr, count, cstride, output[0].bgra);
|
||||
_readVertexData4usARGB(cptr, count, cstride, output[0].color.bgra);
|
||||
break;
|
||||
case GL_INT:
|
||||
case GL_UNSIGNED_INT:
|
||||
_readVertexData4uiARGB(cptr, count, cstride, output[0].bgra);
|
||||
_readVertexData4uiARGB(cptr, count, cstride, output[0].color.bgra);
|
||||
break;
|
||||
default:
|
||||
assert(0 && "Not Implemented");
|
||||
|
@ -771,8 +773,7 @@ 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 ) && DIFFUSE_POINTER.stride == 32){
|
||||
|
||||
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)){
|
||||
profiler_push(__func__);
|
||||
|
||||
Vertex* start = _glSubmissionTargetStart(target);
|
||||
|
@ -818,7 +819,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].bgra);
|
||||
_fillWhiteARGB(count, start[0].color.bgra);
|
||||
} else {
|
||||
_readDiffuseData(first, count, start);
|
||||
}
|
||||
|
@ -1020,7 +1021,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->bgra, to_add);
|
||||
_glCalculateLightingContribution(j, ES->xyz, ES->n, vertex->color.bgra, to_add);
|
||||
|
||||
total[0] += to_add[0];
|
||||
total[1] += to_add[1];
|
||||
|
@ -1029,10 +1030,10 @@ static void light(SubmissionTarget* target) {
|
|||
}
|
||||
}
|
||||
|
||||
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));
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1144,7 +1145,7 @@ static void submitVertices(GLenum mode, GLsizei first, GLuint count, GLenum type
|
|||
target->output = _glActivePolyList();
|
||||
target->count = (mode == GL_TRIANGLE_FAN) ? ((count - 2) * 3) : count;
|
||||
if(target->count < 3 || count < 3){
|
||||
printf("%s: %d = %u verts\n",__func__,count,target->count);
|
||||
printf("%s: %d = %u verts\n",__func__,count,(unsigned int)target->count);
|
||||
}
|
||||
target->header_offset = target->output->vector.size;
|
||||
target->start_offset = target->header_offset + 1;
|
||||
|
|
Loading…
Reference in New Issue
Block a user