Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

glsl_parser_extras.h 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * Copyright © 2010 Intel Corporation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  21. * DEALINGS IN THE SOFTWARE.
  22. */
  23. #pragma once
  24. #ifndef GLSL_PARSER_EXTRAS_H
  25. #define GLSL_PARSER_EXTRAS_H
  26. #include <cstdlib>
  27. #include "glsl_symbol_table.h"
  28. enum _mesa_glsl_parser_targets {
  29. vertex_shader,
  30. geometry_shader,
  31. fragment_shader,
  32. ir_shader
  33. };
  34. struct _mesa_glsl_parse_state {
  35. void *scanner;
  36. exec_list translation_unit;
  37. glsl_symbol_table *symbols;
  38. unsigned language_version;
  39. enum _mesa_glsl_parser_targets target;
  40. /**
  41. * During AST to IR conversion, pointer to current IR function
  42. *
  43. * Will be \c NULL whenever the AST to IR conversion is not inside a
  44. * function definition.
  45. */
  46. class ir_function_signature *current_function;
  47. /** Was there an error during compilation? */
  48. bool error;
  49. /** Index of last generated anonymous temporary. */
  50. unsigned temp_index;
  51. /** Loop or switch statement containing the current instructions. */
  52. class ir_instruction *loop_or_switch_nesting;
  53. /** List of structures defined in user code. */
  54. const glsl_type **user_structures;
  55. unsigned num_user_structures;
  56. char *info_log;
  57. /**
  58. * \name Enable bits for GLSL extensions
  59. */
  60. /*@{*/
  61. unsigned ARB_draw_buffers_enable:1;
  62. unsigned ARB_draw_buffers_warn:1;
  63. unsigned ARB_texture_rectangle_enable:1;
  64. unsigned ARB_texture_rectangle_warn:1;
  65. unsigned EXT_texture_array_enable:1;
  66. unsigned EXT_texture_array_warn:1;
  67. /*@}*/
  68. };
  69. typedef struct YYLTYPE {
  70. int first_line;
  71. int first_column;
  72. int last_line;
  73. int last_column;
  74. unsigned source;
  75. } YYLTYPE;
  76. # define YYLTYPE_IS_DECLARED 1
  77. # define YYLTYPE_IS_TRIVIAL 1
  78. extern void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state,
  79. const char *fmt, ...);
  80. /**
  81. * Emit a warning to the shader log
  82. *
  83. * \sa _mesa_glsl_error
  84. */
  85. extern void _mesa_glsl_warning(const YYLTYPE *locp,
  86. _mesa_glsl_parse_state *state,
  87. const char *fmt, ...);
  88. extern "C" {
  89. extern int preprocess(void *ctx, const char **shader, char **info_log);
  90. }
  91. extern void _mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state,
  92. const char *string);
  93. extern void _mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state);
  94. union YYSTYPE;
  95. extern int _mesa_glsl_lex(union YYSTYPE *yylval, YYLTYPE *yylloc,
  96. void *scanner);
  97. extern int _mesa_glsl_parse(struct _mesa_glsl_parse_state *);
  98. /**
  99. * Process elements of the #extension directive
  100. *
  101. * \return
  102. * If \c name and \c behavior are valid, \c true is returned. Otherwise
  103. * \c false is returned.
  104. */
  105. extern bool _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp,
  106. const char *behavior,
  107. YYLTYPE *behavior_locp,
  108. _mesa_glsl_parse_state *state);
  109. /**
  110. * Get the textual name of the specified shader target
  111. */
  112. extern const char *
  113. _mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target);
  114. #endif /* GLSL_PARSER_EXTRAS_H */