summaryrefslogtreecommitdiffstats
path: root/src/vulkan
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-12-30 17:17:12 -0800
committerJason Ekstrand <[email protected]>2015-12-30 17:45:43 -0800
commit0fe4580e64f01d86fb48cdba665ede4e54200658 (patch)
tree1c44024910d8c44dd269f5fd4b6bf113c5b02a03 /src/vulkan
parente993e45eb157014fe6a7f65be8edda9fd716dc52 (diff)
nir/spirv: Add support for multiple entrypoints per shader
This is done by passing the entrypoint name into spirv_to_nir. It will then process the shader as if that were the only entrypoint we care about. Instead of returning a nir_shader, it now returns a nir_function.
Diffstat (limited to 'src/vulkan')
-rw-r--r--src/vulkan/anv_pipeline.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/vulkan/anv_pipeline.c b/src/vulkan/anv_pipeline.c
index 0f7835ea84f..12430f824ad 100644
--- a/src/vulkan/anv_pipeline.c
+++ b/src/vulkan/anv_pipeline.c
@@ -96,6 +96,7 @@ anv_shader_compile_to_nir(struct anv_device *device,
compiler->glsl_compiler_options[stage].NirOptions;
nir_shader *nir;
+ nir_function *entry_point;
if (module->nir) {
/* Some things such as our meta clear/blit code will give us a NIR
* shader directly. In that case, we just ignore the SPIR-V entirely
@@ -103,12 +104,18 @@ anv_shader_compile_to_nir(struct anv_device *device,
nir = module->nir;
nir->options = nir_options;
nir_validate_shader(nir);
+
+ assert(exec_list_length(&nir->functions) == 1);
+ struct exec_node *node = exec_list_get_head(&nir->functions);
+ entry_point = exec_node_data(nir_function, node, node);
} else {
uint32_t *spirv = (uint32_t *) module->data;
assert(spirv[0] == SPIR_V_MAGIC_NUMBER);
assert(module->size % 4 == 0);
- nir = spirv_to_nir(spirv, module->size / 4, nir_options);
+ entry_point = spirv_to_nir(spirv, module->size / 4, entrypoint_name,
+ nir_options);
+ nir = entry_point->shader;
assert(nir->stage == stage);
nir_validate_shader(nir);
@@ -126,24 +133,15 @@ anv_shader_compile_to_nir(struct anv_device *device,
nir->info.separate_shader = true;
/* Pick off the single entrypoint that we want */
- nir_function_impl *entrypoint = NULL;
foreach_list_typed_safe(nir_function, func, node, &nir->functions) {
- if (strcmp(entrypoint_name, func->name) != 0) {
- /* Not our function, get rid of it */
+ if (func != entry_point)
exec_node_remove(&func->node);
- continue;
- }
-
- assert(entrypoint == NULL);
- assert(func->impl);
- entrypoint = func->impl;
}
assert(exec_list_length(&nir->functions) == 1);
- assert(entrypoint != NULL);
nir = brw_preprocess_nir(nir, compiler->scalar_stage[stage]);
- nir_shader_gather_info(nir, entrypoint);
+ nir_shader_gather_info(nir, entry_point->impl);
return nir;
}