From ca8d27a1c25909cb1bbcb8851b84f00a2b3d13d0 Mon Sep 17 00:00:00 2001 From: Hayden Kowalchuk Date: Thu, 29 Aug 2019 09:40:30 -0400 Subject: [PATCH] fix: minor warning round and add burst draw --- GL/draw.c | 96 ++++++++++++++++++++----------------- GL/framebuffer.c | 5 ++ GL/glu.c | 10 ++++ GL/immediate.c | 1 + GL/private.h | 2 + GL/state.c | 45 +++++++++++------ GL/texture.c | 84 +++++++++++++++++++++++++++----- Makefile | 5 +- containers/aligned_vector.c | 8 ++++ 9 files changed, 185 insertions(+), 71 deletions(-) diff --git a/GL/draw.c b/GL/draw.c index a03edfc..c79e4c2 100644 --- a/GL/draw.c +++ b/GL/draw.c @@ -377,18 +377,34 @@ static void _fillZero2fVE(GLuint count, GLfloat* output) { #endif static void _readVertexData3usARGB(const GLushort* input, GLuint count, GLubyte stride, GLubyte* output) { + (void)input; + (void)count; + (void)stride; + (void)output; assert(0 && "Not Implemented"); } static void _readVertexData3uiARGB(const GLuint* input, GLuint count, GLubyte stride, GLubyte* output) { + (void)input; + (void)count; + (void)stride; + (void)output; assert(0 && "Not Implemented"); } static void _readVertexData4usARGB(const GLushort* input, GLuint count, GLubyte stride, GLubyte* output) { + (void)input; + (void)count; + (void)stride; + (void)output; assert(0 && "Not Implemented"); } static void _readVertexData4uiARGB(const GLuint* input, GLuint count, GLubyte stride, GLubyte* output) { + (void)input; + (void)count; + (void)stride; + (void)output; assert(0 && "Not Implemented"); } @@ -606,7 +622,7 @@ static inline void _readPositionData(const GLuint first, const GLuint count, Ver */ float offset = 0.01f * offset_factor + 0.001f * offset_units; - int i; + unsigned int i; for( i=0;iflags = 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); @@ -862,7 +841,6 @@ static void generate(SubmissionTarget* target, const GLenum mode, const GLsizei profiler_checkpoint("quads"); profiler_pop(); - } } else { const IndexParseFunc indexFunc = _calcParseIndexFunc(type); GLuint j; @@ -1053,6 +1031,8 @@ static void divide(SubmissionTarget* target) { static void push(PVRHeader* header, Vertex* output, const GLuint count, PolyList* activePolyList, GLshort textureUnit) { TRACE(); + (void)output; + (void)count; // Compile the header pvr_poly_cxt_t cxt = *_glGetPVRContext(); @@ -1144,9 +1124,6 @@ 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,(unsigned int)target->count); - } target->header_offset = target->output->vector.size; target->start_offset = target->header_offset + 1; @@ -1163,8 +1140,41 @@ static void submitVertices(GLenum mode, GLsizei first, GLuint count, GLenum type profiler_checkpoint("allocate"); - generate(target, mode, first, count, (GLubyte*) indices, type, doTexture, doMultitexture, doLighting); + 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); + + if(start->flags != 0 && (mode == GL_TRIANGLES || mode == GL_TRIANGLE_STRIP)){ + sq_cpy(start, VERTEX_POINTER.ptr - ( sizeof(unsigned int) * 1 ), count * sizeof(Vertex) ); + } else { + Vertex* it = start; + + sq_cpy(start, VERTEX_POINTER.ptr - ( sizeof(unsigned int) * 1 ), count * sizeof(Vertex) ); + ITERATE(count) { + it->flags = PVR_CMD_VERTEX; + ++it; + } + // 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"); + } + } + }else { + generate(target, mode, first, count, (GLubyte*) indices, type, doTexture, doMultitexture, doLighting); + } profiler_checkpoint("generate"); extern GLboolean LIGHTING_ENABLED; diff --git a/GL/framebuffer.c b/GL/framebuffer.c index 3fd44c2..7ab7995 100644 --- a/GL/framebuffer.c +++ b/GL/framebuffer.c @@ -61,6 +61,7 @@ void APIENTRY glDeleteFramebuffersEXT(GLsizei n, const GLuint* framebuffers) { } void APIENTRY glBindFramebufferEXT(GLenum target, GLuint framebuffer) { + (void)target; TRACE(); if(framebuffer) { @@ -74,6 +75,10 @@ void APIENTRY glBindFramebufferEXT(GLenum target, GLuint framebuffer) { } void APIENTRY glFramebufferTexture2DEXT(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) { + (void)target; + (void)attachment; + (void)textarget; + (void)level; if(texture != 0 && !glIsTexture(texture)) { _glKosThrowError(GL_INVALID_OPERATION, __func__); _glKosPrintError(); diff --git a/GL/glu.c b/GL/glu.c index 79e33b2..be92029 100644 --- a/GL/glu.c +++ b/GL/glu.c @@ -30,6 +30,16 @@ GLint APIENTRY gluScaleImage(GLenum format, GLsizei dst_width, GLsizei dst_height, GLenum dst_type, GLvoid *dst) { + (void) format; + (void) src_width; + (void) src_height; + (void) src_type; + (void) src; + (void) dst_width, + (void) dst_height; + (void) dst_type; + (void) dst; + #if 0 /* Calculate the format that we need to convert the data to */ GLuint dst_format = _determinePVRFormat(format, src_type); diff --git a/GL/immediate.c b/GL/immediate.c index 77b1919..6e6563e 100644 --- a/GL/immediate.c +++ b/GL/immediate.c @@ -165,6 +165,7 @@ void APIENTRY glVertex2fv(const GLfloat* v) { } void APIENTRY glVertex4f(GLfloat x, GLfloat y, GLfloat z, GLfloat w) { + (void) w; glVertex3f(x, y, z); } diff --git a/GL/private.h b/GL/private.h index 2065d5d..592e827 100644 --- a/GL/private.h +++ b/GL/private.h @@ -265,6 +265,8 @@ GLubyte _glKosHasError(); #define MAX_TEXTURE_UNITS 2 #define MAX_LIGHTS 8 +#define MAX(a,b) ((a) > (b) ? a : b) +#define MIN(a,b) ((a) < (b) ? a : b) #define CLAMP( X, MIN, MAX ) ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) ) #define mat_trans_fv12() { \ diff --git a/GL/state.c b/GL/state.c index a3d3de6..1e46fc8 100644 --- a/GL/state.c +++ b/GL/state.c @@ -137,7 +137,7 @@ static void _updatePVRBlend(pvr_poly_cxt_t* context) { GLboolean _glCheckValidEnum(GLint param, GLint* values, const char* func) { GLubyte found = 0; while(*values != 0) { - if(*values == (GLenum)param) { + if(*values == param) { /* Unsure about changing this: (GLenum)param */ found++; break; } @@ -203,26 +203,25 @@ void _glUpdatePVRTextureContext(pvr_poly_cxt_t* context, GLshort textureUnit) { } else { filter = PVR_FILTER_NEAREST; } + /* If we don't have complete mipmaps, and yet mipmapping was enabled, we disable texturing. + * This is effectively what standard GL does (it renders a white texture) + */ + if(!_glIsMipmapComplete(tx1) && enableMipmaps) { + context->txr.enable = PVR_TEXTURE_DISABLE; + context->txr.base = 0; + context->txr.format = 0; + return; + } } else { if(tx1->minFilter == GL_LINEAR && tx1->magFilter == GL_LINEAR) { filter = PVR_FILTER_BILINEAR; } } - /* If we don't have complete mipmaps, and yet mipmapping was enabled, we disable texturing. - * This is effectively what standard GL does (it renders a white texture) - */ - if(!_glIsMipmapComplete(tx1) && enableMipmaps) { - context->txr.enable = PVR_TEXTURE_DISABLE; - context->txr.base = 0; - context->txr.format = 0; - return; - } - if(tx1->data) { context->txr.enable = PVR_TEXTURE_ENABLE; context->txr.filter = filter; - context->txr.mipmap = (enableMipmaps) ? PVR_MIPMAP_ENABLE : PVR_MIPMAP_DISABLE; + context->txr.mipmap = enableMipmaps; context->txr.mipmap_bias = tx1->mipmap_bias; context->txr.width = tx1->width; context->txr.height = tx1->height; @@ -439,18 +438,22 @@ GLAPI void APIENTRY glClearColor(GLfloat r, GLfloat g, GLfloat b, GLfloat a) { /* Depth Testing */ GLAPI void APIENTRY glClearDepthf(GLfloat depth) { + (void) depth; } GLAPI void APIENTRY glClearDepth(GLfloat depth) { + (void) depth; } GLAPI void APIENTRY glDrawBuffer(GLenum mode) { + (void) mode; } GLAPI void APIENTRY glReadBuffer(GLenum mode) { + (void) mode; } @@ -517,6 +520,7 @@ GLAPI void APIENTRY glAlphaFunc(GLenum func, GLclampf ref) { } void glLineWidth(GLfloat width) { + (void) width; ; } @@ -526,14 +530,23 @@ void glPolygonOffset(GLfloat factor, GLfloat units) { } void glGetTexParameteriv(GLenum target, GLenum pname, GLint *params) { + (void) target; + (void) pname; + (void) params; ; } void glColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) { + (void) red; + (void) green; + (void) blue; + (void) alpha; ; } void glPixelStorei(GLenum pname, GLint param) { + (void) pname; + (void) param; ; } @@ -556,8 +569,10 @@ void APIENTRY glScissor(GLint x, GLint y, GLsizei width, GLsizei height) { PVRTileClipCommand *c = aligned_vector_extend(&_glActivePolyList()->vector, 1); GLint miny, maxx, maxy; - GLsizei gl_scissor_width = CLAMP(width, 0, vid_mode->width); - GLsizei gl_scissor_height = CLAMP(height, 0, vid_mode->height); + //GLsizei gl_scissor_width = CLAMP(width, 0, vid_mode->width ); + GLsizei gl_scissor_width = MAX( MIN(width, vid_mode->width), 0 ); + //GLsizei gl_scissor_height = CLAMP(height, 0, vid_mode->height); + GLsizei gl_scissor_height = MAX( MIN(height, vid_mode->height), 0 ); /* force the origin to the lower left-hand corner of the screen */ miny = (vid_mode->height - gl_scissor_height) - y; @@ -603,7 +618,7 @@ static GLenum COMPRESSED_FORMATS [] = { GL_COMPRESSED_RGB_565_VQ_TWID_KOS }; -static GLint NUM_COMPRESSED_FORMATS = sizeof(COMPRESSED_FORMATS) / sizeof(GLenum); +static GLuint NUM_COMPRESSED_FORMATS = sizeof(COMPRESSED_FORMATS) / sizeof(GLenum); void APIENTRY glGetBooleanv(GLenum pname, GLboolean* params) { GLuint enabledAttrs = *_glGetEnabledAttributes(); diff --git a/GL/texture.c b/GL/texture.c index 1131889..f3a5db5 100644 --- a/GL/texture.c +++ b/GL/texture.c @@ -13,8 +13,6 @@ #define CLAMP_U (1<<1) #define CLAMP_V (1<<0) -#define MAX(x, y) ((x > y) ? x : y) - static TextureObject* TEXTURE_UNITS[MAX_TEXTURE_UNITS] = {NULL, NULL}; static NamedArray TEXTURE_OBJECTS; GLubyte ACTIVE_TEXTURE = 0; @@ -170,6 +168,7 @@ GLubyte* _glGetMipmapLocation(TextureObject* obj, GLuint level) { switch(size >> level){ case 1024: offset = 0x55558; + break; case 512: offset = 0x15558; break; @@ -206,6 +205,7 @@ GLubyte* _glGetMipmapLocation(TextureObject* obj, GLuint level) { switch(size >> level){ case 1024: offset = 0x15556; + break; case 512: offset = 0x05556; break; @@ -242,6 +242,7 @@ GLubyte* _glGetMipmapLocation(TextureObject* obj, GLuint level) { switch(size >> level){ case 1024: offset = 0xAAAB0; + break; case 512: offset = 0x2AAB0; break; @@ -886,7 +887,7 @@ GLboolean _glIsMipmapComplete(const TextureObject* obj) { } GLsizei i = 0; - for(; i < obj->mipmapCount-3; ++i) { + for(; i < (GLubyte)(obj->mipmapCount-3); ++i) { if((obj->mipmap & (1 << i)) == 1) { return GL_TRUE; } @@ -899,7 +900,6 @@ GLboolean _glIsMipmapComplete(const TextureObject* obj) { ((x&32)<<5)|((x&64)<<6)|((x&128)<<7)|((x&256)<<8)|((x&512)<<9) ) #define TWIDOUT(x, y) ( TWIDTAB((y)) | (TWIDTAB((x)) << 1) ) -#define MIN(a, b) ( (a)<(b)? (a):(b) ) void APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalFormat, @@ -932,8 +932,8 @@ void APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalFormat, } } - GLint w = width; - GLint h = height; + GLuint w = width; + GLuint h = height; if(level == 0){ if((w < 8 || (w & -w) != w)) { /* Width is not a power of two. Must be!*/ @@ -1325,21 +1325,37 @@ GLAPI void APIENTRY glColorTableEXT(GLenum target, GLenum internalFormat, GLsize } GLAPI void APIENTRY glColorSubTableEXT(GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data) { + (void) target; + (void) start; + (void) count; + (void) format; + (void) type; + (void) data; _glKosThrowError(GL_INVALID_OPERATION, __func__); _glKosPrintError(); } GLAPI void APIENTRY glGetColorTableEXT(GLenum target, GLenum format, GLenum type, GLvoid *data) { + (void) target; + (void) format; + (void) type; + (void) data; _glKosThrowError(GL_INVALID_OPERATION, __func__); _glKosPrintError(); } GLAPI void APIENTRY glGetColorTableParameterivEXT(GLenum target, GLenum pname, GLint *params) { + (void) target; + (void) pname; + (void) params; _glKosThrowError(GL_INVALID_OPERATION, __func__); _glKosPrintError(); } GLAPI void APIENTRY glGetColorTableParameterfvEXT(GLenum target, GLenum pname, GLfloat *params) { + (void) target; + (void) pname; + (void) params; _glKosThrowError(GL_INVALID_OPERATION, __func__); _glKosPrintError(); } @@ -1347,24 +1363,70 @@ GLAPI void APIENTRY glGetColorTableParameterfvEXT(GLenum target, GLenum pname, G GLAPI void APIENTRY glTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels) { + (void) target; + (void) level; + (void) xoffset; + (void) yoffset; + (void) width; + (void) height; + (void) format; + (void) type; + (void) pixels; + assert(0 && "Not Implemented"); } GLAPI void APIENTRY glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) { - + (void) target; + (void) level; + (void) xoffset; + (void) yoffset; + (void) x; + (void) y; + (void) width; + (void) height; + assert(0 && "Not Implemented"); } GLAPI void APIENTRY glCopyTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width) { - + (void) target; + (void) level; + (void) xoffset; + (void) x; + (void) y; + (void) width; + assert(0 && "Not Implemented"); } GLAPI void APIENTRY glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) { - + (void) target; + (void) level; + (void) internalformat; + (void) x; + (void) y; + (void) width; + (void) height; + (void) border; + assert(0 && "Not Implemented"); } GLAPI void APIENTRY glCopyTexImage1D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border) { - + (void) target; + (void) level; + (void) internalformat; + (void) x; + (void) y; + (void) width; + (void) border; + assert(0 && "Not Implemented"); } GLAPI void APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) { - + (void) x; + (void) y; + (void) width; + (void) height; + (void) format; + (void) type; + (void) pixels; + assert(0 && "Not Implemented"); } diff --git a/Makefile b/Makefile index b507865..bf9040e 100644 --- a/Makefile +++ b/Makefile @@ -13,8 +13,9 @@ OBJS += containers/stack.o containers/named_array.o containers/aligned_vector.o SUBDIRS = -KOS_CFLAGS += -ffast-math -O3 -funroll-loops -Iinclude -funsafe-math-optimizations -fno-expensive-optimizations -GCC_FLAGS = -mlra +KOS_CFLAGS += -ffast-math -O2 -funroll-loops -fsingle-precision-constant -Iinclude -funsafe-math-optimizations -DBUILD_LIBGL -Wall -Wextra +#KOS_CFLAGS += -O1 -mlra -Iinclude -DBUILD_LIBGL -Wall -Wextra +#GCC5_FLAGS = -mfsca -mfsrra -mlra # Manipulate the CFLAGS to look our *our* version of the library and includes INC_DIR = $(abspath ./include) diff --git a/containers/aligned_vector.c b/containers/aligned_vector.c index 55ddc7e..a949310 100644 --- a/containers/aligned_vector.c +++ b/containers/aligned_vector.c @@ -102,6 +102,14 @@ void* aligned_vector_resize(AlignedVector* vector, const unsigned int element_co } void* aligned_vector_at(const AlignedVector* vector, const unsigned int index) { + #if 0 + if(index >= vector->size){ + char msg[60]; + sprintf(msg, "Vector OOB: %d %d wanted %d\n", vector->capacity, vector->size, index); + //aligned_vector_resize(vector, index); + assert_msg(index < vector->size, msg); + } + #endif assert(index < vector->size); return &vector->data[index * vector->element_size]; }