summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/r600/r600_texture.c
diff options
context:
space:
mode:
authorJerome Glisse <jglisse@redhat.com>2010-09-01 13:04:42 -0400
committerJerome Glisse <jglisse@redhat.com>2010-09-01 13:04:42 -0400
commit15ce70252c5357081a61f3494261c7e343174301 (patch)
tree896ad87c15a6aad2bf40cca8e69ab2e25420e152 /src/gallium/drivers/r600/r600_texture.c
parent4a955ab6b78e3b3a4cdd54dc933715f0dafbe7f4 (diff)
Revert "Revert "r600g: precompute some of the hw state""
This reverts commit 1fa7245c348cb7aced81f1672140f64cb6450e2f. Conflicts: src/gallium/drivers/r600/r600_state.c
Diffstat (limited to 'src/gallium/drivers/r600/r600_texture.c')
-rw-r--r--src/gallium/drivers/r600/r600_texture.c43
1 files changed, 29 insertions, 14 deletions
diff --git a/src/gallium/drivers/r600/r600_texture.c b/src/gallium/drivers/r600/r600_texture.c
index 77d627cdc8..ec1d50566a 100644
--- a/src/gallium/drivers/r600/r600_texture.c
+++ b/src/gallium/drivers/r600/r600_texture.c
@@ -128,13 +128,25 @@ struct pipe_resource *r600_texture_create(struct pipe_screen *screen,
return &resource->base.b;
}
+static void r600_texture_destroy_state(struct pipe_resource *ptexture)
+{
+ struct r600_resource_texture *rtexture = (struct r600_resource_texture*)ptexture;
+
+ for (int i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++) {
+ radeon_state_decref(rtexture->scissor[i]);
+ radeon_state_decref(rtexture->db[i]);
+ for (int j = 0; j < 8; j++) {
+ radeon_state_decref(rtexture->cb[j][i]);
+ }
+ }
+}
+
static void r600_texture_destroy(struct pipe_screen *screen,
struct pipe_resource *ptex)
{
struct r600_resource_texture *rtex = (struct r600_resource_texture*)ptex;
struct r600_resource *resource = &rtex->resource;
struct r600_screen *rscreen = r600_screen(screen);
- unsigned i;
if (resource->bo) {
radeon_bo_decref(rscreen->rw, resource->bo);
@@ -142,11 +154,7 @@ static void r600_texture_destroy(struct pipe_screen *screen,
if (rtex->uncompressed) {
radeon_bo_decref(rscreen->rw, rtex->uncompressed);
}
- for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++) {
- radeon_state_decref(rtex->scissor[i]);
- radeon_state_decref(rtex->cb0[i]);
- radeon_state_decref(rtex->db[i]);
- }
+ r600_texture_destroy_state(ptex);
FREE(rtex);
}
@@ -211,9 +219,12 @@ struct pipe_resource *r600_texture_from_handle(struct pipe_screen *screen,
pipe_reference_init(&resource->base.b.reference, 1);
resource->base.b.screen = screen;
resource->bo = bo;
+ rtex->depth = 0;
rtex->pitch_override = whandle->stride;
rtex->bpt = util_format_get_blocksize(templ->format);
rtex->pitch[0] = whandle->stride;
+ rtex->width[0] = templ->width0;
+ rtex->height[0] = templ->height0;
rtex->offset[0] = 0;
rtex->size = align(rtex->pitch[0] * templ->height0, 64);
@@ -696,9 +707,9 @@ static struct radeon_state *r600_texture_state_scissor(struct r600_screen *rscre
return rstate;
}
-static struct radeon_state *r600_texture_state_cb0(struct r600_screen *rscreen,
+static struct radeon_state *r600_texture_state_cb(struct r600_screen *rscreen,
struct r600_resource_texture *rtexture,
- unsigned level)
+ unsigned cb, unsigned level)
{
struct radeon_state *rstate;
struct r600_resource *rbuffer;
@@ -707,7 +718,7 @@ static struct radeon_state *r600_texture_state_cb0(struct r600_screen *rscreen,
unsigned format, swap, ntype;
const struct util_format_description *desc;
- rstate = radeon_state(rscreen->rw, R600_STATE_CB0, 0);
+ rstate = radeon_state(rscreen->rw, R600_STATE_CB0 + cb, 0);
if (rstate == NULL)
return NULL;
rbuffer = &rtexture->resource;
@@ -770,6 +781,10 @@ static struct radeon_state *r600_texture_state_db(struct r600_screen *rscreen,
if (rstate == NULL)
return NULL;
rbuffer = &rtexture->resource;
+ rtexture->tilled = 1;
+ rtexture->array_mode = 2;
+ rtexture->tile_type = 1;
+ rtexture->depth = 1;
/* set states (most default value are 0 and struct already
* initialized to 0, thus avoid resetting them)
@@ -838,14 +853,14 @@ static struct radeon_state *r600_texture_state_viewport(struct r600_screen *rscr
return rstate;
}
-int r600_texture_cb0(struct pipe_context *ctx, struct r600_resource_texture *rtexture, unsigned level)
+int r600_texture_cb(struct pipe_context *ctx, struct r600_resource_texture *rtexture, unsigned cb, unsigned level)
{
struct r600_screen *rscreen = r600_screen(ctx->screen);
- if (rtexture->cb0[level] == NULL) {
- rtexture->cb0[level] = r600_texture_state_cb0(rscreen, rtexture, level);
- if (rtexture->cb0[level] == NULL) {
- R600_ERR("failed to create cb0 state for texture\n");
+ if (rtexture->cb[cb][level] == NULL) {
+ rtexture->cb[cb][level] = r600_texture_state_cb(rscreen, rtexture, cb, level);
+ if (rtexture->cb[cb][level] == NULL) {
+ R600_ERR("failed to create cb%d state for texture\n", cb);
return -ENOMEM;
}
}