Fix software renderer

This commit is contained in:
Luke Benstead 2021-05-14 21:53:27 +01:00
parent 840ac7f0cd
commit 5ea4313d59
4 changed files with 11 additions and 7 deletions

View File

@ -471,7 +471,7 @@ GL_FORCE_INLINE void genQuads(Vertex* output, GLuint count) {
Vertex* final = output + 3;
GLuint i = count >> 2;
while(i--) {
__asm__("pref @%0" : : "r"(pen + 4));
PREFETCH(pen + 4);
swapVertex(pen, final);
final->flags = GPU_CMD_VERTEX_EOL;
@ -639,7 +639,7 @@ static void _readPositionData(ReadDiffuseFunc func, const GLuint first, const GL
uint32_t* flags;
ITERATE(count) {
__asm__("pref @%0" : : "r"(vptr + vstride));
PREFETCH(vptr + vstride);
func(vptr, out);
vptr += vstride;
@ -660,7 +660,7 @@ static void _readUVData(ReadUVFunc func, const GLuint first, const GLuint count,
GLubyte* out = (GLubyte*) output[0].uv;
ITERATE(count) {
__asm__("pref @%0" : : "r"(uvptr + uvstride));
PREFETCH(uvptr + uvstride);
func(uvptr, out);
uvptr += uvstride;
@ -675,7 +675,7 @@ static void _readSTData(ReadUVFunc func, const GLuint first, const GLuint count,
GLubyte* out = (GLubyte*) extra[0].st;
ITERATE(count) {
__asm__("pref @%0" : : "r"(stptr + ststride));
PREFETCH(stptr + ststride);
func(stptr, out);
stptr += ststride;
@ -725,7 +725,7 @@ static void _readDiffuseData(ReadDiffuseFunc func, const GLuint first, const GLu
GLubyte* out = (GLubyte*) output[0].bgra;
ITERATE(count) {
__asm__("pref @%0" : : "r"(cptr + cstride));
PREFETCH(cptr + cstride);
func(cptr, out);
cptr += cstride;

View File

@ -101,7 +101,7 @@ GL_FORCE_INLINE void glPerspectiveDivideStandard(void* src, uint32_t n) {
const float h = GetVideoMode()->height;
while(n--) {
__asm__("pref @%0" : : "r"(vertex + 1));
PREFETCH(vertex + 1);
if(likely(glIsVertex(vertex->flags))) {
const float f = MATH_Fast_Invert(vertex->w);
@ -135,7 +135,7 @@ GL_FORCE_INLINE void glPerspectiveDivideFastMode(void* src, uint32_t n) {
const float h = GetVideoMode()->height;
while(n--) {
__asm__("pref @%0" : : "r"(vertex + 1));
PREFETCH(vertex + 1);
if(likely(glIsVertex(vertex->flags))) {
const float f = MATH_Fast_Invert(vertex->w);

View File

@ -17,6 +17,8 @@
#endif
#define PREFETCH(addr) __asm__("pref @%0" : : "r"((addr)))
/* We use sq_cpy if the src and size is properly aligned. We control that the
* destination is properly aligned so we assert that. */
#define FASTCPY(dst, src, bytes) \

View File

@ -5,6 +5,8 @@
#include "../types.h"
#define PREFETCH(addr) do {} while(0)
#define MATH_Fast_Divide(n, d) (n / d)
#define MATH_fmac(a, b, c) (a * b + c)
#define MATH_Fast_Sqrt(x) sqrtf((x))