r300: move some code to common path
authorMaciej Cencora <m.cencora@gmail.com>
Wed, 13 May 2009 21:58:21 +0000 (23:58 +0200)
committerAlex Deucher <alexdeucher@gmail.com>
Sat, 16 May 2009 15:42:03 +0000 (11:42 -0400)
src/mesa/drivers/dri/r300/r300_context.h
src/mesa/drivers/dri/r300/r300_state.c

index cd25b1da017a559c8750ce6d8e7f116f21413f94..4111fa2d81a8e778516ac761ed91e3e9923278f4 100644 (file)
@@ -618,7 +618,7 @@ struct r300_vtable {
        void (* SetupFragmentShaderTextures)(GLcontext *ctx, int *tmu_mappings);
        GLboolean (* BuildFragmentProgramHwCode)(struct r300_fragment_program_compiler *compiler);
        void (* FragmentProgramDump)(union rX00_fragment_program_code *code);
-       GLboolean (* SetupPixelShader)(GLcontext *ctx);
+       void (* SetupPixelShader)(GLcontext *ctx);
 };
 
 
index 7b523e532f4c352c367948d4733e1f2d4f3cc0aa..5821395f66100d5ea62e220a277d219810618df0 100644 (file)
@@ -2279,21 +2279,15 @@ static const GLfloat *get_fragmentprogram_constant(GLcontext *ctx,
 }
 
 
-static GLboolean r300SetupPixelShader(GLcontext *ctx)
+static void r300SetupPixelShader(GLcontext *ctx)
 {
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
        struct r300_fragment_program *fp = (struct r300_fragment_program *) ctx->FragmentProgram._Current;
        struct r300_fragment_program_code *code;
        int i, k;
 
-       /* Program is not native, fallback to software */
-       if (fp->error)
-               return GL_FALSE;
-
        code = &fp->code.r300;
 
-       r300SetupTextures(ctx);
-
        R300_STATECHANGE(rmesa, fpi[0]);
        R300_STATECHANGE(rmesa, fpi[1]);
        R300_STATECHANGE(rmesa, fpi[2]);
@@ -2341,8 +2335,6 @@ static GLboolean r300SetupPixelShader(GLcontext *ctx)
                rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 2] = r300PackFloat24(constant[2]);
                rmesa->hw.fpp.cmd[R300_FPP_PARAM_0 + 4 * i + 3] = r300PackFloat24(constant[3]);
        }
-
-       return GL_TRUE;
 }
 
 #define bump_r500fp_count(ptr, new_count)   do{\
@@ -2359,7 +2351,7 @@ static GLboolean r300SetupPixelShader(GLcontext *ctx)
        if(_nc>_p->r500fp.count)_p->r500fp.count=_nc;\
 } while(0)
 
-static GLboolean r500SetupPixelShader(GLcontext *ctx)
+static void r500SetupPixelShader(GLcontext *ctx)
 {
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
        struct r300_fragment_program *fp = (struct r300_fragment_program *) ctx->FragmentProgram._Current;
@@ -2369,14 +2361,8 @@ static GLboolean r500SetupPixelShader(GLcontext *ctx)
        ((drm_r300_cmd_header_t *) rmesa->hw.r500fp.cmd)->r500fp.count = 0;
        ((drm_r300_cmd_header_t *) rmesa->hw.r500fp_const.cmd)->r500fp.count = 0;
 
-       /* Program is not native, fallback to software */
-       if (fp->error)
-               return GL_FALSE;
-
        code = &fp->code.r500;
 
-       r300SetupTextures(ctx);
-
        R300_STATECHANGE(rmesa, fp);
        rmesa->hw.fp.cmd[R500_FP_PIXSIZE] = code->max_temp_idx;
 
@@ -2412,17 +2398,18 @@ static GLboolean r500SetupPixelShader(GLcontext *ctx)
                rmesa->hw.r500fp_const.cmd[R300_FPP_PARAM_0 + 4 * i + 3] = r300PackFloat32(constant[3]);
        }
        bump_r500fp_const_count(rmesa->hw.r500fp_const.cmd, code->const_nr * 4);
-
-       return GL_TRUE;
 }
 
 void r300UpdateShaderStates(r300ContextPtr rmesa)
 {
        GLcontext *ctx;
        ctx = rmesa->radeon.glCtx;
+       struct r300_fragment_program *r300_fp;
+
+       r300_fp = (struct r300_fragment_program *) ctx->FragmentProgram._Current;
 
        /* should only happenen once, just after context is created */
-       if (!ctx->FragmentProgram._Current)
+       if (!r300_fp)
                return;
 
        r300SetEarlyZState(ctx);
@@ -2450,9 +2437,13 @@ void r300UpdateShaderStates(r300ContextPtr rmesa)
 
        r300TranslateFragmentShader(ctx, ctx->FragmentProgram._Current);
 
-       if (!rmesa->vtbl.SetupPixelShader(ctx))
+       if (r300_fp->error)
                return;
 
+       r300SetupTextures(ctx);
+
+       rmesa->vtbl.SetupPixelShader(ctx);
+
        rmesa->vtbl.SetupRSUnit(ctx);
 
        if (rmesa->options.hw_tcl_enabled)