fix all the previous crap.
holy hell
This commit is contained in:
parent
944f911d41
commit
4a9336f584
20
GL/draw.c
20
GL/draw.c
|
@ -1065,7 +1065,7 @@ static void submitVertices(GLenum mode, GLsizei first, GLuint count, GLenum type
|
|||
|
||||
glActiveTextureARB(activeTexture);
|
||||
|
||||
PROFILER_PUSH(__func__);
|
||||
profiler_push(__func__);
|
||||
|
||||
/* Polygons are treated as triangle fans, the only time this would be a
|
||||
* problem is if we supported glPolygonMode(..., GL_LINE) but we don't.
|
||||
|
@ -1103,19 +1103,19 @@ static void submitVertices(GLenum mode, GLsizei first, GLuint count, GLenum type
|
|||
/* Make room for the vertices and header */
|
||||
aligned_vector_extend(&target->output->vector, target->count + 1);
|
||||
|
||||
PROFILER_CHECKPOINT("allocate");
|
||||
profiler_checkpoint("allocate");
|
||||
|
||||
generate(target, mode, first, count, (GLubyte*) indices, type, doTexture, doMultitexture, doLighting);
|
||||
|
||||
PROFILER_CHECKPOINT("generate");
|
||||
profiler_checkpoint("generate");
|
||||
|
||||
light(target);
|
||||
|
||||
PROFILER_CHECKPOINT("light");
|
||||
profiler_checkpoint("light");
|
||||
|
||||
transform(target);
|
||||
|
||||
PROFILER_CHECKPOINT("transform");
|
||||
profiler_checkpoint("transform");
|
||||
|
||||
if(_glIsClippingEnabled()) {
|
||||
#if DEBUG_CLIPPING
|
||||
|
@ -1150,15 +1150,15 @@ static void submitVertices(GLenum mode, GLsizei first, GLuint count, GLenum type
|
|||
|
||||
}
|
||||
|
||||
PROFILER_CHECKPOINT("clip");
|
||||
profiler_checkpoint("clip");
|
||||
|
||||
divide(target);
|
||||
|
||||
PROFILER_CHECKPOINT("divide");
|
||||
profiler_checkpoint("divide");
|
||||
|
||||
push(_glSubmissionTargetHeader(target), _glSubmissionTargetStart(target), target->count, target->output, 0);
|
||||
|
||||
PROFILER_CHECKPOINT("push");
|
||||
profiler_checkpoint("push");
|
||||
/*
|
||||
Now, if multitexturing is enabled, we want to send exactly the same vertices again, except:
|
||||
- We want to enable blending, and send them to the TR list
|
||||
|
@ -1169,7 +1169,7 @@ static void submitVertices(GLenum mode, GLsizei first, GLuint count, GLenum type
|
|||
|
||||
if(!doMultitexture) {
|
||||
/* Multitexture actively disabled */
|
||||
PROFILER_POP();
|
||||
profiler_pop();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1298,7 +1298,7 @@ void APIENTRY glDisableClientState(GLenum cap) {
|
|||
(ENABLED_VERTEX_ATTRIBUTES &= ~UV_ENABLED_FLAG);
|
||||
break;
|
||||
default:
|
||||
_glKosThrowError(GL_INVALID_ENUM, __func__);
|
||||
_glKosThrowError(GL_INVALID_ENUM, __func__);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ void _glKosPrintError() {
|
|||
}
|
||||
|
||||
fprintf(stderr, "GL ERROR: %s when calling %s\n", _glErrorEnumAsString(last_error), error_function);
|
||||
_glKosResetError();
|
||||
_glKosResetError();
|
||||
}
|
||||
|
||||
GLenum glGetError(void) {
|
||||
|
|
33
GL/flush.c
33
GL/flush.c
|
@ -120,14 +120,13 @@ void APIENTRY glKosInit() {
|
|||
}
|
||||
|
||||
#define QACRTA ((((unsigned int)0x10000000)>>26)<<2)&0x1c
|
||||
static int frame_count = 0;
|
||||
|
||||
void APIENTRY glKosSwapBuffers() {
|
||||
|
||||
|
||||
static int frame_count = 0;
|
||||
|
||||
TRACE();
|
||||
|
||||
PROFILER_PUSH(__func__);
|
||||
profiler_push(__func__);
|
||||
|
||||
pvr_wait_ready();
|
||||
|
||||
|
@ -152,29 +151,11 @@ void APIENTRY glKosSwapBuffers() {
|
|||
aligned_vector_clear(&PT_LIST.vector);
|
||||
aligned_vector_clear(&TR_LIST.vector);
|
||||
|
||||
PROFILER_CHECKPOINT("scene");
|
||||
PROFILER_POP();
|
||||
profiler_checkpoint("scene");
|
||||
profiler_pop();
|
||||
|
||||
#if PROFILER_COMPILE
|
||||
if(++frame_count > 49) {
|
||||
PROFILER_PRINT_STATS();
|
||||
if(frame_count++ > 100) {
|
||||
profiler_print_stats();
|
||||
frame_count = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void APIENTRY glKosReserveOPList(unsigned int elements){
|
||||
aligned_vector_reserve(&OP_LIST.vector, elements);
|
||||
aligned_vector_reserve((AlignedVector*)_glKosINTERNALGetVertices(), elements/3);
|
||||
}
|
||||
|
||||
void APIENTRY glKosReservePTList(unsigned int elements){
|
||||
aligned_vector_reserve(&PT_LIST.vector, elements);
|
||||
aligned_vector_reserve((AlignedVector*)_glKosINTERNALGetVertices(), elements/3);
|
||||
}
|
||||
|
||||
void APIENTRY glKosReserveTRList(unsigned int elements){
|
||||
aligned_vector_reserve(&TR_LIST.vector, elements);
|
||||
aligned_vector_reserve((AlignedVector*)_glKosINTERNALGetVertices(), elements/3);
|
||||
}
|
||||
|
|
|
@ -296,8 +296,3 @@ void APIENTRY glRecti(GLint x1, GLint y1, GLint x2, GLint y2) {
|
|||
void APIENTRY glRectiv(const GLint *v1, const GLint *v2) {
|
||||
return glRectfv((const GLfloat *)v1, (const GLfloat *)v2);
|
||||
}
|
||||
|
||||
|
||||
AlignedVector* APIENTRY _glKosINTERNALGetVertices(){
|
||||
return &VERTICES;
|
||||
}
|
|
@ -1,16 +1,11 @@
|
|||
|
||||
#include <kos.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "profiler.h"
|
||||
#include "private.h"
|
||||
#if PROFILER_COMPILE
|
||||
#include "../containers/aligned_vector.h"
|
||||
|
||||
#ifdef PROFILER_COMPILE
|
||||
|
||||
#define MAX_PATH 256
|
||||
|
||||
typedef struct {
|
||||
|
@ -29,7 +24,7 @@ typedef struct {
|
|||
|
||||
static RootProfiler* root = NULL;
|
||||
|
||||
static char PROFILER_ENABLED = PROFILER_COMPILE;
|
||||
static char PROFILER_ENABLED = 0;
|
||||
|
||||
void profiler_enable() {
|
||||
PROFILER_ENABLED = 1;
|
||||
|
@ -131,24 +126,18 @@ void profiler_pop() {
|
|||
|
||||
aligned_vector_resize(&root->stack, root->stack.size - 1);
|
||||
}
|
||||
#include <inttypes.h>
|
||||
|
||||
void profiler_print_stats() {
|
||||
if(!PROFILER_ENABLED) return;
|
||||
|
||||
fprintf(stderr, "%-40s%-20s%-20s%-20s%-20s\n", "Path", "Time(ms)", "Average", "Total", "Calls");
|
||||
float total_ms = 0;
|
||||
float fps = 0;
|
||||
fprintf(stderr, "%-60s%-20s%-20s%-20s\n", "Path", "Average", "Total", "Calls");
|
||||
|
||||
uint16_t i = 0;
|
||||
for(; i < root->results.size; ++i) {
|
||||
ProfilerResult* result = aligned_vector_at(&root->results, i);
|
||||
float ms = ((float) result->total_time_us) / 1000.0f;
|
||||
float avg = ms / (float) result->total_calls;
|
||||
total_ms += ms;
|
||||
|
||||
fprintf(stderr, "%-60s%-20f%-20f%" PRIu64 "\n", result->name, (double)avg, (double)ms, result->total_calls);
|
||||
}
|
||||
total_ms/=((ProfilerResult*)aligned_vector_at(&root->results, i-1))->total_calls;
|
||||
fps = 1000/total_ms;
|
||||
fprintf(stderr, "%-10s%-10f%-10s%-10f\n", "Time(ms)", total_ms, "FPS", fps);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -2,15 +2,6 @@
|
|||
|
||||
#include <stdint.h>
|
||||
|
||||
#define PROFILER_COMPILE 0
|
||||
#if PROFILER_COMPILE
|
||||
#define PROFILER_PUSH(S) profiler_push(S)
|
||||
#define PROFILER_CHECKPOINT(P) profiler_checkpoint(P)
|
||||
#define PROFILER_POP() profiler_pop()
|
||||
#define PROFILER_PRINT_STATS() profiler_print_stats()
|
||||
void profiler_enable();
|
||||
void profiler_disable();
|
||||
|
||||
typedef struct {
|
||||
char name[64];
|
||||
uint64_t start_time_in_us;
|
||||
|
@ -22,9 +13,6 @@ void profiler_checkpoint(const char* name);
|
|||
void profiler_pop();
|
||||
|
||||
void profiler_print_stats();
|
||||
#else
|
||||
#define PROFILER_PUSH(S)
|
||||
#define PROFILER_CHECKPOINT(P)
|
||||
#define PROFILER_POP()
|
||||
#define PROFILER_PRINT_STATS()
|
||||
#endif
|
||||
|
||||
void profiler_enable();
|
||||
void profiler_disable();
|
||||
|
|
10
GL/texture.c
10
GL/texture.c
|
@ -36,9 +36,6 @@ static GLenum INTERNAL_PALETTE_FORMAT = GL_RGBA4;
|
|||
static TexturePalette* _initTexturePalette() {
|
||||
TexturePalette* palette = (TexturePalette*) malloc(sizeof(TexturePalette));
|
||||
assert(palette);
|
||||
|
||||
//memset(palette, 0x0, sizeof(TexturePalette));
|
||||
sq_clr(palette, (sizeof(TexturePalette) & 0xfffffffc) + 4);
|
||||
|
||||
memset(palette, 0x0, sizeof(TexturePalette));
|
||||
palette->bank = -1;
|
||||
|
@ -402,7 +399,7 @@ void APIENTRY glBindTexture(GLenum target, GLuint texture) {
|
|||
}
|
||||
}
|
||||
|
||||
void APIENTRY glTexEnvi(GLenum target, GLenum pname, GLenum param) {
|
||||
void APIENTRY glTexEnvi(GLenum target, GLenum pname, GLint param) {
|
||||
TRACE();
|
||||
|
||||
GLint target_values [] = {GL_TEXTURE_ENV, 0};
|
||||
|
@ -832,11 +829,12 @@ GLboolean _glIsMipmapComplete(const TextureObject* obj) {
|
|||
}
|
||||
|
||||
#define TWIDTAB(x) ( (x&1)|((x&2)<<1)|((x&4)<<2)|((x&8)<<3)|((x&16)<<4)| \
|
||||
((x&32)<<5)|((x&64)<<6)|((x&128)<<7)|((x&256)<<8)|((x&512)<<9) )
|
||||
#define TWIDOUT(x, y) ( TWIDTAB((y)) | (TWIDTAB((x)) << 1) )
|
||||
((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,
|
||||
GLsizei width, GLsizei height, GLint border,
|
||||
GLenum format, GLenum type, const GLvoid *data) {
|
||||
|
|
|
@ -41,8 +41,7 @@ void aligned_vector_reserve(AlignedVector* vector, unsigned int element_count) {
|
|||
if(element_count <= vector->capacity) {
|
||||
return;
|
||||
}
|
||||
element_count = ((element_count+_VECTOR_ALIGN_COUNT) & ~_VECTOR_ALIGN_COUNT);
|
||||
|
||||
|
||||
unsigned int original_byte_size = vector->size * vector->element_size;
|
||||
|
||||
/* We overallocate so that we don't make small allocations during push backs */
|
||||
|
@ -55,14 +54,7 @@ void aligned_vector_reserve(AlignedVector* vector, unsigned int element_count) {
|
|||
assert(vector->data);
|
||||
|
||||
if(original_data) {
|
||||
if( !(*vector->data % 32) && !(*original_data % 32)){
|
||||
if (original_byte_size % 4)
|
||||
original_byte_size = (original_byte_size & 0xfffffffc) + 4;
|
||||
sq_cpy(vector->data, original_data, original_byte_size);
|
||||
} else {
|
||||
memcpy(vector->data, original_data, original_byte_size);
|
||||
}
|
||||
|
||||
memcpy(vector->data, original_data, original_byte_size);
|
||||
free(original_data);
|
||||
}
|
||||
|
||||
|
@ -83,7 +75,6 @@ void* aligned_vector_push_back(AlignedVector* vector, const void* objs, unsigned
|
|||
|
||||
/* Copy the objects in */
|
||||
memcpy(dest, objs, vector->element_size * count);
|
||||
//sq_cpy(dest, objs, ((vector->element_size * count) & 0xfffffffc) + 4);
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
@ -141,8 +132,6 @@ void aligned_vector_shrink_to_fit(AlignedVector* vector) {
|
|||
|
||||
if(original_data) {
|
||||
memcpy(vector->data, original_data, new_byte_size);
|
||||
//sq_cpy(vector->data, original_data, ((new_byte_size) & 0xfffffffc) + 4);
|
||||
|
||||
free(original_data);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ void named_array_init(NamedArray* array, unsigned int element_size, unsigned int
|
|||
char named_array_used(NamedArray* array, unsigned int id) {
|
||||
unsigned int i = id / 8;
|
||||
unsigned int j = id % 8;
|
||||
|
||||
|
||||
unsigned char v = array->used_markers[i] & (unsigned char) (1 << j);
|
||||
return !!(v);
|
||||
}
|
||||
|
@ -60,9 +60,7 @@ void* named_array_alloc(NamedArray* array, unsigned int* new_id) {
|
|||
array->used_markers[i] |= (unsigned char) 1 << j;
|
||||
*new_id = id;
|
||||
unsigned char* ptr = &array->elements[id * array->element_size];
|
||||
|
||||
//memset(ptr, 0, array->element_size);
|
||||
sq_clr(ptr, (array->element_size & 0xfffffffc) + 4);
|
||||
memset(ptr, 0, array->element_size);
|
||||
return ptr;
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +73,8 @@ void* named_array_reserve(NamedArray* array, unsigned int id) {
|
|||
if(!named_array_used(array, id)) {
|
||||
unsigned int j = (id % 8);
|
||||
unsigned int i = id / 8;
|
||||
|
||||
|
||||
assert(!named_array_used(array, id));
|
||||
array->used_markers[i] |= (unsigned char) 1 << j;
|
||||
|
||||
assert__(named_array_used(array, id)) {
|
||||
|
@ -85,8 +84,7 @@ void* named_array_reserve(NamedArray* array, unsigned int id) {
|
|||
assert(named_array_used(array, id));
|
||||
|
||||
unsigned char* ptr = &array->elements[id * array->element_size];
|
||||
//memset(ptr, 0, array->element_size);
|
||||
sq_clr(ptr, (array->element_size & 0xfffffffc) + 4);
|
||||
memset(ptr, 0, array->element_size);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -485,9 +485,8 @@ GLAPI void APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor);
|
|||
|
||||
/* Texturing */
|
||||
GLAPI void APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param);
|
||||
GLAPI void APIENTRY glTexEnvi(GLenum target, GLenum pname, GLenum param);
|
||||
#define glTexEnvf(target, pname, param) glTexEnvi(target, pname, param)
|
||||
//GLAPI void APIENTRY glTexEnvf(GLenum target, GLenum pname, GLenum param);
|
||||
GLAPI void APIENTRY glTexEnvi(GLenum target, GLenum pname, GLint param);
|
||||
GLAPI void APIENTRY glTexEnvf(GLenum target, GLenum pname, GLfloat param);
|
||||
|
||||
GLAPI GLboolean APIENTRY glIsTexture(GLuint texture);
|
||||
GLAPI void APIENTRY glGenTextures(GLsizei n, GLuint *textures);
|
||||
|
|
|
@ -96,9 +96,5 @@ GLAPI void APIENTRY glKOS_INTERNAL_SetMipmapBias(GLubyte level);
|
|||
/* Pass to glTexParameteri to set the shared bank */
|
||||
#define GL_SHARED_TEXTURE_BANK_KOS 0xEF00
|
||||
|
||||
GLAPI void APIENTRY glKosReserveOPList(unsigned int elements);
|
||||
GLAPI void APIENTRY glKosReservePTList(unsigned int elements);
|
||||
GLAPI void APIENTRY glKosReserveTRList(unsigned int elements);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user