Clean ups and optimisations
This commit is contained in:
parent
4edf8ce04d
commit
0b62ac8673
102
GL/draw.c
102
GL/draw.c
|
@ -3,7 +3,6 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "private.h"
|
||||
#include "platform.h"
|
||||
|
@ -260,37 +259,37 @@ static void _fillZero2f(const GLubyte* __restrict__ input, GLubyte* __restrict__
|
|||
static void _readVertexData3usARGB(const GLubyte* input, GLubyte* output) {
|
||||
_GL_UNUSED(input);
|
||||
_GL_UNUSED(output);
|
||||
assert(0 && "Not Implemented");
|
||||
gl_assert(0 && "Not Implemented");
|
||||
}
|
||||
|
||||
static void _readVertexData3uiARGB(const GLubyte* input, GLubyte* output) {
|
||||
_GL_UNUSED(input);
|
||||
_GL_UNUSED(output);
|
||||
assert(0 && "Not Implemented");
|
||||
gl_assert(0 && "Not Implemented");
|
||||
}
|
||||
|
||||
static void _readVertexData4usARGB(const GLubyte* input, GLubyte* output) {
|
||||
_GL_UNUSED(input);
|
||||
_GL_UNUSED(output);
|
||||
assert(0 && "Not Implemented");
|
||||
gl_assert(0 && "Not Implemented");
|
||||
}
|
||||
|
||||
static void _readVertexData4uiARGB(const GLubyte* input, GLubyte* output) {
|
||||
_GL_UNUSED(input);
|
||||
_GL_UNUSED(output);
|
||||
assert(0 && "Not Implemented");
|
||||
gl_assert(0 && "Not Implemented");
|
||||
}
|
||||
|
||||
static void _readVertexData4usRevARGB(const GLubyte* input, GLubyte* output) {
|
||||
_GL_UNUSED(input);
|
||||
_GL_UNUSED(output);
|
||||
assert(0 && "Not Implemented");
|
||||
gl_assert(0 && "Not Implemented");
|
||||
}
|
||||
|
||||
static void _readVertexData4uiRevARGB(const GLubyte* input, GLubyte* output) {
|
||||
_GL_UNUSED(input);
|
||||
_GL_UNUSED(output);
|
||||
assert(0 && "Not Implemented");
|
||||
gl_assert(0 && "Not Implemented");
|
||||
}
|
||||
|
||||
GLuint* _glGetEnabledAttributes() {
|
||||
|
@ -394,12 +393,12 @@ GL_FORCE_INLINE void transformNormalToEyeSpace(GLfloat* normal) {
|
|||
}
|
||||
|
||||
GL_FORCE_INLINE PolyHeader *_glSubmissionTargetHeader(SubmissionTarget* target) {
|
||||
assert(target->header_offset < target->output->vector.size);
|
||||
gl_assert(target->header_offset < target->output->vector.size);
|
||||
return aligned_vector_at(&target->output->vector, target->header_offset);
|
||||
}
|
||||
|
||||
GL_INLINE_DEBUG Vertex* _glSubmissionTargetStart(SubmissionTarget* target) {
|
||||
assert(target->start_offset < target->output->vector.size);
|
||||
gl_assert(target->start_offset < target->output->vector.size);
|
||||
return aligned_vector_at(&target->output->vector, target->start_offset);
|
||||
}
|
||||
|
||||
|
@ -438,7 +437,7 @@ GL_FORCE_INLINE void genTriangleStrip(Vertex* output, GLuint count) {
|
|||
}
|
||||
|
||||
static void genTriangleFan(Vertex* output, GLuint count) {
|
||||
assert(count <= 255);
|
||||
gl_assert(count <= 255);
|
||||
|
||||
Vertex* dst = output + (((count - 2) * 3) - 1);
|
||||
Vertex* src = output + (count - 1);
|
||||
|
@ -583,74 +582,60 @@ ReadNormalFunc calcReadNormalFunc() {
|
|||
}
|
||||
}
|
||||
|
||||
static void _readPositionData(ReadDiffuseFunc func, const GLuint first, const GLuint count, const Vertex* output) {
|
||||
static void _readPositionData(ReadDiffuseFunc func, const GLuint first, const GLuint count, Vertex* it) {
|
||||
const GLsizei vstride = ATTRIB_POINTERS.vertex.stride;
|
||||
const GLubyte* vptr = ((GLubyte*) ATTRIB_POINTERS.vertex.ptr + (first * vstride));
|
||||
|
||||
GLubyte* out = (GLubyte*) output[0].xyz;
|
||||
uint32_t* flags;
|
||||
float pos[3];
|
||||
float w = 0.0f;
|
||||
|
||||
ITERATE(count) {
|
||||
PREFETCH(vptr + vstride);
|
||||
func(vptr, (GLubyte*) pos);
|
||||
it->flags = GPU_CMD_VERTEX;
|
||||
|
||||
TransformVertex((const float*) pos, &w, it->xyz, &it->w);
|
||||
|
||||
func(vptr, out);
|
||||
vptr += vstride;
|
||||
|
||||
/* Set the flags which are 4 bytes before the position. Doing it here saves
|
||||
* an additional loop */
|
||||
flags = (uint32_t*) out - 1;
|
||||
*flags = GPU_CMD_VERTEX;
|
||||
|
||||
out += sizeof(Vertex);
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
static void _readUVData(ReadUVFunc func, const GLuint first, const GLuint count, const Vertex* output) {
|
||||
static void _readUVData(ReadUVFunc func, const GLuint first, const GLuint count, Vertex* it) {
|
||||
const GLsizei uvstride = ATTRIB_POINTERS.uv.stride;
|
||||
const GLubyte* uvptr = ((GLubyte*) ATTRIB_POINTERS.uv.ptr + (first * uvstride));
|
||||
|
||||
GLubyte* out = (GLubyte*) output[0].uv;
|
||||
|
||||
ITERATE(count) {
|
||||
PREFETCH(uvptr + uvstride);
|
||||
|
||||
func(uvptr, out);
|
||||
func(uvptr, (GLubyte*) it->uv);
|
||||
uvptr += uvstride;
|
||||
out += sizeof(Vertex);
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
static void _readSTData(ReadUVFunc func, const GLuint first, const GLuint count, const VertexExtra* extra) {
|
||||
static void _readSTData(ReadUVFunc func, const GLuint first, const GLuint count, VertexExtra* it) {
|
||||
const GLsizei ststride = ATTRIB_POINTERS.st.stride;
|
||||
const GLubyte* stptr = ((GLubyte*) ATTRIB_POINTERS.st.ptr + (first * ststride));
|
||||
|
||||
GLubyte* out = (GLubyte*) extra[0].st;
|
||||
|
||||
ITERATE(count) {
|
||||
PREFETCH(stptr + ststride);
|
||||
|
||||
func(stptr, out);
|
||||
func(stptr, (GLubyte*) it->st);
|
||||
stptr += ststride;
|
||||
out += sizeof(VertexExtra);
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
static void _readNormalData(ReadNormalFunc func, const GLuint first, const GLuint count, const VertexExtra* extra) {
|
||||
static void _readNormalData(ReadNormalFunc func, const GLuint first, const GLuint count, VertexExtra* it) {
|
||||
const GLsizei nstride = ATTRIB_POINTERS.normal.stride;
|
||||
const GLubyte* nptr = ((GLubyte*) ATTRIB_POINTERS.normal.ptr + (first * nstride));
|
||||
|
||||
GLubyte* out = (GLubyte*) extra[0].nxyz;
|
||||
|
||||
ITERATE(count) {
|
||||
func(nptr, out);
|
||||
func(nptr, (GLubyte*) it->nxyz);
|
||||
nptr += nstride;
|
||||
out += sizeof(VertexExtra);
|
||||
}
|
||||
|
||||
if(_glIsNormalizeEnabled()) {
|
||||
GLubyte* ptr = (GLubyte*) extra->nxyz;
|
||||
ITERATE(count) {
|
||||
GLfloat* n = (GLfloat*) ptr;
|
||||
if(_glIsNormalizeEnabled()) {
|
||||
GLfloat* n = (GLfloat*) it->nxyz;
|
||||
float temp = n[0] * n[0];
|
||||
temp = MATH_fmac(n[1], n[1], temp);
|
||||
temp = MATH_fmac(n[2], n[2], temp);
|
||||
|
@ -659,9 +644,9 @@ static void _readNormalData(ReadNormalFunc func, const GLuint first, const GLuin
|
|||
n[0] *= ilength;
|
||||
n[1] *= ilength;
|
||||
n[2] *= ilength;
|
||||
|
||||
ptr += sizeof(VertexExtra);
|
||||
}
|
||||
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -669,18 +654,15 @@ GL_FORCE_INLINE GLuint diffusePointerSize() {
|
|||
return (ATTRIB_POINTERS.colour.size == GL_BGRA) ? 4 : ATTRIB_POINTERS.colour.size;
|
||||
}
|
||||
|
||||
static void _readDiffuseData(ReadDiffuseFunc func, const GLuint first, const GLuint count, const Vertex* output) {
|
||||
static void _readDiffuseData(ReadDiffuseFunc func, const GLuint first, const GLuint count, Vertex* it) {
|
||||
const GLuint cstride = ATTRIB_POINTERS.colour.stride;
|
||||
const GLubyte* cptr = ((GLubyte*) ATTRIB_POINTERS.colour.ptr) + (first * cstride);
|
||||
|
||||
GLubyte* out = (GLubyte*) output[0].bgra;
|
||||
|
||||
ITERATE(count) {
|
||||
PREFETCH(cptr + cstride);
|
||||
|
||||
func(cptr, out);
|
||||
func(cptr, it->bgra);
|
||||
cptr += cstride;
|
||||
out += sizeof(Vertex);
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -864,11 +846,11 @@ static void generateArrays(SubmissionTarget* target, const GLsizei first, const
|
|||
Vertex* start = _glSubmissionTargetStart(target);
|
||||
VertexExtra* ve = aligned_vector_at(target->extras, 0);
|
||||
|
||||
ReadPositionFunc pfunc = calcReadPositionFunc();
|
||||
ReadDiffuseFunc dfunc = calcReadDiffuseFunc();
|
||||
ReadUVFunc uvfunc = calcReadUVFunc();
|
||||
ReadNormalFunc nfunc = calcReadNormalFunc();
|
||||
ReadUVFunc stfunc = calcReadSTFunc();
|
||||
const ReadPositionFunc pfunc = calcReadPositionFunc();
|
||||
const ReadDiffuseFunc dfunc = calcReadDiffuseFunc();
|
||||
const ReadUVFunc uvfunc = calcReadUVFunc();
|
||||
const ReadNormalFunc nfunc = calcReadNormalFunc();
|
||||
const ReadUVFunc stfunc = calcReadSTFunc();
|
||||
|
||||
_readPositionData(pfunc, first, count, start);
|
||||
_readDiffuseData(dfunc, first, count, start);
|
||||
|
@ -920,7 +902,7 @@ static void generate(SubmissionTarget* target, const GLenum mode, const GLsizei
|
|||
genTriangleStrip(it, count);
|
||||
break;
|
||||
default:
|
||||
assert(0 && "Not Implemented");
|
||||
gl_assert(0 && "Not Implemented");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1042,7 +1024,7 @@ GL_FORCE_INLINE void push(PolyHeader* header, GLboolean multiTextureHeader, Poly
|
|||
_glUpdatePVRTextureContext(&cxt, textureUnit);
|
||||
|
||||
if(multiTextureHeader) {
|
||||
assert(cxt.list_type == GPU_LIST_TR_POLY);
|
||||
gl_assert(cxt.list_type == GPU_LIST_TR_POLY);
|
||||
|
||||
cxt.gen.alpha = GPU_ALPHA_ENABLE;
|
||||
cxt.txr.alpha = GPU_TXRALPHA_ENABLE;
|
||||
|
@ -1117,14 +1099,14 @@ GL_FORCE_INLINE void submitVertices(GLenum mode, GLsizei first, GLuint count, GL
|
|||
}
|
||||
|
||||
// We don't handle this any further, so just make sure we never pass it down */
|
||||
assert(mode != GL_POLYGON);
|
||||
gl_assert(mode != GL_POLYGON);
|
||||
|
||||
target->output = _glActivePolyList();
|
||||
target->count = (mode == GL_TRIANGLE_FAN) ? ((count - 2) * 3) : count;
|
||||
target->header_offset = target->output->vector.size;
|
||||
target->start_offset = target->header_offset + 1;
|
||||
|
||||
assert(target->count);
|
||||
gl_assert(target->count);
|
||||
|
||||
/* Make sure we have enough room for all the "extra" data */
|
||||
aligned_vector_resize(&extras, target->count);
|
||||
|
@ -1192,7 +1174,7 @@ GL_FORCE_INLINE void submitVertices(GLenum mode, GLsizei first, GLuint count, GL
|
|||
&_glTransparentPolyList()->vector, (Vertex*) _glSubmissionTargetHeader(target), target->count + 1
|
||||
);
|
||||
|
||||
assert(vertex);
|
||||
gl_assert(vertex);
|
||||
|
||||
PolyHeader* mtHeader = (PolyHeader*) vertex++;
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "private.h"
|
||||
|
||||
|
@ -197,7 +196,7 @@ static GL_NO_INSTRUMENT GLboolean _glCalculateAverageTexel(GLuint pvrFormat, con
|
|||
|
||||
*d1 = PACK_ARGB4444(a, r, g, b);
|
||||
} else {
|
||||
assert(format == ARGB1555);
|
||||
gl_assert(format == ARGB1555);
|
||||
|
||||
GLushort* s1 = (GLushort*) src1;
|
||||
GLushort* s2 = (GLushort*) src2;
|
||||
|
@ -246,8 +245,8 @@ GLboolean _glGenerateMipmapTwiddled(const GLuint pvrFormat, const GLubyte* prevD
|
|||
const GLubyte* s4 = s3 + stride;
|
||||
GLubyte* t = &thisData[j * stride];
|
||||
|
||||
assert(s4 < prevData + (lastHeight * lastWidth * stride));
|
||||
assert(t < thisData + (thisHeight * thisWidth * stride));
|
||||
gl_assert(s4 < prevData + (lastHeight * lastWidth * stride));
|
||||
gl_assert(t < thisData + (thisHeight * thisWidth * stride));
|
||||
|
||||
_glCalculateAverageTexel(pvrFormat, s1, s2, s3, s4, t);
|
||||
}
|
||||
|
@ -323,7 +322,7 @@ void APIENTRY glGenerateMipmapEXT(GLenum target) {
|
|||
prevHeight = thisHeight;
|
||||
}
|
||||
|
||||
assert(_glIsMipmapComplete(tex));
|
||||
gl_assert(_glIsMipmapComplete(tex));
|
||||
}
|
||||
|
||||
/* generate mipmaps for any image provided by the user and then pass them to OpenGL */
|
||||
|
|
20
GL/gl_assert.h
Normal file
20
GL/gl_assert.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
|
||||
#ifndef NDEBUG
|
||||
/* We're debugging, use normal assert */
|
||||
#include <assert.h>
|
||||
#define gl_assert assert
|
||||
#else
|
||||
/* Release mode, use our custom assert */
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define gl_assert(x) \
|
||||
do {\
|
||||
if(!(x)) {\
|
||||
fprintf(stderr, "Assertion failed at %s:%d\n", __FILE__, __LINE__);\
|
||||
exit(1);\
|
||||
}\
|
||||
} while(0); \
|
||||
|
||||
#endif
|
||||
|
|
@ -275,7 +275,7 @@ void APIENTRY glEnd() {
|
|||
#ifndef NDEBUG
|
||||
// Immediate mode should always activate the fast path
|
||||
GLuint fastPathEnabled = _glRecalcFastPath();
|
||||
assert(fastPathEnabled);
|
||||
gl_assert(fastPathEnabled);
|
||||
#else
|
||||
/* If we're not debugging, set to true - we assume we haven't broken it! */
|
||||
FAST_PATH_ENABLED = GL_TRUE;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
@ -144,7 +143,7 @@ void APIENTRY glLightModeli(GLenum pname, const GLint param) {
|
|||
void APIENTRY glLightModelfv(GLenum pname, const GLfloat *params) {
|
||||
switch(pname) {
|
||||
case GL_LIGHT_MODEL_AMBIENT: {
|
||||
memcpy(SCENE_AMBIENT, params, sizeof(GLfloat) * 4);
|
||||
for(int i = 0; i < 4; ++i) SCENE_AMBIENT[i] = params[i];
|
||||
_glPrecalcLightingValues(SCENE_AMBIENT_MASK);
|
||||
} break;
|
||||
case GL_LIGHT_MODEL_LOCAL_VIEWER:
|
||||
|
@ -393,7 +392,7 @@ GL_FORCE_INLINE float faster_pow2(const float p) {
|
|||
}
|
||||
|
||||
GL_FORCE_INLINE float faster_log2(const float x) {
|
||||
assert(x >= 0.0f);
|
||||
gl_assert(x >= 0.0f);
|
||||
|
||||
const union { float f; uint32_t i; } vx = { x };
|
||||
const float y = (float) (vx.i) * 1.1920928955078125e-7f;
|
||||
|
|
|
@ -3,7 +3,8 @@
|
|||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "gl_assert.h"
|
||||
|
||||
#define MEMSET(dst, v, size) memset((dst), (v), (size))
|
||||
|
||||
|
|
|
@ -75,8 +75,8 @@ static uint32_t *d; // SQ target
|
|||
|
||||
GL_FORCE_INLINE void _glSubmitHeaderOrVertex(const Vertex* v) {
|
||||
#ifndef NDEBUG
|
||||
assert(!isnan(v->xyz[2]));
|
||||
assert(!isnan(v->w));
|
||||
gl_assert(!isnan(v->xyz[2]));
|
||||
gl_assert(!isnan(v->w));
|
||||
#endif
|
||||
|
||||
#if CLIP_DEBUG
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#define FASTCPY(dst, src, bytes) \
|
||||
do { \
|
||||
if(bytes % 32 == 0 && ((uintptr_t) src % 4) == 0) { \
|
||||
assert(((uintptr_t) dst) % 32 == 0); \
|
||||
gl_assert(((uintptr_t) dst) % 32 == 0); \
|
||||
sq_cpy(dst, src, bytes); \
|
||||
} else { \
|
||||
memcpy(dst, src, bytes); \
|
||||
|
|
|
@ -164,8 +164,8 @@ GL_FORCE_INLINE void _glPerspectiveDivideVertex(Vertex* vertex, const float h) {
|
|||
GL_FORCE_INLINE void _glSubmitHeaderOrVertex(const Vertex* v) {
|
||||
#ifndef NDEBUG
|
||||
if(glIsVertex(v->flags)) {
|
||||
assert(!isnan(v->xyz[2]));
|
||||
assert(!isnan(v->w));
|
||||
gl_assert(!isnan(v->xyz[2]));
|
||||
gl_assert(!isnan(v->w));
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "gl_assert.h"
|
||||
#include "platform.h"
|
||||
#include "types.h"
|
||||
|
||||
|
|
77
GL/texture.c
77
GL/texture.c
|
@ -3,7 +3,6 @@
|
|||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "config.h"
|
||||
|
@ -44,14 +43,14 @@ static void* yalloc_alloc_and_defrag(size_t size) {
|
|||
ret = yalloc_alloc(YALLOC_BASE, size);
|
||||
}
|
||||
|
||||
assert(ret && "Out of PVR memory!");
|
||||
gl_assert(ret && "Out of PVR memory!");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static TexturePalette* _initTexturePalette() {
|
||||
TexturePalette* palette = (TexturePalette*) malloc(sizeof(TexturePalette));
|
||||
assert(palette);
|
||||
gl_assert(palette);
|
||||
|
||||
MEMSET4(palette, 0x0, sizeof(TexturePalette));
|
||||
palette->bank = -1;
|
||||
|
@ -61,7 +60,7 @@ static TexturePalette* _initTexturePalette() {
|
|||
static GLshort _glGenPaletteSlot(GLushort size) {
|
||||
GLushort i, j;
|
||||
|
||||
assert(size == 16 || size == 256);
|
||||
gl_assert(size == 16 || size == 256);
|
||||
|
||||
if(size == 16) {
|
||||
for(i = 0; i < MAX_GLDC_PALETTE_SLOTS; ++i) {
|
||||
|
@ -94,7 +93,7 @@ GLushort _glFreePaletteSlots(GLushort size)
|
|||
{
|
||||
GLushort i, j , slots = 0;
|
||||
|
||||
assert(size == 16 || size == 256);
|
||||
gl_assert(size == 16 || size == 256);
|
||||
|
||||
if(size == 16) {
|
||||
for(i = 0; i < MAX_GLDC_PALETTE_SLOTS; ++i) {
|
||||
|
@ -119,7 +118,7 @@ static void _glReleasePaletteSlot(GLshort slot, GLushort size)
|
|||
{
|
||||
GLushort i;
|
||||
|
||||
assert(size == 16 || size == 256);
|
||||
gl_assert(size == 16 || size == 256);
|
||||
|
||||
if (size == 16) {
|
||||
GLushort bank = slot / MAX_GLDC_PALETTE_SLOTS;
|
||||
|
@ -215,7 +214,7 @@ static void GPUTextureTwiddle16BPP(void * src, void* dst, uint32_t w, uint32_t h
|
|||
}
|
||||
|
||||
TexturePalette* _glGetSharedPalette(GLshort bank) {
|
||||
assert(bank >= 0 && bank < MAX_GLDC_SHARED_PALETTES);
|
||||
gl_assert(bank >= 0 && bank < MAX_GLDC_SHARED_PALETTES);
|
||||
return SHARED_PALETTES[bank];
|
||||
}
|
||||
void _glSetInternalPaletteFormat(GLenum val) {
|
||||
|
@ -235,7 +234,7 @@ void _glSetInternalPaletteFormat(GLenum val) {
|
|||
GPUSetPaletteFormat(GPU_PAL_RGB565);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
gl_assert(0);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -473,7 +472,7 @@ GLubyte _glInitTextures() {
|
|||
|
||||
#ifdef __DREAMCAST__
|
||||
/* Ensure memory is aligned */
|
||||
assert((uintptr_t) YALLOC_BASE % 32 == 0);
|
||||
gl_assert((uintptr_t) YALLOC_BASE % 32 == 0);
|
||||
#endif
|
||||
|
||||
yalloc_init(YALLOC_BASE, YALLOC_SIZE);
|
||||
|
@ -536,7 +535,7 @@ void APIENTRY glGenTextures(GLsizei n, GLuint *textures) {
|
|||
GLuint id = 0;
|
||||
TextureObject* txr = (TextureObject*) named_array_alloc(&TEXTURE_OBJECTS, &id);
|
||||
|
||||
assert(id); // Generated IDs must never be zero
|
||||
gl_assert(id); // Generated IDs must never be zero
|
||||
|
||||
_glInitializeTextureObject(txr, id);
|
||||
|
||||
|
@ -805,7 +804,7 @@ void APIENTRY glCompressedTexImage2DARB(GLenum target,
|
|||
|
||||
active->data = yalloc_alloc_and_defrag(imageSize);
|
||||
|
||||
assert(active->data); // Debug assert
|
||||
gl_assert(active->data); // Debug assert
|
||||
|
||||
if(!active->data) { // Release, bail out "gracefully"
|
||||
_glKosThrowError(GL_OUT_OF_MEMORY, __func__);
|
||||
|
@ -1226,7 +1225,7 @@ void _glAllocateSpaceForMipmaps(TextureObject* active) {
|
|||
|
||||
active->data = yalloc_alloc_and_defrag(bytes);
|
||||
|
||||
assert(active->data);
|
||||
gl_assert(active->data);
|
||||
if(!active->data) {
|
||||
free(temp);
|
||||
return;
|
||||
|
@ -1313,7 +1312,7 @@ void APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalFormat,
|
|||
} else {
|
||||
/* Mipmap Errors, kos crashes if 1x1 */
|
||||
if((h < 2) || (w < 2)){
|
||||
assert(TEXTURE_UNITS[ACTIVE_TEXTURE]);
|
||||
gl_assert(TEXTURE_UNITS[ACTIVE_TEXTURE]);
|
||||
TEXTURE_UNITS[ACTIVE_TEXTURE]->mipmap |= (1 << level);
|
||||
return;
|
||||
}
|
||||
|
@ -1351,7 +1350,7 @@ void APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalFormat,
|
|||
|
||||
TextureObject* active = TEXTURE_UNITS[ACTIVE_TEXTURE];
|
||||
|
||||
assert(active);
|
||||
gl_assert(active);
|
||||
|
||||
if(active->data && (level == 0)) {
|
||||
/* pre-existing texture - check if changed */
|
||||
|
@ -1382,10 +1381,10 @@ void APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalFormat,
|
|||
}
|
||||
|
||||
if(!active->data) {
|
||||
assert(active);
|
||||
assert(width);
|
||||
assert(height);
|
||||
assert(destStride);
|
||||
gl_assert(active);
|
||||
gl_assert(width);
|
||||
gl_assert(height);
|
||||
gl_assert(destStride);
|
||||
|
||||
/* need texture memory */
|
||||
active->width = width;
|
||||
|
@ -1397,7 +1396,7 @@ void APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalFormat,
|
|||
active->dataStride = destStride;
|
||||
active->baseDataSize = bytes;
|
||||
|
||||
assert(bytes);
|
||||
gl_assert(bytes);
|
||||
|
||||
if(level > 0) {
|
||||
/* If we're uploading a mipmap level, we need to allocate the full amount of space */
|
||||
|
@ -1416,7 +1415,7 @@ void APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalFormat,
|
|||
_glAllocateSpaceForMipmaps(active);
|
||||
}
|
||||
|
||||
assert(active->data);
|
||||
gl_assert(active->data);
|
||||
|
||||
/* If we run out of PVR memory just return */
|
||||
if(!active->data) {
|
||||
|
@ -1462,7 +1461,7 @@ void APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalFormat,
|
|||
}
|
||||
|
||||
GLubyte* targetData = (active->baseDataOffset == 0) ? active->data : _glGetMipmapLocation(active, level);
|
||||
assert(targetData);
|
||||
gl_assert(targetData);
|
||||
|
||||
GLubyte* conversionBuffer = NULL;
|
||||
|
||||
|
@ -1470,9 +1469,9 @@ void APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalFormat,
|
|||
/* No data? Do nothing! */
|
||||
return;
|
||||
} else if(!needsConversion && !needsTwiddling) {
|
||||
assert(targetData);
|
||||
assert(data);
|
||||
assert(bytes);
|
||||
gl_assert(targetData);
|
||||
gl_assert(data);
|
||||
gl_assert(bytes);
|
||||
|
||||
/* No conversion? Just copy the data, and the pvr_format is correct */
|
||||
FASTCPY(targetData, data, bytes);
|
||||
|
@ -1491,7 +1490,7 @@ void APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalFormat,
|
|||
}
|
||||
|
||||
GLint stride = _determineStride(format, type);
|
||||
assert(stride > -1);
|
||||
gl_assert(stride > -1);
|
||||
|
||||
if(stride == -1) {
|
||||
INFO_MSG("Stride was not detected\n");
|
||||
|
@ -1504,8 +1503,8 @@ void APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalFormat,
|
|||
GLubyte* dest = conversionBuffer;
|
||||
const GLubyte* source = data;
|
||||
|
||||
assert(conversionBuffer);
|
||||
assert(source);
|
||||
gl_assert(conversionBuffer);
|
||||
gl_assert(source);
|
||||
|
||||
/* Perform the conversion */
|
||||
GLuint i;
|
||||
|
@ -1538,7 +1537,7 @@ void APIENTRY glTexImage2D(GLenum target, GLint level, GLint internalFormat,
|
|||
active->color &= ~(1 << 26);
|
||||
} else {
|
||||
/* We should only get here if we converted twiddled data... which is never currently */
|
||||
assert(conversionBuffer);
|
||||
gl_assert(conversionBuffer);
|
||||
|
||||
// We've already converted the data and we
|
||||
// don't need to twiddle it!
|
||||
|
@ -1697,7 +1696,7 @@ GLAPI void APIENTRY glColorTableEXT(GLenum target, GLenum internalFormat, GLsize
|
|||
|
||||
GLint sourceStride = _determineStride(format, type);
|
||||
|
||||
assert(sourceStride > -1);
|
||||
gl_assert(sourceStride > -1);
|
||||
|
||||
TextureConversionFunc convert = _determineConversion(
|
||||
INTERNAL_PALETTE_FORMAT,
|
||||
|
@ -1734,7 +1733,7 @@ GLAPI void APIENTRY glColorTableEXT(GLenum target, GLenum internalFormat, GLsize
|
|||
palette = active->palette;
|
||||
}
|
||||
|
||||
assert(palette);
|
||||
gl_assert(palette);
|
||||
|
||||
if(target) {
|
||||
free(palette->data);
|
||||
|
@ -1750,7 +1749,7 @@ GLAPI void APIENTRY glColorTableEXT(GLenum target, GLenum internalFormat, GLsize
|
|||
palette->format = format;
|
||||
palette->width = width;
|
||||
palette->size = (width > 16) ? 256 : 16;
|
||||
assert(palette->size == 16 || palette->size == 256);
|
||||
gl_assert(palette->size == 16 || palette->size == 256);
|
||||
|
||||
palette->bank = _glGenPaletteSlot(palette->size);
|
||||
|
||||
|
@ -1766,8 +1765,8 @@ GLAPI void APIENTRY glColorTableEXT(GLenum target, GLenum internalFormat, GLsize
|
|||
GLubyte* src = (GLubyte*) data;
|
||||
GLubyte* dst = (GLubyte*) palette->data;
|
||||
|
||||
assert(src);
|
||||
assert(dst);
|
||||
gl_assert(src);
|
||||
gl_assert(dst);
|
||||
|
||||
/* Transform and copy the source palette to the texture */
|
||||
GLushort i = 0;
|
||||
|
@ -1825,7 +1824,7 @@ GLAPI void APIENTRY glTexSubImage2D(
|
|||
_GL_UNUSED(format);
|
||||
_GL_UNUSED(type);
|
||||
_GL_UNUSED(pixels);
|
||||
assert(0 && "Not Implemented");
|
||||
gl_assert(0 && "Not Implemented");
|
||||
}
|
||||
|
||||
GLAPI void APIENTRY glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height) {
|
||||
|
@ -1837,7 +1836,7 @@ GLAPI void APIENTRY glCopyTexSubImage2D(GLenum target, GLint level, GLint xoffse
|
|||
_GL_UNUSED(y);
|
||||
_GL_UNUSED(width);
|
||||
_GL_UNUSED(height);
|
||||
assert(0 && "Not Implemented");
|
||||
gl_assert(0 && "Not Implemented");
|
||||
}
|
||||
|
||||
GLAPI void APIENTRY glCopyTexSubImage1D(GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width) {
|
||||
|
@ -1847,7 +1846,7 @@ GLAPI void APIENTRY glCopyTexSubImage1D(GLenum target, GLint level, GLint xoffse
|
|||
_GL_UNUSED(x);
|
||||
_GL_UNUSED(y);
|
||||
_GL_UNUSED(width);
|
||||
assert(0 && "Not Implemented");
|
||||
gl_assert(0 && "Not Implemented");
|
||||
}
|
||||
|
||||
GLAPI void APIENTRY glCopyTexImage2D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border) {
|
||||
|
@ -1859,7 +1858,7 @@ GLAPI void APIENTRY glCopyTexImage2D(GLenum target, GLint level, GLenum internal
|
|||
_GL_UNUSED(width);
|
||||
_GL_UNUSED(height);
|
||||
_GL_UNUSED(border);
|
||||
assert(0 && "Not Implemented");
|
||||
gl_assert(0 && "Not Implemented");
|
||||
}
|
||||
|
||||
GLAPI void APIENTRY glCopyTexImage1D(GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border) {
|
||||
|
@ -1870,7 +1869,7 @@ GLAPI void APIENTRY glCopyTexImage1D(GLenum target, GLint level, GLenum internal
|
|||
_GL_UNUSED(y);
|
||||
_GL_UNUSED(width);
|
||||
_GL_UNUSED(border);
|
||||
assert(0 && "Not Implemented");
|
||||
gl_assert(0 && "Not Implemented");
|
||||
}
|
||||
|
||||
GLAPI void APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels) {
|
||||
|
@ -1881,7 +1880,7 @@ GLAPI void APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height
|
|||
_GL_UNUSED(format);
|
||||
_GL_UNUSED(type);
|
||||
_GL_UNUSED(pixels);
|
||||
assert(0 && "Not Implemented");
|
||||
gl_assert(0 && "Not Implemented");
|
||||
}
|
||||
GLuint _glMaxTextureMemory() {
|
||||
return YALLOC_SIZE;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include "yalloc.h"
|
||||
#include "yalloc_internals.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user