Attention

You are reading the latest (unstable) version of this documentation, which may document features not available or compatible with Godot 3.x.

Work in progress

Godot documentation is being updated to reflect the latest changes in version 4.0. Some documentation pages may still state outdated information. This banner will tell you if you're reading one of such pages.

The contents of this page are up to date. If you can still find outdated information, please open an issue.

RenderingDevice

Inherits: Object

Abstraction for working with modern low-level graphics APIs.

Description

RenderingDevice is an abstraction for working with modern low-level graphics APIs such as Vulkan.

On startup, Godot creates a global RenderingDevice which can be retrieved using RenderingServer.get_rendering_device. This global RenderingDevice performs drawing to the screen.

Internally, RenderingDevice is used in Godot to provide support for several modern low-level graphics APIs while reducing the amount of code duplication required.

Local RenderingDevices: Using RenderingServer.create_local_rendering_device, you can create "secondary" rendering devices to perform drawing and GPU compute operations on separate threads.

Note: RenderingDevice is not available when running in headless mode or when using the Compatibility rendering method.

Methods

void

barrier ( BarrierMask from=7, BarrierMask to=7 )

Error

buffer_clear ( RID buffer, int offset, int size_bytes, BarrierMask post_barrier=7 )

PackedByteArray

buffer_get_data ( RID buffer, int offset_bytes=0, int size_bytes=0 )

Error

buffer_update ( RID buffer, int offset, int size_bytes, PackedByteArray data, BarrierMask post_barrier=7 )

void

capture_timestamp ( String name )

void

compute_list_add_barrier ( int compute_list )

int

compute_list_begin ( bool allow_draw_overlap=false )

void

compute_list_bind_compute_pipeline ( int compute_list, RID compute_pipeline )

void

compute_list_bind_uniform_set ( int compute_list, RID uniform_set, int set_index )

void

compute_list_dispatch ( int compute_list, int x_groups, int y_groups, int z_groups )

void

compute_list_end ( BarrierMask post_barrier=7 )

void

compute_list_set_push_constant ( int compute_list, PackedByteArray buffer, int size_bytes )

RID

compute_pipeline_create ( RID shader, RDPipelineSpecializationConstant[] specialization_constants=[] )

bool

compute_pipeline_is_valid ( RID compute_pieline )

RenderingDevice

create_local_device ( )

void

draw_command_begin_label ( String name, Color color )

void

draw_command_end_label ( )

void

draw_command_insert_label ( String name, Color color )

int

draw_list_begin ( RID framebuffer, InitialAction initial_color_action, FinalAction final_color_action, InitialAction initial_depth_action, FinalAction final_depth_action, PackedColorArray clear_color_values=PackedColorArray(), float clear_depth=1.0, int clear_stencil=0, Rect2 region=Rect2(0, 0, 0, 0), Array storage_textures=[] )

int

draw_list_begin_for_screen ( int screen=0, Color clear_color=Color(0, 0, 0, 1) )

PackedInt64Array

draw_list_begin_split ( RID framebuffer, int splits, InitialAction initial_color_action, FinalAction final_color_action, InitialAction initial_depth_action, FinalAction final_depth_action, PackedColorArray clear_color_values=PackedColorArray(), float clear_depth=1.0, int clear_stencil=0, Rect2 region=Rect2(0, 0, 0, 0), RID[] storage_textures=[] )

void

draw_list_bind_index_array ( int draw_list, RID index_array )

void

draw_list_bind_render_pipeline ( int draw_list, RID render_pipeline )

void

draw_list_bind_uniform_set ( int draw_list, RID uniform_set, int set_index )

void

draw_list_bind_vertex_array ( int draw_list, RID vertex_array )

void

draw_list_disable_scissor ( int draw_list )

void

draw_list_draw ( int draw_list, bool use_indices, int instances, int procedural_vertex_count=0 )

void

draw_list_enable_scissor ( int draw_list, Rect2 rect=Rect2(0, 0, 0, 0) )

void

draw_list_end ( BarrierMask post_barrier=7 )

void

draw_list_set_blend_constants ( int draw_list, Color color )

void

draw_list_set_push_constant ( int draw_list, PackedByteArray buffer, int size_bytes )

int

draw_list_switch_to_next_pass ( )

PackedInt64Array

draw_list_switch_to_next_pass_split ( int splits )

RID

framebuffer_create ( RID[] textures, int validate_with_format=-1, int view_count=1 )

RID

framebuffer_create_empty ( Vector2i size, TextureSamples samples=0, int validate_with_format=-1 )

