mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 17:20:10 +01:00
nvk: Cache NIR shaders
We can't cache shader binaries just yet but this at least lets us cache the output of spirv_to_nir and the initial optimize. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25443>
This commit is contained in:
parent
cdbd86c176
commit
968cefbff1
4 changed files with 26 additions and 3 deletions
|
|
@ -183,7 +183,7 @@ nvk_compute_pipeline_create(struct nvk_device *dev,
|
|||
|
||||
nir_shader *nir;
|
||||
result = nvk_shader_stage_to_nir(dev, &pCreateInfo->stage, &robustness,
|
||||
NULL, &nir);
|
||||
cache, NULL, &nir);
|
||||
if (result != VK_SUCCESS)
|
||||
goto fail;
|
||||
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ nvk_graphics_pipeline_create(struct nvk_device *dev,
|
|||
pCreateInfo->pNext, sinfo->pNext);
|
||||
|
||||
result = nvk_shader_stage_to_nir(dev, sinfo, &robustness[stage],
|
||||
NULL, &nir[stage]);
|
||||
cache, NULL, &nir[stage]);
|
||||
if (result != VK_SUCCESS)
|
||||
goto fail;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include "vk_nir_convert_ycbcr.h"
|
||||
#include "vk_pipeline.h"
|
||||
#include "vk_pipeline_cache.h"
|
||||
#include "vk_pipeline_layout.h"
|
||||
#include "vk_shader_module.h"
|
||||
#include "vk_ycbcr_conversion.h"
|
||||
|
|
@ -24,6 +25,8 @@
|
|||
|
||||
#include "nv50_ir_driver.h"
|
||||
|
||||
#include "util/mesa-sha1.h"
|
||||
|
||||
#include "cla097.h"
|
||||
#include "clc397.h"
|
||||
#include "clc597.h"
|
||||
|
|
@ -421,16 +424,32 @@ VkResult
|
|||
nvk_shader_stage_to_nir(struct nvk_device *dev,
|
||||
const VkPipelineShaderStageCreateInfo *sinfo,
|
||||
const struct vk_pipeline_robustness_state *rstate,
|
||||
struct vk_pipeline_cache *cache,
|
||||
void *mem_ctx, struct nir_shader **nir_out)
|
||||
{
|
||||
struct nvk_physical_device *pdev = nvk_device_physical(dev);
|
||||
const gl_shader_stage stage = vk_to_mesa_shader_stage(sinfo->stage);
|
||||
const nir_shader_compiler_options *nir_options =
|
||||
nvk_physical_device_nir_options(pdev, stage);
|
||||
|
||||
unsigned char stage_sha1[SHA1_DIGEST_LENGTH];
|
||||
vk_pipeline_hash_shader_stage(sinfo, rstate, stage_sha1);
|
||||
|
||||
if (cache == NULL)
|
||||
cache = dev->mem_cache;
|
||||
|
||||
nir_shader *nir = vk_pipeline_cache_lookup_nir(cache, stage_sha1,
|
||||
sizeof(stage_sha1),
|
||||
nir_options, NULL,
|
||||
mem_ctx);
|
||||
if (nir != NULL) {
|
||||
*nir_out = nir;
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
const struct spirv_to_nir_options spirv_options =
|
||||
nvk_physical_device_spirv_options(pdev, rstate);
|
||||
|
||||
nir_shader *nir;
|
||||
VkResult result = vk_pipeline_shader_stage_to_nir(&dev->vk, sinfo,
|
||||
&spirv_options,
|
||||
nir_options,
|
||||
|
|
@ -438,6 +457,8 @@ nvk_shader_stage_to_nir(struct nvk_device *dev,
|
|||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
vk_pipeline_cache_add_nir(cache, stage_sha1, sizeof(stage_sha1), nir);
|
||||
|
||||
*nir_out = nir;
|
||||
|
||||
return VK_SUCCESS;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
struct nvk_device;
|
||||
struct nvk_physical_device;
|
||||
struct nvk_pipeline_compilation_ctx;
|
||||
struct vk_pipeline_cache;
|
||||
struct vk_pipeline_layout;
|
||||
struct vk_pipeline_robustness_state;
|
||||
struct vk_shader_module;
|
||||
|
|
@ -129,6 +130,7 @@ VkResult
|
|||
nvk_shader_stage_to_nir(struct nvk_device *dev,
|
||||
const VkPipelineShaderStageCreateInfo *sinfo,
|
||||
const struct vk_pipeline_robustness_state *rstate,
|
||||
struct vk_pipeline_cache *cache,
|
||||
void *mem_ctx, struct nir_shader **nir_out);
|
||||
|
||||
void
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue