gl_shader_stage stage,
const nir_shader_compiler_options *options)
{
- struct gl_shader *sh = shader_prog->_LinkedShaders[stage];
+ struct gl_linked_shader *sh = shader_prog->_LinkedShaders[stage];
nir_shader *shader = nir_shader_create(NULL, stage, options);
bool do_copy_propagation_elements(exec_list *instructions);
bool do_constant_propagation(exec_list *instructions);
void do_dead_builtin_varyings(struct gl_context *ctx,
- gl_shader *producer, gl_shader *consumer,
+ gl_linked_shader *producer,
+ gl_linked_shader *consumer,
unsigned num_tfeedback_decls,
class tfeedback_decl *tfeedback_decls);
bool do_dead_code(exec_list *instructions, bool uniform_locations_assigned);
bool lower_temp, bool lower_uniform);
bool lower_quadop_vector(exec_list *instructions, bool dont_lower_swz);
bool lower_const_arrays_to_uniforms(exec_list *instructions);
-bool lower_clip_cull_distance(struct gl_shader_program *prog, gl_shader *shader);
+bool lower_clip_cull_distance(struct gl_shader_program *prog,
+ gl_linked_shader *shader);
void lower_output_reads(unsigned stage, exec_list *instructions);
bool lower_packing_builtins(exec_list *instructions, int op_mask);
-void lower_shared_reference(struct gl_shader *shader, unsigned *shared_size);
-void lower_ubo_reference(struct gl_shader *shader, bool clamp_block_indices);
+void lower_shared_reference(struct gl_linked_shader *shader,
+ unsigned *shared_size);
+void lower_ubo_reference(struct gl_linked_shader *shader,
+ bool clamp_block_indices);
void lower_packed_varyings(void *mem_ctx,
unsigned locations_used, ir_variable_mode mode,
- unsigned gs_input_vertices, gl_shader *shader,
+ unsigned gs_input_vertices,
+ gl_linked_shader *shader,
bool disable_varying_packing, bool xfb_enabled);
bool lower_vector_insert(exec_list *instructions, bool lower_nonconstant_index);
-bool lower_vector_derefs(gl_shader *shader);
-void lower_named_interface_blocks(void *mem_ctx, gl_shader *shader);
+bool lower_vector_derefs(gl_linked_shader *shader);
+void lower_named_interface_blocks(void *mem_ctx, gl_linked_shader *shader);
bool optimize_redundant_jumps(exec_list *instructions);
bool optimize_split_arrays(exec_list *instructions, bool linked);
bool lower_offset_arrays(exec_list *instructions);
void optimize_dead_builtin_variables(exec_list *instructions,
enum ir_variable_mode other);
-bool lower_tess_level(gl_shader *shader);
+bool lower_tess_level(gl_linked_shader *shader);
-bool lower_vertex_id(gl_shader *shader);
+bool lower_vertex_id(gl_linked_shader *shader);
bool lower_subroutine(exec_list *instructions, struct _mesa_glsl_parse_state *state);
void propagate_invariance(exec_list *instructions);
*num_buffers = 0;
for (unsigned i = 0; i < MESA_SHADER_STAGES; ++i) {
- struct gl_shader *sh = prog->_LinkedShaders[i];
+ struct gl_linked_shader *sh = prog->_LinkedShaders[i];
if (sh == NULL)
continue;
class call_link_visitor : public ir_hierarchical_visitor {
public:
- call_link_visitor(gl_shader_program *prog, gl_shader *linked,
+ call_link_visitor(gl_shader_program *prog, gl_linked_shader *linked,
gl_shader **shader_list, unsigned num_shaders)
{
this->prog = prog;
* linked shader that are accessed by the function. It is also used to add
* global variables from the shader where the function originated.
*/
- gl_shader *linked;
+ gl_linked_shader *linked;
/**
* Table of variables local to the function.
bool
-link_function_calls(gl_shader_program *prog, gl_shader *main,
+link_function_calls(gl_shader_program *prog, gl_linked_shader *main,
gl_shader **shader_list, unsigned num_shaders)
{
call_link_visitor v(prog, main, shader_list, num_shaders);
void
validate_interstage_inout_blocks(struct gl_shader_program *prog,
- const gl_shader *producer,
- const gl_shader *consumer)
+ const gl_linked_shader *producer,
+ const gl_linked_shader *consumer)
{
interface_block_definitions definitions;
/* VS -> GS, VS -> TCS, VS -> TES, TES -> GS */
void
validate_interstage_uniform_blocks(struct gl_shader_program *prog,
- gl_shader **stages, int num_stages)
+ gl_linked_shader **stages)
{
interface_block_definitions definitions;
- for (int i = 0; i < num_stages; i++) {
+ for (int i = 0; i < MESA_SHADER_STAGES; i++) {
if (stages[i] == NULL)
continue;
- const gl_shader *stage = stages[i];
+ const gl_linked_shader *stage = stages[i];
foreach_in_list(ir_instruction, node, stage->ir) {
ir_variable *var = node->as_variable();
if (!var || !var->get_interface_type() ||
link_uniform_blocks(void *mem_ctx,
struct gl_context *ctx,
struct gl_shader_program *prog,
- struct gl_shader **shader_list,
+ struct gl_linked_shader **shader_list,
unsigned num_shaders,
struct gl_uniform_block **ubo_blocks,
unsigned *num_ubo_blocks,
}
for (int sh = 0; sh < MESA_SHADER_STAGES; sh++) {
- gl_shader *shader = prog->_LinkedShaders[sh];
+ gl_linked_shader *shader = prog->_LinkedShaders[sh];
if (shader) {
if (storage->type->base_type == GLSL_TYPE_SAMPLER &&
if (storage->type->is_sampler()) {
for (int sh = 0; sh < MESA_SHADER_STAGES; sh++) {
- gl_shader *shader = prog->_LinkedShaders[sh];
+ gl_linked_shader *shader = prog->_LinkedShaders[sh];
if (shader && storage->opaque[sh].active) {
unsigned index = storage->opaque[sh].index;
void *mem_ctx = NULL;
for (unsigned int i = 0; i < MESA_SHADER_STAGES; i++) {
- struct gl_shader *shader = prog->_LinkedShaders[i];
+ struct gl_linked_shader *shader = prog->_LinkedShaders[i];
if (shader == NULL)
continue;
* shaders).
*/
static void
-link_update_uniform_buffer_variables(struct gl_shader *shader)
+link_update_uniform_buffer_variables(struct gl_linked_shader *shader)
{
foreach_in_list(ir_instruction, node, shader->ir) {
ir_variable *const var = node->as_variable();
struct string_to_uint_map *hiddenUniforms = new string_to_uint_map;
count_uniform_size uniform_size(prog->UniformHash, hiddenUniforms);
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
- struct gl_shader *sh = prog->_LinkedShaders[i];
+ struct gl_linked_shader *sh = prog->_LinkedShaders[i];
if (sh == NULL)
continue;
continue;
for (unsigned j = 0; j < MESA_SHADER_STAGES; j++) {
- struct gl_shader *sh = prog->_LinkedShaders[j];
+ struct gl_linked_shader *sh = prog->_LinkedShaders[j];
if (!sh)
continue;
if (uniforms[i].remap_location != UNMAPPED_UNIFORM_LOC)
continue;
for (unsigned j = 0; j < MESA_SHADER_STAGES; j++) {
- struct gl_shader *sh = prog->_LinkedShaders[j];
+ struct gl_linked_shader *sh = prog->_LinkedShaders[j];
if (!sh)
continue;
}
bool
-process_xfb_layout_qualifiers(void *mem_ctx, const gl_shader *sh,
+process_xfb_layout_qualifiers(void *mem_ctx, const gl_linked_shader *sh,
unsigned *num_tfeedback_decls,
char ***varying_names)
{
*/
void
cross_validate_outputs_to_inputs(struct gl_shader_program *prog,
- gl_shader *producer, gl_shader *consumer)
+ gl_linked_shader *producer,
+ gl_linked_shader *consumer)
{
glsl_symbol_table parameters;
ir_variable *explicit_locations[MAX_VARYINGS_INCL_PATCH][4] =
*/
void
remove_unused_shader_inputs_and_outputs(bool is_separate_shader_object,
- gl_shader *sh,
+ gl_linked_shader *sh,
enum ir_variable_mode mode)
{
if (is_separate_shader_object)
* with a max of MAX_VARYING.
*/
uint64_t
-reserved_varying_slot(struct gl_shader *stage, ir_variable_mode io_mode)
+reserved_varying_slot(struct gl_linked_shader *stage,
+ ir_variable_mode io_mode)
{
assert(io_mode == ir_var_shader_in || io_mode == ir_var_shader_out);
/* Avoid an overflow of the returned value */
assign_varying_locations(struct gl_context *ctx,
void *mem_ctx,
struct gl_shader_program *prog,
- gl_shader *producer, gl_shader *consumer,
+ gl_linked_shader *producer,
+ gl_linked_shader *consumer,
unsigned num_tfeedback_decls,
tfeedback_decl *tfeedback_decls,
const uint64_t reserved_slots)
bool
check_against_output_limit(struct gl_context *ctx,
struct gl_shader_program *prog,
- gl_shader *producer,
+ gl_linked_shader *producer,
unsigned num_explicit_locations)
{
unsigned output_vectors = num_explicit_locations;
bool
check_against_input_limit(struct gl_context *ctx,
struct gl_shader_program *prog,
- gl_shader *consumer,
+ gl_linked_shader *consumer,
unsigned num_explicit_locations)
{
unsigned input_vectors = num_explicit_locations;
void
cross_validate_outputs_to_inputs(struct gl_shader_program *prog,
- gl_shader *producer, gl_shader *consumer);
+ gl_linked_shader *producer,
+ gl_linked_shader *consumer);
bool
parse_tfeedback_decls(struct gl_context *ctx, struct gl_shader_program *prog,
char **varying_names, tfeedback_decl *decls);
bool
-process_xfb_layout_qualifiers(void *mem_ctx, const gl_shader *sh,
+process_xfb_layout_qualifiers(void *mem_ctx, const gl_linked_shader *sh,
unsigned *num_tfeedback_decls,
char ***varying_names);
void
remove_unused_shader_inputs_and_outputs(bool is_separate_shader_object,
- gl_shader *sh,
+ gl_linked_shader *sh,
enum ir_variable_mode mode);
bool
assign_varying_locations(struct gl_context *ctx,
void *mem_ctx,
struct gl_shader_program *prog,
- gl_shader *producer, gl_shader *consumer,
+ gl_linked_shader *producer,
+ gl_linked_shader *consumer,
unsigned num_tfeedback_decls,
tfeedback_decl *tfeedback_decls,
const uint64_t reserved_slots);
uint64_t
-reserved_varying_slot(struct gl_shader *stage, ir_variable_mode io_mode);
+reserved_varying_slot(struct gl_linked_shader *stage,
+ ir_variable_mode io_mode);
bool
check_against_output_limit(struct gl_context *ctx,
struct gl_shader_program *prog,
- gl_shader *producer,
+ gl_linked_shader *producer,
unsigned num_explicit_locations);
bool
check_against_input_limit(struct gl_context *ctx,
struct gl_shader_program *prog,
- gl_shader *consumer,
+ gl_linked_shader *consumer,
unsigned num_explicit_locations);
#endif /* GLSL_LINK_VARYINGS_H */
*/
static void
analyze_clip_cull_usage(struct gl_shader_program *prog,
- struct gl_shader *shader,
+ struct gl_linked_shader *shader,
struct gl_context *ctx,
GLuint *clip_distance_array_size,
GLuint *cull_distance_array_size)
*/
void
validate_vertex_shader_executable(struct gl_shader_program *prog,
- struct gl_shader *shader,
+ struct gl_linked_shader *shader,
struct gl_context *ctx)
{
if (shader == NULL)
void
validate_tess_eval_shader_executable(struct gl_shader_program *prog,
- struct gl_shader *shader,
+ struct gl_linked_shader *shader,
struct gl_context *ctx)
{
if (shader == NULL)
*/
void
validate_fragment_shader_executable(struct gl_shader_program *prog,
- struct gl_shader *shader)
+ struct gl_linked_shader *shader)
{
if (shader == NULL)
return;
*/
void
validate_geometry_shader_executable(struct gl_shader_program *prog,
- struct gl_shader *shader,
+ struct gl_linked_shader *shader,
struct gl_context *ctx)
{
if (shader == NULL)
validate_geometry_shader_emissions(struct gl_context *ctx,
struct gl_shader_program *prog)
{
- struct gl_shader *sh = prog->_LinkedShaders[MESA_SHADER_GEOMETRY];
+ struct gl_linked_shader *sh = prog->_LinkedShaders[MESA_SHADER_GEOMETRY];
if (sh != NULL) {
find_emit_vertex_visitor emit_vertex(ctx->Const.MaxVertexStreams - 1);
}
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
- struct gl_shader *sh = prog->_LinkedShaders[i];
+ struct gl_linked_shader *sh = prog->_LinkedShaders[i];
InterfaceBlockStageIndex[i] = new int[max_num_buffer_blocks];
for (unsigned int j = 0; j < max_num_buffer_blocks; j++)
int stage_index = InterfaceBlockStageIndex[i][j];
if (stage_index != -1) {
- struct gl_shader *sh = prog->_LinkedShaders[i];
+ struct gl_linked_shader *sh = prog->_LinkedShaders[i];
blks[j].stageref |= (1 << i);
* Populates a shaders symbol table with all global declarations
*/
static void
-populate_symbol_table(gl_shader *sh)
+populate_symbol_table(gl_linked_shader *sh)
{
sh->symbols = new(sh) glsl_symbol_table;
* should be added.
*/
void
-remap_variables(ir_instruction *inst, struct gl_shader *target,
+remap_variables(ir_instruction *inst, struct gl_linked_shader *target,
hash_table *temps)
{
class remap_visitor : public ir_hierarchical_visitor {
public:
- remap_visitor(struct gl_shader *target,
+ remap_visitor(struct gl_linked_shader *target,
hash_table *temps)
{
this->target = target;
}
private:
- struct gl_shader *target;
+ struct gl_linked_shader *target;
glsl_symbol_table *symbols;
exec_list *instructions;
hash_table *temps;
*/
exec_node *
move_non_declarations(exec_list *instructions, exec_node *last,
- bool make_copies, gl_shader *target)
+ bool make_copies, gl_linked_shader *target)
{
hash_table *temps = NULL;
static void
link_xfb_stride_layout_qualifiers(struct gl_context *ctx,
struct gl_shader_program *prog,
- struct gl_shader *linked_shader,
+ struct gl_linked_shader *linked_shader,
struct gl_shader **shader_list,
unsigned num_shaders)
{
*/
static void
link_tcs_out_layout_qualifiers(struct gl_shader_program *prog,
- struct gl_shader *linked_shader,
+ struct gl_linked_shader *linked_shader,
struct gl_shader **shader_list,
unsigned num_shaders)
{
*/
static void
link_tes_in_layout_qualifiers(struct gl_shader_program *prog,
- struct gl_shader *linked_shader,
+ struct gl_linked_shader *linked_shader,
struct gl_shader **shader_list,
unsigned num_shaders)
{
*/
static void
link_fs_input_layout_qualifiers(struct gl_shader_program *prog,
- struct gl_shader *linked_shader,
+ struct gl_linked_shader *linked_shader,
struct gl_shader **shader_list,
unsigned num_shaders)
{
*/
static void
link_gs_inout_layout_qualifiers(struct gl_shader_program *prog,
- struct gl_shader *linked_shader,
+ struct gl_linked_shader *linked_shader,
struct gl_shader **shader_list,
unsigned num_shaders)
{
*/
static void
link_cs_input_layout_qualifiers(struct gl_shader_program *prog,
- struct gl_shader *linked_shader,
+ struct gl_linked_shader *linked_shader,
struct gl_shader **shader_list,
unsigned num_shaders)
{
* If this function is supplied a single shader, it is cloned, and the new
* shader is returned.
*/
-static struct gl_shader *
+static struct gl_linked_shader *
link_intrastage_shaders(void *mem_ctx,
struct gl_context *ctx,
struct gl_shader_program *prog,
*/
gl_shader *main = NULL;
for (unsigned i = 0; i < num_shaders; i++) {
- if (!_mesa_get_main_function_signature(shader_list[i]->symbols)) {
+ if (_mesa_get_main_function_signature(shader_list[i]->symbols)) {
main = shader_list[i];
break;
}
return NULL;
}
- gl_shader *linked = ctx->Driver.NewShader(NULL, 0, shader_list[0]->Stage);
+ gl_linked_shader *linked = ctx->Driver.NewShader(shader_list[0]->Stage);
linked->ir = new(linked) exec_list;
clone_ir_list(mem_ctx, linked->ir, main->ir);
if (!ok) {
- _mesa_delete_shader(ctx, linked);
+ _mesa_delete_linked_shader(ctx, linked);
return NULL;
}
&num_ssbo_blocks);
if (!prog->LinkStatus) {
- _mesa_delete_shader(ctx, linked);
+ _mesa_delete_linked_shader(ctx, linked);
return NULL;
}
if (prog->_LinkedShaders[MESA_SHADER_TESS_EVAL] == NULL)
return;
- gl_shader *const tcs = prog->_LinkedShaders[MESA_SHADER_TESS_CTRL];
- gl_shader *const tes = prog->_LinkedShaders[MESA_SHADER_TESS_EVAL];
+ gl_linked_shader *const tcs = prog->_LinkedShaders[MESA_SHADER_TESS_CTRL];
+ gl_linked_shader *const tes = prog->_LinkedShaders[MESA_SHADER_TESS_EVAL];
/* If no control shader is present, then the TES inputs are statically
* sized to MaxPatchVertices; the actual size of the arrays won't be
assert((target_index == MESA_SHADER_VERTEX)
|| (target_index == MESA_SHADER_FRAGMENT));
- gl_shader *const sh = prog->_LinkedShaders[target_index];
+ gl_linked_shader *const sh = prog->_LinkedShaders[target_index];
if (sh == NULL)
return true;
* unmatch flag if found so we don't optimise them away.
*/
static void
-match_explicit_outputs_to_inputs(gl_shader *producer,
- gl_shader *consumer)
+match_explicit_outputs_to_inputs(gl_linked_shader *producer,
+ gl_linked_shader *consumer)
{
glsl_symbol_table parameters;
ir_variable *explicit_locations[MAX_VARYINGS_INCL_PATCH][4] =
unsigned total_shader_storage_blocks = 0;
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
- struct gl_shader *sh = prog->_LinkedShaders[i];
+ struct gl_linked_shader *sh = prog->_LinkedShaders[i];
if (sh == NULL)
continue;
link_calculate_subroutine_compat(struct gl_shader_program *prog)
{
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
- struct gl_shader *sh = prog->_LinkedShaders[i];
+ struct gl_linked_shader *sh = prog->_LinkedShaders[i];
int count;
if (!sh)
continue;
check_subroutine_resources(struct gl_shader_program *prog)
{
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
- struct gl_shader *sh = prog->_LinkedShaders[i];
+ struct gl_linked_shader *sh = prog->_LinkedShaders[i];
if (sh) {
if (sh->NumSubroutineUniformRemapTable > MAX_SUBROUTINE_UNIFORM_LOCATIONS)
return;
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
- struct gl_shader *sh = prog->_LinkedShaders[i];
+ struct gl_linked_shader *sh = prog->_LinkedShaders[i];
if (sh) {
if (sh->NumImages > ctx->Const.Program[i].MaxImageUniforms)
static bool
reserve_subroutine_explicit_locations(struct gl_shader_program *prog,
- struct gl_shader *sh,
+ struct gl_linked_shader *sh,
ir_variable *var)
{
unsigned slots = var->type->uniform_locations();
unsigned entries_total = 0;
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
- struct gl_shader *sh = prog->_LinkedShaders[i];
+ struct gl_linked_shader *sh = prog->_LinkedShaders[i];
if (!sh)
continue;
assert(MESA_SHADER_STAGES < 8);
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
- struct gl_shader *sh = shProg->_LinkedShaders[i];
+ struct gl_linked_shader *sh = shProg->_LinkedShaders[i];
if (!sh)
continue;
static bool
add_packed_varyings(struct gl_shader_program *shProg, int stage, GLenum type)
{
- struct gl_shader *sh = shProg->_LinkedShaders[stage];
+ struct gl_linked_shader *sh = shProg->_LinkedShaders[stage];
GLenum iface;
if (!sh || !sh->packed_varyings)
static bool
add_fragdata_arrays(struct gl_shader_program *shProg)
{
- struct gl_shader *sh = shProg->_LinkedShaders[MESA_SHADER_FRAGMENT];
+ struct gl_linked_shader *sh = shProg->_LinkedShaders[MESA_SHADER_FRAGMENT];
if (!sh || !sh->fragdata_arrays)
return true;
}
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
- struct gl_shader *sh = shProg->_LinkedShaders[i];
+ struct gl_linked_shader *sh = shProg->_LinkedShaders[i];
GLuint type;
if (!sh)
link_assign_subroutine_types(struct gl_shader_program *prog)
{
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
- gl_shader *sh = prog->_LinkedShaders[i];
+ gl_linked_shader *sh = prog->_LinkedShaders[i];
if (sh == NULL)
continue;
return;
for (unsigned stage = 0; stage < MESA_SHADER_STAGES; stage++) {
- gl_shader *sh = prog->_LinkedShaders[stage];
+ gl_linked_shader *sh = prog->_LinkedShaders[stage];
if (!sh)
continue;
}
for (unsigned int i = 0; i < MESA_SHADER_STAGES; i++) {
- if (prog->_LinkedShaders[i] != NULL)
- _mesa_delete_shader(ctx, prog->_LinkedShaders[i]);
+ if (prog->_LinkedShaders[i] != NULL) {
+ _mesa_delete_linked_shader(ctx, prog->_LinkedShaders[i]);
+ }
prog->_LinkedShaders[i] = NULL;
}
*/
for (int stage = 0; stage < MESA_SHADER_STAGES; stage++) {
if (num_shaders[stage] > 0) {
- gl_shader *const sh =
+ gl_linked_shader *const sh =
link_intrastage_shaders(mem_ctx, ctx, prog, shader_list[stage],
num_shaders[stage]);
if (!prog->LinkStatus) {
if (sh)
- _mesa_delete_shader(ctx, sh);
+ _mesa_delete_linked_shader(ctx, sh);
goto done;
}
}
if (!prog->LinkStatus) {
if (sh)
- _mesa_delete_shader(ctx, sh);
+ _mesa_delete_linked_shader(ctx, sh);
goto done;
}
- _mesa_reference_shader(ctx, &prog->_LinkedShaders[stage], sh);
+ prog->_LinkedShaders[stage] = sh;
}
}
}
/* Cross-validate uniform blocks between shader stages */
- validate_interstage_uniform_blocks(prog, prog->_LinkedShaders,
- MESA_SHADER_STAGES);
+ validate_interstage_uniform_blocks(prog, prog->_LinkedShaders);
if (!prog->LinkStatus)
goto done;
* This rule also applies to GLSL ES 3.00.
*/
if (max_version >= (prog->IsES ? 300 : 130)) {
- struct gl_shader *sh = prog->_LinkedShaders[MESA_SHADER_FRAGMENT];
+ struct gl_linked_shader *sh = prog->_LinkedShaders[MESA_SHADER_FRAGMENT];
if (sh) {
lower_discard_flow(sh->ir);
}
/* If the program is made up of only a single stage */
if (first == last) {
- gl_shader *const sh = prog->_LinkedShaders[last];
+ gl_linked_shader *const sh = prog->_LinkedShaders[last];
if (prog->SeparateShader) {
const uint64_t reserved_slots =
reserved_varying_slot(sh, ir_var_shader_in);
if (prog->_LinkedShaders[i] == NULL && i != 0)
continue;
- gl_shader *const sh_i = prog->_LinkedShaders[i];
- gl_shader *const sh_next = prog->_LinkedShaders[next];
+ gl_linked_shader *const sh_i = prog->_LinkedShaders[i];
+ gl_linked_shader *const sh_next = prog->_LinkedShaders[next];
const uint64_t reserved_out_slots =
reserved_varying_slot(sh_i, ir_var_shader_out);
#define GLSL_LINKER_H
extern bool
-link_function_calls(gl_shader_program *prog, gl_shader *main,
+link_function_calls(gl_shader_program *prog, gl_linked_shader *main,
gl_shader **shader_list, unsigned num_shaders);
extern void
link_uniform_blocks(void *mem_ctx,
struct gl_context *ctx,
struct gl_shader_program *prog,
- struct gl_shader **shader_list,
+ struct gl_linked_shader **shader_list,
unsigned num_shaders,
struct gl_uniform_block **ubo_blocks,
unsigned *num_ubo_blocks,
void
validate_interstage_inout_blocks(struct gl_shader_program *prog,
- const gl_shader *producer,
- const gl_shader *consumer);
+ const gl_linked_shader *producer,
+ const gl_linked_shader *consumer);
void
validate_interstage_uniform_blocks(struct gl_shader_program *prog,
- gl_shader **stages, int num_stages);
+ gl_linked_shader **stages);
extern void
link_assign_atomic_counter_resources(struct gl_context *ctx,
}
bool
-lower_clip_cull_distance(struct gl_shader_program *prog, gl_shader *shader)
+lower_clip_cull_distance(struct gl_shader_program *prog,
+ struct gl_linked_shader *shader)
{
int clip_size, cull_size;
}
void
-lower_named_interface_blocks(void *mem_ctx, gl_shader *shader)
+lower_named_interface_blocks(void *mem_ctx, gl_linked_shader *shader)
{
flatten_named_interface_blocks_declarations v_decl(mem_ctx);
v_decl.run(shader->ir);
bool disable_varying_packing,
bool xfb_enabled);
- void run(struct gl_shader *shader);
+ void run(struct gl_linked_shader *shader);
private:
void bitwise_assign_pack(ir_rvalue *lhs, ir_rvalue *rhs);
}
void
-lower_packed_varyings_visitor::run(struct gl_shader *shader)
+lower_packed_varyings_visitor::run(struct gl_linked_shader *shader)
{
foreach_in_list(ir_instruction, node, shader->ir) {
ir_variable *var = node->as_variable();
void
lower_packed_varyings(void *mem_ctx, unsigned locations_used,
ir_variable_mode mode, unsigned gs_input_vertices,
- gl_shader *shader, bool disable_varying_packing,
+ gl_linked_shader *shader, bool disable_varying_packing,
bool xfb_enabled)
{
exec_list *instructions = shader->ir;
public lower_buffer_access::lower_buffer_access {
public:
- lower_shared_reference_visitor(struct gl_shader *shader)
+ lower_shared_reference_visitor(struct gl_linked_shader *shader)
: list_ctx(ralloc_context(NULL)), shader(shader), shared_size(0u)
{
list_inithead(&var_offsets);
unsigned write_mask);
void *list_ctx;
- struct gl_shader *shader;
+ struct gl_linked_shader *shader;
struct list_head var_offsets;
unsigned shared_size;
bool progress;
} /* unnamed namespace */
void
-lower_shared_reference(struct gl_shader *shader, unsigned *shared_size)
+lower_shared_reference(struct gl_linked_shader *shader, unsigned *shared_size)
{
if (shader->Stage != MESA_SHADER_COMPUTE)
return;
bool
-lower_tess_level(gl_shader *shader)
+lower_tess_level(gl_linked_shader *shader)
{
if ((shader->Stage != MESA_SHADER_TESS_CTRL) &&
(shader->Stage != MESA_SHADER_TESS_EVAL))
class lower_ubo_reference_visitor :
public lower_buffer_access::lower_buffer_access {
public:
- lower_ubo_reference_visitor(struct gl_shader *shader,
+ lower_ubo_reference_visitor(struct gl_linked_shader *shader,
bool clamp_block_indices)
: shader(shader), clamp_block_indices(clamp_block_indices),
struct_field(NULL), variable(NULL)
ir_call *check_for_ssbo_atomic_intrinsic(ir_call *ir);
ir_visitor_status visit_enter(ir_call *ir);
- struct gl_shader *shader;
+ struct gl_linked_shader *shader;
bool clamp_block_indices;
struct gl_uniform_buffer_variable *ubo_var;
const struct glsl_struct_field *struct_field;
} /* unnamed namespace */
void
-lower_ubo_reference(struct gl_shader *shader, bool clamp_block_indices)
+lower_ubo_reference(struct gl_linked_shader *shader, bool clamp_block_indices)
{
lower_ubo_reference_visitor v(shader, clamp_block_indices);
}
bool
-lower_vector_derefs(gl_shader *shader)
+lower_vector_derefs(gl_linked_shader *shader)
{
vector_deref_visitor v;
}
bool
-lower_vertex_id(gl_shader *shader)
+lower_vertex_id(gl_linked_shader *shader)
{
/* gl_VertexID only exists in the vertex shader.
*/
*/
class replace_varyings_visitor : public ir_rvalue_visitor {
public:
- replace_varyings_visitor(struct gl_shader *sha,
+ replace_varyings_visitor(struct gl_linked_shader *sha,
const varying_info_visitor *info,
unsigned external_texcoord_usage,
unsigned external_color_usage,
}
private:
- struct gl_shader *shader;
+ struct gl_linked_shader *shader;
const varying_info_visitor *info;
ir_variable *new_fragdata[MAX_DRAW_BUFFERS];
ir_variable *new_texcoord[MAX_TEXTURE_COORD_UNITS];
} /* anonymous namespace */
static void
-lower_texcoord_array(struct gl_shader *shader, const varying_info_visitor *info)
+lower_texcoord_array(struct gl_linked_shader *shader, const varying_info_visitor *info)
{
replace_varyings_visitor(shader, info,
(1 << MAX_TEXTURE_COORD_UNITS) - 1,
}
static void
-lower_fragdata_array(struct gl_shader *shader)
+lower_fragdata_array(struct gl_linked_shader *shader)
{
varying_info_visitor info(ir_var_shader_out, true);
info.get(shader->ir, 0, NULL);
void
do_dead_builtin_varyings(struct gl_context *ctx,
- gl_shader *producer, gl_shader *consumer,
+ gl_linked_shader *producer,
+ gl_linked_shader *consumer,
unsigned num_tfeedback_decls,
tfeedback_decl *tfeedback_decls)
{
ctx->Const.GenerateTemporaryNames = true;
ctx->Const.MaxPatchVertices = 32;
- ctx->Driver.NewShader = _mesa_new_shader;
+ ctx->Driver.NewShader = _mesa_new_linked_shader;
}
/* Returned string will have 'ctx' as its ralloc owner. */
}
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
- struct gl_shader *shader = whole_program->_LinkedShaders[i];
+ struct gl_linked_shader *shader = whole_program->_LinkedShaders[i];
if (!shader)
continue;
return shader;
}
+struct gl_linked_shader *
+_mesa_new_linked_shader(gl_shader_stage stage)
+{
+ struct gl_linked_shader *shader;
+
+ assert(stage == MESA_SHADER_FRAGMENT || stage == MESA_SHADER_VERTEX);
+ shader = rzalloc(NULL, struct gl_linked_shader);
+ if (shader) {
+ shader->Stage = stage;
+ }
+ return shader;
+}
+
void
_mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh)
{
ralloc_free(sh);
}
+void
+_mesa_delete_linked_shader(struct gl_context *ctx,
+ struct gl_linked_shader *sh)
+{
+ ralloc_free(sh);
+}
+
void
_mesa_clear_shader_program_data(struct gl_shader_program *shProg)
{
extern "C" struct gl_shader *
_mesa_new_shader(struct gl_context *ctx, GLuint name, gl_shader_stage stage);
+extern "C" struct gl_linked_shader *
+_mesa_new_linked_shader(gl_shader_stage stage);
+
extern "C" void
_mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh);
+extern "C" void
+_mesa_delete_linked_shader(struct gl_context *ctx,
+ struct gl_linked_shader *sh);
+
extern "C" void
_mesa_clear_shader_program_data(struct gl_shader_program *);
struct gl_context *ctx = &local_ctx;
initialize_context_to_defaults(ctx, API_OPENGL_COMPAT);
- ctx->Driver.NewShader = _mesa_new_shader;
+ ctx->Driver.NewShader = _mesa_new_linked_shader;
ir_variable::temporaries_allocate_names = true;
struct gl_shader *shader = rzalloc(NULL, struct gl_shader);
const GLuint name = ~0;
struct gl_shader *sh;
- sh = ctx->Driver.NewShader(ctx, name, stage);
+ sh = _mesa_new_shader(ctx, name, stage);
sh->Source = strdup(source);
sh->CompileStatus = false;
_mesa_compile_shader(ctx, sh);
/* Resolve color for each active shader image. */
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
- const struct gl_shader *shader = ctx->_Shader->CurrentProgram[i] ?
- ctx->_Shader->CurrentProgram[i]->_LinkedShaders[i] : NULL;
+ const struct gl_linked_shader *shader =
+ ctx->_Shader->CurrentProgram[i] ?
+ ctx->_Shader->CurrentProgram[i]->_LinkedShaders[i] : NULL;
if (unlikely(shader && shader->NumImages)) {
for (unsigned j = 0; j < shader->NumImages; j++) {
struct brw_shader {
- struct gl_shader base;
+ struct gl_linked_shader base;
bool compiled_once;
};
uint32_t *out_offset, unsigned num_vector_components,
unsigned stride_dwords, unsigned offset_dwords);
void brw_upload_ubo_surfaces(struct brw_context *brw,
- struct gl_shader *shader,
+ struct gl_linked_shader *shader,
struct brw_stage_state *stage_state,
struct brw_stage_prog_data *prog_data);
void brw_upload_abo_surfaces(struct brw_context *brw,
- struct gl_shader *shader,
+ struct gl_linked_shader *shader,
struct brw_stage_state *stage_state,
struct brw_stage_prog_data *prog_data);
void brw_upload_image_surfaces(struct brw_context *brw,
- struct gl_shader *shader,
+ struct gl_linked_shader *shader,
struct brw_stage_state *stage_state,
struct brw_stage_prog_data *prog_data);
struct brw_gs_prog_key *key)
{
struct brw_compiler *compiler = brw->intelScreen->compiler;
- struct gl_shader *shader = prog->_LinkedShaders[MESA_SHADER_GEOMETRY];
struct brw_stage_state *stage_state = &brw->gs.base;
struct brw_gs_prog_data prog_data;
bool start_busy = false;
* padding around uniform values below vec4 size, so the worst case is that
* every uniform is a float which gets padded to the size of a vec4.
*/
- struct gl_shader *gs = prog->_LinkedShaders[MESA_SHADER_GEOMETRY];
+ struct gl_linked_shader *gs = prog->_LinkedShaders[MESA_SHADER_GEOMETRY];
struct brw_shader *bgs = (struct brw_shader *) gs;
int param_count = gp->program.Base.nir->num_uniforms / 4;
char *error_str;
const unsigned *program =
brw_compile_gs(brw->intelScreen->compiler, brw, mem_ctx, key,
- &prog_data, shader->Program->nir, prog,
+ &prog_data, gs->Program->nir, prog,
st_index, &program_size, &error_str);
if (program == NULL) {
ralloc_free(mem_ctx);
brw_shader_precompile(struct gl_context *ctx,
struct gl_shader_program *sh_prog)
{
- struct gl_shader *vs = sh_prog->_LinkedShaders[MESA_SHADER_VERTEX];
- struct gl_shader *tcs = sh_prog->_LinkedShaders[MESA_SHADER_TESS_CTRL];
- struct gl_shader *tes = sh_prog->_LinkedShaders[MESA_SHADER_TESS_EVAL];
- struct gl_shader *gs = sh_prog->_LinkedShaders[MESA_SHADER_GEOMETRY];
- struct gl_shader *fs = sh_prog->_LinkedShaders[MESA_SHADER_FRAGMENT];
- struct gl_shader *cs = sh_prog->_LinkedShaders[MESA_SHADER_COMPUTE];
+ struct gl_linked_shader *vs = sh_prog->_LinkedShaders[MESA_SHADER_VERTEX];
+ struct gl_linked_shader *tcs = sh_prog->_LinkedShaders[MESA_SHADER_TESS_CTRL];
+ struct gl_linked_shader *tes = sh_prog->_LinkedShaders[MESA_SHADER_TESS_EVAL];
+ struct gl_linked_shader *gs = sh_prog->_LinkedShaders[MESA_SHADER_GEOMETRY];
+ struct gl_linked_shader *fs = sh_prog->_LinkedShaders[MESA_SHADER_FRAGMENT];
+ struct gl_linked_shader *cs = sh_prog->_LinkedShaders[MESA_SHADER_COMPUTE];
if (fs && !brw_fs_precompile(ctx, sh_prog, fs->Program))
return false;
process_glsl_ir(gl_shader_stage stage,
struct brw_context *brw,
struct gl_shader_program *shader_prog,
- struct gl_shader *shader)
+ struct gl_linked_shader *shader)
{
struct gl_context *ctx = &brw->ctx;
const struct brw_compiler *compiler = brw->intelScreen->compiler;
}
}
-extern "C" struct gl_shader *
-brw_new_shader(struct gl_context *ctx, GLuint name, gl_shader_stage stage)
+extern "C" struct gl_linked_shader *
+brw_new_shader(gl_shader_stage stage)
{
struct brw_shader *shader;
shader = rzalloc(NULL, struct brw_shader);
if (shader) {
shader->base.Stage = stage;
- shader->base.Name = name;
- _mesa_init_shader(ctx, &shader->base);
}
return &shader->base;
unsigned int stage;
for (stage = 0; stage < ARRAY_SIZE(shProg->_LinkedShaders); stage++) {
- struct gl_shader *shader = shProg->_LinkedShaders[stage];
+ struct gl_linked_shader *shader = shProg->_LinkedShaders[stage];
if (!shader)
continue;
struct gl_program *prog =
ctx->Driver.NewProgram(ctx, _mesa_shader_stage_to_program(stage),
- shader->Name);
+ 0);
if (!prog)
return false;
prog->Parameters = _mesa_new_parameter_list();
void
brw_dump_ir(const char *stage, struct gl_shader_program *shader_prog,
- struct gl_shader *shader, struct gl_program *prog)
+ struct gl_linked_shader *shader, struct gl_program *prog)
{
if (shader_prog) {
if (shader->ir) {
void
brw_dump_ir(const char *stage, struct gl_shader_program *shader_prog,
- struct gl_shader *shader, struct gl_program *prog);
+ struct gl_linked_shader *shader, struct gl_program *prog);
void brw_upload_tcs_prog(struct brw_context *brw,
uint64_t per_vertex_slots, uint32_t per_patch_slots);
struct brw_stage_prog_data *stage_prog_data,
uint32_t next_binding_table_offset)
{
- const struct gl_shader *shader = NULL;
+ const struct gl_linked_shader *shader = NULL;
int num_textures = _mesa_fls(prog->SamplersUsed);
if (shader_prog)
char **error_str)
{
const struct brw_device_info *devinfo = compiler->devinfo;
- struct gl_shader *shader =
+ struct gl_linked_shader *shader =
shader_prog->_LinkedShaders[MESA_SHADER_TESS_EVAL];
const bool is_scalar = compiler->scalar_stage[MESA_SHADER_TESS_EVAL];
struct gl_program *prog);
GLboolean brw_link_shader(struct gl_context *ctx, struct gl_shader_program *prog);
-struct gl_shader *brw_new_shader(struct gl_context *ctx, GLuint name,
- gl_shader_stage stage);
+struct gl_linked_shader *brw_new_shader(gl_shader_stage stage);
int type_size_scalar(const struct glsl_type *type);
int type_size_vec4(const struct glsl_type *type);
* padding around uniform values below vec4 size, so the worst case is that
* every uniform is a float which gets padded to the size of a vec4.
*/
- struct gl_shader *tcs = shader_prog ?
+ struct gl_linked_shader *tcs = shader_prog ?
shader_prog->_LinkedShaders[MESA_SHADER_TESS_CTRL] : NULL;
int param_count = nir->num_uniforms / 4;
* padding around uniform values below vec4 size, so the worst case is that
* every uniform is a float which gets padded to the size of a vec4.
*/
- struct gl_shader *tes = shader_prog->_LinkedShaders[MESA_SHADER_TESS_EVAL];
+ struct gl_linked_shader *tes =
+ shader_prog->_LinkedShaders[MESA_SHADER_TESS_EVAL];
int param_count = nir->num_uniforms / 4;
prog_data.base.base.param =
void
brw_upload_ubo_surfaces(struct brw_context *brw,
- struct gl_shader *shader,
+ struct gl_linked_shader *shader,
struct brw_stage_state *stage_state,
struct brw_stage_prog_data *prog_data)
{
void
brw_upload_abo_surfaces(struct brw_context *brw,
- struct gl_shader *shader,
+ struct gl_linked_shader *shader,
struct brw_stage_state *stage_state,
struct brw_stage_prog_data *prog_data)
{
void
brw_upload_image_surfaces(struct brw_context *brw,
- struct gl_shader *shader,
+ struct gl_linked_shader *shader,
struct brw_stage_state *stage_state,
struct brw_stage_prog_data *prog_data)
{
GLenum mode_before_gs = mode;
if (tes) {
- struct gl_shader *tes_sh = tes->_LinkedShaders[MESA_SHADER_TESS_EVAL];
+ struct gl_linked_shader *tes_sh =
+ tes->_LinkedShaders[MESA_SHADER_TESS_EVAL];
if (tes_sh->TessEval.PointMode)
mode_before_gs = GL_POINTS;
else if (tes_sh->TessEval.PrimitiveMode == GL_ISOLINES)
else if (ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL]) {
struct gl_shader_program *tes =
ctx->_Shader->CurrentProgram[MESA_SHADER_TESS_EVAL];
- struct gl_shader *tes_sh = tes->_LinkedShaders[MESA_SHADER_TESS_EVAL];
+ struct gl_linked_shader *tes_sh =
+ tes->_LinkedShaders[MESA_SHADER_TESS_EVAL];
if (tes_sh->TessEval.PointMode)
pass = ctx->TransformFeedback.Mode == GL_POINTS;
else if (tes_sh->TessEval.PrimitiveMode == GL_ISOLINES)
* \name GLSL-related functions (ARB extensions and OpenGL 2.x)
*/
/*@{*/
- struct gl_shader *(*NewShader)(struct gl_context *ctx,
- GLuint name, gl_shader_stage stage);
+ struct gl_linked_shader *(*NewShader)(gl_shader_stage stage);
void (*UseProgram)(struct gl_context *ctx, struct gl_shader_program *shProg);
/*@}*/
_mesa_glsl_parse_state *state;
p.mem_ctx = ralloc_context(NULL);
- p.shader = ctx->Driver.NewShader(ctx, 0, MESA_SHADER_FRAGMENT);
+ p.shader = _mesa_new_shader(ctx, 0, MESA_SHADER_FRAGMENT);
p.shader->ir = new(p.shader) exec_list;
state = new(p.shader) _mesa_glsl_parse_state(ctx, MESA_SHADER_FRAGMENT,
p.shader);
};
/**
- * A GLSL vertex or fragment shader object.
+ * A linked GLSL shader object.
*/
-struct gl_shader
+struct gl_linked_shader
{
- /** GL_FRAGMENT_SHADER || GL_VERTEX_SHADER || GL_GEOMETRY_SHADER_ARB ||
- * GL_TESS_CONTROL_SHADER || GL_TESS_EVALUATION_SHADER.
- * Must be the first field.
- */
- GLenum Type;
gl_shader_stage Stage;
- GLuint Name; /**< AKA the handle */
- GLint RefCount; /**< Reference count */
- GLchar *Label; /**< GL_KHR_debug */
- GLboolean DeletePending;
- GLboolean CompileStatus;
- bool IsES; /**< True if this shader uses GLSL ES */
-
- GLuint SourceChecksum; /**< for debug/logging purposes */
- const GLchar *Source; /**< Source code string */
struct gl_program *Program; /**< Post-compile assembly code */
- GLchar *InfoLog;
-
- unsigned Version; /**< GLSL version used for linking */
/**
* \name Sampler tracking
struct gl_subroutine_function *SubroutineFunctions;
};
+/**
+ * A GLSL shader object.
+ */
+struct gl_shader
+{
+ /** GL_FRAGMENT_SHADER || GL_VERTEX_SHADER || GL_GEOMETRY_SHADER_ARB ||
+ * GL_TESS_CONTROL_SHADER || GL_TESS_EVALUATION_SHADER.
+ * Must be the first field.
+ */
+ GLenum Type;
+ gl_shader_stage Stage;
+ GLuint Name; /**< AKA the handle */
+ GLint RefCount; /**< Reference count */
+ GLchar *Label; /**< GL_KHR_debug */
+ GLboolean DeletePending;
+ GLboolean CompileStatus;
+ bool IsES; /**< True if this shader uses GLSL ES */
+
+ GLuint SourceChecksum; /**< for debug/logging purposes */
+ const GLchar *Source; /**< Source code string */
+
+ GLchar *InfoLog;
+
+ unsigned Version; /**< GLSL version used for linking */
+
+ struct exec_list *ir;
+ struct glsl_symbol_table *symbols;
+
+ bool uses_builtin_functions;
+ bool uses_gl_fragcoord;
+ bool redeclares_gl_fragcoord;
+ bool ARB_fragment_coord_conventions_enable;
+
+ /**
+ * Fragment shader state from GLSL 1.50 layout qualifiers.
+ */
+ bool origin_upper_left;
+ bool pixel_center_integer;
+
+ struct {
+ /** Global xfb_stride out qualifier if any */
+ GLuint BufferStride[MAX_FEEDBACK_BUFFERS];
+ } TransformFeedback;
+
+ /**
+ * Tessellation Control shader state from layout qualifiers.
+ */
+ struct {
+ /**
+ * 0 - vertices not declared in shader, or
+ * 1 .. GL_MAX_PATCH_VERTICES
+ */
+ GLint VerticesOut;
+ } TessCtrl;
+
+ /**
+ * Tessellation Evaluation shader state from layout qualifiers.
+ */
+ struct {
+ /**
+ * GL_TRIANGLES, GL_QUADS, GL_ISOLINES or PRIM_UNKNOWN if it's not set
+ * in this shader.
+ */
+ GLenum PrimitiveMode;
+ /**
+ * GL_EQUAL, GL_FRACTIONAL_ODD, GL_FRACTIONAL_EVEN, or 0 if it's not set
+ * in this shader.
+ */
+ GLenum Spacing;
+ /**
+ * GL_CW, GL_CCW, or 0 if it's not set in this shader.
+ */
+ GLenum VertexOrder;
+ /**
+ * 1, 0, or -1 if it's not set in this shader.
+ */
+ int PointMode;
+ } TessEval;
+
+ /**
+ * Geometry shader state from GLSL 1.50 layout qualifiers.
+ */
+ struct {
+ GLint VerticesOut;
+ /**
+ * 0 - Invocations count not declared in shader, or
+ * 1 .. MAX_GEOMETRY_SHADER_INVOCATIONS
+ */
+ GLint Invocations;
+ /**
+ * GL_POINTS, GL_LINES, GL_LINES_ADJACENCY, GL_TRIANGLES, or
+ * GL_TRIANGLES_ADJACENCY, or PRIM_UNKNOWN if it's not set in this
+ * shader.
+ */
+ GLenum InputType;
+ /**
+ * GL_POINTS, GL_LINE_STRIP or GL_TRIANGLE_STRIP, or PRIM_UNKNOWN if
+ * it's not set in this shader.
+ */
+ GLenum OutputType;
+ } Geom;
+
+ /**
+ * Whether early fragment tests are enabled as defined by
+ * ARB_shader_image_load_store.
+ */
+ bool EarlyFragmentTests;
+
+ /**
+ * Compute shader state from ARB_compute_shader layout qualifiers.
+ */
+ struct {
+ /**
+ * Size specified using local_size_{x,y,z}, or all 0's to indicate that
+ * it's not set in this shader.
+ */
+ unsigned LocalSize[3];
+ } Comp;
+};
+
struct gl_uniform_buffer_variable
{
* \c MESA_SHADER_* defines. Entries for non-existent stages will be
* \c NULL.
*/
- struct gl_shader *_LinkedShaders[MESA_SHADER_STAGES];
+ struct gl_linked_shader *_LinkedShaders[MESA_SHADER_STAGES];
/** List of all active resources after linking. */
struct gl_program_resource *ProgramResourceList;
return 1;
case GL_COMPATIBLE_SUBROUTINES: {
const struct gl_uniform_storage *uni;
- struct gl_shader *sh;
+ struct gl_linked_shader *sh;
unsigned count, i;
int j;
case MESA_SHADER_TESS_EVAL: {
struct gl_tess_eval_program *dst_tep =
(struct gl_tess_eval_program *) dst;
- struct gl_shader *tes_sh = src->_LinkedShaders[MESA_SHADER_TESS_EVAL];
+ struct gl_linked_shader *tes_sh =
+ src->_LinkedShaders[MESA_SHADER_TESS_EVAL];
dst_tep->PrimitiveMode = tes_sh->TessEval.PrimitiveMode;
dst_tep->Spacing = tes_sh->TessEval.Spacing;
}
case MESA_SHADER_GEOMETRY: {
struct gl_geometry_program *dst_gp = (struct gl_geometry_program *) dst;
- struct gl_shader *geom_sh = src->_LinkedShaders[MESA_SHADER_GEOMETRY];
+ struct gl_linked_shader *geom_sh =
+ src->_LinkedShaders[MESA_SHADER_GEOMETRY];
dst_gp->VerticesIn = src->Geom.VerticesIn;
dst_gp->VerticesOut = geom_sh->Geom.VerticesOut;
GET_CURRENT_CONTEXT(ctx);
const char *api_name = "glGetActiveSubroutineUniformiv";
struct gl_shader_program *shProg;
- struct gl_shader *sh;
+ struct gl_linked_shader *sh;
gl_shader_stage stage;
struct gl_program_resource *res;
const struct gl_uniform_storage *uni;
GET_CURRENT_CONTEXT(ctx);
const char *api_name = "glUniformSubroutinesuiv";
struct gl_shader_program *shProg;
- struct gl_shader *sh;
+ struct gl_linked_shader *sh;
gl_shader_stage stage;
int i;
GET_CURRENT_CONTEXT(ctx);
const char *api_name = "glGetUniformSubroutineuiv";
struct gl_shader_program *shProg;
- struct gl_shader *sh;
+ struct gl_linked_shader *sh;
gl_shader_stage stage;
if (!_mesa_has_shader_subroutine(ctx)) {
GET_CURRENT_CONTEXT(ctx);
const char *api_name = "glGetProgramStageiv";
struct gl_shader_program *shProg;
- struct gl_shader *sh;
+ struct gl_linked_shader *sh;
gl_shader_stage stage;
if (!_mesa_has_shader_subroutine(ctx)) {
}
static int
-find_compat_subroutine(struct gl_shader *sh, const struct glsl_type *type)
+find_compat_subroutine(struct gl_linked_shader *sh,
+ const struct glsl_type *type)
{
int i, j;
}
static void
-_mesa_shader_init_subroutine_defaults(struct gl_shader *sh)
+_mesa_shader_init_subroutine_defaults(struct gl_linked_shader *sh)
{
int i, j;
/**
* Allocate a new gl_shader object, initialize it.
- * Called via ctx->Driver.NewShader()
*/
struct gl_shader *
_mesa_new_shader(struct gl_context *ctx, GLuint name, gl_shader_stage stage)
}
+/**
+ * Allocate a new gl_linked_shader object.
+ * Called via ctx->Driver.NewShader()
+ */
+struct gl_linked_shader *
+_mesa_new_linked_shader(gl_shader_stage stage)
+{
+ struct gl_linked_shader *shader;
+ shader = rzalloc(NULL, struct gl_linked_shader);
+ if (shader) {
+ shader->Stage = stage;
+ }
+ return shader;
+}
+
+
/**
* Delete a shader object.
*/
{
free((void *)sh->Source);
free(sh->Label);
+ ralloc_free(sh);
+}
+
+
+/**
+ * Delete a shader object.
+ */
+void
+_mesa_delete_linked_shader(struct gl_context *ctx,
+ struct gl_linked_shader *sh)
+{
_mesa_reference_program(ctx, &sh->Program, NULL);
ralloc_free(sh);
}
for (sh = 0; sh < MESA_SHADER_STAGES; sh++) {
if (shProg->_LinkedShaders[sh] != NULL) {
- _mesa_delete_shader(ctx, shProg->_LinkedShaders[sh]);
+ _mesa_delete_linked_shader(ctx, shProg->_LinkedShaders[sh]);
shProg->_LinkedShaders[sh] = NULL;
}
}
void
_mesa_init_shader_object_functions(struct dd_function_table *driver)
{
- driver->NewShader = _mesa_new_shader;
+ driver->NewShader = _mesa_new_linked_shader;
driver->LinkShader = _mesa_ir_link_shader;
}
extern struct gl_shader *
_mesa_new_shader(struct gl_context *ctx, GLuint name, gl_shader_stage type);
+extern struct gl_linked_shader *
+_mesa_new_linked_shader(gl_shader_stage type);
+
extern void
_mesa_delete_shader(struct gl_context *ctx, struct gl_shader *sh);
+extern void
+_mesa_delete_linked_shader(struct gl_context *ctx,
+ struct gl_linked_shader *sh);
+
extern struct gl_shader_program *
_mesa_lookup_shader_program(struct gl_context *ctx, GLuint name);
if (uni->type->is_sampler()) {
bool flushed = false;
for (int i = 0; i < MESA_SHADER_STAGES; i++) {
- struct gl_shader *const sh = shProg->_LinkedShaders[i];
+ struct gl_linked_shader *const sh = shProg->_LinkedShaders[i];
/* If the shader stage doesn't use the sampler uniform, skip this.
*/
if (uni->type->is_image()) {
for (int i = 0; i < MESA_SHADER_STAGES; i++) {
if (uni->opaque[i].active) {
- struct gl_shader *sh = shProg->_LinkedShaders[i];
+ struct gl_linked_shader *sh = shProg->_LinkedShaders[i];
for (int j = 0; j < count; j++)
sh->ImageUnits[uni->opaque[i].index + offset + j] =
struct gl_program *prog)
{
GLbitfield mask = prog->SamplersUsed;
- struct gl_shader *shader =
+ struct gl_linked_shader *shader =
shProg->_LinkedShaders[_mesa_program_enum_to_shader_stage(prog->Target)];
assert(shader);
void
_mesa_generate_parameters_list_for_uniforms(struct gl_shader_program
*shader_program,
- struct gl_shader *sh,
+ struct gl_linked_shader *sh,
struct gl_program_parameter_list
*params)
{
static struct gl_program *
get_mesa_program(struct gl_context *ctx,
struct gl_shader_program *shader_program,
- struct gl_shader *shader)
+ struct gl_linked_shader *shader)
{
ir_to_mesa_visitor v;
struct prog_instruction *mesa_instructions, *mesa_inst;
void
_mesa_generate_parameters_list_for_uniforms(struct gl_shader_program
*shader_program,
- struct gl_shader *sh,
+ struct gl_linked_shader *sh,
struct gl_program_parameter_list
*params);
void
* _mesa_write_shader_to_file function.
*/
void
-_mesa_append_uniforms_to_file(const struct gl_shader *shader)
+_mesa_append_uniforms_to_file(const struct gl_linked_shader *shader)
{
const struct gl_program *const prog = shader->Program;
const char *type;
_mesa_write_shader_to_file(const struct gl_shader *shader);
extern void
-_mesa_append_uniforms_to_file(const struct gl_shader *shader);
+_mesa_append_uniforms_to_file(const struct gl_linked_shader *shader);
#ifdef __cplusplus
};
static void st_bind_ubos(struct st_context *st,
- struct gl_shader *shader,
+ struct gl_linked_shader *shader,
unsigned shader_type)
{
unsigned i;
#include "st_format.h"
static void
-st_bind_images(struct st_context *st, struct gl_shader *shader,
+st_bind_images(struct st_context *st, struct gl_linked_shader *shader,
unsigned shader_type)
{
unsigned i;
#include "st_program.h"
static void
-st_bind_ssbos(struct st_context *st, struct gl_shader *shader,
+st_bind_ssbos(struct st_context *st, struct gl_linked_shader *shader,
unsigned shader_type)
{
unsigned i;
struct gl_program *
st_nir_get_mesa_program(struct gl_context *ctx,
struct gl_shader_program *shader_program,
- struct gl_shader *shader)
+ struct gl_linked_shader *shader)
{
struct gl_program *prog;
GLenum target = _mesa_shader_stage_to_program(shader->Stage);
struct gl_context *ctx;
struct gl_program *prog;
struct gl_shader_program *shader_program;
- struct gl_shader *shader;
+ struct gl_linked_shader *shader;
struct gl_shader_compiler_options *options;
int next_temp;
static struct gl_program *
get_mesa_program_tgsi(struct gl_context *ctx,
struct gl_shader_program *shader_program,
- struct gl_shader *shader)
+ struct gl_linked_shader *shader)
{
glsl_to_tgsi_visitor* v;
struct gl_program *prog;
static struct gl_program *
get_mesa_program(struct gl_context *ctx,
struct gl_shader_program *shader_program,
- struct gl_shader *shader)
+ struct gl_linked_shader *shader)
{
struct pipe_screen *pscreen = ctx->st->pipe->screen;
unsigned ptarget = st_shader_stage_to_ptarget(shader->Stage);
struct gl_program *
st_nir_get_mesa_program(struct gl_context *ctx,
struct gl_shader_program *shader_program,
- struct gl_shader *shader);
+ struct gl_linked_shader *shader);
#ifdef __cplusplus
}
struct gl_shader_program *shProg = (struct gl_shader_program *) data;
GLuint i;
- for (i = 0; i < shProg->NumShaders; i++) {
- destroy_program_variants(st, shProg->Shaders[i]->Program);
- }
-
for (i = 0; i < ARRAY_SIZE(shProg->_LinkedShaders); i++) {
if (shProg->_LinkedShaders[i])
destroy_program_variants(st, shProg->_LinkedShaders[i]->Program);
case GL_TESS_CONTROL_SHADER:
case GL_TESS_EVALUATION_SHADER:
case GL_COMPUTE_SHADER:
- {
- destroy_program_variants(st, shader->Program);
- }
break;
default:
assert(0);