shader_warnings.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /**************************************************************************/
  2. /* shader_warnings.h */
  3. /**************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /**************************************************************************/
  8. /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
  9. /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
  10. /* */
  11. /* Permission is hereby granted, free of charge, to any person obtaining */
  12. /* a copy of this software and associated documentation files (the */
  13. /* "Software"), to deal in the Software without restriction, including */
  14. /* without limitation the rights to use, copy, modify, merge, publish, */
  15. /* distribute, sublicense, and/or sell copies of the Software, and to */
  16. /* permit persons to whom the Software is furnished to do so, subject to */
  17. /* the following conditions: */
  18. /* */
  19. /* The above copyright notice and this permission notice shall be */
  20. /* included in all copies or substantial portions of the Software. */
  21. /* */
  22. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  23. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  24. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
  25. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  26. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  27. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  28. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  29. /**************************************************************************/
  30. #ifndef SHADER_WARNINGS_H
  31. #define SHADER_WARNINGS_H
  32. #ifdef DEBUG_ENABLED
  33. #include "core/string/string_name.h"
  34. #include "core/templates/hash_map.h"
  35. #include "core/templates/list.h"
  36. #include "core/templates/rb_map.h"
  37. #include "core/variant/variant.h"
  38. class ShaderWarning {
  39. public:
  40. enum Code {
  41. FLOAT_COMPARISON,
  42. UNUSED_CONSTANT,
  43. UNUSED_FUNCTION,
  44. UNUSED_STRUCT,
  45. UNUSED_UNIFORM,
  46. UNUSED_VARYING,
  47. UNUSED_LOCAL_VARIABLE,
  48. FORMATTING_ERROR,
  49. DEVICE_LIMIT_EXCEEDED,
  50. MAGIC_POSITION_WRITE,
  51. WARNING_MAX,
  52. };
  53. enum CodeFlags : uint32_t {
  54. NONE_FLAG = 0U,
  55. FLOAT_COMPARISON_FLAG = 1U,
  56. UNUSED_CONSTANT_FLAG = 2U,
  57. UNUSED_FUNCTION_FLAG = 4U,
  58. UNUSED_STRUCT_FLAG = 8U,
  59. UNUSED_UNIFORM_FLAG = 16U,
  60. UNUSED_VARYING_FLAG = 32U,
  61. UNUSED_LOCAL_VARIABLE_FLAG = 64U,
  62. FORMATTING_ERROR_FLAG = 128U,
  63. DEVICE_LIMIT_EXCEEDED_FLAG = 256U,
  64. MAGIC_POSITION_WRITE_FLAG = 512U,
  65. };
  66. private:
  67. Code code;
  68. int line;
  69. StringName subject;
  70. Vector<Variant> extra_args;
  71. public:
  72. Code get_code() const;
  73. int get_line() const;
  74. const StringName &get_subject() const;
  75. String get_message() const;
  76. String get_name() const;
  77. Vector<Variant> get_extra_args() const;
  78. static String get_name_from_code(Code p_code);
  79. static Code get_code_from_name(const String &p_name);
  80. static CodeFlags get_flags_from_codemap(const HashMap<Code, bool> &p_map);
  81. ShaderWarning(Code p_code = WARNING_MAX, int p_line = -1, const StringName &p_subject = "", const Vector<Variant> &p_extra_args = Vector<Variant>());
  82. };
  83. #endif // DEBUG_ENABLED
  84. #endif // SHADER_WARNINGS_H