fix: header change

This commit is contained in:
Hayden Kowalchuk 2019-09-18 20:15:14 -04:00
parent 000d6dae7d
commit 5ff3bf0b13
2 changed files with 48 additions and 21 deletions

View File

@ -1,7 +1,8 @@
#include <string.h> #include <string.h>
#include <stdio.h>
#include <dc/matrix.h> #include <dc/matrix.h>
#include <stdio.h> #include <kos/string.h>
#include "../include/gl.h" #include "../include/gl.h"
#include "../containers/stack.h" #include "../containers/stack.h"

View File

@ -98,17 +98,12 @@ typedef struct {
GLboolean is_directional; GLboolean is_directional;
} LightSource; } LightSource;
union color_t {
uint8_t bgra[sizeof(uint32_t)];
uint32_t packed;
};
typedef struct { typedef struct {
/* Same 32 byte layout as pvr_vertex_t */ /* Same 32 byte layout as pvr_vertex_t */
uint32_t flags; uint32_t flags;
float xyz[3]; float xyz[3];
float uv[2]; float uv[2];
union color_t color; uint8_t bgra[4];
/* In the pvr_vertex_t structure, this next 4 bytes is oargb /* In the pvr_vertex_t structure, this next 4 bytes is oargb
* but we're not using that for now, so having W here makes the code * but we're not using that for now, so having W here makes the code
@ -116,14 +111,12 @@ typedef struct {
float w; float w;
} Vertex; } Vertex;
/* FIXME: SH4 has a swap.w instruction, we should leverage it here! */ /* FIXME: SH4 has a swap.w instruction, we should leverage it here! */
#define _SWAP32(type, x, y) \ #define _SWAP32(x, y) \
do { \ do { \
type t = *((type*) &x); \ uint32_t t = *((uint32_t*) &x); \
*((type*) &x) = *((type*) &y); \ *((uint32_t*) &x) = *((uint32_t*) &y); \
*((type*) &y) = t; \ *((uint32_t*) &y) = t; \
} while(0) } while(0)
/* /*
@ -134,16 +127,48 @@ do { \
#define swapVertex(a, b) \ #define swapVertex(a, b) \
do { \ do { \
_SWAP32(uint32_t, a->flags, b->flags); \ _SWAP32(a->flags, b->flags); \
_SWAP32(float, a->xyz[0], b->xyz[0]); \ _SWAP32(a->xyz[0], b->xyz[0]); \
_SWAP32(float, a->xyz[1], b->xyz[1]); \ _SWAP32(a->xyz[1], b->xyz[1]); \
_SWAP32(float, a->xyz[2], b->xyz[2]); \ _SWAP32(a->xyz[2], b->xyz[2]); \
_SWAP32(float, a->uv[0], b->uv[0]); \ _SWAP32(a->uv[0], b->uv[0]); \
_SWAP32(float, a->uv[1], b->uv[1]); \ _SWAP32(a->uv[1], b->uv[1]); \
_SWAP32(uint32_t, a->color.packed, b->color.packed); \ _SWAP32(a->bgra, b->bgra); \
_SWAP32(float, a->w, b->w); \ _SWAP32(a->w, b->w); \
} while(0) } while(0)
#if 0
/* FIXME: SH4 has a swap.w instruction, we should leverage it here! */
inline void _SWAP32( void* x, void* y)
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
*((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);
#pragma GCC diagnostic pop
}
/*
*((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) \
{ \
_SWAP32(&a->flags, &b->flags); \
_SWAP32(&a->xyz[0], &b->xyz[0]); \
_SWAP32(&a->xyz[1], &b->xyz[1]); \
_SWAP32(&a->xyz[2], &b->xyz[2]); \
_SWAP32(&a->uv[0], &b->uv[0]); \
_SWAP32(&a->uv[1], &b->uv[1]); \
_SWAP32(&a->bgra, &b->bgra); \
_SWAP32(&a->w, &b->w); \
}
#endif
/* ClipVertex doesn't have room for these, so we need to parse them /* ClipVertex doesn't have room for these, so we need to parse them
* out separately. Potentially 'w' will be housed here if we support oargb */ * out separately. Potentially 'w' will be housed here if we support oargb */
typedef struct { typedef struct {
@ -213,6 +238,7 @@ pvr_poly_cxt_t* _glGetPVRContext();
GLubyte _glInitTextures(); GLubyte _glInitTextures();
void _glUpdatePVRTextureContext(pvr_poly_cxt_t* context, GLshort textureUnit); void _glUpdatePVRTextureContext(pvr_poly_cxt_t* context, GLshort textureUnit);
void _glAllocateSpaceForMipmaps(TextureObject* active);
typedef struct { typedef struct {
const void* ptr; const void* ptr;