RID

framebuffer_create_multipass ( RID[] textures, RDFramebufferPass[] passes, int validate_with_format=-1, int view_count=1 )

int

framebuffer_format_create ( RDAttachmentFormat[] attachments, int view_count=1 )

int

framebuffer_format_create_empty ( TextureSamples samples=0 )

int

framebuffer_format_create_multipass ( RDAttachmentFormat[] attachments, RDFramebufferPass[] passes, int view_count=1 )

TextureSamples

framebuffer_format_get_texture_samples ( int format, int render_pass=0 )

int

framebuffer_get_format ( RID framebuffer )

bool

framebuffer_is_valid ( RID framebuffer ) const

void

free_rid ( RID rid )

void

full_barrier ( )

int

get_captured_timestamp_cpu_time ( int index ) const

int

get_captured_timestamp_gpu_time ( int index ) const

String

get_captured_timestamp_name ( int index ) const

int

get_captured_timestamps_count ( ) const

int

get_captured_timestamps_frame ( ) const

String

get_device_name ( ) const

String

get_device_pipeline_cache_uuid ( ) const

String

get_device_vendor_name ( ) const

int

get_driver_resource ( DriverResource resource, RID rid, int index )

int

get_frame_delay ( ) const

int

get_memory_usage ( MemoryType type ) const

RID

index_array_create ( RID index_buffer, int index_offset, int index_count )

RID

index_buffer_create ( int size_indices, IndexBufferFormat format, PackedByteArray data=PackedByteArray(), bool use_restart_indices=false )

int

limit_get ( Limit limit ) const

RID

render_pipeline_create ( RID shader, int framebuffer_format, int vertex_format, RenderPrimitive primitive, RDPipelineRasterizationState rasterization_state, RDPipelineMultisampleState multisample_state, RDPipelineDepthStencilState stencil_state, RDPipelineColorBlendState color_blend_state, PipelineDynamicStateFlags dynamic_state_flags=0, int for_render_pass=0, RDPipelineSpecializationConstant[] specialization_constants=[] )

bool

render_pipeline_is_valid ( RID render_pipeline )

RID

sampler_create ( RDSamplerState state )

int

screen_get_framebuffer_format ( ) const

int

screen_get_height ( int screen=0 ) const

int

screen_get_width ( int screen=0 ) const

void

set_resource_name ( RID id, String name )

PackedByteArray

shader_compile_binary_from_spirv ( RDShaderSPIRV spirv_data, String name="" )

RDShaderSPIRV

shader_compile_spirv_from_source ( RDShaderSource shader_source, bool allow_cache=true )

RID

shader_create_from_bytecode ( PackedByteArray binary_data )

RID

shader_create_from_spirv ( RDShaderSPIRV spirv_data, String name="" )

int

shader_get_vertex_input_attribute_mask ( RID shader )

RID

storage_buffer_create ( int size_bytes, PackedByteArray data=PackedByteArray(), StorageBufferUsage usage=0 )

void

submit ( )

void

sync ( )

RID

texture_buffer_create ( int size_bytes, DataFormat format, PackedByteArray data=PackedByteArray() )

Error

texture_clear ( RID texture, Color color, int base_mipmap, int mipmap_count, int base_layer, int layer_count, BarrierMask post_barrier=7 )

Error

texture_copy ( RID from_texture, RID to_texture, Vector3 from_pos, Vector3 to_pos, Vector3 size, int src_mipmap, int dst_mipmap, int src_layer, int dst_layer, BarrierMask post_barrier=7 )

RID

texture_create ( RDTextureFormat format, RDTextureView view, PackedByteArray[] data=[] )

RID

texture_create_shared ( RDTextureView view, RID with_texture )

RID

texture_create_shared_from_slice ( RDTextureView view, RID with_texture, int layer, int mipmap, int mipmaps=1, TextureSliceType slice_type=0 )

PackedByteArray

texture_get_data ( RID texture, int layer )

bool

texture_is_format_supported_for_usage ( DataFormat format, TextureUsageBits usage_flags ) const

bool

texture_is_shared ( RID texture )

bool

texture_is_valid ( RID texture )

Error

texture_resolve_multisample ( RID from_texture, RID to_texture, BarrierMask post_barrier=7 )

Error

texture_update ( RID texture, int layer, PackedByteArray data, BarrierMask post_barrier=7 )

RID

uniform_buffer_create ( int size_bytes, PackedByteArray data=PackedByteArray() )

RID

uniform_set_create ( RDUniform[] uniforms, RID shader, int shader_set )

