r600g: sampler and texture state doesn't need a range/block.
authorDave Airlie <airlied@redhat.com>
Thu, 2 Jun 2011 22:50:58 +0000 (08:50 +1000)
committerDave Airlie <airlied@redhat.com>
Thu, 2 Jun 2011 22:54:25 +0000 (08:54 +1000)
These are handled separately in the winsys, so don't need the calculations
done at this point. this manifested as a crash in point-sprite,

Thanks to XoD on #radeon for pointing it out.

Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600.h
src/gallium/drivers/r600/r600_state.c
src/gallium/drivers/r600/r600_state_common.c

index 9bef3f89ca6625947f06c900f13829300956acc9..54f5410c3246b8fcfa8c803b4cd351d03101cfea 100644 (file)
@@ -337,7 +337,6 @@ static void *evergreen_create_rs_state(struct pipe_context *ctx,
 static void *evergreen_create_sampler_state(struct pipe_context *ctx,
                                        const struct pipe_sampler_state *state)
 {
-       struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
        struct r600_pipe_state *rstate = CALLOC_STRUCT(r600_pipe_state);
        union util_color uc;
        unsigned aniso_flag_offset = state->max_anisotropy > 1 ? 2 : 0;
@@ -348,7 +347,7 @@ static void *evergreen_create_sampler_state(struct pipe_context *ctx,
 
        rstate->id = R600_PIPE_STATE_SAMPLER;
        util_pack_color(state->border_color, PIPE_FORMAT_B8G8R8A8_UNORM, &uc);
-       r600_pipe_state_add_reg(rstate, R_03C000_SQ_TEX_SAMPLER_WORD0_0,
+       r600_pipe_state_add_reg_noblock(rstate, R_03C000_SQ_TEX_SAMPLER_WORD0_0,
                        S_03C000_CLAMP_X(r600_tex_wrap(state->wrap_s)) |
                        S_03C000_CLAMP_Y(r600_tex_wrap(state->wrap_t)) |
                        S_03C000_CLAMP_Z(r600_tex_wrap(state->wrap_r)) |
@@ -358,21 +357,21 @@ static void *evergreen_create_sampler_state(struct pipe_context *ctx,
                        S_03C000_MAX_ANISO(r600_tex_aniso_filter(state->max_anisotropy)) |
                        S_03C000_DEPTH_COMPARE_FUNCTION(r600_tex_compare(state->compare_func)) |
                        S_03C000_BORDER_COLOR_TYPE(uc.ui ? V_03C000_SQ_TEX_BORDER_COLOR_REGISTER : 0), 0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate, R_03C004_SQ_TEX_SAMPLER_WORD1_0,
+       r600_pipe_state_add_reg_noblock(rstate, R_03C004_SQ_TEX_SAMPLER_WORD1_0,
                        S_03C004_MIN_LOD(S_FIXED(CLAMP(state->min_lod, 0, 15), 8)) |
                        S_03C004_MAX_LOD(S_FIXED(CLAMP(state->max_lod, 0, 15), 8)),
                        0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate, R_03C008_SQ_TEX_SAMPLER_WORD2_0,
-                               S_03C008_LOD_BIAS(S_FIXED(CLAMP(state->lod_bias, -16, 16), 8)) |
-                               (state->seamless_cube_map ? 0 : S_03C008_DISABLE_CUBE_WRAP(1)) |
-                               S_03C008_TYPE(1),
-                               0xFFFFFFFF, NULL);
+       r600_pipe_state_add_reg_noblock(rstate, R_03C008_SQ_TEX_SAMPLER_WORD2_0,
+                                       S_03C008_LOD_BIAS(S_FIXED(CLAMP(state->lod_bias, -16, 16), 8)) |
+                                       (state->seamless_cube_map ? 0 : S_03C008_DISABLE_CUBE_WRAP(1)) |
+                                       S_03C008_TYPE(1),
+                                       0xFFFFFFFF, NULL);
 
        if (uc.ui) {
-               r600_pipe_state_add_reg(rstate, R_00A404_TD_PS_SAMPLER0_BORDER_RED, fui(state->border_color[0]), 0xFFFFFFFF, NULL);
-               r600_pipe_state_add_reg(rstate, R_00A408_TD_PS_SAMPLER0_BORDER_GREEN, fui(state->border_color[1]), 0xFFFFFFFF, NULL);
-               r600_pipe_state_add_reg(rstate, R_00A40C_TD_PS_SAMPLER0_BORDER_BLUE, fui(state->border_color[2]), 0xFFFFFFFF, NULL);
-               r600_pipe_state_add_reg(rstate, R_00A410_TD_PS_SAMPLER0_BORDER_ALPHA, fui(state->border_color[3]), 0xFFFFFFFF, NULL);
+               r600_pipe_state_add_reg_noblock(rstate, R_00A404_TD_PS_SAMPLER0_BORDER_RED, fui(state->border_color[0]), 0xFFFFFFFF, NULL);
+               r600_pipe_state_add_reg_noblock(rstate, R_00A408_TD_PS_SAMPLER0_BORDER_GREEN, fui(state->border_color[1]), 0xFFFFFFFF, NULL);
+               r600_pipe_state_add_reg_noblock(rstate, R_00A40C_TD_PS_SAMPLER0_BORDER_BLUE, fui(state->border_color[2]), 0xFFFFFFFF, NULL);
+               r600_pipe_state_add_reg_noblock(rstate, R_00A410_TD_PS_SAMPLER0_BORDER_ALPHA, fui(state->border_color[3]), 0xFFFFFFFF, NULL);
        }
        return rstate;
 }
index 50a07537d3eec1eda7913828e769dba3cbcb4858..23e7181a86e21993258560a5bbe91dc072aa715c 100644 (file)
@@ -317,6 +317,9 @@ void _r600_pipe_state_add_reg(struct r600_context *ctx,
                              u32 range_id, u32 block_id,
                              struct r600_bo *bo);
 
+void r600_pipe_state_add_reg_noblock(struct r600_pipe_state *state,
+                                    u32 offset, u32 value, u32 mask,
+                                    struct r600_bo *bo);
 #define r600_pipe_state_add_reg(state, offset, value, mask, bo) _r600_pipe_state_add_reg(&rctx->ctx, state, offset, value, mask, CTX_RANGE_ID(offset), CTX_BLOCK_ID(offset), bo)
 
 static inline void r600_pipe_state_mod_reg(struct r600_pipe_state *state,
index 3043c5e1c8b0e11137ac1271402b9781d2c2c3bf..e9011de9fe05795125ac90f44d843eb042fcd8e2 100644 (file)
@@ -369,7 +369,6 @@ static void *r600_create_rs_state(struct pipe_context *ctx,
 static void *r600_create_sampler_state(struct pipe_context *ctx,
                                        const struct pipe_sampler_state *state)
 {
-       struct r600_pipe_context *rctx = (struct r600_pipe_context *)ctx;
        struct r600_pipe_state *rstate = CALLOC_STRUCT(r600_pipe_state);
        union util_color uc;
        unsigned aniso_flag_offset = state->max_anisotropy > 1 ? 4 : 0;
@@ -380,26 +379,26 @@ static void *r600_create_sampler_state(struct pipe_context *ctx,
 
        rstate->id = R600_PIPE_STATE_SAMPLER;
        util_pack_color(state->border_color, PIPE_FORMAT_B8G8R8A8_UNORM, &uc);
-       r600_pipe_state_add_reg(rstate, R_03C000_SQ_TEX_SAMPLER_WORD0_0,
-                       S_03C000_CLAMP_X(r600_tex_wrap(state->wrap_s)) |
-                       S_03C000_CLAMP_Y(r600_tex_wrap(state->wrap_t)) |
-                       S_03C000_CLAMP_Z(r600_tex_wrap(state->wrap_r)) |
-                       S_03C000_XY_MAG_FILTER(r600_tex_filter(state->mag_img_filter) | aniso_flag_offset) |
-                       S_03C000_XY_MIN_FILTER(r600_tex_filter(state->min_img_filter) | aniso_flag_offset) |
-                       S_03C000_MIP_FILTER(r600_tex_mipfilter(state->min_mip_filter)) |
-                       S_03C000_MAX_ANISO(r600_tex_aniso_filter(state->max_anisotropy)) |
-                       S_03C000_DEPTH_COMPARE_FUNCTION(r600_tex_compare(state->compare_func)) |
-                       S_03C000_BORDER_COLOR_TYPE(uc.ui ? V_03C000_SQ_TEX_BORDER_COLOR_REGISTER : 0), 0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate, R_03C004_SQ_TEX_SAMPLER_WORD1_0,
-                       S_03C004_MIN_LOD(S_FIXED(CLAMP(state->min_lod, 0, 15), 6)) |
-                       S_03C004_MAX_LOD(S_FIXED(CLAMP(state->max_lod, 0, 15), 6)) |
-                       S_03C004_LOD_BIAS(S_FIXED(CLAMP(state->lod_bias, -16, 16), 6)), 0xFFFFFFFF, NULL);
-       r600_pipe_state_add_reg(rstate, R_03C008_SQ_TEX_SAMPLER_WORD2_0, S_03C008_TYPE(1), 0xFFFFFFFF, NULL);
+       r600_pipe_state_add_reg_noblock(rstate, R_03C000_SQ_TEX_SAMPLER_WORD0_0,
+                                       S_03C000_CLAMP_X(r600_tex_wrap(state->wrap_s)) |
+                                       S_03C000_CLAMP_Y(r600_tex_wrap(state->wrap_t)) |
+                                       S_03C000_CLAMP_Z(r600_tex_wrap(state->wrap_r)) |
+                                       S_03C000_XY_MAG_FILTER(r600_tex_filter(state->mag_img_filter) | aniso_flag_offset) |
+                                       S_03C000_XY_MIN_FILTER(r600_tex_filter(state->min_img_filter) | aniso_flag_offset) |
+                                       S_03C000_MIP_FILTER(r600_tex_mipfilter(state->min_mip_filter)) |
+                                       S_03C000_MAX_ANISO(r600_tex_aniso_filter(state->max_anisotropy)) |
+                                       S_03C000_DEPTH_COMPARE_FUNCTION(r600_tex_compare(state->compare_func)) |
+                                       S_03C000_BORDER_COLOR_TYPE(uc.ui ? V_03C000_SQ_TEX_BORDER_COLOR_REGISTER : 0), 0xFFFFFFFF, NULL);
+       r600_pipe_state_add_reg_noblock(rstate, R_03C004_SQ_TEX_SAMPLER_WORD1_0,
+                                       S_03C004_MIN_LOD(S_FIXED(CLAMP(state->min_lod, 0, 15), 6)) |
+                                       S_03C004_MAX_LOD(S_FIXED(CLAMP(state->max_lod, 0, 15), 6)) |
+                                       S_03C004_LOD_BIAS(S_FIXED(CLAMP(state->lod_bias, -16, 16), 6)), 0xFFFFFFFF, NULL);
+       r600_pipe_state_add_reg_noblock(rstate, R_03C008_SQ_TEX_SAMPLER_WORD2_0, S_03C008_TYPE(1), 0xFFFFFFFF, NULL);
        if (uc.ui) {
-               r600_pipe_state_add_reg(rstate, R_00A400_TD_PS_SAMPLER0_BORDER_RED, fui(state->border_color[0]), 0xFFFFFFFF, NULL);
-               r600_pipe_state_add_reg(rstate, R_00A404_TD_PS_SAMPLER0_BORDER_GREEN, fui(state->border_color[1]), 0xFFFFFFFF, NULL);
-               r600_pipe_state_add_reg(rstate, R_00A408_TD_PS_SAMPLER0_BORDER_BLUE, fui(state->border_color[2]), 0xFFFFFFFF, NULL);
-               r600_pipe_state_add_reg(rstate, R_00A40C_TD_PS_SAMPLER0_BORDER_ALPHA, fui(state->border_color[3]), 0xFFFFFFFF, NULL);
+               r600_pipe_state_add_reg_noblock(rstate, R_00A400_TD_PS_SAMPLER0_BORDER_RED, fui(state->border_color[0]), 0xFFFFFFFF, NULL);
+               r600_pipe_state_add_reg_noblock(rstate, R_00A404_TD_PS_SAMPLER0_BORDER_GREEN, fui(state->border_color[1]), 0xFFFFFFFF, NULL);
+               r600_pipe_state_add_reg_noblock(rstate, R_00A408_TD_PS_SAMPLER0_BORDER_BLUE, fui(state->border_color[2]), 0xFFFFFFFF, NULL);
+               r600_pipe_state_add_reg_noblock(rstate, R_00A40C_TD_PS_SAMPLER0_BORDER_ALPHA, fui(state->border_color[3]), 0xFFFFFFFF, NULL);
        }
        return rstate;
 }
index 14182fb01370d684e5e1a4f576e546fb49927144..19e384b36894ec180fabfe516176b190823fb795 100644 (file)
@@ -676,12 +676,27 @@ void _r600_pipe_state_add_reg(struct r600_context *ctx,
 
        range = &ctx->range[range_id];
        block = range->blocks[block_id];
+       state->regs[state->nregs].block = block;
+       state->regs[state->nregs].id = (offset - block->start_offset) >> 2;
 
        state->regs[state->nregs].value = value;
        state->regs[state->nregs].mask = mask;
        state->regs[state->nregs].bo = bo;
-       state->regs[state->nregs].block = block;
-       state->regs[state->nregs].id = (offset - block->start_offset) >> 2;
+
+       state->nregs++;
+       assert(state->nregs < R600_BLOCK_MAX_REG);
+}
+
+void r600_pipe_state_add_reg_noblock(struct r600_pipe_state *state,
+                                    u32 offset, u32 value, u32 mask,
+                                    struct r600_bo *bo)
+{
+       state->regs[state->nregs].id = offset;
+       state->regs[state->nregs].block = NULL;
+       state->regs[state->nregs].value = value;
+       state->regs[state->nregs].mask = mask;
+       state->regs[state->nregs].bo = bo;
+
        state->nregs++;
        assert(state->nregs < R600_BLOCK_MAX_REG);
 }