summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-08-05 17:14:59 -0700
committerJason Ekstrand <[email protected]>2015-10-02 14:22:53 -0700
commite4fea486da6ee2964ae15380bcdc8676dcc2a515 (patch)
treea8faca08ee04592105e464bbf922631c65fd72d1 /src
parentcd1ae6ebfac22f76d26a5b8659423969b2aeddce (diff)
nir: Add a a nir_shader_info struct
This commit also adds code to glsl_to_nir and prog_to_nir to fill it out. Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/glsl/nir/glsl_to_nir.cpp18
-rw-r--r--src/glsl/nir/nir.c1
-rw-r--r--src/glsl/nir/nir.h34
-rw-r--r--src/mesa/program/prog_to_nir.c13
4 files changed, 66 insertions, 0 deletions
diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp
index ba08e172637..6820962b38e 100644
--- a/src/glsl/nir/glsl_to_nir.cpp
+++ b/src/glsl/nir/glsl_to_nir.cpp
@@ -144,8 +144,26 @@ glsl_to_nir(const struct gl_shader_program *shader_prog,
nir_lower_outputs_to_temporaries(shader);
+ /* TODO: Use _mesa_fls instead */
+ unsigned num_textures = 0;
+ for (unsigned i = 0; i < 8 * sizeof(sh->Program->SamplersUsed); i++)
+ if (sh->Program->SamplersUsed & (1 << i))
+ num_textures = i;
+
shader->gs.vertices_out = sh->Geom.VerticesOut;
shader->gs.invocations = sh->Geom.Invocations;
+ shader->info.name = ralloc_asprintf(shader, "GLSL%d", sh->Name);
+ shader->info.num_textures = num_textures;
+ shader->info.num_ubos = sh->NumUniformBlocks;
+ shader->info.num_abos = shader_prog->NumAtomicBuffers;
+ shader->info.num_ssbos = shader_prog->NumBufferInterfaceBlocks;
+ shader->info.num_images = sh->NumImages;
+ shader->info.inputs_read = sh->Program->InputsRead;
+ shader->info.outputs_written = sh->Program->OutputsWritten;
+ shader->info.system_values_read = sh->Program->SystemValuesRead;
+ shader->info.uses_texture_gather = sh->Program->UsesGather;
+ shader->info.uses_clip_distance_out = sh->Program->UsesClipDistanceOut;
+ shader->info.separate_shader = shader_prog->SeparateShader;
return shader;
}
diff --git a/src/glsl/nir/nir.c b/src/glsl/nir/nir.c
index fe10b380ef0..7a469a6ccf8 100644
--- a/src/glsl/nir/nir.c
+++ b/src/glsl/nir/nir.c
@@ -41,6 +41,7 @@ nir_shader_create(void *mem_ctx,
exec_list_make_empty(&shader->outputs);
shader->options = options;
+ memset(&shader->info, 0, sizeof(shader->info));
exec_list_make_empty(&shader->functions);
exec_list_make_empty(&shader->registers);
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index bf5d41d43a9..0c06d675a4d 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -1454,6 +1454,37 @@ typedef struct nir_shader_compiler_options {
bool native_integers;
} nir_shader_compiler_options;
+typedef struct nir_shader_info {
+ const char *name;
+
+ /* Number of textures used by this shader */
+ unsigned num_textures;
+ /* Number of uniform buffers used by this shader */
+ unsigned num_ubos;
+ /* Number of atomic buffers used by this shader */
+ unsigned num_abos;
+ /* Number of shader storage buffers used by this shader */
+ unsigned num_ssbos;
+ /* Number of images used by this shader */
+ unsigned num_images;
+
+ /* Which inputs are actually read */
+ uint64_t inputs_read;
+ /* Which outputs are actually written */
+ uint64_t outputs_written;
+ /* Which system values are actually read */
+ uint64_t system_values_read;
+
+ /* Whether or not this shader ever uses textureGather() */
+ bool uses_texture_gather;
+
+ /* Whether or not this shader uses the gl_ClipDistance output */
+ bool uses_clip_distance_out;
+
+ /* Whether or not separate shader objects were used */
+ bool separate_shader;
+} nir_shader_info;
+
typedef struct nir_shader {
/** list of uniforms (nir_variable) */
struct exec_list uniforms;
@@ -1471,6 +1502,9 @@ typedef struct nir_shader {
*/
const struct nir_shader_compiler_options *options;
+ /** Various bits of compile-time information about a given shader */
+ struct nir_shader_info info;
+
/** list of global variables in the shader (nir_variable) */
struct exec_list globals;
diff --git a/src/mesa/program/prog_to_nir.c b/src/mesa/program/prog_to_nir.c
index 1bd735a47bb..fc00534028f 100644
--- a/src/mesa/program/prog_to_nir.c
+++ b/src/mesa/program/prog_to_nir.c
@@ -1122,6 +1122,19 @@ prog_to_nir(const struct gl_program *prog,
ptn_add_output_stores(c);
+ s->info.name = ralloc_asprintf(s, "ARB%d", prog->Id);
+ s->info.num_textures = _mesa_fls(prog->SamplersUsed);
+ s->info.num_ubos = 0;
+ s->info.num_abos = 0;
+ s->info.num_ssbos = 0;
+ s->info.num_images = 0;
+ s->info.inputs_read = prog->InputsRead;
+ s->info.outputs_written = prog->OutputsWritten;
+ s->info.system_values_read = prog->SystemValuesRead;
+ s->info.uses_texture_gather = false;
+ s->info.uses_clip_distance_out = false;
+ s->info.separate_shader = false;
+
fail:
if (c->error) {
ralloc_free(s);