2010-02-22 13:19:34 -08: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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
#ifndef GLSL_PARSER_EXTRAS_H
|
|
|
|
|
#define GLSL_PARSER_EXTRAS_H
|
|
|
|
|
|
2010-08-27 11:53:19 -06:00
|
|
|
/*
|
|
|
|
|
* Most of the definitions here only apply to C++
|
|
|
|
|
*/
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
|
|
|
|
|
|
2011-02-10 10:26:42 -08:00
|
|
|
#include <stdlib.h>
|
2010-03-19 11:57:24 -07:00
|
|
|
#include "glsl_symbol_table.h"
|
2010-02-22 13:19:34 -08:00
|
|
|
|
|
|
|
|
enum _mesa_glsl_parser_targets {
|
|
|
|
|
vertex_shader,
|
|
|
|
|
geometry_shader,
|
2010-10-20 14:59:40 -07:00
|
|
|
fragment_shader
|
2010-02-22 13:19:34 -08:00
|
|
|
};
|
|
|
|
|
|
2010-10-12 12:26:10 -04:00
|
|
|
struct gl_context;
|
2010-07-18 15:59:43 -07:00
|
|
|
|
2012-01-28 11:26:02 -08:00
|
|
|
struct glsl_switch_state {
|
|
|
|
|
/** Temporary variables needed for switch statement. */
|
|
|
|
|
ir_variable *test_var;
|
|
|
|
|
ir_variable *is_fallthru_var;
|
|
|
|
|
ir_variable *is_break_var;
|
|
|
|
|
class ast_switch_statement *switch_nesting_ast;
|
2012-01-30 08:50:14 -08:00
|
|
|
|
|
|
|
|
/** Table of constant values already used in case labels */
|
|
|
|
|
struct hash_table *labels_ht;
|
2012-01-30 09:50:35 -08:00
|
|
|
class ast_case_label *previous_default;
|
2012-01-30 08:50:14 -08:00
|
|
|
|
2012-01-28 11:26:02 -08:00
|
|
|
bool is_switch_innermost; // if switch stmt is closest to break, ...
|
|
|
|
|
};
|
|
|
|
|
|
2012-08-01 18:36:57 -07:00
|
|
|
const char *
|
|
|
|
|
glsl_compute_version_string(void *mem_ctx, bool is_es, unsigned version);
|
|
|
|
|
|
2012-08-01 19:09:24 -07:00
|
|
|
typedef struct YYLTYPE {
|
|
|
|
|
int first_line;
|
|
|
|
|
int first_column;
|
|
|
|
|
int last_line;
|
|
|
|
|
int last_column;
|
|
|
|
|
unsigned source;
|
|
|
|
|
} YYLTYPE;
|
|
|
|
|
# define YYLTYPE_IS_DECLARED 1
|
|
|
|
|
# define YYLTYPE_IS_TRIVIAL 1
|
|
|
|
|
|
2013-09-25 14:36:27 -07:00
|
|
|
extern void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state,
|
|
|
|
|
const char *fmt, ...);
|
|
|
|
|
|
|
|
|
|
|
2010-02-22 13:19:34 -08:00
|
|
|
struct _mesa_glsl_parse_state {
|
2012-04-02 16:14:31 +00:00
|
|
|
_mesa_glsl_parse_state(struct gl_context *_ctx, GLenum target,
|
2010-07-18 15:59:43 -07:00
|
|
|
void *mem_ctx);
|
|
|
|
|
|
2013-09-11 20:07:53 -07:00
|
|
|
DECLARE_RALLOC_CXX_OPERATORS(_mesa_glsl_parse_state);
|
2010-07-18 15:59:43 -07:00
|
|
|
|
2012-08-02 06:45:30 -07:00
|
|
|
/**
|
|
|
|
|
* Generate a string representing the GLSL version currently being compiled
|
|
|
|
|
* (useful for error messages).
|
|
|
|
|
*/
|
|
|
|
|
const char *get_version_string()
|
|
|
|
|
{
|
|
|
|
|
return glsl_compute_version_string(this, this->es_shader,
|
|
|
|
|
this->language_version);
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-01 19:09:24 -07:00
|
|
|
/**
|
|
|
|
|
* Determine whether the current GLSL version is sufficiently high to
|
|
|
|
|
* support a certain feature.
|
|
|
|
|
*
|
|
|
|
|
* \param required_glsl_version is the desktop GLSL version that is
|
|
|
|
|
* required to support the feature, or 0 if no version of desktop GLSL
|
|
|
|
|
* supports the feature.
|
|
|
|
|
*
|
|
|
|
|
* \param required_glsl_es_version is the GLSL ES version that is required
|
|
|
|
|
* to support the feature, or 0 if no version of GLSL ES suports the
|
|
|
|
|
* feature.
|
|
|
|
|
*/
|
|
|
|
|
bool is_version(unsigned required_glsl_version,
|
2013-08-30 01:07:37 -07:00
|
|
|
unsigned required_glsl_es_version) const
|
2012-08-01 19:09:24 -07:00
|
|
|
{
|
|
|
|
|
unsigned required_version = this->es_shader ?
|
|
|
|
|
required_glsl_es_version : required_glsl_version;
|
|
|
|
|
return required_version != 0
|
|
|
|
|
&& this->language_version >= required_version;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool check_version(unsigned required_glsl_version,
|
|
|
|
|
unsigned required_glsl_es_version,
|
|
|
|
|
YYLTYPE *locp, const char *fmt, ...) PRINTFLIKE(5, 6);
|
|
|
|
|
|
2012-08-05 09:57:01 -07:00
|
|
|
bool check_precision_qualifiers_allowed(YYLTYPE *locp)
|
|
|
|
|
{
|
|
|
|
|
return check_version(130, 100, locp,
|
|
|
|
|
"precision qualifiers are forbidden");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool check_bitwise_operations_allowed(YYLTYPE *locp)
|
|
|
|
|
{
|
2012-08-02 08:18:12 -07:00
|
|
|
return check_version(130, 300, locp, "bit-wise operations are forbidden");
|
2012-08-05 09:57:01 -07:00
|
|
|
}
|
|
|
|
|
|
2013-09-25 14:36:27 -07:00
|
|
|
bool check_explicit_attrib_location_allowed(YYLTYPE *locp,
|
|
|
|
|
const ir_variable *var)
|
|
|
|
|
{
|
|
|
|
|
if (!this->has_explicit_attrib_location()) {
|
|
|
|
|
const char *const requirement = this->es_shader
|
|
|
|
|
? "GLSL ES 300"
|
|
|
|
|
: "GL_ARB_explicit_attrib_location extension or GLSL 330";
|
|
|
|
|
|
|
|
|
|
_mesa_glsl_error(locp, this, "%s explicit location requires %s",
|
|
|
|
|
mode_string(var), requirement);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-23 18:13:52 -07:00
|
|
|
bool has_explicit_attrib_location() const
|
|
|
|
|
{
|
|
|
|
|
return ARB_explicit_attrib_location_enable || is_version(330, 300);
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-23 18:18:14 -07:00
|
|
|
bool has_uniform_buffer_objects() const
|
|
|
|
|
{
|
|
|
|
|
return ARB_uniform_buffer_object_enable || is_version(140, 300);
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-02 11:17:30 -07:00
|
|
|
void process_version_directive(YYLTYPE *locp, int version,
|
|
|
|
|
const char *ident);
|
2012-08-02 11:02:55 -07:00
|
|
|
|
2012-04-02 16:14:31 +00:00
|
|
|
struct gl_context *const ctx;
|
2010-02-22 13:19:34 -08:00
|
|
|
void *scanner;
|
2010-05-10 11:17:53 -07:00
|
|
|
exec_list translation_unit;
|
2010-03-19 11:57:24 -07:00
|
|
|
glsl_symbol_table *symbols;
|
2010-02-22 13:19:34 -08:00
|
|
|
|
2012-04-26 18:21:43 -07:00
|
|
|
unsigned num_uniform_blocks;
|
|
|
|
|
unsigned uniform_block_array_size;
|
|
|
|
|
struct gl_uniform_block *uniform_blocks;
|
|
|
|
|
|
2013-02-05 15:07:26 -08:00
|
|
|
unsigned num_supported_versions;
|
|
|
|
|
struct {
|
|
|
|
|
unsigned ver;
|
|
|
|
|
bool es;
|
|
|
|
|
} supported_versions[12];
|
|
|
|
|
|
2010-08-16 12:34:53 -07:00
|
|
|
bool es_shader;
|
2010-02-22 13:19:34 -08:00
|
|
|
unsigned language_version;
|
|
|
|
|
enum _mesa_glsl_parser_targets target;
|
2010-03-11 14:08:33 -08:00
|
|
|
|
2013-08-13 09:15:01 -07:00
|
|
|
/**
|
|
|
|
|
* Number of nested struct_specifier levels
|
|
|
|
|
*
|
|
|
|
|
* Outside a struct_specifer, this is zero.
|
|
|
|
|
*/
|
|
|
|
|
unsigned struct_specifier_depth;
|
|
|
|
|
|
2012-06-22 13:36:35 -07:00
|
|
|
/**
|
|
|
|
|
* Default uniform layout qualifiers tracked during parsing.
|
|
|
|
|
* Currently affects uniform blocks and uniform buffer variables in
|
|
|
|
|
* those blocks.
|
|
|
|
|
*/
|
2012-08-29 09:04:00 -06:00
|
|
|
struct ast_type_qualifier *default_uniform_qualifier;
|
2012-06-22 13:36:35 -07:00
|
|
|
|
2013-06-12 14:03:49 -07:00
|
|
|
/**
|
|
|
|
|
* True if a geometry shader input primitive type was specified using a
|
|
|
|
|
* layout directive.
|
|
|
|
|
*
|
|
|
|
|
* Note: this value is computed at ast_to_hir time rather than at parse
|
|
|
|
|
* time.
|
|
|
|
|
*/
|
|
|
|
|
bool gs_input_prim_type_specified;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* If gs_input_prim_type_specified is true, the primitive type that was
|
|
|
|
|
* specified. Otherwise ignored.
|
|
|
|
|
*/
|
|
|
|
|
GLenum gs_input_prim_type;
|
|
|
|
|
|
|
|
|
|
/** Output layout qualifiers from GLSL 1.50. (geometry shader controls)*/
|
|
|
|
|
struct ast_type_qualifier *out_qualifier;
|
|
|
|
|
|
2011-01-31 15:02:24 -08:00
|
|
|
/**
|
|
|
|
|
* Printable list of GLSL versions supported by the current context
|
|
|
|
|
*
|
|
|
|
|
* \note
|
|
|
|
|
* This string should probably be generated per-context instead of per
|
|
|
|
|
* invokation of the compiler. This should be changed when the method of
|
|
|
|
|
* tracking supported GLSL versions changes.
|
|
|
|
|
*/
|
|
|
|
|
const char *supported_version_string;
|
|
|
|
|
|
2010-06-29 14:21:05 -07:00
|
|
|
/**
|
|
|
|
|
* Implementation defined limits that affect built-in variables, etc.
|
|
|
|
|
*
|
|
|
|
|
* \sa struct gl_constants (in mtypes.h)
|
|
|
|
|
*/
|
|
|
|
|
struct {
|
2010-07-20 14:03:35 -07:00
|
|
|
/* 1.10 */
|
|
|
|
|
unsigned MaxLights;
|
|
|
|
|
unsigned MaxClipPlanes;
|
|
|
|
|
unsigned MaxTextureUnits;
|
2010-07-01 13:30:50 -07:00
|
|
|
unsigned MaxTextureCoords;
|
2010-07-20 14:03:35 -07:00
|
|
|
unsigned MaxVertexAttribs;
|
|
|
|
|
unsigned MaxVertexUniformComponents;
|
|
|
|
|
unsigned MaxVertexTextureImageUnits;
|
|
|
|
|
unsigned MaxCombinedTextureImageUnits;
|
|
|
|
|
unsigned MaxTextureImageUnits;
|
|
|
|
|
unsigned MaxFragmentUniformComponents;
|
|
|
|
|
|
|
|
|
|
/* ARB_draw_buffers */
|
|
|
|
|
unsigned MaxDrawBuffers;
|
2012-08-04 10:00:20 -07:00
|
|
|
|
|
|
|
|
/* 3.00 ES */
|
|
|
|
|
int MinProgramTexelOffset;
|
|
|
|
|
int MaxProgramTexelOffset;
|
2013-07-26 11:55:52 -07:00
|
|
|
|
|
|
|
|
/* 1.50 */
|
|
|
|
|
unsigned MaxVertexOutputComponents;
|
|
|
|
|
unsigned MaxGeometryInputComponents;
|
|
|
|
|
unsigned MaxGeometryOutputComponents;
|
|
|
|
|
unsigned MaxFragmentInputComponents;
|
|
|
|
|
unsigned MaxGeometryTextureImageUnits;
|
|
|
|
|
unsigned MaxGeometryOutputVertices;
|
|
|
|
|
unsigned MaxGeometryTotalOutputComponents;
|
|
|
|
|
unsigned MaxGeometryUniformComponents;
|
2013-10-20 12:39:16 -07:00
|
|
|
|
|
|
|
|
/* ARB_shader_atomic_counters */
|
|
|
|
|
unsigned MaxVertexAtomicCounters;
|
|
|
|
|
unsigned MaxGeometryAtomicCounters;
|
|
|
|
|
unsigned MaxFragmentAtomicCounters;
|
|
|
|
|
unsigned MaxCombinedAtomicCounters;
|
|
|
|
|
unsigned MaxAtomicBufferBindings;
|
2010-06-29 14:21:05 -07:00
|
|
|
} Const;
|
|
|
|
|
|
2010-03-19 17:08:05 -07:00
|
|
|
/**
|
|
|
|
|
* During AST to IR conversion, pointer to current IR function
|
|
|
|
|
*
|
|
|
|
|
* Will be \c NULL whenever the AST to IR conversion is not inside a
|
|
|
|
|
* function definition.
|
|
|
|
|
*/
|
|
|
|
|
class ir_function_signature *current_function;
|
|
|
|
|
|
2011-07-29 15:28:52 -07:00
|
|
|
/**
|
|
|
|
|
* During AST to IR conversion, pointer to the toplevel IR
|
|
|
|
|
* instruction list being generated.
|
|
|
|
|
*/
|
|
|
|
|
exec_list *toplevel_ir;
|
|
|
|
|
|
2010-06-29 09:59:40 -07:00
|
|
|
/** Have we found a return statement in this function? */
|
|
|
|
|
bool found_return;
|
|
|
|
|
|
2010-03-11 14:08:33 -08:00
|
|
|
/** Was there an error during compilation? */
|
|
|
|
|
bool error;
|
2010-03-29 15:20:42 -07:00
|
|
|
|
2011-01-06 10:49:56 -08:00
|
|
|
/**
|
|
|
|
|
* Are all shader inputs / outputs invariant?
|
|
|
|
|
*
|
|
|
|
|
* This is set when the 'STDGL invariant(all)' pragma is used.
|
|
|
|
|
*/
|
|
|
|
|
bool all_invariant;
|
|
|
|
|
|
2010-04-05 17:01:53 -07:00
|
|
|
/** Loop or switch statement containing the current instructions. */
|
glsl: Generate IR for switch statements
Up until now modifying the GLSL compiler has been pretty straightforward.
This is where things get interesting. But still pretty straightforward.
Switch statements can be thought of a series of if/then/else statements.
Case labels are compared with the value of a test expression and the case
statements are executed if the comparison is true.
There are a couple of aspects of switch statements that complicate this simple
view of the world. The primary one is that cases can fall through sequentially
to subsequent case, unless a break statement is encountered, in which case,
the switch statement exits completely.
But break handling is further complicated by the fact that a break statement
can impact the exit of a loop. Thus, we need to coordinate break processing
between switch statements and loop statements.
The code generated by a switch statement maintains three temporary state
variables:
int test_value;
bool is_fallthru;
bool is_break;
test_value is initialized to the value of the test expression at the head of
the switch statement. This is the value that case labels are compared against.
is_fallthru is used to sequentially fall through to subsequent cases and is
initialized to false. When a case label matches the test expression, this
state variable is set to true. It will also be forced to false if a break
statement has been encountered. This forcing to false on break MUST be
after every case test. In practice, we defer that forcing to immediately after
the last case comparison prior to executing a case statement, but that is
an optimization.
is_break is used to indicate that a break statement has been executed and is
initialized to false. When a break statement is encountered, it is set to true.
This state variable is then used to conditionally force is_fallthru to to false
to prevent subsequent case statements from executing.
Code generation for break statements depends on whether the break statement is
inside a switch statement or inside a loop statement. If it inside a loop
statement is inside a break statement, the same code as before gets generated.
But if a switch statement is inside a loop statement, code is emitted to set
the is_break state to true.
Just as ASTs for loop statements are managed in a stack-like
manner to handle nesting, we also add a bool to capture the innermost switch
or loop condition. Note that we still need to maintain a loop AST stack to
properly handle for-loop code generation on a continue statement. Technically,
we don't (yet) need a switch AST stack, but I am using one for orthogonality
with loop statements, in anticipation of future use. Note that a simple
boolean stack would have sufficed.
We will illustrate a switch statement with its analogous conditional code that
a switch statement corresponds to by examining an example.
Consider the following switch statement:
switch (42) {
case 0:
case 1:
gl_FragColor = vec4(1.0, 2.0, 3.0, 4.0);
case 2:
case 3:
gl_FragColor = vec4(4.0, 3.0, 2.0, 1.0);
break;
case 4:
default:
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
}
Note that case 0 and case 1 fall through to cases 2 and 3 if they occur.
Note that case 4 and the default case must be reached explicitly, since cases
2 and 3 break at the end of their case.
Finally, note that case 4 and the default case don't break but simply fall
through to the end of the switch.
For this code, the equivalent code can be expressed as:
int test_val = 42; // capture value of test expression
bool is_fallthru = false; // prevent initial fall through
bool is_break = false; // capture the execution of a break stmt
is_fallthru |= (test_val == 0); // enable fallthru on case 0
is_fallthru |= (test_val == 1); // enable fallthru on case 1
is_fallthru &= !is_break; // inhibit fallthru on previous break
if (is_fallthru) {
gl_FragColor = vec4(1.0, 2.0, 3.0, 4.0);
}
is_fallthru |= (test_val == 2); // enable fallthru on case 2
is_fallthru |= (test_val == 3); // enable fallthru on case 3
is_fallthru &= !is_break; // inhibit fallthru on previous break
if (is_fallthru) {
gl_FragColor = vec4(4.0, 3.0, 2.0, 1.0);
is_break = true; // inhibit all subsequent fallthru for break
}
is_fallthru |= (test_val == 4); // enable fallthru on case 4
is_fallthru = true; // enable fallthru for default case
is_fallthru &= !is_break; // inhibit fallthru on previous break
if (is_fallthru) {
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
}
The code generate for |= and &= uses the conditional assignment capabilities
of the IR.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-11-07 16:17:58 -08:00
|
|
|
class ast_iteration_statement *loop_nesting_ast;
|
|
|
|
|
|
2012-01-28 11:26:02 -08:00
|
|
|
struct glsl_switch_state switch_state;
|
2010-04-07 16:59:46 -07:00
|
|
|
|
2010-04-28 13:14:53 -07:00
|
|
|
/** List of structures defined in user code. */
|
|
|
|
|
const glsl_type **user_structures;
|
|
|
|
|
unsigned num_user_structures;
|
|
|
|
|
|
2010-04-29 18:00:33 -07:00
|
|
|
char *info_log;
|
|
|
|
|
|
2010-04-07 16:59:46 -07:00
|
|
|
/**
|
|
|
|
|
* \name Enable bits for GLSL extensions
|
|
|
|
|
*/
|
|
|
|
|
/*@{*/
|
2011-06-24 12:33:30 -07:00
|
|
|
bool ARB_draw_buffers_enable;
|
|
|
|
|
bool ARB_draw_buffers_warn;
|
|
|
|
|
bool ARB_draw_instanced_enable;
|
|
|
|
|
bool ARB_draw_instanced_warn;
|
|
|
|
|
bool ARB_explicit_attrib_location_enable;
|
|
|
|
|
bool ARB_explicit_attrib_location_warn;
|
|
|
|
|
bool ARB_fragment_coord_conventions_enable;
|
|
|
|
|
bool ARB_fragment_coord_conventions_warn;
|
|
|
|
|
bool ARB_texture_rectangle_enable;
|
|
|
|
|
bool ARB_texture_rectangle_warn;
|
2012-12-24 00:57:37 +01:00
|
|
|
bool ARB_texture_gather_enable;
|
|
|
|
|
bool ARB_texture_gather_warn;
|
2011-06-24 12:33:30 -07:00
|
|
|
bool EXT_texture_array_enable;
|
|
|
|
|
bool EXT_texture_array_warn;
|
|
|
|
|
bool ARB_shader_texture_lod_enable;
|
|
|
|
|
bool ARB_shader_texture_lod_warn;
|
|
|
|
|
bool ARB_shader_stencil_export_enable;
|
|
|
|
|
bool ARB_shader_stencil_export_warn;
|
|
|
|
|
bool AMD_conservative_depth_enable;
|
|
|
|
|
bool AMD_conservative_depth_warn;
|
2011-08-09 10:53:29 -07:00
|
|
|
bool ARB_conservative_depth_enable;
|
|
|
|
|
bool ARB_conservative_depth_warn;
|
2011-06-24 12:33:30 -07:00
|
|
|
bool AMD_shader_stencil_export_enable;
|
|
|
|
|
bool AMD_shader_stencil_export_warn;
|
|
|
|
|
bool OES_texture_3D_enable;
|
|
|
|
|
bool OES_texture_3D_warn;
|
2011-10-23 18:51:06 +08:00
|
|
|
bool OES_EGL_image_external_enable;
|
|
|
|
|
bool OES_EGL_image_external_warn;
|
2012-04-30 13:19:01 +02:00
|
|
|
bool ARB_shader_bit_encoding_enable;
|
|
|
|
|
bool ARB_shader_bit_encoding_warn;
|
2011-12-25 19:17:03 +01:00
|
|
|
bool ARB_uniform_buffer_object_enable;
|
|
|
|
|
bool ARB_uniform_buffer_object_warn;
|
2012-07-16 20:45:17 +02:00
|
|
|
bool OES_standard_derivatives_enable;
|
|
|
|
|
bool OES_standard_derivatives_warn;
|
2012-11-03 20:43:17 +10:00
|
|
|
bool ARB_texture_cube_map_array_enable;
|
|
|
|
|
bool ARB_texture_cube_map_array_warn;
|
2013-01-21 17:09:53 -08:00
|
|
|
bool ARB_shading_language_packing_enable;
|
|
|
|
|
bool ARB_shading_language_packing_warn;
|
2012-12-21 21:33:37 +13:00
|
|
|
bool ARB_texture_multisample_enable;
|
|
|
|
|
bool ARB_texture_multisample_warn;
|
2013-09-26 19:37:30 +12:00
|
|
|
bool ARB_texture_query_levels_enable;
|
|
|
|
|
bool ARB_texture_query_levels_warn;
|
2012-09-23 19:50:41 +10:00
|
|
|
bool ARB_texture_query_lod_enable;
|
|
|
|
|
bool ARB_texture_query_lod_warn;
|
2013-04-09 16:01:38 -07:00
|
|
|
bool ARB_gpu_shader5_enable;
|
|
|
|
|
bool ARB_gpu_shader5_warn;
|
2013-03-27 13:58:04 -07:00
|
|
|
bool AMD_vertex_shader_layer_enable;
|
|
|
|
|
bool AMD_vertex_shader_layer_warn;
|
2013-05-20 08:41:18 -07:00
|
|
|
bool ARB_shading_language_420pack_enable;
|
|
|
|
|
bool ARB_shading_language_420pack_warn;
|
2013-08-30 12:34:36 -07:00
|
|
|
bool ARB_sample_shading_enable;
|
|
|
|
|
bool ARB_sample_shading_warn;
|
2013-09-12 11:40:00 -05:00
|
|
|
bool EXT_shader_integer_mix_enable;
|
|
|
|
|
bool EXT_shader_integer_mix_warn;
|
2013-10-07 18:55:18 -07:00
|
|
|
bool ARB_shader_atomic_counters_enable;
|
|
|
|
|
bool ARB_shader_atomic_counters_warn;
|
2010-04-07 16:59:46 -07:00
|
|
|
/*@}*/
|
2010-06-30 16:42:07 -07:00
|
|
|
|
|
|
|
|
/** Extensions supported by the OpenGL implementation. */
|
|
|
|
|
const struct gl_extensions *extensions;
|
2010-07-20 11:29:46 -07:00
|
|
|
|
|
|
|
|
/** Shaders containing built-in functions that are used for linking. */
|
|
|
|
|
struct gl_shader *builtins_to_link[16];
|
|
|
|
|
unsigned num_builtins_to_link;
|
2013-07-30 21:13:48 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* For geometry shaders, size of the most recently seen input declaration
|
|
|
|
|
* that was a sized array, or 0 if no sized input array declarations have
|
|
|
|
|
* been seen.
|
|
|
|
|
*
|
|
|
|
|
* Unused for other shader types.
|
|
|
|
|
*/
|
|
|
|
|
unsigned gs_input_size;
|
2010-02-22 13:19:34 -08:00
|
|
|
};
|
|
|
|
|
|
2010-07-21 13:43:47 -07:00
|
|
|
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
|
|
|
|
do { \
|
|
|
|
|
if (N) \
|
|
|
|
|
{ \
|
|
|
|
|
(Current).first_line = YYRHSLOC(Rhs, 1).first_line; \
|
|
|
|
|
(Current).first_column = YYRHSLOC(Rhs, 1).first_column; \
|
|
|
|
|
(Current).last_line = YYRHSLOC(Rhs, N).last_line; \
|
|
|
|
|
(Current).last_column = YYRHSLOC(Rhs, N).last_column; \
|
|
|
|
|
} \
|
|
|
|
|
else \
|
|
|
|
|
{ \
|
|
|
|
|
(Current).first_line = (Current).last_line = \
|
|
|
|
|
YYRHSLOC(Rhs, 0).last_line; \
|
|
|
|
|
(Current).first_column = (Current).last_column = \
|
|
|
|
|
YYRHSLOC(Rhs, 0).last_column; \
|
|
|
|
|
} \
|
|
|
|
|
(Current).source = 0; \
|
|
|
|
|
} while (0)
|
|
|
|
|
|
2010-04-07 14:47:46 -07:00
|
|
|
/**
|
|
|
|
|
* Emit a warning to the shader log
|
|
|
|
|
*
|
|
|
|
|
* \sa _mesa_glsl_error
|
|
|
|
|
*/
|
|
|
|
|
extern void _mesa_glsl_warning(const YYLTYPE *locp,
|
2010-04-29 18:00:33 -07:00
|
|
|
_mesa_glsl_parse_state *state,
|
2010-04-07 14:47:46 -07:00
|
|
|
const char *fmt, ...);
|
|
|
|
|
|
2010-02-22 13:19:34 -08:00
|
|
|
extern void _mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state,
|
2010-06-21 11:43:42 -07:00
|
|
|
const char *string);
|
2010-02-22 13:19:34 -08:00
|
|
|
|
|
|
|
|
extern void _mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state);
|
|
|
|
|
|
|
|
|
|
union YYSTYPE;
|
2013-07-29 15:27:46 -07:00
|
|
|
extern int _mesa_glsl_lexer_lex(union YYSTYPE *yylval, YYLTYPE *yylloc,
|
|
|
|
|
void *scanner);
|
2010-02-22 13:19:34 -08:00
|
|
|
|
|
|
|
|
extern int _mesa_glsl_parse(struct _mesa_glsl_parse_state *);
|
|
|
|
|
|
2010-04-07 16:46:25 -07:00
|
|
|
/**
|
|
|
|
|
* Process elements of the #extension directive
|
|
|
|
|
*
|
|
|
|
|
* \return
|
|
|
|
|
* If \c name and \c behavior are valid, \c true is returned. Otherwise
|
|
|
|
|
* \c false is returned.
|
|
|
|
|
*/
|
|
|
|
|
extern bool _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp,
|
|
|
|
|
const char *behavior,
|
|
|
|
|
YYLTYPE *behavior_locp,
|
|
|
|
|
_mesa_glsl_parse_state *state);
|
|
|
|
|
|
2010-04-07 16:44:30 -07:00
|
|
|
/**
|
|
|
|
|
* Get the textual name of the specified shader target
|
|
|
|
|
*/
|
|
|
|
|
extern const char *
|
|
|
|
|
_mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target);
|
|
|
|
|
|
2010-08-27 11:53:19 -06:00
|
|
|
|
|
|
|
|
#endif /* __cplusplus */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* These definitions apply to C and C++
|
|
|
|
|
*/
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2013-06-12 16:57:11 -07:00
|
|
|
extern const char *
|
|
|
|
|
_mesa_glsl_shader_target_name(GLenum type);
|
|
|
|
|
|
2012-09-14 10:13:01 +10:00
|
|
|
extern int glcpp_preprocess(void *ctx, const char **shader, char **info_log,
|
2012-12-05 12:56:16 -08:00
|
|
|
const struct gl_extensions *extensions, struct gl_context *gl_ctx);
|
2010-08-27 11:53:19 -06:00
|
|
|
|
2011-03-25 16:00:11 +00:00
|
|
|
extern void _mesa_destroy_shader_compiler(void);
|
|
|
|
|
extern void _mesa_destroy_shader_compiler_caches(void);
|
2010-08-27 11:53:19 -06:00
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
2010-02-22 13:19:34 -08:00
|
|
|
#endif /* GLSL_PARSER_EXTRAS_H */
|