bool

uniform_set_is_valid ( RID uniform_set )

RID

vertex_array_create ( int vertex_count, int vertex_format, RID[] src_buffers, PackedInt64Array offsets=PackedInt64Array() )

RID

vertex_buffer_create ( int size_bytes, PackedByteArray data=PackedByteArray(), bool use_as_storage=false )

int

vertex_format_create ( RDVertexAttribute[] vertex_descriptions )


Enumerations

enum DeviceType:

DeviceType DEVICE_TYPE_OTHER = 0

Rendering device type does not match any of the other enum values or is unknown.

DeviceType DEVICE_TYPE_INTEGRATED_GPU = 1

Rendering device is an integrated GPU, which is typically (but not always) slower than dedicated GPUs (DEVICE_TYPE_DISCRETE_GPU). On Android and iOS, the rendering device type is always considered to be DEVICE_TYPE_INTEGRATED_GPU.

DeviceType DEVICE_TYPE_DISCRETE_GPU = 2

Rendering device is a dedicated GPU, which is typically (but not always) faster than integrated GPUs (DEVICE_TYPE_INTEGRATED_GPU).

DeviceType DEVICE_TYPE_VIRTUAL_GPU = 3

Rendering device is an emulated GPU in a virtual environment. This is typically much slower than the host GPU, which means the expected performance level on a dedicated GPU will be roughly equivalent to DEVICE_TYPE_INTEGRATED_GPU. Virtual machine GPU passthrough (such as VFIO) will not report the device type as DEVICE_TYPE_VIRTUAL_GPU. Instead, the host GPU's device type will be reported as if the GPU was not emulated.

DeviceType DEVICE_TYPE_CPU = 4

Rendering device is provided by software emulation (such as Lavapipe or SwiftShader). This is the slowest kind of rendering device available; it's typically much slower than DEVICE_TYPE_INTEGRATED_GPU.

DeviceType DEVICE_TYPE_MAX = 5

Represents the size of the DeviceType enum.


enum DriverResource:

DriverResource DRIVER_RESOURCE_VULKAN_DEVICE = 0

DriverResource DRIVER_RESOURCE_VULKAN_PHYSICAL_DEVICE = 1

DriverResource DRIVER_RESOURCE_VULKAN_INSTANCE = 2

DriverResource DRIVER_RESOURCE_VULKAN_QUEUE = 3

DriverResource DRIVER_RESOURCE_VULKAN_QUEUE_FAMILY_INDEX = 4

DriverResource DRIVER_RESOURCE_VULKAN_IMAGE = 5

DriverResource DRIVER_RESOURCE_VULKAN_IMAGE_VIEW = 6

DriverResource DRIVER_RESOURCE_VULKAN_IMAGE_NATIVE_TEXTURE_FORMAT = 7

DriverResource DRIVER_RESOURCE_VULKAN_SAMPLER = 8

DriverResource DRIVER_RESOURCE_VULKAN_DESCRIPTOR_SET = 9

DriverResource DRIVER_RESOURCE_VULKAN_BUFFER = 10

DriverResource DRIVER_RESOURCE_VULKAN_COMPUTE_PIPELINE = 11

DriverResource DRIVER_RESOURCE_VULKAN_RENDER_PIPELINE = 12


enum DataFormat:

DataFormat DATA_FORMAT_R4G4_UNORM_PACK8 = 0

DataFormat DATA_FORMAT_R4G4B4A4_UNORM_PACK16 = 1

DataFormat DATA_FORMAT_B4G4R4A4_UNORM_PACK16 = 2

DataFormat DATA_FORMAT_R5G6B5_UNORM_PACK16 = 3

DataFormat DATA_FORMAT_B5G6R5_UNORM_PACK16 = 4

DataFormat DATA_FORMAT_R5G5B5A1_UNORM_PACK16 = 5

DataFormat DATA_FORMAT_B5G5R5A1_UNORM_PACK16 = 6

DataFormat DATA_FORMAT_A1R5G5B5_UNORM_PACK16 = 7

DataFormat DATA_FORMAT_R8_UNORM = 8

DataFormat DATA_FORMAT_R8_SNORM = 9

DataFormat DATA_FORMAT_R8_USCALED = 10

DataFormat DATA_FORMAT_R8_SSCALED = 11

DataFormat DATA_FORMAT_R8_UINT = 12

DataFormat DATA_FORMAT_R8_SINT = 13

DataFormat DATA_FORMAT_R8_SRGB = 14

DataFormat DATA_FORMAT_R8G8_UNORM = 15

