Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Dave 2023-04-15 19:54:17 +02:00
commit 75937e8257
4 changed files with 26 additions and 46 deletions

View File

@ -36,7 +36,7 @@ else()
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ffp-contract=fast -ffast-math") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -ffp-contract=fast -ffast-math")
endif() endif()
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -fexpensive-optimizations") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -fexpensive-optimizations -fomit-frame-pointer -finline-functions")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -g -Wall -Wextra") set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -g -Wall -Wextra")
set( set(

View File

@ -200,28 +200,9 @@ void APIENTRY glRotatef(GLfloat angle, GLfloat x, GLfloat y, GLfloat z) {
/* Load an arbitrary matrix */ /* Load an arbitrary matrix */
void APIENTRY glLoadMatrixf(const GLfloat *m) { void APIENTRY glLoadMatrixf(const GLfloat *m) {
static Matrix4x4 TEMP; static Matrix4x4 __attribute__((aligned(32))) TEMP;
TEMP[M0] = m[0];
TEMP[M1] = m[1];
TEMP[M2] = m[2];
TEMP[M3] = m[3];
TEMP[M4] = m[4];
TEMP[M5] = m[5];
TEMP[M6] = m[6];
TEMP[M7] = m[7];
TEMP[M8] = m[8];
TEMP[M9] = m[9];
TEMP[M10] = m[10];
TEMP[M11] = m[11];
TEMP[M12] = m[12];
TEMP[M13] = m[13];
TEMP[M14] = m[14];
TEMP[M15] = m[15];
memcpy(TEMP, m, sizeof(float) * 16);
stack_replace(MATRIX_STACKS + MATRIX_IDX, TEMP); stack_replace(MATRIX_STACKS + MATRIX_IDX, TEMP);
if(MATRIX_MODE == GL_MODELVIEW) { if(MATRIX_MODE == GL_MODELVIEW) {

View File

@ -9,7 +9,9 @@
#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 0xe0000000 #define SQ_BASE_ADDRESS (uint32_t *)(void *) \
(0xe0000000 | (((uint32_t)0x10000000) & 0x03ffffe0))
static volatile uint32_t* PVR_LMMODE0 = (uint32_t*) 0xA05F6884; static volatile uint32_t* PVR_LMMODE0 = (uint32_t*) 0xA05F6884;
@ -38,9 +40,6 @@ void InitGPU(_Bool autosort, _Bool fsaa) {
void SceneBegin() { void SceneBegin() {
pvr_wait_ready(); pvr_wait_ready();
pvr_scene_begin(); pvr_scene_begin();
QACR0 = 0x11; /* Enable the direct texture path by setting the higher two bits */
QACR1 = 0x11;
} }
void SceneListBegin(GPUList list) { void SceneListBegin(GPUList list) {
@ -83,7 +82,6 @@ GL_FORCE_INLINE void _glSubmitHeaderOrVertex(uint32_t* d, const Vertex* v) {
#endif #endif
uint32_t *s = (uint32_t*) v; uint32_t *s = (uint32_t*) v;
__asm__("pref @%0" : : "r"(s + 8)); /* prefetch 32 bytes for next loop */
d[0] = *(s++); d[0] = *(s++);
d[1] = *(s++); d[1] = *(s++);
d[2] = *(s++); d[2] = *(s++);
@ -104,7 +102,7 @@ static struct __attribute__((aligned(32))) {
static int tri_count = 0; static int tri_count = 0;
static int strip_count = 0; static int strip_count = 0;
GL_FORCE_INLINE void interpolateColour(const uint32_t* a, const uint32_t* b, const float t, uint32_t* out) { static inline void interpolateColour(const uint32_t* a, const uint32_t* b, const float t, uint32_t* out) {
const static uint32_t MASK1 = 0x00FF00FF; const static uint32_t MASK1 = 0x00FF00FF;
const static uint32_t MASK2 = 0xFF00FF00; const static uint32_t MASK2 = 0xFF00FF00;
@ -140,7 +138,7 @@ GL_FORCE_INLINE void ClearTriangle() {
tri_count = 0; tri_count = 0;
} }
GL_FORCE_INLINE void ShiftTriangle() { static inline void ShiftTriangle() {
if(!tri_count) { if(!tri_count) {
return; return;
} }
@ -156,7 +154,7 @@ GL_FORCE_INLINE void ShiftTriangle() {
} }
GL_FORCE_INLINE void ShiftRotateTriangle() { static inline void ShiftRotateTriangle() {
if(!tri_count) { if(!tri_count) {
return; return;
} }
@ -177,8 +175,16 @@ void SceneListSubmit(void* src, int n) {
PVR_SET(SPAN_SORT_CFG, 0x0); PVR_SET(SPAN_SORT_CFG, 0x0);
uint32_t *d = (uint32_t*) SQ_BASE_ADDRESS; //Set PVR DMA registers
*PVR_LMMODE0 = 0x0; /* Enable 64bit mode */ volatile int *pvrdmacfg = (int*)0xA05F6888;
pvrdmacfg[0] = 1;
pvrdmacfg[1] = 0;
//Set QACR registers
volatile int *qacr = (int*)0xFF000038;
qacr[1] = qacr[0] = 0x11;
uint32_t *d = SQ_BASE_ADDRESS;
Vertex __attribute__((aligned(32))) tmp; Vertex __attribute__((aligned(32))) tmp;
@ -188,17 +194,14 @@ void SceneListSubmit(void* src, int n) {
if(!_glNearZClippingEnabled()) { if(!_glNearZClippingEnabled()) {
/* Prep store queues */ /* Prep store queues */
for(int i = 0; i < n; ++i, ++vertex) { while(n--) {
PREFETCH(vertex + 1);
if(glIsVertex(vertex->flags)) { if(glIsVertex(vertex->flags)) {
_glPerspectiveDivideVertex(vertex, h); _glPerspectiveDivideVertex(vertex, h);
} }
_glSubmitHeaderOrVertex(d, vertex);
}
/* Wait for both store queues to complete */ _glSubmitHeaderOrVertex(d, vertex);
d = (uint32_t *) SQ_BASE_ADDRESS; ++vertex;
d[0] = d[8] = 0; }
return; return;
} }
@ -211,8 +214,8 @@ void SceneListSubmit(void* src, int n) {
#endif #endif
for(int i = 0; i < n; ++i, ++vertex) { for(int i = 0; i < n; ++i, ++vertex) {
PREFETCH(vertex + 12); PREFETCH(vertex + 1);
PREFETCH(vertex + 2);
/* Wait until we fill the triangle */ /* Wait until we fill the triangle */
if(tri_count < 3) { if(tri_count < 3) {
if(glIsVertex(vertex->flags)) { if(glIsVertex(vertex->flags)) {
@ -422,10 +425,6 @@ void SceneListSubmit(void* src, int n) {
strip_count = 2; strip_count = 2;
} }
} }
/* Wait for both store queues to complete */
d = (uint32_t *)0xe0000000;
d[0] = d[8] = 0;
} }
void SceneListFinish() { void SceneListFinish() {

View File

@ -24,7 +24,7 @@
#define GL_FORCE_INLINE static GL_INLINE_DEBUG #define GL_FORCE_INLINE static GL_INLINE_DEBUG
#endif #endif
#define PREFETCH(addr) __asm__("pref @%0" : : "r"((addr))) #define PREFETCH(addr) __builtin_prefetch((addr))
GL_FORCE_INLINE void* memcpy_fast(void *dest, const void *src, size_t len) { GL_FORCE_INLINE void* memcpy_fast(void *dest, const void *src, size_t len) {
if(!len) { if(!len) {