r600g: fix pointsprite & resource unbinding
authorJerome Glisse <jglisse@redhat.com>
Mon, 27 Sep 2010 18:58:01 +0000 (14:58 -0400)
committerJerome Glisse <jglisse@redhat.com>
Mon, 27 Sep 2010 19:00:17 +0000 (15:00 -0400)
When asking to bind NULL resource assume it's unbinding
so free resource and unreference assoicated buffer.
Also fix pointsprite parameter.

Fix glsl-fs-pointcoord & fp-fragment-position

Signed-off-by: Jerome Glisse <jglisse@redhat.com>
src/gallium/drivers/r600/evergreen_state.c
src/gallium/drivers/r600/r600_state2.c
src/gallium/winsys/r600/drm/evergreen_state.c
src/gallium/winsys/r600/drm/r600_state2.c

index 89f7c7f53a4a5f5d39089fc81d4e8853d277cf3c..1553088aa2130035bd8e47a7d5effc2519f44de5 100644 (file)
@@ -1524,7 +1524,8 @@ void evergreen_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shader
                }
                if (rshader->input[i].name == TGSI_SEMANTIC_FACE)
                        have_face = TRUE;
-               if (rctx->sprite_coord_enable & (1 << i)) {
+               if (rshader->input[i].name == TGSI_SEMANTIC_GENERIC &&
+                       rctx->sprite_coord_enable & (1 << rshader->input[i].sid)) {
                        tmp |= S_028644_PT_SPRITE_TEX(1);
                }
                r600_pipe_state_add_reg(rstate, EVERGREEN_GROUP_CONTEXT, R_028644_SPI_PS_INPUT_CNTL_0 + i * 4, tmp, 0xFFFFFFFF, NULL);
index 8bf8d24549c009694d964b4813567f0d207ba64e..06a6f0d80cc950ee133c00115be58cee1282738f 100644 (file)
@@ -127,7 +127,8 @@ static void r600_pipe_shader_ps(struct pipe_context *ctx, struct r600_pipe_shade
                }
                if (rshader->input[i].name == TGSI_SEMANTIC_FACE)
                        have_face = TRUE;
-               if (rctx->sprite_coord_enable & (1 << i)) {
+               if (rshader->input[i].name == TGSI_SEMANTIC_GENERIC &&
+                       rctx->sprite_coord_enable & (1 << rshader->input[i].sid)) {
                        tmp |= S_028644_PT_SPRITE_TEX(1);
                }
                r600_pipe_state_add_reg(rstate, R600_GROUP_CONTEXT, R_028644_SPI_PS_INPUT_CNTL_0 + i * 4, tmp, 0xFFFFFFFF, NULL);
index c2455e3a490442491e6986e3a948b78f9d7893c2..1cc22a98fd1b58a254fe0e980fd798be4045b443 100644 (file)
@@ -625,6 +625,12 @@ static inline void evergreen_context_pipe_state_set_resource(struct r600_context
        offset -= ctx->groups[EVERGREEN_GROUP_RESOURCE].start_offset;
        id = ctx->groups[EVERGREEN_GROUP_RESOURCE].offset_block_id[offset >> 2];
        block = &ctx->groups[EVERGREEN_GROUP_RESOURCE].blocks[id];
+       if (state == NULL) {
+               block->status &= ~(R600_BLOCK_STATUS_ENABLED | R600_BLOCK_STATUS_DIRTY);
+               radeon_ws_bo_reference(ctx->radeon, &block->reloc[1].bo, NULL);
+               radeon_ws_bo_reference(ctx->radeon , &block->reloc[2].bo, NULL);
+               return;
+       }
        block->reg[0] = state->regs[0].value;
        block->reg[1] = state->regs[1].value;
        block->reg[2] = state->regs[2].value;
@@ -673,6 +679,10 @@ static inline void evergreen_context_pipe_state_set_sampler(struct r600_context
        offset -= ctx->groups[EVERGREEN_GROUP_SAMPLER].start_offset;
        id = ctx->groups[EVERGREEN_GROUP_SAMPLER].offset_block_id[offset >> 2];
        block = &ctx->groups[EVERGREEN_GROUP_SAMPLER].blocks[id];
+       if (state == NULL) {
+               block->status &= ~(R600_BLOCK_STATUS_ENABLED | R600_BLOCK_STATUS_DIRTY);
+               return;
+       }
        block->reg[0] = state->regs[0].value;
        block->reg[1] = state->regs[1].value;
        block->reg[2] = state->regs[2].value;
@@ -689,6 +699,13 @@ static inline void evergreen_context_pipe_state_set_sampler_border(struct r600_c
        fake_offset -= ctx->groups[EVERGREEN_GROUP_SAMPLER_BORDER].start_offset;
        id = ctx->groups[EVERGREEN_GROUP_SAMPLER_BORDER].offset_block_id[fake_offset >> 2];
        block = &ctx->groups[EVERGREEN_GROUP_SAMPLER_BORDER].blocks[id];
+       if (state == NULL) {
+               block->status &= ~(R600_BLOCK_STATUS_ENABLED | R600_BLOCK_STATUS_DIRTY);
+               return;
+       }
+       if (state->nregs <= 3) {
+               return;
+       }
        block->reg[0] = id;
        block->reg[1] = state->regs[3].value;
        block->reg[2] = state->regs[4].value;
@@ -704,9 +721,7 @@ void evergreen_context_pipe_state_set_ps_sampler(struct r600_context *ctx, struc
 
        offset = 0x0003C000 + id * 0xc;
        evergreen_context_pipe_state_set_sampler(ctx, state, offset);
-       if (state->nregs > 3) {
-               evergreen_context_pipe_state_set_sampler_border(ctx, state, R_00A400_TD_PS_SAMPLER0_BORDER_INDEX, id);
-       }
+       evergreen_context_pipe_state_set_sampler_border(ctx, state, R_00A400_TD_PS_SAMPLER0_BORDER_INDEX, id);
 }
 
 void evergreen_context_pipe_state_set_vs_sampler(struct r600_context *ctx, struct r600_pipe_state *state, unsigned id)
@@ -715,9 +730,7 @@ void evergreen_context_pipe_state_set_vs_sampler(struct r600_context *ctx, struc
 
        offset = 0x0003C0D8 + id * 0xc;
        evergreen_context_pipe_state_set_sampler(ctx, state, offset);
-       if (state->nregs > 3) {
-               evergreen_context_pipe_state_set_sampler_border(ctx, state, R_00A414_TD_VS_SAMPLER0_BORDER_INDEX, id);
-       }
+       evergreen_context_pipe_state_set_sampler_border(ctx, state, R_00A414_TD_VS_SAMPLER0_BORDER_INDEX, id);
 }
 
 
index c4b45e565c5d83626f1db8aae65d5d3797910bfc..97aecc7a42ce0ef97784bc1314f4f2b2a4ab87fe 100644 (file)
@@ -802,6 +802,12 @@ static inline void r600_context_pipe_state_set_resource(struct r600_context *ctx
        offset -= ctx->groups[R600_GROUP_RESOURCE].start_offset;
        id = ctx->groups[R600_GROUP_RESOURCE].offset_block_id[offset >> 2];
        block = &ctx->groups[R600_GROUP_RESOURCE].blocks[id];
+       if (state == NULL) {
+               block->status &= ~(R600_BLOCK_STATUS_ENABLED | R600_BLOCK_STATUS_DIRTY);
+               radeon_ws_bo_reference(ctx->radeon, &block->reloc[1].bo, NULL);
+               radeon_ws_bo_reference(ctx->radeon , &block->reloc[2].bo, NULL);
+               return;
+       }
        block->reg[0] = state->regs[0].value;
        block->reg[1] = state->regs[1].value;
        block->reg[2] = state->regs[2].value;
@@ -849,6 +855,10 @@ static inline void r600_context_pipe_state_set_sampler(struct r600_context *ctx,
        offset -= ctx->groups[R600_GROUP_SAMPLER].start_offset;
        id = ctx->groups[R600_GROUP_SAMPLER].offset_block_id[offset >> 2];
        block = &ctx->groups[R600_GROUP_SAMPLER].blocks[id];
+       if (state == NULL) {
+               block->status &= ~(R600_BLOCK_STATUS_ENABLED | R600_BLOCK_STATUS_DIRTY);
+               return;
+       }
        block->reg[0] = state->regs[0].value;
        block->reg[1] = state->regs[1].value;
        block->reg[2] = state->regs[2].value;
@@ -865,6 +875,13 @@ static inline void r600_context_pipe_state_set_sampler_border(struct r600_contex
        offset -= ctx->groups[R600_GROUP_CONFIG].start_offset;
        id = ctx->groups[R600_GROUP_CONFIG].offset_block_id[offset >> 2];
        block = &ctx->groups[R600_GROUP_CONFIG].blocks[id];
+       if (state == NULL) {
+               block->status &= ~(R600_BLOCK_STATUS_ENABLED | R600_BLOCK_STATUS_DIRTY);
+               return;
+       }
+       if (state->nregs <= 3) {
+               return;
+       }
        block->reg[0] = state->regs[3].value;
        block->reg[1] = state->regs[4].value;
        block->reg[2] = state->regs[5].value;
@@ -880,10 +897,8 @@ void r600_context_pipe_state_set_ps_sampler(struct r600_context *ctx, struct r60
 
        offset = 0x0003C000 + id * 0xc;
        r600_context_pipe_state_set_sampler(ctx, state, offset);
-       if (state->nregs > 3) {
-               offset = 0x0000A400 + id * 0x10;
-               r600_context_pipe_state_set_sampler_border(ctx, state, offset);
-       }
+       offset = 0x0000A400 + id * 0x10;
+       r600_context_pipe_state_set_sampler_border(ctx, state, offset);
 }
 
 void r600_context_pipe_state_set_vs_sampler(struct r600_context *ctx, struct r600_pipe_state *state, unsigned id)
@@ -892,10 +907,8 @@ void r600_context_pipe_state_set_vs_sampler(struct r600_context *ctx, struct r60
 
        offset = 0x0003C0D8 + id * 0xc;
        r600_context_pipe_state_set_sampler(ctx, state, offset);
-       if (state->nregs > 3) {
-               offset = 0x0000A600 + id * 0x10;
-               r600_context_pipe_state_set_sampler_border(ctx, state, offset);
-       }
+       offset = 0x0000A600 + id * 0x10;
+       r600_context_pipe_state_set_sampler_border(ctx, state, offset);
 }
 
 void r600_context_group_emit_dirty(struct r600_context *ctx, struct r600_group *group)