More porting work
This commit is contained in:
parent
be974e96ad
commit
6361cd415e
77
GL/flush.c
77
GL/flush.c
|
@ -1,57 +1,16 @@
|
|||
|
||||
|
||||
#include <kos.h>
|
||||
|
||||
#include "../include/glkos.h"
|
||||
#include "../containers/aligned_vector.h"
|
||||
#include "private.h"
|
||||
#include "profiler.h"
|
||||
#include "version.h"
|
||||
|
||||
#define TA_SQ_ADDR (unsigned int *)(void *) \
|
||||
(0xe0000000 | (((unsigned long)0x10000000) & 0x03ffffe0))
|
||||
|
||||
static PolyList OP_LIST;
|
||||
static PolyList PT_LIST;
|
||||
static PolyList TR_LIST;
|
||||
|
||||
static void pvr_list_submit(void *src, int n) {
|
||||
GLuint *d = TA_SQ_ADDR;
|
||||
GLuint *s = src;
|
||||
|
||||
/* fill/write queues as many times necessary */
|
||||
while(n--) {
|
||||
__asm__("pref @%0" : : "r"(s + 8)); /* prefetch 32 bytes for next loop */
|
||||
d[0] = *(s++);
|
||||
d[1] = *(s++);
|
||||
d[2] = *(s++);
|
||||
d[3] = *(s++);
|
||||
d[4] = *(s++);
|
||||
d[5] = *(s++);
|
||||
d[6] = *(s++);
|
||||
d[7] = *(s++);
|
||||
__asm__("pref @%0" : : "r"(d));
|
||||
d += 8;
|
||||
}
|
||||
|
||||
/* Wait for both store queues to complete */
|
||||
d = (GLuint *)0xe0000000;
|
||||
d[0] = d[8] = 0;
|
||||
}
|
||||
|
||||
static void _glInitPVR(GLboolean autosort, GLboolean fsaa) {
|
||||
pvr_init_params_t params = {
|
||||
/* Enable opaque and translucent polygons with size 32 and 32 */
|
||||
{PVR_BINSIZE_32, PVR_BINSIZE_0, PVR_BINSIZE_32, PVR_BINSIZE_0, PVR_BINSIZE_32},
|
||||
PVR_VERTEX_BUF_SIZE, /* Vertex buffer size */
|
||||
0, /* No DMA */
|
||||
fsaa, /* No FSAA */
|
||||
(autosort) ? 0 : 1 /* Disable translucent auto-sorting to match traditional GL */
|
||||
};
|
||||
|
||||
pvr_init(¶ms);
|
||||
}
|
||||
|
||||
|
||||
PolyList* _glActivePolyList() {
|
||||
if(_glIsBlendingEnabled()) {
|
||||
|
@ -92,7 +51,7 @@ void APIENTRY glKosInitEx(GLdcConfig* config) {
|
|||
|
||||
printf("\nWelcome to GLdc! Git revision: %s\n\n", GLDC_VERSION);
|
||||
|
||||
_glInitPVR(config->autosort_enabled, config->fsaa_enabled);
|
||||
InitGPU(config->autosort_enabled, config->fsaa_enabled);
|
||||
|
||||
_glInitMatrices();
|
||||
_glInitAttributePointers();
|
||||
|
@ -105,9 +64,9 @@ void APIENTRY glKosInitEx(GLdcConfig* config) {
|
|||
|
||||
_glInitTextures();
|
||||
|
||||
OP_LIST.list_type = PVR_LIST_OP_POLY;
|
||||
PT_LIST.list_type = PVR_LIST_PT_POLY;
|
||||
TR_LIST.list_type = PVR_LIST_TR_POLY;
|
||||
OP_LIST.list_type = GPU_LIST_OP_POLY;
|
||||
PT_LIST.list_type = GPU_LIST_PT_POLY;
|
||||
TR_LIST.list_type = GPU_LIST_TR_POLY;
|
||||
|
||||
aligned_vector_init(&OP_LIST.vector, sizeof(Vertex));
|
||||
aligned_vector_init(&PT_LIST.vector, sizeof(Vertex));
|
||||
|
@ -124,7 +83,6 @@ void APIENTRY glKosInit() {
|
|||
glKosInitEx(&config);
|
||||
}
|
||||
|
||||
#define QACRTA ((((unsigned int)0x10000000)>>26)<<2)&0x1c
|
||||
|
||||
void APIENTRY glKosSwapBuffers() {
|
||||
static int frame_count = 0;
|
||||
|
@ -133,24 +91,19 @@ void APIENTRY glKosSwapBuffers() {
|
|||
|
||||
profiler_push(__func__);
|
||||
|
||||
pvr_wait_ready();
|
||||
SceneBegin();
|
||||
SceneListBegin(GPU_LIST_OP_POLY);
|
||||
SceneListSubmit(OP_LIST.vector.data, OP_LIST.vector.size);
|
||||
SceneListFinish();
|
||||
|
||||
pvr_scene_begin();
|
||||
QACR0 = QACRTA;
|
||||
QACR1 = QACRTA;
|
||||
SceneListBegin(GPU_LIST_PT_POLY);
|
||||
SceneListSubmit(PT_LIST.vector.data, PT_LIST.vector.size);
|
||||
SceneListFinish();
|
||||
|
||||
pvr_list_begin(PVR_LIST_OP_POLY);
|
||||
pvr_list_submit(OP_LIST.vector.data, OP_LIST.vector.size);
|
||||
pvr_list_finish();
|
||||
|
||||
pvr_list_begin(PVR_LIST_PT_POLY);
|
||||
pvr_list_submit(PT_LIST.vector.data, PT_LIST.vector.size);
|
||||
pvr_list_finish();
|
||||
|
||||
pvr_list_begin(PVR_LIST_TR_POLY);
|
||||
pvr_list_submit(TR_LIST.vector.data, TR_LIST.vector.size);
|
||||
pvr_list_finish();
|
||||
pvr_scene_finish();
|
||||
SceneListBegin(GPU_LIST_TR_POLY);
|
||||
SceneListSubmit(TR_LIST.vector.data, TR_LIST.vector.size);
|
||||
SceneListFinish();
|
||||
SceneFinish();
|
||||
|
||||
aligned_vector_clear(&OP_LIST.vector);
|
||||
aligned_vector_clear(&PT_LIST.vector);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
#include <dc/vec3f.h>
|
||||
|
||||
#include "private.h"
|
||||
|
||||
#define _MIN(x, y) (x < y) ? x : y
|
||||
|
|
46
GL/matrix.c
46
GL/matrix.c
|
@ -1,10 +1,6 @@
|
|||
#include <string.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <dc/fmath.h>
|
||||
#include <dc/matrix.h>
|
||||
#include <dc/matrix3d.h>
|
||||
#include <dc/vec3f.h>
|
||||
|
||||
#include "private.h"
|
||||
#include "../include/gl.h"
|
||||
|
@ -453,40 +449,40 @@ static inline void vec3f_cross(const GLfloat* v1, const GLfloat* v2, GLfloat* re
|
|||
GL_FORCE_INLINE void vec3f_normalize_sh4(float *v){
|
||||
float length, ilength;
|
||||
|
||||
ilength = MATH_fsrra(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
|
||||
ilength = MATH_fsrra(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
|
||||
length = MATH_Fast_Invert(ilength);
|
||||
if (length)
|
||||
{
|
||||
v[0] *= ilength;
|
||||
v[1] *= ilength;
|
||||
v[2] *= ilength;
|
||||
}
|
||||
if (length)
|
||||
{
|
||||
v[0] *= ilength;
|
||||
v[1] *= ilength;
|
||||
v[2] *= ilength;
|
||||
}
|
||||
}
|
||||
|
||||
void gluLookAt(GLfloat eyex, GLfloat eyey, GLfloat eyez, GLfloat centerx,
|
||||
GLfloat centery, GLfloat centerz, GLfloat upx, GLfloat upy,
|
||||
GLfloat upz) {
|
||||
GLfloat m [16];
|
||||
GLfloat f [3];
|
||||
GLfloat u [3];
|
||||
GLfloat s [3];
|
||||
GLfloat f [3];
|
||||
GLfloat u [3];
|
||||
GLfloat s [3];
|
||||
|
||||
f[0] = centerx - eyex;
|
||||
f[1] = centery - eyey;
|
||||
f[2] = centerz - eyez;
|
||||
f[0] = centerx - eyex;
|
||||
f[1] = centery - eyey;
|
||||
f[2] = centerz - eyez;
|
||||
|
||||
u[0] = upx;
|
||||
u[1] = upy;
|
||||
u[2] = upz;
|
||||
u[0] = upx;
|
||||
u[1] = upy;
|
||||
u[2] = upz;
|
||||
|
||||
vec3f_normalize_sh4(f);
|
||||
vec3f_cross(f, u, s);
|
||||
vec3f_cross(f, u, s);
|
||||
vec3f_normalize_sh4(s);
|
||||
vec3f_cross(s, f, u);
|
||||
vec3f_cross(s, f, u);
|
||||
|
||||
m[0] = s[0]; m[4] = s[1]; m[8] = s[2]; m[12] = 0.0f;
|
||||
m[1] = u[0]; m[5] = u[1]; m[9] = u[2]; m[13] = 0.0f;
|
||||
m[2] = -f[0]; m[6] = -f[1]; m[10] = -f[2]; m[14] = 0.0f;
|
||||
m[0] = s[0]; m[4] = s[1]; m[8] = s[2]; m[12] = 0.0f;
|
||||
m[1] = u[0]; m[5] = u[1]; m[9] = u[2]; m[13] = 0.0f;
|
||||
m[2] = -f[0]; m[6] = -f[1]; m[10] = -f[2]; m[14] = 0.0f;
|
||||
m[3] = 0.0f; m[7] = 0.0f; m[11] = 0.0f; m[15] = 1.0f;
|
||||
|
||||
static Matrix4x4 trn __attribute__((aligned(32))) = {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef enum GPUAlpha {
|
||||
GPU_ALPHA_DISABLE = 0,
|
||||
|
@ -131,6 +132,15 @@ enum GPUCommand {
|
|||
GPU_CMD_SPRITE = 0xA0000000
|
||||
};
|
||||
|
||||
void SceneBegin();
|
||||
|
||||
void SceneListBegin(GPUList list);
|
||||
void SceneListSubmit(void* src, int n);
|
||||
void SceneListFinish();
|
||||
|
||||
void SceneFinish();
|
||||
|
||||
|
||||
|
||||
#ifdef __DREAMCAST__
|
||||
#include "platforms/sh4.h"
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
#include "../platform.h"
|
||||
#include "sh4.h"
|
||||
|
||||
#define TA_SQ_ADDR (unsigned int *)(void *) \
|
||||
(0xe0000000 | (((unsigned long)0x10000000) & 0x03ffffe0))
|
||||
|
||||
#define QACRTA ((((unsigned int)0x10000000)>>26)<<2)&0x1c
|
||||
|
||||
|
||||
void InitGPU(_Bool autosort, _Bool fsaa) {
|
||||
pvr_init_params_t params = {
|
||||
/* Enable opaque and translucent polygons with size 32 and 32 */
|
||||
{PVR_BINSIZE_32, PVR_BINSIZE_0, PVR_BINSIZE_32, PVR_BINSIZE_0, PVR_BINSIZE_32},
|
||||
PVR_VERTEX_BUF_SIZE, /* Vertex buffer size */
|
||||
0, /* No DMA */
|
||||
fsaa, /* No FSAA */
|
||||
(autosort) ? 0 : 1 /* Disable translucent auto-sorting to match traditional GL */
|
||||
};
|
||||
|
||||
pvr_init(¶ms);
|
||||
}
|
||||
|
||||
void SceneBegin() {
|
||||
pvr_wait_ready();
|
||||
pvr_scene_begin();
|
||||
QACR0 = QACRTA;
|
||||
QACR1 = QACRTA;
|
||||
}
|
||||
|
||||
void SceneListBegin(GPUList list) {
|
||||
pvr_list_begin(list);
|
||||
}
|
||||
|
||||
void SceneListSubmit(void* src, int n) {
|
||||
GLuint *d = TA_SQ_ADDR;
|
||||
GLuint *s = src;
|
||||
|
||||
/* fill/write queues as many times necessary */
|
||||
while(n--) {
|
||||
__asm__("pref @%0" : : "r"(s + 8)); /* prefetch 32 bytes for next loop */
|
||||
d[0] = *(s++);
|
||||
d[1] = *(s++);
|
||||
d[2] = *(s++);
|
||||
d[3] = *(s++);
|
||||
d[4] = *(s++);
|
||||
d[5] = *(s++);
|
||||
d[6] = *(s++);
|
||||
d[7] = *(s++);
|
||||
__asm__("pref @%0" : : "r"(d));
|
||||
d += 8;
|
||||
}
|
||||
|
||||
/* Wait for both store queues to complete */
|
||||
d = (GLuint *)0xe0000000;
|
||||
d[0] = d[8] = 0;
|
||||
}
|
||||
|
||||
void SceneListFinish() {
|
||||
pvr_list_finish();
|
||||
}
|
||||
|
||||
void SceneFinish() {
|
||||
pvr_scene_finish();
|
||||
}
|
|
@ -46,3 +46,5 @@ inline void TransformVertices(const Vertex* vertices, const int count) {
|
|||
it->w = __w;
|
||||
}
|
||||
}
|
||||
|
||||
void InitGPU(_Bool autosort, _Bool fsaa);
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
#include "../platform.h"
|
||||
#include "x86.h"
|
||||
|
||||
void InitGPU(_Bool autosort, _Bool fsaa) {
|
||||
|
||||
}
|
||||
|
||||
void SceneBegin() {
|
||||
|
||||
}
|
||||
|
||||
void SceneListBegin(GPUList list) {
|
||||
|
||||
}
|
||||
|
||||
void SceneListSubmit(void* src, int n) {
|
||||
|
||||
}
|
||||
|
||||
void SceneListFinish() {
|
||||
|
||||
}
|
||||
|
||||
void SceneFinish() {
|
||||
|
||||
}
|
|
@ -30,3 +30,5 @@ inline void TransformVertices(const Vertex* vertices, const int count) {
|
|||
(void) vertices;
|
||||
(void) count;
|
||||
}
|
||||
|
||||
void InitGPU(_Bool autosort, _Bool fsaa);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define PRIVATE_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "platform.h"
|
||||
#include "types.h"
|
||||
|
|
Loading…
Reference in New Issue
Block a user