fix: minor warning round and add burst draw

This commit is contained in:
Hayden Kowalchuk 2019-08-29 09:40:30 -04:00
parent 924c3f16ea
commit ca8d27a1c2
9 changed files with 185 additions and 71 deletions

View File

@ -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;i<count;i++) {
output[i].xyz[2] = output[i].xyz[2]+offset;
}
@ -773,43 +789,6 @@ 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.ptr - VERTEX_POINTER.ptr) == (sizeof(GLfloat) * 5)){
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);
@ -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;

View File

@ -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();

View File

@ -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);

View File

@ -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);
}

View File

@ -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() { \

View File

@ -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();

View File

@ -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");
}

View File

@ -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)

View File

@ -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];
}