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-03-10 10:42:37 -08:00
|
|
|
#include <cstdlib>
|
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-04-07 14:38:03 -07:00
|
|
|
fragment_shader,
|
|
|
|
ir_shader
|
2010-02-22 13:19:34 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct _mesa_glsl_parse_state {
|
|
|
|
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
|
|
|
|
|
|
|
unsigned language_version;
|
|
|
|
enum _mesa_glsl_parser_targets target;
|
2010-03-11 14:08:33 -08:00
|
|
|
|
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 {
|
|
|
|
unsigned MaxDrawBuffers;
|
2010-07-01 13:30:50 -07:00
|
|
|
unsigned MaxTextureCoords;
|
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;
|
|
|
|
|
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
|
|
|
|
|
|
|
/** Index of last generated anonymous temporary. */
|
|
|
|
unsigned temp_index;
|
2010-04-05 17:01:53 -07:00
|
|
|
|
|
|
|
/** Loop or switch statement containing the current instructions. */
|
|
|
|
class ir_instruction *loop_or_switch_nesting;
|
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
|
|
|
|
*/
|
|
|
|
/*@{*/
|
|
|
|
unsigned ARB_draw_buffers_enable:1;
|
|
|
|
unsigned ARB_draw_buffers_warn:1;
|
2010-04-07 17:13:44 -07:00
|
|
|
unsigned ARB_texture_rectangle_enable:1;
|
|
|
|
unsigned ARB_texture_rectangle_warn:1;
|
2010-06-08 16:17:17 -07:00
|
|
|
unsigned EXT_texture_array_enable:1;
|
|
|
|
unsigned EXT_texture_array_warn:1;
|
2010-04-07 16:59:46 -07:00
|
|
|
/*@}*/
|
2010-02-22 13:19:34 -08: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
|
|
|
|
|
2010-03-11 14:08:33 -08:00
|
|
|
extern void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state,
|
|
|
|
const char *fmt, ...);
|
2010-02-22 13:19:34 -08:00
|
|
|
|
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-06-16 12:18:00 -07:00
|
|
|
extern "C" {
|
2010-06-30 16:27:22 -07:00
|
|
|
extern int preprocess(void *ctx, const char **shader, char **info_log,
|
|
|
|
const struct gl_extensions *extensions);
|
2010-06-16 12:18:00 -07:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
extern int _mesa_glsl_lex(union YYSTYPE *yylval, YYLTYPE *yylloc,
|
|
|
|
void *scanner);
|
|
|
|
|
|
|
|
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-06-03 09:31:46 -07:00
|
|
|
void do_ir_to_mesa(exec_list *instructions);
|
|
|
|
|
2010-02-22 13:19:34 -08:00
|
|
|
#endif /* GLSL_PARSER_EXTRAS_H */
|