glsl: Pass ctx to program interface query helper functions.
The next commit will use this in add_shader_variable - this just separates out some of the mechanical changes for easier review. Cc: mesa-stable@lists.freedesktop.org Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com> Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
This commit is contained in:
@@ -3654,7 +3654,9 @@ create_shader_variable(struct gl_shader_program *shProg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
add_shader_variable(struct gl_shader_program *shProg, struct set *resource_set,
|
add_shader_variable(const struct gl_context *ctx,
|
||||||
|
struct gl_shader_program *shProg,
|
||||||
|
struct set *resource_set,
|
||||||
unsigned stage_mask,
|
unsigned stage_mask,
|
||||||
GLenum programInterface, ir_variable *var,
|
GLenum programInterface, ir_variable *var,
|
||||||
const char *name, const glsl_type *type,
|
const char *name, const glsl_type *type,
|
||||||
@@ -3683,7 +3685,7 @@ add_shader_variable(struct gl_shader_program *shProg, struct set *resource_set,
|
|||||||
for (unsigned i = 0; i < type->length; i++) {
|
for (unsigned i = 0; i < type->length; i++) {
|
||||||
const struct glsl_struct_field *field = &type->fields.structure[i];
|
const struct glsl_struct_field *field = &type->fields.structure[i];
|
||||||
char *field_name = ralloc_asprintf(shProg, "%s.%s", name, field->name);
|
char *field_name = ralloc_asprintf(shProg, "%s.%s", name, field->name);
|
||||||
if (!add_shader_variable(shProg, resource_set,
|
if (!add_shader_variable(ctx, shProg, resource_set,
|
||||||
stage_mask, programInterface,
|
stage_mask, programInterface,
|
||||||
var, field_name, field->type,
|
var, field_name, field->type,
|
||||||
use_implicit_location, field_location,
|
use_implicit_location, field_location,
|
||||||
@@ -3733,7 +3735,8 @@ add_shader_variable(struct gl_shader_program *shProg, struct set *resource_set,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
add_interface_variables(struct gl_shader_program *shProg,
|
add_interface_variables(const struct gl_context *ctx,
|
||||||
|
struct gl_shader_program *shProg,
|
||||||
struct set *resource_set,
|
struct set *resource_set,
|
||||||
unsigned stage, GLenum programInterface)
|
unsigned stage, GLenum programInterface)
|
||||||
{
|
{
|
||||||
@@ -3784,7 +3787,7 @@ add_interface_variables(struct gl_shader_program *shProg,
|
|||||||
(stage == MESA_SHADER_VERTEX && var->data.mode == ir_var_shader_in) ||
|
(stage == MESA_SHADER_VERTEX && var->data.mode == ir_var_shader_in) ||
|
||||||
(stage == MESA_SHADER_FRAGMENT && var->data.mode == ir_var_shader_out);
|
(stage == MESA_SHADER_FRAGMENT && var->data.mode == ir_var_shader_out);
|
||||||
|
|
||||||
if (!add_shader_variable(shProg, resource_set,
|
if (!add_shader_variable(ctx, shProg, resource_set,
|
||||||
1 << stage, programInterface,
|
1 << stage, programInterface,
|
||||||
var, var->name, var->type, vs_input_or_fs_output,
|
var, var->name, var->type, vs_input_or_fs_output,
|
||||||
var->data.location - loc_bias))
|
var->data.location - loc_bias))
|
||||||
@@ -3794,7 +3797,9 @@ add_interface_variables(struct gl_shader_program *shProg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
add_packed_varyings(struct gl_shader_program *shProg, struct set *resource_set,
|
add_packed_varyings(const struct gl_context *ctx,
|
||||||
|
struct gl_shader_program *shProg,
|
||||||
|
struct set *resource_set,
|
||||||
int stage, GLenum type)
|
int stage, GLenum type)
|
||||||
{
|
{
|
||||||
struct gl_linked_shader *sh = shProg->_LinkedShaders[stage];
|
struct gl_linked_shader *sh = shProg->_LinkedShaders[stage];
|
||||||
@@ -3820,7 +3825,7 @@ add_packed_varyings(struct gl_shader_program *shProg, struct set *resource_set,
|
|||||||
if (type == iface) {
|
if (type == iface) {
|
||||||
const int stage_mask =
|
const int stage_mask =
|
||||||
build_stageref(shProg, var->name, var->data.mode);
|
build_stageref(shProg, var->name, var->data.mode);
|
||||||
if (!add_shader_variable(shProg, resource_set,
|
if (!add_shader_variable(ctx, shProg, resource_set,
|
||||||
stage_mask,
|
stage_mask,
|
||||||
iface, var, var->name, var->type, false,
|
iface, var, var->name, var->type, false,
|
||||||
var->data.location - VARYING_SLOT_VAR0))
|
var->data.location - VARYING_SLOT_VAR0))
|
||||||
@@ -3832,7 +3837,9 @@ add_packed_varyings(struct gl_shader_program *shProg, struct set *resource_set,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
add_fragdata_arrays(struct gl_shader_program *shProg, struct set *resource_set)
|
add_fragdata_arrays(const struct gl_context *ctx,
|
||||||
|
struct gl_shader_program *shProg,
|
||||||
|
struct set *resource_set)
|
||||||
{
|
{
|
||||||
struct gl_linked_shader *sh = shProg->_LinkedShaders[MESA_SHADER_FRAGMENT];
|
struct gl_linked_shader *sh = shProg->_LinkedShaders[MESA_SHADER_FRAGMENT];
|
||||||
|
|
||||||
@@ -3844,7 +3851,7 @@ add_fragdata_arrays(struct gl_shader_program *shProg, struct set *resource_set)
|
|||||||
if (var) {
|
if (var) {
|
||||||
assert(var->data.mode == ir_var_shader_out);
|
assert(var->data.mode == ir_var_shader_out);
|
||||||
|
|
||||||
if (!add_shader_variable(shProg, resource_set,
|
if (!add_shader_variable(ctx, shProg, resource_set,
|
||||||
1 << MESA_SHADER_FRAGMENT,
|
1 << MESA_SHADER_FRAGMENT,
|
||||||
GL_PROGRAM_OUTPUT, var, var->name, var->type,
|
GL_PROGRAM_OUTPUT, var, var->name, var->type,
|
||||||
true, var->data.location - FRAG_RESULT_DATA0))
|
true, var->data.location - FRAG_RESULT_DATA0))
|
||||||
@@ -4103,24 +4110,24 @@ build_program_resource_list(struct gl_context *ctx,
|
|||||||
|
|
||||||
/* Program interface needs to expose varyings in case of SSO. */
|
/* Program interface needs to expose varyings in case of SSO. */
|
||||||
if (shProg->SeparateShader) {
|
if (shProg->SeparateShader) {
|
||||||
if (!add_packed_varyings(shProg, resource_set,
|
if (!add_packed_varyings(ctx, shProg, resource_set,
|
||||||
input_stage, GL_PROGRAM_INPUT))
|
input_stage, GL_PROGRAM_INPUT))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!add_packed_varyings(shProg, resource_set,
|
if (!add_packed_varyings(ctx, shProg, resource_set,
|
||||||
output_stage, GL_PROGRAM_OUTPUT))
|
output_stage, GL_PROGRAM_OUTPUT))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!add_fragdata_arrays(shProg, resource_set))
|
if (!add_fragdata_arrays(ctx, shProg, resource_set))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Add inputs and outputs to the resource list. */
|
/* Add inputs and outputs to the resource list. */
|
||||||
if (!add_interface_variables(shProg, resource_set,
|
if (!add_interface_variables(ctx, shProg, resource_set,
|
||||||
input_stage, GL_PROGRAM_INPUT))
|
input_stage, GL_PROGRAM_INPUT))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!add_interface_variables(shProg, resource_set,
|
if (!add_interface_variables(ctx, shProg, resource_set,
|
||||||
output_stage, GL_PROGRAM_OUTPUT))
|
output_stage, GL_PROGRAM_OUTPUT))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user