Merge branch 'pvr_direct' into 'master'

Optimization, -O2 Clipping Fix, Nehe20 Build Fix, Warnings Cleanup

See merge request simulant/GLdc!119
This commit is contained in:
Luke Benstead 2024-08-11 10:53:29 +00:00
commit 9711cee788
18 changed files with 122 additions and 156 deletions

View File

@ -22,7 +22,7 @@ string(TOUPPER ${BACKEND} BACKEND_UPPER)
add_definitions(-DBACKEND_${BACKEND_UPPER}) add_definitions(-DBACKEND_${BACKEND_UPPER})
set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD 99)
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD 14)
include_directories(include) include_directories(include)

View File

@ -158,6 +158,14 @@ void APIENTRY glColor3fv(const GLfloat* v) {
COLOR[B8IDX] = (GLubyte)(v[2] * 255); COLOR[B8IDX] = (GLubyte)(v[2] * 255);
} }
typedef union punned {
GLubyte* byte;
GLfloat* flt;
uint32_t* u32;
void* vptr;
uintptr_t uptr;
} punned_t;
void APIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z) { void APIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z) {
IM_ENABLED_VERTEX_ATTRIBUTES |= VERTEX_ENABLED_FLAG; IM_ENABLED_VERTEX_ATTRIBUTES |= VERTEX_ENABLED_FLAG;
@ -170,18 +178,18 @@ void APIENTRY glVertex3f(GLfloat x, GLfloat y, GLfloat z) {
IM_ATTRIBS.colour.ptr = IM_ATTRIBS.st.ptr + 8; IM_ATTRIBS.colour.ptr = IM_ATTRIBS.st.ptr + 8;
IM_ATTRIBS.normal.ptr = IM_ATTRIBS.colour.ptr + 4; IM_ATTRIBS.normal.ptr = IM_ATTRIBS.colour.ptr + 4;
uint32_t* dest = (uint32_t*) &vert->x; punned_t dest = { .flt = &vert->x };
*(dest++) = *((uint32_t*) &x); *(dest.flt++) = x;
*(dest++) = *((uint32_t*) &y); *(dest.flt++) = y;
*(dest++) = *((uint32_t*) &z); *(dest.flt++) = z;
*(dest++) = *((uint32_t*) &UV_COORD[0]); *(dest.flt++) = UV_COORD[0];
*(dest++) = *((uint32_t*) &UV_COORD[1]); *(dest.flt++) = UV_COORD[1];
*(dest++) = *((uint32_t*) &ST_COORD[0]); *(dest.flt++) = ST_COORD[0];
*(dest++) = *((uint32_t*) &ST_COORD[1]); *(dest.flt++) = ST_COORD[1];
*(dest++) = *((uint32_t*) COLOR); *(dest.u32++) = *((uint32_t*)(void*) COLOR);
*(dest++) = *((uint32_t*) &NORMAL[0]); *(dest.flt++) = NORMAL[0];
*(dest++) = *((uint32_t*) &NORMAL[1]); *(dest.flt++) = NORMAL[1];
*(dest++) = *((uint32_t*) &NORMAL[2]); *(dest.flt++) = NORMAL[2];
} }
void APIENTRY glVertex3fv(const GLfloat* v) { void APIENTRY glVertex3fv(const GLfloat* v) {

View File

@ -183,8 +183,13 @@ void APIENTRY glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) {
}; };
float r = DEG2RAD * angle; float r = DEG2RAD * angle;
#ifdef __DREAMCAST__
float s, c;
fsincos(r, &s, &c);
#else
float c = cosf(r); float c = cosf(r);
float s = sinf(r); float s = sinf(r);
#endif
VEC3_NORMALIZE(x, y, z); VEC3_NORMALIZE(x, y, z);

View File

