pvr: encapsulate clear-state

Same story as the previous commit; this let's us store an architecture
specific structure inside an architecture agnostic structure.

Reviewed-by: Ashish Chauhan <ashish.chauhan@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38423>
This commit is contained in:
Erik Faye-Lund 2025-11-11 15:27:28 +01:00 committed by Marge Bot
parent ddd604439f
commit afff4be21c
10 changed files with 66 additions and 49 deletions

View file

@ -1648,7 +1648,7 @@ static VkResult pvr_clear_color_attachment_static(
ASSERTED const bool has_eight_output_registers =
PVR_HAS_FEATURE(dev_info, eight_output_registers);
const struct pvr_device_static_clear_state *dev_clear_state =
&device->static_clear_state;
device->static_clear_state;
const bool uses_tile_buffer = mrt_resource->type ==
USC_MRT_RESOURCE_TYPE_MEMORY;
const struct pvr_pds_clear_attachment_program_info *clear_attachment_program;
@ -1780,7 +1780,7 @@ static VkResult pvr_clear_color_attachment_static(
assert(template_idx < PVR_STATIC_CLEAR_VARIANT_COUNT);
template =
cmd_buffer->device->static_clear_state.ppp_templates[template_idx];
cmd_buffer->device->static_clear_state->ppp_templates[template_idx];
template.config.pds_state = &pds_state;
@ -2068,7 +2068,7 @@ static void pvr_clear_attachments(struct pvr_cmd_buffer *cmd_buffer,
assert(template_idx < PVR_STATIC_CLEAR_VARIANT_COUNT);
template =
cmd_buffer->device->static_clear_state.ppp_templates[template_idx];
cmd_buffer->device->static_clear_state->ppp_templates[template_idx];
if (attachment->aspectMask & VK_IMAGE_ASPECT_STENCIL_BIT) {
/* clang-format off */
@ -2102,7 +2102,7 @@ static void pvr_clear_attachments(struct pvr_cmd_buffer *cmd_buffer,
if (vs_has_rt_id_output) {
const struct pvr_device_static_clear_state *dev_clear_state =
&cmd_buffer->device->static_clear_state;
cmd_buffer->device->static_clear_state;
const struct pvr_suballoc_bo *multi_layer_vert_bo =
dev_clear_state->usc_multi_layer_vertex_shader_bo;
@ -2128,15 +2128,15 @@ static void pvr_clear_attachments(struct pvr_cmd_buffer *cmd_buffer,
*/
pvr_pds_clear_vertex_shader_program_init_base(
&pds_program,
cmd_buffer->device->static_clear_state.usc_vertex_shader_bo);
cmd_buffer->device->static_clear_state->usc_vertex_shader_bo);
pds_program_upload.code_offset =
cmd_buffer->device->static_clear_state.pds.code_offset;
cmd_buffer->device->static_clear_state->pds.code_offset;
/* TODO: The code size doesn't get used by pvr_clear_vdm_state() maybe
* let's change its interface to make that clear and not set this?
*/
pds_program_upload.code_size =
cmd_buffer->device->static_clear_state.pds.code_size;
cmd_buffer->device->static_clear_state->pds.code_size;
}
for (uint32_t j = 0; j < rect_count; j++) {

View file

@ -181,7 +181,7 @@ VkResult pvr_emit_ppp_from_template(
const uint32_t cache_line_size =
pvr_get_slc_cache_line_size(&device->pdevice->dev_info);
const struct pvr_static_clear_ppp_base *const base =
&device->static_clear_state.ppp_base;
&device->static_clear_state->ppp_base;
struct pvr_suballoc_bo *pvr_bo;
uint32_t *stream;
VkResult result;
@ -254,7 +254,7 @@ pvr_device_init_clear_attachment_programs(struct pvr_device *device)
MAX2(ROGUE_TA_STATE_PDS_TEXUNICODEBASE_ADDR_ALIGNMENT,
ROGUE_TA_STATE_PDS_SHADERBASE_ADDR_ALIGNMENT);
struct pvr_device_static_clear_state *clear_state =
&device->static_clear_state;
device->static_clear_state;
const struct pvr_device_info *dev_info = &device->pdevice->dev_info;
uint32_t pds_texture_program_offsets[PVR_NUM_CLEAR_ATTACH_SHADERS];
uint32_t pds_pixel_program_offsets[PVR_NUM_CLEAR_ATTACH_SHADERS];
@ -420,7 +420,7 @@ static void
pvr_device_finish_clear_attachment_programs(struct pvr_device *device)
{
struct pvr_device_static_clear_state *clear_state =
&device->static_clear_state;
device->static_clear_state;
pvr_bo_suballoc_free(clear_state->usc_clear_attachment_programs);
pvr_bo_suballoc_free(clear_state->pds_clear_attachment_programs);
@ -475,7 +475,14 @@ VkResult pvr_device_init_graphics_static_clear_state(struct pvr_device *device)
const uint32_t vdm_state_size_in_dw =
pvr_clear_vdm_state_get_size_in_dw(dev_info, 1);
struct pvr_device_static_clear_state *state = &device->static_clear_state;
struct pvr_device_static_clear_state *state = device->static_clear_state =
vk_zalloc(&device->vk.alloc,
sizeof(struct pvr_device_static_clear_state), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!state)
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
const uint32_t cache_line_size = pvr_get_slc_cache_line_size(dev_info);
struct pvr_pds_vertex_shader_program pds_program;
const pco_precomp_data *precomp_data;
@ -596,7 +603,7 @@ err_free_usc_multi_layer_shader:
void pvr_device_finish_graphics_static_clear_state(struct pvr_device *device)
{
struct pvr_device_static_clear_state *state = &device->static_clear_state;
struct pvr_device_static_clear_state *state = device->static_clear_state;
pvr_device_finish_clear_attachment_programs(device);
@ -610,6 +617,8 @@ void pvr_device_finish_graphics_static_clear_state(struct pvr_device *device)
pvr_bo_suballoc_free(state->vertices_bo);
pvr_bo_suballoc_free(state->usc_vertex_shader_bo);
pvr_bo_suballoc_free(state->usc_multi_layer_vertex_shader_bo);
vk_free(&device->vk.alloc, state);
}
void pvr_pds_clear_vertex_shader_program_init_base(

View file

@ -28,12 +28,14 @@
#include <stdint.h>
#include <vulkan/vulkan_core.h>
#include "pvr_common.h"
#include "pvr_csb.h"
#include "pvr_device_info.h"
#include "util/macros.h"
#define PVR_CLEAR_VERTEX_COUNT 4
#define PVR_CLEAR_VERTEX_COORDINATES 3
#define PVR_NUM_CLEAR_ATTACH_SHADERS 20U
/* These can be used as offsets within a PVR_STATIC_CLEAR_PDS_STATE_COUNT dwords
* sized array to get the respective state word.
@ -100,6 +102,37 @@ struct pvr_static_clear_ppp_template {
} config;
};
struct pvr_device_static_clear_state {
struct pvr_suballoc_bo *usc_vertex_shader_bo;
struct pvr_suballoc_bo *vertices_bo;
struct pvr_pds_upload pds;
/* Only valid if PVR_HAS_FEATURE(dev_info, gs_rta_support). */
struct pvr_suballoc_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];
const uint32_t *vdm_words;
const uint32_t *large_clear_vdm_words;
struct pvr_suballoc_bo *usc_clear_attachment_programs;
struct pvr_suballoc_bo *pds_clear_attachment_programs;
/* TODO: See if we can use PVR_CLEAR_ATTACHMENT_PROGRAM_COUNT to save some
* memory.
*/
struct pvr_pds_clear_attachment_program_info {
pvr_dev_addr_t texture_program_offset;
pvr_dev_addr_t pixel_program_offset;
uint32_t texture_program_pds_temps_count;
/* Size in dwords. */
uint32_t texture_program_data_size;
} pds_clear_attachment_program_info[PVR_NUM_CLEAR_ATTACH_SHADERS];
};
VkResult pvr_device_init_graphics_static_clear_state(struct pvr_device *device);
void pvr_device_finish_graphics_static_clear_state(struct pvr_device *device);

View file

@ -3425,9 +3425,9 @@ static void pvr_emit_clear_words(struct pvr_cmd_buffer *const cmd_buffer,
}
if (pvr_is_large_clear_required(cmd_buffer))
vdm_state = device->static_clear_state.large_clear_vdm_words;
vdm_state = device->static_clear_state->large_clear_vdm_words;
else
vdm_state = device->static_clear_state.vdm_words;
vdm_state = device->static_clear_state->vdm_words;
memcpy(stream, vdm_state, PVR_DW_TO_BYTES(vdm_state_size_in_dw));
@ -3442,7 +3442,7 @@ static VkResult pvr_cs_write_load_op_for_view(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[VK_IMAGE_ASPECT_COLOR_BIT];
device->static_clear_state->ppp_templates[VK_IMAGE_ASPECT_COLOR_BIT];
uint32_t pds_state[PVR_PDS_STATE_LENGTH];
struct pvr_pds_upload shareds_update_program;
struct pvr_suballoc_bo *pvr_bo;
@ -7851,7 +7851,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[VK_IMAGE_ASPECT_COLOR_BIT];
device->static_clear_state->ppp_templates[VK_IMAGE_ASPECT_COLOR_BIT];
uint32_t pds_state[PVR_PDS_STATE_LENGTH] = { 0 };
struct pvr_csb *csb = &sub_cmd->control_stream;
struct pvr_suballoc_bo *ppp_bo;

View file

@ -33,6 +33,7 @@
#include "hwdef/rogue_hw_utils.h"
#include "pvr_bo.h"
#include "pvr_buffer.h"
#include "pvr_csb.h"
#include "pvr_debug.h"
#include "pvr_device.h"
#include "pvr_entrypoints.h"

View file

@ -24,16 +24,18 @@
#include "util/mesa-sha1.h"
#include "pvr_clear.h"
#include "pvr_bo.h"
#include "pvr_common.h"
#include "pvr_macros.h"
#include "pvr_pds.h"
#include "pvr_spm.h"
#include "pvr_usc.h"
#include "pvr_winsys.h"
typedef struct _pco_ctx pco_ctx;
struct pvr_border_color_table;
struct pvr_device_static_clear_state;
struct pvr_instance;
struct pvr_queue;
@ -108,36 +110,7 @@ struct pvr_device {
struct pvr_pds_upload sw_compute_barrier_pds;
} idfwdf_state;
struct pvr_device_static_clear_state {
struct pvr_suballoc_bo *usc_vertex_shader_bo;
struct pvr_suballoc_bo *vertices_bo;
struct pvr_pds_upload pds;
/* Only valid if PVR_HAS_FEATURE(dev_info, gs_rta_support). */
struct pvr_suballoc_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];
const uint32_t *vdm_words;
const uint32_t *large_clear_vdm_words;
struct pvr_suballoc_bo *usc_clear_attachment_programs;
struct pvr_suballoc_bo *pds_clear_attachment_programs;
/* TODO: See if we can use PVR_CLEAR_ATTACHMENT_PROGRAM_COUNT to save some
* memory.
*/
struct pvr_pds_clear_attachment_program_info {
pvr_dev_addr_t texture_program_offset;
pvr_dev_addr_t pixel_program_offset;
uint32_t texture_program_pds_temps_count;
/* Size in dwords. */
uint32_t texture_program_data_size;
} pds_clear_attachment_program_info[PVR_NUM_CLEAR_ATTACH_SHADERS];
} static_clear_state;
struct pvr_device_static_clear_state *static_clear_state;
struct {
struct pvr_suballoc_bo *usc_programs;

View file

@ -29,6 +29,7 @@
#include "hwdef/rogue_hw_utils.h"
#include "pvr_common.h"
#include "pvr_csb.h"
#include "pvr_device.h"
#include "pvr_entrypoints.h"
#include "pvr_formats.h"

View file

@ -29,6 +29,7 @@
#include <string.h>
#include "pvr_buffer.h"
#include "pvr_csb.h"
#include "pvr_device.h"
#include "pvr_device_info.h"
#include "pvr_entrypoints.h"

View file

@ -29,6 +29,7 @@
#include "hwdef/rogue_hw_utils.h"
#include "pvr_bo.h"
#include "pvr_common.h"
#include "pvr_csb.h"
#include "pvr_device.h"
#include "pvr_device_info.h"
#include "pvr_job_transfer.h"

View file

@ -201,8 +201,6 @@ pvr_uscgen_clear_attach_index(struct pvr_clear_attach_props *props)
}
#undef INDEX
#define PVR_NUM_CLEAR_ATTACH_SHADERS 20U
pco_shader *
pvr_usc_zero_init_wg_mem(pco_ctx *ctx, unsigned start, unsigned count);