static int si_init_surface(struct si_screen *sscreen,
struct radeon_surf *surface,
const struct pipe_resource *ptex,
+ unsigned num_color_samples,
enum radeon_surf_mode array_mode,
unsigned pitch_in_bytes_override,
unsigned offset,
/* VI: DCC clear for 4x and 8x MSAA array textures unimplemented. */
if (sscreen->info.chip_class == VI &&
- ptex->nr_samples >= 4 &&
+ num_color_samples >= 4 &&
ptex->array_size > 1)
flags |= RADEON_SURF_DISABLE_DCC;
/* GFX9: DCC clear for 4x and 8x MSAA textures unimplemented. */
if (sscreen->info.chip_class >= GFX9 &&
- ptex->nr_samples >= 4)
+ num_color_samples >= 4)
flags |= RADEON_SURF_DISABLE_DCC;
if (ptex->bind & PIPE_BIND_SCANOUT || is_scanout) {
if (!(ptex->flags & SI_RESOURCE_FLAG_FORCE_TILING))
flags |= RADEON_SURF_OPTIMIZE_FOR_SPACE;
- r = sscreen->ws->surface_init(sscreen->ws, ptex, ptex->nr_samples,
+ r = sscreen->ws->surface_init(sscreen->ws, ptex, num_color_samples,
flags, bpe, array_mode, surface);
if (r) {
return r;
static struct r600_texture *
si_texture_create_object(struct pipe_screen *screen,
const struct pipe_resource *base,
+ unsigned num_color_samples,
struct pb_buffer *buf,
struct radeon_surf *surface)
{
rtex->surface = *surface;
rtex->size = rtex->surface.surf_size;
+ rtex->num_color_samples = num_color_samples;
rtex->tc_compatible_htile = rtex->surface.htile_size != 0 &&
(rtex->surface.flags &
return RADEON_SURF_MODE_2D;
}
+static unsigned si_get_num_color_samples(const struct pipe_resource *templ,
+ bool imported)
+{
+ return CLAMP(templ->nr_samples, 1, 8);
+}
+
struct pipe_resource *si_texture_create(struct pipe_screen *screen,
const struct pipe_resource *templ)
{
!is_flushed_depth &&
templ->nr_samples <= 1 && /* TC-compat HTILE is less efficient with MSAA */
util_format_is_depth_or_stencil(templ->format);
-
+ unsigned num_color_samples = si_get_num_color_samples(templ, false);
int r;
- r = si_init_surface(sscreen, &surface, templ,
+ r = si_init_surface(sscreen, &surface, templ, num_color_samples,
si_choose_tiling(sscreen, templ, tc_compatible_htile),
0, 0, false, false, is_flushed_depth,
tc_compatible_htile);
}
return (struct pipe_resource *)
- si_texture_create_object(screen, templ, NULL, &surface);
+ si_texture_create_object(screen, templ, num_color_samples,
+ NULL, &surface);
}
static struct pipe_resource *si_texture_from_handle(struct pipe_screen *screen,
si_surface_import_metadata(sscreen, &surface, &metadata,
&array_mode, &is_scanout);
- r = si_init_surface(sscreen, &surface, templ, array_mode, stride,
- offset, true, is_scanout, false, false);
+ unsigned num_color_samples = si_get_num_color_samples(templ, true);
+
+ r = si_init_surface(sscreen, &surface, templ, num_color_samples,
+ array_mode, stride, offset, true, is_scanout,
+ false, false);
if (r) {
return NULL;
}
- rtex = si_texture_create_object(screen, templ, buf, &surface);
+ rtex = si_texture_create_object(screen, templ, num_color_samples,
+ buf, &surface);
if (!rtex)
return NULL;
*/
array_mode = RADEON_SURF_MODE_LINEAR_ALIGNED;
is_scanout = false;
-
}
- r = si_init_surface(sscreen, &surface, templ,
- array_mode, memobj->stride,
- offset, true, is_scanout,
- false, false);
+ unsigned num_color_samples = si_get_num_color_samples(templ, true);
+
+ r = si_init_surface(sscreen, &surface, templ, num_color_samples,
+ array_mode, memobj->stride, offset, true,
+ is_scanout, false, false);
if (r)
return NULL;
- rtex = si_texture_create_object(screen, templ, memobj->buf, &surface);
+ rtex = si_texture_create_object(screen, templ, num_color_samples,
+ memobj->buf, &surface);
if (!rtex)
return NULL;