mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-26 12:50:10 +01:00
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 <kenneth@whitecape.org>
This commit is contained in:
parent
cd1ae6ebfa
commit
e4fea486da
4 changed files with 66 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue