rendering_device.h 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273
  1. /*************************************************************************/
  2. /* rendering_device.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 RENDERING_DEVICE_H
  31. #define RENDERING_DEVICE_H
  32. #include "core/object/class_db.h"
  33. #include "core/variant/typed_array.h"
  34. #include "servers/display_server.h"
  35. class RDTextureFormat;
  36. class RDTextureView;
  37. class RDAttachmentFormat;
  38. class RDSamplerState;
  39. class RDVertexAttribute;
  40. class RDShaderSource;
  41. class RDShaderSPIRV;
  42. class RDUniforms;
  43. class RDPipelineRasterizationState;
  44. class RDPipelineMultisampleState;
  45. class RDPipelineDepthStencilState;
  46. class RDPipelineColorBlendState;
  47. class RDFramebufferPass;
  48. class RDPipelineSpecializationConstant;
  49. class RenderingDevice : public Object {
  50. GDCLASS(RenderingDevice, Object)
  51. public:
  52. enum DeviceFamily {
  53. DEVICE_UNKNOWN,
  54. DEVICE_OPENGL,
  55. DEVICE_VULKAN,
  56. DEVICE_DIRECTX
  57. };
  58. enum DriverResource {
  59. DRIVER_RESOURCE_VULKAN_DEVICE = 0,
  60. DRIVER_RESOURCE_VULKAN_PHYSICAL_DEVICE,
  61. DRIVER_RESOURCE_VULKAN_INSTANCE,
  62. DRIVER_RESOURCE_VULKAN_QUEUE,
  63. DRIVER_RESOURCE_VULKAN_QUEUE_FAMILY_INDEX,
  64. DRIVER_RESOURCE_VULKAN_IMAGE,
  65. DRIVER_RESOURCE_VULKAN_IMAGE_VIEW,
  66. DRIVER_RESOURCE_VULKAN_IMAGE_NATIVE_TEXTURE_FORMAT,
  67. DRIVER_RESOURCE_VULKAN_SAMPLER,
  68. DRIVER_RESOURCE_VULKAN_DESCRIPTOR_SET,
  69. DRIVER_RESOURCE_VULKAN_BUFFER,
  70. DRIVER_RESOURCE_VULKAN_COMPUTE_PIPELINE,
  71. DRIVER_RESOURCE_VULKAN_RENDER_PIPELINE,
  72. //next driver continue enum from 1000 to keep order
  73. };
  74. enum ShaderStage {
  75. SHADER_STAGE_VERTEX,
  76. SHADER_STAGE_FRAGMENT,
  77. SHADER_STAGE_TESSELATION_CONTROL,
  78. SHADER_STAGE_TESSELATION_EVALUATION,
  79. SHADER_STAGE_COMPUTE,
  80. SHADER_STAGE_MAX,
  81. SHADER_STAGE_VERTEX_BIT = (1 << SHADER_STAGE_VERTEX),
  82. SHADER_STAGE_FRAGMENT_BIT = (1 << SHADER_STAGE_FRAGMENT),
  83. SHADER_STAGE_TESSELATION_CONTROL_BIT = (1 << SHADER_STAGE_TESSELATION_CONTROL),
  84. SHADER_STAGE_TESSELATION_EVALUATION_BIT = (1 << SHADER_STAGE_TESSELATION_EVALUATION),
  85. SHADER_STAGE_COMPUTE_BIT = (1 << SHADER_STAGE_COMPUTE),
  86. };
  87. enum ShaderLanguage {
  88. SHADER_LANGUAGE_GLSL,
  89. SHADER_LANGUAGE_HLSL
  90. };
  91. enum SubgroupOperations {
  92. SUBGROUP_BASIC_BIT = 1,
  93. SUBGROUP_VOTE_BIT = 2,
  94. SUBGROUP_ARITHMETIC_BIT = 4,
  95. SUBGROUP_BALLOT_BIT = 8,
  96. SUBGROUP_SHUFFLE_BIT = 16,
  97. SUBGROUP_SHUFFLE_RELATIVE_BIT = 32,
  98. SUBGROUP_CLUSTERED_BIT = 64,
  99. SUBGROUP_QUAD_BIT = 128,
  100. };
  101. struct Capabilities {
  102. // main device info
  103. DeviceFamily device_family = DEVICE_UNKNOWN;
  104. uint32_t version_major = 1.0;
  105. uint32_t version_minor = 0.0;
  106. // subgroup capabilities
  107. uint32_t subgroup_size = 0;
  108. uint32_t subgroup_in_shaders = 0; // Set flags using SHADER_STAGE_VERTEX_BIT, SHADER_STAGE_FRAGMENT_BIT, etc.
  109. uint32_t subgroup_operations = 0; // Set flags, using SubgroupOperations
  110. // features
  111. bool supports_multiview = false; // If true this device supports multiview options
  112. bool supports_fsr_half_float = false; // If true this device supports FSR scaling 3D in half float mode, otherwise use the fallback mode
  113. };
  114. typedef String (*ShaderSPIRVGetCacheKeyFunction)(const Capabilities *p_capabilities);
  115. typedef Vector<uint8_t> (*ShaderCompileToSPIRVFunction)(ShaderStage p_stage, const String &p_source_code, ShaderLanguage p_language, String *r_error, const Capabilities *p_capabilities);
  116. typedef Vector<uint8_t> (*ShaderCacheFunction)(ShaderStage p_stage, const String &p_source_code, ShaderLanguage p_language);
  117. private:
  118. static ShaderCompileToSPIRVFunction compile_to_spirv_function;
  119. static ShaderCacheFunction cache_function;
  120. static ShaderSPIRVGetCacheKeyFunction get_spirv_cache_key_function;
  121. static RenderingDevice *singleton;
  122. protected:
  123. static void _bind_methods();
  124. Capabilities device_capabilities;
  125. public:
  126. //base numeric ID for all types
  127. enum {
  128. INVALID_ID = -1,
  129. INVALID_FORMAT_ID = -1
  130. };
  131. /*****************/
  132. /**** GENERIC ****/
  133. /*****************/
  134. enum CompareOperator {
  135. COMPARE_OP_NEVER,
  136. COMPARE_OP_LESS,
  137. COMPARE_OP_EQUAL,
  138. COMPARE_OP_LESS_OR_EQUAL,
  139. COMPARE_OP_GREATER,
  140. COMPARE_OP_NOT_EQUAL,
  141. COMPARE_OP_GREATER_OR_EQUAL,
  142. COMPARE_OP_ALWAYS,
  143. COMPARE_OP_MAX //not an actual operator, just the amount of operators :D
  144. };
  145. enum DataFormat {
  146. DATA_FORMAT_R4G4_UNORM_PACK8,
  147. DATA_FORMAT_R4G4B4A4_UNORM_PACK16,
  148. DATA_FORMAT_B4G4R4A4_UNORM_PACK16,
  149. DATA_FORMAT_R5G6B5_UNORM_PACK16,
  150. DATA_FORMAT_B5G6R5_UNORM_PACK16,
  151. DATA_FORMAT_R5G5B5A1_UNORM_PACK16,
  152. DATA_FORMAT_B5G5R5A1_UNORM_PACK16,
  153. DATA_FORMAT_A1R5G5B5_UNORM_PACK16,
  154. DATA_FORMAT_R8_UNORM,
  155. DATA_FORMAT_R8_SNORM,
  156. DATA_FORMAT_R8_USCALED,
  157. DATA_FORMAT_R8_SSCALED,
  158. DATA_FORMAT_R8_UINT,
  159. DATA_FORMAT_R8_SINT,
  160. DATA_FORMAT_R8_SRGB,
  161. DATA_FORMAT_R8G8_UNORM,
  162. DATA_FORMAT_R8G8_SNORM,
  163. DATA_FORMAT_R8G8_USCALED,
  164. DATA_FORMAT_R8G8_SSCALED,
  165. DATA_FORMAT_R8G8_UINT,
  166. DATA_FORMAT_R8G8_SINT,
  167. DATA_FORMAT_R8G8_SRGB,
  168. DATA_FORMAT_R8G8B8_UNORM,
  169. DATA_FORMAT_R8G8B8_SNORM,
  170. DATA_FORMAT_R8G8B8_USCALED,
  171. DATA_FORMAT_R8G8B8_SSCALED,
  172. DATA_FORMAT_R8G8B8_UINT,
  173. DATA_FORMAT_R8G8B8_SINT,
  174. DATA_FORMAT_R8G8B8_SRGB,
  175. DATA_FORMAT_B8G8R8_UNORM,
  176. DATA_FORMAT_B8G8R8_SNORM,
  177. DATA_FORMAT_B8G8R8_USCALED,
  178. DATA_FORMAT_B8G8R8_SSCALED,
  179. DATA_FORMAT_B8G8R8_UINT,
  180. DATA_FORMAT_B8G8R8_SINT,
  181. DATA_FORMAT_B8G8R8_SRGB,
  182. DATA_FORMAT_R8G8B8A8_UNORM,
  183. DATA_FORMAT_R8G8B8A8_SNORM,
  184. DATA_FORMAT_R8G8B8A8_USCALED,
  185. DATA_FORMAT_R8G8B8A8_SSCALED,
  186. DATA_FORMAT_R8G8B8A8_UINT,
  187. DATA_FORMAT_R8G8B8A8_SINT,
  188. DATA_FORMAT_R8G8B8A8_SRGB,
  189. DATA_FORMAT_B8G8R8A8_UNORM,
  190. DATA_FORMAT_B8G8R8A8_SNORM,
  191. DATA_FORMAT_B8G8R8A8_USCALED,
  192. DATA_FORMAT_B8G8R8A8_SSCALED,
  193. DATA_FORMAT_B8G8R8A8_UINT,
  194. DATA_FORMAT_B8G8R8A8_SINT,
  195. DATA_FORMAT_B8G8R8A8_SRGB,
  196. DATA_FORMAT_A8B8G8R8_UNORM_PACK32,
  197. DATA_FORMAT_A8B8G8R8_SNORM_PACK32,
  198. DATA_FORMAT_A8B8G8R8_USCALED_PACK32,
  199. DATA_FORMAT_A8B8G8R8_SSCALED_PACK32,
  200. DATA_FORMAT_A8B8G8R8_UINT_PACK32,
  201. DATA_FORMAT_A8B8G8R8_SINT_PACK32,
  202. DATA_FORMAT_A8B8G8R8_SRGB_PACK32,
  203. DATA_FORMAT_A2R10G10B10_UNORM_PACK32,
  204. DATA_FORMAT_A2R10G10B10_SNORM_PACK32,
  205. DATA_FORMAT_A2R10G10B10_USCALED_PACK32,
  206. DATA_FORMAT_A2R10G10B10_SSCALED_PACK32,
  207. DATA_FORMAT_A2R10G10B10_UINT_PACK32,
  208. DATA_FORMAT_A2R10G10B10_SINT_PACK32,
  209. DATA_FORMAT_A2B10G10R10_UNORM_PACK32,
  210. DATA_FORMAT_A2B10G10R10_SNORM_PACK32,
  211. DATA_FORMAT_A2B10G10R10_USCALED_PACK32,
  212. DATA_FORMAT_A2B10G10R10_SSCALED_PACK32,
  213. DATA_FORMAT_A2B10G10R10_UINT_PACK32,
  214. DATA_FORMAT_A2B10G10R10_SINT_PACK32,
  215. DATA_FORMAT_R16_UNORM,
  216. DATA_FORMAT_R16_SNORM,
  217. DATA_FORMAT_R16_USCALED,
  218. DATA_FORMAT_R16_SSCALED,
  219. DATA_FORMAT_R16_UINT,
  220. DATA_FORMAT_R16_SINT,
  221. DATA_FORMAT_R16_SFLOAT,
  222. DATA_FORMAT_R16G16_UNORM,
  223. DATA_FORMAT_R16G16_SNORM,
  224. DATA_FORMAT_R16G16_USCALED,
  225. DATA_FORMAT_R16G16_SSCALED,
  226. DATA_FORMAT_R16G16_UINT,
  227. DATA_FORMAT_R16G16_SINT,
  228. DATA_FORMAT_R16G16_SFLOAT,
  229. DATA_FORMAT_R16G16B16_UNORM,
  230. DATA_FORMAT_R16G16B16_SNORM,
  231. DATA_FORMAT_R16G16B16_USCALED,
  232. DATA_FORMAT_R16G16B16_SSCALED,
  233. DATA_FORMAT_R16G16B16_UINT,
  234. DATA_FORMAT_R16G16B16_SINT,
  235. DATA_FORMAT_R16G16B16_SFLOAT,
  236. DATA_FORMAT_R16G16B16A16_UNORM,
  237. DATA_FORMAT_R16G16B16A16_SNORM,
  238. DATA_FORMAT_R16G16B16A16_USCALED,
  239. DATA_FORMAT_R16G16B16A16_SSCALED,
  240. DATA_FORMAT_R16G16B16A16_UINT,
  241. DATA_FORMAT_R16G16B16A16_SINT,
  242. DATA_FORMAT_R16G16B16A16_SFLOAT,
  243. DATA_FORMAT_R32_UINT,
  244. DATA_FORMAT_R32_SINT,
  245. DATA_FORMAT_R32_SFLOAT,
  246. DATA_FORMAT_R32G32_UINT,
  247. DATA_FORMAT_R32G32_SINT,
  248. DATA_FORMAT_R32G32_SFLOAT,
  249. DATA_FORMAT_R32G32B32_UINT,
  250. DATA_FORMAT_R32G32B32_SINT,
  251. DATA_FORMAT_R32G32B32_SFLOAT,
  252. DATA_FORMAT_R32G32B32A32_UINT,
  253. DATA_FORMAT_R32G32B32A32_SINT,
  254. DATA_FORMAT_R32G32B32A32_SFLOAT,
  255. DATA_FORMAT_R64_UINT,
  256. DATA_FORMAT_R64_SINT,
  257. DATA_FORMAT_R64_SFLOAT,
  258. DATA_FORMAT_R64G64_UINT,
  259. DATA_FORMAT_R64G64_SINT,
  260. DATA_FORMAT_R64G64_SFLOAT,
  261. DATA_FORMAT_R64G64B64_UINT,
  262. DATA_FORMAT_R64G64B64_SINT,
  263. DATA_FORMAT_R64G64B64_SFLOAT,
  264. DATA_FORMAT_R64G64B64A64_UINT,
  265. DATA_FORMAT_R64G64B64A64_SINT,
  266. DATA_FORMAT_R64G64B64A64_SFLOAT,
  267. DATA_FORMAT_B10G11R11_UFLOAT_PACK32,
  268. DATA_FORMAT_E5B9G9R9_UFLOAT_PACK32,
  269. DATA_FORMAT_D16_UNORM,
  270. DATA_FORMAT_X8_D24_UNORM_PACK32,
  271. DATA_FORMAT_D32_SFLOAT,
  272. DATA_FORMAT_S8_UINT,
  273. DATA_FORMAT_D16_UNORM_S8_UINT,
  274. DATA_FORMAT_D24_UNORM_S8_UINT,
  275. DATA_FORMAT_D32_SFLOAT_S8_UINT,
  276. DATA_FORMAT_BC1_RGB_UNORM_BLOCK,
  277. DATA_FORMAT_BC1_RGB_SRGB_BLOCK,
  278. DATA_FORMAT_BC1_RGBA_UNORM_BLOCK,
  279. DATA_FORMAT_BC1_RGBA_SRGB_BLOCK,
  280. DATA_FORMAT_BC2_UNORM_BLOCK,
  281. DATA_FORMAT_BC2_SRGB_BLOCK,
  282. DATA_FORMAT_BC3_UNORM_BLOCK,
  283. DATA_FORMAT_BC3_SRGB_BLOCK,
  284. DATA_FORMAT_BC4_UNORM_BLOCK,
  285. DATA_FORMAT_BC4_SNORM_BLOCK,
  286. DATA_FORMAT_BC5_UNORM_BLOCK,
  287. DATA_FORMAT_BC5_SNORM_BLOCK,
  288. DATA_FORMAT_BC6H_UFLOAT_BLOCK,
  289. DATA_FORMAT_BC6H_SFLOAT_BLOCK,
  290. DATA_FORMAT_BC7_UNORM_BLOCK,
  291. DATA_FORMAT_BC7_SRGB_BLOCK,
  292. DATA_FORMAT_ETC2_R8G8B8_UNORM_BLOCK,
  293. DATA_FORMAT_ETC2_R8G8B8_SRGB_BLOCK,
  294. DATA_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK,
  295. DATA_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK,
  296. DATA_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK,
  297. DATA_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK,
  298. DATA_FORMAT_EAC_R11_UNORM_BLOCK,
  299. DATA_FORMAT_EAC_R11_SNORM_BLOCK,
  300. DATA_FORMAT_EAC_R11G11_UNORM_BLOCK,
  301. DATA_FORMAT_EAC_R11G11_SNORM_BLOCK,
  302. DATA_FORMAT_ASTC_4x4_UNORM_BLOCK,
  303. DATA_FORMAT_ASTC_4x4_SRGB_BLOCK,
  304. DATA_FORMAT_ASTC_5x4_UNORM_BLOCK,
  305. DATA_FORMAT_ASTC_5x4_SRGB_BLOCK,
  306. DATA_FORMAT_ASTC_5x5_UNORM_BLOCK,
  307. DATA_FORMAT_ASTC_5x5_SRGB_BLOCK,
  308. DATA_FORMAT_ASTC_6x5_UNORM_BLOCK,
  309. DATA_FORMAT_ASTC_6x5_SRGB_BLOCK,
  310. DATA_FORMAT_ASTC_6x6_UNORM_BLOCK,
  311. DATA_FORMAT_ASTC_6x6_SRGB_BLOCK,
  312. DATA_FORMAT_ASTC_8x5_UNORM_BLOCK,
  313. DATA_FORMAT_ASTC_8x5_SRGB_BLOCK,
  314. DATA_FORMAT_ASTC_8x6_UNORM_BLOCK,
  315. DATA_FORMAT_ASTC_8x6_SRGB_BLOCK,
  316. DATA_FORMAT_ASTC_8x8_UNORM_BLOCK,
  317. DATA_FORMAT_ASTC_8x8_SRGB_BLOCK,
  318. DATA_FORMAT_ASTC_10x5_UNORM_BLOCK,
  319. DATA_FORMAT_ASTC_10x5_SRGB_BLOCK,
  320. DATA_FORMAT_ASTC_10x6_UNORM_BLOCK,
  321. DATA_FORMAT_ASTC_10x6_SRGB_BLOCK,
  322. DATA_FORMAT_ASTC_10x8_UNORM_BLOCK,
  323. DATA_FORMAT_ASTC_10x8_SRGB_BLOCK,
  324. DATA_FORMAT_ASTC_10x10_UNORM_BLOCK,
  325. DATA_FORMAT_ASTC_10x10_SRGB_BLOCK,
  326. DATA_FORMAT_ASTC_12x10_UNORM_BLOCK,
  327. DATA_FORMAT_ASTC_12x10_SRGB_BLOCK,
  328. DATA_FORMAT_ASTC_12x12_UNORM_BLOCK,
  329. DATA_FORMAT_ASTC_12x12_SRGB_BLOCK,
  330. DATA_FORMAT_G8B8G8R8_422_UNORM,
  331. DATA_FORMAT_B8G8R8G8_422_UNORM,
  332. DATA_FORMAT_G8_B8_R8_3PLANE_420_UNORM,
  333. DATA_FORMAT_G8_B8R8_2PLANE_420_UNORM,
  334. DATA_FORMAT_G8_B8_R8_3PLANE_422_UNORM,
  335. DATA_FORMAT_G8_B8R8_2PLANE_422_UNORM,
  336. DATA_FORMAT_G8_B8_R8_3PLANE_444_UNORM,
  337. DATA_FORMAT_R10X6_UNORM_PACK16,
  338. DATA_FORMAT_R10X6G10X6_UNORM_2PACK16,
  339. DATA_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16,
  340. DATA_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16,
  341. DATA_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16,
  342. DATA_FORMAT_G10X6_B10X6_R10X6_3PLANE_420_UNORM_3PACK16,
  343. DATA_FORMAT_G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16,
  344. DATA_FORMAT_G10X6_B10X6_R10X6_3PLANE_422_UNORM_3PACK16,
  345. DATA_FORMAT_G10X6_B10X6R10X6_2PLANE_422_UNORM_3PACK16,
  346. DATA_FORMAT_G10X6_B10X6_R10X6_3PLANE_444_UNORM_3PACK16,
  347. DATA_FORMAT_R12X4_UNORM_PACK16,
  348. DATA_FORMAT_R12X4G12X4_UNORM_2PACK16,
  349. DATA_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16,
  350. DATA_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16,
  351. DATA_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16,
  352. DATA_FORMAT_G12X4_B12X4_R12X4_3PLANE_420_UNORM_3PACK16,
  353. DATA_FORMAT_G12X4_B12X4R12X4_2PLANE_420_UNORM_3PACK16,
  354. DATA_FORMAT_G12X4_B12X4_R12X4_3PLANE_422_UNORM_3PACK16,
  355. DATA_FORMAT_G12X4_B12X4R12X4_2PLANE_422_UNORM_3PACK16,
  356. DATA_FORMAT_G12X4_B12X4_R12X4_3PLANE_444_UNORM_3PACK16,
  357. DATA_FORMAT_G16B16G16R16_422_UNORM,
  358. DATA_FORMAT_B16G16R16G16_422_UNORM,
  359. DATA_FORMAT_G16_B16_R16_3PLANE_420_UNORM,
  360. DATA_FORMAT_G16_B16R16_2PLANE_420_UNORM,
  361. DATA_FORMAT_G16_B16_R16_3PLANE_422_UNORM,
  362. DATA_FORMAT_G16_B16R16_2PLANE_422_UNORM,
  363. DATA_FORMAT_G16_B16_R16_3PLANE_444_UNORM,
  364. DATA_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG,
  365. DATA_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG,
  366. DATA_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG,
  367. DATA_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG,
  368. DATA_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG,
  369. DATA_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG,
  370. DATA_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG,
  371. DATA_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG,
  372. DATA_FORMAT_MAX
  373. };
  374. /*****************/
  375. /**** BARRIER ****/
  376. /*****************/
  377. enum BarrierMask {
  378. BARRIER_MASK_RASTER = 1,
  379. BARRIER_MASK_COMPUTE = 2,
  380. BARRIER_MASK_TRANSFER = 4,
  381. BARRIER_MASK_NO_BARRIER = 8,
  382. BARRIER_MASK_ALL = BARRIER_MASK_RASTER | BARRIER_MASK_COMPUTE | BARRIER_MASK_TRANSFER
  383. };
  384. /*****************/
  385. /**** TEXTURE ****/
  386. /*****************/
  387. enum TextureType {
  388. TEXTURE_TYPE_1D,
  389. TEXTURE_TYPE_2D,
  390. TEXTURE_TYPE_3D,
  391. TEXTURE_TYPE_CUBE,
  392. TEXTURE_TYPE_1D_ARRAY,
  393. TEXTURE_TYPE_2D_ARRAY,
  394. TEXTURE_TYPE_CUBE_ARRAY,
  395. TEXTURE_TYPE_MAX
  396. };
  397. enum TextureSamples {
  398. TEXTURE_SAMPLES_1,
  399. TEXTURE_SAMPLES_2,
  400. TEXTURE_SAMPLES_4,
  401. TEXTURE_SAMPLES_8,
  402. TEXTURE_SAMPLES_16,
  403. TEXTURE_SAMPLES_32,
  404. TEXTURE_SAMPLES_64,
  405. TEXTURE_SAMPLES_MAX
  406. };
  407. enum TextureUsageBits {
  408. TEXTURE_USAGE_SAMPLING_BIT = (1 << 0),
  409. TEXTURE_USAGE_COLOR_ATTACHMENT_BIT = (1 << 1),
  410. TEXTURE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT = (1 << 2),
  411. TEXTURE_USAGE_STORAGE_BIT = (1 << 3),
  412. TEXTURE_USAGE_STORAGE_ATOMIC_BIT = (1 << 4),
  413. TEXTURE_USAGE_CPU_READ_BIT = (1 << 5),
  414. TEXTURE_USAGE_CAN_UPDATE_BIT = (1 << 6),
  415. TEXTURE_USAGE_CAN_COPY_FROM_BIT = (1 << 7),
  416. TEXTURE_USAGE_CAN_COPY_TO_BIT = (1 << 8),
  417. TEXTURE_USAGE_INPUT_ATTACHMENT_BIT = (1 << 9),
  418. };
  419. enum TextureSwizzle {
  420. TEXTURE_SWIZZLE_IDENTITY,
  421. TEXTURE_SWIZZLE_ZERO,
  422. TEXTURE_SWIZZLE_ONE,
  423. TEXTURE_SWIZZLE_R,
  424. TEXTURE_SWIZZLE_G,
  425. TEXTURE_SWIZZLE_B,
  426. TEXTURE_SWIZZLE_A,
  427. TEXTURE_SWIZZLE_MAX
  428. };
  429. struct TextureFormat {
  430. DataFormat format;
  431. uint32_t width;
  432. uint32_t height;
  433. uint32_t depth;
  434. uint32_t array_layers;
  435. uint32_t mipmaps;
  436. TextureType texture_type;
  437. TextureSamples samples;
  438. uint32_t usage_bits;
  439. Vector<DataFormat> shareable_formats;
  440. TextureFormat() {
  441. format = DATA_FORMAT_R8_UNORM;
  442. width = 1;
  443. height = 1;
  444. depth = 1;
  445. array_layers = 1;
  446. mipmaps = 1;
  447. texture_type = TEXTURE_TYPE_2D;
  448. samples = TEXTURE_SAMPLES_1;
  449. usage_bits = 0;
  450. }
  451. };
  452. struct TextureView {
  453. DataFormat format_override;
  454. TextureSwizzle swizzle_r;
  455. TextureSwizzle swizzle_g;
  456. TextureSwizzle swizzle_b;
  457. TextureSwizzle swizzle_a;
  458. TextureView() {
  459. format_override = DATA_FORMAT_MAX; //means, use same as format
  460. swizzle_r = TEXTURE_SWIZZLE_R;
  461. swizzle_g = TEXTURE_SWIZZLE_G;
  462. swizzle_b = TEXTURE_SWIZZLE_B;
  463. swizzle_a = TEXTURE_SWIZZLE_A;
  464. }
  465. };
  466. virtual RID texture_create(const TextureFormat &p_format, const TextureView &p_view, const Vector<Vector<uint8_t>> &p_data = Vector<Vector<uint8_t>>()) = 0;
  467. virtual RID texture_create_shared(const TextureView &p_view, RID p_with_texture) = 0;
  468. enum TextureSliceType {
  469. TEXTURE_SLICE_2D,
  470. TEXTURE_SLICE_CUBEMAP,
  471. TEXTURE_SLICE_3D,
  472. TEXTURE_SLICE_2D_ARRAY,
  473. };
  474. virtual RID texture_create_shared_from_slice(const TextureView &p_view, RID p_with_texture, uint32_t p_layer, uint32_t p_mipmap, TextureSliceType p_slice_type = TEXTURE_SLICE_2D) = 0;
  475. virtual Error texture_update(RID p_texture, uint32_t p_layer, const Vector<uint8_t> &p_data, uint32_t p_post_barrier = BARRIER_MASK_ALL) = 0;
  476. virtual Vector<uint8_t> texture_get_data(RID p_texture, uint32_t p_layer) = 0; // CPU textures will return immediately, while GPU textures will most likely force a flush
  477. virtual bool texture_is_format_supported_for_usage(DataFormat p_format, uint32_t p_usage) const = 0;
  478. virtual bool texture_is_shared(RID p_texture) = 0;
  479. virtual bool texture_is_valid(RID p_texture) = 0;
  480. virtual Size2i texture_size(RID p_texture) = 0;
  481. virtual Error texture_copy(RID p_from_texture, RID p_to_texture, const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_size, uint32_t p_src_mipmap, uint32_t p_dst_mipmap, uint32_t p_src_layer, uint32_t p_dst_layer, uint32_t p_post_barrier = BARRIER_MASK_ALL) = 0;
  482. virtual Error texture_clear(RID p_texture, const Color &p_color, uint32_t p_base_mipmap, uint32_t p_mipmaps, uint32_t p_base_layer, uint32_t p_layers, uint32_t p_post_barrier = BARRIER_MASK_ALL) = 0;
  483. virtual Error texture_resolve_multisample(RID p_from_texture, RID p_to_texture, uint32_t p_post_barrier = BARRIER_MASK_ALL) = 0;
  484. /*********************/
  485. /**** FRAMEBUFFER ****/
  486. /*********************/
  487. struct AttachmentFormat {
  488. DataFormat format;
  489. TextureSamples samples;
  490. uint32_t usage_flags;
  491. AttachmentFormat() {
  492. format = DATA_FORMAT_R8G8B8A8_UNORM;
  493. samples = TEXTURE_SAMPLES_1;
  494. usage_flags = 0;
  495. }
  496. };
  497. typedef int64_t FramebufferFormatID;
  498. // This ID is warranted to be unique for the same formats, does not need to be freed
  499. virtual FramebufferFormatID framebuffer_format_create(const Vector<AttachmentFormat> &p_format, uint32_t p_view_count = 1) = 0;
  500. struct FramebufferPass {
  501. enum {
  502. ATTACHMENT_UNUSED = -1
  503. };
  504. Vector<int32_t> color_attachments;
  505. Vector<int32_t> input_attachments;
  506. Vector<int32_t> resolve_attachments;
  507. Vector<int32_t> preserve_attachments;
  508. int32_t depth_attachment = ATTACHMENT_UNUSED;
  509. };
  510. virtual FramebufferFormatID framebuffer_format_create_multipass(const Vector<AttachmentFormat> &p_attachments, Vector<FramebufferPass> &p_passes, uint32_t p_view_count = 1) = 0;
  511. virtual FramebufferFormatID framebuffer_format_create_empty(TextureSamples p_samples = TEXTURE_SAMPLES_1) = 0;
  512. virtual TextureSamples framebuffer_format_get_texture_samples(FramebufferFormatID p_format, uint32_t p_pass = 0) = 0;
  513. virtual RID framebuffer_create(const Vector<RID> &p_texture_attachments, FramebufferFormatID p_format_check = INVALID_ID, uint32_t p_view_count = 1) = 0;
  514. virtual RID framebuffer_create_multipass(const Vector<RID> &p_texture_attachments, Vector<FramebufferPass> &p_passes, FramebufferFormatID p_format_check = INVALID_ID, uint32_t p_view_count = 1) = 0;
  515. virtual RID framebuffer_create_empty(const Size2i &p_size, TextureSamples p_samples = TEXTURE_SAMPLES_1, FramebufferFormatID p_format_check = INVALID_ID) = 0;
  516. virtual FramebufferFormatID framebuffer_get_format(RID p_framebuffer) = 0;
  517. /*****************/
  518. /**** SAMPLER ****/
  519. /*****************/
  520. enum SamplerFilter {
  521. SAMPLER_FILTER_NEAREST,
  522. SAMPLER_FILTER_LINEAR,
  523. };
  524. enum SamplerRepeatMode {
  525. SAMPLER_REPEAT_MODE_REPEAT,
  526. SAMPLER_REPEAT_MODE_MIRRORED_REPEAT,
  527. SAMPLER_REPEAT_MODE_CLAMP_TO_EDGE,
  528. SAMPLER_REPEAT_MODE_CLAMP_TO_BORDER,
  529. SAMPLER_REPEAT_MODE_MIRROR_CLAMP_TO_EDGE,
  530. SAMPLER_REPEAT_MODE_MAX
  531. };
  532. enum SamplerBorderColor {
  533. SAMPLER_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK,
  534. SAMPLER_BORDER_COLOR_INT_TRANSPARENT_BLACK,
  535. SAMPLER_BORDER_COLOR_FLOAT_OPAQUE_BLACK,
  536. SAMPLER_BORDER_COLOR_INT_OPAQUE_BLACK,
  537. SAMPLER_BORDER_COLOR_FLOAT_OPAQUE_WHITE,
  538. SAMPLER_BORDER_COLOR_INT_OPAQUE_WHITE,
  539. SAMPLER_BORDER_COLOR_MAX
  540. };
  541. struct SamplerState {
  542. SamplerFilter mag_filter;
  543. SamplerFilter min_filter;
  544. SamplerFilter mip_filter;
  545. SamplerRepeatMode repeat_u;
  546. SamplerRepeatMode repeat_v;
  547. SamplerRepeatMode repeat_w;
  548. float lod_bias;
  549. bool use_anisotropy;
  550. float anisotropy_max;
  551. bool enable_compare;
  552. CompareOperator compare_op;
  553. float min_lod;
  554. float max_lod;
  555. SamplerBorderColor border_color;
  556. bool unnormalized_uvw;
  557. SamplerState() {
  558. mag_filter = SAMPLER_FILTER_NEAREST;
  559. min_filter = SAMPLER_FILTER_NEAREST;
  560. mip_filter = SAMPLER_FILTER_NEAREST;
  561. repeat_u = SAMPLER_REPEAT_MODE_CLAMP_TO_EDGE;
  562. repeat_v = SAMPLER_REPEAT_MODE_CLAMP_TO_EDGE;
  563. repeat_w = SAMPLER_REPEAT_MODE_CLAMP_TO_EDGE;
  564. lod_bias = 0;
  565. use_anisotropy = false;
  566. anisotropy_max = 1.0;
  567. enable_compare = false;
  568. compare_op = COMPARE_OP_ALWAYS;
  569. min_lod = 0;
  570. max_lod = 1e20; //something very large should do
  571. border_color = SAMPLER_BORDER_COLOR_FLOAT_OPAQUE_BLACK;
  572. unnormalized_uvw = false;
  573. }
  574. };
  575. virtual RID sampler_create(const SamplerState &p_state) = 0;
  576. /**********************/
  577. /**** VERTEX ARRAY ****/
  578. /**********************/
  579. enum VertexFrequency {
  580. VERTEX_FREQUENCY_VERTEX,
  581. VERTEX_FREQUENCY_INSTANCE,
  582. };
  583. struct VertexAttribute {
  584. uint32_t location; //shader location
  585. uint32_t offset;
  586. DataFormat format;
  587. uint32_t stride;
  588. VertexFrequency frequency;
  589. VertexAttribute() {
  590. location = 0;
  591. offset = 0;
  592. stride = 0;
  593. format = DATA_FORMAT_MAX;
  594. frequency = VERTEX_FREQUENCY_VERTEX;
  595. }
  596. };
  597. virtual RID vertex_buffer_create(uint32_t p_size_bytes, const Vector<uint8_t> &p_data = Vector<uint8_t>(), bool p_use_as_storage = false) = 0;
  598. typedef int64_t VertexFormatID;
  599. // This ID is warranted to be unique for the same formats, does not need to be freed
  600. virtual VertexFormatID vertex_format_create(const Vector<VertexAttribute> &p_vertex_formats) = 0;
  601. virtual RID vertex_array_create(uint32_t p_vertex_count, VertexFormatID p_vertex_format, const Vector<RID> &p_src_buffers) = 0;
  602. enum IndexBufferFormat {
  603. INDEX_BUFFER_FORMAT_UINT16,
  604. INDEX_BUFFER_FORMAT_UINT32,
  605. };
  606. virtual RID index_buffer_create(uint32_t p_size_indices, IndexBufferFormat p_format, const Vector<uint8_t> &p_data = Vector<uint8_t>(), bool p_use_restart_indices = false) = 0;
  607. virtual RID index_array_create(RID p_index_buffer, uint32_t p_index_offset, uint32_t p_index_count) = 0;
  608. /****************/
  609. /**** SHADER ****/
  610. /****************/
  611. const Capabilities *get_device_capabilities() const { return &device_capabilities; };
  612. virtual Vector<uint8_t> shader_compile_spirv_from_source(ShaderStage p_stage, const String &p_source_code, ShaderLanguage p_language = SHADER_LANGUAGE_GLSL, String *r_error = nullptr, bool p_allow_cache = true);
  613. virtual String shader_get_spirv_cache_key() const;
  614. static void shader_set_compile_to_spirv_function(ShaderCompileToSPIRVFunction p_function);
  615. static void shader_set_spirv_cache_function(ShaderCacheFunction p_function);
  616. static void shader_set_get_cache_key_function(ShaderSPIRVGetCacheKeyFunction p_function);
  617. struct ShaderStageSPIRVData {
  618. ShaderStage shader_stage;
  619. Vector<uint8_t> spir_v;
  620. ShaderStageSPIRVData() {
  621. shader_stage = SHADER_STAGE_VERTEX;
  622. }
  623. };
  624. virtual String shader_get_binary_cache_key() const = 0;
  625. virtual Vector<uint8_t> shader_compile_binary_from_spirv(const Vector<ShaderStageSPIRVData> &p_spirv, const String &p_shader_name = "") = 0;
  626. virtual RID shader_create_from_spirv(const Vector<ShaderStageSPIRVData> &p_spirv, const String &p_shader_name = "");
  627. virtual RID shader_create_from_bytecode(const Vector<uint8_t> &p_shader_binary) = 0;
  628. virtual uint32_t shader_get_vertex_input_attribute_mask(RID p_shader) = 0;
  629. /******************/
  630. /**** UNIFORMS ****/
  631. /******************/
  632. enum UniformType {
  633. UNIFORM_TYPE_SAMPLER, //for sampling only (sampler GLSL type)
  634. UNIFORM_TYPE_SAMPLER_WITH_TEXTURE, // for sampling only, but includes a texture, (samplerXX GLSL type), first a sampler then a texture
  635. UNIFORM_TYPE_TEXTURE, //only texture, (textureXX GLSL type)
  636. UNIFORM_TYPE_IMAGE, // storage image (imageXX GLSL type), for compute mostly
  637. UNIFORM_TYPE_TEXTURE_BUFFER, // buffer texture (or TBO, textureBuffer type)
  638. UNIFORM_TYPE_SAMPLER_WITH_TEXTURE_BUFFER, // buffer texture with a sampler(or TBO, samplerBuffer type)
  639. UNIFORM_TYPE_IMAGE_BUFFER, //texel buffer, (imageBuffer type), for compute mostly
  640. UNIFORM_TYPE_UNIFORM_BUFFER, //regular uniform buffer (or UBO).
  641. UNIFORM_TYPE_STORAGE_BUFFER, //storage buffer ("buffer" qualifier) like UBO, but supports storage, for compute mostly
  642. UNIFORM_TYPE_INPUT_ATTACHMENT, //used for sub-pass read/write, for mobile mostly
  643. UNIFORM_TYPE_MAX
  644. };
  645. enum StorageBufferUsage {
  646. STORAGE_BUFFER_USAGE_DISPATCH_INDIRECT = 1
  647. };
  648. virtual RID uniform_buffer_create(uint32_t p_size_bytes, const Vector<uint8_t> &p_data = Vector<uint8_t>()) = 0;
  649. virtual RID storage_buffer_create(uint32_t p_size, const Vector<uint8_t> &p_data = Vector<uint8_t>(), uint32_t p_usage = 0) = 0;
  650. virtual RID texture_buffer_create(uint32_t p_size_elements, DataFormat p_format, const Vector<uint8_t> &p_data = Vector<uint8_t>()) = 0;
  651. struct Uniform {
  652. UniformType uniform_type;
  653. int binding; //binding index as specified in shader
  654. //for single items, provide one ID, for
  655. //multiple items (declared as arrays in shader),
  656. //provide more
  657. //for sampler with texture, supply two IDs for each.
  658. //accepted IDs are: Sampler, Texture, Uniform Buffer and Texture Buffer
  659. Vector<RID> ids;
  660. Uniform() {
  661. uniform_type = UNIFORM_TYPE_IMAGE;
  662. binding = 0;
  663. }
  664. };
  665. virtual RID uniform_set_create(const Vector<Uniform> &p_uniforms, RID p_shader, uint32_t p_shader_set) = 0;
  666. virtual bool uniform_set_is_valid(RID p_uniform_set) = 0;
  667. typedef void (*UniformSetInvalidatedCallback)(const RID &, void *);
  668. virtual void uniform_set_set_invalidation_callback(RID p_uniform_set, UniformSetInvalidatedCallback p_callback, void *p_userdata) = 0;
  669. virtual Error buffer_update(RID p_buffer, uint32_t p_offset, uint32_t p_size, const void *p_data, uint32_t p_post_barrier = BARRIER_MASK_ALL) = 0;
  670. virtual Error buffer_clear(RID p_buffer, uint32_t p_offset, uint32_t p_size, uint32_t p_post_barrier = BARRIER_MASK_ALL) = 0;
  671. virtual Vector<uint8_t> buffer_get_data(RID p_buffer) = 0; //this causes stall, only use to retrieve large buffers for saving
  672. /******************************************/
  673. /**** PIPELINE SPECIALIZATION CONSTANT ****/
  674. /******************************************/
  675. enum PipelineSpecializationConstantType {
  676. PIPELINE_SPECIALIZATION_CONSTANT_TYPE_BOOL,
  677. PIPELINE_SPECIALIZATION_CONSTANT_TYPE_INT,
  678. PIPELINE_SPECIALIZATION_CONSTANT_TYPE_FLOAT,
  679. };
  680. struct PipelineSpecializationConstant {
  681. PipelineSpecializationConstantType type;
  682. uint32_t constant_id;
  683. union {
  684. uint32_t int_value;
  685. float float_value;
  686. bool bool_value;
  687. };
  688. PipelineSpecializationConstant() {
  689. type = PIPELINE_SPECIALIZATION_CONSTANT_TYPE_BOOL;
  690. constant_id = 0;
  691. int_value = 0;
  692. }
  693. };
  694. /*************************/
  695. /**** RENDER PIPELINE ****/
  696. /*************************/
  697. enum RenderPrimitive {
  698. RENDER_PRIMITIVE_POINTS,
  699. RENDER_PRIMITIVE_LINES,
  700. RENDER_PRIMITIVE_LINES_WITH_ADJACENCY,
  701. RENDER_PRIMITIVE_LINESTRIPS,
  702. RENDER_PRIMITIVE_LINESTRIPS_WITH_ADJACENCY,
  703. RENDER_PRIMITIVE_TRIANGLES,
  704. RENDER_PRIMITIVE_TRIANGLES_WITH_ADJACENCY,
  705. RENDER_PRIMITIVE_TRIANGLE_STRIPS,
  706. RENDER_PRIMITIVE_TRIANGLE_STRIPS_WITH_AJACENCY,
  707. RENDER_PRIMITIVE_TRIANGLE_STRIPS_WITH_RESTART_INDEX,
  708. RENDER_PRIMITIVE_TESSELATION_PATCH,
  709. RENDER_PRIMITIVE_MAX
  710. };
  711. //disable optimization, tessellate control points
  712. enum PolygonCullMode {
  713. POLYGON_CULL_DISABLED,
  714. POLYGON_CULL_FRONT,
  715. POLYGON_CULL_BACK,
  716. };
  717. enum PolygonFrontFace {
  718. POLYGON_FRONT_FACE_CLOCKWISE,
  719. POLYGON_FRONT_FACE_COUNTER_CLOCKWISE,
  720. };
  721. enum StencilOperation {
  722. STENCIL_OP_KEEP,
  723. STENCIL_OP_ZERO,
  724. STENCIL_OP_REPLACE,
  725. STENCIL_OP_INCREMENT_AND_CLAMP,
  726. STENCIL_OP_DECREMENT_AND_CLAMP,
  727. STENCIL_OP_INVERT,
  728. STENCIL_OP_INCREMENT_AND_WRAP,
  729. STENCIL_OP_DECREMENT_AND_WRAP,
  730. STENCIL_OP_MAX //not an actual operator, just the amount of operators :D
  731. };
  732. enum LogicOperation {
  733. LOGIC_OP_CLEAR,
  734. LOGIC_OP_AND,
  735. LOGIC_OP_AND_REVERSE,
  736. LOGIC_OP_COPY,
  737. LOGIC_OP_AND_INVERTED,
  738. LOGIC_OP_NO_OP,
  739. LOGIC_OP_XOR,
  740. LOGIC_OP_OR,
  741. LOGIC_OP_NOR,
  742. LOGIC_OP_EQUIVALENT,
  743. LOGIC_OP_INVERT,
  744. LOGIC_OP_OR_REVERSE,
  745. LOGIC_OP_COPY_INVERTED,
  746. LOGIC_OP_OR_INVERTED,
  747. LOGIC_OP_NAND,
  748. LOGIC_OP_SET,
  749. LOGIC_OP_MAX //not an actual operator, just the amount of operators :D
  750. };
  751. enum BlendFactor {
  752. BLEND_FACTOR_ZERO,
  753. BLEND_FACTOR_ONE,
  754. BLEND_FACTOR_SRC_COLOR,
  755. BLEND_FACTOR_ONE_MINUS_SRC_COLOR,
  756. BLEND_FACTOR_DST_COLOR,
  757. BLEND_FACTOR_ONE_MINUS_DST_COLOR,
  758. BLEND_FACTOR_SRC_ALPHA,
  759. BLEND_FACTOR_ONE_MINUS_SRC_ALPHA,
  760. BLEND_FACTOR_DST_ALPHA,
  761. BLEND_FACTOR_ONE_MINUS_DST_ALPHA,
  762. BLEND_FACTOR_CONSTANT_COLOR,
  763. BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR,
  764. BLEND_FACTOR_CONSTANT_ALPHA,
  765. BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA,
  766. BLEND_FACTOR_SRC_ALPHA_SATURATE,
  767. BLEND_FACTOR_SRC1_COLOR,
  768. BLEND_FACTOR_ONE_MINUS_SRC1_COLOR,
  769. BLEND_FACTOR_SRC1_ALPHA,
  770. BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA,
  771. BLEND_FACTOR_MAX
  772. };
  773. enum BlendOperation {
  774. BLEND_OP_ADD,
  775. BLEND_OP_SUBTRACT,
  776. BLEND_OP_REVERSE_SUBTRACT,
  777. BLEND_OP_MINIMUM,
  778. BLEND_OP_MAXIMUM, //yes this one is an actual operator
  779. BLEND_OP_MAX //not an actual operator, just the amount of operators :D
  780. };
  781. struct PipelineRasterizationState {
  782. bool enable_depth_clamp;
  783. bool discard_primitives;
  784. bool wireframe;
  785. PolygonCullMode cull_mode;
  786. PolygonFrontFace front_face;
  787. bool depth_bias_enable;
  788. float depth_bias_constant_factor;
  789. float depth_bias_clamp;
  790. float depth_bias_slope_factor;
  791. float line_width;
  792. uint32_t patch_control_points;
  793. PipelineRasterizationState() {
  794. enable_depth_clamp = false;
  795. discard_primitives = false;
  796. wireframe = false;
  797. cull_mode = POLYGON_CULL_DISABLED;
  798. front_face = POLYGON_FRONT_FACE_CLOCKWISE;
  799. depth_bias_enable = false;
  800. depth_bias_constant_factor = 0;
  801. depth_bias_clamp = 0;
  802. depth_bias_slope_factor = 0;
  803. line_width = 1.0;
  804. patch_control_points = 1;
  805. }
  806. };
  807. struct PipelineMultisampleState {
  808. TextureSamples sample_count;
  809. bool enable_sample_shading;
  810. float min_sample_shading;
  811. Vector<uint32_t> sample_mask;
  812. bool enable_alpha_to_coverage;
  813. bool enable_alpha_to_one;
  814. PipelineMultisampleState() {
  815. sample_count = TEXTURE_SAMPLES_1;
  816. enable_sample_shading = false;
  817. min_sample_shading = 0;
  818. enable_alpha_to_coverage = false;
  819. enable_alpha_to_one = false;
  820. }
  821. };
  822. struct PipelineDepthStencilState {
  823. bool enable_depth_test;
  824. bool enable_depth_write;
  825. CompareOperator depth_compare_operator;
  826. bool enable_depth_range;
  827. float depth_range_min;
  828. float depth_range_max;
  829. bool enable_stencil;
  830. struct StencilOperationState {
  831. StencilOperation fail;
  832. StencilOperation pass;
  833. StencilOperation depth_fail;
  834. CompareOperator compare;
  835. uint32_t compare_mask;
  836. uint32_t write_mask;
  837. uint32_t reference;
  838. StencilOperationState() {
  839. fail = STENCIL_OP_ZERO;
  840. pass = STENCIL_OP_ZERO;
  841. depth_fail = STENCIL_OP_ZERO;
  842. compare = COMPARE_OP_ALWAYS;
  843. compare_mask = 0;
  844. write_mask = 0;
  845. reference = 0;
  846. }
  847. };
  848. StencilOperationState front_op;
  849. StencilOperationState back_op;
  850. PipelineDepthStencilState() {
  851. enable_depth_test = false;
  852. enable_depth_write = false;
  853. depth_compare_operator = COMPARE_OP_ALWAYS;
  854. enable_depth_range = false;
  855. depth_range_min = 0;
  856. depth_range_max = 0;
  857. enable_stencil = false;
  858. }
  859. };
  860. struct PipelineColorBlendState {
  861. bool enable_logic_op;
  862. LogicOperation logic_op;
  863. struct Attachment {
  864. bool enable_blend;
  865. BlendFactor src_color_blend_factor;
  866. BlendFactor dst_color_blend_factor;
  867. BlendOperation color_blend_op;
  868. BlendFactor src_alpha_blend_factor;
  869. BlendFactor dst_alpha_blend_factor;
  870. BlendOperation alpha_blend_op;
  871. bool write_r;
  872. bool write_g;
  873. bool write_b;
  874. bool write_a;
  875. Attachment() {
  876. enable_blend = false;
  877. src_color_blend_factor = BLEND_FACTOR_ZERO;
  878. dst_color_blend_factor = BLEND_FACTOR_ZERO;
  879. color_blend_op = BLEND_OP_ADD;
  880. src_alpha_blend_factor = BLEND_FACTOR_ZERO;
  881. dst_alpha_blend_factor = BLEND_FACTOR_ZERO;
  882. alpha_blend_op = BLEND_OP_ADD;
  883. write_r = true;
  884. write_g = true;
  885. write_b = true;
  886. write_a = true;
  887. }
  888. };
  889. static PipelineColorBlendState create_disabled(int p_attachments = 1) {
  890. PipelineColorBlendState bs;
  891. for (int i = 0; i < p_attachments; i++) {
  892. bs.attachments.push_back(Attachment());
  893. }
  894. return bs;
  895. }
  896. static PipelineColorBlendState create_blend(int p_attachments = 1) {
  897. PipelineColorBlendState bs;
  898. for (int i = 0; i < p_attachments; i++) {
  899. Attachment ba;
  900. ba.enable_blend = true;
  901. ba.src_color_blend_factor = BLEND_FACTOR_SRC_ALPHA;
  902. ba.dst_color_blend_factor = BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
  903. ba.src_alpha_blend_factor = BLEND_FACTOR_SRC_ALPHA;
  904. ba.dst_alpha_blend_factor = BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
  905. bs.attachments.push_back(ba);
  906. }
  907. return bs;
  908. }
  909. Vector<Attachment> attachments; //one per render target texture
  910. Color blend_constant;
  911. PipelineColorBlendState() {
  912. enable_logic_op = false;
  913. logic_op = LOGIC_OP_CLEAR;
  914. }
  915. };
  916. enum PipelineDynamicStateFlags {
  917. DYNAMIC_STATE_LINE_WIDTH = (1 << 0),
  918. DYNAMIC_STATE_DEPTH_BIAS = (1 << 1),
  919. DYNAMIC_STATE_BLEND_CONSTANTS = (1 << 2),
  920. DYNAMIC_STATE_DEPTH_BOUNDS = (1 << 3),
  921. DYNAMIC_STATE_STENCIL_COMPARE_MASK = (1 << 4),
  922. DYNAMIC_STATE_STENCIL_WRITE_MASK = (1 << 5),
  923. DYNAMIC_STATE_STENCIL_REFERENCE = (1 << 6),
  924. };
  925. virtual bool render_pipeline_is_valid(RID p_pipeline) = 0;
  926. virtual RID render_pipeline_create(RID p_shader, FramebufferFormatID p_framebuffer_format, VertexFormatID p_vertex_format, RenderPrimitive p_render_primitive, const PipelineRasterizationState &p_rasterization_state, const PipelineMultisampleState &p_multisample_state, const PipelineDepthStencilState &p_depth_stencil_state, const PipelineColorBlendState &p_blend_state, int p_dynamic_state_flags = 0, uint32_t p_for_render_pass = 0, const Vector<PipelineSpecializationConstant> &p_specialization_constants = Vector<PipelineSpecializationConstant>()) = 0;
  927. /**************************/
  928. /**** COMPUTE PIPELINE ****/
  929. /**************************/
  930. virtual RID compute_pipeline_create(RID p_shader, const Vector<PipelineSpecializationConstant> &p_specialization_constants = Vector<PipelineSpecializationConstant>()) = 0;
  931. virtual bool compute_pipeline_is_valid(RID p_pipeline) = 0;
  932. /****************/
  933. /**** SCREEN ****/
  934. /****************/
  935. virtual int screen_get_width(DisplayServer::WindowID p_screen = 0) const = 0;
  936. virtual int screen_get_height(DisplayServer::WindowID p_screen = 0) const = 0;
  937. virtual FramebufferFormatID screen_get_framebuffer_format() const = 0;
  938. /********************/
  939. /**** DRAW LISTS ****/
  940. /********************/
  941. enum InitialAction {
  942. INITIAL_ACTION_CLEAR, //start rendering and clear the whole framebuffer (region or not) (supply params)
  943. INITIAL_ACTION_CLEAR_REGION, //start rendering and clear the framebuffer in the specified region (supply params)
  944. INITIAL_ACTION_CLEAR_REGION_CONTINUE, //continue rendering and clear the framebuffer in the specified region (supply params)
  945. INITIAL_ACTION_KEEP, //start rendering, but keep attached color texture contents (depth will be cleared)
  946. INITIAL_ACTION_DROP, //start rendering, ignore what is there, just write above it
  947. INITIAL_ACTION_CONTINUE, //continue rendering (framebuffer must have been left in "continue" state as final action previously)
  948. INITIAL_ACTION_MAX
  949. };
  950. enum FinalAction {
  951. FINAL_ACTION_READ, //will no longer render to it, allows attached textures to be read again, but depth buffer contents will be dropped (Can't be read from)
  952. FINAL_ACTION_DISCARD, // discard contents after rendering
  953. FINAL_ACTION_CONTINUE, //will continue rendering later, attached textures can't be read until re-bound with "finish"
  954. FINAL_ACTION_MAX
  955. };
  956. typedef int64_t DrawListID;
  957. virtual DrawListID draw_list_begin_for_screen(DisplayServer::WindowID p_screen = 0, const Color &p_clear_color = Color()) = 0;
  958. virtual DrawListID draw_list_begin(RID p_framebuffer, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, const Vector<Color> &p_clear_color_values = Vector<Color>(), float p_clear_depth = 1.0, uint32_t p_clear_stencil = 0, const Rect2 &p_region = Rect2(), const Vector<RID> &p_storage_textures = Vector<RID>()) = 0;
  959. virtual Error draw_list_begin_split(RID p_framebuffer, uint32_t p_splits, DrawListID *r_split_ids, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, const Vector<Color> &p_clear_color_values = Vector<Color>(), float p_clear_depth = 1.0, uint32_t p_clear_stencil = 0, const Rect2 &p_region = Rect2(), const Vector<RID> &p_storage_textures = Vector<RID>()) = 0;
  960. virtual void draw_list_bind_render_pipeline(DrawListID p_list, RID p_render_pipeline) = 0;
  961. virtual void draw_list_bind_uniform_set(DrawListID p_list, RID p_uniform_set, uint32_t p_index) = 0;
  962. virtual void draw_list_bind_vertex_array(DrawListID p_list, RID p_vertex_array) = 0;
  963. virtual void draw_list_bind_index_array(DrawListID p_list, RID p_index_array) = 0;
  964. virtual void draw_list_set_line_width(DrawListID p_list, float p_width) = 0;
  965. virtual void draw_list_set_push_constant(DrawListID p_list, const void *p_data, uint32_t p_data_size) = 0;
  966. virtual void draw_list_draw(DrawListID p_list, bool p_use_indices, uint32_t p_instances = 1, uint32_t p_procedural_vertices = 0) = 0;
  967. virtual void draw_list_enable_scissor(DrawListID p_list, const Rect2 &p_rect) = 0;
  968. virtual void draw_list_disable_scissor(DrawListID p_list) = 0;
  969. virtual uint32_t draw_list_get_current_pass() = 0;
  970. virtual DrawListID draw_list_switch_to_next_pass() = 0;
  971. virtual Error draw_list_switch_to_next_pass_split(uint32_t p_splits, DrawListID *r_split_ids) = 0;
  972. virtual void draw_list_end(uint32_t p_post_barrier = BARRIER_MASK_ALL) = 0;
  973. /***********************/
  974. /**** COMPUTE LISTS ****/
  975. /***********************/
  976. typedef int64_t ComputeListID;
  977. virtual ComputeListID compute_list_begin(bool p_allow_draw_overlap = false) = 0;
  978. virtual void compute_list_bind_compute_pipeline(ComputeListID p_list, RID p_compute_pipeline) = 0;
  979. virtual void compute_list_bind_uniform_set(ComputeListID p_list, RID p_uniform_set, uint32_t p_index) = 0;
  980. virtual void compute_list_set_push_constant(ComputeListID p_list, const void *p_data, uint32_t p_data_size) = 0;
  981. virtual void compute_list_dispatch(ComputeListID p_list, uint32_t p_x_groups, uint32_t p_y_groups, uint32_t p_z_groups) = 0;
  982. virtual void compute_list_dispatch_threads(ComputeListID p_list, uint32_t p_x_threads, uint32_t p_y_threads, uint32_t p_z_threads) = 0;
  983. virtual void compute_list_dispatch_indirect(ComputeListID p_list, RID p_buffer, uint32_t p_offset) = 0;
  984. virtual void compute_list_add_barrier(ComputeListID p_list) = 0;
  985. virtual void compute_list_end(uint32_t p_post_barrier = BARRIER_MASK_ALL) = 0;
  986. virtual void barrier(uint32_t p_from = BARRIER_MASK_ALL, uint32_t p_to = BARRIER_MASK_ALL) = 0;
  987. virtual void full_barrier() = 0;
  988. /***************/
  989. /**** FREE! ****/
  990. /***************/
  991. virtual void free(RID p_id) = 0;
  992. /****************/
  993. /**** Timing ****/
  994. /****************/
  995. virtual void capture_timestamp(const String &p_name) = 0;
  996. virtual uint32_t get_captured_timestamps_count() const = 0;
  997. virtual uint64_t get_captured_timestamps_frame() const = 0;
  998. virtual uint64_t get_captured_timestamp_gpu_time(uint32_t p_index) const = 0;
  999. virtual uint64_t get_captured_timestamp_cpu_time(uint32_t p_index) const = 0;
  1000. virtual String get_captured_timestamp_name(uint32_t p_index) const = 0;
  1001. /****************/
  1002. /**** LIMITS ****/
  1003. /****************/
  1004. enum Limit {
  1005. LIMIT_MAX_BOUND_UNIFORM_SETS,
  1006. LIMIT_MAX_FRAMEBUFFER_COLOR_ATTACHMENTS,
  1007. LIMIT_MAX_TEXTURES_PER_UNIFORM_SET,
  1008. LIMIT_MAX_SAMPLERS_PER_UNIFORM_SET,
  1009. LIMIT_MAX_STORAGE_BUFFERS_PER_UNIFORM_SET,
  1010. LIMIT_MAX_STORAGE_IMAGES_PER_UNIFORM_SET,
  1011. LIMIT_MAX_UNIFORM_BUFFERS_PER_UNIFORM_SET,
  1012. LIMIT_MAX_DRAW_INDEXED_INDEX,
  1013. LIMIT_MAX_FRAMEBUFFER_HEIGHT,
  1014. LIMIT_MAX_FRAMEBUFFER_WIDTH,
  1015. LIMIT_MAX_TEXTURE_ARRAY_LAYERS,
  1016. LIMIT_MAX_TEXTURE_SIZE_1D,
  1017. LIMIT_MAX_TEXTURE_SIZE_2D,
  1018. LIMIT_MAX_TEXTURE_SIZE_3D,
  1019. LIMIT_MAX_TEXTURE_SIZE_CUBE,
  1020. LIMIT_MAX_TEXTURES_PER_SHADER_STAGE,
  1021. LIMIT_MAX_SAMPLERS_PER_SHADER_STAGE,
  1022. LIMIT_MAX_STORAGE_BUFFERS_PER_SHADER_STAGE,
  1023. LIMIT_MAX_STORAGE_IMAGES_PER_SHADER_STAGE,
  1024. LIMIT_MAX_UNIFORM_BUFFERS_PER_SHADER_STAGE,
  1025. LIMIT_MAX_PUSH_CONSTANT_SIZE,
  1026. LIMIT_MAX_UNIFORM_BUFFER_SIZE,
  1027. LIMIT_MAX_VERTEX_INPUT_ATTRIBUTE_OFFSET,
  1028. LIMIT_MAX_VERTEX_INPUT_ATTRIBUTES,
  1029. LIMIT_MAX_VERTEX_INPUT_BINDINGS,
  1030. LIMIT_MAX_VERTEX_INPUT_BINDING_STRIDE,
  1031. LIMIT_MIN_UNIFORM_BUFFER_OFFSET_ALIGNMENT,
  1032. LIMIT_MAX_COMPUTE_SHARED_MEMORY_SIZE,
  1033. LIMIT_MAX_COMPUTE_WORKGROUP_COUNT_X,
  1034. LIMIT_MAX_COMPUTE_WORKGROUP_COUNT_Y,
  1035. LIMIT_MAX_COMPUTE_WORKGROUP_COUNT_Z,
  1036. LIMIT_MAX_COMPUTE_WORKGROUP_INVOCATIONS,
  1037. LIMIT_MAX_COMPUTE_WORKGROUP_SIZE_X,
  1038. LIMIT_MAX_COMPUTE_WORKGROUP_SIZE_Y,
  1039. LIMIT_MAX_COMPUTE_WORKGROUP_SIZE_Z,
  1040. };
  1041. virtual int limit_get(Limit p_limit) = 0;
  1042. //methods below not exposed, used by RenderingDeviceRD
  1043. virtual void prepare_screen_for_drawing() = 0;
  1044. virtual void swap_buffers() = 0;
  1045. virtual uint32_t get_frame_delay() const = 0;
  1046. virtual void submit() = 0;
  1047. virtual void sync() = 0;
  1048. enum MemoryType {
  1049. MEMORY_TEXTURES,
  1050. MEMORY_BUFFERS,
  1051. MEMORY_TOTAL
  1052. };
  1053. virtual uint64_t get_memory_usage(MemoryType p_type) const = 0;
  1054. virtual RenderingDevice *create_local_device() = 0;
  1055. virtual void set_resource_name(RID p_id, const String p_name) = 0;
  1056. virtual void draw_command_begin_label(String p_label_name, const Color p_color = Color(1, 1, 1, 1)) = 0;
  1057. virtual void draw_command_insert_label(String p_label_name, const Color p_color = Color(1, 1, 1, 1)) = 0;
  1058. virtual void draw_command_end_label() = 0;
  1059. virtual String get_device_vendor_name() const = 0;
  1060. virtual String get_device_name() const = 0;
  1061. virtual String get_device_pipeline_cache_uuid() const = 0;
  1062. virtual uint64_t get_driver_resource(DriverResource p_resource, RID p_rid = RID(), uint64_t p_index = 0) = 0;
  1063. static RenderingDevice *get_singleton();
  1064. RenderingDevice();
  1065. protected:
  1066. //binders to script API
  1067. RID _texture_create(const Ref<RDTextureFormat> &p_format, const Ref<RDTextureView> &p_view, const TypedArray<PackedByteArray> &p_data = Array());
  1068. RID _texture_create_shared(const Ref<RDTextureView> &p_view, RID p_with_texture);
  1069. RID _texture_create_shared_from_slice(const Ref<RDTextureView> &p_view, RID p_with_texture, uint32_t p_layer, uint32_t p_mipmap, TextureSliceType p_slice_type = TEXTURE_SLICE_2D);
  1070. FramebufferFormatID _framebuffer_format_create(const TypedArray<RDAttachmentFormat> &p_attachments, uint32_t p_view_count);
  1071. FramebufferFormatID _framebuffer_format_create_multipass(const TypedArray<RDAttachmentFormat> &p_attachments, const TypedArray<RDFramebufferPass> &p_passes, uint32_t p_view_count);
  1072. RID _framebuffer_create(const TypedArray<RID> &p_textures, FramebufferFormatID p_format_check = INVALID_ID, uint32_t p_view_count = 1);
  1073. RID _framebuffer_create_multipass(const TypedArray<RID> &p_textures, const TypedArray<RDFramebufferPass> &p_passes, FramebufferFormatID p_format_check = INVALID_ID, uint32_t p_view_count = 1);
  1074. RID _sampler_create(const Ref<RDSamplerState> &p_state);
  1075. VertexFormatID _vertex_format_create(const TypedArray<RDVertexAttribute> &p_vertex_formats);
  1076. RID _vertex_array_create(uint32_t p_vertex_count, VertexFormatID p_vertex_format, const TypedArray<RID> &p_src_buffers);
  1077. Ref<RDShaderSPIRV> _shader_compile_spirv_from_source(const Ref<RDShaderSource> &p_source, bool p_allow_cache = true);
  1078. Vector<uint8_t> _shader_compile_binary_from_spirv(const Ref<RDShaderSPIRV> &p_bytecode, const String &p_shader_name = "");
  1079. RID _shader_create_from_spirv(const Ref<RDShaderSPIRV> &p_spirv, const String &p_shader_name = "");
  1080. RID _uniform_set_create(const Array &p_uniforms, RID p_shader, uint32_t p_shader_set);
  1081. Error _buffer_update(RID p_buffer, uint32_t p_offset, uint32_t p_size, const Vector<uint8_t> &p_data, uint32_t p_post_barrier = BARRIER_MASK_ALL);
  1082. RID _render_pipeline_create(RID p_shader, FramebufferFormatID p_framebuffer_format, VertexFormatID p_vertex_format, RenderPrimitive p_render_primitive, const Ref<RDPipelineRasterizationState> &p_rasterization_state, const Ref<RDPipelineMultisampleState> &p_multisample_state, const Ref<RDPipelineDepthStencilState> &p_depth_stencil_state, const Ref<RDPipelineColorBlendState> &p_blend_state, int p_dynamic_state_flags, uint32_t p_for_render_pass, const TypedArray<RDPipelineSpecializationConstant> &p_specialization_constants);
  1083. RID _compute_pipeline_create(RID p_shader, const TypedArray<RDPipelineSpecializationConstant> &p_specialization_constants);
  1084. Vector<int64_t> _draw_list_begin_split(RID p_framebuffer, uint32_t p_splits, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, const Vector<Color> &p_clear_color_values = Vector<Color>(), float p_clear_depth = 1.0, uint32_t p_clear_stencil = 0, const Rect2 &p_region = Rect2(), const TypedArray<RID> &p_storage_textures = TypedArray<RID>());
  1085. void _draw_list_set_push_constant(DrawListID p_list, const Vector<uint8_t> &p_data, uint32_t p_data_size);
  1086. void _compute_list_set_push_constant(ComputeListID p_list, const Vector<uint8_t> &p_data, uint32_t p_data_size);
  1087. Vector<int64_t> _draw_list_switch_to_next_pass_split(uint32_t p_splits);
  1088. };
  1089. VARIANT_ENUM_CAST(RenderingDevice::DriverResource)
  1090. VARIANT_ENUM_CAST(RenderingDevice::ShaderStage)
  1091. VARIANT_ENUM_CAST(RenderingDevice::ShaderLanguage)
  1092. VARIANT_ENUM_CAST(RenderingDevice::CompareOperator)
  1093. VARIANT_ENUM_CAST(RenderingDevice::DataFormat)
  1094. VARIANT_ENUM_CAST(RenderingDevice::TextureType)
  1095. VARIANT_ENUM_CAST(RenderingDevice::TextureSamples)
  1096. VARIANT_ENUM_CAST(RenderingDevice::TextureUsageBits)
  1097. VARIANT_ENUM_CAST(RenderingDevice::TextureSwizzle)
  1098. VARIANT_ENUM_CAST(RenderingDevice::TextureSliceType)
  1099. VARIANT_ENUM_CAST(RenderingDevice::SamplerFilter)
  1100. VARIANT_ENUM_CAST(RenderingDevice::SamplerRepeatMode)
  1101. VARIANT_ENUM_CAST(RenderingDevice::SamplerBorderColor)
  1102. VARIANT_ENUM_CAST(RenderingDevice::VertexFrequency)
  1103. VARIANT_ENUM_CAST(RenderingDevice::IndexBufferFormat)
  1104. VARIANT_ENUM_CAST(RenderingDevice::StorageBufferUsage)
  1105. VARIANT_ENUM_CAST(RenderingDevice::UniformType)
  1106. VARIANT_ENUM_CAST(RenderingDevice::RenderPrimitive)
  1107. VARIANT_ENUM_CAST(RenderingDevice::PolygonCullMode)
  1108. VARIANT_ENUM_CAST(RenderingDevice::PolygonFrontFace)
  1109. VARIANT_ENUM_CAST(RenderingDevice::StencilOperation)
  1110. VARIANT_ENUM_CAST(RenderingDevice::LogicOperation)
  1111. VARIANT_ENUM_CAST(RenderingDevice::BlendFactor)
  1112. VARIANT_ENUM_CAST(RenderingDevice::BlendOperation)
  1113. VARIANT_ENUM_CAST(RenderingDevice::PipelineDynamicStateFlags)
  1114. VARIANT_ENUM_CAST(RenderingDevice::PipelineSpecializationConstantType)
  1115. VARIANT_ENUM_CAST(RenderingDevice::InitialAction)
  1116. VARIANT_ENUM_CAST(RenderingDevice::FinalAction)
  1117. VARIANT_ENUM_CAST(RenderingDevice::Limit)
  1118. VARIANT_ENUM_CAST(RenderingDevice::MemoryType)
  1119. typedef RenderingDevice RD;
  1120. #endif // RENDERING_DEVICE_H