X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=dpsoftrast.c;h=6a75be2e521411fe8d440b3d2f4f1d70767c083f;hb=8367a30715017e7a497f6baf65dbaff5f72d6cf3;hp=754cf685ddfe84d3a02d7f63a5dfa44bf5350b20;hpb=174371d91d9450d9b746e581c54241acc3e757d3;p=xonotic%2Fdarkplaces.git diff --git a/dpsoftrast.c b/dpsoftrast.c index 754cf685..6a75be2e 100644 --- a/dpsoftrast.c +++ b/dpsoftrast.c @@ -617,9 +617,6 @@ int DPSOFTRAST_Texture_New(int flags, int width, int height, int depth) d = depth; size = 0; mipmaps = 0; - w = width; - h = height; - d = depth; for (;;) { s = w * h * d * sides * 4; @@ -1321,25 +1318,25 @@ void DPSOFTRAST_SetTexture(int unitnum, int index) void DPSOFTRAST_SetVertexPointer(const float *vertex3f, size_t stride) { dpsoftrast.pointer_vertex3f = vertex3f; - dpsoftrast.stride_vertex = stride; + dpsoftrast.stride_vertex = (int)stride; } void DPSOFTRAST_SetColorPointer(const float *color4f, size_t stride) { dpsoftrast.pointer_color4f = color4f; dpsoftrast.pointer_color4ub = NULL; - dpsoftrast.stride_color = stride; + dpsoftrast.stride_color = (int)stride; } void DPSOFTRAST_SetColorPointer4ub(const unsigned char *color4ub, size_t stride) { dpsoftrast.pointer_color4f = NULL; dpsoftrast.pointer_color4ub = color4ub; - dpsoftrast.stride_color = stride; + dpsoftrast.stride_color = (int)stride; } void DPSOFTRAST_SetTexCoordPointer(int unitnum, int numcomponents, size_t stride, const float *texcoordf) { dpsoftrast.pointer_texcoordf[unitnum] = texcoordf; dpsoftrast.components_texcoord[unitnum] = numcomponents; - dpsoftrast.stride_texcoord[unitnum] = stride; + dpsoftrast.stride_texcoord[unitnum] = (int)stride; } DEFCOMMAND(18, SetShader, int mode; int permutation; int exactspecularmath;) @@ -1728,14 +1725,6 @@ static void DPSOFTRAST_Vertex_Copy(float *out4f, const float *in4f, int numitems out = _mm_shuffle_ps(p, p, _MM_SHUFFLE(0, 3, 2, 1)); \ } -#define DPSOFTRAST_PROJECTY(out, in, viewportcenter, viewportscale) \ -{ \ - __m128 p = (in), w = _mm_shuffle_ps(p, p, _MM_SHUFFLE(3, 3, 3, 3)); \ - p = _mm_move_ss(_mm_shuffle_ps(p, p, _MM_SHUFFLE(2, 1, 0, 3)), _mm_set_ss(1.0f)); \ - p = _mm_add_ps(viewportcenter, _mm_div_ps(_mm_mul_ps(viewportscale, p), w)); \ - out = _mm_shuffle_ps(p, p, _MM_SHUFFLE(0, 3, 2, 1)); \ -} - #define DPSOFTRAST_TRANSFORMVERTEX(out, in, m0, m1, m2, m3) \ { \ __m128 p = (in); \ @@ -4050,7 +4039,7 @@ void DPSOFTRAST_PixelShader_LightDirection(DPSOFTRAST_State_Thread *thread, cons { for (x = startx;x < endx;x++) { - z = buffer_z[x]; + // z = buffer_z[x]; diffusetex[0] = buffer_texture_colorbgra8[x*4+0]; diffusetex[1] = buffer_texture_colorbgra8[x*4+1]; diffusetex[2] = buffer_texture_colorbgra8[x*4+2]; @@ -4160,7 +4149,7 @@ static void DPSOFTRAST_PixelShader_LightSource(DPSOFTRAST_State_Thread *thread, unsigned char buffer_texture_shirtbgra8[DPSOFTRAST_DRAW_MAXSPANLENGTH*4]; unsigned char buffer_FragColorbgra8[DPSOFTRAST_DRAW_MAXSPANLENGTH*4]; int x, startx = span->startx, endx = span->endx; - float Color_Ambient[4], Color_Diffuse[4], Color_Specular[4], Color_Glow[4], Color_Pants[4], Color_Shirt[4], LightColor[4]; + float Color_Ambient[4], Color_Diffuse[4], Color_Specular[4], /*Color_Glow[4],*/ Color_Pants[4], Color_Shirt[4], LightColor[4]; float CubeVectordata[4]; float CubeVectorslope[4]; float LightVectordata[4]; @@ -4180,10 +4169,12 @@ static void DPSOFTRAST_PixelShader_LightSource(DPSOFTRAST_State_Thread *thread, float CubeVector[4]; float attenuation; int d[4]; +#if 0 Color_Glow[2] = thread->uniform4f[DPSOFTRAST_UNIFORM_Color_Glow*4+0]; Color_Glow[1] = thread->uniform4f[DPSOFTRAST_UNIFORM_Color_Glow*4+1]; Color_Glow[0] = thread->uniform4f[DPSOFTRAST_UNIFORM_Color_Glow*4+2]; Color_Glow[3] = 0.0f; +#endif Color_Ambient[2] = thread->uniform4f[DPSOFTRAST_UNIFORM_Color_Ambient*4+0]; Color_Ambient[1] = thread->uniform4f[DPSOFTRAST_UNIFORM_Color_Ambient*4+1]; Color_Ambient[0] = thread->uniform4f[DPSOFTRAST_UNIFORM_Color_Ambient*4+2]; @@ -4455,7 +4446,7 @@ static void DPSOFTRAST_VertexShader_Refraction(void) static void DPSOFTRAST_PixelShader_Refraction(DPSOFTRAST_State_Thread *thread, const DPSOFTRAST_State_Triangle * RESTRICT triangle, const DPSOFTRAST_State_Span * RESTRICT span) { float buffer_z[DPSOFTRAST_DRAW_MAXSPANLENGTH]; - float z; + //float z; int x, startx = span->startx, endx = span->endx; // texture reads @@ -4503,7 +4494,7 @@ static void DPSOFTRAST_PixelShader_Refraction(DPSOFTRAST_State_Thread *thread, c float iw; unsigned char c[4]; - z = buffer_z[x]; + //z = buffer_z[x]; // " vec2 ScreenScaleRefractReflectIW = ScreenScaleRefractReflect.xy * (1.0 / ModelViewProjectionPosition.w);\n" iw = 1.0f / (ModelViewProjectionPositiondata[3] + ModelViewProjectionPositionslope[3]*x); // / z @@ -4587,7 +4578,7 @@ static void DPSOFTRAST_VertexShader_Water(void) static void DPSOFTRAST_PixelShader_Water(DPSOFTRAST_State_Thread *thread, const DPSOFTRAST_State_Triangle * RESTRICT triangle, const DPSOFTRAST_State_Span * RESTRICT span) { float buffer_z[DPSOFTRAST_DRAW_MAXSPANLENGTH]; - float z; + // float z; int x, startx = span->startx, endx = span->endx; // texture reads @@ -4656,7 +4647,7 @@ static void DPSOFTRAST_PixelShader_Water(DPSOFTRAST_State_Thread *thread, const unsigned char c2[4]; float Fresnel; - z = buffer_z[x]; + // z = buffer_z[x]; // " vec4 ScreenScaleRefractReflectIW = ScreenScaleRefractReflect * (1.0 / ModelViewProjectionPosition.w);\n" iw = 1.0f / (ModelViewProjectionPositiondata[3] + ModelViewProjectionPositionslope[3]*x); // / z @@ -4702,23 +4693,6 @@ static void DPSOFTRAST_PixelShader_Water(DPSOFTRAST_State_Thread *thread, const -static void DPSOFTRAST_VertexShader_ShowDepth(void) -{ - DPSOFTRAST_Array_TransformProject(DPSOFTRAST_ARRAY_POSITION, DPSOFTRAST_ARRAY_POSITION, dpsoftrast.uniform4f + 4*DPSOFTRAST_UNIFORM_ModelViewProjectionMatrixM1); -} - -static void DPSOFTRAST_PixelShader_ShowDepth(DPSOFTRAST_State_Thread *thread, const DPSOFTRAST_State_Triangle * RESTRICT triangle, const DPSOFTRAST_State_Span * RESTRICT span) -{ - // TODO: IMPLEMENT - float buffer_z[DPSOFTRAST_DRAW_MAXSPANLENGTH]; - unsigned char buffer_FragColorbgra8[DPSOFTRAST_DRAW_MAXSPANLENGTH*4]; - DPSOFTRAST_Draw_Span_Begin(thread, triangle, span, buffer_z); - memset(buffer_FragColorbgra8 + span->startx*4, 0, (span->endx - span->startx)*4); - DPSOFTRAST_Draw_Span_FinishBGRA8(thread, triangle, span, buffer_FragColorbgra8); -} - - - static void DPSOFTRAST_VertexShader_DeferredGeometry(void) { DPSOFTRAST_Array_TransformProject(DPSOFTRAST_ARRAY_POSITION, DPSOFTRAST_ARRAY_POSITION, dpsoftrast.uniform4f + 4*DPSOFTRAST_UNIFORM_ModelViewProjectionMatrixM1); @@ -4780,7 +4754,6 @@ static const DPSOFTRAST_ShaderModeInfo DPSOFTRAST_ShaderModeTable[SHADERMODE_COU {2, DPSOFTRAST_VertexShader_LightSource, DPSOFTRAST_PixelShader_LightSource, {DPSOFTRAST_ARRAY_TEXCOORD0, DPSOFTRAST_ARRAY_TEXCOORD1, DPSOFTRAST_ARRAY_TEXCOORD2, DPSOFTRAST_ARRAY_TEXCOORD3, DPSOFTRAST_ARRAY_TEXCOORD4, ~0}, {GL20TU_COLOR, GL20TU_PANTS, GL20TU_SHIRT, GL20TU_GLOW, GL20TU_NORMAL, GL20TU_GLOSS, GL20TU_CUBE, ~0}}, {2, DPSOFTRAST_VertexShader_Refraction, DPSOFTRAST_PixelShader_Refraction, {DPSOFTRAST_ARRAY_TEXCOORD0, DPSOFTRAST_ARRAY_TEXCOORD4, ~0}, {GL20TU_NORMAL, GL20TU_REFRACTION, ~0}}, {2, DPSOFTRAST_VertexShader_Water, DPSOFTRAST_PixelShader_Water, {DPSOFTRAST_ARRAY_TEXCOORD0, DPSOFTRAST_ARRAY_TEXCOORD1, DPSOFTRAST_ARRAY_TEXCOORD2, DPSOFTRAST_ARRAY_TEXCOORD3, DPSOFTRAST_ARRAY_TEXCOORD4, DPSOFTRAST_ARRAY_TEXCOORD6, ~0}, {GL20TU_NORMAL, GL20TU_REFLECTION, GL20TU_REFRACTION, ~0}}, - {2, DPSOFTRAST_VertexShader_ShowDepth, DPSOFTRAST_PixelShader_ShowDepth, {~0}}, {2, DPSOFTRAST_VertexShader_DeferredGeometry, DPSOFTRAST_PixelShader_DeferredGeometry, {~0}}, {2, DPSOFTRAST_VertexShader_DeferredLightSource, DPSOFTRAST_PixelShader_DeferredLightSource, {~0}}, }; @@ -4795,8 +4768,6 @@ static void DPSOFTRAST_Draw_DepthTest(DPSOFTRAST_State_Thread *thread, DPSOFTRAS int depthslope; unsigned int d; unsigned char *pixelmask; - DPSOFTRAST_State_Triangle *triangle; - triangle = &thread->triangles[span->triangle]; depthpixel = dpsoftrast.fb_depthpixels + span->y * dpsoftrast.fb_width + span->x; startx = span->startx; endx = span->endx;