merge: master
This commit is contained in:
parent
d923a09d32
commit
eeeae88ece
25
GL/clip.c
25
GL/clip.c
|
@ -32,32 +32,28 @@ void _glClipLineToNearZ(const Vertex* v1, const Vertex* v2, Vertex* vout, float*
|
|||
|
||||
float vec [] = {v2->xyz[0] - v1->xyz[0], v2->xyz[1] - v1->xyz[1], v2->xyz[2] - v1->xyz[2]};
|
||||
|
||||
vout->xyz[0] = v1->xyz[0] + (vec[0] * (*t));
|
||||
vout->xyz[1] = v1->xyz[1] + (vec[1] * (*t));
|
||||
vout->xyz[2] = v1->xyz[2] + (vec[2] * (*t));
|
||||
vout->xyz[0] = MATH_fmac(vec[0], (*t), v1->xyz[0]);
|
||||
vout->xyz[1] = MATH_fmac(vec[1], (*t), v1->xyz[1]);
|
||||
vout->xyz[2] = MATH_fmac(vec[2], (*t), v1->xyz[2]);
|
||||
|
||||
}
|
||||
|
||||
static inline void interpolateFloat(const float v1, const float v2, const float t, float* out) {
|
||||
float v = v2 - v1;
|
||||
*out = (v * t) + v1;
|
||||
*out = MATH_fmac(v2 - v1,t, v1);
|
||||
}
|
||||
|
||||
static inline void interpolateVec2(const float* v1, const float* v2, const float t, float* out) {
|
||||
/* FIXME: SH4 has an asm instruction for this */
|
||||
interpolateFloat(v1[0], v2[0], t, &out[0]);
|
||||
interpolateFloat(v1[1], v2[1], t, &out[1]);
|
||||
}
|
||||
|
||||
static inline void interpolateVec3(const float* v1, const float* v2, const float t, float* out) {
|
||||
/* FIXME: SH4 has an asm instruction for this */
|
||||
|
||||
interpolateFloat(v1[0], v2[0], t, &out[0]);
|
||||
interpolateFloat(v1[1], v2[1], t, &out[1]);
|
||||
interpolateFloat(v1[2], v2[2], t, &out[2]);
|
||||
}
|
||||
|
||||
static inline void interpolateVec4(const float* v1, const float* v2, const float t, float* out) {
|
||||
/* FIXME: SH4 has an asm instruction for this */
|
||||
interpolateFloat(v1[0], v2[0], t, &out[0]);
|
||||
interpolateFloat(v1[1], v2[1], t, &out[1]);
|
||||
interpolateFloat(v1[2], v2[2], t, &out[2]);
|
||||
|
@ -120,7 +116,16 @@ void _glClipTriangle(const Triangle* triangle, const uint8_t visible, Submission
|
|||
interpolateVec2(ve1->st, ve2->st, t, veNext.st);
|
||||
|
||||
if(flatShade) {
|
||||
*((uint32_t*) next.bgra) = *((uint32_t*) vertices[2].bgra);
|
||||
/* Original */
|
||||
//*((uint32_t*) next.bgra) = *((uint32_t*) vertices[2].bgra);
|
||||
|
||||
/* "Correct" memcpy */
|
||||
//memcpy(next.bgra, vertices[2].bgra, 4);
|
||||
|
||||
/* manual aliasing */
|
||||
uint32_t* a = (void*)(&vertices[2].bgra[0]);
|
||||
uint32_t* b = (void*)(&next.bgra[0]);
|
||||
*b = *a;
|
||||
} else {
|
||||
interpolateColour(v1->bgra, v2->bgra, t, next.bgra);
|
||||
}
|
||||
|
|
4
GL/glu.c
4
GL/glu.c
|
@ -104,8 +104,8 @@ GLint APIENTRY gluBuild2DMipmaps( GLenum target,GLint internalFormat, GLsizei wi
|
|||
while(th > maxtex)
|
||||
th /= 2;
|
||||
|
||||
levels = 1 + floor(log2(tw));
|
||||
level = 1 + floor(log2(th));
|
||||
levels = 1 + floorf(log2f(tw));
|
||||
level = 1 + floorf(log2f(th));
|
||||
if (level > levels)
|
||||
levels = level;
|
||||
|
||||
|
|
35
GL/matrix.c
35
GL/matrix.c
|
@ -299,7 +299,7 @@ void APIENTRY glFrustum(GLfloat left, GLfloat right,
|
|||
/* Frustum Matrix */
|
||||
static Matrix4x4 FrustumMatrix __attribute__((aligned(32)));
|
||||
|
||||
memset(FrustumMatrix, 0, sizeof(float) * 16);
|
||||
memset4(FrustumMatrix, 0, sizeof(float) * 16);
|
||||
|
||||
const float near2 = 2.0f * znear;
|
||||
const float A = (right + left) / (right - left);
|
||||
|
@ -476,18 +476,15 @@ void APIENTRY glDepthRange(GLclampf n, GLclampf f) {
|
|||
DEPTH_RANGE_MULTIPLIER_H = (n + f) / 2.0f;
|
||||
}
|
||||
|
||||
#include "sh4_math.h"
|
||||
|
||||
/* Vector Cross Product - Used by glhLookAtf2 */
|
||||
static inline void vec3f_cross(GLfloat* v1, GLfloat* v2, GLfloat* result) {
|
||||
result[0] = (v1[1] * v2[2]) - (v1[2] * v2[1]);
|
||||
result[1] = (v1[2] * v2[0]) - (v1[0] * v2[2]);
|
||||
result[2] = (v1[0] * v2[1]) - (v1[1] * v2[0]);
|
||||
/* Vector Cross Product - Used by gluLookAt */
|
||||
static inline void vec3f_cross(const GLfloat* v1, const GLfloat* v2, GLfloat* result) {
|
||||
result[0] = v1[1] * v2[2] - v1[2] * v2[1];
|
||||
result[1] = v1[2] * v2[0] - v1[0] * v2[2];
|
||||
result[2] = v1[0] * v2[1] - v1[1] * v2[0];
|
||||
}
|
||||
|
||||
|
||||
static inline void vec3f_normalize_sh4(float *v){
|
||||
float length, ilength;
|
||||
float length, ilength;
|
||||
|
||||
ilength = MATH_fsrra(v[0]*v[0] + v[1]*v[1] + v[2]*v[2]);
|
||||
length = MATH_Invert(ilength);
|
||||
|
@ -525,8 +522,22 @@ void gluLookAt(GLfloat eyex, GLfloat eyey, GLfloat eyez, GLfloat centerx,
|
|||
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;
|
||||
|
||||
glMultMatrixf(m);
|
||||
glTranslatef(-eyex, -eyey, -eyez);
|
||||
static Matrix4x4 trn __attribute__((aligned(32))) = {
|
||||
1.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 1.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 1.0f
|
||||
};
|
||||
|
||||
trn[M12] = -eyex;
|
||||
trn[M13] = -eyey;
|
||||
trn[M14] = -eyez;
|
||||
|
||||
// Does not modify internal Modelview matrix
|
||||
upload_matrix(&m);
|
||||
multiply_matrix(&trn);
|
||||
multiply_matrix(stack_top(MATRIX_STACKS + (GL_MODELVIEW & 0xF)));
|
||||
download_matrix(stack_top(MATRIX_STACKS + (GL_MODELVIEW & 0xF)));
|
||||
}
|
||||
|
||||
void _glApplyRenderMatrix() {
|
||||
|
|
|
@ -35,7 +35,7 @@ static TexturePalette* _initTexturePalette() {
|
|||
TexturePalette* palette = (TexturePalette*) malloc(sizeof(TexturePalette));
|
||||
assert(palette);
|
||||
|
||||
memset(palette, 0x0, sizeof(TexturePalette));
|
||||
memset4(palette, 0x0, sizeof(TexturePalette));
|
||||
palette->bank = -1;
|
||||
return palette;
|
||||
}
|
||||
|
@ -282,7 +282,7 @@ GLubyte* _glGetMipmapLocation(TextureObject* obj, GLuint level) {
|
|||
}
|
||||
|
||||
GLuint _glGetMipmapLevelCount(TextureObject* obj) {
|
||||
return 1 + floor(log2(MAX(obj->width, obj->height)));
|
||||
return 1 + floorf(log2f(MAX(obj->width, obj->height)));
|
||||
}
|
||||
|
||||
static GLuint _glGetMipmapDataSize(TextureObject* obj) {
|
||||
|
|
|
@ -30,18 +30,19 @@ void named_array_init(NamedArray* array, unsigned int element_size, unsigned int
|
|||
array->max_element_count = max_elements;
|
||||
|
||||
float c = (float) max_elements / 8.0f;
|
||||
array->marker_count = (unsigned char) ceil(c);
|
||||
array->marker_count = (unsigned char) ceilf(c);
|
||||
|
||||
#ifdef _arch_dreamcast
|
||||
// Use 32-bit aligned memory on the Dreamcast
|
||||
array->elements = (unsigned char*) memalign(0x20, element_size * max_elements);
|
||||
array->used_markers = (unsigned char*) memalign(0x20, array->marker_count);
|
||||
memset4(array->elements, 0, element_size * max_elements);
|
||||
#else
|
||||
array->elements = (unsigned char*) malloc(element_size * max_elements);
|
||||
array->used_markers = (unsigned char*) malloc(array->marker_count);
|
||||
memset(array->elements, 0, element_size * max_elements);
|
||||
#endif
|
||||
memset(array->used_markers, 0, sizeof(unsigned char) * array->marker_count);
|
||||
memset(array->elements, 0, element_size * max_elements);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ static GLuint PVR_TextureWidth(unsigned char *HDR);
|
|||
static GLuint PVR_TextureFormat(unsigned char *HDR);
|
||||
|
||||
static GLuint _glGetMipmapLevelCount(GLuint width, GLuint height) {
|
||||
return 1 + floor(log2(MAX(width, height)));
|
||||
return 1 + floorf(log2f(MAX(width, height)));
|
||||
}
|
||||
|
||||
static GLuint _glGetMipmapDataSize(GLuint width, GLuint height) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user