[Mesa-dev] [PATCH 10/25] mesa/nir/radv/anv: add shader_info param to nir_shader builder
Timothy Arceri
timothy.arceri at collabora.com
Tue Oct 18 06:12:13 UTC 2016
And pass in a pointer to the shader info in gl_program for ARB programs.
---
src/amd/vulkan/radv_meta_blit.c | 12 ++++++++----
src/amd/vulkan/radv_meta_blit2d.c | 12 ++++++++----
src/amd/vulkan/radv_meta_buffer.c | 6 ++++--
src/amd/vulkan/radv_meta_bufimage.c | 3 ++-
src/amd/vulkan/radv_meta_clear.c | 12 ++++++++----
src/amd/vulkan/radv_meta_decompress.c | 6 ++++--
src/amd/vulkan/radv_meta_fast_clear.c | 6 ++++--
src/amd/vulkan/radv_meta_resolve.c | 6 ++++--
src/amd/vulkan/radv_meta_resolve_cs.c | 2 +-
src/amd/vulkan/radv_pipeline.c | 2 +-
src/compiler/nir/nir_builder.h | 5 +++--
src/compiler/nir/tests/control_flow_tests.cpp | 3 ++-
src/gallium/auxiliary/nir/tgsi_to_nir.c | 2 +-
src/intel/blorp/blorp_blit.c | 2 +-
src/intel/blorp/blorp_clear.c | 2 +-
src/mesa/drivers/dri/i965/brw_program.c | 2 +-
src/mesa/drivers/dri/i965/brw_program.h | 2 +-
src/mesa/drivers/dri/i965/brw_tcs.c | 3 ++-
src/mesa/program/prog_to_nir.c | 5 +++--
src/mesa/program/prog_to_nir.h | 2 +-
20 files changed, 60 insertions(+), 35 deletions(-)
diff --git a/src/amd/vulkan/radv_meta_blit.c b/src/amd/vulkan/radv_meta_blit.c
index bfbf880..3eda43e 100644
--- a/src/amd/vulkan/radv_meta_blit.c
+++ b/src/amd/vulkan/radv_meta_blit.c
@@ -37,7 +37,8 @@ build_nir_vertex_shader(void)
const struct glsl_type *vec4 = glsl_vec4_type();
nir_builder b;
- nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_VERTEX, NULL);
+ nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_VERTEX, NULL,
+ NULL);
b.shader->info->name = ralloc_strdup(b.shader, "meta_blit_vs");
nir_variable *pos_in = nir_variable_create(b.shader, nir_var_shader_in,
@@ -67,7 +68,8 @@ build_nir_copy_fragment_shader(enum glsl_sampler_dim tex_dim)
const struct glsl_type *vec4 = glsl_vec4_type();
nir_builder b;
- nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL);
+ nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL,
+ NULL);
sprintf(shader_name, "meta_blit_fs.%d", tex_dim);
b.shader->info->name = ralloc_strdup(b.shader, shader_name);
@@ -121,7 +123,8 @@ build_nir_copy_fragment_shader_depth(enum glsl_sampler_dim tex_dim)
const struct glsl_type *vec4 = glsl_vec4_type();
nir_builder b;
- nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL);
+ nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL,
+ NULL);
sprintf(shader_name, "meta_blit_depth_fs.%d", tex_dim);
b.shader->info->name = ralloc_strdup(b.shader, shader_name);
@@ -175,7 +178,8 @@ build_nir_copy_fragment_shader_stencil(enum glsl_sampler_dim tex_dim)
const struct glsl_type *vec4 = glsl_vec4_type();
nir_builder b;
- nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL);
+ nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL,
+ NULL);
sprintf(shader_name, "meta_blit_stencil_fs.%d", tex_dim);
b.shader->info->name = ralloc_strdup(b.shader, shader_name);
diff --git a/src/amd/vulkan/radv_meta_blit2d.c b/src/amd/vulkan/radv_meta_blit2d.c
index 6e92f80..bed03a3 100644
--- a/src/amd/vulkan/radv_meta_blit2d.c
+++ b/src/amd/vulkan/radv_meta_blit2d.c
@@ -438,7 +438,8 @@ build_nir_vertex_shader(void)
const struct glsl_type *vec2 = glsl_vector_type(GLSL_TYPE_FLOAT, 2);
nir_builder b;
- nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_VERTEX, NULL);
+ nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_VERTEX, NULL,
+ NULL);
b.shader->info->name = ralloc_strdup(b.shader, "meta_blit_vs");
nir_variable *pos_in = nir_variable_create(b.shader, nir_var_shader_in,
@@ -573,7 +574,8 @@ build_nir_copy_fragment_shader(struct radv_device *device,
const struct glsl_type *vec2 = glsl_vector_type(GLSL_TYPE_FLOAT, 2);
nir_builder b;
- nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL);
+ nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL,
+ NULL);
b.shader->info->name = ralloc_strdup(b.shader, name);
nir_variable *tex_pos_in = nir_variable_create(b.shader, nir_var_shader_in,
@@ -602,7 +604,8 @@ build_nir_copy_fragment_shader_depth(struct radv_device *device,
const struct glsl_type *vec2 = glsl_vector_type(GLSL_TYPE_FLOAT, 2);
nir_builder b;
- nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL);
+ nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL,
+ NULL);
b.shader->info->name = ralloc_strdup(b.shader, name);
nir_variable *tex_pos_in = nir_variable_create(b.shader, nir_var_shader_in,
@@ -631,7 +634,8 @@ build_nir_copy_fragment_shader_stencil(struct radv_device *device,
const struct glsl_type *vec2 = glsl_vector_type(GLSL_TYPE_FLOAT, 2);
nir_builder b;
- nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL);
+ nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL,
+ NULL);
b.shader->info->name = ralloc_strdup(b.shader, name);
nir_variable *tex_pos_in = nir_variable_create(b.shader, nir_var_shader_in,
diff --git a/src/amd/vulkan/radv_meta_buffer.c b/src/amd/vulkan/radv_meta_buffer.c
index 05c4971..6294975 100644
--- a/src/amd/vulkan/radv_meta_buffer.c
+++ b/src/amd/vulkan/radv_meta_buffer.c
@@ -9,7 +9,8 @@ build_buffer_fill_shader(struct radv_device *dev)
{
nir_builder b;
- nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_COMPUTE, NULL);
+ nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_COMPUTE, NULL,
+ NULL);
b.shader->info->name = ralloc_strdup(b.shader, "meta_buffer_fill");
b.shader->info->cs.local_size[0] = 64;
b.shader->info->cs.local_size[1] = 1;
@@ -59,7 +60,8 @@ build_buffer_copy_shader(struct radv_device *dev)
{
nir_builder b;
- nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_COMPUTE, NULL);
+ nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_COMPUTE, NULL,
+ NULL);
b.shader->info->name = ralloc_strdup(b.shader, "meta_buffer_copy");
b.shader->info->cs.local_size[0] = 64;
b.shader->info->cs.local_size[1] = 1;
diff --git a/src/amd/vulkan/radv_meta_bufimage.c b/src/amd/vulkan/radv_meta_bufimage.c
index c9dd072..005b52c 100644
--- a/src/amd/vulkan/radv_meta_bufimage.c
+++ b/src/amd/vulkan/radv_meta_bufimage.c
@@ -13,7 +13,8 @@ build_nir_itob_compute_shader(struct radv_device *dev)
false,
false,
GLSL_TYPE_FLOAT);
- nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_COMPUTE, NULL);
+ nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_COMPUTE, NULL,
+ NULL);
b.shader->info->name = ralloc_strdup(b.shader, "meta_itob_cs");
b.shader->info->cs.local_size[0] = 16;
b.shader->info->cs.local_size[1] = 16;
diff --git a/src/amd/vulkan/radv_meta_clear.c b/src/amd/vulkan/radv_meta_clear.c
index 34b318a..276fc65 100644
--- a/src/amd/vulkan/radv_meta_clear.c
+++ b/src/amd/vulkan/radv_meta_clear.c
@@ -53,8 +53,10 @@ build_color_shaders(struct nir_shader **out_vs,
nir_builder vs_b;
nir_builder fs_b;
- nir_builder_init_simple_shader(&vs_b, NULL, MESA_SHADER_VERTEX, NULL);
- nir_builder_init_simple_shader(&fs_b, NULL, MESA_SHADER_FRAGMENT, NULL);
+ nir_builder_init_simple_shader(&vs_b, NULL, MESA_SHADER_VERTEX, NULL,
+ NULL);
+ nir_builder_init_simple_shader(&fs_b, NULL, MESA_SHADER_FRAGMENT, NULL,
+ NULL);
vs_b.shader->info->name = ralloc_strdup(vs_b.shader, "meta_clear_color_vs");
fs_b.shader->info->name = ralloc_strdup(fs_b.shader, "meta_clear_color_fs");
@@ -455,8 +457,10 @@ build_depthstencil_shader(struct nir_shader **out_vs, struct nir_shader **out_fs
{
nir_builder vs_b, fs_b;
- nir_builder_init_simple_shader(&vs_b, NULL, MESA_SHADER_VERTEX, NULL);
- nir_builder_init_simple_shader(&fs_b, NULL, MESA_SHADER_FRAGMENT, NULL);
+ nir_builder_init_simple_shader(&vs_b, NULL, MESA_SHADER_VERTEX, NULL,
+ NULL);
+ nir_builder_init_simple_shader(&fs_b, NULL, MESA_SHADER_FRAGMENT, NULL,
+ NULL);
vs_b.shader->info->name = ralloc_strdup(vs_b.shader, "meta_clear_depthstencil_vs");
fs_b.shader->info->name = ralloc_strdup(fs_b.shader, "meta_clear_depthstencil_fs");
diff --git a/src/amd/vulkan/radv_meta_decompress.c b/src/amd/vulkan/radv_meta_decompress.c
index 47ef64d..ff91abd 100644
--- a/src/amd/vulkan/radv_meta_decompress.c
+++ b/src/amd/vulkan/radv_meta_decompress.c
@@ -45,7 +45,8 @@ build_nir_vs(void)
nir_variable *a_position;
nir_variable *v_position;
- nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_VERTEX, NULL);
+ nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_VERTEX, NULL,
+ NULL);
b.shader->info->name = ralloc_strdup(b.shader, "meta_depth_decomp_vs");
a_position = nir_variable_create(b.shader, nir_var_shader_in, vec4,
@@ -67,7 +68,8 @@ build_nir_fs(void)
{
nir_builder b;
- nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL);
+ nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL,
+ NULL);
b.shader->info->name = ralloc_asprintf(b.shader,
"meta_depth_decomp_noop_fs");
diff --git a/src/amd/vulkan/radv_meta_fast_clear.c b/src/amd/vulkan/radv_meta_fast_clear.c
index d3ebf41..89a56d3 100644
--- a/src/amd/vulkan/radv_meta_fast_clear.c
+++ b/src/amd/vulkan/radv_meta_fast_clear.c
@@ -48,7 +48,8 @@ build_nir_vs(void)
nir_variable *a_tex_position;
nir_variable *v_tex_position;
- nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_VERTEX, NULL);
+ nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_VERTEX, NULL,
+ NULL);
b.shader->info->name = ralloc_strdup(b.shader, "meta_fast_clear_vs");
a_position = nir_variable_create(b.shader, nir_var_shader_in, vec4,
@@ -82,7 +83,8 @@ build_nir_fs(void)
nir_variable *v_tex_position; /* vec4, varying texture coordinate */
nir_variable *f_color; /* vec4, fragment output color */
- nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL);
+ nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL,
+ NULL);
b.shader->info->name = ralloc_asprintf(b.shader,
"meta_fast_clear_fs");
diff --git a/src/amd/vulkan/radv_meta_resolve.c b/src/amd/vulkan/radv_meta_resolve.c
index 8e2a353..a937dea 100644
--- a/src/amd/vulkan/radv_meta_resolve.c
+++ b/src/amd/vulkan/radv_meta_resolve.c
@@ -48,7 +48,8 @@ build_nir_vs(void)
nir_variable *a_tex_position;
nir_variable *v_tex_position;
- nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_VERTEX, NULL);
+ nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_VERTEX, NULL,
+ NULL);
b.shader->info->name = ralloc_strdup(b.shader, "meta_resolve_vs");
a_position = nir_variable_create(b.shader, nir_var_shader_in, vec4,
@@ -82,7 +83,8 @@ build_nir_fs(void)
nir_variable *v_tex_position; /* vec4, varying texture coordinate */
nir_variable *f_color; /* vec4, fragment output color */
- nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL);
+ nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL,
+ NULL);
b.shader->info->name = ralloc_asprintf(b.shader,
"meta_resolve_fs");
diff --git a/src/amd/vulkan/radv_meta_resolve_cs.c b/src/amd/vulkan/radv_meta_resolve_cs.c
index 126823b..8d62ef9 100644
--- a/src/amd/vulkan/radv_meta_resolve_cs.c
+++ b/src/amd/vulkan/radv_meta_resolve_cs.c
@@ -46,7 +46,7 @@ build_resolve_compute_shader(struct radv_device *dev, bool is_integer, int sampl
false,
GLSL_TYPE_FLOAT);
snprintf(name, 64, "meta_resolve_cs-%d-%s", samples, is_integer ? "int" : "float");
- nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_COMPUTE, NULL);
+ nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_COMPUTE, NULL, NULL);
b.shader->info->name = ralloc_strdup(b.shader, name);
b.shader->info->cs.local_size[0] = 16;
b.shader->info->cs.local_size[1] = 16;
diff --git a/src/amd/vulkan/radv_pipeline.c b/src/amd/vulkan/radv_pipeline.c
index edc0674e..921b602 100644
--- a/src/amd/vulkan/radv_pipeline.c
+++ b/src/amd/vulkan/radv_pipeline.c
@@ -1215,7 +1215,7 @@ radv_pipeline_init(struct radv_pipeline *pipeline,
if (!modules[MESA_SHADER_FRAGMENT]) {
nir_builder fs_b;
- nir_builder_init_simple_shader(&fs_b, NULL, MESA_SHADER_FRAGMENT, NULL);
+ nir_builder_init_simple_shader(&fs_b, NULL, MESA_SHADER_FRAGMENT, NULL, NULL);
fs_b.shader->info->name = ralloc_strdup(fs_b.shader, "noop_fs");
fs_m.nir = fs_b.shader;
modules[MESA_SHADER_FRAGMENT] = &fs_m;
diff --git a/src/compiler/nir/nir_builder.h b/src/compiler/nir/nir_builder.h
index 0ee7d1a..5ff84e2 100644
--- a/src/compiler/nir/nir_builder.h
+++ b/src/compiler/nir/nir_builder.h
@@ -50,9 +50,10 @@ nir_builder_init(nir_builder *build, nir_function_impl *impl)
static inline void
nir_builder_init_simple_shader(nir_builder *build, void *mem_ctx,
gl_shader_stage stage,
- const nir_shader_compiler_options *options)
+ const nir_shader_compiler_options *options,
+ shader_info *si)
{
- build->shader = nir_shader_create(mem_ctx, stage, options, NULL);
+ build->shader = nir_shader_create(mem_ctx, stage, options, si);
nir_function *func = nir_function_create(build->shader, "main");
build->exact = false;
build->impl = nir_function_impl_create(func);
diff --git a/src/compiler/nir/tests/control_flow_tests.cpp b/src/compiler/nir/tests/control_flow_tests.cpp
index ae0954f..0b70f57 100644
--- a/src/compiler/nir/tests/control_flow_tests.cpp
+++ b/src/compiler/nir/tests/control_flow_tests.cpp
@@ -35,7 +35,8 @@ protected:
nir_cf_test::nir_cf_test()
{
static const nir_shader_compiler_options options = { };
- nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_VERTEX, &options);
+ nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_VERTEX, &options,
+ NULL);
}
nir_cf_test::~nir_cf_test()
diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c
index 3f05acd..adeea60 100644
--- a/src/gallium/auxiliary/nir/tgsi_to_nir.c
+++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c
@@ -1999,7 +1999,7 @@ tgsi_to_nir(const void *tgsi_tokens,
nir_builder_init_simple_shader(&c->build, NULL,
tgsi_processor_to_shader_stage(scan.processor),
- options);
+ options, NULL);
s = c->build.shader;
s->num_inputs = scan.file_max[TGSI_FILE_INPUT] + 1;
diff --git a/src/intel/blorp/blorp_blit.c b/src/intel/blorp/blorp_blit.c
index 0c3ee72..d7a7763 100644
--- a/src/intel/blorp/blorp_blit.c
+++ b/src/intel/blorp/blorp_blit.c
@@ -1044,7 +1044,7 @@ brw_blorp_build_nir_shader(struct blorp_context *blorp,
(key->dst_samples <= 1));
nir_builder b;
- nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL);
+ nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL, NULL);
struct brw_blorp_blit_vars v;
brw_blorp_blit_vars_init(&b, &v, key);
diff --git a/src/intel/blorp/blorp_clear.c b/src/intel/blorp/blorp_clear.c
index f932789..8285e0e 100644
--- a/src/intel/blorp/blorp_clear.c
+++ b/src/intel/blorp/blorp_clear.c
@@ -55,7 +55,7 @@ blorp_params_get_clear_kernel(struct blorp_context *blorp,
void *mem_ctx = ralloc_context(NULL);
nir_builder b;
- nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL);
+ nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL, NULL);
b.shader->info->name = ralloc_strdup(b.shader, "BLORP-clear");
nir_variable *v_color = nir_variable_create(b.shader, nir_var_shader_in,
diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c
index 7151558..8c0c936 100644
--- a/src/mesa/drivers/dri/i965/brw_program.c
+++ b/src/mesa/drivers/dri/i965/brw_program.c
@@ -64,7 +64,7 @@ brw_nir_lower_uniforms(nir_shader *nir, bool is_scalar)
nir_shader *
brw_create_nir(struct brw_context *brw,
const struct gl_shader_program *shader_prog,
- const struct gl_program *prog,
+ struct gl_program *prog,
gl_shader_stage stage,
bool is_scalar)
{
diff --git a/src/mesa/drivers/dri/i965/brw_program.h b/src/mesa/drivers/dri/i965/brw_program.h
index eed07a2..7b24dbb 100644
--- a/src/mesa/drivers/dri/i965/brw_program.h
+++ b/src/mesa/drivers/dri/i965/brw_program.h
@@ -34,7 +34,7 @@ struct brw_context;
struct nir_shader *brw_create_nir(struct brw_context *brw,
const struct gl_shader_program *shader_prog,
- const struct gl_program *prog,
+ struct gl_program *prog,
gl_shader_stage stage,
bool is_scalar);
diff --git a/src/mesa/drivers/dri/i965/brw_tcs.c b/src/mesa/drivers/dri/i965/brw_tcs.c
index 7511507..0910d24 100644
--- a/src/mesa/drivers/dri/i965/brw_tcs.c
+++ b/src/mesa/drivers/dri/i965/brw_tcs.c
@@ -41,7 +41,8 @@ create_passthrough_tcs(const struct brw_compiler *compiler,
const struct brw_tcs_prog_key *key)
{
nir_builder b;
- nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_TESS_CTRL, options);
+ nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_TESS_CTRL, options,
+ NULL);
nir_shader *nir = b.shader;
nir_variable *var;
nir_intrinsic_instr *load;
diff --git a/src/mesa/program/prog_to_nir.c b/src/mesa/program/prog_to_nir.c
index a65d4bf..a675bc6 100644
--- a/src/mesa/program/prog_to_nir.c
+++ b/src/mesa/program/prog_to_nir.c
@@ -1006,7 +1006,7 @@ setup_registers_and_variables(struct ptn_compile *c)
}
struct nir_shader *
-prog_to_nir(const struct gl_program *prog,
+prog_to_nir(struct gl_program *prog,
const nir_shader_compiler_options *options)
{
struct ptn_compile *c;
@@ -1018,7 +1018,8 @@ prog_to_nir(const struct gl_program *prog,
return NULL;
c->prog = prog;
- nir_builder_init_simple_shader(&c->build, NULL, stage, options);
+ nir_builder_init_simple_shader(&c->build, NULL, stage, options,
+ &prog->info);
s = c->build.shader;
if (prog->Parameters->NumParameters > 0) {
diff --git a/src/mesa/program/prog_to_nir.h b/src/mesa/program/prog_to_nir.h
index 09425b5..b1e0ec7 100644
--- a/src/mesa/program/prog_to_nir.h
+++ b/src/mesa/program/prog_to_nir.h
@@ -31,7 +31,7 @@
extern "C" {
#endif
-struct nir_shader *prog_to_nir(const struct gl_program *prog,
+struct nir_shader *prog_to_nir(struct gl_program *prog,
const nir_shader_compiler_options *options);
#ifdef __cplusplus
--
2.7.4
More information about the mesa-dev
mailing list