intel: Implement ISL_AUX_OP_AMBIGUATE for MCS

Implement the ambiguate operation for MCS. This clears MCS layers with a
sample-dependent "uncompressed" value that tells the sampler to go look
at the main surface.

Reviewed-by: Ivan Briano <ivan.briano@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22545>
This commit is contained in:
Nanley Chery 2023-04-13 17:46:41 -07:00 committed by Marge Bot
parent 71d52a4d85
commit bba4d850c2
5 changed files with 98 additions and 0 deletions

View file

@ -44,6 +44,7 @@ blorp_op_to_intel_measure_snapshot(enum blorp_op op)
MAP(HIZ_AMBIGUATE),
MAP(HIZ_CLEAR),
MAP(HIZ_RESOLVE),
MAP(MCS_AMBIGUATE),
MAP(MCS_COLOR_CLEAR),
MAP(MCS_PARTIAL_RESOLVE),
MAP(SLOW_COLOR_CLEAR),
@ -68,6 +69,7 @@ const char *blorp_op_to_name(enum blorp_op op)
MAP(HIZ_AMBIGUATE),
MAP(HIZ_CLEAR),
MAP(HIZ_RESOLVE),
MAP(MCS_AMBIGUATE),
MAP(MCS_COLOR_CLEAR),
MAP(MCS_PARTIAL_RESOLVE),
MAP(SLOW_COLOR_CLEAR),

View file

@ -45,6 +45,7 @@ enum blorp_op {
BLORP_OP_HIZ_AMBIGUATE,
BLORP_OP_HIZ_CLEAR,
BLORP_OP_HIZ_RESOLVE,
BLORP_OP_MCS_AMBIGUATE,
BLORP_OP_MCS_COLOR_CLEAR,
BLORP_OP_MCS_PARTIAL_RESOLVE,
BLORP_OP_SLOW_COLOR_CLEAR,
@ -306,6 +307,11 @@ blorp_mcs_partial_resolve(struct blorp_batch *batch,
enum isl_format format,
uint32_t start_layer, uint32_t num_layers);
void
blorp_mcs_ambiguate(struct blorp_batch *batch,
struct blorp_surf *surf,
uint32_t start_layer, uint32_t num_layers);
void
blorp_hiz_op(struct blorp_batch *batch, struct blorp_surf *surf,
uint32_t level, uint32_t start_layer, uint32_t num_layers,

View file

@ -1433,6 +1433,94 @@ blorp_mcs_partial_resolve(struct blorp_batch *batch,
batch->blorp->exec(batch, &params);
}
static uint64_t
get_mcs_ambiguate_pixel(int sample_count)
{
/* See the Broadwell PRM, Volume 5 "Memory Views", Section "Compressed
* Multisample Surfaces".
*/
assert(sample_count >= 2);
assert(sample_count <= 16);
/* Each MCS element contains an array of sample slice (SS) elements. The
* size of this array matches the sample count.
*/
const int num_ss_entries = sample_count;
/* The width of each SS entry is just large enough to index every slice. */
const int ss_entry_size_b = util_logbase2(num_ss_entries);
/* The encoding for "ambiguated" has each sample slice value storing its
* index (e.g., SS[0] = 0, SS[1] = 1, etc.). The values are stored in
* little endian order. The unused bits are defined as either Reserved or
* Reserved (MBZ). We choose to interpret both as MBZ.
*/
uint64_t ambiguate_pixel = 0;
for (uint64_t entry = 0; entry < num_ss_entries; entry++)
ambiguate_pixel |= entry << (entry * ss_entry_size_b);
return ambiguate_pixel;
}
/** Clear an MCS to the "uncompressed" state
*
* This pass is the MCS equivalent of a "HiZ resolve". It sets the MCS values
* for a given layer of a surface to a sample-count dependent value which is
* the "uncompressed" state which tells the sampler to go look at the main
* surface.
*/
void
blorp_mcs_ambiguate(struct blorp_batch *batch,
struct blorp_surf *surf,
uint32_t start_layer, uint32_t num_layers)
{
assert((batch->flags & BLORP_BATCH_USE_COMPUTE) == 0);
struct blorp_params params;
blorp_params_init(&params);
params.op = BLORP_OP_MCS_AMBIGUATE;
assert(ISL_GFX_VER(batch->blorp->isl_dev) >= 7);
enum isl_format renderable_format;
switch (isl_format_get_layout(surf->aux_surf->format)->bpb) {
case 8: renderable_format = ISL_FORMAT_R8_UINT; break;
case 32: renderable_format = ISL_FORMAT_R32_UINT; break;
case 64: renderable_format = ISL_FORMAT_R32G32_UINT; break;
default: unreachable("Unexpected MCS format size for ambiguate");
}
params.dst = (struct brw_blorp_surface_info) {
.enabled = true,
.surf = *surf->aux_surf,
.addr = surf->aux_addr,
.view = {
.usage = ISL_SURF_USAGE_RENDER_TARGET_BIT,
.format = renderable_format,
.base_level = 0,
.base_array_layer = start_layer,
.levels = 1,
.array_len = num_layers,
.swizzle = ISL_SWIZZLE_IDENTITY,
},
};
params.x0 = 0;
params.y0 = 0;
params.x1 = params.dst.surf.logical_level0_px.width;
params.y1 = params.dst.surf.logical_level0_px.height;
params.num_layers = params.dst.view.array_len;
const uint64_t pixel = get_mcs_ambiguate_pixel(surf->surf->samples);
params.wm_inputs.clear_color[0] = pixel & 0xFFFFFFFF;
params.wm_inputs.clear_color[1] = pixel >> 32;
if (!blorp_params_get_clear_kernel(batch, &params, true, false))
return;
batch->blorp->exec(batch, &params);
}
/** Clear a CCS to the "uncompressed" state
*
* This pass is the CCS equivalent of a "HiZ resolve". It sets the CCS values

View file

@ -249,6 +249,7 @@ intel_measure_snapshot_string(enum intel_measure_snapshot_type type)
[INTEL_SNAPSHOT_HIZ_AMBIGUATE] = "hiz ambiguate",
[INTEL_SNAPSHOT_HIZ_CLEAR] = "hiz clear",
[INTEL_SNAPSHOT_HIZ_RESOLVE] = "hiz resolve",
[INTEL_SNAPSHOT_MCS_AMBIGUATE] = "mcs ambiguate",
[INTEL_SNAPSHOT_MCS_COLOR_CLEAR] = "mcs color clear",
[INTEL_SNAPSHOT_MCS_PARTIAL_RESOLVE] = "mcs partial resolve",
[INTEL_SNAPSHOT_SLOW_COLOR_CLEAR] = "slow color clear",

View file

@ -44,6 +44,7 @@ enum intel_measure_snapshot_type {
INTEL_SNAPSHOT_HIZ_AMBIGUATE,
INTEL_SNAPSHOT_HIZ_CLEAR,
INTEL_SNAPSHOT_HIZ_RESOLVE,
INTEL_SNAPSHOT_MCS_AMBIGUATE,
INTEL_SNAPSHOT_MCS_COLOR_CLEAR,
INTEL_SNAPSHOT_MCS_PARTIAL_RESOLVE,
INTEL_SNAPSHOT_SLOW_COLOR_CLEAR,