shader_warnings.h 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*************************************************************************/
  2. /* shader_warnings.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* https://godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
  9. /* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
  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
  31. #define SHADER_WARNINGS
  32. #ifdef DEBUG_ENABLED
  33. #include "core/string/string_name.h"
  34. #include "core/templates/list.h"
  35. #include "core/templates/map.h"
  36. #include "core/variant/variant.h"
  37. class ShaderWarning {
  38. public:
  39. enum Code {
  40. FLOAT_COMPARISON,
  41. UNUSED_CONSTANT,
  42. UNUSED_FUNCTION,
  43. UNUSED_STRUCT,
  44. UNUSED_UNIFORM,
  45. UNUSED_VARYING,
  46. UNUSED_LOCAL_VARIABLE,
  47. FORMATTING_ERROR,
  48. DEVICE_LIMIT_EXCEEDED,
  49. WARNING_MAX,
  50. };
  51. enum CodeFlags : uint32_t {
  52. NONE_FLAG = 0U,
  53. FLOAT_COMPARISON_FLAG = 1U,
  54. UNUSED_CONSTANT_FLAG = 2U,
  55. UNUSED_FUNCTION_FLAG = 4U,
  56. UNUSED_STRUCT_FLAG = 8U,
  57. UNUSED_UNIFORM_FLAG = 16U,
  58. UNUSED_VARYING_FLAG = 32U,
  59. UNUSED_LOCAL_VARIABLE_FLAG = 64U,
  60. FORMATTING_ERROR_FLAG = 128U,
  61. DEVICE_LIMIT_EXCEEDED_FLAG = 256U,
  62. };
  63. private:
  64. Code code;
  65. int line;
  66. StringName subject;
  67. Vector<Variant> extra_args;
  68. public:
  69. Code get_code() const;
  70. int get_line() const;
  71. const StringName &get_subject() const;
  72. String get_message() const;
  73. String get_name() const;
  74. Vector<Variant> get_extra_args() const;
  75. static String get_name_from_code(Code p_code);
  76. static Code get_code_from_name(const String &p_name);
  77. static CodeFlags get_flags_from_codemap(const Map<Code, bool> &p_map);
  78. ShaderWarning(Code p_code = WARNING_MAX, int p_line = -1, const StringName &p_subject = "", const Vector<Variant> &p_extra_args = Vector<Variant>());
  79. };
  80. #endif // DEBUG_ENABLED
  81. #endif // SHADER_WARNINGS