Skip to content

Commit

Permalink
pvr: switch pvr_spm to use pvr_bo_suballoc
Browse files Browse the repository at this point in the history
Signed-off-by: Luigi Santivetti <[email protected]>
Reviewed-by: Karmjit Mahil <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22940>
  • Loading branch information
luigi-santivetti committed May 16, 2023
1 parent 983f98d commit e2e6adb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 30 deletions.
4 changes: 2 additions & 2 deletions src/imagination/vulkan/pvr_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ struct pvr_device {
} static_clear_state;

struct {
struct pvr_bo *usc_programs;
struct pvr_bo *pds_programs;
struct pvr_suballoc_bo *usc_programs;
struct pvr_suballoc_bo *pds_programs;

struct pvr_spm_per_load_program_state {
pvr_dev_addr_t pds_pixel_program_offset;
Expand Down
48 changes: 20 additions & 28 deletions src/imagination/vulkan/pvr_spm.c
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ VkResult pvr_device_init_spm_load_state(struct pvr_device *device)
uint32_t usc_aligned_offsets[PVR_SPM_LOAD_PROGRAM_COUNT];
uint32_t pds_allocation_size = 0;
uint32_t usc_allocation_size = 0;
struct pvr_bo *pds_bo;
struct pvr_bo *usc_bo;
struct pvr_suballoc_bo *pds_bo;
struct pvr_suballoc_bo *usc_bo;
uint8_t *mem_ptr;
VkResult result;

Expand All @@ -282,25 +282,22 @@ VkResult pvr_device_init_spm_load_state(struct pvr_device *device)
usc_allocation_size += ALIGN_POT(spm_load_collection[i].size, 4);
}

result = pvr_bo_alloc(device,
device->heaps.usc_heap,
usc_allocation_size,
4,
PVR_BO_ALLOC_FLAG_CPU_MAPPED,
&usc_bo);
result = pvr_bo_suballoc(&device->suballoc_usc,
usc_allocation_size,
4,
false,
&usc_bo);
if (result != VK_SUCCESS)
return result;

mem_ptr = (uint8_t *)usc_bo->bo->map;
mem_ptr = (uint8_t *)pvr_bo_suballoc_get_map_addr(usc_bo);

for (uint32_t i = 0; i < ARRAY_SIZE(spm_load_collection); i++) {
memcpy(mem_ptr + usc_aligned_offsets[i],
spm_load_collection[i].code,
spm_load_collection[i].size);
}

pvr_bo_cpu_unmap(device, usc_bo);

/* Upload PDS programs. */

for (uint32_t i = 0; i < ARRAY_SIZE(spm_load_collection); i++) {
Expand Down Expand Up @@ -340,26 +337,25 @@ VkResult pvr_device_init_spm_load_state(struct pvr_device *device)
}

/* FIXME: Figure out the define for alignment of 16. */
result = pvr_bo_alloc(device,
device->heaps.pds_heap,
pds_allocation_size,
16,
PVR_BO_ALLOC_FLAG_CPU_MAPPED,
&pds_bo);
result = pvr_bo_suballoc(&device->suballoc_pds,
pds_allocation_size,
16,
false,
&pds_bo);
if (result != VK_SUCCESS) {
pvr_bo_free(device, usc_bo);
pvr_bo_suballoc_free(usc_bo);
return result;
}

mem_ptr = (uint8_t *)pds_bo->bo->map;
mem_ptr = (uint8_t *)pvr_bo_suballoc_get_map_addr(pds_bo);

for (uint32_t i = 0; i < ARRAY_SIZE(spm_load_collection); i++) {
struct pvr_pds_pixel_shader_sa_program pds_texture_program = {
/* DMA for clear colors and tile buffer address parts. */
.num_texture_dma_kicks = 1,
};
const pvr_dev_addr_t usc_program_dev_addr =
PVR_DEV_ADDR_OFFSET(usc_bo->vma->dev_addr, usc_aligned_offsets[i]);
PVR_DEV_ADDR_OFFSET(usc_bo->dev_addr, usc_aligned_offsets[i]);
struct pvr_pds_kickusc_program pds_kick_program = { 0 };

pvr_pds_generate_pixel_shader_sa_code_segment(
Expand All @@ -378,11 +374,9 @@ VkResult pvr_device_init_spm_load_state(struct pvr_device *device)
(uint32_t *)(mem_ptr + pds_kick_aligned_offsets[i]));

device->spm_load_state.load_program[i].pds_pixel_program_offset =
PVR_DEV_ADDR_OFFSET(pds_bo->vma->dev_addr,
pds_kick_aligned_offsets[i]);
PVR_DEV_ADDR_OFFSET(pds_bo->dev_addr, pds_kick_aligned_offsets[i]);
device->spm_load_state.load_program[i].pds_uniform_program_offset =
PVR_DEV_ADDR_OFFSET(pds_bo->vma->dev_addr,
pds_texture_aligned_offsets[i]);
PVR_DEV_ADDR_OFFSET(pds_bo->dev_addr, pds_texture_aligned_offsets[i]);

/* TODO: From looking at the pvr_pds_generate_...() functions, it seems
* like temps_used is always 1. Should we remove this and hard code it
Expand All @@ -392,8 +386,6 @@ VkResult pvr_device_init_spm_load_state(struct pvr_device *device)
pds_texture_program.temps_used;
}

pvr_bo_cpu_unmap(device, pds_bo);

device->spm_load_state.usc_programs = usc_bo;
device->spm_load_state.pds_programs = pds_bo;

Expand All @@ -402,8 +394,8 @@ VkResult pvr_device_init_spm_load_state(struct pvr_device *device)

void pvr_device_finish_spm_load_state(struct pvr_device *device)
{
pvr_bo_free(device, device->spm_load_state.pds_programs);
pvr_bo_free(device, device->spm_load_state.usc_programs);
pvr_bo_suballoc_free(device->spm_load_state.pds_programs);
pvr_bo_suballoc_free(device->spm_load_state.usc_programs);
}

static inline enum PVRX(PBESTATE_PACKMODE)
Expand Down

0 comments on commit e2e6adb

Please sign in to comment.