@ -1,5 +1,7 @@
#include <float.h> #include <float.h>
#include <dc/sq.h>
#include "../platform.h" #include "../platform.h"
#include "sh4.h" #include "sh4.h"
@ -11,8 +13,6 @@
#define likely(x) __builtin_expect(!!(x), 1) #define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0) #define unlikely(x) __builtin_expect(!!(x), 0)
#define SQ_BASE_ADDRESS (void*) 0xe0000000
GL_FORCE_INLINE bool glIsVertex(const float flags) { GL_FORCE_INLINE bool glIsVertex(const float flags) {
return flags == GPU_CMD_VERTEX_EOL || flags == GPU_CMD_VERTEX; return flags == GPU_CMD_VERTEX_EOL || flags == GPU_CMD_VERTEX;
@ -70,60 +70,49 @@ void SceneListBegin(GPUList list) {
} }
GL_FORCE_INLINE float _glFastInvert(float x) { GL_FORCE_INLINE float _glFastInvert(float x) {
return (1.f / __builtin_sqrtf(x * x)); return (1.0f / __builtin_sqrtf(x * x));
} }
GL_FORCE_INLINE void _glPerspectiveDivideVertex(Vertex* vertex, const float h) { GL_FORCE_INLINE void _glPerspectiveDivideVertex(Vertex* vertex, const float h, int count) {
TRACE(); TRACE();
const float f = _glFastInvert(vertex->w); for(int v = 0; v < count; ++v) {
const float f = _glFastInvert(vertex[v].w);
/* Convert to screenspace */ /* Convert to screenspace */
/* (note that vertices have already been viewport transformed) */ /* (note that vertices have already been viewport transformed) */
vertex->xyz[0] = vertex->xyz[0] * f; vertex->xyz[0] *= f;
vertex->xyz[1] = vertex->xyz[1] * f; vertex->xyz[1] *= f;
/* Orthographic projections need to use invZ otherwise we lose /* Orthographic projections need to use invZ otherwise we lose
the depth information. As w == 1, and clip-space range is -w to +w the depth information. As w == 1, and clip-space range is -w to +w
we add 1.0 to the Z to bring it into range. We add a little extra to we add 1.0 to the Z to bring it into range. We add a little extra to
avoid a divide by zero. avoid a divide by zero.
*/ */
if(vertex->w == 1.0f) { if(vertex[v].w == 1.0f) {
vertex->xyz[2] = _glFastInvert(1.0001f + vertex->xyz[2]); vertex[v].xyz[2] = _glFastInvert(1.0001f + vertex[v].xyz[2]);
} else { } else {
vertex->xyz[2] = f; vertex[v].xyz[2] = f;
}
} }
} }
volatile uint32_t *sq = SQ_BASE_ADDRESS;
static inline void _glFlushBuffer() { static inline void _glFlushBuffer() {
TRACE(); TRACE();
/* Wait for both store queues to complete */ sq_wait();
sq = (uint32_t*) 0xe0000000;
sq[0] = sq[8] = 0;
} }
static inline void _glPushHeaderOrVertex(Vertex* v) { static uintptr_t sq_dest_addr = 0;
static inline void _glPushHeaderOrVertex(Vertex* v, size_t count) {
TRACE(); TRACE();
#if CLIP_DEBUG #if CLIP_DEBUG
fprintf(stderr, "{%f, %f, %f, %f}, // %x (%x)\n", v->xyz[0], v->xyz[1], v->xyz[2], v->w, v->flags, v); fprintf(stderr, "{%f, %f, %f, %f}, // %x (%x)\n", v->xyz[0], v->xyz[1], v->xyz[2], v->w, v->flags, v);
#endif #endif
uint32_t* s = (uint32_t*) v; sq_fast_cpy((void *)sq_dest_addr, v, count);
sq[0] = *(s++);
sq[1] = *(s++);
sq[2] = *(s++);
sq[3] = *(s++);
sq[4] = *(s++);
sq[5] = *(s++);
sq[6] = *(s++);
sq[7] = *(s++);
__asm__("pref @%0" : : "r"(sq));
sq += 8;
} }
static inline void _glClipEdge(const Vertex* const v1, const Vertex* const v2, Vertex* vout) { static inline void _glClipEdge(const Vertex* const v1, const Vertex* const v2, Vertex* vout) {
@ -151,7 +140,6 @@ static inline void _glClipEdge(const Vertex* const v1, const Vertex* const v2, V
#define SPAN_SORT_CFG 0x005F8030 #define SPAN_SORT_CFG 0x005F8030
static volatile uint32_t* PVR_LMMODE0 = (uint32_t*) 0xA05F6884; static volatile uint32_t* PVR_LMMODE0 = (uint32_t*) 0xA05F6884;
static volatile uint32_t *PVR_LMMODE1 = (uint32_t*) 0xA05F6888; static volatile uint32_t *PVR_LMMODE1 = (uint32_t*) 0xA05F6888;
static volatile uint32_t *QACR = (uint32_t*) 0xFF000038;
enum Visible { enum Visible {
NONE_VISIBLE = 0, NONE_VISIBLE = 0,
@ -184,9 +172,6 @@ void SceneListSubmit(Vertex* vertices, int n) {
*PVR_LMMODE0 = 0; *PVR_LMMODE0 = 0;
*PVR_LMMODE1 = 0; *PVR_LMMODE1 = 0;
//Set QACR registers
QACR[1] = QACR[0] = 0x11;
#if CLIP_DEBUG #if CLIP_DEBUG
fprintf(stderr, "----\n"); fprintf(stderr, "----\n");
@ -211,16 +196,17 @@ void SceneListSubmit(Vertex* vertices, int n) {
do { queued_vertex = &qv; *queued_vertex = *(v); } while(0) do { queued_vertex = &qv; *queued_vertex = *(v); } while(0)
#define SUBMIT_QUEUED_VERTEX(sflags) \ #define SUBMIT_QUEUED_VERTEX(sflags) \
do { if(queued_vertex) { queued_vertex->flags = (sflags); _glPushHeaderOrVertex(queued_vertex); queued_vertex = NULL; } } while(0) do { if(queued_vertex) { queued_vertex->flags = (sflags); _glPushHeaderOrVertex(queued_vertex, 1); queued_vertex = NULL; } } while(0)
int visible_mask = 0; int visible_mask = 0;
sq = SQ_BASE_ADDRESS; sq_dest_addr = (uintptr_t)SQ_MASK_DEST(PVR_TA_INPUT);
sq_lock((void *)PVR_TA_INPUT);
Vertex* v0 = vertices; Vertex* v0 = vertices;
for(int i = 0; i < n - 1; ++i, ++v0) { for(int i = 0; i < n - 1; ++i, ++v0) {
if(is_header(v0)) { if(is_header(v0)) {
_glPushHeaderOrVertex(v0); _glPushHeaderOrVertex(v0, 1);
visible_mask = 0; visible_mask = 0;
continue; continue;
} }
@ -244,13 +230,9 @@ void SceneListSubmit(Vertex* vertices, int n) {
if(visible_mask == ALL_VISIBLE) { if(visible_mask == ALL_VISIBLE) {
SUBMIT_QUEUED_VERTEX(qv.flags); SUBMIT_QUEUED_VERTEX(qv.flags);
_glPerspectiveDivideVertex(v0, h); _glPerspectiveDivideVertex(v0, h, 2);
_glPushHeaderOrVertex(v0);
v1->flags = GPU_CMD_VERTEX_EOL; v1->flags = GPU_CMD_VERTEX_EOL;
_glPushHeaderOrVertex(v0, 2);
_glPerspectiveDivideVertex(v1, h);
_glPushHeaderOrVertex(v1);
} else { } else {
// If the previous triangle wasn't all visible, and we // If the previous triangle wasn't all visible, and we
// queued a vertex - we force it to be EOL and submit // queued a vertex - we force it to be EOL and submit
@ -286,7 +268,7 @@ void SceneListSubmit(Vertex* vertices, int n) {
switch(visible_mask) { switch(visible_mask) {
case ALL_VISIBLE: case ALL_VISIBLE:
_glPerspectiveDivideVertex(v0, h); _glPerspectiveDivideVertex(v0, h, 1);
QUEUE_VERTEX(v0); QUEUE_VERTEX(v0);
break; break;
case NONE_VISIBLE: case NONE_VISIBLE:
@ -299,14 +281,11 @@ void SceneListSubmit(Vertex* vertices, int n) {
_glClipEdge(v2, v0, b); _glClipEdge(v2, v0, b);
b->flags = GPU_CMD_VERTEX; b->flags = GPU_CMD_VERTEX;
_glPerspectiveDivideVertex(v0, h); _glPerspectiveDivideVertex(v0, h, 1);
_glPushHeaderOrVertex(v0); _glPushHeaderOrVertex(v0, 1);
_glPerspectiveDivideVertex(a, h); _glPerspectiveDivideVertex(a, h, 2);
_glPushHeaderOrVertex(a); _glPushHeaderOrVertex(a, 2);
_glPerspectiveDivideVertex(b, h);
_glPushHeaderOrVertex(b);
QUEUE_VERTEX(b); QUEUE_VERTEX(b);
break; break;
@ -319,13 +298,11 @@ void SceneListSubmit(Vertex* vertices, int n) {
_glClipEdge(v1, v2, b); _glClipEdge(v1, v2, b);
b->flags = v2->flags; b->flags = v2->flags;
_glPerspectiveDivideVertex(a, h); _glPerspectiveDivideVertex(a, h, 3);
_glPushHeaderOrVertex(a); _glPushHeaderOrVertex(a, 1);
_glPerspectiveDivideVertex(c, h); _glPushHeaderOrVertex(c, 1);
_glPushHeaderOrVertex(c);
_glPerspectiveDivideVertex(b, h);
QUEUE_VERTEX(b); QUEUE_VERTEX(b);
break; break;
case THIRD_VISIBLE: case THIRD_VISIBLE:
@ -337,14 +314,9 @@ void SceneListSubmit(Vertex* vertices, int n) {
_glClipEdge(v1, v2, b); _glClipEdge(v1, v2, b);
b->flags = GPU_CMD_VERTEX; b->flags = GPU_CMD_VERTEX;
_glPerspectiveDivideVertex(a, h); _glPerspectiveDivideVertex(a, h, 3);
//_glPushHeaderOrVertex(a); _glPushHeaderOrVertex(a, 2);
_glPushHeaderOrVertex(a);
_glPerspectiveDivideVertex(b, h);
_glPushHeaderOrVertex(b);
_glPerspectiveDivideVertex(c, h);
QUEUE_VERTEX(c); QUEUE_VERTEX(c);
break; break;
case FIRST_AND_SECOND_VISIBLE: case FIRST_AND_SECOND_VISIBLE:
@ -353,20 +325,17 @@ void SceneListSubmit(Vertex* vertices, int n) {
_glClipEdge(v2, v0, b); _glClipEdge(v2, v0, b);
b->flags = GPU_CMD_VERTEX; b->flags = GPU_CMD_VERTEX;
_glPerspectiveDivideVertex(v0, h); _glPerspectiveDivideVertex(v0, h, 1);
_glPushHeaderOrVertex(v0); _glPushHeaderOrVertex(v0, 1);
_glClipEdge(v1, v2, a); _glClipEdge(v1, v2, a);
a->flags = v2->flags; a->flags = v2->flags;
_glPerspectiveDivideVertex(c, h); _glPerspectiveDivideVertex(a, h, 3);
_glPushHeaderOrVertex(c);
_glPerspectiveDivideVertex(b, h); _glPushHeaderOrVertex(c, 1);
_glPushHeaderOrVertex(b);
_glPerspectiveDivideVertex(a, h); _glPushHeaderOrVertex(b, 2);
_glPushHeaderOrVertex(c);
QUEUE_VERTEX(a); QUEUE_VERTEX(a);
break; break;
@ -380,17 +349,13 @@ void SceneListSubmit(Vertex* vertices, int n) {
_glClipEdge(v2, v0, b); _glClipEdge(v2, v0, b);
b->flags = GPU_CMD_VERTEX; b->flags = GPU_CMD_VERTEX;
_glPerspectiveDivideVertex(a, h); _glPerspectiveDivideVertex(a, h, 4);
_glPushHeaderOrVertex(a); _glPushHeaderOrVertex(a, 1);
_glPerspectiveDivideVertex(c, h); _glPushHeaderOrVertex(c, 1);
_glPushHeaderOrVertex(c);
_glPerspectiveDivideVertex(b, h); _glPushHeaderOrVertex(b, 2);
_glPushHeaderOrVertex(b);
_glPushHeaderOrVertex(c);
_glPerspectiveDivideVertex(d, h);
QUEUE_VERTEX(d); QUEUE_VERTEX(d);
break; break;
case FIRST_AND_THIRD_VISIBLE: case FIRST_AND_THIRD_VISIBLE:
@ -403,16 +368,16 @@ void SceneListSubmit(Vertex* vertices, int n) {
_glClipEdge(v1, v2, b); _glClipEdge(v1, v2, b);
b->flags = GPU_CMD_VERTEX; b->flags = GPU_CMD_VERTEX;
_glPerspectiveDivideVertex(v0, h); _glPerspectiveDivideVertex(v0, h, 1);
_glPushHeaderOrVertex(v0); _glPushHeaderOrVertex(v0, 1);
_glPerspectiveDivideVertex(a, h); _glPerspectiveDivideVertex(a, h, 3);
_glPushHeaderOrVertex(a); _glPushHeaderOrVertex(a, 1);
_glPushHeaderOrVertex(c, 1);
_glPushHeaderOrVertex(b, 1);
_glPerspectiveDivideVertex(c, h);
_glPushHeaderOrVertex(c);
_glPerspectiveDivideVertex(b, h);
_glPushHeaderOrVertex(b);
QUEUE_VERTEX(c); QUEUE_VERTEX(c);
break; break;
default: default:
@ -423,6 +388,7 @@ void SceneListSubmit(Vertex* vertices, int n) {
SUBMIT_QUEUED_VERTEX(GPU_CMD_VERTEX_EOL); SUBMIT_QUEUED_VERTEX(GPU_CMD_VERTEX_EOL);
_glFlushBuffer(); _glFlushBuffer();
sq_unlock();
} }
void SceneListFinish() { void SceneListFinish() {

View File

@ -80,9 +80,7 @@ static struct {
.color_control = GL_SINGLE_COLOR, .color_control = GL_SINGLE_COLOR,
.color_material_mode = GL_AMBIENT_AND_DIFFUSE, .color_material_mode = GL_AMBIENT_AND_DIFFUSE,
.color_material_mask = AMBIENT_MASK | DIFFUSE_MASK, .color_material_mask = AMBIENT_MASK | DIFFUSE_MASK,
.lights = {0},
.enabled_light_count = 0, .enabled_light_count = 0,
.material = {0},
.shade_model = GL_SMOOTH .shade_model = GL_SMOOTH
}; };

View File

@ -80,7 +80,6 @@ void DrawGLScene()
{ {
const float RED [] = {1.0, 0, 0, 0.5}; const float RED [] = {1.0, 0, 0, 0.5};
const float BLUE [] = {0.0, 0, 1, 0.5}; const float BLUE [] = {0.0, 0, 1, 0.5};
const float NONE [] = {0, 0, 0, 0};
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer

View File

@ -48,7 +48,6 @@ int dtex_to_gl_texture(texture *tex, char* filename) {
GLboolean twiddled = (header.type & (1 << 26)) < 1; GLboolean twiddled = (header.type & (1 << 26)) < 1;
GLboolean compressed = (header.type & (1 << 30)) > 0; GLboolean compressed = (header.type & (1 << 30)) > 0;
GLboolean mipmapped = (header.type & (1 << 31)) > 0; GLboolean mipmapped = (header.type & (1 << 31)) > 0;
GLboolean strided = (header.type & (1 << 25)) > 0;
GLuint format = (header.type >> 27) & 0b111; GLuint format = (header.type >> 27) & 0b111;
image->data = (char *) malloc (header.size); image->data = (char *) malloc (header.size);

View File

@ -26,7 +26,7 @@ KOS_INIT_ROMDISK(romdisk);
float xrot, yrot, zrot; float xrot, yrot, zrot;
/* storage for one texture */ /* storage for one texture */
int texture[1]; GLuint texture[1];
// Load Bitmaps And Convert To Textures // Load Bitmaps And Convert To Textures
void LoadGLTextures() { void LoadGLTextures() {
@ -81,7 +81,7 @@ void InitGL(int Width, int Height) // We call this right after our OpenG
GLfloat l1_pos[] = {5.0, 0.0, 1.0, 1.0}; GLfloat l1_pos[] = {5.0, 0.0, 1.0, 1.0};
GLfloat l1_diff[] = {1.0, 0.0, 0.0, 1.0}; GLfloat l1_diff[] = {1.0, 0.0, 0.0, 1.0};
GLfloat l1_amb[] = {0.5, 0.5, 0.5, 1.0}; //GLfloat l1_amb[] = {0.5, 0.5, 0.5, 1.0};
//glLightfv(GL_LIGHT1, GL_AMBIENT, l1_amb); //glLightfv(GL_LIGHT1, GL_AMBIENT, l1_amb);
glLightfv(GL_LIGHT1, GL_DIFFUSE, l1_diff); glLightfv(GL_LIGHT1, GL_DIFFUSE, l1_diff);
@ -93,7 +93,7 @@ void InitGL(int Width, int Height) // We call this right after our OpenG
GLfloat l2_pos[] = {0.0, 15.0, 1.0, 1.0}; GLfloat l2_pos[] = {0.0, 15.0, 1.0, 1.0};
GLfloat l2_dir[] = {0.0, -1.0, 0.0}; GLfloat l2_dir[] = {0.0, -1.0, 0.0};
GLfloat l2_diff[] = {0.5, 0.5, 0.0, 1.0}; GLfloat l2_diff[] = {0.5, 0.5, 0.0, 1.0};
GLfloat l2_amb[] = {0.5, 0.5, 0.5, 1.0}; //GLfloat l2_amb[] = {0.5, 0.5, 0.5, 1.0};
glEnable(GL_LIGHT2); glEnable(GL_LIGHT2);
glLightfv(GL_LIGHT2, GL_DIFFUSE, l2_diff); glLightfv(GL_LIGHT2, GL_DIFFUSE, l2_diff);
@ -145,7 +145,7 @@ void DrawTexturedQuad(int tex, float x, float y, float z)
GLfloat y0 = y - texH / 2; GLfloat y0 = y - texH / 2;
GLfloat x1 = x + texW / 2; GLfloat x1 = x + texW / 2;
GLfloat y1 = y + texH / 2; GLfloat y1 = y + texH / 2;
GLfloat color[] = {1.0f, 1.0f, 1.0f, 1.0f}; //GLfloat color[] = {1.0f, 1.0f, 1.0f, 1.0f};
GLfloat mat_ambient[] = {1.0f, 1.0f, 1.0f, 1.0f}; GLfloat mat_ambient[] = {1.0f, 1.0f, 1.0f, 1.0f};
GLfloat vertex_data[] = { GLfloat vertex_data[] = {
@ -172,14 +172,6 @@ void DrawTexturedQuad(int tex, float x, float y, float z)
0.0, 0.0, 1.0 0.0, 0.0, 1.0
}; };
GLfloat color_data[] = {
/* 2D Coordinate, texture coordinate */
color[0], color[1], color[2], color[3],
color[0], color[1], color[2], color[3],
color[0], color[1], color[2], color[3],
color[0], color[1], color[2], color[3]
};
//GLint indices[] = {0,1,2,3,2,3}; //GLint indices[] = {0,1,2,3,2,3};
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);

View File

@ -24,8 +24,7 @@ KOS_INIT_ROMDISK(romdisk);
#include "../loadbmp.h" #include "../loadbmp.h"
float xrot, yrot, zrot; float xrot, yrot, zrot;
GLuint texture[1];
int texture[1];
void LoadGLTextures() { void LoadGLTextures() {

View File

@ -35,7 +35,7 @@ int ImageLoad(char *filename, Image *image) {
return 0; return 0;
} }
image->sizeX = sizeX; image->sizeX = sizeX;
printf("Width of %s: %d\n", filename, sizeX); printf("Width of %s: %ld\n", filename, sizeX);
// read the height // read the height
if ((i = fread(&sizeY, 4, 1, file)) != 1) { if ((i = fread(&sizeY, 4, 1, file)) != 1) {
@ -43,7 +43,7 @@ int ImageLoad(char *filename, Image *image) {
return 0; return 0;
} }
image->sizeY = sizeY; image->sizeY = sizeY;
printf("Height of %s: %d\n", filename, sizeY); printf("Height of %s: %ld\n", filename, sizeY);
// calculate the size (assuming 24 bits or 3 bytes per pixel). // calculate the size (assuming 24 bits or 3 bytes per pixel).
size = image->sizeX * image->sizeY * 3; size = image->sizeX * image->sizeY * 3;

View File

@ -20,9 +20,7 @@ KOS_INIT_ROMDISK(romdisk);
#endif #endif
#include "../loadbmp.h" #include "../loadbmp.h"
GLuint texture[1];
/* storage for one texture */
int texture[1];
// Load Bitmaps And Convert To Textures // Load Bitmaps And Convert To Textures
void LoadGLTextures() { void LoadGLTextures() {

View File

@ -62,7 +62,7 @@ int ImageLoad(char *filename, Image *image) {
GLboolean twiddled = (header.type & (1 << 26)) < 1; GLboolean twiddled = (header.type & (1 << 26)) < 1;
GLboolean compressed = (header.type & (1 << 30)) > 0; GLboolean compressed = (header.type & (1 << 30)) > 0;
GLboolean mipmapped = (header.type & (1 << 31)) > 0; GLboolean mipmapped = (header.type & (1 << 31)) > 0;
GLboolean strided = (header.type & (1 << 25)) > 0; //GLboolean strided = (header.type & (1 << 25)) > 0;
GLuint format = (header.type >> 27) & 0b111; GLuint format = (header.type >> 27) & 0b111;
image->data = (char *) malloc (header.size); image->data = (char *) malloc (header.size);
@ -70,8 +70,8 @@ int ImageLoad(char *filename, Image *image) {
image->sizeY = header.height; image->sizeY = header.height;
image->dataSize = header.size; image->dataSize = header.size;
GLuint expected = 2 * header.width * header.height; //GLuint expected = 2 * header.width * header.height;
GLuint ratio = (GLuint) (((GLfloat) expected) / ((GLfloat) header.size)); //GLuint ratio = (GLuint) (((GLfloat) expected) / ((GLfloat) header.size));
fread(image->data, image->dataSize, 1, file); fread(image->data, image->dataSize, 1, file);
fclose(file); fclose(file);

View File

@ -22,7 +22,7 @@ KOS_INIT_ROMDISK(romdisk);
float xrot, yrot, zrot; float xrot, yrot, zrot;
/* storage for one texture */ /* storage for one texture */
int texture[1]; GLuint texture[1];
/* Image type - contains height, width, and data */ /* Image type - contains height, width, and data */
struct Image { struct Image {
@ -59,7 +59,7 @@ int ImageLoad(char *filename, Image *image) {
GLboolean twiddled = (header.type & (1 << 26)) < 1; GLboolean twiddled = (header.type & (1 << 26)) < 1;
GLboolean compressed = (header.type & (1 << 30)) > 0; GLboolean compressed = (header.type & (1 << 30)) > 0;
GLboolean mipmapped = (header.type & (1 << 31)) > 0; GLboolean mipmapped = (header.type & (1 << 31)) > 0;
GLboolean strided = (header.type & (1 << 25)) > 0; //GLboolean strided = (header.type & (1 << 25)) > 0;
GLuint format = (header.type >> 27) & 0b111; GLuint format = (header.type >> 27) & 0b111;
image->data = (char *) malloc (header.size); image->data = (char *) malloc (header.size);
@ -67,8 +67,8 @@ int ImageLoad(char *filename, Image *image) {
image->sizeY = header.height; image->sizeY = header.height;
image->dataSize = header.size; image->dataSize = header.size;
GLuint expected = 2 * header.width * header.height; //GLuint expected = 2 * header.width * header.height;
GLuint ratio = (GLuint) (((GLfloat) expected) / ((GLfloat) header.size)); //GLuint ratio = (GLuint) (((GLfloat) expected) / ((GLfloat) header.size));
fread(image->data, image->dataSize, 1, file); fread(image->data, image->dataSize, 1, file);
fclose(file); fclose(file);

View File

@ -11,6 +11,11 @@
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef __DREAMCAST__
#include <kos.h>
#endif
#define FPS 60 #define FPS 60
uint32_t waittime = 1000.0f/FPS; uint32_t waittime = 1000.0f/FPS;
uint32_t framestarttime = 0; uint32_t framestarttime = 0;
@ -227,8 +232,6 @@ int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
BOOL done=FALSE; // Bool Variable To Exit Loop
glKosInit(); glKosInit();
InitGL(); InitGL();

View File

@ -22,8 +22,7 @@ KOS_INIT_ROMDISK(romdisk);
/* floats for x rotation, y rotation, z rotation */ /* floats for x rotation, y rotation, z rotation */
float xrot, yrot, zrot; float xrot, yrot, zrot;
/* storage for one texture */ GLuint texture[1];
int texture[1];
typedef struct { typedef struct {
unsigned int height; unsigned int height;

View File

@ -41,7 +41,7 @@
/* floats for x rotation, y rotation, z rotation */ /* floats for x rotation, y rotation, z rotation */
float xrot, yrot, zrot; float xrot, yrot, zrot;
int textures[3]; GLuint textures[3];
typedef struct { typedef struct {
uint32_t height; uint32_t height;
@ -272,7 +272,7 @@ int BMP_GetPalette(FILE *pFile)
bitCount = BmpInfoHeader.ClrImportant * sizeof(RGB_QUAD); bitCount = BmpInfoHeader.ClrImportant * sizeof(RGB_QUAD);
if (fread(BmpRgbQuad, 1, bitCount, pFile) != bitCount){ if (fread(BmpRgbQuad, 1, bitCount, pFile) != bitCount){
fprintf(stderr, "Failed to read palette: %d\n", bitCount); fprintf(stderr, "Failed to read palette: %ld\n", bitCount);
return 0; return 0;
} }
@ -293,7 +293,7 @@ int BMP_GetPalette(FILE *pFile)
int BMP_Depack(FILE *pFile,char *pZone) int BMP_Depack(FILE *pFile,char *pZone)
{ {
char PadRead[4]; char PadRead[4];
int32_t i, j, Offset, PadSize, pix, c; int32_t i, j, Offset, PadSize, c;
if (BmpInfoHeader.Compression != BMP_BI_RGB) if (BmpInfoHeader.Compression != BMP_BI_RGB)
return 0; return 0;
@ -356,7 +356,7 @@ int LoadPalettedBMP(const char* filename, Image* image)
} }
/* store palette information */ /* store palette information */
image->palette = BmpPal; image->palette = (char*)BmpPal;
image->palette_width = 16; image->palette_width = 16;

View File

@ -287,7 +287,7 @@ static bool write_samples(const char* path) {
root = ARCS; root = ARCS;
for(int i = 0; i < BUCKET_SIZE; ++i) { for(int i = 0; i < BUCKET_SIZE; ++i) {
if(root->pc) { if(root->pc) {
printf("Incrementing %d for %x. ", (root->pc - lowest_address) / bin_size, (unsigned int) root->pc); printf("Incrementing %ld for %x. ", (root->pc - lowest_address) / bin_size, (unsigned int) root->pc);
bins[(root->pc - lowest_address) / bin_size]++; bins[(root->pc - lowest_address) / bin_size]++;
printf("Now: %d\n", (int) bins[(root->pc - lowest_address) / bin_size]); printf("Now: %d\n", (int) bins[(root->pc - lowest_address) / bin_size]);

View File

@ -435,7 +435,7 @@ bool test_clip_case_001() {
SceneListSubmit(&data[0], data.size()); SceneListSubmit(&data[0], data.size());
check_equal(sent.size(), 5); check_equal(sent.size(), 5u);
check_equal(sent[0].flags, GPU_CMD_POLYHDR); check_equal(sent[0].flags, GPU_CMD_POLYHDR);
check_equal(sent[1].flags, GPU_CMD_VERTEX); check_equal(sent[1].flags, GPU_CMD_VERTEX);
check_equal(sent[2].flags, GPU_CMD_VERTEX); check_equal(sent[2].flags, GPU_CMD_VERTEX);
@ -461,7 +461,7 @@ bool test_clip_case_010() {
SceneListSubmit(&data[0], data.size()); SceneListSubmit(&data[0], data.size());
check_equal(sent.size(), 4); check_equal(sent.size(), 4u);
check_equal(sent[0].flags, GPU_CMD_POLYHDR); check_equal(sent[0].flags, GPU_CMD_POLYHDR);
check_equal(sent[1].flags, GPU_CMD_VERTEX); check_equal(sent[1].flags, GPU_CMD_VERTEX);
check_equal(sent[2].flags, GPU_CMD_VERTEX); check_equal(sent[2].flags, GPU_CMD_VERTEX);
@ -481,7 +481,7 @@ bool test_clip_case_100() {
SceneListSubmit(&data[0], data.size()); SceneListSubmit(&data[0], data.size());
check_equal(sent.size(), 5); check_equal(sent.size(), 5u);
check_equal(sent[0].flags, GPU_CMD_POLYHDR); check_equal(sent[0].flags, GPU_CMD_POLYHDR);
check_equal(sent[1].flags, GPU_CMD_VERTEX); check_equal(sent[1].flags, GPU_CMD_VERTEX);
check_equal(sent[2].flags, GPU_CMD_VERTEX); check_equal(sent[2].flags, GPU_CMD_VERTEX);
@ -507,7 +507,7 @@ bool test_clip_case_110() {
SceneListSubmit(&data[0], data.size()); SceneListSubmit(&data[0], data.size());
check_equal(sent.size(), 6); check_equal(sent.size(), 6u);
check_equal(sent[0].flags, GPU_CMD_POLYHDR); check_equal(sent[0].flags, GPU_CMD_POLYHDR);
check_equal(sent[1].flags, GPU_CMD_VERTEX); check_equal(sent[1].flags, GPU_CMD_VERTEX);
check_equal(sent[2].flags, GPU_CMD_VERTEX); check_equal(sent[2].flags, GPU_CMD_VERTEX);
@ -530,7 +530,7 @@ bool test_clip_case_011() {
SceneListSubmit(&data[0], data.size()); SceneListSubmit(&data[0], data.size());
check_equal(sent.size(), 6); check_equal(sent.size(), 6u);
check_equal(sent[0].flags, GPU_CMD_POLYHDR); check_equal(sent[0].flags, GPU_CMD_POLYHDR);
check_equal(sent[1].flags, GPU_CMD_VERTEX); check_equal(sent[1].flags, GPU_CMD_VERTEX);
check_equal(sent[2].flags, GPU_CMD_VERTEX); check_equal(sent[2].flags, GPU_CMD_VERTEX);
@ -553,7 +553,7 @@ bool test_clip_case_101() {
SceneListSubmit(&data[0], data.size()); SceneListSubmit(&data[0], data.size());
check_equal(sent.size(), 6); check_equal(sent.size(), 6u);
check_equal(sent[0].flags, GPU_CMD_POLYHDR); check_equal(sent[0].flags, GPU_CMD_POLYHDR);
check_equal(sent[1].flags, GPU_CMD_VERTEX); check_equal(sent[1].flags, GPU_CMD_VERTEX);
check_equal(sent[2].flags, GPU_CMD_VERTEX); check_equal(sent[2].flags, GPU_CMD_VERTEX);
@ -576,7 +576,7 @@ bool test_clip_case_111() {
SceneListSubmit(&data[0], data.size()); SceneListSubmit(&data[0], data.size());
check_equal(sent.size(), 4); check_equal(sent.size(), 4u);
check_equal(sent[0].flags, GPU_CMD_POLYHDR); check_equal(sent[0].flags, GPU_CMD_POLYHDR);
check_equal(sent[1].flags, GPU_CMD_VERTEX); check_equal(sent[1].flags, GPU_CMD_VERTEX);
check_equal(sent[2].flags, GPU_CMD_VERTEX); check_equal(sent[2].flags, GPU_CMD_VERTEX);