More stubbing
This commit is contained in:
parent
60992f2bc5
commit
20733435e4
15
GL/draw.c
15
GL/draw.c
|
@ -856,14 +856,17 @@ static void clip(SubmissionTarget* target) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mat_transform3(const float* xyz, const float* xyzOut, const uint32_t count, const uint32_t inStride, const uint32_t outStride) {
|
static void mat_transform3(const float* xyz, const float* xyzOut, const uint32_t count, const uint32_t inStride, const uint32_t outStride) {
|
||||||
uint8_t* dataIn = (uint8_t*) xyz;
|
const uint8_t* dataIn = (const uint8_t*) xyz;
|
||||||
uint8_t* dataOut = (uint8_t*) xyzOut;
|
uint8_t* dataOut = (uint8_t*) xyzOut;
|
||||||
|
|
||||||
ITERATE(count) {
|
ITERATE(count) {
|
||||||
float* in = (float*) dataIn;
|
const float* in = (const float*) dataIn;
|
||||||
float* out = (float*) dataOut;
|
float* out = (float*) dataOut;
|
||||||
|
|
||||||
mat_trans_single3_nodiv_nomod(in[0], in[1], in[2], out[0], out[1], out[2]);
|
TransformVec3NoMod(
|
||||||
|
in,
|
||||||
|
out
|
||||||
|
);
|
||||||
|
|
||||||
dataIn += inStride;
|
dataIn += inStride;
|
||||||
dataOut += outStride;
|
dataOut += outStride;
|
||||||
|
@ -871,14 +874,14 @@ static void mat_transform3(const float* xyz, const float* xyzOut, const uint32_t
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mat_transform_normal3(const float* xyz, const float* xyzOut, const uint32_t count, const uint32_t inStride, const uint32_t outStride) {
|
static void mat_transform_normal3(const float* xyz, const float* xyzOut, const uint32_t count, const uint32_t inStride, const uint32_t outStride) {
|
||||||
uint8_t* dataIn = (uint8_t*) xyz;
|
const uint8_t* dataIn = (const uint8_t*) xyz;
|
||||||
uint8_t* dataOut = (uint8_t*) xyzOut;
|
uint8_t* dataOut = (uint8_t*) xyzOut;
|
||||||
|
|
||||||
ITERATE(count) {
|
ITERATE(count) {
|
||||||
float* in = (float*) dataIn;
|
const float* in = (const float*) dataIn;
|
||||||
float* out = (float*) dataOut;
|
float* out = (float*) dataOut;
|
||||||
|
|
||||||
mat_trans_normal3_nomod(in[0], in[1], in[2], out[0], out[1], out[2]);
|
TransformNormalNoMod(in, out);
|
||||||
|
|
||||||
dataIn += inStride;
|
dataIn += inStride;
|
||||||
dataOut += outStride;
|
dataOut += outStride;
|
||||||
|
|
8
GL/fog.c
8
GL/fog.c
|
@ -10,13 +10,13 @@ static GLfloat FOG_COLOR [] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||||
|
|
||||||
static void updatePVRFog() {
|
static void updatePVRFog() {
|
||||||
if(FOG_MODE == GL_LINEAR) {
|
if(FOG_MODE == GL_LINEAR) {
|
||||||
pvr_fog_table_linear(FOG_START, FOG_END);
|
GPUSetFogLinear(FOG_START, FOG_END);
|
||||||
} else if(FOG_MODE == GL_EXP) {
|
} else if(FOG_MODE == GL_EXP) {
|
||||||
pvr_fog_table_exp(FOG_DENSITY);
|
GPUSetFogExp(FOG_DENSITY);
|
||||||
} else if(FOG_MODE == GL_EXP2) {
|
} else if(FOG_MODE == GL_EXP2) {
|
||||||
pvr_fog_table_exp2(FOG_DENSITY);
|
GPUSetFogExp2(FOG_DENSITY);
|
||||||
}
|
}
|
||||||
pvr_fog_table_color(FOG_COLOR[3], FOG_COLOR[0], FOG_COLOR[1], FOG_COLOR[2]);
|
GPUSetFogColor(FOG_COLOR[3], FOG_COLOR[0], FOG_COLOR[1], FOG_COLOR[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void APIENTRY glFogf(GLenum pname, GLfloat param) {
|
void APIENTRY glFogf(GLenum pname, GLfloat param) {
|
||||||
|
|
|
@ -202,12 +202,7 @@ void APIENTRY glLightfv(GLenum light, GLenum pname, const GLfloat *params) {
|
||||||
if(LIGHTS[idx].isDirectional) {
|
if(LIGHTS[idx].isDirectional) {
|
||||||
//FIXME: Do we need to rotate directional lights?
|
//FIXME: Do we need to rotate directional lights?
|
||||||
} else {
|
} else {
|
||||||
mat_trans_single4(
|
TransformVec3(LIGHTS[idx].position);
|
||||||
LIGHTS[idx].position[0],
|
|
||||||
LIGHTS[idx].position[1],
|
|
||||||
LIGHTS[idx].position[2],
|
|
||||||
LIGHTS[idx].position[3]
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -388,10 +383,6 @@ GL_FORCE_INLINE GLboolean isSpecularColorMaterial() {
|
||||||
return (COLOR_MATERIAL_MODE == GL_SPECULAR);
|
return (COLOR_MATERIAL_MODE == GL_SPECULAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
GL_FORCE_INLINE void initVec3(struct vec3f* v, const GLfloat* src) {
|
|
||||||
memcpy(v, src, sizeof(GLfloat) * 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Implementation from here (MIT):
|
* Implementation from here (MIT):
|
||||||
* https://github.com/appleseedhq/appleseed/blob/master/src/appleseed/foundation/math/fastmath.h
|
* https://github.com/appleseedhq/appleseed/blob/master/src/appleseed/foundation/math/fastmath.h
|
||||||
|
|
|
@ -176,7 +176,7 @@ void APIENTRY glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) {
|
||||||
float c = cos(r);
|
float c = cos(r);
|
||||||
float s = sin(r);
|
float s = sin(r);
|
||||||
|
|
||||||
vec3f_normalize(x, y, z);
|
VEC3_NORMALIZE(x, y, z);
|
||||||
|
|
||||||
float invc = 1.0f - c;
|
float invc = 1.0f - c;
|
||||||
float xs = x * s;
|
float xs = x * s;
|
||||||
|
|
|
@ -67,6 +67,14 @@ typedef enum GPUTextureFormat {
|
||||||
GPU_TXRFMT_STRIDE = (1 << 21)
|
GPU_TXRFMT_STRIDE = (1 << 21)
|
||||||
} GPUTextureFormat;
|
} GPUTextureFormat;
|
||||||
|
|
||||||
|
inline uint32_t GPUPaletteSelect8BPP(uint32_t x) {
|
||||||
|
return x << 25;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline uint32_t GPUPaletteSelect4BPP(uint32_t x) {
|
||||||
|
return x << 21;
|
||||||
|
}
|
||||||
|
|
||||||
typedef enum GPUCulling {
|
typedef enum GPUCulling {
|
||||||
GPU_CULLING_NONE = 0,
|
GPU_CULLING_NONE = 0,
|
||||||
GPU_CULLING_SMALL = 1,
|
GPU_CULLING_SMALL = 1,
|
||||||
|
|
|
@ -34,6 +34,25 @@ inline void MultiplyMatrix4x4(const float* mat) {
|
||||||
mat_apply((matrix_t*) mat);
|
mat_apply((matrix_t*) mat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline void TransformVec3(float* x) {
|
||||||
|
mat_trans_single4(x[0], x[1], x[2], x[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Transform a 3-element vector using the stored matrix (w == 1) */
|
||||||
|
inline void TransformVec3NoMod(const float* xIn, float* xOut) {
|
||||||
|
mat_trans_single3_nodiv_nomod(xIn[0], xIn[1], xIn[2], xOut[0], xOut[1], xOut[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Transform a 3-element normal using the stored matrix (w == 0)*/
|
||||||
|
inline void TransformNormalNoMod(const float* in, float* out) {
|
||||||
|
mat_trans_normal3_nomod(in[0], in[1], in[2], out[0], out[1], out[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Transform a 4-element vector in-place by the stored matrix */
|
||||||
|
inline void TransformVec4(float* x) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
inline void TransformVertices(const Vertex* vertices, const int count) {
|
inline void TransformVertices(const Vertex* vertices, const int count) {
|
||||||
Vertex* it = vertices;
|
Vertex* it = vertices;
|
||||||
for(int i = 0; i < count; ++i, ++it) {
|
for(int i = 0; i < count; ++i, ++it) {
|
||||||
|
@ -57,3 +76,41 @@ inline void TransformVertices(const Vertex* vertices, const int count) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitGPU(_Bool autosort, _Bool fsaa);
|
void InitGPU(_Bool autosort, _Bool fsaa);
|
||||||
|
|
||||||
|
inline void GPUSetPaletteFormat(GPUPaletteFormat format) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void GPUSetPaletteEntry(uint32_t idx, uint32_t value) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void GPUSetBackgroundColour(float r, float g, float b) {
|
||||||
|
pvr_set_bg_color(r, g, b);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define PT_ALPHA_REF 0x011c
|
||||||
|
|
||||||
|
inline void GPUSetAlphaCutOff(uint8_t val) {
|
||||||
|
PVR_SET(PT_ALPHA_REF, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void GPUSetClearDepth(float v) {
|
||||||
|
pvr_set_zclip(v);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void GPUSetFogLinear(float start, float end) {
|
||||||
|
pvr_fog_table_linear(start, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void GPUSetFogExp(float density) {
|
||||||
|
pvr_fog_table_exp(density);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void GPUSetFogExp2(float density) {
|
||||||
|
pvr_fog_table_exp2(density);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void GPUSetFogColor(float r, float g, float b, float a) {
|
||||||
|
pvr_fog_table_color(r, g, b, a);
|
||||||
|
}
|
||||||
|
|
|
@ -14,13 +14,19 @@
|
||||||
#define FASTCPY(dst, src, bytes) memcpy(dst, src, bytes)
|
#define FASTCPY(dst, src, bytes) memcpy(dst, src, bytes)
|
||||||
#define FASTCPY4(dst, src, bytes) memcpy(dst, src, bytes)
|
#define FASTCPY4(dst, src, bytes) memcpy(dst, src, bytes)
|
||||||
#define MEMSET4(dst, v, size) memset((dst), (v), (size))
|
#define MEMSET4(dst, v, size) memset((dst), (v), (size))
|
||||||
#define NORMALIZEVEC3(x, y, z) \
|
#define VEC3_NORMALIZE(x, y, z) \
|
||||||
do { \
|
do { \
|
||||||
float l = MATH_fsrra((x) * (x) + (y) * (y) + (z) * (z)); \
|
float l = MATH_fsrra((x) * (x) + (y) * (y) + (z) * (z)); \
|
||||||
x *= l; \
|
x *= l; \
|
||||||
y *= l; \
|
y *= l; \
|
||||||
z *= l; \
|
z *= l; \
|
||||||
while(0); \
|
} while(0)
|
||||||
|
|
||||||
|
#define VEC3_LENGTH(x, y, z, d) \
|
||||||
|
d = MATH_Fast_Sqrt((x) * (x) + (y) * (y) + (z) * (z))
|
||||||
|
|
||||||
|
#define VEC3_DOT(x1, y1, z1, x2, y2, z2, d) \
|
||||||
|
d = (x1 * x2) + (y1 * y2) + (z1 * z2)
|
||||||
|
|
||||||
struct PolyHeader;
|
struct PolyHeader;
|
||||||
struct PolyContext;
|
struct PolyContext;
|
||||||
|
@ -42,9 +48,47 @@ inline void DownloadMatrix4x4(Matrix4x4* mat) {
|
||||||
(void) mat;
|
(void) mat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Transform a 3-element vector in-place using the stored matrix (w == 1) */
|
||||||
|
inline void TransformVec3(float* x) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Transform a 3-element vector using the stored matrix (w == 1) */
|
||||||
|
inline void TransformVec3NoMod(const float* xIn, float* xOut) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Transform a 3-element normal using the stored matrix (w == 0)*/
|
||||||
|
inline void TransformNormalNoMod(const float* xIn, float* xOut) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Transform a 4-element vector in-place by the stored matrix */
|
||||||
|
inline void TransformVec4(float* x) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
inline void TransformVertices(const Vertex* vertices, const int count) {
|
inline void TransformVertices(const Vertex* vertices, const int count) {
|
||||||
(void) vertices;
|
(void) vertices;
|
||||||
(void) count;
|
(void) count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitGPU(_Bool autosort, _Bool fsaa);
|
void InitGPU(_Bool autosort, _Bool fsaa);
|
||||||
|
|
||||||
|
size_t GPUMemoryAvailable();
|
||||||
|
void* GPUMemoryAlloc(size_t size);
|
||||||
|
|
||||||
|
enum GPUPaletteFormat;
|
||||||
|
|
||||||
|
void GPUSetPaletteFormat(GPUPaletteFormat format);
|
||||||
|
void GPUSetPaletteEntry(uint32_t idx, uint32_t value);
|
||||||
|
|
||||||
|
void GPUSetBackgroundColour(float r, float g, float b);
|
||||||
|
void GPUSetAlphaCutOff(uint8_t v);
|
||||||
|
void GPUSetClearDepth(float v);
|
||||||
|
|
||||||
|
void GPUSetFogLinear(float start, float end);
|
||||||
|
void GPUSetFogExp(float density);
|
||||||
|
void GPUSetFogExp2(float density);
|
||||||
|
void GPUSetFogColor(float r, float g, float b, float a);
|
||||||
|
|
||||||
|
|
11
GL/state.c
11
GL/state.c
|
@ -235,9 +235,9 @@ void _glUpdatePVRTextureContext(PolyContext *context, GLshort textureUnit) {
|
||||||
if(tx1->isPaletted) {
|
if(tx1->isPaletted) {
|
||||||
if(_glIsSharedTexturePaletteEnabled()) {
|
if(_glIsSharedTexturePaletteEnabled()) {
|
||||||
TexturePalette* palette = _glGetSharedPalette(tx1->shared_bank);
|
TexturePalette* palette = _glGetSharedPalette(tx1->shared_bank);
|
||||||
context->txr.format |= PVR_TXRFMT_8BPP_PAL(palette->bank);
|
context->txr.format |= GPUPaletteSelect8BPP(palette->bank);
|
||||||
} else {
|
} else {
|
||||||
context->txr.format |= PVR_TXRFMT_8BPP_PAL((tx1->palette) ? tx1->palette->bank : 0);
|
context->txr.format |= GPUPaletteSelect8BPP((tx1->palette) ? tx1->palette->bank : 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,7 +415,7 @@ GLAPI void APIENTRY glDisable(GLenum cap) {
|
||||||
/* Clear Caps */
|
/* Clear Caps */
|
||||||
GLAPI void APIENTRY glClear(GLuint mode) {
|
GLAPI void APIENTRY glClear(GLuint mode) {
|
||||||
if(mode & GL_COLOR_BUFFER_BIT) {
|
if(mode & GL_COLOR_BUFFER_BIT) {
|
||||||
pvr_set_bg_color(CLEAR_COLOUR[0], CLEAR_COLOUR[1], CLEAR_COLOUR[2]);
|
GPUSetBackgroundColour(CLEAR_COLOUR[0], CLEAR_COLOUR[1], CLEAR_COLOUR[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -437,7 +437,7 @@ GLAPI void APIENTRY glClearDepthf(GLfloat depth) {
|
||||||
|
|
||||||
GLAPI void APIENTRY glClearDepth(GLfloat depth) {
|
GLAPI void APIENTRY glClearDepth(GLfloat depth) {
|
||||||
/* We reverse because using invW means that farther Z == lower number */
|
/* We reverse because using invW means that farther Z == lower number */
|
||||||
pvr_set_zclip(1.0f - depth);
|
GPUSetClearDepth(1.0f - depth);
|
||||||
}
|
}
|
||||||
|
|
||||||
GLAPI void APIENTRY glDrawBuffer(GLenum mode) {
|
GLAPI void APIENTRY glDrawBuffer(GLenum mode) {
|
||||||
|
@ -495,7 +495,6 @@ GLAPI void APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor) {
|
||||||
_updatePVRBlend(&GL_CONTEXT);
|
_updatePVRBlend(&GL_CONTEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PT_ALPHA_REF 0x011c
|
|
||||||
|
|
||||||
GLAPI void APIENTRY glAlphaFunc(GLenum func, GLclampf ref) {
|
GLAPI void APIENTRY glAlphaFunc(GLenum func, GLclampf ref) {
|
||||||
GLint validFuncs[] = {
|
GLint validFuncs[] = {
|
||||||
|
@ -508,7 +507,7 @@ GLAPI void APIENTRY glAlphaFunc(GLenum func, GLclampf ref) {
|
||||||
}
|
}
|
||||||
|
|
||||||
GLubyte val = (GLubyte)(ref * 255.0f);
|
GLubyte val = (GLubyte)(ref * 255.0f);
|
||||||
PVR_SET(PT_ALPHA_REF, val);
|
GPUSetAlphaCutOff(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void glLineWidth(GLfloat width) {
|
void glLineWidth(GLfloat width) {
|
||||||
|
|
12
GL/texture.c
12
GL/texture.c
|
@ -123,10 +123,10 @@ void _glSetInternalPaletteFormat(GLenum val) {
|
||||||
INTERNAL_PALETTE_FORMAT = val;
|
INTERNAL_PALETTE_FORMAT = val;
|
||||||
|
|
||||||
if(INTERNAL_PALETTE_FORMAT == GL_RGBA4) {
|
if(INTERNAL_PALETTE_FORMAT == GL_RGBA4) {
|
||||||
pvr_set_pal_format(GPU_PAL_ARGB4444);
|
GPUSetPaletteFormat(GPU_PAL_ARGB4444);
|
||||||
} else {
|
} else {
|
||||||
assert(INTERNAL_PALETTE_FORMAT == GL_RGBA8);
|
assert(INTERNAL_PALETTE_FORMAT == GL_RGBA8);
|
||||||
pvr_set_pal_format(GPU_PAL_ARGB8888);
|
GPUSetPaletteFormat(GPU_PAL_ARGB8888);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,9 +145,9 @@ void _glApplyColorTable(TexturePalette* src) {
|
||||||
for(i = 0; i < src->width; ++i) {
|
for(i = 0; i < src->width; ++i) {
|
||||||
GLubyte* entry = &src->data[i * 4];
|
GLubyte* entry = &src->data[i * 4];
|
||||||
if(INTERNAL_PALETTE_FORMAT == GL_RGBA8) {
|
if(INTERNAL_PALETTE_FORMAT == GL_RGBA8) {
|
||||||
pvr_set_pal_entry(offset + i, PACK_ARGB8888(entry[3], entry[0], entry[1], entry[2]));
|
GPUSetPaletteEntry(offset + i, PACK_ARGB8888(entry[3], entry[0], entry[1], entry[2]));
|
||||||
} else {
|
} else {
|
||||||
pvr_set_pal_entry(offset + i, PACK_ARGB4444(entry[3], entry[0], entry[1], entry[2]));
|
GPUSetPaletteEntry(offset + i, PACK_ARGB4444(entry[3], entry[0], entry[1], entry[2]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -332,9 +332,9 @@ GLubyte _glInitTextures() {
|
||||||
memset((void*) BANKS_USED, 0x0, sizeof(BANKS_USED));
|
memset((void*) BANKS_USED, 0x0, sizeof(BANKS_USED));
|
||||||
memset((void*) SUBBANKS_USED, 0x0, sizeof(SUBBANKS_USED));
|
memset((void*) SUBBANKS_USED, 0x0, sizeof(SUBBANKS_USED));
|
||||||
|
|
||||||
size_t vram_free = pvr_mem_available();
|
size_t vram_free = GPUMemoryAvailable();
|
||||||
YALLOC_SIZE = vram_free - PVR_MEM_BUFFER_SIZE; /* Take all but 64kb VRAM */
|
YALLOC_SIZE = vram_free - PVR_MEM_BUFFER_SIZE; /* Take all but 64kb VRAM */
|
||||||
YALLOC_BASE = pvr_mem_malloc(YALLOC_SIZE);
|
YALLOC_BASE = GPUMemoryAlloc(YALLOC_SIZE);
|
||||||
yalloc_init(YALLOC_BASE, YALLOC_SIZE);
|
yalloc_init(YALLOC_BASE, YALLOC_SIZE);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user