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_fini(&rtexture->scissor[i]);
+ radeon_state_fini(&rtexture->db[i]);
+ for (int j = 0; j < 8; j++) {
+ radeon_state_fini(&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);
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);
}
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);
};
desc = util_format_description(format);
+ word4 |= r600_get_swizzle_combined(desc->swizzle, swizzle_view);
+
/* Colorspace (return non-RGB formats directly). */
switch (desc->colorspace) {
/* Depth stencil formats */
break;
}
- word4 |= r600_get_swizzle_combined(desc->swizzle, swizzle_view);
-
/* S3TC formats. TODO */
if (desc->layout == UTIL_FORMAT_LAYOUT_S3TC) {
goto out_unknown;
*yuv_format_p = yuv_format;
return result;
out_unknown:
- R600_ERR("Unable to handle texformat %d %s\n", format, util_format_name(format));
+// R600_ERR("Unable to handle texformat %d %s\n", format, util_format_name(format));
return ~0;
}
return 0;
}
-static struct radeon_state *r600_texture_state_scissor(struct r600_screen *rscreen,
+static void r600_texture_state_scissor(struct r600_screen *rscreen,
struct r600_resource_texture *rtexture,
unsigned level)
{
- struct radeon_state *rstate;
-
- rstate = radeon_state(rscreen->rw, R600_SCISSOR);
- if (rstate == NULL)
- return NULL;
+ struct radeon_state *rstate = &rtexture->scissor[level];
+ radeon_state_init(rstate, rscreen->rw, R600_STATE_SCISSOR, 0, 0);
/* set states (most default value are 0 and struct already
* initialized to 0, thus avoid resetting them)
*/
rstate->states[R600_SCISSOR__PA_SC_WINDOW_SCISSOR_BR] = S_028244_BR_X(rtexture->width[level]) | S_028244_BR_Y(rtexture->height[level]);
rstate->states[R600_SCISSOR__PA_SC_WINDOW_SCISSOR_TL] = 0x80000000;
- if (radeon_state_pm4(rstate)) {
- radeon_state_decref(rstate);
- return NULL;
- }
- return rstate;
+ radeon_state_pm4(rstate);
}
-static struct radeon_state *r600_texture_state_cb0(struct r600_screen *rscreen,
- struct r600_resource_texture *rtexture,
- unsigned level)
+static void r600_texture_state_cb(struct r600_screen *rscreen, struct r600_resource_texture *rtexture, unsigned cb, unsigned level)
{
struct radeon_state *rstate;
struct r600_resource *rbuffer;
unsigned format, swap, ntype;
const struct util_format_description *desc;
- rstate = radeon_state(rscreen->rw, R600_CB0);
- if (rstate == NULL)
- return NULL;
+ rstate = &rtexture->cb[cb][level];
+ radeon_state_init(rstate, rscreen->rw, R600_STATE_CB0 + cb, 0, 0);
rbuffer = &rtexture->resource;
/* set states (most default value are 0 and struct already
rstate->nbo = 3;
color_info = S_0280A0_SOURCE_FORMAT(1);
}
- rstate->reloc_pm4_id[0] = R600_CB__CB_COLOR0_BASE_BO_ID;
- rstate->reloc_pm4_id[1] = R600_CB__CB_COLOR0_FRAG_BO_ID;
- rstate->reloc_pm4_id[2] = R600_CB__CB_COLOR0_TILE_BO_ID;
color_info |= S_0280A0_FORMAT(format) |
S_0280A0_COMP_SWAP(swap) |
S_0280A0_BLEND_CLAMP(1) |
S_0280A0_NUMBER_TYPE(ntype);
- rstate->states[R600_CB__CB_COLOR0_BASE] = rtexture->offset[level] >> 8;
- rstate->states[R600_CB__CB_COLOR0_INFO] = color_info;
- rstate->states[R600_CB__CB_COLOR0_SIZE] = S_028060_PITCH_TILE_MAX(pitch) |
+ rstate->states[R600_CB0__CB_COLOR0_BASE] = rtexture->offset[level] >> 8;
+ rstate->states[R600_CB0__CB_COLOR0_INFO] = color_info;
+ rstate->states[R600_CB0__CB_COLOR0_SIZE] = S_028060_PITCH_TILE_MAX(pitch) |
S_028060_SLICE_TILE_MAX(slice);
- if (radeon_state_pm4(rstate)) {
- radeon_state_decref(rstate);
- return NULL;
- }
- return rstate;
+ radeon_state_pm4(rstate);
}
-static struct radeon_state *r600_texture_state_db(struct r600_screen *rscreen,
- struct r600_resource_texture *rtexture,
- unsigned level)
+static void r600_texture_state_db(struct r600_screen *rscreen, struct r600_resource_texture *rtexture, unsigned level)
{
- struct radeon_state *rstate;
+ struct radeon_state *rstate = &rtexture->db[level];
struct r600_resource *rbuffer;
unsigned pitch, slice, format;
- rstate = radeon_state(rscreen->rw, R600_DB);
- if (rstate == NULL)
- return NULL;
+ radeon_state_init(rstate, rscreen->rw, R600_STATE_DB, 0, 0);
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)
rstate->states[R600_DB__DB_PREFETCH_LIMIT] = (rtexture->height[level] / 8) -1;
rstate->states[R600_DB__DB_DEPTH_SIZE] = S_028000_PITCH_TILE_MAX(pitch) |
S_028000_SLICE_TILE_MAX(slice);
- rstate->reloc_pm4_id[0] = R600_DB__DB_DEPTH_BASE_BO_ID;
rstate->bo[0] = radeon_bo_incref(rscreen->rw, rbuffer->bo);
rstate->placement[0] = RADEON_GEM_DOMAIN_GTT;
rstate->nbo = 1;
- if (radeon_state_pm4(rstate)) {
- radeon_state_decref(rstate);
- return NULL;
- }
- return rstate;
+ radeon_state_pm4(rstate);
}
int r600_texture_scissor(struct pipe_context *ctx, struct r600_resource_texture *rtexture, unsigned level)
{
struct r600_screen *rscreen = r600_screen(ctx->screen);
- if (rtexture->scissor[level] == NULL) {
- rtexture->scissor[level] = r600_texture_state_scissor(rscreen, rtexture, level);
- if (rtexture->scissor[level] == NULL) {
- R600_ERR("failed to create scissor for uncompressing depth\n");
- return -ENOMEM;
- }
+ if (!rtexture->scissor[level].cpm4) {
+ r600_texture_state_scissor(rscreen, rtexture, level);
}
return 0;
}
-static struct radeon_state *r600_texture_state_viewport(struct r600_screen *rscreen,
- struct r600_resource_texture *rtexture,
- unsigned level)
+static void r600_texture_state_viewport(struct r600_screen *rscreen, struct r600_resource_texture *rtexture, unsigned level)
{
- struct radeon_state *rstate;
+ struct radeon_state *rstate = &rtexture->viewport[level];
- rstate = radeon_state(rscreen->rw, R600_VIEWPORT);
- if (rstate == NULL)
- return NULL;
+ radeon_state_init(rstate, rscreen->rw, R600_STATE_VIEWPORT, 0, 0);
/* set states (most default value are 0 and struct already
* initialized to 0, thus avoid resetting them)
rstate->states[R600_VIEWPORT__PA_CL_VTE_CNTL] = 0x0000043F;
rstate->states[R600_VIEWPORT__PA_SC_VPORT_ZMAX_0] = 0x3F800000;
- if (radeon_state_pm4(rstate)) {
- radeon_state_decref(rstate);
- return NULL;
- }
- return rstate;
+ radeon_state_pm4(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");
- return -ENOMEM;
- }
+ if (!rtexture->cb[cb][level].cpm4) {
+ r600_texture_state_cb(rscreen, rtexture, cb, level);
}
return 0;
}
{
struct r600_screen *rscreen = r600_screen(ctx->screen);
- if (rtexture->db[level] == NULL) {
- rtexture->db[level] = r600_texture_state_db(rscreen, rtexture, level);
- if (rtexture->db[level] == NULL) {
- R600_ERR("failed to create db state for texture\n");
- return -ENOMEM;
- }
+ if (!rtexture->db[level].cpm4) {
+ r600_texture_state_db(rscreen, rtexture, level);
}
return 0;
}
{
struct r600_screen *rscreen = r600_screen(ctx->screen);
- if (rtexture->viewport[level] == NULL) {
- rtexture->viewport[level] = r600_texture_state_viewport(rscreen, rtexture, level);
- if (rtexture->viewport[level] == NULL) {
- R600_ERR("failed to create viewport state for texture\n");
- return -ENOMEM;
- }
+ if (!rtexture->viewport[level].cpm4) {
+ r600_texture_state_viewport(rscreen, rtexture, level);
}
return 0;
}