diff --git a/src/imagination/vulkan/pvr_blit.c b/src/imagination/vulkan/pvr_blit.c index 37f1ba5fce1..8f33494918d 100644 --- a/src/imagination/vulkan/pvr_blit.c +++ b/src/imagination/vulkan/pvr_blit.c @@ -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++) { diff --git a/src/imagination/vulkan/pvr_clear.c b/src/imagination/vulkan/pvr_clear.c index a8c1d03d1f2..fd3c1a7646e 100644 --- a/src/imagination/vulkan/pvr_clear.c +++ b/src/imagination/vulkan/pvr_clear.c @@ -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( diff --git a/src/imagination/vulkan/pvr_clear.h b/src/imagination/vulkan/pvr_clear.h index c1c265c487d..0c3ab67790a 100644 --- a/src/imagination/vulkan/pvr_clear.h +++ b/src/imagination/vulkan/pvr_clear.h @@ -28,12 +28,14 @@ #include #include +#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); diff --git a/src/imagination/vulkan/pvr_cmd_buffer.c b/src/imagination/vulkan/pvr_cmd_buffer.c index fa4dfbde2e2..8a9aacf38cb 100644 --- a/src/imagination/vulkan/pvr_cmd_buffer.c +++ b/src/imagination/vulkan/pvr_cmd_buffer.c @@ -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; diff --git a/src/imagination/vulkan/pvr_descriptor_set.c b/src/imagination/vulkan/pvr_descriptor_set.c index 48c9787082e..08e79cc0211 100644 --- a/src/imagination/vulkan/pvr_descriptor_set.c +++ b/src/imagination/vulkan/pvr_descriptor_set.c @@ -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" diff --git a/src/imagination/vulkan/pvr_device.h b/src/imagination/vulkan/pvr_device.h index a8c2c133403..7fdeafcbea2 100644 --- a/src/imagination/vulkan/pvr_device.h +++ b/src/imagination/vulkan/pvr_device.h @@ -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; diff --git a/src/imagination/vulkan/pvr_formats.c b/src/imagination/vulkan/pvr_formats.c index 68ffa240562..932b5986d70 100644 --- a/src/imagination/vulkan/pvr_formats.c +++ b/src/imagination/vulkan/pvr_formats.c @@ -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" diff --git a/src/imagination/vulkan/pvr_image.c b/src/imagination/vulkan/pvr_image.c index 5d88a09c60d..eeee713c6bd 100644 --- a/src/imagination/vulkan/pvr_image.c +++ b/src/imagination/vulkan/pvr_image.c @@ -29,6 +29,7 @@ #include #include "pvr_buffer.h" +#include "pvr_csb.h" #include "pvr_device.h" #include "pvr_device_info.h" #include "pvr_entrypoints.h" diff --git a/src/imagination/vulkan/pvr_transfer_frag_store.c b/src/imagination/vulkan/pvr_transfer_frag_store.c index 9f2e9257ab6..1c404b28fa4 100644 --- a/src/imagination/vulkan/pvr_transfer_frag_store.c +++ b/src/imagination/vulkan/pvr_transfer_frag_store.c @@ -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" diff --git a/src/imagination/vulkan/pvr_usc.h b/src/imagination/vulkan/pvr_usc.h index d6c8a1236ea..6e0dfa37272 100644 --- a/src/imagination/vulkan/pvr_usc.h +++ b/src/imagination/vulkan/pvr_usc.h @@ -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);