nvk: Add an nvk_shader_finish() helper

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25747>
This commit is contained in:
Faith Ekstrand 2023-10-14 00:18:45 -05:00 committed by Marge Bot
parent 112be1901b
commit 0c84c55972
3 changed files with 16 additions and 8 deletions

View file

@ -32,14 +32,8 @@ nvk_pipeline_free(struct nvk_device *dev,
struct nvk_pipeline *pipeline,
const VkAllocationCallbacks *pAllocator)
{
for (uint32_t s = 0; s < ARRAY_SIZE(pipeline->shaders); s++) {
if (pipeline->shaders[s].upload_size > 0) {
nvk_heap_free(dev, &dev->shader_heap,
pipeline->shaders[s].upload_addr,
pipeline->shaders[s].upload_size);
}
free(pipeline->shaders[s].xfb);
}
for (uint32_t s = 0; s < ARRAY_SIZE(pipeline->shaders); s++)
nvk_shader_finish(dev, &pipeline->shaders[s]);
vk_object_free(&dev->vk, pAllocator, pipeline);
}

View file

@ -1306,3 +1306,14 @@ nvk_shader_upload(struct nvk_device *dev, struct nvk_shader *shader)
return result;
}
void
nvk_shader_finish(struct nvk_device *dev, struct nvk_shader *shader)
{
if (shader->upload_size > 0) {
nvk_heap_free(dev, &dev->shader_heap,
shader->upload_addr,
shader->upload_size);
}
free(shader->xfb);
}

View file

@ -146,4 +146,7 @@ nvk_compile_nir(struct nvk_physical_device *dev, nir_shader *nir,
VkResult
nvk_shader_upload(struct nvk_device *dev, struct nvk_shader *shader);
void
nvk_shader_finish(struct nvk_device *dev, struct nvk_shader *shader);
#endif