pvr: move tile_buffer_size logic to pvr_device.c

Signed-off-by: Ella Stanforth <ella@igalia.com>
Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38744>
This commit is contained in:
Ella Stanforth
2025-09-19 11:56:07 +01:00
committed by Marge Bot
parent 95e24abf1a
commit 2dcaa9866d
5 changed files with 35 additions and 40 deletions

View File

@@ -41,6 +41,7 @@
#include <vulkan/vulkan.h>
#include "hwdef/pvr_hw_utils.h"
#include "hwdef/rogue_hw_utils.h"
#include "pco_uscgen_programs.h"
#include "pvr_bo.h"
#include "pvr_border.h"
@@ -728,6 +729,36 @@ static void pvr_device_finish_tile_buffer_state(struct pvr_device *device)
pvr_bo_free(device, device->tile_buffer_state.buffers[i]);
}
/** Gets the amount of memory to allocate per-core for a tile buffer. */
static uint32_t
pvr_get_tile_buffer_size_per_core(const struct pvr_device *device)
{
uint32_t clusters =
PVR_GET_FEATURE_VALUE(&device->pdevice->dev_info, num_clusters, 1U);
/* Round the number of clusters up to the next power of two. */
if (!PVR_HAS_FEATURE(&device->pdevice->dev_info, tile_per_usc))
clusters = util_next_power_of_two(clusters);
/* Tile buffer is (total number of partitions across all clusters) * 16 * 16
* (quadrant size in pixels).
*/
return device->pdevice->dev_runtime_info.total_reserved_partition_size *
clusters * sizeof(uint32_t);
}
/**
* Gets the amount of memory to allocate for a tile buffer on the current BVNC.
*/
static uint32_t
pvr_get_tile_buffer_size(const struct pvr_device *device)
{
/* On a multicore system duplicate the buffer for each core. */
/* TODO: Optimise tile buffer size to use core_count, not max_num_cores. */
return pvr_get_tile_buffer_size_per_core(device) *
rogue_get_max_num_cores(&device->pdevice->dev_info);
}
/**
* \brief Ensures that a certain amount of tile buffers are allocated.
*
@@ -735,9 +766,9 @@ static void pvr_device_finish_tile_buffer_state(struct pvr_device *device)
* present, append new tile buffers of \p size_in_bytes each to reach the quota.
*/
VkResult pvr_device_tile_buffer_ensure_cap(struct pvr_device *device,
uint32_t capacity,
uint32_t size_in_bytes)
uint32_t capacity)
{
uint32_t size_in_bytes = pvr_get_tile_buffer_size(device);
struct pvr_device_tile_buffer_state *tile_buffer_state =
&device->tile_buffer_state;
const uint32_t cache_line_size =

View File

@@ -178,8 +178,7 @@ uint32_t pvr_calc_fscommon_size_and_tiles_in_flight(
uint32_t min_tiles_in_flight);
VkResult pvr_device_tile_buffer_ensure_cap(struct pvr_device *device,
uint32_t capacity,
uint32_t size_in_bytes);
uint32_t capacity);
VkResult pvr_pds_compute_shader_create_and_upload(
struct pvr_device *device,

View File

@@ -322,36 +322,6 @@ static void pvr_reset_render(struct pvr_renderpass_context *ctx)
ctx->ds_load_surface = NULL;
}
/** Gets the amount of memory to allocate per-core for a tile buffer. */
static uint32_t
pvr_get_tile_buffer_size_per_core(const struct pvr_device *device)
{
uint32_t clusters =
PVR_GET_FEATURE_VALUE(&device->pdevice->dev_info, num_clusters, 1U);
/* Round the number of clusters up to the next power of two. */
if (!PVR_HAS_FEATURE(&device->pdevice->dev_info, tile_per_usc))
clusters = util_next_power_of_two(clusters);
/* Tile buffer is (total number of partitions across all clusters) * 16 * 16
* (quadrant size in pixels).
*/
return device->pdevice->dev_runtime_info.total_reserved_partition_size *
clusters * sizeof(uint32_t);
}
/**
* Gets the amount of memory to allocate for a tile buffer on the current BVNC.
*/
static uint32_t
pvr_get_tile_buffer_size(const struct pvr_device *device)
{
/* On a multicore system duplicate the buffer for each core. */
/* TODO: Optimise tile buffer size to use core_count, not max_num_cores. */
return pvr_get_tile_buffer_size_per_core(device) *
rogue_get_max_num_cores(&device->pdevice->dev_info);
}
static void
pvr_finalise_mrt_setup(const struct pvr_device *device,
struct pvr_renderpass_hwsetup_render *hw_render,
@@ -359,7 +329,6 @@ pvr_finalise_mrt_setup(const struct pvr_device *device,
{
mrt->num_output_regs = hw_render->output_regs_count;
mrt->num_tile_buffers = hw_render->tile_buffers_count;
mrt->tile_buffer_size = pvr_get_tile_buffer_size(device);
}
/**

View File

@@ -78,9 +78,6 @@ struct usc_mrt_setup {
/* Number of tile buffers used. */
uint32_t num_tile_buffers;
/* Size of a tile buffer in bytes. */
uint32_t tile_buffer_size;
/* Array of MRT resources allocated for each render target. The number of
* elements is determined by usc_mrt_setup::num_render_targets.
*/

View File

@@ -814,8 +814,7 @@ static inline VkResult pvr_hw_render_load_ops_setup(
if (hw_render->tile_buffers_count) {
result = pvr_device_tile_buffer_ensure_cap(
device,
hw_render->tile_buffers_count,
hw_render->eot_setup.tile_buffer_size);
hw_render->tile_buffers_count);
if (result != VK_SUCCESS)
return result;
}