pvr: Remove PVR_STATIC_CLEAR_.*_BIT and use VkImageAspectFlags.

This commit removes the PVR_STATIC_CLEAR_.*_BIT used to index the
static clear templates in the device. Now we use the Vulkan flags
so no need for any conversion of the flags.

Signed-off-by: Karmjit Mahil <Karmjit.Mahil@imgtec.com>
Reviewed-by: Frank Binns <frank.binns@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20055>
This commit is contained in:
Karmjit Mahil
2022-10-20 11:24:14 +01:00
committed by Marge Bot
parent 7509e259f8
commit 0b72ff00b1
5 changed files with 14 additions and 51 deletions

View File

@@ -229,34 +229,6 @@ pvr_clear_needs_rt_id_output(struct pvr_device_info *dev_info,
return false;
}
static inline uint32_t
pvr_clear_template_idx_from_aspect(VkImageAspectFlags aspect)
{
switch (aspect) {
case VK_IMAGE_ASPECT_COLOR_BIT:
/* From the Vulkan 1.3.229 spec VUID-VkClearAttachment-aspectMask-00019:
*
* "If aspectMask includes VK_IMAGE_ASPECT_COLOR_BIT, it must not
* include VK_IMAGE_ASPECT_DEPTH_BIT or VK_IMAGE_ASPECT_STENCIL_BIT"
*
*/
return PVR_STATIC_CLEAR_COLOR_BIT;
case VK_IMAGE_ASPECT_DEPTH_BIT:
return PVR_STATIC_CLEAR_DEPTH_BIT;
case VK_IMAGE_ASPECT_STENCIL_BIT:
return PVR_STATIC_CLEAR_STENCIL_BIT;
case VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT:
return PVR_STATIC_CLEAR_DEPTH_BIT | PVR_STATIC_CLEAR_STENCIL_BIT;
default:
unreachable("Invalid aspect mask for clear.");
return 0;
}
}
static VkResult pvr_clear_color_attachment_static_create_consts_buffer(
struct pvr_cmd_buffer *cmd_buffer,
const struct pvr_shader_factory_info *shader_info,
@@ -470,6 +442,7 @@ static VkResult pvr_clear_color_attachment_static(
texturedatabase.addr = PVR_DEV_ADDR(pds_texture_program_addr);
}
assert(template_idx < PVR_STATIC_CLEAR_VARIANT_COUNT);
template =
cmd_buffer->device->static_clear_state.ppp_templates[template_idx];
@@ -478,7 +451,7 @@ static VkResult pvr_clear_color_attachment_static(
template.config.ispctl.upass =
cmd_buffer->state.render_pass_info.isp_userpass;
if (template_idx & PVR_STATIC_CLEAR_STENCIL_BIT)
if (template_idx & VK_IMAGE_ASPECT_STENCIL_BIT)
template.config.ispa.sref = stencil;
if (vs_has_rt_id_output) {
@@ -582,7 +555,7 @@ static void pvr_clear_attachments(struct pvr_cmd_buffer *cmd_buffer,
mrt_resource,
format,
packed_clear_color,
PVR_STATIC_CLEAR_COLOR_BIT,
VK_IMAGE_ASPECT_COLOR_BIT,
0,
vs_has_rt_id_output);
if (result != VK_SUCCESS)
@@ -592,15 +565,11 @@ static void pvr_clear_attachments(struct pvr_cmd_buffer *cmd_buffer,
const VkClearColorValue clear_color = {
.float32 = { [0] = attachment->clearValue.depthStencil.depth, },
};
const uint32_t template_idx = attachment->aspectMask |
VK_IMAGE_ASPECT_COLOR_BIT;
const uint32_t stencil = attachment->clearValue.depthStencil.stencil;
uint32_t packed_clear_color[PVR_CLEAR_COLOR_ARRAY_SIZE];
const struct usc_mrt_resource *mrt_resource;
uint32_t template_idx;
template_idx =
pvr_clear_template_idx_from_aspect(attachment->aspectMask);
template_idx |= PVR_STATIC_CLEAR_COLOR_BIT;
assert(hw_pass->z_replicate > 0);
mrt_resource = &hw_pass->setup.mrt_resources[hw_pass->z_replicate];
@@ -619,12 +588,11 @@ static void pvr_clear_attachments(struct pvr_cmd_buffer *cmd_buffer,
if (result != VK_SUCCESS)
return;
} else {
const uint32_t template_idx = attachment->aspectMask;
struct pvr_static_clear_ppp_template template;
uint32_t template_idx;
struct pvr_bo *pvr_bo;
template_idx =
pvr_clear_template_idx_from_aspect(attachment->aspectMask);
assert(template_idx < PVR_STATIC_CLEAR_VARIANT_COUNT);
template =
cmd_buffer->device->static_clear_state.ppp_templates[template_idx];

View File

@@ -62,9 +62,9 @@ static void pvr_device_setup_graphics_static_clear_ppp_templates(
templates[static PVR_STATIC_CLEAR_VARIANT_COUNT])
{
for (uint32_t i = 0; i < PVR_STATIC_CLEAR_VARIANT_COUNT; i++) {
const bool has_depth = !!(i & PVR_STATIC_CLEAR_DEPTH_BIT);
const bool has_stencil = !!(i & PVR_STATIC_CLEAR_STENCIL_BIT);
const bool has_color = !!(i & PVR_STATIC_CLEAR_COLOR_BIT);
const bool has_color = !!(i & VK_IMAGE_ASPECT_COLOR_BIT);
const bool has_depth = !!(i & VK_IMAGE_ASPECT_DEPTH_BIT);
const bool has_stencil = !!(i & VK_IMAGE_ASPECT_STENCIL_BIT);
struct pvr_static_clear_ppp_template *const template = &templates[i];

View File

@@ -75,13 +75,7 @@ static_assert(PVR_STATIC_CLEAR_PPP_PDS_TYPE_TEXTUREDATABASE + 1 ==
PVR_STATIC_CLEAR_PDS_STATE_COUNT,
"pvr_static_clear_ppp_pds_state_type might require fixing.");
enum pvr_static_clear_variant_bits {
PVR_STATIC_CLEAR_DEPTH_BIT = BITFIELD_BIT(0),
PVR_STATIC_CLEAR_STENCIL_BIT = BITFIELD_BIT(1),
PVR_STATIC_CLEAR_COLOR_BIT = BITFIELD_BIT(2),
};
#define PVR_STATIC_CLEAR_VARIANT_COUNT (PVR_STATIC_CLEAR_COLOR_BIT << 1U)
#define PVR_STATIC_CLEAR_VARIANT_COUNT (VK_IMAGE_ASPECT_STENCIL_BIT << 1U)
struct pvr_bo;
struct pvr_cmd_buffer;

View File

@@ -2421,7 +2421,7 @@ static VkResult pvr_cs_write_load_op(struct pvr_cmd_buffer *cmd_buffer,
{
const struct pvr_device *device = cmd_buffer->device;
struct pvr_static_clear_ppp_template template =
device->static_clear_state.ppp_templates[PVR_STATIC_CLEAR_COLOR_BIT];
device->static_clear_state.ppp_templates[VK_IMAGE_ASPECT_COLOR_BIT];
uint32_t pds_state[PVR_STATIC_CLEAR_PDS_STATE_COUNT];
struct pvr_pds_upload shareds_update_program;
struct pvr_bo *pvr_bo;
@@ -6034,7 +6034,7 @@ static void pvr_insert_transparent_obj(struct pvr_cmd_buffer *const cmd_buffer,
* in parallel so writing the template in place could cause problems.
*/
struct pvr_static_clear_ppp_template clear =
device->static_clear_state.ppp_templates[PVR_STATIC_CLEAR_COLOR_BIT];
device->static_clear_state.ppp_templates[VK_IMAGE_ASPECT_COLOR_BIT];
uint32_t pds_state[PVR_STATIC_CLEAR_PDS_STATE_COUNT] = { 0 };
struct pvr_csb *csb = &sub_cmd->control_stream;
struct pvr_bo *ppp_bo;

View File

@@ -342,6 +342,7 @@ struct pvr_device {
struct pvr_bo *usc_multi_layer_vertex_shader_bo;
struct pvr_static_clear_ppp_base ppp_base;
/* Indexable using VkImageAspectFlags. */
struct pvr_static_clear_ppp_template
ppp_templates[PVR_STATIC_CLEAR_VARIANT_COUNT];