glsl/nir: Add and use a gl_nir_link() function
Perform all the NIR linking steps in order. Change iris and i965 to use it. Suggested by Alejandro. v2: Add gl_nir_linker_options struct. Reviewed-by: Alejandro Piñeiro <apinheiro@igalia.com> [v1]
This commit is contained in:
@@ -253,3 +253,19 @@ nir_build_program_resource_list(struct gl_context *ctx,
|
|||||||
|
|
||||||
_mesa_set_destroy(resource_set, NULL);
|
_mesa_set_destroy(resource_set, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
gl_nir_link(struct gl_context *ctx, struct gl_shader_program *prog,
|
||||||
|
const struct gl_nir_linker_options *options)
|
||||||
|
{
|
||||||
|
if (!gl_nir_link_uniform_blocks(ctx, prog))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (!gl_nir_link_uniforms(ctx, prog, options->fill_parameters))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
gl_nir_link_assign_atomic_counter_resources(ctx, prog);
|
||||||
|
gl_nir_link_assign_xfb_resources(ctx, prog);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
@@ -31,6 +31,14 @@ extern "C" {
|
|||||||
struct gl_context;
|
struct gl_context;
|
||||||
struct gl_shader_program;
|
struct gl_shader_program;
|
||||||
|
|
||||||
|
struct gl_nir_linker_options {
|
||||||
|
bool fill_parameters;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool gl_nir_link(struct gl_context *ctx,
|
||||||
|
struct gl_shader_program *prog,
|
||||||
|
const struct gl_nir_linker_options *options);
|
||||||
|
|
||||||
bool gl_nir_link_uniforms(struct gl_context *ctx,
|
bool gl_nir_link_uniforms(struct gl_context *ctx,
|
||||||
struct gl_shader_program *prog,
|
struct gl_shader_program *prog,
|
||||||
bool fill_parameters);
|
bool fill_parameters);
|
||||||
|
@@ -269,17 +269,13 @@ brw_link_shader(struct gl_context *ctx, struct gl_shader_program *shProg)
|
|||||||
|
|
||||||
/* SPIR-V programs use a NIR linker */
|
/* SPIR-V programs use a NIR linker */
|
||||||
if (shProg->data->spirv) {
|
if (shProg->data->spirv) {
|
||||||
if (!gl_nir_link_uniform_blocks(ctx, shProg)) {
|
static const gl_nir_linker_options opts = {
|
||||||
|
.fill_parameters = false,
|
||||||
|
};
|
||||||
|
if (!gl_nir_link(ctx, shProg, &opts))
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gl_nir_link_uniforms(ctx, shProg, /* fill_parameters */ false))
|
|
||||||
return GL_FALSE;
|
|
||||||
|
|
||||||
gl_nir_link_assign_atomic_counter_resources(ctx, shProg);
|
|
||||||
gl_nir_link_assign_xfb_resources(ctx, shProg);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (stage = 0; stage < ARRAY_SIZE(shProg->_LinkedShaders); stage++) {
|
for (stage = 0; stage < ARRAY_SIZE(shProg->_LinkedShaders); stage++) {
|
||||||
struct gl_linked_shader *shader = shProg->_LinkedShaders[stage];
|
struct gl_linked_shader *shader = shProg->_LinkedShaders[stage];
|
||||||
if (!shader)
|
if (!shader)
|
||||||
|
@@ -687,15 +687,12 @@ st_link_nir(struct gl_context *ctx,
|
|||||||
* st_nir_preprocess.
|
* st_nir_preprocess.
|
||||||
*/
|
*/
|
||||||
if (shader_program->data->spirv) {
|
if (shader_program->data->spirv) {
|
||||||
if (!gl_nir_link_uniform_blocks(ctx, shader_program))
|
static const gl_nir_linker_options opts = {
|
||||||
|
.fill_parameters = true,
|
||||||
|
};
|
||||||
|
if (!gl_nir_link(ctx, shader_program, &opts))
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
if (!gl_nir_link_uniforms(ctx, shader_program, /* fill_parameters */ true))
|
|
||||||
return GL_FALSE;
|
|
||||||
|
|
||||||
gl_nir_link_assign_atomic_counter_resources(ctx, shader_program);
|
|
||||||
gl_nir_link_assign_xfb_resources(ctx, shader_program);
|
|
||||||
|
|
||||||
nir_build_program_resource_list(ctx, shader_program);
|
nir_build_program_resource_list(ctx, shader_program);
|
||||||
|
|
||||||
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
|
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
|
||||||
|
Reference in New Issue
Block a user