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.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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 "main/simple_list.h"
  28. #include "glsl_symbol_table.h"
  29. enum _mesa_glsl_parser_targets {
  30. vertex_shader,
  31. geometry_shader,
  32. fragment_shader
  33. };
  34. struct _mesa_glsl_parse_state {
  35. void *scanner;
  36. struct simple_node 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. /**
  54. * \name Enable bits for GLSL extensions
  55. */
  56. /*@{*/
  57. unsigned ARB_draw_buffers_enable:1;
  58. unsigned ARB_draw_buffers_warn:1;
  59. unsigned ARB_texture_rectangle_enable:1;
  60. unsigned ARB_texture_rectangle_warn:1;
  61. /*@}*/
  62. };
  63. typedef struct YYLTYPE {
  64. int first_line;
  65. int first_column;
  66. int last_line;
  67. int last_column;
  68. unsigned source;
  69. } YYLTYPE;
  70. # define YYLTYPE_IS_DECLARED 1
  71. # define YYLTYPE_IS_TRIVIAL 1
  72. extern void _mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state,
  73. const char *fmt, ...);
  74. /**
  75. * Emit a warning to the shader log
  76. *
  77. * \sa _mesa_glsl_error
  78. */
  79. extern void _mesa_glsl_warning(const YYLTYPE *locp,
  80. const _mesa_glsl_parse_state *state,
  81. const char *fmt, ...);
  82. extern void _mesa_glsl_lexer_ctor(struct _mesa_glsl_parse_state *state,
  83. const char *string, size_t len);
  84. extern void _mesa_glsl_lexer_dtor(struct _mesa_glsl_parse_state *state);
  85. union YYSTYPE;
  86. extern int _mesa_glsl_lex(union YYSTYPE *yylval, YYLTYPE *yylloc,
  87. void *scanner);
  88. extern int _mesa_glsl_parse(struct _mesa_glsl_parse_state *);
  89. /**
  90. * Process elements of the #extension directive
  91. *
  92. * \return
  93. * If \c name and \c behavior are valid, \c true is returned. Otherwise
  94. * \c false is returned.
  95. */
  96. extern bool _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp,
  97. const char *behavior,
  98. YYLTYPE *behavior_locp,
  99. _mesa_glsl_parse_state *state);
  100. /**
  101. * Get the textual name of the specified shader target
  102. */
  103. extern const char *
  104. _mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target);
  105. #endif /* GLSL_PARSER_EXTRAS_H */