radv: Don't re-use entry_point pointer from spirv_to_nir

Replace its uses with checking for is_entrypoint and calling
nir_shader_get_entrypoint().

This is a preparation to change spirv_to_nir() return type.

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
This commit is contained in:
Caio Marcelo de Oliveira Filho
2019-05-19 00:11:37 -07:00
parent ee59bac9f4
commit a3bfdacb6c

View File

@@ -210,7 +210,6 @@ radv_shader_compile_to_nir(struct radv_device *device,
const struct radv_pipeline_layout *layout)
{
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
@@ -220,8 +219,6 @@ radv_shader_compile_to_nir(struct radv_device *device,
nir_validate_shader(nir, "in internal shader");
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(module->size % 4 == 0);
@@ -290,7 +287,7 @@ radv_shader_compile_to_nir(struct radv_device *device,
.push_const_addr_format = nir_address_format_logical,
.shared_addr_format = nir_address_format_32bit_offset,
};
entry_point = spirv_to_nir(spirv, module->size / 4,
nir_function *entry_point = spirv_to_nir(spirv, module->size / 4,
spec_entries, num_spec_entries,
stage, entrypoint_name,
&spirv_options, &nir_options);
@@ -311,11 +308,12 @@ radv_shader_compile_to_nir(struct radv_device *device,
/* Pick off the single entrypoint that we want */
foreach_list_typed_safe(nir_function, func, node, &nir->functions) {
if (func != entry_point)
if (func->is_entrypoint)
func->name = ralloc_strdup(func, "main");
else
exec_node_remove(&func->node);
}
assert(exec_list_length(&nir->functions) == 1);
entry_point->name = ralloc_strdup(entry_point, "main");
/* Make sure we lower constant initializers on output variables so that
* nir_remove_dead_variables below sees the corresponding stores
@@ -344,7 +342,7 @@ radv_shader_compile_to_nir(struct radv_device *device,
/* Vulkan uses the separate-shader linking model */
nir->info.separate_shader = true;
nir_shader_gather_info(nir, entry_point->impl);
nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir));
static const nir_lower_tex_options tex_options = {
.lower_txp = ~0,