unsigned first_level, unsigned last_level)
{
/* CMASK or DCC can be discarded and we can still end up here. */
- if (!tex->cmask_size && !tex->surface.fmask_size && !tex->dcc_offset)
+ if (!tex->cmask_buffer && !tex->surface.fmask_size && !tex->dcc_offset)
return;
si_blit_decompress_color(sctx, tex, first_level, last_level, 0,
si_decompress_depth(sctx, stex, planes,
level, level,
first_layer, last_layer);
- } else if (stex->surface.fmask_size || stex->cmask_size || stex->dcc_offset) {
+ } else if (stex->surface.fmask_size || stex->cmask_buffer || stex->dcc_offset) {
/* If we've rendered into the framebuffer and it's a blitting
* source, make sure the decompression pass is invoked
* by dirtying the framebuffer.
info->src.box.height == dst_height &&
info->src.box.depth == 1 &&
!dst->surface.is_linear &&
- (!dst->cmask_size || !dst->dirty_level_mask)) { /* dst cannot be fast-cleared */
+ (!dst->cmask_buffer || !dst->dirty_level_mask)) { /* dst cannot be fast-cleared */
/* Check the last constraint. */
if (src->surface.micro_tile_mode != dst->surface.micro_tile_mode) {
/* The next fast clear will switch to this mode to
if (tex->dcc_separate_buffer && !tex->separate_dcc_dirty)
return;
- if (!tex->is_depth && (tex->cmask_size || tex->dcc_offset)) {
+ if (!tex->is_depth && (tex->cmask_buffer || tex->dcc_offset)) {
si_blit_decompress_color(sctx, tex, 0, res->last_level,
0, util_max_layer(res, 0),
tex->dcc_separate_buffer != NULL);
static void si_alloc_separate_cmask(struct si_screen *sscreen,
struct si_texture *tex)
{
- if (tex->cmask_buffer)
+ if (tex->cmask_buffer || !tex->surface.cmask_size)
return;
- assert(tex->cmask_size == 0);
-
- if (!tex->surface.cmask_size)
- return;
-
tex->cmask_buffer =
si_aligned_buffer_create(&sscreen->b,
SI_RESOURCE_FLAG_UNMAPPABLE,
if (tex->cmask_buffer == NULL)
return;
- tex->cmask_size = tex->surface.cmask_size;
tex->cmask_base_address_reg = tex->cmask_buffer->gpu_address >> 8;
tex->cb_color_info |= S_028C70_FAST_CLEAR(1);
continue;
/* DCC fast clear with MSAA should clear CMASK to 0xC. */
- if (tex->buffer.b.b.nr_samples >= 2 && tex->cmask_size) {
+ if (tex->buffer.b.b.nr_samples >= 2 && tex->cmask_buffer) {
/* TODO: This doesn't work with MSAA. */
if (eliminate_needed)
continue;
si_clear_buffer(sctx, &tex->cmask_buffer->b.b,
- tex->cmask_offset, tex->cmask_size,
+ tex->cmask_offset, tex->surface.cmask_size,
0xCCCCCCCC, SI_COHERENCY_CB_META);
need_decompress_pass = true;
}
/* ensure CMASK is enabled */
si_alloc_separate_cmask(sctx->screen, tex);
- if (tex->cmask_size == 0) {
+ if (!tex->cmask_buffer)
continue;
- }
/* Do the fast clear. */
si_clear_buffer(sctx, &tex->cmask_buffer->b.b,
- tex->cmask_offset, tex->cmask_size, 0,
+ tex->cmask_offset, tex->surface.cmask_size, 0,
SI_COHERENCY_CB_META);
need_decompress_pass = true;
}
* dst: If overwriting the whole texture, discard CMASK and use
* SDMA. Otherwise, use the 3D path.
*/
- if (dst->cmask_size && dst->dirty_level_mask & (1 << dst_level)) {
+ if (dst->cmask_buffer && dst->dirty_level_mask & (1 << dst_level)) {
/* The CMASK clear is only enabled for the first level. */
assert(dst_level == 0);
if (!util_texrange_covers_whole_level(&dst->buffer.b.b, dst_level,
}
/* All requirements are met. Prepare textures for SDMA. */
- if (src->cmask_size && src->dirty_level_mask & (1 << src_level))
+ if (src->cmask_buffer && src->dirty_level_mask & (1 << src_level))
sctx->b.flush_resource(&sctx->b, &src->buffer.b.b);
assert(!(src->dirty_level_mask & (1 << src_level)));
void si_texture_discard_cmask(struct si_screen *sscreen,
struct si_texture *tex)
{
- if (!tex->cmask_size)
+ if (!tex->cmask_buffer)
return;
assert(tex->buffer.b.b.nr_samples <= 1);
/* Disable CMASK. */
- tex->cmask_size = 0;
tex->cmask_base_address_reg = tex->buffer.gpu_address >> 8;
tex->dirty_level_mask = 0;
if (tex->cmask_buffer != &tex->buffer)
r600_resource_reference(&tex->cmask_buffer, NULL);
+ tex->cmask_buffer = NULL;
+
/* Notify all contexts about the change. */
p_atomic_inc(&sscreen->dirty_tex_counter);
p_atomic_inc(&sscreen->compressed_colortex_counter);
tex->fmask_offset = new_tex->fmask_offset;
tex->cmask_offset = new_tex->cmask_offset;
- tex->cmask_size = new_tex->cmask_size;
tex->cmask_base_address_reg = new_tex->cmask_base_address_reg;
r600_resource_reference(&tex->cmask_buffer, new_tex->cmask_buffer);
tex->dcc_offset = new_tex->dcc_offset;
if (new_bind_flag == PIPE_BIND_LINEAR) {
assert(!tex->htile_offset);
- assert(!tex->cmask_size);
+ assert(!tex->cmask_buffer);
assert(!tex->surface.fmask_size);
assert(!tex->dcc_offset);
assert(!tex->is_depth);
}
if (!(usage & PIPE_HANDLE_USAGE_EXPLICIT_FLUSH) &&
- (tex->cmask_size || tex->dcc_offset)) {
+ (tex->cmask_buffer || tex->dcc_offset)) {
/* Eliminate fast clear (both CMASK and DCC) */
si_eliminate_fast_color_clear(sctx, tex);
/* eliminate_fast_color_clear flushes the context */
/* Disable CMASK if flush_resource isn't going
* to be called.
*/
- if (tex->cmask_size)
+ if (tex->cmask_buffer)
si_texture_discard_cmask(sscreen, tex);
}
tex->surface.u.gfx9.fmask.epitch);
}
- if (tex->cmask_size) {
+ if (tex->cmask_buffer) {
u_log_printf(log, " CMask: offset=%"PRIu64", size=%u, "
"alignment=%u, rb_aligned=%u, pipe_aligned=%u\n",
tex->cmask_offset,
tex->surface.u.legacy.fmask.slice_tile_max,
tex->surface.u.legacy.fmask.tiling_index);
- if (tex->cmask_size)
+ if (tex->cmask_buffer)
u_log_printf(log, " CMask: offset=%"PRIu64", size=%u, alignment=%u, "
"slice_tile_max=%u\n",
- tex->cmask_offset, tex->cmask_size, tex->surface.cmask_alignment,
+ tex->cmask_offset, tex->surface.cmask_size, tex->surface.cmask_alignment,
tex->surface.u.legacy.cmask_slice_tile_max);
if (tex->htile_offset)
tex->size = tex->fmask_offset + tex->surface.fmask_size;
/* Allocate CMASK. */
- tex->cmask_size = tex->surface.cmask_size;
tex->cmask_offset = align64(tex->size, tex->surface.cmask_alignment);
- tex->size = tex->cmask_offset + tex->cmask_size;
+ tex->size = tex->cmask_offset + tex->surface.cmask_size;
tex->cb_color_info |= S_028C70_FAST_CLEAR(1);
tex->cmask_buffer = &tex->buffer;
- if (!tex->surface.fmask_size || !tex->cmask_size) {
+ if (!tex->surface.fmask_size || !tex->surface.cmask_size) {
FREE(tex);
return NULL;
}
resource->gart_usage = buf->size;
}
- if (tex->cmask_size) {
+ if (tex->cmask_buffer) {
/* Initialize the cmask to 0xCC (= compressed state). */
si_screen_clear_buffer(sscreen, &tex->cmask_buffer->b.b,
- tex->cmask_offset, tex->cmask_size,
+ tex->cmask_offset, tex->surface.cmask_size,
0xCCCCCCCC);
}
if (tex->htile_offset) {