From 8536760016d40b324cc9d9699c7075cfdea8b643 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Tue, 18 Feb 2025 17:25:02 -0600 Subject: [PATCH] nvk: Constify instance and pdev pointers Part-of: --- src/nouveau/vulkan/nvk_buffer.c | 4 ++-- src/nouveau/vulkan/nvk_buffer_view.c | 6 +++--- src/nouveau/vulkan/nvk_buffer_view.h | 2 +- src/nouveau/vulkan/nvk_cmd_buffer.c | 10 +++++----- src/nouveau/vulkan/nvk_cmd_clear.c | 2 +- src/nouveau/vulkan/nvk_cmd_copy.c | 2 +- src/nouveau/vulkan/nvk_cmd_dispatch.c | 6 +++--- src/nouveau/vulkan/nvk_cmd_draw.c | 10 +++++----- src/nouveau/vulkan/nvk_cmd_indirect.c | 10 +++++----- src/nouveau/vulkan/nvk_cmd_meta.c | 2 +- src/nouveau/vulkan/nvk_codegen.c | 3 ++- src/nouveau/vulkan/nvk_descriptor_set.c | 20 +++++++++---------- .../vulkan/nvk_descriptor_set_layout.c | 4 ++-- src/nouveau/vulkan/nvk_device.c | 2 +- src/nouveau/vulkan/nvk_device.h | 8 +++++++- src/nouveau/vulkan/nvk_device_memory.c | 6 +++--- src/nouveau/vulkan/nvk_edb_bview_cache.c | 2 +- src/nouveau/vulkan/nvk_image.c | 15 +++++++------- src/nouveau/vulkan/nvk_image.h | 4 ++-- src/nouveau/vulkan/nvk_image_view.c | 2 +- .../vulkan/nvk_indirect_execution_set.c | 12 +++++------ .../vulkan/nvk_indirect_execution_set.h | 8 ++++---- src/nouveau/vulkan/nvk_physical_device.c | 2 +- src/nouveau/vulkan/nvk_physical_device.h | 4 ++-- src/nouveau/vulkan/nvk_query_pool.c | 2 +- src/nouveau/vulkan/nvk_queue.c | 10 +++++----- src/nouveau/vulkan/nvk_sampler.c | 2 +- src/nouveau/vulkan/nvk_shader.c | 17 ++++++++-------- src/nouveau/vulkan/nvk_shader.h | 5 +++-- src/nouveau/vulkan/nvk_upload_queue.c | 2 +- 30 files changed, 96 insertions(+), 88 deletions(-) diff --git a/src/nouveau/vulkan/nvk_buffer.c b/src/nouveau/vulkan/nvk_buffer.c index b7266ba09a5..5554db88332 100644 --- a/src/nouveau/vulkan/nvk_buffer.c +++ b/src/nouveau/vulkan/nvk_buffer.c @@ -160,7 +160,7 @@ nvk_GetDeviceBufferMemoryRequirements( VkMemoryRequirements2 *pMemoryRequirements) { VK_FROM_HANDLE(nvk_device, dev, device); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); const uint32_t alignment = nvk_get_buffer_alignment(nvk_device_physical(dev), @@ -239,7 +239,7 @@ nvk_bind_buffer_memory(struct nvk_device *dev, { VK_FROM_HANDLE(nvk_device_memory, mem, info->memory); VK_FROM_HANDLE(nvk_buffer, buffer, info->buffer); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); VkResult result = VK_SUCCESS; if ((pdev->debug_flags & NVK_DEBUG_PUSH_DUMP) && diff --git a/src/nouveau/vulkan/nvk_buffer_view.c b/src/nouveau/vulkan/nvk_buffer_view.c index 3f8d03dd2e6..6c625a39e88 100644 --- a/src/nouveau/vulkan/nvk_buffer_view.c +++ b/src/nouveau/vulkan/nvk_buffer_view.c @@ -16,7 +16,7 @@ #include "clb097.h" VkFormatFeatureFlags2 -nvk_get_buffer_format_features(struct nvk_physical_device *pdev, +nvk_get_buffer_format_features(const struct nvk_physical_device *pdev, VkFormat vk_format) { VkFormatFeatureFlags2 features = 0; @@ -50,7 +50,7 @@ nvk_CreateBufferView(VkDevice _device, { VK_FROM_HANDLE(nvk_device, dev, _device); VK_FROM_HANDLE(nvk_buffer, buffer, pCreateInfo->buffer); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); struct nvk_buffer_view *view; VkResult result; @@ -97,7 +97,7 @@ nvk_DestroyBufferView(VkDevice _device, { VK_FROM_HANDLE(nvk_device, dev, _device); VK_FROM_HANDLE(nvk_buffer_view, view, bufferView); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); if (!view) return; diff --git a/src/nouveau/vulkan/nvk_buffer_view.h b/src/nouveau/vulkan/nvk_buffer_view.h index 704e1e2630d..1553c0d400f 100644 --- a/src/nouveau/vulkan/nvk_buffer_view.h +++ b/src/nouveau/vulkan/nvk_buffer_view.h @@ -14,7 +14,7 @@ struct nvk_physical_device; VkFormatFeatureFlags2 -nvk_get_buffer_format_features(struct nvk_physical_device *pdev, +nvk_get_buffer_format_features(const struct nvk_physical_device *pdev, VkFormat format); struct nvk_buffer_view { diff --git a/src/nouveau/vulkan/nvk_cmd_buffer.c b/src/nouveau/vulkan/nvk_cmd_buffer.c index 226a52c2b1a..3bc6b15f96e 100644 --- a/src/nouveau/vulkan/nvk_cmd_buffer.c +++ b/src/nouveau/vulkan/nvk_cmd_buffer.c @@ -520,7 +520,7 @@ nvk_cmd_invalidate_deps(struct nvk_cmd_buffer *cmd, const VkDependencyInfo *deps) { struct nvk_device *dev = nvk_cmd_buffer_device(cmd); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); enum nvk_barrier barriers = 0; @@ -662,7 +662,7 @@ nvk_bind_descriptor_sets(struct nvk_cmd_buffer *cmd, { VK_FROM_HANDLE(vk_pipeline_layout, pipeline_layout, info->layout); struct nvk_device *dev = nvk_cmd_buffer_device(cmd); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); union nvk_buffer_descriptor dynamic_buffers[NVK_MAX_DYNAMIC_BUFFERS]; uint8_t set_dynamic_buffer_start[NVK_MAX_SETS]; @@ -977,7 +977,7 @@ nvk_cmd_buffer_flush_push_descriptors(struct nvk_cmd_buffer *cmd, struct nvk_descriptor_state *desc) { struct nvk_device *dev = nvk_cmd_buffer_device(cmd); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); const uint32_t min_cbuf_alignment = nvk_min_cbuf_alignment(&pdev->info); VkResult result; @@ -1012,7 +1012,7 @@ nvk_cmd_buffer_get_cbuf_addr(struct nvk_cmd_buffer *cmd, struct nvk_buffer_address *addr_out) { struct nvk_device *dev = nvk_cmd_buffer_device(cmd); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); switch (cbuf->type) { case NVK_CBUF_TYPE_INVALID: @@ -1090,7 +1090,7 @@ void nvk_cmd_buffer_dump(struct nvk_cmd_buffer *cmd, FILE *fp) { struct nvk_device *dev = nvk_cmd_buffer_device(cmd); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); util_dynarray_foreach(&cmd->pushes, struct nvk_cmd_push, p) { if (p->map) { diff --git a/src/nouveau/vulkan/nvk_cmd_clear.c b/src/nouveau/vulkan/nvk_cmd_clear.c index 22af057ac35..3e8630594c8 100644 --- a/src/nouveau/vulkan/nvk_cmd_clear.c +++ b/src/nouveau/vulkan/nvk_cmd_clear.c @@ -319,7 +319,7 @@ nvk_CmdClearColorImage(VkCommandBuffer commandBuffer, { VK_FROM_HANDLE(nvk_cmd_buffer, cmd, commandBuffer); struct nvk_device *dev = nvk_cmd_buffer_device(cmd); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); VK_FROM_HANDLE(nvk_image, image, _image); VkClearValue clear_value = { diff --git a/src/nouveau/vulkan/nvk_cmd_copy.c b/src/nouveau/vulkan/nvk_cmd_copy.c index 10fcf8a3463..49fc77d3bf2 100644 --- a/src/nouveau/vulkan/nvk_cmd_copy.c +++ b/src/nouveau/vulkan/nvk_cmd_copy.c @@ -24,7 +24,7 @@ static inline uint16_t nvk_cmd_buffer_copy_cls(struct nvk_cmd_buffer *cmd) { struct nvk_device *dev = nvk_cmd_buffer_device(cmd); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); return pdev->info.cls_copy; } diff --git a/src/nouveau/vulkan/nvk_cmd_dispatch.c b/src/nouveau/vulkan/nvk_cmd_dispatch.c index 1dd2ceb6309..a96bd230eb9 100644 --- a/src/nouveau/vulkan/nvk_cmd_dispatch.c +++ b/src/nouveau/vulkan/nvk_cmd_dispatch.c @@ -28,7 +28,7 @@ VkResult nvk_push_dispatch_state_init(struct nvk_queue *queue, struct nv_push *p) { struct nvk_device *dev = nvk_queue_device(queue); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); P_MTHD(p, NV90C0, SET_OBJECT); P_NV90C0_SET_OBJECT(p, { @@ -55,7 +55,7 @@ static inline uint16_t nvk_cmd_buffer_compute_cls(struct nvk_cmd_buffer *cmd) { struct nvk_device *dev = nvk_cmd_buffer_device(cmd); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); return pdev->info.cls_compute; } @@ -125,7 +125,7 @@ nvk_cmd_upload_qmd(struct nvk_cmd_buffer *cmd, uint64_t *root_desc_addr_out) { struct nvk_device *dev = nvk_cmd_buffer_device(cmd); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); const uint32_t min_cbuf_alignment = nvk_min_cbuf_alignment(&pdev->info); VkResult result; diff --git a/src/nouveau/vulkan/nvk_cmd_draw.c b/src/nouveau/vulkan/nvk_cmd_draw.c index 5e1e6b069f9..d90dd9d5651 100644 --- a/src/nouveau/vulkan/nvk_cmd_draw.c +++ b/src/nouveau/vulkan/nvk_cmd_draw.c @@ -34,7 +34,7 @@ static inline uint16_t nvk_cmd_buffer_3d_cls(struct nvk_cmd_buffer *cmd) { struct nvk_device *dev = nvk_cmd_buffer_device(cmd); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); return pdev->info.cls_eng3d; } @@ -107,7 +107,7 @@ VkResult nvk_push_draw_state_init(struct nvk_queue *queue, struct nv_push *p) { struct nvk_device *dev = nvk_queue_device(queue); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); /* 3D state */ P_MTHD(p, NV9097, SET_OBJECT); @@ -1651,7 +1651,7 @@ static void nvk_flush_vi_state(struct nvk_cmd_buffer *cmd) { struct nvk_device *dev = nvk_cmd_buffer_device(cmd); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); const struct vk_dynamic_graphics_state *dyn = &cmd->vk.dynamic_graphics_state; @@ -1783,7 +1783,7 @@ static void nvk_flush_vp_state(struct nvk_cmd_buffer *cmd) { struct nvk_device *dev = nvk_cmd_buffer_device(cmd); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); const struct vk_dynamic_graphics_state *dyn = &cmd->vk.dynamic_graphics_state; @@ -3345,7 +3345,7 @@ void nvk_cmd_flush_gfx_cbufs(struct nvk_cmd_buffer *cmd) { struct nvk_device *dev = nvk_cmd_buffer_device(cmd); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); const uint32_t min_cbuf_alignment = nvk_min_cbuf_alignment(&pdev->info); struct nvk_descriptor_state *desc = &cmd->state.gfx.descriptors; diff --git a/src/nouveau/vulkan/nvk_cmd_indirect.c b/src/nouveau/vulkan/nvk_cmd_indirect.c index e87c839546a..dbc7311a7dc 100644 --- a/src/nouveau/vulkan/nvk_cmd_indirect.c +++ b/src/nouveau/vulkan/nvk_cmd_indirect.c @@ -260,7 +260,7 @@ static void build_process_cs_cmd_seq(nir_builder *b, struct nvk_nir_push *p, nir_def *in_addr, nir_def *seq_idx, struct process_cmd_in *in, - struct nvk_physical_device *pdev, + const struct nvk_physical_device *pdev, const VkIndirectCommandsLayoutCreateInfoEXT *info, uint32_t *qmd_size_per_seq_B_out) { @@ -416,7 +416,7 @@ build_process_cs_cmd_seq(nir_builder *b, struct nvk_nir_push *p, static void build_gfx_set_exec(nir_builder *b, struct nvk_nir_push *p, nir_def *token_addr, struct process_cmd_in *in, - struct nvk_physical_device *pdev, + const struct nvk_physical_device *pdev, const VkIndirectCommandsExecutionSetTokenEXT *token) { switch (token->type) { @@ -622,7 +622,7 @@ static void build_process_gfx_cmd_seq(nir_builder *b, struct nvk_nir_push *p, nir_def *in_addr, nir_def *seq_idx, struct process_cmd_in *in, - struct nvk_physical_device *pdev, + const struct nvk_physical_device *pdev, const VkIndirectCommandsLayoutCreateInfoEXT *info) { for (uint32_t t = 0; t < info->tokenCount; t++) { @@ -721,7 +721,7 @@ build_process_shader(struct nvk_device *dev, uint32_t *cmd_seq_stride_B_out, uint32_t *qmd_size_per_seq_B_out) { - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); nir_builder build = nir_builder_init_simple_shader(MESA_SHADER_COMPUTE, NULL, @@ -912,7 +912,7 @@ nvk_GetGeneratedCommandsMemoryRequirementsEXT( VK_FROM_HANDLE(nvk_device, dev, _device); VK_FROM_HANDLE(nvk_indirect_commands_layout, layout, pInfo->indirectCommandsLayout); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); uint64_t size = layout->cmd_seq_stride_B * (uint64_t)pInfo->maxSequenceCount; if (layout->qmd_size_per_seq_B > 0) { diff --git a/src/nouveau/vulkan/nvk_cmd_meta.c b/src/nouveau/vulkan/nvk_cmd_meta.c index 4504df5ac93..978e52b52df 100644 --- a/src/nouveau/vulkan/nvk_cmd_meta.c +++ b/src/nouveau/vulkan/nvk_cmd_meta.c @@ -38,7 +38,7 @@ nvk_cmd_bind_map_buffer(struct vk_command_buffer *vk_cmd, VkResult nvk_device_init_meta(struct nvk_device *dev) { - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); VkResult result = vk_meta_device_init(&dev->vk, &dev->meta); if (result != VK_SUCCESS) diff --git a/src/nouveau/vulkan/nvk_codegen.c b/src/nouveau/vulkan/nvk_codegen.c index 99a1258d442..485fa970430 100644 --- a/src/nouveau/vulkan/nvk_codegen.c +++ b/src/nouveau/vulkan/nvk_codegen.c @@ -793,7 +793,8 @@ nvk_fill_transform_feedback_state(struct nak_xfb_info *xfb, } VkResult -nvk_cg_compile_nir(struct nvk_physical_device *pdev, nir_shader *nir, +nvk_cg_compile_nir(const struct nvk_physical_device *pdev, + nir_shader *nir, const struct nak_fs_key *fs_key, struct nvk_shader *shader) { diff --git a/src/nouveau/vulkan/nvk_descriptor_set.c b/src/nouveau/vulkan/nvk_descriptor_set.c index b1de3697d0d..9731302b602 100644 --- a/src/nouveau/vulkan/nvk_descriptor_set.c +++ b/src/nouveau/vulkan/nvk_descriptor_set.c @@ -167,7 +167,7 @@ write_storage_image_view_desc(struct nvk_descriptor_set *set, } static union nvk_buffer_descriptor -ubo_desc(struct nvk_physical_device *pdev, +ubo_desc(const struct nvk_physical_device *pdev, struct nvk_addr_range addr_range) { const uint32_t min_cbuf_alignment = nvk_min_cbuf_alignment(&pdev->info); @@ -192,7 +192,7 @@ ubo_desc(struct nvk_physical_device *pdev, } static void -write_ubo_desc(struct nvk_physical_device *pdev, +write_ubo_desc(const struct nvk_physical_device *pdev, struct nvk_descriptor_set *set, const VkDescriptorBufferInfo *const info, uint32_t binding, uint32_t elem) @@ -206,7 +206,7 @@ write_ubo_desc(struct nvk_physical_device *pdev, } static void -write_dynamic_ubo_desc(struct nvk_physical_device *pdev, +write_dynamic_ubo_desc(const struct nvk_physical_device *pdev, struct nvk_descriptor_set *set, const VkDescriptorBufferInfo *const info, uint32_t binding, uint32_t elem) @@ -281,7 +281,7 @@ get_edb_buffer_view_desc(struct nvk_device *dev, } static void -write_buffer_view_desc(struct nvk_physical_device *pdev, +write_buffer_view_desc(const struct nvk_physical_device *pdev, struct nvk_descriptor_set *set, const VkBufferView bufferView, uint32_t binding, uint32_t elem) @@ -318,7 +318,7 @@ nvk_UpdateDescriptorSets(VkDevice device, const VkCopyDescriptorSet *pDescriptorCopies) { VK_FROM_HANDLE(nvk_device, dev, device); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); for (uint32_t w = 0; w < descriptorWriteCount; w++) { const VkWriteDescriptorSet *write = &pDescriptorWrites[w]; @@ -445,7 +445,7 @@ nvk_push_descriptor_set_update(struct nvk_device *dev, uint32_t write_count, const VkWriteDescriptorSet *writes) { - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); assert(layout->non_variable_descriptor_buffer_size < sizeof(push_set->data)); struct nvk_descriptor_set set = { @@ -554,7 +554,7 @@ nvk_CreateDescriptorPool(VkDevice _device, VkDescriptorPool *pDescriptorPool) { VK_FROM_HANDLE(nvk_device, dev, _device); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); struct nvk_descriptor_pool *pool; VkResult result; @@ -702,7 +702,7 @@ nvk_descriptor_set_create(struct nvk_device *dev, uint32_t variable_count, struct nvk_descriptor_set **out_set) { - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); struct nvk_descriptor_set *set; VkResult result; @@ -861,7 +861,7 @@ nvk_descriptor_set_write_template(struct nvk_device *dev, const struct vk_descriptor_update_template *template, const void *data) { - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); for (uint32_t i = 0; i < template->entry_count; i++) { const struct vk_descriptor_template_entry *entry = @@ -1000,7 +1000,7 @@ nvk_GetDescriptorEXT(VkDevice _device, size_t dataSize, void *pDescriptor) { VK_FROM_HANDLE(nvk_device, dev, _device); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); switch (pDescriptorInfo->type) { case VK_DESCRIPTOR_TYPE_SAMPLER: { diff --git a/src/nouveau/vulkan/nvk_descriptor_set_layout.c b/src/nouveau/vulkan/nvk_descriptor_set_layout.c index e207560537e..a5fb148d2c9 100644 --- a/src/nouveau/vulkan/nvk_descriptor_set_layout.c +++ b/src/nouveau/vulkan/nvk_descriptor_set_layout.c @@ -134,7 +134,7 @@ nvk_CreateDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout *pSetLayout) { VK_FROM_HANDLE(nvk_device, dev, device); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); uint32_t num_bindings = 0; uint32_t immutable_sampler_count = 0; @@ -386,7 +386,7 @@ nvk_GetDescriptorSetLayoutSupport(VkDevice device, VkDescriptorSetLayoutSupport *pSupport) { VK_FROM_HANDLE(nvk_device, dev, device); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); const VkMutableDescriptorTypeCreateInfoEXT *mutable_info = vk_find_struct_const(pCreateInfo->pNext, diff --git a/src/nouveau/vulkan/nvk_device.c b/src/nouveau/vulkan/nvk_device.c index 96cbf6127b6..38d4c9e17ca 100644 --- a/src/nouveau/vulkan/nvk_device.c +++ b/src/nouveau/vulkan/nvk_device.c @@ -55,7 +55,7 @@ nvk_slm_area_ensure(struct nvk_device *dev, uint32_t slm_bytes_per_lane, uint32_t crs_bytes_per_warp) { - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); VkResult result; assert(slm_bytes_per_lane < (1 << 24)); diff --git a/src/nouveau/vulkan/nvk_device.h b/src/nouveau/vulkan/nvk_device.h index 737a522be30..4e38adc58f4 100644 --- a/src/nouveau/vulkan/nvk_device.h +++ b/src/nouveau/vulkan/nvk_device.h @@ -62,8 +62,14 @@ VkResult nvk_device_ensure_slm(struct nvk_device *dev, uint32_t slm_bytes_per_lane, uint32_t crs_bytes_per_warp); +static inline const struct nvk_physical_device * +nvk_device_physical(const struct nvk_device *dev) +{ + return (struct nvk_physical_device *)dev->vk.physical; +} + static inline struct nvk_physical_device * -nvk_device_physical(struct nvk_device *dev) +nvk_device_physical_mut(struct nvk_device *dev) { return (struct nvk_physical_device *)dev->vk.physical; } diff --git a/src/nouveau/vulkan/nvk_device_memory.c b/src/nouveau/vulkan/nvk_device_memory.c index 9d0d6e48e05..8eaa1e5ef76 100644 --- a/src/nouveau/vulkan/nvk_device_memory.c +++ b/src/nouveau/vulkan/nvk_device_memory.c @@ -65,7 +65,7 @@ nvk_GetMemoryFdPropertiesKHR(VkDevice device, VkMemoryFdPropertiesKHR *pMemoryFdProperties) { VK_FROM_HANDLE(nvk_device, dev, device); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); struct nvkmd_mem *mem; VkResult result; @@ -109,7 +109,7 @@ nvk_AllocateMemory(VkDevice device, VkDeviceMemory *pMem) { VK_FROM_HANDLE(nvk_device, dev, device); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + struct nvk_physical_device *pdev = nvk_device_physical_mut(dev); struct nvk_device_memory *mem; VkResult result = VK_SUCCESS; @@ -246,7 +246,7 @@ nvk_FreeMemory(VkDevice device, { VK_FROM_HANDLE(nvk_device, dev, device); VK_FROM_HANDLE(nvk_device_memory, mem, _mem); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + struct nvk_physical_device *pdev = nvk_device_physical_mut(dev); if (!mem) return; diff --git a/src/nouveau/vulkan/nvk_edb_bview_cache.c b/src/nouveau/vulkan/nvk_edb_bview_cache.c index cf569ee866a..239447125d0 100644 --- a/src/nouveau/vulkan/nvk_edb_bview_cache.c +++ b/src/nouveau/vulkan/nvk_edb_bview_cache.c @@ -125,7 +125,7 @@ VkResult nvk_edb_bview_cache_init(struct nvk_device *dev, struct nvk_edb_bview_cache *cache) { - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); VkResult result; cache->cache = _mesa_hash_table_create(NULL, _mesa_hash_pointer, diff --git a/src/nouveau/vulkan/nvk_image.c b/src/nouveau/vulkan/nvk_image.c index d257fa51e34..905e36fb909 100644 --- a/src/nouveau/vulkan/nvk_image.c +++ b/src/nouveau/vulkan/nvk_image.c @@ -25,7 +25,7 @@ #include "clc597.h" static VkFormatFeatureFlags2 -nvk_get_image_plane_format_features(struct nvk_physical_device *pdev, +nvk_get_image_plane_format_features(const struct nvk_physical_device *pdev, VkFormat vk_format, VkImageTiling tiling, uint64_t drm_format_mod) { @@ -100,7 +100,7 @@ nvk_get_image_plane_format_features(struct nvk_physical_device *pdev, } VkFormatFeatureFlags2 -nvk_get_image_format_features(struct nvk_physical_device *pdev, +nvk_get_image_format_features(const struct nvk_physical_device *pdev, VkFormat vk_format, VkImageTiling tiling, uint64_t drm_format_mod) { @@ -164,7 +164,7 @@ nvk_get_image_format_features(struct nvk_physical_device *pdev, } void -nvk_get_drm_format_modifier_properties_list(struct nvk_physical_device *pdev, +nvk_get_drm_format_modifier_properties_list(const struct nvk_physical_device *pdev, VkFormat vk_format, VkBaseOutStructure *ext) { @@ -740,7 +740,7 @@ nvk_image_init(struct nvk_device *dev, struct nvk_image *image, const VkImageCreateInfo *pCreateInfo) { - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); vk_image_init(&dev->vk, &image->vk, pCreateInfo); @@ -934,7 +934,7 @@ nvk_image_plane_size_align_B(struct nvk_device *dev, const struct nvk_image_plane *plane, uint64_t *size_B_out, uint64_t *align_B_out) { - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); const bool sparse_bound = image->vk.create_flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT; @@ -1019,7 +1019,7 @@ nvk_CreateImage(VkDevice _device, VkImage *pImage) { VK_FROM_HANDLE(nvk_device, dev, _device); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); struct nvk_image *image; VkResult result; @@ -1135,14 +1135,13 @@ nvk_get_image_memory_requirements(struct nvk_device *dev, VkImageAspectFlags aspects, VkMemoryRequirements2 *pMemoryRequirements) { - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); uint32_t memory_types = (1 << pdev->mem_type_count) - 1; /* Remove non host visible heaps from the types for host image copy in case * of potential issues. This should be removed when we get ReBAR. */ if (image->vk.usage & VK_IMAGE_USAGE_HOST_TRANSFER_BIT_EXT) { - struct nvk_physical_device *pdev = nvk_device_physical(dev); for (uint32_t i = 0; i < pdev->mem_type_count; i++) { if (!(pdev->mem_types[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) diff --git a/src/nouveau/vulkan/nvk_image.h b/src/nouveau/vulkan/nvk_image.h index 20084475c92..99d3f9921f1 100644 --- a/src/nouveau/vulkan/nvk_image.h +++ b/src/nouveau/vulkan/nvk_image.h @@ -42,12 +42,12 @@ struct nvkmd_mem; struct nvkmd_va; VkFormatFeatureFlags2 -nvk_get_image_format_features(struct nvk_physical_device *pdev, +nvk_get_image_format_features(const struct nvk_physical_device *pdev, VkFormat format, VkImageTiling tiling, uint64_t drm_format_mod); void -nvk_get_drm_format_modifier_properties_list(struct nvk_physical_device *pdev, +nvk_get_drm_format_modifier_properties_list(const struct nvk_physical_device *pdev, VkFormat vk_format, VkBaseOutStructure *ext); diff --git a/src/nouveau/vulkan/nvk_image_view.c b/src/nouveau/vulkan/nvk_image_view.c index b4f65031d3c..6a09cdcc822 100644 --- a/src/nouveau/vulkan/nvk_image_view.c +++ b/src/nouveau/vulkan/nvk_image_view.c @@ -102,7 +102,7 @@ nvk_image_view_init(struct nvk_device *dev, bool driver_internal, const VkImageViewCreateInfo *pCreateInfo) { - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); VK_FROM_HANDLE(nvk_image, image, pCreateInfo->image); VkResult result; diff --git a/src/nouveau/vulkan/nvk_indirect_execution_set.c b/src/nouveau/vulkan/nvk_indirect_execution_set.c index cd327fc302c..a176107930a 100644 --- a/src/nouveau/vulkan/nvk_indirect_execution_set.c +++ b/src/nouveau/vulkan/nvk_indirect_execution_set.c @@ -18,7 +18,7 @@ nvk_ies_map(struct nvk_indirect_execution_set *ies, uint32_t index) } void -nvk_ies_cs_qmd_init(struct nvk_physical_device *pdev, +nvk_ies_cs_qmd_init(const struct nvk_physical_device *pdev, struct nvk_ies_cs_qmd *qmd, struct nvk_shader *shader) { @@ -73,7 +73,7 @@ nvk_ies_set_cs(struct nvk_device *dev, } uint16_t -nvk_ies_gfx_pipeline_max_dw_count(struct nvk_physical_device *pdev, +nvk_ies_gfx_pipeline_max_dw_count(const struct nvk_physical_device *pdev, VkShaderStageFlags stages) { gl_shader_stage last_vtgm = MESA_SHADER_VERTEX; @@ -93,7 +93,7 @@ nvk_ies_gfx_pipeline_max_dw_count(struct nvk_physical_device *pdev, } static uint32_t -nvk_ies_stride_gfx_pipeline(struct nvk_physical_device *pdev, +nvk_ies_stride_gfx_pipeline(const struct nvk_physical_device *pdev, VkShaderStageFlags stages) { return sizeof(struct nvk_ies_gfx_pipeline) + @@ -145,7 +145,7 @@ nvk_ies_set_gfx_pipeline(struct nvk_device *dev, } uint16_t -nvk_ies_gfx_shader_max_dw_count(struct nvk_physical_device *pdev, +nvk_ies_gfx_shader_max_dw_count(const struct nvk_physical_device *pdev, VkShaderStageFlags stages, bool last_vtgm) { @@ -161,7 +161,7 @@ nvk_ies_gfx_shader_max_dw_count(struct nvk_physical_device *pdev, } static uint32_t -nvk_ies_stride_gfx_shader(struct nvk_physical_device *pdev, +nvk_ies_stride_gfx_shader(const struct nvk_physical_device *pdev, VkShaderStageFlags stages) { return sizeof(struct nvk_ies_gfx_shader) + @@ -238,7 +238,7 @@ nvk_CreateIndirectExecutionSetEXT(VkDevice _device, VkIndirectExecutionSetEXT *pIndirectExecutionSet) { VK_FROM_HANDLE(nvk_device, dev, _device); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); VkResult result; struct nvk_indirect_execution_set *ies = diff --git a/src/nouveau/vulkan/nvk_indirect_execution_set.h b/src/nouveau/vulkan/nvk_indirect_execution_set.h index d98f8542612..26e5f5d7bb7 100644 --- a/src/nouveau/vulkan/nvk_indirect_execution_set.h +++ b/src/nouveau/vulkan/nvk_indirect_execution_set.h @@ -25,12 +25,12 @@ struct nvk_ies_cs_qmd { PRAGMA_DIAGNOSTIC_POP static inline uint16_t -nvk_ies_cs_qmd_max_dw_count(struct nvk_physical_device *pdev) +nvk_ies_cs_qmd_max_dw_count(const struct nvk_physical_device *pdev) { return 64; } -void nvk_ies_cs_qmd_init(struct nvk_physical_device *pdev, +void nvk_ies_cs_qmd_init(const struct nvk_physical_device *pdev, struct nvk_ies_cs_qmd *qmd, struct nvk_shader *shader); @@ -45,7 +45,7 @@ PRAGMA_DIAGNOSTIC_POP static_assert(sizeof(struct nvk_ies_gfx_shader) == 4, "nvk_ies_gfx_shader has no holes"); -uint16_t nvk_ies_gfx_shader_max_dw_count(struct nvk_physical_device *pdev, +uint16_t nvk_ies_gfx_shader_max_dw_count(const struct nvk_physical_device *pdev, VkShaderStageFlags stages, bool last_vtgm); @@ -59,7 +59,7 @@ PRAGMA_DIAGNOSTIC_POP static_assert(sizeof(struct nvk_ies_gfx_pipeline) == 4, "nvk_ies_gfx_pipeline has no holes"); -uint16_t nvk_ies_gfx_pipeline_max_dw_count(struct nvk_physical_device *pdev, +uint16_t nvk_ies_gfx_pipeline_max_dw_count(const struct nvk_physical_device *pdev, VkShaderStageFlags stages); struct nvk_indirect_execution_set { diff --git a/src/nouveau/vulkan/nvk_physical_device.c b/src/nouveau/vulkan/nvk_physical_device.c index ae716b1a56f..50194222da2 100644 --- a/src/nouveau/vulkan/nvk_physical_device.c +++ b/src/nouveau/vulkan/nvk_physical_device.c @@ -1198,7 +1198,7 @@ nvk_get_device_properties(const struct nvk_instance *instance, static void nvk_physical_device_init_pipeline_cache(struct nvk_physical_device *pdev) { - struct nvk_instance *instance = nvk_physical_device_instance(pdev); + const struct nvk_instance *instance = nvk_physical_device_instance(pdev); struct mesa_sha1 sha_ctx; _mesa_sha1_init(&sha_ctx); diff --git a/src/nouveau/vulkan/nvk_physical_device.h b/src/nouveau/vulkan/nvk_physical_device.h index 74592db4811..b104b153870 100644 --- a/src/nouveau/vulkan/nvk_physical_device.h +++ b/src/nouveau/vulkan/nvk_physical_device.h @@ -74,8 +74,8 @@ nvk_use_edb_buffer_views(const struct nvk_physical_device *pdev) return pdev->debug_flags & NVK_DEBUG_FORCE_EDB_BVIEW; } -static inline struct nvk_instance * -nvk_physical_device_instance(struct nvk_physical_device *pdev) +static inline const struct nvk_instance * +nvk_physical_device_instance(const struct nvk_physical_device *pdev) { return (struct nvk_instance *)pdev->vk.instance; } diff --git a/src/nouveau/vulkan/nvk_query_pool.c b/src/nouveau/vulkan/nvk_query_pool.c index 38643c44d4d..b2ff64b3ae4 100644 --- a/src/nouveau/vulkan/nvk_query_pool.c +++ b/src/nouveau/vulkan/nvk_query_pool.c @@ -39,7 +39,7 @@ nvk_CreateQueryPool(VkDevice device, VkQueryPool *pQueryPool) { VK_FROM_HANDLE(nvk_device, dev, device); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); struct nvk_query_pool *pool; VkResult result; diff --git a/src/nouveau/vulkan/nvk_queue.c b/src/nouveau/vulkan/nvk_queue.c index b8571c02e6d..4dbeb03e7ba 100644 --- a/src/nouveau/vulkan/nvk_queue.c +++ b/src/nouveau/vulkan/nvk_queue.c @@ -46,7 +46,7 @@ nvk_queue_state_update(struct nvk_queue *queue, struct nvk_queue_state *qs) { struct nvk_device *dev = nvk_queue_device(queue); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); struct nvkmd_mem *mem; uint32_t alloc_count, bytes_per_warp, bytes_per_tpc; bool dirty = false; @@ -271,7 +271,7 @@ nvk_queue_submit_exec(struct nvk_queue *queue, struct vk_queue_submit *submit) { struct nvk_device *dev = nvk_queue_device(queue); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); VkResult result; const bool sync = pdev->debug_flags & NVK_DEBUG_PUSH_SYNC; @@ -388,7 +388,7 @@ nvk_queue_submit_simple(struct nvk_queue *queue, uint32_t dw_count, const uint32_t *dw) { struct nvk_device *dev = nvk_queue_device(queue); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); VkResult result; if (vk_queue_is_lost(&queue->vk)) @@ -434,7 +434,7 @@ static VkResult nvk_queue_init_context_state(struct nvk_queue *queue) { struct nvk_device *dev = nvk_queue_device(queue); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); VkResult result; uint32_t push_data[4096]; @@ -486,7 +486,7 @@ nvk_queue_init(struct nvk_device *dev, struct nvk_queue *queue, const VkDeviceQueueCreateInfo *pCreateInfo, uint32_t index_in_family) { - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); VkResult result; assert(pCreateInfo->queueFamilyIndex < pdev->queue_family_count); diff --git a/src/nouveau/vulkan/nvk_sampler.c b/src/nouveau/vulkan/nvk_sampler.c index 5b435dc3f20..bc2e8c9ce14 100644 --- a/src/nouveau/vulkan/nvk_sampler.c +++ b/src/nouveau/vulkan/nvk_sampler.c @@ -289,7 +289,7 @@ nvk_CreateSampler(VkDevice device, VkSampler *pSampler) { VK_FROM_HANDLE(nvk_device, dev, device); - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); struct nvk_sampler *sampler; VkResult result; diff --git a/src/nouveau/vulkan/nvk_shader.c b/src/nouveau/vulkan/nvk_shader.c index 1d214ccbf72..db2ad2f0396 100644 --- a/src/nouveau/vulkan/nvk_shader.c +++ b/src/nouveau/vulkan/nvk_shader.c @@ -402,7 +402,7 @@ nvk_lower_nir(struct nvk_device *dev, nir_shader *nir, struct vk_descriptor_set_layout * const *set_layouts, struct nvk_cbuf_map *cbuf_map_out) { - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); if (nir->info.stage == MESA_SHADER_FRAGMENT) { NIR_PASS(_, nir, nir_lower_input_attachments, @@ -544,7 +544,7 @@ nvk_shader_dump(struct nvk_shader *shader) #endif static VkResult -nvk_compile_nir_with_nak(struct nvk_physical_device *pdev, +nvk_compile_nir_with_nak(const struct nvk_physical_device *pdev, nir_shader *nir, VkShaderCreateFlagsEXT shader_flags, const struct vk_pipeline_robustness_state *rs, @@ -579,7 +579,7 @@ nvk_compile_nir(struct nvk_device *dev, nir_shader *nir, const struct nak_fs_key *fs_key, struct nvk_shader *shader) { - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); VkResult result; if (use_nak(pdev, nir->info.stage)) { @@ -615,7 +615,7 @@ nvk_compile_nir(struct nvk_device *dev, nir_shader *nir, static VkResult nvk_shader_upload(struct nvk_device *dev, struct nvk_shader *shader) { - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); uint32_t hdr_size = 0; if (shader->info.stage != MESA_SHADER_COMPUTE) { @@ -712,7 +712,7 @@ nvk_pipeline_bind_group(gl_shader_stage stage) } uint16_t -nvk_max_shader_push_dw(struct nvk_physical_device *pdev, +nvk_max_shader_push_dw(const struct nvk_physical_device *pdev, gl_shader_stage stage, bool last_vtgm) { if (stage == MESA_SHADER_COMPUTE) @@ -739,7 +739,7 @@ nvk_shader_fill_push(struct nvk_device *dev, struct nvk_shader *shader, const VkAllocationCallbacks* pAllocator) { - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); ASSERTED uint16_t max_dw_count = 0; uint32_t push_dw[200]; @@ -1032,7 +1032,7 @@ nvk_compile_nir_shader(struct nvk_device *dev, nir_shader *nir, const VkAllocationCallbacks *alloc, struct nvk_shader **shader_out) { - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); const struct vk_pipeline_robustness_state rs_none = { .uniform_buffers = VK_PIPELINE_ROBUSTNESS_BUFFER_BEHAVIOR_DISABLED_EXT, @@ -1042,7 +1042,8 @@ nvk_compile_nir_shader(struct nvk_device *dev, nir_shader *nir, assert(nir->info.stage == MESA_SHADER_COMPUTE); if (nir->options == NULL) - nir->options = nvk_get_nir_options(&pdev->vk, nir->info.stage, &rs_none); + nir->options = nvk_get_nir_options((struct vk_physical_device *)&pdev->vk, + nir->info.stage, &rs_none); struct vk_shader_compile_info info = { .stage = nir->info.stage, diff --git a/src/nouveau/vulkan/nvk_shader.h b/src/nouveau/vulkan/nvk_shader.h index 1ed143ca49c..c6fa0671c78 100644 --- a/src/nouveau/vulkan/nvk_shader.h +++ b/src/nouveau/vulkan/nvk_shader.h @@ -80,7 +80,7 @@ struct nvk_cbuf_map { }; uint16_t -nvk_max_shader_push_dw(struct nvk_physical_device *pdev, +nvk_max_shader_push_dw(const struct nvk_physical_device *pdev, gl_shader_stage stage, bool last_vtgm); struct nvk_shader { @@ -167,7 +167,8 @@ nvk_cg_nir_options(const struct nvk_physical_device *pdev, void nvk_cg_preprocess_nir(nir_shader *nir); void nvk_cg_optimize_nir(nir_shader *nir); -VkResult nvk_cg_compile_nir(struct nvk_physical_device *pdev, nir_shader *nir, +VkResult nvk_cg_compile_nir(const struct nvk_physical_device *pdev, + nir_shader *nir, const struct nak_fs_key *fs_key, struct nvk_shader *shader); diff --git a/src/nouveau/vulkan/nvk_upload_queue.c b/src/nouveau/vulkan/nvk_upload_queue.c index ac07c1b7132..58265664326 100644 --- a/src/nouveau/vulkan/nvk_upload_queue.c +++ b/src/nouveau/vulkan/nvk_upload_queue.c @@ -62,7 +62,7 @@ VkResult nvk_upload_queue_init(struct nvk_device *dev, struct nvk_upload_queue *queue) { - struct nvk_physical_device *pdev = nvk_device_physical(dev); + const struct nvk_physical_device *pdev = nvk_device_physical(dev); VkResult result; memset(queue, 0, sizeof(*queue));