DataFormat DATA_FORMAT_R8G8_SNORM = 16

DataFormat DATA_FORMAT_R8G8_USCALED = 17

DataFormat DATA_FORMAT_R8G8_SSCALED = 18

DataFormat DATA_FORMAT_R8G8_UINT = 19

DataFormat DATA_FORMAT_R8G8_SINT = 20

DataFormat DATA_FORMAT_R8G8_SRGB = 21

DataFormat DATA_FORMAT_R8G8B8_UNORM = 22

DataFormat DATA_FORMAT_R8G8B8_SNORM = 23

DataFormat DATA_FORMAT_R8G8B8_USCALED = 24

DataFormat DATA_FORMAT_R8G8B8_SSCALED = 25

DataFormat DATA_FORMAT_R8G8B8_UINT = 26

DataFormat DATA_FORMAT_R8G8B8_SINT = 27

DataFormat DATA_FORMAT_R8G8B8_SRGB = 28

DataFormat DATA_FORMAT_B8G8R8_UNORM = 29

DataFormat DATA_FORMAT_B8G8R8_SNORM = 30

DataFormat DATA_FORMAT_B8G8R8_USCALED = 31

DataFormat DATA_FORMAT_B8G8R8_SSCALED = 32

DataFormat DATA_FORMAT_B8G8R8_UINT = 33

DataFormat DATA_FORMAT_B8G8R8_SINT = 34

DataFormat DATA_FORMAT_B8G8R8_SRGB = 35

DataFormat DATA_FORMAT_R8G8B8A8_UNORM = 36

DataFormat DATA_FORMAT_R8G8B8A8_SNORM = 37

DataFormat DATA_FORMAT_R8G8B8A8_USCALED = 38

DataFormat DATA_FORMAT_R8G8B8A8_SSCALED = 39

DataFormat DATA_FORMAT_R8G8B8A8_UINT = 40

DataFormat DATA_FORMAT_R8G8B8A8_SINT = 41

DataFormat DATA_FORMAT_R8G8B8A8_SRGB = 42

DataFormat DATA_FORMAT_B8G8R8A8_UNORM = 43

DataFormat DATA_FORMAT_B8G8R8A8_SNORM = 44

DataFormat DATA_FORMAT_B8G8R8A8_USCALED = 45

DataFormat DATA_FORMAT_B8G8R8A8_SSCALED = 46

DataFormat DATA_FORMAT_B8G8R8A8_UINT = 47

DataFormat DATA_FORMAT_B8G8R8A8_SINT = 48

DataFormat DATA_FORMAT_B8G8R8A8_SRGB = 49

DataFormat DATA_FORMAT_A8B8G8R8_UNORM_PACK32 = 50

DataFormat DATA_FORMAT_A8B8G8R8_SNORM_PACK32 = 51

DataFormat DATA_FORMAT_A8B8G8R8_USCALED_PACK32 = 52

DataFormat DATA_FORMAT_A8B8G8R8_SSCALED_PACK32 = 53

DataFormat DATA_FORMAT_A8B8G8R8_UINT_PACK32 = 54

DataFormat DATA_FORMAT_A8B8G8R8_SINT_PACK32 = 55

DataFormat DATA_FORMAT_A8B8G8R8_SRGB_PACK32 = 56

DataFormat DATA_FORMAT_A2R10G10B10_UNORM_PACK32 = 57

DataFormat DATA_FORMAT_A2R10G10B10_SNORM_PACK32 = 58

DataFormat DATA_FORMAT_A2R10G10B10_USCALED_PACK32 = 59

DataFormat DATA_FORMAT_A2R10G10B10_SSCALED_PACK32 = 60

DataFormat DATA_FORMAT_A2R10G10B10_UINT_PACK32 = 61

DataFormat DATA_FORMAT_A2R10G10B10_SINT_PACK32 = 62

DataFormat DATA_FORMAT_A2B10G10R10_UNORM_PACK32 = 63

DataFormat DATA_FORMAT_A2B10G10R10_SNORM_PACK32 = 64

DataFormat DATA_FORMAT_A2B10G10R10_USCALED_PACK32 = 65

DataFormat DATA_FORMAT_A2B10G10R10_SSCALED_PACK32 = 66

DataFormat DATA_FORMAT_A2B10G10R10_UINT_PACK32 = 67

DataFormat DATA_FORMAT_A2B10G10R10_SINT_PACK32 = 68

DataFormat DATA_FORMAT_R16_UNORM = 69

DataFormat DATA_FORMAT_R16_SNORM = 70