]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - dpsoftrast.c
Change shader permutation flags to 64bit.
[xonotic/darkplaces.git] / dpsoftrast.c
index bca738af94e2d35137206a7abf2b718877a66ce9..d9c72720449bd3a245da6397b5b873cb0c0da729 100644 (file)
@@ -257,7 +257,7 @@ typedef ALIGN(struct DPSOFTRAST_State_Thread_s
        ALIGN(float fb_clipplane[4]);
 
        int shader_mode;
-       int shader_permutation;
+       dpuint64 shader_permutation;
        int shader_exactspecularmath;
 
        DPSOFTRAST_Texture *texbound[DPSOFTRAST_MAXTEXTUREUNITS];
@@ -336,7 +336,7 @@ typedef ALIGN(struct DPSOFTRAST_State_s
        int drawclipped;
        
        int shader_mode;
-       int shader_permutation;
+       dpuint64 shader_permutation;
        int shader_exactspecularmath;
 
        int texture_max;
@@ -1339,14 +1339,14 @@ void DPSOFTRAST_SetTexCoordPointer(int unitnum, int numcomponents, size_t stride
        dpsoftrast.stride_texcoord[unitnum] = (int)stride;
 }
 
-DEFCOMMAND(18, SetShader, int mode; int permutation; int exactspecularmath;)
+DEFCOMMAND(18, SetShader, int mode; dpuint64 permutation; int exactspecularmath;)
 static void DPSOFTRAST_Interpret_SetShader(DPSOFTRAST_State_Thread *thread, DPSOFTRAST_Command_SetShader *command)
 {
        thread->shader_mode = command->mode;
        thread->shader_permutation = command->permutation;
        thread->shader_exactspecularmath = command->exactspecularmath;
 }
-void DPSOFTRAST_SetShader(int mode, int permutation, int exactspecularmath)
+void DPSOFTRAST_SetShader(int mode, dpuint64 permutation, int exactspecularmath)
 {
        DPSOFTRAST_Command_SetShader *command = DPSOFTRAST_ALLOCATECOMMAND(SetShader);
        command->mode = mode;
@@ -1664,10 +1664,10 @@ static void DPSOFTRAST_Fill4f(float *dst, const float *src, int size)
 static void DPSOFTRAST_Vertex_Transform(float *out4f, const float *in4f, int numitems, const float *inmatrix16f)
 {
 #ifdef SSE_POSSIBLE
-       static const float identitymatrix[4][4] = {{1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1}};
+       static const float identitymatrix16f[4][4] = {{1,0,0,0},{0,1,0,0},{0,0,1,0},{0,0,0,1}};
        __m128 m0, m1, m2, m3;
        float *end;
-       if (!memcmp(identitymatrix, inmatrix16f, sizeof(float[16])))
+       if (!memcmp(identitymatrix16f, inmatrix16f, sizeof(float[16])))
        {
                // fast case for identity matrix
                if (out4f != in4f) memcpy(out4f, in4f, numitems * sizeof(float[4]));
@@ -1810,7 +1810,7 @@ static int DPSOFTRAST_Vertex_BoundY(int *starty, int *endy, const float *minposf
        
 static int DPSOFTRAST_Vertex_Project(float *out4f, float *screen4f, int *starty, int *endy, const float *in4f, int numitems)
 {
-       static const float identitymatrix[16] = {1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1};
+       static const float identitymatrix16f[16] = {1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1};
        float *end = out4f + numitems*4;
        __m128 viewportcenter = _mm_load_ps(dpsoftrast.fb_viewportcenter), viewportscale = _mm_load_ps(dpsoftrast.fb_viewportscale);
        __m128 minpos, maxpos;
@@ -1852,17 +1852,17 @@ static int DPSOFTRAST_Vertex_Project(float *out4f, float *screen4f, int *starty,
                ALIGN(float maxposf[4]);
                _mm_store_ps(minposf, minpos);
                _mm_store_ps(maxposf, maxpos);
-               return DPSOFTRAST_Vertex_BoundY(starty, endy, minposf, maxposf, identitymatrix);
+               return DPSOFTRAST_Vertex_BoundY(starty, endy, minposf, maxposf, identitymatrix16f);
        }
        return 0;
 }
 
 static int DPSOFTRAST_Vertex_TransformProject(float *out4f, float *screen4f, int *starty, int *endy, const float *in4f, int numitems, const float *inmatrix16f)
 {
-       static const float identitymatrix[16] = {1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1};
+       static const float identitymatrix16f[16] = {1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1};
        __m128 m0, m1, m2, m3, viewportcenter, viewportscale, minpos, maxpos;
        float *end;
-       if (!memcmp(identitymatrix, inmatrix16f, sizeof(float[16])))
+       if (!memcmp(identitymatrix16f, inmatrix16f, sizeof(float[16])))
                return DPSOFTRAST_Vertex_Project(out4f, screen4f, starty, endy, in4f, numitems);
        end = out4f + numitems*4;
        viewportcenter = _mm_load_ps(dpsoftrast.fb_viewportcenter);
@@ -2294,12 +2294,12 @@ static void DPSOFTRAST_Texture2DBGRA8(DPSOFTRAST_Texture *texture, int mip, floa
        pixelbase = (unsigned char *)texture->bytes + texture->mipmap[mip][0] + texture->mipmap[mip][1] - 4*width;
        if(texture->filter & DPSOFTRAST_TEXTURE_FILTER_LINEAR)
        {
-               unsigned int tc[2] = { x * (width<<12) - 2048, y * (height<<12) - 2048};
+               unsigned int tc[2] = { (unsigned int)floor(x) * (width<<12) - 2048, (unsigned int)floor(y) * (height<<12) - 2048};
                unsigned int frac[2] = { tc[0]&0xFFF, tc[1]&0xFFF };
                unsigned int ifrac[2] = { 0x1000 - frac[0], 0x1000 - frac[1] };
                unsigned int lerp[4] = { ifrac[0]*ifrac[1], frac[0]*ifrac[1], ifrac[0]*frac[1], frac[0]*frac[1] };
-               int tci[2] = { tc[0]>>12, tc[1]>>12 };
-               int tci1[2] = { tci[0] + 1, tci[1] + 1 };
+               int tci[2] = { (int)tc[0]>>12, (int)tc[1]>>12 };
+               int tci1[2] = { (int)tci[0] + 1, (int)tci[1] + 1 };
                if (texture->flags & DPSOFTRAST_TEXTURE_FLAG_CLAMPTOEDGE)
                {
                        tci[0] = tci[0] >= 0 ? (tci[0] <= wrapmask[0] ? tci[0] : wrapmask[0]) : 0;
@@ -2325,7 +2325,7 @@ static void DPSOFTRAST_Texture2DBGRA8(DPSOFTRAST_Texture *texture, int mip, floa
        }
        else
        {
-               int tci[2] = { x * width, y * height };
+               int tci[2] = { (int)floor(x) * width, (int)floor(y) * height };
                if (texture->flags & DPSOFTRAST_TEXTURE_FLAG_CLAMPTOEDGE)
                {
                        tci[0] = tci[0] >= 0 ? (tci[0] <= wrapmask[0] ? tci[0] : wrapmask[0]) : 0;