2011-10-25 03:37:11 +01:00
|
|
|
/* -*- c++ -*- */
|
2010-07-14 01:36:13 +01:00
|
|
|
/*
|
|
|
|
* Copyright © 2010 Intel Corporation
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
|
|
* DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef GLSL_LINKER_H
|
|
|
|
#define GLSL_LINKER_H
|
|
|
|
|
2018-03-28 13:59:26 +01:00
|
|
|
#include "linker_util.h"
|
|
|
|
|
2018-04-08 18:13:08 +01:00
|
|
|
struct gl_shader_program;
|
|
|
|
struct gl_shader;
|
|
|
|
struct gl_linked_shader;
|
|
|
|
|
2010-07-14 01:36:13 +01:00
|
|
|
extern bool
|
2016-06-30 05:55:40 +01:00
|
|
|
link_function_calls(gl_shader_program *prog, gl_linked_shader *main,
|
2016-09-28 07:04:05 +01:00
|
|
|
gl_shader **shader_list, unsigned num_shaders);
|
2010-07-14 01:36:13 +01:00
|
|
|
|
2011-10-12 00:15:47 +01:00
|
|
|
extern void
|
2013-10-04 18:46:29 +01:00
|
|
|
link_invalidate_variable_locations(exec_list *ir);
|
2011-10-12 00:15:47 +01:00
|
|
|
|
2011-10-18 19:54:48 +01:00
|
|
|
extern void
|
2014-08-09 03:46:05 +01:00
|
|
|
link_assign_uniform_locations(struct gl_shader_program *prog,
|
2016-12-04 11:47:17 +00:00
|
|
|
struct gl_context *ctx);
|
2011-10-18 19:54:48 +01:00
|
|
|
|
2012-04-06 22:06:13 +01:00
|
|
|
extern void
|
2014-08-09 03:46:05 +01:00
|
|
|
link_set_uniform_initializers(struct gl_shader_program *prog,
|
|
|
|
unsigned int boolean_true);
|
2012-04-06 22:06:13 +01:00
|
|
|
|
2012-04-27 21:52:56 +01:00
|
|
|
extern int
|
|
|
|
link_cross_validate_uniform_block(void *mem_ctx,
|
2016-09-28 07:04:05 +01:00
|
|
|
struct gl_uniform_block **linked_blocks,
|
|
|
|
unsigned int *num_linked_blocks,
|
|
|
|
struct gl_uniform_block *new_block);
|
2012-04-27 21:52:56 +01:00
|
|
|
|
2016-04-03 03:44:33 +01:00
|
|
|
extern void
|
2013-01-22 05:59:56 +00:00
|
|
|
link_uniform_blocks(void *mem_ctx,
|
2015-04-21 11:12:05 +01:00
|
|
|
struct gl_context *ctx,
|
2013-01-22 05:59:56 +00:00
|
|
|
struct gl_shader_program *prog,
|
2016-06-27 22:52:46 +01:00
|
|
|
struct gl_linked_shader *shader,
|
2016-04-03 03:44:33 +01:00
|
|
|
struct gl_uniform_block **ubo_blocks,
|
|
|
|
unsigned *num_ubo_blocks,
|
|
|
|
struct gl_uniform_block **ssbo_blocks,
|
|
|
|
unsigned *num_ssbo_blocks);
|
2013-01-22 05:59:56 +00:00
|
|
|
|
2015-02-21 10:47:14 +00:00
|
|
|
bool
|
|
|
|
validate_intrastage_arrays(struct gl_shader_program *prog,
|
|
|
|
ir_variable *const var,
|
2019-04-23 15:52:36 +01:00
|
|
|
ir_variable *const existing,
|
|
|
|
bool match_precision = true);
|
2015-02-21 10:47:14 +00:00
|
|
|
|
2013-07-27 19:08:31 +01:00
|
|
|
void
|
2013-07-27 22:58:43 +01:00
|
|
|
validate_intrastage_interface_blocks(struct gl_shader_program *prog,
|
|
|
|
const gl_shader **shader_list,
|
2013-05-21 07:42:49 +01:00
|
|
|
unsigned num_shaders);
|
|
|
|
|
2013-07-27 19:08:31 +01:00
|
|
|
void
|
glsl: Fix interstage uniform interface block link error detection.
Previously, we checked for interstage uniform interface block link
errors in validate_interstage_interface_blocks(), which is only called
on pairs of adjacent shader stages. Therefore, we failed to detect
uniform interface block mismatches between non-adjacent shader stages.
Before the introduction of geometry shaders, this wasn't a problem,
because the only supported shader stages were vertex and fragment
shaders, therefore they were always adjacent. However, now that we
allow a program to contain vertex, geometry, and fragment shaders,
that is no longer the case.
Fixes piglit test "skip-stage-uniform-block-array-size-mismatch".
Cc: "10.0" <mesa-stable@lists.freedesktop.org>
v2: Rename validate_interstage_interface_blocks() to
validate_interstage_inout_blocks() to reflect the fact that it no
longer validates uniform blocks.
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
v3: Make validate_interstage_inout_blocks() skip uniform blocks.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2013-11-15 22:23:45 +00:00
|
|
|
validate_interstage_inout_blocks(struct gl_shader_program *prog,
|
2016-06-30 05:55:40 +01:00
|
|
|
const gl_linked_shader *producer,
|
|
|
|
const gl_linked_shader *consumer);
|
glsl: Fix interstage uniform interface block link error detection.
Previously, we checked for interstage uniform interface block link
errors in validate_interstage_interface_blocks(), which is only called
on pairs of adjacent shader stages. Therefore, we failed to detect
uniform interface block mismatches between non-adjacent shader stages.
Before the introduction of geometry shaders, this wasn't a problem,
because the only supported shader stages were vertex and fragment
shaders, therefore they were always adjacent. However, now that we
allow a program to contain vertex, geometry, and fragment shaders,
that is no longer the case.
Fixes piglit test "skip-stage-uniform-block-array-size-mismatch".
Cc: "10.0" <mesa-stable@lists.freedesktop.org>
v2: Rename validate_interstage_interface_blocks() to
validate_interstage_inout_blocks() to reflect the fact that it no
longer validates uniform blocks.
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
v3: Make validate_interstage_inout_blocks() skip uniform blocks.
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
2013-11-15 22:23:45 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
validate_interstage_uniform_blocks(struct gl_shader_program *prog,
|
2016-06-30 05:55:40 +01:00
|
|
|
gl_linked_shader **stages);
|
2013-05-21 07:46:16 +01:00
|
|
|
|
2013-09-11 20:14:46 +01:00
|
|
|
extern void
|
|
|
|
link_assign_atomic_counter_resources(struct gl_context *ctx,
|
|
|
|
struct gl_shader_program *prog);
|
|
|
|
|
|
|
|
extern void
|
|
|
|
link_check_atomic_counter_resources(struct gl_context *ctx,
|
|
|
|
struct gl_shader_program *prog);
|
|
|
|
|
2016-09-15 19:09:34 +01:00
|
|
|
|
|
|
|
extern struct gl_linked_shader *
|
|
|
|
link_intrastage_shaders(void *mem_ctx,
|
|
|
|
struct gl_context *ctx,
|
|
|
|
struct gl_shader_program *prog,
|
|
|
|
struct gl_shader **shader_list,
|
|
|
|
unsigned num_shaders,
|
|
|
|
bool allow_missing_main);
|
|
|
|
|
2017-11-01 23:27:53 +00:00
|
|
|
extern unsigned
|
|
|
|
link_calculate_matrix_stride(const glsl_type *matrix, bool row_major,
|
|
|
|
enum glsl_interface_packing packing);
|
|
|
|
|
2011-10-25 03:37:11 +01:00
|
|
|
/**
|
2013-01-28 22:43:03 +00:00
|
|
|
* Class for processing all of the leaf fields of a variable that corresponds
|
|
|
|
* to a program resource.
|
2011-10-25 03:37:11 +01:00
|
|
|
*
|
2013-01-28 22:43:03 +00:00
|
|
|
* The leaf fields are all the parts of the variable that the application
|
|
|
|
* could query using \c glGetProgramResourceIndex (or that could be returned
|
|
|
|
* by \c glGetProgramResourceName).
|
2011-10-25 03:37:11 +01:00
|
|
|
*
|
|
|
|
* Classes my derive from this class to implement specific functionality.
|
|
|
|
* This class only provides the mechanism to iterate over the leaves. Derived
|
|
|
|
* classes must implement \c ::visit_field and may override \c ::process.
|
|
|
|
*/
|
2013-01-28 22:43:03 +00:00
|
|
|
class program_resource_visitor {
|
2011-10-25 03:37:11 +01:00
|
|
|
public:
|
|
|
|
/**
|
2013-01-28 22:43:03 +00:00
|
|
|
* Begin processing a variable
|
2011-10-25 03:37:11 +01:00
|
|
|
*
|
|
|
|
* Classes that overload this function should call \c ::process from the
|
2013-01-28 22:43:03 +00:00
|
|
|
* base class to start the recursive processing of the variable.
|
2011-10-25 03:37:11 +01:00
|
|
|
*
|
2013-01-28 22:43:03 +00:00
|
|
|
* \param var The variable that is to be processed
|
2011-10-25 03:37:11 +01:00
|
|
|
*
|
2013-01-28 22:43:03 +00:00
|
|
|
* Calls \c ::visit_field for each leaf of the variable.
|
2013-01-22 03:32:07 +00:00
|
|
|
*
|
|
|
|
* \warning
|
2013-01-28 22:43:03 +00:00
|
|
|
* When processing a uniform block, this entry should only be used in cases
|
|
|
|
* where the row / column ordering of matrices in the block does not
|
|
|
|
* matter. For example, enumerating the names of members of the block, but
|
|
|
|
* not for determining the offsets of members.
|
2011-10-25 03:37:11 +01:00
|
|
|
*/
|
2017-07-24 01:24:53 +01:00
|
|
|
void process(ir_variable *var, bool use_std430_as_default);
|
2011-10-25 03:37:11 +01:00
|
|
|
|
2019-02-22 06:13:39 +00:00
|
|
|
/**
|
|
|
|
* Begin processing a variable
|
|
|
|
*
|
|
|
|
* Classes that overload this function should call \c ::process from the
|
|
|
|
* base class to start the recursive processing of the variable.
|
|
|
|
*
|
|
|
|
* \param var The variable that is to be processed
|
|
|
|
* \param var_type The glsl_type reference of the variable
|
|
|
|
*
|
|
|
|
* Calls \c ::visit_field for each leaf of the variable.
|
|
|
|
*
|
|
|
|
* \warning
|
|
|
|
* When processing a uniform block, this entry should only be used in cases
|
|
|
|
* where the row / column ordering of matrices in the block does not
|
|
|
|
* matter. For example, enumerating the names of members of the block, but
|
|
|
|
* not for determining the offsets of members.
|
|
|
|
*/
|
|
|
|
void process(ir_variable *var, const glsl_type *var_type,
|
|
|
|
bool use_std430_as_default);
|
|
|
|
|
2013-01-22 04:42:19 +00:00
|
|
|
/**
|
2013-01-28 22:43:03 +00:00
|
|
|
* Begin processing a variable of a structured type.
|
2013-01-22 04:42:19 +00:00
|
|
|
*
|
|
|
|
* This flavor of \c process should be used to handle structured types
|
|
|
|
* (i.e., structures, interfaces, or arrays there of) that need special
|
|
|
|
* name handling. A common usage is to handle cases where the block name
|
|
|
|
* (instead of the instance name) is used for an interface block.
|
|
|
|
*
|
|
|
|
* \param type Type that is to be processed, associated with \c name
|
2013-01-28 22:43:03 +00:00
|
|
|
* \param name Base name of the structured variable being processed
|
2013-01-22 04:42:19 +00:00
|
|
|
*
|
|
|
|
* \note
|
|
|
|
* \c type must be \c GLSL_TYPE_RECORD, \c GLSL_TYPE_INTERFACE, or an array
|
|
|
|
* there of.
|
|
|
|
*/
|
2017-07-24 01:24:53 +01:00
|
|
|
void process(const glsl_type *type, const char *name,
|
|
|
|
bool use_std430_as_default);
|
2013-01-22 04:42:19 +00:00
|
|
|
|
2011-10-25 03:37:11 +01:00
|
|
|
protected:
|
2013-08-17 07:30:43 +01:00
|
|
|
/**
|
|
|
|
* Method invoked for each leaf of the variable
|
|
|
|
*
|
|
|
|
* \param type Type of the field.
|
|
|
|
* \param name Fully qualified name of the field.
|
|
|
|
* \param row_major For a matrix type, is it stored row-major.
|
|
|
|
* \param record_type Type of the record containing the field.
|
2014-07-16 23:37:10 +01:00
|
|
|
* \param last_field Set if \c name is the last field of the structure
|
|
|
|
* containing it. This will always be false for items
|
|
|
|
* not contained in a structure or interface block.
|
2013-08-17 07:30:43 +01:00
|
|
|
*/
|
|
|
|
virtual void visit_field(const glsl_type *type, const char *name,
|
2014-07-16 23:37:10 +01:00
|
|
|
bool row_major, const glsl_type *record_type,
|
2016-05-11 01:49:19 +01:00
|
|
|
const enum glsl_interface_packing packing,
|
2016-11-09 20:45:39 +00:00
|
|
|
bool last_field) = 0;
|
2011-10-25 03:37:11 +01:00
|
|
|
|
2015-02-10 08:02:09 +00:00
|
|
|
virtual void enter_record(const glsl_type *type, const char *name,
|
2016-05-11 01:49:19 +01:00
|
|
|
bool row_major, const enum glsl_interface_packing packing);
|
2015-02-10 08:02:09 +00:00
|
|
|
|
|
|
|
virtual void leave_record(const glsl_type *type, const char *name,
|
2016-05-11 01:49:19 +01:00
|
|
|
bool row_major, const enum glsl_interface_packing packing);
|
2015-02-10 08:02:09 +00:00
|
|
|
|
2016-01-08 10:06:41 +00:00
|
|
|
virtual void set_buffer_offset(unsigned offset);
|
|
|
|
|
2015-08-30 03:49:46 +01:00
|
|
|
virtual void set_record_array_count(unsigned record_array_count);
|
|
|
|
|
2011-10-25 03:37:11 +01:00
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* \param name_length Length of the current name \b not including the
|
|
|
|
* terminating \c NUL character.
|
2014-07-16 23:37:10 +01:00
|
|
|
* \param last_field Set if \c name is the last field of the structure
|
|
|
|
* containing it. This will always be false for items
|
|
|
|
* not contained in a structure or interface block.
|
2011-10-25 03:37:11 +01:00
|
|
|
*/
|
2013-01-22 03:32:07 +00:00
|
|
|
void recursion(const glsl_type *t, char **name, size_t name_length,
|
2014-07-16 23:37:10 +01:00
|
|
|
bool row_major, const glsl_type *record_type,
|
2016-05-11 01:49:19 +01:00
|
|
|
const enum glsl_interface_packing packing,
|
2016-03-11 05:15:02 +00:00
|
|
|
bool last_field, unsigned record_array_count,
|
|
|
|
const glsl_struct_field *named_ifc_member);
|
2011-10-25 03:37:11 +01:00
|
|
|
};
|
|
|
|
|
2010-07-14 01:36:13 +01:00
|
|
|
#endif /* GLSL_LINKER_H */
|