nir: Add a nir_shader_compiler_options struct pointed to by the shaders.
This will be used to give the optimization passes a chance to customize behavior for the particular target device. v2: Rebase to master (no TGSI->NIR present) Reviewed-by: Kenneth Graunke <kenneth@whitecape.org> (v1)
This commit is contained in:
@@ -124,11 +124,32 @@ private:
|
|||||||
|
|
||||||
}; /* end of anonymous namespace */
|
}; /* end of anonymous namespace */
|
||||||
|
|
||||||
|
static const nir_shader_compiler_options default_options = {
|
||||||
|
};
|
||||||
|
|
||||||
nir_shader *
|
nir_shader *
|
||||||
glsl_to_nir(exec_list *ir, _mesa_glsl_parse_state *state,
|
glsl_to_nir(exec_list *ir, _mesa_glsl_parse_state *state,
|
||||||
bool native_integers)
|
bool native_integers)
|
||||||
{
|
{
|
||||||
nir_shader *shader = nir_shader_create(NULL);
|
const nir_shader_compiler_options *options;
|
||||||
|
|
||||||
|
if (state) {
|
||||||
|
struct gl_context *ctx = state->ctx;
|
||||||
|
struct gl_shader_compiler_options *gl_options =
|
||||||
|
&ctx->Const.ShaderCompilerOptions[state->stage];
|
||||||
|
|
||||||
|
if (!gl_options->NirOptions) {
|
||||||
|
nir_shader_compiler_options *new_options =
|
||||||
|
rzalloc(ctx, nir_shader_compiler_options);
|
||||||
|
options = gl_options->NirOptions = new_options;
|
||||||
|
} else {
|
||||||
|
options = gl_options->NirOptions;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
options = &default_options;
|
||||||
|
}
|
||||||
|
|
||||||
|
nir_shader *shader = nir_shader_create(NULL, options);
|
||||||
|
|
||||||
if (state) {
|
if (state) {
|
||||||
shader->num_user_structures = state->num_user_structures;
|
shader->num_user_structures = state->num_user_structures;
|
||||||
|
@@ -29,7 +29,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
nir_shader *
|
nir_shader *
|
||||||
nir_shader_create(void *mem_ctx)
|
nir_shader_create(void *mem_ctx, const nir_shader_compiler_options *options)
|
||||||
{
|
{
|
||||||
nir_shader *shader = ralloc(mem_ctx, nir_shader);
|
nir_shader *shader = ralloc(mem_ctx, nir_shader);
|
||||||
|
|
||||||
@@ -40,6 +40,8 @@ nir_shader_create(void *mem_ctx)
|
|||||||
shader->outputs = _mesa_hash_table_create(shader, _mesa_key_hash_string,
|
shader->outputs = _mesa_hash_table_create(shader, _mesa_key_hash_string,
|
||||||
_mesa_key_string_equal);
|
_mesa_key_string_equal);
|
||||||
|
|
||||||
|
shader->options = options;
|
||||||
|
|
||||||
shader->num_user_structures = 0;
|
shader->num_user_structures = 0;
|
||||||
shader->user_structures = NULL;
|
shader->user_structures = NULL;
|
||||||
|
|
||||||
|
@@ -1326,6 +1326,9 @@ typedef struct nir_function {
|
|||||||
exec_node_data(nir_function_overload, \
|
exec_node_data(nir_function_overload, \
|
||||||
exec_list_get_head(&(func)->overload_list), node)
|
exec_list_get_head(&(func)->overload_list), node)
|
||||||
|
|
||||||
|
typedef struct nir_shader_compiler_options {
|
||||||
|
} nir_shader_compiler_options;
|
||||||
|
|
||||||
typedef struct nir_shader {
|
typedef struct nir_shader {
|
||||||
/** hash table of name -> uniform nir_variable */
|
/** hash table of name -> uniform nir_variable */
|
||||||
struct hash_table *uniforms;
|
struct hash_table *uniforms;
|
||||||
@@ -1336,6 +1339,13 @@ typedef struct nir_shader {
|
|||||||
/** hash table of name -> output nir_variable */
|
/** hash table of name -> output nir_variable */
|
||||||
struct hash_table *outputs;
|
struct hash_table *outputs;
|
||||||
|
|
||||||
|
/** Set of driver-specific options for the shader.
|
||||||
|
*
|
||||||
|
* The memory for the options is expected to be kept in a single static
|
||||||
|
* copy by the driver.
|
||||||
|
*/
|
||||||
|
const struct nir_shader_compiler_options *options;
|
||||||
|
|
||||||
/** list of global variables in the shader */
|
/** list of global variables in the shader */
|
||||||
struct exec_list globals;
|
struct exec_list globals;
|
||||||
|
|
||||||
@@ -1366,7 +1376,8 @@ typedef struct nir_shader {
|
|||||||
foreach_list_typed(nir_function_overload, overload, node, \
|
foreach_list_typed(nir_function_overload, overload, node, \
|
||||||
&(func)->overload_list)
|
&(func)->overload_list)
|
||||||
|
|
||||||
nir_shader *nir_shader_create(void *mem_ctx);
|
nir_shader *nir_shader_create(void *mem_ctx,
|
||||||
|
const nir_shader_compiler_options *options);
|
||||||
|
|
||||||
/** creates a register, including assigning it an index and adding it to the list */
|
/** creates a register, including assigning it an index and adding it to the list */
|
||||||
nir_register *nir_global_reg_create(nir_shader *shader);
|
nir_register *nir_global_reg_create(nir_shader *shader);
|
||||||
|
@@ -3034,6 +3034,8 @@ struct gl_shader_compiler_options
|
|||||||
GLboolean OptimizeForAOS;
|
GLboolean OptimizeForAOS;
|
||||||
|
|
||||||
struct gl_sl_pragmas DefaultPragmas; /**< Default #pragma settings */
|
struct gl_sl_pragmas DefaultPragmas; /**< Default #pragma settings */
|
||||||
|
|
||||||
|
struct nir_shader_compiler_options *NirOptions;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user