*/
#include "si_pipe.h"
-#include "sid.h"
#include "util/u_format.h"
#include "util/u_surface.h"
if (op & SI_SAVE_TEXTURES) {
util_blitter_save_fragment_sampler_states(
sctx->blitter, 2,
- sctx->samplers[PIPE_SHADER_FRAGMENT].views.sampler_states);
+ (void**)sctx->samplers[PIPE_SHADER_FRAGMENT].views.sampler_states);
util_blitter_save_fragment_sampler_views(sctx->blitter, 2,
sctx->samplers[PIPE_SHADER_FRAGMENT].views.views);
/* disable levels without DCC */
for (int i = first_level; i <= last_level; i++) {
- if (!rtex->dcc_offset ||
- !rtex->surface.level[i].dcc_enabled)
+ if (!vi_dcc_enabled(rtex, i))
level_mask &= ~(1 << i);
}
} else if (rtex->fmask.size) {
}
}
+static void
+si_decompress_color_texture(struct si_context *sctx, struct r600_texture *tex,
+ unsigned first_level, unsigned last_level)
+{
+ /* CMASK or DCC can be discarded and we can still end up here. */
+ if (!tex->cmask.size && !tex->fmask.size && !tex->dcc_offset)
+ return;
+
+ si_blit_decompress_color(&sctx->b.b, tex, first_level, last_level, 0,
+ util_max_layer(&tex->resource.b.b, first_level),
+ false);
+}
+
static void
si_decompress_sampler_color_textures(struct si_context *sctx,
struct si_textures_info *textures)
assert(view);
tex = (struct r600_texture *)view->texture;
- assert(tex->cmask.size || tex->fmask.size || tex->dcc_offset);
- si_blit_decompress_color(&sctx->b.b, tex,
- view->u.tex.first_level, view->u.tex.last_level,
- 0, util_max_layer(&tex->resource.b.b, view->u.tex.first_level),
- false);
+ si_decompress_color_texture(sctx, tex, view->u.tex.first_level,
+ view->u.tex.last_level);
}
}
assert(view->resource->target != PIPE_BUFFER);
tex = (struct r600_texture *)view->resource;
- if (!tex->cmask.size && !tex->fmask.size && !tex->dcc_offset)
+
+ si_decompress_color_texture(sctx, tex, view->u.tex.level,
+ view->u.tex.level);
+ }
+}
+
+static void si_check_render_feedback_texture(struct si_context *sctx,
+ struct r600_texture *tex,
+ unsigned first_level,
+ unsigned last_level,
+ unsigned first_layer,
+ unsigned last_layer)
+{
+ bool render_feedback = false;
+
+ if (!tex->dcc_offset)
+ return;
+
+ for (unsigned j = 0; j < sctx->framebuffer.state.nr_cbufs; ++j) {
+ struct r600_surface * surf;
+
+ if (!sctx->framebuffer.state.cbufs[j])
continue;
- si_blit_decompress_color(&sctx->b.b, tex,
- view->u.tex.level, view->u.tex.level,
- 0, util_max_layer(&tex->resource.b.b, view->u.tex.level),
- false);
+ surf = (struct r600_surface*)sctx->framebuffer.state.cbufs[j];
+
+ if (tex == (struct r600_texture *)surf->base.texture &&
+ surf->base.u.tex.level >= first_level &&
+ surf->base.u.tex.level <= last_level &&
+ surf->base.u.tex.first_layer <= last_layer &&
+ surf->base.u.tex.last_layer >= first_layer) {
+ render_feedback = true;
+ break;
+ }
}
+
+ if (render_feedback)
+ r600_texture_disable_dcc(&sctx->b, tex);
}
static void si_check_render_feedback_textures(struct si_context *sctx,
while (mask) {
const struct pipe_sampler_view *view;
struct r600_texture *tex;
- bool render_feedback = false;
unsigned i = u_bit_scan(&mask);
continue;
tex = (struct r600_texture *)view->texture;
- if (!tex->dcc_offset)
- continue;
- for (unsigned j = 0; j < sctx->framebuffer.state.nr_cbufs; ++j) {
- struct r600_surface * surf;
-
- if (!sctx->framebuffer.state.cbufs[j])
- continue;
-
- surf = (struct r600_surface*)sctx->framebuffer.state.cbufs[j];
-
- if (tex == (struct r600_texture*)surf->base.texture &&
- surf->base.u.tex.level >= view->u.tex.first_level &&
- surf->base.u.tex.level <= view->u.tex.last_level &&
- surf->base.u.tex.first_layer <= view->u.tex.last_layer &&
- surf->base.u.tex.last_layer >= view->u.tex.first_layer)
- render_feedback = true;
- }
-
- if (render_feedback)
- r600_texture_disable_dcc(&sctx->b, tex);
+ si_check_render_feedback_texture(sctx, tex,
+ view->u.tex.first_level,
+ view->u.tex.last_level,
+ view->u.tex.first_layer,
+ view->u.tex.last_layer);
}
}
while (mask) {
const struct pipe_image_view *view;
struct r600_texture *tex;
- bool render_feedback = false;
unsigned i = u_bit_scan(&mask);
continue;
tex = (struct r600_texture *)view->resource;
- if (!tex->dcc_offset)
- continue;
-
- for (unsigned j = 0; j < sctx->framebuffer.state.nr_cbufs; ++j) {
- struct r600_surface * surf;
-
- if (!sctx->framebuffer.state.cbufs[j])
- continue;
-
- surf = (struct r600_surface*)sctx->framebuffer.state.cbufs[j];
- if (tex == (struct r600_texture*)surf->base.texture &&
- surf->base.u.tex.level == view->u.tex.level &&
- surf->base.u.tex.first_layer <= view->u.tex.last_layer &&
- surf->base.u.tex.last_layer >= view->u.tex.first_layer)
- render_feedback = true;
- }
-
- if (render_feedback)
- r600_texture_disable_dcc(&sctx->b, tex);
+ si_check_render_feedback_texture(sctx, tex,
+ view->u.tex.level,
+ view->u.tex.level,
+ view->u.tex.first_layer,
+ view->u.tex.last_layer);
}
}
sctx->need_check_render_feedback = false;
}
-static void si_decompress_textures(struct si_context *sctx, int shader_start,
- int shader_end)
+static void si_decompress_textures(struct si_context *sctx, unsigned shader_mask)
{
- unsigned compressed_colortex_counter;
+ unsigned compressed_colortex_counter, mask;
if (sctx->blitter->running)
return;
si_update_compressed_colortex_masks(sctx);
}
- /* Flush depth textures which need to be flushed. */
- for (int i = shader_start; i < shader_end; i++) {
+ /* Decompress color & depth textures if needed. */
+ mask = sctx->compressed_tex_shader_mask & shader_mask;
+ while (mask) {
+ unsigned i = u_bit_scan(&mask);
+
if (sctx->samplers[i].depth_texture_mask) {
si_flush_depth_textures(sctx, &sctx->samplers[i]);
}
void si_decompress_graphics_textures(struct si_context *sctx)
{
- si_decompress_textures(sctx, 0, SI_NUM_GRAPHICS_SHADERS);
+ si_decompress_textures(sctx, u_bit_consecutive(0, SI_NUM_GRAPHICS_SHADERS));
}
void si_decompress_compute_textures(struct si_context *sctx)
{
- si_decompress_textures(sctx, SI_NUM_GRAPHICS_SHADERS, SI_NUM_SHADERS);
+ si_decompress_textures(sctx, 1 << PIPE_SHADER_COMPUTE);
}
static void si_clear(struct pipe_context *ctx, unsigned buffers,
const struct pipe_box *src_box)
{
struct si_context *sctx = (struct si_context *)ctx;
+ struct r600_texture *rsrc = (struct r600_texture*)src;
struct pipe_surface *dst_view, dst_templ;
struct pipe_sampler_view src_templ, *src_view;
unsigned dst_width, dst_height, src_width0, src_height0;
- unsigned src_force_level = 0;
+ unsigned dst_width0, dst_height0, src_force_level = 0;
struct pipe_box sbox, dstbox;
/* Handle buffers first. */
if (dst->target == PIPE_BUFFER && src->target == PIPE_BUFFER) {
- si_copy_buffer(sctx, dst, src, dstx, src_box->x, src_box->width);
+ si_copy_buffer(sctx, dst, src, dstx, src_box->x, src_box->width, 0);
return;
}
dst_width = u_minify(dst->width0, dst_level);
dst_height = u_minify(dst->height0, dst_level);
+ dst_width0 = dst->width0;
+ dst_height0 = dst->height0;
src_width0 = src->width0;
src_height0 = src->height0;
util_blitter_default_dst_texture(&dst_templ, dst, dst_level, dstz);
- util_blitter_default_src_texture(&src_templ, src, src_level);
+ util_blitter_default_src_texture(sctx->blitter, &src_templ, src, src_level);
if (util_format_is_compressed(src->format) ||
util_format_is_compressed(dst->format)) {
- unsigned blocksize = util_format_get_blocksize(src->format);
+ unsigned blocksize = rsrc->surface.bpe;
if (blocksize == 8)
src_templ.format = PIPE_FORMAT_R16G16B16A16_UINT; /* 64-bit block */
dst_width = util_format_get_nblocksx(dst->format, dst_width);
dst_height = util_format_get_nblocksy(dst->format, dst_height);
+ dst_width0 = util_format_get_nblocksx(dst->format, dst_width0);
+ dst_height0 = util_format_get_nblocksy(dst->format, dst_height0);
src_width0 = util_format_get_nblocksx(src->format, src_width0);
src_height0 = util_format_get_nblocksy(src->format, src_height0);
src_box = &sbox;
src_force_level = src_level;
- } else if (!util_blitter_is_copy_supported(sctx->blitter, dst, src) ||
- /* also *8_SNORM has precision issues, use UNORM instead */
- util_format_is_snorm8(src->format)) {
+ } else if (!util_blitter_is_copy_supported(sctx->blitter, dst, src)) {
if (util_format_is_subsampled_422(src->format)) {
src_templ.format = PIPE_FORMAT_R8G8B8A8_UINT;
dst_templ.format = PIPE_FORMAT_R8G8B8A8_UINT;
dst_width = util_format_get_nblocksx(dst->format, dst_width);
+ dst_width0 = util_format_get_nblocksx(dst->format, dst_width0);
src_width0 = util_format_get_nblocksx(src->format, src_width0);
dstx = util_format_get_nblocksx(dst->format, dstx);
sbox.width = util_format_get_nblocksx(src->format, src_box->width);
src_box = &sbox;
} else {
- unsigned blocksize = util_format_get_blocksize(src->format);
+ unsigned blocksize = rsrc->surface.bpe;
switch (blocksize) {
case 1:
}
}
+ vi_disable_dcc_if_incompatible_format(&sctx->b, dst, dst_level,
+ dst_templ.format);
+ vi_disable_dcc_if_incompatible_format(&sctx->b, src, src_level,
+ src_templ.format);
+
/* Initialize the surface. */
dst_view = r600_create_surface_custom(ctx, dst, &dst_templ,
+ dst_width0, dst_height0,
dst_width, dst_height);
/* Initialize the sampler view. */
struct si_context *sctx = (struct si_context*)ctx;
struct r600_texture *src = (struct r600_texture*)info->src.resource;
struct r600_texture *dst = (struct r600_texture*)info->dst.resource;
+ MAYBE_UNUSED struct r600_texture *rtmp;
unsigned dst_width = u_minify(info->dst.resource->width0, info->dst.level);
unsigned dst_height = u_minify(info->dst.resource->height0, info->dst.level);
enum pipe_format format = info->src.format;
info->src.box.width == dst_width &&
info->src.box.height == dst_height &&
info->src.box.depth == 1 &&
- dst->surface.level[info->dst.level].mode >= RADEON_SURF_MODE_1D &&
+ !dst->surface.is_linear &&
(!dst->cmask.size || !dst->dirty_level_mask)) { /* dst cannot be fast-cleared */
/* Check the last constraint. */
if (src->surface.micro_tile_mode != dst->surface.micro_tile_mode) {
* it's being overwritten anyway, clear it to uncompressed.
* This is still the fastest codepath even with this clear.
*/
- if (dst->dcc_offset &&
- dst->surface.level[info->dst.level].dcc_enabled) {
+ if (vi_dcc_enabled(dst, info->dst.level)) {
+ /* TODO: Implement per-level DCC clears for GFX9. */
+ if (sctx->b.chip_class >= GFX9 &&
+ info->dst.resource->last_level != 0)
+ goto resolve_to_temp;
+
vi_dcc_clear_level(&sctx->b, dst, info->dst.level,
0xFFFFFFFF);
dst->dirty_level_mask &= ~(1 << info->dst.level);
R600_RESOURCE_FLAG_DISABLE_DCC;
/* The src and dst microtile modes must be the same. */
- if (src->surface.micro_tile_mode == V_009910_ADDR_SURF_DISPLAY_MICRO_TILING)
+ if (src->surface.micro_tile_mode == RADEON_MICRO_MODE_DISPLAY)
templ.bind = PIPE_BIND_SCANOUT;
else
templ.bind = 0;
tmp = ctx->screen->resource_create(ctx->screen, &templ);
if (!tmp)
return false;
+ rtmp = (struct r600_texture*)tmp;
- assert(src->surface.micro_tile_mode ==
- ((struct r600_texture*)tmp)->surface.micro_tile_mode);
+ assert(!rtmp->surface.is_linear);
+ assert(src->surface.micro_tile_mode == rtmp->surface.micro_tile_mode);
/* resolve */
si_blitter_begin(ctx, SI_COLOR_RESOLVE |
* resource_copy_region can't do this yet, because dma_copy calls it
* on failure (recursion).
*/
- if (rdst->surface.level[info->dst.level].mode ==
- RADEON_SURF_MODE_LINEAR_ALIGNED &&
+ if (rdst->surface.is_linear &&
sctx->b.dma_copy &&
util_can_blit_via_copy_region(info, false)) {
sctx->b.dma_copy(ctx, info->dst.resource, info->dst.level,
/* The driver doesn't decompress resources automatically while
* u_blitter is rendering. */
- vi_dcc_disable_if_incompatible_format(&sctx->b, info->src.resource,
+ vi_disable_dcc_if_incompatible_format(&sctx->b, info->src.resource,
info->src.level,
info->src.format);
- vi_dcc_disable_if_incompatible_format(&sctx->b, info->dst.resource,
+ vi_disable_dcc_if_incompatible_format(&sctx->b, info->dst.resource,
info->dst.level,
info->dst.format);
si_decompress_subresource(ctx, info->src.resource, info->mask,
/* The driver doesn't decompress resources automatically while
* u_blitter is rendering. */
- vi_dcc_disable_if_incompatible_format(&sctx->b, tex, base_level,
+ vi_disable_dcc_if_incompatible_format(&sctx->b, tex, base_level,
format);
si_decompress_subresource(ctx, tex, PIPE_MASK_RGBAZS,
base_level, first_layer, last_layer);