summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimothy Arceri <tarceri@itsqueeze.com>2019-12-06 21:57:16 +1100
committerTimothy Arceri <tarceri@itsqueeze.com>2019-12-13 00:07:19 +0000
commita6aedc662ebbcac747475324abe3791ff67fc1a8 (patch)
treedadce9bb76192df75032944ced5098a32688740c
parent144f54e483d1e1b0cd865606fecdef002bb322b1 (diff)
st/glsl_to_nir: use nir based program resource list builder
Here we use the NIR based builder to add everything to the resource list execpt for SSO packed varyings. Since the details of those varyings get lost during packing we leave the special handing to the GLSL IR pass for now. In order to do this we add some bools to the build resource list functions. Using the NIR based resource list builder gets us a step closer to using a native NIR based linker. It should also be faster than the GLSL IR builder, one because the NIR optimisations should mean we add less entries due to better optimisations, and two because nir gives us better lists to work with and we don't need to walk the entire IR to find the resources. Ack-by: Alejandro PiƱeiro <apinheiro@igalia.com>
-rw-r--r--src/compiler/glsl/gl_nir_linker.c5
-rw-r--r--src/compiler/glsl/gl_nir_linker.h3
-rw-r--r--src/compiler/glsl/linker.cpp6
-rw-r--r--src/compiler/glsl/program.h3
-rw-r--r--src/mesa/drivers/dri/i965/brw_link.cpp4
-rw-r--r--src/mesa/program/ir_to_mesa.cpp2
-rw-r--r--src/mesa/state_tracker/st_glsl_to_ir.cpp2
-rw-r--r--src/mesa/state_tracker/st_glsl_to_nir.cpp5
8 files changed, 20 insertions, 10 deletions
diff --git a/src/compiler/glsl/gl_nir_linker.c b/src/compiler/glsl/gl_nir_linker.c
index 2664942662a..5ad590726f1 100644
--- a/src/compiler/glsl/gl_nir_linker.c
+++ b/src/compiler/glsl/gl_nir_linker.c
@@ -397,10 +397,11 @@ add_interface_variables(const struct gl_context *ctx,
*/
void
nir_build_program_resource_list(struct gl_context *ctx,
- struct gl_shader_program *prog)
+ struct gl_shader_program *prog,
+ bool rebuild_resourse_list)
{
/* Rebuild resource list. */
- if (prog->data->ProgramResourceList) {
+ if (prog->data->ProgramResourceList && rebuild_resourse_list) {
ralloc_free(prog->data->ProgramResourceList);
prog->data->ProgramResourceList = NULL;
prog->data->NumProgramResourceList = 0;
diff --git a/src/compiler/glsl/gl_nir_linker.h b/src/compiler/glsl/gl_nir_linker.h
index 82c5bf2ab49..bc7b053119c 100644
--- a/src/compiler/glsl/gl_nir_linker.h
+++ b/src/compiler/glsl/gl_nir_linker.h
@@ -47,7 +47,8 @@ void gl_nir_set_uniform_initializers(struct gl_context *ctx,
struct gl_shader_program *prog);
void nir_build_program_resource_list(struct gl_context *ctx,
- struct gl_shader_program *prog);
+ struct gl_shader_program *prog,
+ bool rebuild_resourse_list);
void gl_nir_link_assign_atomic_counter_resources(struct gl_context *ctx,
struct gl_shader_program *prog);
diff --git a/src/compiler/glsl/linker.cpp b/src/compiler/glsl/linker.cpp
index 1b30a59d8fb..81f28524429 100644
--- a/src/compiler/glsl/linker.cpp
+++ b/src/compiler/glsl/linker.cpp
@@ -4124,7 +4124,8 @@ add_fragdata_arrays(const struct gl_context *ctx,
*/
void
build_program_resource_list(struct gl_context *ctx,
- struct gl_shader_program *shProg)
+ struct gl_shader_program *shProg,
+ bool add_packed_varyings_only)
{
/* Rebuild resource list. */
if (shProg->data->ProgramResourceList) {
@@ -4164,6 +4165,9 @@ build_program_resource_list(struct gl_context *ctx,
return;
}
+ if (add_packed_varyings_only)
+ return;
+
if (!add_fragdata_arrays(ctx, shProg, resource_set))
return;
diff --git a/src/compiler/glsl/program.h b/src/compiler/glsl/program.h
index 9df42ddc1c4..0106e1dd6f3 100644
--- a/src/compiler/glsl/program.h
+++ b/src/compiler/glsl/program.h
@@ -46,7 +46,8 @@ link_shaders(struct gl_context *ctx, struct gl_shader_program *prog);
extern void
build_program_resource_list(struct gl_context *ctx,
- struct gl_shader_program *shProg);
+ struct gl_shader_program *shProg,
+ bool add_packed_varyings_only);
extern long
parse_program_resource_name(const GLchar *name,
diff --git a/src/mesa/drivers/dri/i965/brw_link.cpp b/src/mesa/drivers/dri/i965/brw_link.cpp
index 512206e71e6..c77b696e6a7 100644
--- a/src/mesa/drivers/dri/i965/brw_link.cpp
+++ b/src/mesa/drivers/dri/i965/brw_link.cpp
@@ -384,9 +384,9 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg)
/* SPIR-V programs build its resource list from linked NIR shaders. */
if (!shProg->data->spirv)
- build_program_resource_list(ctx, shProg);
+ build_program_resource_list(ctx, shProg, false);
else
- nir_build_program_resource_list(ctx, shProg);
+ nir_build_program_resource_list(ctx, shProg, true);
for (stage = 0; stage < ARRAY_SIZE(shProg->_LinkedShaders); stage++) {
struct gl_linked_shader *shader = shProg->_LinkedShaders[stage];
diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 453dff09e45..293c412d23d 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -3127,7 +3127,7 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
}
}
- build_program_resource_list(ctx, prog);
+ build_program_resource_list(ctx, prog, false);
return prog->data->LinkStatus;
}
diff --git a/src/mesa/state_tracker/st_glsl_to_ir.cpp b/src/mesa/state_tracker/st_glsl_to_ir.cpp
index 25e16fa058c..4d2a45728a9 100644
--- a/src/mesa/state_tracker/st_glsl_to_ir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_ir.cpp
@@ -167,7 +167,7 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
validate_ir_tree(ir);
}
- build_program_resource_list(ctx, prog);
+ build_program_resource_list(ctx, prog, use_nir);
if (use_nir)
return st_link_nir(ctx, prog);
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index c252babb711..425af0cfb5d 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -699,7 +699,7 @@ st_link_nir(struct gl_context *ctx,
if (!gl_nir_link(ctx, shader_program, &opts))
return GL_FALSE;
- nir_build_program_resource_list(ctx, shader_program);
+ nir_build_program_resource_list(ctx, shader_program, true);
for (unsigned i = 0; i < num_shaders; i++) {
struct gl_linked_shader *shader = linked_shader[i];
@@ -721,6 +721,9 @@ st_link_nir(struct gl_context *ctx,
linked_shader[i + 1]->Program->nir);
}
+ if (!shader_program->data->spirv)
+ nir_build_program_resource_list(ctx, shader_program, false);
+
for (unsigned i = 0; i < num_shaders; i++) {
struct gl_linked_shader *shader = linked_shader[i];
nir_shader *nir = shader->Program->nir;