pvr, pco: store device runtime info in compiler context

Signed-off-by: Simon Perretta <simon.perretta@imgtec.com>
Acked-by: Frank Binns <frank.binns@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41545>
This commit is contained in:
Simon Perretta 2026-05-13 12:53:54 +01:00 committed by Marge Bot
parent 1821309b54
commit cba2833e0d
5 changed files with 28 additions and 8 deletions

View file

@ -38,14 +38,18 @@ static void pco_ctx_destructor(UNUSED void *ptr)
* \brief Allocates and sets up a PCO compiler context.
*
* \param[in] dev_info Device info.
* \param[in] dev_runtime_info Device runtime info.
* \param[in] mem_ctx Ralloc memory allocation context.
* \return The PCO compiler context, or NULL on failure.
*/
pco_ctx *pco_ctx_create(const struct pvr_device_info *dev_info, void *mem_ctx)
pco_ctx *pco_ctx_create(const struct pvr_device_info *dev_info,
const struct pvr_device_runtime_info *dev_runtime_info,
void *mem_ctx)
{
pco_ctx *ctx = rzalloc_size(mem_ctx, sizeof(*ctx));
ctx->dev_info = dev_info;
ctx->dev_runtime_info = dev_runtime_info;
pco_debug_init();

View file

@ -20,13 +20,16 @@
/* Driver-specific forward-declarations. */
struct pvr_device_info;
struct pvr_device_runtime_info;
/* Compiler-specific forward-declarations. */
typedef struct _pco_shader pco_shader;
typedef struct _pco_ctx pco_ctx;
typedef struct _pco_data pco_data;
pco_ctx *pco_ctx_create(const struct pvr_device_info *dev_info, void *mem_ctx);
pco_ctx *pco_ctx_create(const struct pvr_device_info *dev_info,
const struct pvr_device_runtime_info *dev_runtime_info,
void *mem_ctx);
void pco_ctx_setup_usclib(pco_ctx *ctx, const void *data, unsigned size);
void pco_ctx_update_dev_info(pco_ctx *ctx,
const struct pvr_device_info *dev_info);

View file

@ -37,6 +37,9 @@ typedef struct _pco_ctx {
/** Device information. */
const struct pvr_device_info *dev_info;
/** Device runtime information. */
const struct pvr_device_runtime_info *dev_runtime_info;
/** Device-specific NIR options. */
nir_shader_compiler_options nir_options;
@ -47,10 +50,14 @@ typedef struct _pco_ctx {
const nir_shader *usclib;
} pco_ctx;
void pco_setup_spirv_options(const struct pvr_device_info *dev_info,
struct spirv_to_nir_options *spirv_options);
void pco_setup_nir_options(const struct pvr_device_info *dev_info,
nir_shader_compiler_options *nir_options);
void pco_setup_spirv_options(
const struct pvr_device_info *dev_info,
const struct pvr_device_runtime_info *dev_runtime_info,
struct spirv_to_nir_options *spirv_options);
void pco_setup_nir_options(
const struct pvr_device_info *dev_info,
const struct pvr_device_runtime_info *dev_runtime_info,
nir_shader_compiler_options *nir_options);
/* Debug. */
enum pco_debug {

View file

@ -373,6 +373,11 @@ int main(int argc, char *argv[argc])
sizeof(pvr_device_info_common));
++num_devices;
/* Dummy device runtime info (just zeroes).
* None of the precompiled shaders will be using any related functionality.
*/
struct pvr_device_runtime_info dev_runtime_info = { 0 };
int fd = open(spv_file, O_RDONLY);
if (fd < 0) {
fprintf(stderr, "Failed to open %s\n", spv_file);
@ -410,7 +415,7 @@ int main(int argc, char *argv[argc])
"Imagination Technologies Ltd.",
basename(hdr_file));
pco_ctx *ctx = pco_ctx_create(NULL, mem_ctx);
pco_ctx *ctx = pco_ctx_create(NULL, &dev_runtime_info, mem_ctx);
nir_shader *nir = spv_to_nir(mem_ctx, spirv_map, spirv_len);
struct nir_precomp_opts opts = { 0 };

View file

@ -1156,7 +1156,8 @@ VkResult pvr_physical_device_init(struct pvr_physical_device *pdevice,
pdevice->vk.supported_sync_types = ws->sync_types;
pdevice->pco_ctx = pco_ctx_create(&pdevice->dev_info, NULL);
pdevice->pco_ctx =
pco_ctx_create(&pdevice->dev_info, &pdevice->dev_runtime_info, NULL);
if (!pdevice->pco_ctx) {
result = vk_errorf(instance,
VK_ERROR_INITIALIZATION_FAILED,