pvr: encapsulate border-table

The border-table is architecture specific, but it's stored in the device
structure that isn't. We need to store a pointer to it instead, because
the size will vary from architecture to architecture.

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:14:27 +01:00
committed by Marge Bot
parent 8233f77caa
commit ddd604439f
7 changed files with 33 additions and 21 deletions
+15 -8
View File
@@ -283,9 +283,15 @@ static inline void pvr_border_color_swizzle_to_tex_format(
*color = swizzled_color;
}
VkResult pvr_border_color_table_init(struct pvr_border_color_table *const table,
struct pvr_device *const device)
VkResult
pvr_border_color_table_init(struct pvr_device *const device)
{
struct pvr_border_color_table *table = device->border_color_table =
vk_zalloc(&device->vk.alloc, sizeof(struct pvr_border_color_table), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!table)
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
const struct pvr_device_info *const dev_info = &device->pdevice->dev_info;
const uint32_t cache_line_size = pvr_get_slc_cache_line_size(dev_info);
const uint32_t table_size = sizeof(struct pvr_border_color_table_entry) *
@@ -329,18 +335,19 @@ err_out:
return result;
}
void pvr_border_color_table_finish(struct pvr_border_color_table *const table,
struct pvr_device *const device)
void
pvr_border_color_table_finish(struct pvr_device *const device)
{
#if MESA_DEBUG
BITSET_SET_RANGE_INSIDE_WORD(table->unused_entries,
BITSET_SET_RANGE_INSIDE_WORD(device->border_color_table->unused_entries,
0,
PVR_BORDER_COLOR_TABLE_NR_BUILTIN_ENTRIES - 1);
BITSET_NOT(table->unused_entries);
assert(BITSET_IS_EMPTY(table->unused_entries));
BITSET_NOT(device->border_color_table->unused_entries);
assert(BITSET_IS_EMPTY(device->border_color_table->unused_entries));
#endif
pvr_bo_free(device, table->table);
pvr_bo_free(device, device->border_color_table->table);
vk_free(&device->vk.alloc, device->border_color_table);
}
static inline void pvr_border_color_table_set_custom_entry(
+5 -4
View File
@@ -59,10 +59,11 @@ struct pvr_border_color_table {
struct pvr_bo *table;
};
VkResult pvr_border_color_table_init(struct pvr_border_color_table *table,
struct pvr_device *device);
void pvr_border_color_table_finish(struct pvr_border_color_table *table,
struct pvr_device *device);
VkResult
pvr_border_color_table_init(struct pvr_device *const device);
void
pvr_border_color_table_finish(struct pvr_device *device);
VkResult
pvr_border_color_table_get_or_create_entry(struct pvr_device *device,
+2 -2
View File
@@ -944,7 +944,7 @@ pvr_create_device(struct pvr_physical_device *pdevice,
if (result != VK_SUCCESS)
goto err_pvr_spm_finish_scratch_buffer_store;
result = pvr_border_color_table_init(&device->border_color_table, device);
result = pvr_border_color_table_init(device);
if (result != VK_SUCCESS)
goto err_pvr_robustness_buffer_finish;
@@ -1032,7 +1032,7 @@ pvr_destroy_device(struct pvr_device *device,
if (!device)
return;
pvr_border_color_table_finish(&device->border_color_table, device);
pvr_border_color_table_finish(device);
pvr_robustness_buffer_finish(device);
pvr_spm_finish_scratch_buffer_store(device);
pvr_queues_destroy(device);
+3 -2
View File
@@ -24,15 +24,16 @@
#include "util/mesa-sha1.h"
#include "pvr_border.h"
#include "pvr_clear.h"
#include "pvr_common.h"
#include "pvr_macros.h"
#include "pvr_pds.h"
#include "pvr_spm.h"
#include "pvr_usc.h"
typedef struct _pco_ctx pco_ctx;
struct pvr_border_color_table;
struct pvr_instance;
struct pvr_queue;
@@ -167,7 +168,7 @@ struct pvr_device {
struct vk_sync *presignaled_sync;
struct pvr_border_color_table border_color_table;
struct pvr_border_color_table *border_color_table;
};
struct pvr_device_memory {
+2 -1
View File
@@ -26,6 +26,7 @@
#include <stdint.h>
#include <vulkan/vulkan.h>
#include "pvr_border.h"
#include "pvr_cmd_buffer.h"
#include "pvr_csb.h"
#include "pvr_debug.h"
@@ -61,7 +62,7 @@ pvr_submit_info_stream_init(struct pvr_compute_ctx *ctx,
CR_TPU_BORDER_COLOUR_TABLE_CDM,
value) {
value.border_colour_table_address =
device->border_color_table.table->vma->dev_addr;
device->border_color_table->table->vma->dev_addr;
}
stream_ptr += pvr_cmd_length(CR_TPU_BORDER_COLOUR_TABLE_CDM);
+3 -2
View File
@@ -29,6 +29,7 @@
#include "hwdef/rogue_hw_defs.h"
#include "hwdef/rogue_hw_utils.h"
#include "pvr_bo.h"
#include "pvr_border.h"
#include "pvr_cmd_buffer.h"
#include "pvr_csb.h"
#include "pvr_debug.h"
@@ -1002,7 +1003,7 @@ static void pvr_geom_state_stream_init(struct pvr_render_ctx *ctx,
CR_TPU_BORDER_COLOUR_TABLE_VDM,
value) {
value.border_colour_table_address =
device->border_color_table.table->vma->dev_addr;
device->border_color_table->table->vma->dev_addr;
}
stream_ptr += pvr_cmd_length(CR_TPU_BORDER_COLOUR_TABLE_VDM);
@@ -1318,7 +1319,7 @@ static void pvr_frag_state_stream_init(struct pvr_render_ctx *ctx,
CR_TPU_BORDER_COLOUR_TABLE_PDM,
value) {
value.border_colour_table_address =
device->border_color_table.table->vma->dev_addr;
device->border_color_table->table->vma->dev_addr;
}
stream_ptr += pvr_cmd_length(CR_TPU_BORDER_COLOUR_TABLE_PDM);
+3 -2
View File
@@ -15,6 +15,7 @@
#include "vk_log.h"
#include "pvr_border.h"
#include "pvr_device.h"
#include "pvr_entrypoints.h"
#include "pvr_physical_device.h"
@@ -79,7 +80,7 @@ VkResult pvr_CreateSampler(VkDevice _device,
result = pvr_border_color_table_get_or_create_entry(
device,
sampler,
&device->border_color_table,
device->border_color_table,
&sampler->border_color_table_index);
if (result != VK_SUCCESS)
goto err_free_sampler;
@@ -227,7 +228,7 @@ void pvr_DestroySampler(VkDevice _device,
if (!sampler)
return;
pvr_border_color_table_release_entry(&device->border_color_table,
pvr_border_color_table_release_entry(device->border_color_table,
sampler->border_color_table_index);
vk_sampler_destroy(&device->vk, pAllocator, &sampler->vk);