mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 04:48:08 +02:00
zink: split off CreateShaderModule into util function
Reviewed-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14976>
This commit is contained in:
parent
cd9b099038
commit
6c0740c129
2 changed files with 28 additions and 19 deletions
|
|
@ -1020,6 +1020,29 @@ zink_shader_dump(void *words, size_t size, const char *file)
|
|||
}
|
||||
}
|
||||
|
||||
VkShaderModule
|
||||
zink_shader_spirv_compile(struct zink_screen *screen, struct zink_shader *zs, struct spirv_shader *spirv)
|
||||
{
|
||||
VkShaderModule mod;
|
||||
VkShaderModuleCreateInfo smci = {0};
|
||||
|
||||
if (zink_debug & ZINK_DEBUG_SPIRV) {
|
||||
char buf[256];
|
||||
static int i;
|
||||
snprintf(buf, sizeof(buf), "dump%02d.spv", i++);
|
||||
zink_shader_dump(spirv->words, spirv->num_words * sizeof(uint32_t), buf);
|
||||
}
|
||||
|
||||
smci.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
|
||||
smci.codeSize = spirv->num_words * sizeof(uint32_t);
|
||||
smci.pCode = spirv->words;
|
||||
|
||||
VkResult ret = VKSCR(CreateShaderModule)(screen->dev, &smci, NULL, &mod);
|
||||
bool success = zink_screen_handle_vkresult(screen, ret);
|
||||
assert(success);
|
||||
return success ? mod : VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
VkShaderModule
|
||||
zink_shader_compile(struct zink_screen *screen, struct zink_shader *zs, nir_shader *base_nir, const struct zink_shader_key *key)
|
||||
{
|
||||
|
|
@ -1133,25 +1156,9 @@ zink_shader_compile(struct zink_screen *screen, struct zink_shader *zs, nir_shad
|
|||
NIR_PASS_V(nir, nir_convert_from_ssa, true);
|
||||
|
||||
struct spirv_shader *spirv = nir_to_spirv(nir, sinfo, screen->spirv_version);
|
||||
if (!spirv)
|
||||
goto done;
|
||||
if (spirv)
|
||||
mod = zink_shader_spirv_compile(screen, zs, spirv);
|
||||
|
||||
if (zink_debug & ZINK_DEBUG_SPIRV) {
|
||||
char buf[256];
|
||||
static int i;
|
||||
snprintf(buf, sizeof(buf), "dump%02d.spv", i++);
|
||||
zink_shader_dump(spirv->words, spirv->num_words * sizeof(uint32_t), buf);
|
||||
}
|
||||
|
||||
VkShaderModuleCreateInfo smci = {0};
|
||||
smci.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
|
||||
smci.codeSize = spirv->num_words * sizeof(uint32_t);
|
||||
smci.pCode = spirv->words;
|
||||
|
||||
if (VKSCR(CreateShaderModule)(screen->dev, &smci, NULL, &mod) != VK_SUCCESS)
|
||||
mod = VK_NULL_HANDLE;
|
||||
|
||||
done:
|
||||
ralloc_free(nir);
|
||||
|
||||
/* TODO: determine if there's any reason to cache spirv output? */
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ struct zink_screen;
|
|||
struct zink_shader_key;
|
||||
struct zink_shader_module;
|
||||
struct zink_gfx_program;
|
||||
struct spirv_shader;
|
||||
|
||||
struct nir_shader_compiler_options;
|
||||
struct nir_shader;
|
||||
|
|
@ -104,7 +105,8 @@ void
|
|||
zink_compiler_assign_io(nir_shader *producer, nir_shader *consumer);
|
||||
VkShaderModule
|
||||
zink_shader_compile(struct zink_screen *screen, struct zink_shader *zs, nir_shader *nir, const struct zink_shader_key *key);
|
||||
|
||||
VkShaderModule
|
||||
zink_shader_spirv_compile(struct zink_screen *screen, struct zink_shader *zs, struct spirv_shader *spirv);
|
||||
struct zink_shader *
|
||||
zink_shader_create(struct zink_screen *screen, struct nir_shader *nir,
|
||||
const struct pipe_stream_output_info *so_info);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue