X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=dpsoftrast.c;h=52376179de44c69ea08cc84181325b6cb1f90f44;hb=36fe913f95d54768c8dc16d798da13bd3a0eb06c;hp=6674814999e1b159e08fa4dc80bd7d5f9ae0685d;hpb=7c545a08bd3ddcecb0e43b4b62658d6d639faed5;p=xonotic%2Fdarkplaces.git diff --git a/dpsoftrast.c b/dpsoftrast.c index 66748149..52376179 100644 --- a/dpsoftrast.c +++ b/dpsoftrast.c @@ -1,6 +1,7 @@ #include #include +#define _USE_MATH_DEFINES #include #include "quakedef.h" #include "dpsoftrast.h" @@ -545,11 +546,18 @@ void DPSOFTRAST_Texture_CalculateMipmaps(int index) void DPSOFTRAST_Texture_UpdatePartial(int index, int mip, const unsigned char *pixels, int blockx, int blocky, int blockwidth, int blockheight) { DPSOFTRAST_Texture *texture; + unsigned char *dst; texture = DPSOFTRAST_Texture_GetByIndex(index);if (!texture) return; - - // FIXME IMPLEMENT - - dpsoftrast.errorstring = "DPSOFTRAST_Texture_UpdatePartial: Not implemented."; + + dst = texture->bytes + (blocky * texture->mipmap[0][2] + blockx) * 4; + while (blockheight > 0) + { + memcpy(dst, pixels, blockwidth * 4); + pixels += blockwidth * 4; + dst += texture->mipmap[0][2] * 4; + blockheight--; + } + DPSOFTRAST_Texture_CalculateMipmaps(index); } void DPSOFTRAST_Texture_UpdateFull(int index, const unsigned char *pixels) { @@ -904,10 +912,10 @@ void DPSOFTRAST_Uniform4fvARB(DPSOFTRAST_UNIFORM index, const float *v) dpsoftrast.uniform4f[index*4+2] = v[2]; dpsoftrast.uniform4f[index*4+3] = v[3]; } -void DPSOFTRAST_UniformMatrix4fvARB(DPSOFTRAST_UNIFORM index, int arraysize, int transpose, const float *v) +void DPSOFTRAST_UniformMatrix4fvARB(DPSOFTRAST_UNIFORM uniform, int arraysize, int transpose, const float *v) { - int i; - for (i = 0;i < arraysize;i++, index += 4, v += 16) + int i, index; + for (i = 0, index = (int)uniform;i < arraysize;i++, index += 4, v += 16) { if (transpose) { @@ -3584,9 +3592,12 @@ void DPSOFTRAST_Draw_ProcessTriangles(int firstvertex, int numtriangles, const i #define SKIPBACKFACE \ if(cullface != GL_NONE) \ { \ - __m128 triangleedge[2] = { _mm_sub_ps(screen[0], screen[1]), _mm_sub_ps(screen[2], screen[1]) }; \ + __m128 triangleedge[2]; \ + __m128 trianglenormal; \ + triangleedge[0] = _mm_sub_ps(screen[0], screen[1]); \ + triangleedge[1] = _mm_sub_ps(screen[2], screen[1]); \ /* store normal in 2, 0, 1 order instead of 0, 1, 2 as it requires fewer shuffles and leaves z component accessible as scalar */ \ - __m128 trianglenormal = _mm_sub_ss(_mm_mul_ss(triangleedge[0], _mm_shuffle_ps(triangleedge[1], triangleedge[1], _MM_SHUFFLE(3, 0, 2, 1))), \ + trianglenormal = _mm_sub_ss(_mm_mul_ss(triangleedge[0], _mm_shuffle_ps(triangleedge[1], triangleedge[1], _MM_SHUFFLE(3, 0, 2, 1))), \ _mm_mul_ss(_mm_shuffle_ps(triangleedge[0], triangleedge[0], _MM_SHUFFLE(3, 0, 2, 1)), triangleedge[1])); \ /* apply current cullface mode (this culls many triangles) */ \ switch(cullface) \ @@ -3765,7 +3776,7 @@ void DPSOFTRAST_Draw_ProcessTriangles(int firstvertex, int numtriangles, const i y = _mm_cvtss_si32(mipedgetc); if (y > 0) { - y = (int)(log(y)/M_LN2); + y = (int)(log((float)y)/M_LN2); if (y > texture->mipmaps - 1) y = texture->mipmaps - 1; } @@ -3801,7 +3812,7 @@ void DPSOFTRAST_Draw_ProcessTriangles(int firstvertex, int numtriangles, const i case 0xF000: /*1110*/ edge0p = 3;edge0n = 0;edge1p = 3;edge1n = 2;break; case 0x0FFF: /*0001*/ edge0p = 2;edge0n = 3;edge1p = 0;edge1n = 3;break; case 0x0FF0: /*1001*/ edge0p = 2;edge0n = 3;edge1p = 1;edge1n = 0;break; - case 0x0F0F: /*0101*/ edge0p = 2;edge0n = 3;edge1p = 1;edge1n = 2;break; // concave - nonsense + case 0x0F0F: /*0101*/ edge0p = 2;edge0n = 3;edge1p = 2;edge1n = 1;break; // concave - nonsense case 0x0F00: /*1101*/ edge0p = 2;edge0n = 3;edge1p = 2;edge1n = 1;break; case 0x00FF: /*0011*/ edge0p = 1;edge0n = 2;edge1p = 0;edge1n = 3;break; case 0x00F0: /*1011*/ edge0p = 1;edge0n = 2;edge1p = 1;edge1n = 0;break;