fix: private.h

- add convenience defines
- note struct ordering and padding
- add const
This commit is contained in:
Hayden Kowalchuk 2020-03-05 14:57:30 -05:00
parent bf00aca843
commit 5a89fbcd7d

View File

@ -11,12 +11,21 @@
#include "../include/gl.h" #include "../include/gl.h"
#include "../containers/aligned_vector.h" #include "../containers/aligned_vector.h"
#include "../containers/named_array.h" #include "../containers/named_array.h"
#include "sh4_math.h"
#define GL_FORCE_INLINE __attribute__((always_inline)) static __inline__ extern void* memcpy4 (void *dest, const void *src, size_t count);
#define GL_NO_INSTRUMENT inline __attribute__((no_instrument_function))
#define GL_INLINE_DEBUG GL_NO_INSTRUMENT __attribute__((always_inline))
#define GL_FORCE_INLINE static GL_INLINE_DEBUG
#define _GL_UNUSED(x) (void)(x)
#define FASTCPY(dst, src, bytes) \ #define FASTCPY(dst, src, bytes) \
(bytes % 32 == 0) ? sq_cpy(dst, src, bytes) : memcpy(dst, src, bytes); (bytes % 32 == 0) ? sq_cpy(dst, src, bytes) : memcpy(dst, src, bytes);
#define FASTCPY4(dst, src, bytes) \
(bytes % 32 == 0) ? sq_cpy(dst, src, bytes) : memcpy4(dst, src, bytes);
#define _PACK4(v) ((v * 0xF) / 0xFF) #define _PACK4(v) ((v * 0xF) / 0xFF)
#define PACK_ARGB4444(a,r,g,b) (_PACK4(a) << 12) | (_PACK4(r) << 8) | (_PACK4(g) << 4) | (_PACK4(b)) #define PACK_ARGB4444(a,r,g,b) (_PACK4(a) << 12) | (_PACK4(r) << 8) | (_PACK4(g) << 4) | (_PACK4(b))
#define PACK_ARGB8888(a,r,g,b) ( ((a & 0xFF) << 24) | ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | (b & 0xFF) ) #define PACK_ARGB8888(a,r,g,b) ( ((a & 0xFF) << 24) | ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | (b & 0xFF) )
@ -109,35 +118,41 @@ typedef struct {
} TexturePalette; } TexturePalette;
typedef struct { typedef struct {
GLushort width; //0
GLushort height;
GLuint color; /* This is the PVR texture format */
GLubyte env;
GLushort mipmap; /* Bitmask of supplied mipmap levels */
GLubyte mipmapCount; /* The number of mipmap levels */
GLubyte uv_clamp;
GLuint index; GLuint index;
GLvoid *data; GLuint color; /* This is the PVR texture format */
GLuint dataStride; //8
GLuint baseDataSize; /* The data size of mipmap level 0 */
GLenum minFilter; GLenum minFilter;
GLenum magFilter; GLenum magFilter;
//16
GLboolean isCompressed; GLvoid *data;
GLboolean isPaletted; TexturePalette* palette;
//24
GLushort width;
GLushort height;
//28
GLushort mipmap; /* Bitmask of supplied mipmap levels */
/* When using the shared palette, this is the bank (0-3) */
GLushort shared_bank;
//32
GLuint dataStride;
//36
GLubyte mipmap_bias;
GLubyte env;
GLubyte mipmapCount; /* The number of mipmap levels */
GLubyte uv_clamp;
//40
/* Mipmap textures have a different /* Mipmap textures have a different
* offset for the base level when supplying the data, this * offset for the base level when supplying the data, this
* keeps track of that. baseDataOffset == 0 * keeps track of that. baseDataOffset == 0
* means that the texture has no mipmaps * means that the texture has no mipmaps
*/ */
GLuint baseDataOffset; GLuint baseDataOffset;
GLuint baseDataSize; /* The data size of mipmap level 0 */
TexturePalette* palette; //48
GLboolean isCompressed;
/* When using the shared palette, this is the bank (0-3) */ GLboolean isPaletted;
GLushort shared_bank; //50
} TextureObject; } TextureObject;
typedef struct { typedef struct {
@ -176,20 +191,6 @@ typedef struct {
float w; float w;
} Vertex; } Vertex;
/* FIXME: SH4 has a swap.w instruction, we should leverage it here! */
#define _SWAP32(x, y) \
do { \
uint32_t t = *((uint32_t*) &x); \
*((uint32_t*) &x) = *((uint32_t*) &y); \
*((uint32_t*) &y) = t; \
} while(0)
/*
*((uint32_t*) &x) = *((uint32_t*) &x) ^ *((uint32_t*) &y); \
*((uint32_t*) &y) = *((uint32_t*) &x) ^ *((uint32_t*) &y); \
*((uint32_t*) &x) = *((uint32_t*) &x) ^ *((uint32_t*) &y); */
#define swapVertex(a, b) \ #define swapVertex(a, b) \
do { \ do { \
Vertex c = *a; \ Vertex c = *a; \
@ -307,8 +308,8 @@ GLboolean _glIsBlendingEnabled();
GLboolean _glIsAlphaTestEnabled(); GLboolean _glIsAlphaTestEnabled();
GLboolean _glIsMipmapComplete(const TextureObject* obj); GLboolean _glIsMipmapComplete(const TextureObject* obj);
GLubyte* _glGetMipmapLocation(TextureObject* obj, GLuint level); GLubyte* _glGetMipmapLocation(const TextureObject* obj, GLuint level);
GLuint _glGetMipmapLevelCount(TextureObject* obj); GLuint _glGetMipmapLevelCount(const TextureObject* obj);
GLboolean _glIsLightingEnabled(); GLboolean _glIsLightingEnabled();
GLboolean _glIsLightEnabled(GLubyte light); GLboolean _glIsLightEnabled(GLubyte light);
@ -336,19 +337,8 @@ GLubyte _glKosHasError();
#define MAX_TEXTURE_UNITS 2 #define MAX_TEXTURE_UNITS 2
#define MAX_LIGHTS 8 #define MAX_LIGHTS 8
#define CLAMP( X, MIN, MAX ) ( (X)<(MIN) ? (MIN) : ((X)>(MAX) ? (MAX) : (X)) ) #define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
#define mat_trans_fv12() { \ #define CLAMP( X, _MIN, _MAX ) ( (X)<(_MIN) ? (_MIN) : ((X)>(_MAX) ? (_MAX) : (X)) )
__asm__ __volatile__( \
"fldi1 fr15\n" \
"ftrv xmtrx, fv12\n" \
"fldi1 fr14\n" \
"fdiv fr15, fr14\n" \
"fmul fr14, fr12\n" \
"fmul fr14, fr13\n" \
: "=f" (__x), "=f" (__y), "=f" (__z) \
: "0" (__x), "1" (__y), "2" (__z) \
: "fr15" ); \
}
#endif // PRIVATE_H #endif // PRIVATE_H