Simplify the element drawing

This commit is contained in:
Luke Benstead 2019-03-04 20:41:33 +00:00
parent 7c0a123aac
commit d89997a277
2 changed files with 8 additions and 40 deletions

View File

@ -460,6 +460,8 @@ static inline PolyBuildFunc _calcBuildFunc(const GLenum type) {
return &_buildStrip; return &_buildStrip;
} }
static inline void nullFloatParseFunc(GLfloat* out, const GLubyte* in) {}
static inline void genElementsCommon( static inline void genElementsCommon(
ClipVertex* output, ClipVertex* output,
const GLubyte* iptr, GLuint istride, GLenum type, const GLubyte* iptr, GLuint istride, GLenum type,
@ -473,9 +475,9 @@ static inline void genElementsCommon(
) { ) {
const FloatParseFunc vertexFunc = _calcVertexParseFunc(); const FloatParseFunc vertexFunc = _calcVertexParseFunc();
const ByteParseFunc diffuseFunc = _calcDiffuseParseFunc(); const ByteParseFunc diffuseFunc = _calcDiffuseParseFunc();
const FloatParseFunc uvFunc = _calcUVParseFunc(); const FloatParseFunc uvFunc = (doTexture) ? _calcUVParseFunc() : &nullFloatParseFunc;
const FloatParseFunc stFunc = _calcSTParseFunc(); const FloatParseFunc stFunc = (doMultitexture) ? _calcSTParseFunc() : &nullFloatParseFunc;
const FloatParseFunc normalFunc = _calcNormalParseFunc(); const FloatParseFunc normalFunc = (doLighting) ? _calcNormalParseFunc() : &nullFloatParseFunc;
const IndexParseFunc indexFunc = _calcParseIndexFunc(type); const IndexParseFunc indexFunc = _calcParseIndexFunc(type);
@ -487,42 +489,12 @@ static inline void genElementsCommon(
GLuint j = indexFunc(idx); GLuint j = indexFunc(idx);
vertex->flags = PVR_CMD_VERTEX; vertex->flags = PVR_CMD_VERTEX;
vertexFunc(vertex->xyz, vptr + (j * vstride)); vertexFunc(vertex->xyz, vptr + (j * vstride));
}
idx = iptr;
vertex = output;
for(i = 0; i < count; ++i, idx += istride, ++vertex) {
GLuint j = indexFunc(idx);
diffuseFunc(vertex->bgra, cptr + (j * cstride)); diffuseFunc(vertex->bgra, cptr + (j * cstride));
}
if(doTexture) {
idx = iptr;
vertex = output;
for(i = 0; i < count; ++i, idx += istride, ++vertex) {
GLuint j = indexFunc(idx);
uvFunc(vertex->uv, uvptr + (j * uvstride)); uvFunc(vertex->uv, uvptr + (j * uvstride));
}
}
if(doMultitexture) {
idx = iptr;
vertex = output;
for(i = 0; i < count; ++i, idx += istride, ++vertex) {
GLuint j = indexFunc(idx);
stFunc(vertex->st, stptr + (j * ststride)); stFunc(vertex->st, stptr + (j * ststride));
}
}
if(doLighting) {
idx = iptr;
vertex = output;
for(i = 0; i < count; ++i, idx += istride, ++vertex) {
GLuint j = indexFunc(idx);
normalFunc(vertex->nxyz, nptr + (j * nstride)); normalFunc(vertex->nxyz, nptr + (j * nstride));
} }
} }
}
static inline void genElementsTriangles( static inline void genElementsTriangles(
ClipVertex* output, ClipVertex* output,

View File

@ -81,10 +81,6 @@ void named_array_release(NamedArray* array, unsigned int new_id) {
} }
void* named_array_get(NamedArray* array, unsigned int id) { void* named_array_get(NamedArray* array, unsigned int id) {
if(id == 0) {
return NULL;
}
if(!named_array_used(array, id)) { if(!named_array_used(array, id)) {
return NULL; return NULL;
} }