texture_rd.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /**************************************************************************/
  2. /* texture_rd.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. #pragma once
  31. // Note, these classes are part of the Rendering Device based renderer.
  32. // They are included here to ensure the correct order of registration
  33. // is performed.
  34. // Once the renderer has been moved into a module, these classes should
  35. // be moved as well.
  36. #include "scene/resources/texture.h"
  37. class Texture2DRD : public Texture2D {
  38. GDCLASS(Texture2DRD, Texture2D)
  39. mutable RID texture_rid;
  40. RID texture_rd_rid;
  41. Size2i size;
  42. protected:
  43. static void _bind_methods();
  44. public:
  45. virtual int get_width() const override;
  46. virtual int get_height() const override;
  47. virtual RID get_rid() const override;
  48. virtual bool has_alpha() const override;
  49. virtual Ref<Image> get_image() const override;
  50. void set_texture_rd_rid(RID p_texture_rd_rid);
  51. RID get_texture_rd_rid() const;
  52. // Internal function that should only be called from the rendering thread.
  53. void _set_texture_rd_rid(RID p_texture_rd_rid);
  54. Texture2DRD();
  55. ~Texture2DRD();
  56. };
  57. class TextureLayeredRD : public TextureLayered {
  58. GDCLASS(TextureLayeredRD, TextureLayered)
  59. LayeredType layer_type;
  60. mutable RID texture_rid;
  61. RID texture_rd_rid;
  62. Image::Format image_format;
  63. Size2i size;
  64. uint32_t layers = 0;
  65. uint32_t mipmaps = 0;
  66. protected:
  67. static void _bind_methods();
  68. public:
  69. virtual Image::Format get_format() const override;
  70. virtual LayeredType get_layered_type() const override;
  71. virtual int get_width() const override;
  72. virtual int get_height() const override;
  73. virtual int get_layers() const override;
  74. virtual bool has_mipmaps() const override;
  75. virtual RID get_rid() const override;
  76. virtual Ref<Image> get_layer_data(int p_layer) const override;
  77. void set_texture_rd_rid(RID p_texture_rd_rid);
  78. RID get_texture_rd_rid() const;
  79. // Internal function that should only be called from the rendering thread.
  80. void _set_texture_rd_rid(RID p_texture_rd_rid);
  81. TextureLayeredRD(LayeredType p_layer_type);
  82. ~TextureLayeredRD();
  83. };
  84. class Texture2DArrayRD : public TextureLayeredRD {
  85. GDCLASS(Texture2DArrayRD, TextureLayeredRD)
  86. public:
  87. Texture2DArrayRD() :
  88. TextureLayeredRD(LAYERED_TYPE_2D_ARRAY) {}
  89. };
  90. class TextureCubemapRD : public TextureLayeredRD {
  91. GDCLASS(TextureCubemapRD, TextureLayeredRD)
  92. public:
  93. TextureCubemapRD() :
  94. TextureLayeredRD(LAYERED_TYPE_CUBEMAP) {}
  95. };
  96. class TextureCubemapArrayRD : public TextureLayeredRD {
  97. GDCLASS(TextureCubemapArrayRD, TextureLayeredRD)
  98. public:
  99. TextureCubemapArrayRD() :
  100. TextureLayeredRD(LAYERED_TYPE_CUBEMAP_ARRAY) {}
  101. };
  102. class Texture3DRD : public Texture3D {
  103. GDCLASS(Texture3DRD, Texture3D)
  104. mutable RID texture_rid;
  105. RID texture_rd_rid;
  106. Image::Format image_format;
  107. Vector3i size;
  108. uint32_t mipmaps = 0;
  109. protected:
  110. static void _bind_methods();
  111. public:
  112. virtual Image::Format get_format() const override;
  113. virtual int get_width() const override;
  114. virtual int get_height() const override;
  115. virtual int get_depth() const override;
  116. virtual bool has_mipmaps() const override;
  117. virtual RID get_rid() const override;
  118. void set_texture_rd_rid(RID p_texture_rd_rid);
  119. RID get_texture_rd_rid() const;
  120. // Internal function that should only be called from the rendering thread.
  121. void _set_texture_rd_rid(RID p_texture_rd_rid);
  122. Texture3DRD();
  123. ~Texture3DRD();
  124. };