rendering_device.h 49 KB

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