Module: Mesa Branch: main Commit: bba4d850c22a6657729616d11c428870cce5b565 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bba4d850c22a6657729616d11c428870cce5b565
Author: Nanley Chery <[email protected]> Date: Thu Apr 13 17:46:41 2023 -0700 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 <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22545> --- src/intel/blorp/blorp.c | 2 + src/intel/blorp/blorp.h | 6 +++ src/intel/blorp/blorp_clear.c | 88 ++++++++++++++++++++++++++++++++++++++++ src/intel/common/intel_measure.c | 1 + src/intel/common/intel_measure.h | 1 + 5 files changed, 98 insertions(+) diff --git a/src/intel/blorp/blorp.c b/src/intel/blorp/blorp.c index 48a8edf88f4..57627b492c7 100644 --- a/src/intel/blorp/blorp.c +++ b/src/intel/blorp/blorp.c @@ -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), diff --git a/src/intel/blorp/blorp.h b/src/intel/blorp/blorp.h index 40560e3d6bc..54228f7131c 100644 --- a/src/intel/blorp/blorp.h +++ b/src/intel/blorp/blorp.h @@ -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, diff --git a/src/intel/blorp/blorp_clear.c b/src/intel/blorp/blorp_clear.c index b03aa7efa4f..5a166100f96 100644 --- a/src/intel/blorp/blorp_clear.c +++ b/src/intel/blorp/blorp_clear.c @@ -1433,6 +1433,94 @@ blorp_mcs_partial_resolve(struct blorp_batch *batch, batch->blorp->exec(batch, ¶ms); } +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(¶ms); + 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, ¶ms, true, false)) + return; + + batch->blorp->exec(batch, ¶ms); +} + /** Clear a CCS to the "uncompressed" state * * This pass is the CCS equivalent of a "HiZ resolve". It sets the CCS values diff --git a/src/intel/common/intel_measure.c b/src/intel/common/intel_measure.c index 4364eaf1d97..9dff9df2b5e 100644 --- a/src/intel/common/intel_measure.c +++ b/src/intel/common/intel_measure.c @@ -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", diff --git a/src/intel/common/intel_measure.h b/src/intel/common/intel_measure.h index 069924603a6..d7fbf6a4c3e 100644 --- a/src/intel/common/intel_measure.h +++ b/src/intel/common/intel_measure.h @@ -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,
