mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-22 09:10:11 +01:00
radeonsi: rewrite si_get_opaque_metadata, also for gfx10 support
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
This commit is contained in:
parent
e718f8e713
commit
f8b6c5a1a6
1 changed files with 41 additions and 25 deletions
|
|
@ -725,30 +725,34 @@ static void si_set_tex_bo_metadata(struct si_screen *sscreen,
|
||||||
sscreen->ws->buffer_set_metadata(tex->buffer.buf, &md);
|
sscreen->ws->buffer_set_metadata(tex->buffer.buf, &md);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void si_get_opaque_metadata(struct si_screen *sscreen,
|
static void si_read_tex_bo_metadata(struct si_screen *sscreen,
|
||||||
struct si_texture *tex,
|
struct si_texture *tex,
|
||||||
struct radeon_bo_metadata *md)
|
struct radeon_bo_metadata *md)
|
||||||
{
|
{
|
||||||
uint32_t *desc = &md->metadata[2];
|
uint32_t *desc = &md->metadata[2];
|
||||||
|
|
||||||
if (sscreen->info.chip_class < GFX8)
|
if (md->size_metadata < 10 * 4 || /* at least 2(header) + 8(desc) dwords */
|
||||||
|
md->metadata[0] == 0 || /* invalid version number */
|
||||||
|
md->metadata[1] != si_get_bo_metadata_word1(sscreen)) /* invalid PCI ID */
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Return if DCC is enabled. The texture should be set up with it
|
if (sscreen->info.chip_class >= GFX8 &&
|
||||||
* already.
|
|
||||||
*/
|
|
||||||
if (md->size_metadata >= 10 * 4 && /* at least 2(header) + 8(desc) dwords */
|
|
||||||
md->metadata[0] != 0 &&
|
|
||||||
md->metadata[1] == si_get_bo_metadata_word1(sscreen) &&
|
|
||||||
G_008F28_COMPRESSION_EN(desc[6])) {
|
G_008F28_COMPRESSION_EN(desc[6])) {
|
||||||
tex->dcc_offset = (uint64_t)desc[7] << 8;
|
/* Read DCC information.
|
||||||
|
*
|
||||||
|
* Some state trackers don't set the SCANOUT flag when
|
||||||
|
* importing displayable images, which affects PIPE_ALIGNED
|
||||||
|
* and RB_ALIGNED, so we need to recover them here.
|
||||||
|
*/
|
||||||
|
switch (sscreen->info.chip_class) {
|
||||||
|
case GFX8:
|
||||||
|
tex->dcc_offset = (uint64_t)desc[7] << 8;
|
||||||
|
break;
|
||||||
|
|
||||||
if (sscreen->info.chip_class >= GFX9) {
|
case GFX9:
|
||||||
/* Fix up parameters for displayable DCC. Some state
|
tex->dcc_offset =
|
||||||
* trackers don't set the SCANOUT flag when importing
|
((uint64_t)desc[7] << 8) |
|
||||||
* displayable images, so we have to recover the correct
|
((uint64_t)G_008F24_META_DATA_ADDRESS(desc[5]) << 40);
|
||||||
* parameters here.
|
|
||||||
*/
|
|
||||||
tex->surface.u.gfx9.dcc.pipe_aligned =
|
tex->surface.u.gfx9.dcc.pipe_aligned =
|
||||||
G_008F24_META_PIPE_ALIGNED(desc[5]);
|
G_008F24_META_PIPE_ALIGNED(desc[5]);
|
||||||
tex->surface.u.gfx9.dcc.rb_aligned =
|
tex->surface.u.gfx9.dcc.rb_aligned =
|
||||||
|
|
@ -758,14 +762,26 @@ static void si_get_opaque_metadata(struct si_screen *sscreen,
|
||||||
if (!tex->surface.u.gfx9.dcc.pipe_aligned &&
|
if (!tex->surface.u.gfx9.dcc.pipe_aligned &&
|
||||||
!tex->surface.u.gfx9.dcc.rb_aligned)
|
!tex->surface.u.gfx9.dcc.rb_aligned)
|
||||||
tex->surface.is_displayable = true;
|
tex->surface.is_displayable = true;
|
||||||
}
|
break;
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Disable DCC. These are always set by texture_from_handle and must
|
case GFX10:
|
||||||
* be cleared here.
|
tex->dcc_offset =
|
||||||
*/
|
((uint64_t)G_00A018_META_DATA_ADDRESS_LO(desc[6]) << 8) |
|
||||||
tex->dcc_offset = 0;
|
((uint64_t)desc[7] << 16);
|
||||||
|
tex->surface.u.gfx9.dcc.pipe_aligned =
|
||||||
|
G_00A018_META_PIPE_ALIGNED(desc[6]);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* Disable DCC. dcc_offset is always set by texture_from_handle
|
||||||
|
* and must be cleared here.
|
||||||
|
*/
|
||||||
|
tex->dcc_offset = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool si_has_displayable_dcc(struct si_texture *tex)
|
static bool si_has_displayable_dcc(struct si_texture *tex)
|
||||||
|
|
@ -1691,7 +1707,7 @@ static struct pipe_resource *si_texture_from_winsys_buffer(struct si_screen *ssc
|
||||||
tex->buffer.b.is_shared = true;
|
tex->buffer.b.is_shared = true;
|
||||||
tex->buffer.external_usage = usage;
|
tex->buffer.external_usage = usage;
|
||||||
|
|
||||||
si_get_opaque_metadata(sscreen, tex, &metadata);
|
si_read_tex_bo_metadata(sscreen, tex, &metadata);
|
||||||
|
|
||||||
/* Displayable DCC requires an explicit flush. */
|
/* Displayable DCC requires an explicit flush. */
|
||||||
if (dedicated &&
|
if (dedicated &&
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue