Table of Contents

Class RenderingDevice

Namespace
Godot
Assembly
GodotSharp.dll

RenderingDevice is an abstraction for working with modern low-level graphics APIs such as Vulkan. Compared to RenderingServer (which works with Godot's own rendering subsystems), RenderingDevice is much lower-level and allows working more directly with the underlying graphics APIs. RenderingDevice is used in Godot to provide support for several modern low-level graphics APIs while reducing the amount of code duplication required. RenderingDevice can also be used in your own projects to perform things that are not exposed by RenderingServer or high-level nodes, such as using compute shaders.

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

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

Note: RenderingDevice assumes intermediate knowledge of modern graphics APIs such as Vulkan, Direct3D 12, Metal or WebGPU. These graphics APIs are lower-level than OpenGL or Direct3D 11, requiring you to perform what was previously done by the graphics driver itself. If you have difficulty understanding the concepts used in this class, follow the Vulkan Tutorial or Vulkan Guide. It's recommended to have existing modern OpenGL or Direct3D 11 knowledge before attempting to learn a low-level graphics API.

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

public class RenderingDevice : GodotObject, IDisposable
Inheritance
RenderingDevice
Implements
Inherited Members

Fields

InvalidFormatId

Returned by functions that return a format ID if a value is invalid.

public const long InvalidFormatId = -1

Field Value

long

InvalidId

Returned by functions that return an ID if a value is invalid.

public const long InvalidId = -1

Field Value

long

Methods

Barrier(BarrierMask, BarrierMask)

Puts a memory barrier in place. This is used for synchronization to avoid data races. See also FullBarrier(), which may be useful for debugging.

public void Barrier(RenderingDevice.BarrierMask from = BarrierMask.AllBarriers, RenderingDevice.BarrierMask to = BarrierMask.AllBarriers)

Parameters

from RenderingDevice.BarrierMask
to RenderingDevice.BarrierMask

BufferClear(Rid, uint, uint, BarrierMask)

Clears the contents of the buffer, clearing sizeBytes bytes, starting at offset. Always raises a memory barrier.

Prints an error if:

- the size isn't a multiple of four

- the region specified by offset + sizeBytes exceeds the buffer

- a draw list is currently active (created by DrawListBegin(Rid, InitialAction, FinalAction, InitialAction, FinalAction, Color[], float, uint, Rect2?, Array<Rid>))

- a compute list is currently active (created by ComputeListBegin(bool))

public Error BufferClear(Rid buffer, uint offset, uint sizeBytes, RenderingDevice.BarrierMask postBarrier = BarrierMask.AllBarriers)

Parameters

buffer Rid
offset uint
sizeBytes uint
postBarrier RenderingDevice.BarrierMask

Returns

Error

BufferGetData(Rid, uint, uint)

Returns a copy of the data of the specified buffer, optionally offsetBytes and sizeBytes can be set to copy only a portion of the buffer.

public byte[] BufferGetData(Rid buffer, uint offsetBytes = 0, uint sizeBytes = 0)

Parameters

buffer Rid
offsetBytes uint
sizeBytes uint

Returns

byte[]

BufferUpdate(Rid, uint, uint, byte[], BarrierMask)

Updates a region of sizeBytes bytes, starting at offset, in the buffer, with the specified data. Raises a memory barrier except when postBarrier is set to NoBarrier.

Prints an error if:

- the region specified by offset + sizeBytes exceeds the buffer

- a draw list is currently active (created by DrawListBegin(Rid, InitialAction, FinalAction, InitialAction, FinalAction, Color[], float, uint, Rect2?, Array<Rid>))

- a compute list is currently active (created by ComputeListBegin(bool))

public Error BufferUpdate(Rid buffer, uint offset, uint sizeBytes, byte[] data, RenderingDevice.BarrierMask postBarrier = BarrierMask.AllBarriers)

Parameters

buffer Rid
offset uint
sizeBytes uint
data byte[]
postBarrier RenderingDevice.BarrierMask

Returns

Error

CaptureTimestamp(string)

Creates a timestamp marker with the specified name. This is used for performance reporting with the GetCapturedTimestampCpuTime(uint), GetCapturedTimestampGpuTime(uint) and GetCapturedTimestampName(uint) methods.

public void CaptureTimestamp(string name)

Parameters

name string

ComputeListAddBarrier(long)

Raises a Vulkan compute barrier in the specified computeList.

public void ComputeListAddBarrier(long computeList)

Parameters

computeList long

ComputeListBegin(bool)

Starts a list of compute commands created with the compute_* methods. The returned value should be passed to other compute_list_* functions.

If allowDrawOverlap is true, you may have one draw list running at the same time as one compute list. Multiple compute lists cannot be created at the same time; you must finish the previous compute list first using ComputeListEnd(BarrierMask).

A simple compute operation might look like this (code is not a complete example):

var rd = RenderingDevice.new()
  var compute_list = rd.compute_list_begin()

rd.compute_list_bind_compute_pipeline(compute_list, compute_shader_dilate_pipeline) rd.compute_list_bind_uniform_set(compute_list, compute_base_uniform_set, 0) rd.compute_list_bind_uniform_set(compute_list, dilate_uniform_set, 1)

for i in atlas_slices: rd.compute_list_set_push_constant(compute_list, push_constant, push_constant.size()) rd.compute_list_dispatch(compute_list, group_size.x, group_size.y, group_size.z) # No barrier, let them run all together.

rd.compute_list_end()

public long ComputeListBegin(bool allowDrawOverlap = false)

Parameters

allowDrawOverlap bool

Returns

long

ComputeListBindComputePipeline(long, Rid)

Tells the GPU what compute pipeline to use when processing the compute list. If the shader has changed since the last time this function was called, Godot will unbind all descriptor sets and will re-bind them inside ComputeListDispatch(long, uint, uint, uint).

public void ComputeListBindComputePipeline(long computeList, Rid computePipeline)

Parameters

computeList long
computePipeline Rid

ComputeListBindUniformSet(long, Rid, uint)

Binds the uniformSet to this computeList. Godot ensures that all textures in the uniform set have the correct Vulkan access masks. If Godot had to change access masks of textures, it will raise a Vulkan image memory barrier.

public void ComputeListBindUniformSet(long computeList, Rid uniformSet, uint setIndex)

Parameters

computeList long
uniformSet Rid
setIndex uint

ComputeListDispatch(long, uint, uint, uint)

Submits the compute list for processing on the GPU. This is the compute equivalent to DrawListDraw(long, bool, uint, uint).

public void ComputeListDispatch(long computeList, uint xGroups, uint yGroups, uint zGroups)

Parameters

computeList long
xGroups uint
yGroups uint
zGroups uint

ComputeListEnd(BarrierMask)

Finishes a list of compute commands created with the compute_* methods.

public void ComputeListEnd(RenderingDevice.BarrierMask postBarrier = BarrierMask.AllBarriers)

Parameters

postBarrier RenderingDevice.BarrierMask

ComputeListSetPushConstant(long, byte[], uint)

Sets the push constant data to buffer for the specified computeList. The shader determines how this binary data is used. The buffer's size in bytes must also be specified in sizeBytes (this can be obtained by calling the PackedByteArray.size method on the passed buffer).

public void ComputeListSetPushConstant(long computeList, byte[] buffer, uint sizeBytes)

Parameters

computeList long
buffer byte[]
sizeBytes uint

ComputePipelineCreate(Rid, Array<RDPipelineSpecializationConstant>)

Creates a new compute pipeline. It can be accessed with the RID that is returned.

Once finished with your RID, you will want to free the RID using the RenderingDevice's FreeRid(Rid) method.

public Rid ComputePipelineCreate(Rid shader, Array<RDPipelineSpecializationConstant> specializationConstants = null)

Parameters

shader Rid
specializationConstants Array<RDPipelineSpecializationConstant>

Returns

Rid

ComputePipelineIsValid(Rid)

Returns true if the compute pipeline specified by the computePipeline RID is valid, false otherwise.

public bool ComputePipelineIsValid(Rid computePipeline)

Parameters

computePipeline Rid

Returns

bool

CreateLocalDevice()

Create a new local RenderingDevice. This is most useful for performing compute operations on the GPU independently from the rest of the engine.

public RenderingDevice CreateLocalDevice()

Returns

RenderingDevice

DrawCommandBeginLabel(string, Color)

Create a command buffer debug label region that can be displayed in third-party tools such as RenderDoc. All regions must be ended with a DrawCommandEndLabel() call. When viewed from the linear series of submissions to a single queue, calls to DrawCommandBeginLabel(string, Color) and DrawCommandEndLabel() must be matched and balanced.

The VK_EXT_DEBUG_UTILS_EXTENSION_NAME Vulkan extension must be available and enabled for command buffer debug label region to work. See also DrawCommandInsertLabel(string, Color) and DrawCommandEndLabel().

public void DrawCommandBeginLabel(string name, Color color)

Parameters

name string
color Color

DrawCommandEndLabel()

Ends the command buffer debug label region started by a DrawCommandBeginLabel(string, Color) call.

public void DrawCommandEndLabel()

DrawCommandInsertLabel(string, Color)

Inserts a command buffer debug label region in the current command buffer. Unlike DrawCommandBeginLabel(string, Color), this region should not be ended with a DrawCommandEndLabel() call.

public void DrawCommandInsertLabel(string name, Color color)

Parameters

name string
color Color

DrawListBegin(Rid, InitialAction, FinalAction, InitialAction, FinalAction, Color[], float, uint, Rect2?, Array<Rid>)

Starts a list of raster drawing commands created with the draw_* methods. The returned value should be passed to other draw_list_* functions.

Multiple draw lists cannot be created at the same time; you must finish the previous draw list first using DrawListEnd(BarrierMask).

A simple drawing operation might look like this (code is not a complete example):

var rd = RenderingDevice.new()
  var clear_colors = PackedColorArray([Color(0, 0, 0, 0), Color(0, 0, 0, 0), Color(0, 0, 0, 0)])
  var draw_list = rd.draw_list_begin(framebuffers[i], RenderingDevice.INITIAL_ACTION_CLEAR, RenderingDevice.FINAL_ACTION_READ, RenderingDevice.INITIAL_ACTION_CLEAR, RenderingDevice.FINAL_ACTION_DISCARD, clear_colors)

Draw opaque.

rd.draw_list_bind_render_pipeline(draw_list, raster_pipeline) rd.draw_list_bind_uniform_set(draw_list, raster_base_uniform, 0) rd.draw_list_set_push_constant(draw_list, raster_push_constant, raster_push_constant.size()) rd.draw_list_draw(draw_list, false, 1, slice_triangle_count[i] * 3)

Draw wire.

rd.draw_list_bind_render_pipeline(draw_list, raster_pipeline_wire) rd.draw_list_bind_uniform_set(draw_list, raster_base_uniform, 0) rd.draw_list_set_push_constant(draw_list, raster_push_constant, raster_push_constant.size()) rd.draw_list_draw(draw_list, false, 1, slice_triangle_count[i] * 3)

rd.draw_list_end()

public long DrawListBegin(Rid framebuffer, RenderingDevice.InitialAction initialColorAction, RenderingDevice.FinalAction finalColorAction, RenderingDevice.InitialAction initialDepthAction, RenderingDevice.FinalAction finalDepthAction, Color[] clearColorValues = null, float clearDepth = 1, uint clearStencil = 0, Rect2? region = null, Array<Rid> storageTextures = null)

Parameters

framebuffer Rid
initialColorAction RenderingDevice.InitialAction
finalColorAction RenderingDevice.FinalAction
initialDepthAction RenderingDevice.InitialAction
finalDepthAction RenderingDevice.FinalAction
clearColorValues Color[]

If the parameter is null, then the default value is Array.Empty<Color>().

clearDepth float
clearStencil uint
region Rect2?

If the parameter is null, then the default value is new Rect2(new Vector2(0, 0), new Vector2(0, 0)).

storageTextures Array<Rid>

Returns

long

DrawListBeginForScreen(int, Color?)

High-level variant of DrawListBegin(Rid, InitialAction, FinalAction, InitialAction, FinalAction, Color[], float, uint, Rect2?, Array<Rid>), with the parameters automatically being adjusted for drawing onto the window specified by the screen ID.

Note: Cannot be used with local RenderingDevices, as these don't have a screen. If called on a local RenderingDevice, DrawListBeginForScreen(int, Color?) returns InvalidId.

public long DrawListBeginForScreen(int screen = 0, Color? clearColor = null)

Parameters

screen int
clearColor Color?

If the parameter is null, then the default value is new Color(0, 0, 0, 1).

Returns

long

DrawListBeginSplit(Rid, uint, InitialAction, FinalAction, InitialAction, FinalAction, Color[], float, uint, Rect2?, Array<Rid>)

Variant of DrawListBegin(Rid, InitialAction, FinalAction, InitialAction, FinalAction, Color[], float, uint, Rect2?, Array<Rid>) with support for multiple splits. The splits parameter determines how many splits are created.

public long[] DrawListBeginSplit(Rid framebuffer, uint splits, RenderingDevice.InitialAction initialColorAction, RenderingDevice.FinalAction finalColorAction, RenderingDevice.InitialAction initialDepthAction, RenderingDevice.FinalAction finalDepthAction, Color[] clearColorValues = null, float clearDepth = 1, uint clearStencil = 0, Rect2? region = null, Array<Rid> storageTextures = null)

Parameters

framebuffer Rid
splits uint
initialColorAction RenderingDevice.InitialAction
finalColorAction RenderingDevice.FinalAction
initialDepthAction RenderingDevice.InitialAction
finalDepthAction RenderingDevice.FinalAction
clearColorValues Color[]

If the parameter is null, then the default value is Array.Empty<Color>().

clearDepth float
clearStencil uint
region Rect2?

If the parameter is null, then the default value is new Rect2(new Vector2(0, 0), new Vector2(0, 0)).

storageTextures Array<Rid>

Returns

long[]

DrawListBindIndexArray(long, Rid)

Binds indexArray to the specified drawList.

public void DrawListBindIndexArray(long drawList, Rid indexArray)

Parameters

drawList long
indexArray Rid

DrawListBindRenderPipeline(long, Rid)

Binds renderPipeline to the specified drawList.

public void DrawListBindRenderPipeline(long drawList, Rid renderPipeline)

Parameters

drawList long
renderPipeline Rid

DrawListBindUniformSet(long, Rid, uint)

Binds uniformSet to the specified drawList. A setIndex must also be specified, which is an identifier starting from 0 that must match the one expected by the draw list.

public void DrawListBindUniformSet(long drawList, Rid uniformSet, uint setIndex)

Parameters

drawList long
uniformSet Rid
setIndex uint

DrawListBindVertexArray(long, Rid)

Binds vertexArray to the specified drawList.

public void DrawListBindVertexArray(long drawList, Rid vertexArray)

Parameters

drawList long
vertexArray Rid

DrawListDisableScissor(long)

Removes and disables the scissor rectangle for the specified drawList. See also DrawListEnableScissor(long, Rect2?).

public void DrawListDisableScissor(long drawList)

Parameters

drawList long

DrawListDraw(long, bool, uint, uint)

Submits drawList for rendering on the GPU. This is the raster equivalent to ComputeListDispatch(long, uint, uint, uint).

public void DrawListDraw(long drawList, bool useIndices, uint instances, uint proceduralVertexCount = 0)

Parameters

drawList long
useIndices bool
instances uint
proceduralVertexCount uint

DrawListEnableScissor(long, Rect2?)

Creates a scissor rectangle and enables it for the specified drawList. Scissor rectangles are used for clipping by discarding fragments that fall outside a specified rectangular portion of the screen. See also DrawListDisableScissor(long).

Note: The specified rect is automatically intersected with the screen's dimensions, which means it cannot exceed the screen's dimensions.

public void DrawListEnableScissor(long drawList, Rect2? rect = null)

Parameters

drawList long
rect Rect2?

If the parameter is null, then the default value is new Rect2(new Vector2(0, 0), new Vector2(0, 0)).

DrawListEnd(BarrierMask)

Finishes a list of raster drawing commands created with the draw_* methods.

public void DrawListEnd(RenderingDevice.BarrierMask postBarrier = BarrierMask.AllBarriers)

Parameters

postBarrier RenderingDevice.BarrierMask

DrawListSetBlendConstants(long, Color)

Sets blend constants for the specified drawList to color. Blend constants are used only if the graphics pipeline is created with BlendConstants flag set.

public void DrawListSetBlendConstants(long drawList, Color color)

Parameters

drawList long
color Color

DrawListSetPushConstant(long, byte[], uint)

Sets the push constant data to buffer for the specified drawList. The shader determines how this binary data is used. The buffer's size in bytes must also be specified in sizeBytes (this can be obtained by calling the PackedByteArray.size method on the passed buffer).

public void DrawListSetPushConstant(long drawList, byte[] buffer, uint sizeBytes)

Parameters

drawList long
buffer byte[]
sizeBytes uint

DrawListSwitchToNextPass()

Switches to the next draw pass and returns the split's ID. Equivalent to DrawListSwitchToNextPassSplit(uint) with splits set to 1.

public long DrawListSwitchToNextPass()

Returns

long

DrawListSwitchToNextPassSplit(uint)

Switches to the next draw pass, with the number of splits allocated specified in splits. The return value is an array containing the ID of each split. For single-split usage, see DrawListSwitchToNextPass().

public long[] DrawListSwitchToNextPassSplit(uint splits)

Parameters

splits uint

Returns

long[]

FramebufferCreate(Array<Rid>, long, uint)

Creates a new framebuffer. It can be accessed with the RID that is returned.

Once finished with your RID, you will want to free the RID using the RenderingDevice's FreeRid(Rid) method.

public Rid FramebufferCreate(Array<Rid> textures, long validateWithFormat = -1, uint viewCount = 1)

Parameters

textures Array<Rid>
validateWithFormat long
viewCount uint

Returns

Rid

FramebufferCreateEmpty(Vector2I, TextureSamples, long)

Creates a new empty framebuffer. It can be accessed with the RID that is returned.

Once finished with your RID, you will want to free the RID using the RenderingDevice's FreeRid(Rid) method.

public Rid FramebufferCreateEmpty(Vector2I size, RenderingDevice.TextureSamples samples = TextureSamples.Samples1, long validateWithFormat = -1)

Parameters

size Vector2I
samples RenderingDevice.TextureSamples
validateWithFormat long

Returns

Rid

FramebufferCreateMultipass(Array<Rid>, Array<RDFramebufferPass>, long, uint)

Creates a new multipass framebuffer. It can be accessed with the RID that is returned.

Once finished with your RID, you will want to free the RID using the RenderingDevice's FreeRid(Rid) method.

public Rid FramebufferCreateMultipass(Array<Rid> textures, Array<RDFramebufferPass> passes, long validateWithFormat = -1, uint viewCount = 1)

Parameters

textures Array<Rid>
passes Array<RDFramebufferPass>
validateWithFormat long
viewCount uint

Returns

Rid

FramebufferFormatCreate(Array<RDAttachmentFormat>, uint)

Creates a new framebuffer format with the specified attachments and viewCount. Returns the new framebuffer's unique framebuffer format ID.

If viewCount is greater than or equal to 2, enables multiview which is used for VR rendering. This requires support for the Vulkan multiview extension.

public long FramebufferFormatCreate(Array<RDAttachmentFormat> attachments, uint viewCount = 1)

Parameters

attachments Array<RDAttachmentFormat>
viewCount uint

Returns

long

FramebufferFormatCreateEmpty(TextureSamples)

Creates a new empty framebuffer format with the specified number of samples and returns its ID.

public long FramebufferFormatCreateEmpty(RenderingDevice.TextureSamples samples = TextureSamples.Samples1)

Parameters

samples RenderingDevice.TextureSamples

Returns

long

FramebufferFormatCreateMultipass(Array<RDAttachmentFormat>, Array<RDFramebufferPass>, uint)

Creates a multipass framebuffer format with the specified attachments, passes and viewCount and returns its ID. If viewCount is greater than or equal to 2, enables multiview which is used for VR rendering. This requires support for the Vulkan multiview extension.

public long FramebufferFormatCreateMultipass(Array<RDAttachmentFormat> attachments, Array<RDFramebufferPass> passes, uint viewCount = 1)

Parameters

attachments Array<RDAttachmentFormat>
passes Array<RDFramebufferPass>
viewCount uint

Returns

long

FramebufferFormatGetTextureSamples(long, uint)

Returns the number of texture samples used for the given framebuffer format ID (returned by FramebufferGetFormat(Rid)).

public RenderingDevice.TextureSamples FramebufferFormatGetTextureSamples(long format, uint renderPass = 0)

Parameters

format long
renderPass uint

Returns

RenderingDevice.TextureSamples

FramebufferGetFormat(Rid)

Returns the format ID of the framebuffer specified by the framebuffer RID. This ID is guaranteed to be unique for the same formats and does not need to be freed.

public long FramebufferGetFormat(Rid framebuffer)

Parameters

framebuffer Rid

Returns

long

FramebufferIsValid(Rid)

Returns true if the framebuffer specified by the framebuffer RID is valid, false otherwise.

public bool FramebufferIsValid(Rid framebuffer)

Parameters

framebuffer Rid

Returns

bool

FreeRid(Rid)

Tries to free an object in the RenderingDevice. To avoid memory leaks, this should be called after using an object as memory management does not occur automatically when using RenderingDevice directly.

public void FreeRid(Rid rid)

Parameters

rid Rid

FullBarrier()

Puts a full memory barrier in place. This is a memory Barrier(BarrierMask, BarrierMask) with all flags enabled. FullBarrier() it should only be used for debugging as it can severely impact performance.

public void FullBarrier()

GetCapturedTimestampCpuTime(uint)

Returns the timestamp in CPU time for the rendering step specified by index (in microseconds since the engine started). See also GetCapturedTimestampGpuTime(uint) and CaptureTimestamp(string).

public ulong GetCapturedTimestampCpuTime(uint index)

Parameters

index uint

Returns

ulong

GetCapturedTimestampGpuTime(uint)

Returns the timestamp in GPU time for the rendering step specified by index (in microseconds since the engine started). See also GetCapturedTimestampCpuTime(uint) and CaptureTimestamp(string).

public ulong GetCapturedTimestampGpuTime(uint index)

Parameters

index uint

Returns

ulong

GetCapturedTimestampName(uint)

Returns the timestamp's name for the rendering step specified by index. See also CaptureTimestamp(string).

public string GetCapturedTimestampName(uint index)

Parameters

index uint

Returns

string

GetCapturedTimestampsCount()

Returns the total number of timestamps (rendering steps) available for profiling.

public uint GetCapturedTimestampsCount()

Returns

uint

GetCapturedTimestampsFrame()

Returns the index of the last frame rendered that has rendering timestamps available for querying.

public ulong GetCapturedTimestampsFrame()

Returns

ulong

GetDeviceName()

Returns the name of the video adapter (e.g. "GeForce GTX 1080/PCIe/SSE2"). Equivalent to GetVideoAdapterName(). See also GetDeviceVendorName().

public string GetDeviceName()

Returns

string

GetDevicePipelineCacheUuid()

Returns the universally unique identifier for the pipeline cache. This is used to cache shader files on disk, which avoids shader recompilations on subsequent engine runs. This UUID varies depending on the graphics card model, but also the driver version. Therefore, updating graphics drivers will invalidate the shader cache.

public string GetDevicePipelineCacheUuid()

Returns

string

GetDeviceVendorName()

Returns the vendor of the video adapter (e.g. "NVIDIA Corporation"). Equivalent to GetVideoAdapterVendor(). See also GetDeviceName().

public string GetDeviceVendorName()

Returns

string

GetDriverResource(DriverResource, Rid, ulong)

Returns the unique identifier of the driver resource for the specified rid. Some driver resource types ignore the specified rid (see RenderingDevice.DriverResource descriptions). index is always ignored but must be specified anyway.

public ulong GetDriverResource(RenderingDevice.DriverResource resource, Rid rid, ulong index)

Parameters

resource RenderingDevice.DriverResource
rid Rid
index ulong

Returns

ulong

GetFrameDelay()

Returns the frame count kept by the graphics API. Higher values result in higher input lag, but with more consistent throughput. For the main RenderingDevice, frames are cycled (usually 3 with triple-buffered V-Sync enabled). However, local RenderingDevices only have 1 frame.

public uint GetFrameDelay()

Returns

uint

GetMemoryUsage(MemoryType)

Returns the memory usage in bytes corresponding to the given type. When using Vulkan, these statistics are calculated by Vulkan Memory Allocator.

public ulong GetMemoryUsage(RenderingDevice.MemoryType type)

Parameters

type RenderingDevice.MemoryType

Returns

ulong

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

IndexArrayCreate(Rid, uint, uint)

Creates a new index array. It can be accessed with the RID that is returned.

Once finished with your RID, you will want to free the RID using the RenderingDevice's FreeRid(Rid) method.

public Rid IndexArrayCreate(Rid indexBuffer, uint indexOffset, uint indexCount)

Parameters

indexBuffer Rid
indexOffset uint
indexCount uint

Returns

Rid

IndexBufferCreate(uint, IndexBufferFormat, byte[], bool)

Creates a new index buffer. It can be accessed with the RID that is returned.

Once finished with your RID, you will want to free the RID using the RenderingDevice's FreeRid(Rid) method.

public Rid IndexBufferCreate(uint sizeIndices, RenderingDevice.IndexBufferFormat format, byte[] data = null, bool useRestartIndices = false)

Parameters

sizeIndices uint
format RenderingDevice.IndexBufferFormat
data byte[]

If the parameter is null, then the default value is Array.Empty<byte>().

useRestartIndices bool

Returns

Rid

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

LimitGet(Limit)

Returns the value of the specified limit. This limit varies depending on the current graphics hardware (and sometimes the driver version). If the given limit is exceeded, rendering errors will occur.

Limits for various graphics hardware can be found in the Vulkan Hardware Database.

public ulong LimitGet(RenderingDevice.Limit limit)

Parameters

limit RenderingDevice.Limit

Returns

ulong

RenderPipelineCreate(Rid, long, long, RenderPrimitive, RDPipelineRasterizationState, RDPipelineMultisampleState, RDPipelineDepthStencilState, RDPipelineColorBlendState, PipelineDynamicStateFlags, uint, Array<RDPipelineSpecializationConstant>)

Creates a new render pipeline. It can be accessed with the RID that is returned.

Once finished with your RID, you will want to free the RID using the RenderingDevice's FreeRid(Rid) method.

public Rid RenderPipelineCreate(Rid shader, long framebufferFormat, long vertexFormat, RenderingDevice.RenderPrimitive primitive, RDPipelineRasterizationState rasterizationState, RDPipelineMultisampleState multisampleState, RDPipelineDepthStencilState stencilState, RDPipelineColorBlendState colorBlendState, RenderingDevice.PipelineDynamicStateFlags dynamicStateFlags = (RenderingDevice.PipelineDynamicStateFlags)0, uint forRenderPass = 0, Array<RDPipelineSpecializationConstant> specializationConstants = null)

Parameters

shader Rid
framebufferFormat long
vertexFormat long
primitive RenderingDevice.RenderPrimitive
rasterizationState RDPipelineRasterizationState
multisampleState RDPipelineMultisampleState
stencilState RDPipelineDepthStencilState
colorBlendState RDPipelineColorBlendState
dynamicStateFlags RenderingDevice.PipelineDynamicStateFlags
forRenderPass uint
specializationConstants Array<RDPipelineSpecializationConstant>

Returns

Rid

RenderPipelineIsValid(Rid)

Returns true if the render pipeline specified by the renderPipeline RID is valid, false otherwise.

public bool RenderPipelineIsValid(Rid renderPipeline)

Parameters

renderPipeline Rid

Returns

bool

SamplerCreate(RDSamplerState)

Creates a new sampler. It can be accessed with the RID that is returned.

Once finished with your RID, you will want to free the RID using the RenderingDevice's FreeRid(Rid) method.

public Rid SamplerCreate(RDSamplerState state)

Parameters

state RDSamplerState

Returns

Rid

SamplerIsFormatSupportedForFilter(DataFormat, SamplerFilter)

Returns true if implementation supports using a texture of format with the given samplerFilter.

public bool SamplerIsFormatSupportedForFilter(RenderingDevice.DataFormat format, RenderingDevice.SamplerFilter samplerFilter)

Parameters

format RenderingDevice.DataFormat
samplerFilter RenderingDevice.SamplerFilter

Returns

bool

ScreenGetFramebufferFormat()

Returns the screen's framebuffer format.

Note: Only the main RenderingDevice returned by GetRenderingDevice() has a format. If called on a local RenderingDevice, this method prints an error and returns InvalidId.

public long ScreenGetFramebufferFormat()

Returns

long

ScreenGetHeight(int)

Returns the window height matching the graphics API context for the given window ID (in pixels). Despite the parameter being named screen, this returns the window size. See also ScreenGetWidth(int).

Note: Only the main RenderingDevice returned by GetRenderingDevice() has a height. If called on a local RenderingDevice, this method prints an error and returns InvalidId.

public int ScreenGetHeight(int screen = 0)

Parameters

screen int

Returns

int

ScreenGetWidth(int)

Returns the window width matching the graphics API context for the given window ID (in pixels). Despite the parameter being named screen, this returns the window size. See also ScreenGetHeight(int).

Note: Only the main RenderingDevice returned by GetRenderingDevice() has a width. If called on a local RenderingDevice, this method prints an error and returns InvalidId.

public int ScreenGetWidth(int screen = 0)

Parameters

screen int

Returns

int

SetResourceName(Rid, string)

Sets the resource name for id to name. This is used for debugging with third-party tools such as RenderDoc.

The following types of resources can be named: texture, sampler, vertex buffer, index buffer, uniform buffer, texture buffer, storage buffer, uniform set buffer, shader, render pipeline and compute pipeline. Framebuffers cannot be named. Attempting to name an incompatible resource type will print an error.

Note: Resource names are only set when the engine runs in verbose mode (IsStdOutVerbose() = true), or when using an engine build compiled with the dev_mode=yes SCons option. The graphics driver must also support the VK_EXT_DEBUG_UTILS_EXTENSION_NAME Vulkan extension for named resources to work.

public void SetResourceName(Rid id, string name)

Parameters

id Rid
name string

ShaderCompileBinaryFromSpirV(RDShaderSpirV, string)

Compiles a binary shader from spirVData and returns the compiled binary data as a byte[]. This compiled shader is specific to the GPU model and driver version used; it will not work on different GPU models or even different driver versions. See also ShaderCompileSpirVFromSource(RDShaderSource, bool).

name is an optional human-readable name that can be given to the compiled shader for organizational purposes.

public byte[] ShaderCompileBinaryFromSpirV(RDShaderSpirV spirVData, string name = "")

Parameters

spirVData RDShaderSpirV
name string

Returns

byte[]

ShaderCompileSpirVFromSource(RDShaderSource, bool)

Compiles a SPIR-V from the shader source code in shaderSource and returns the SPIR-V as a RDShaderSpirV. This intermediate language shader is portable across different GPU models and driver versions, but cannot be run directly by GPUs until compiled into a binary shader using ShaderCompileBinaryFromSpirV(RDShaderSpirV, string).

If allowCache is true, make use of the shader cache generated by Godot. This avoids a potentially lengthy shader compilation step if the shader is already in cache. If allowCache is false, Godot's shader cache is ignored and the shader will always be recompiled.

public RDShaderSpirV ShaderCompileSpirVFromSource(RDShaderSource shaderSource, bool allowCache = true)

Parameters

shaderSource RDShaderSource
allowCache bool

Returns

RDShaderSpirV

ShaderCreateFromBytecode(byte[], Rid)

Creates a new shader instance from a binary compiled shader. It can be accessed with the RID that is returned.

Once finished with your RID, you will want to free the RID using the RenderingDevice's FreeRid(Rid) method. See also ShaderCompileBinaryFromSpirV(RDShaderSpirV, string) and ShaderCreateFromSpirV(RDShaderSpirV, string).

public Rid ShaderCreateFromBytecode(byte[] binaryData, Rid placeholderRid = default)

Parameters

binaryData byte[]
placeholderRid Rid

Returns

Rid

ShaderCreateFromSpirV(RDShaderSpirV, string)

Creates a new shader instance from SPIR-V intermediate code. It can be accessed with the RID that is returned.

Once finished with your RID, you will want to free the RID using the RenderingDevice's FreeRid(Rid) method. See also ShaderCompileSpirVFromSource(RDShaderSource, bool) and ShaderCreateFromBytecode(byte[], Rid).

public Rid ShaderCreateFromSpirV(RDShaderSpirV spirVData, string name = "")

Parameters

spirVData RDShaderSpirV
name string

Returns

Rid

ShaderCreatePlaceholder()

Create a placeholder RID by allocating an RID without initializing it for use in ShaderCreateFromBytecode(byte[], Rid). This allows you to create an RID for a shader and pass it around, but defer compiling the shader to a later time.

public Rid ShaderCreatePlaceholder()

Returns

Rid

ShaderGetVertexInputAttributeMask(Rid)

Returns the internal vertex input mask. Internally, the vertex input mask is an unsigned integer consisting of the locations (specified in GLSL via. layout(location = ...)) of the input variables (specified in GLSL by the in keyword).

public ulong ShaderGetVertexInputAttributeMask(Rid shader)

Parameters

shader Rid

Returns

ulong

StorageBufferCreate(uint, byte[], StorageBufferUsage)

Creates a storage buffer with the specified data and usage. It can be accessed with the RID that is returned.

Once finished with your RID, you will want to free the RID using the RenderingDevice's FreeRid(Rid) method.

public Rid StorageBufferCreate(uint sizeBytes, byte[] data = null, RenderingDevice.StorageBufferUsage usage = (RenderingDevice.StorageBufferUsage)0)

Parameters

sizeBytes uint
data byte[]

If the parameter is null, then the default value is Array.Empty<byte>().

usage RenderingDevice.StorageBufferUsage

Returns

Rid

Submit()

Pushes the frame setup and draw command buffers then marks the local device as currently processing (which allows calling Sync()).

Note: Only available in local RenderingDevices.

public void Submit()

Sync()

Forces a synchronization between the CPU and GPU, which may be required in certain cases. Only call this when needed, as CPU-GPU synchronization has a performance cost.

Note: Only available in local RenderingDevices.

Note: Sync() can only be called after a Submit().

public void Sync()

TextureBufferCreate(uint, DataFormat, byte[])

Creates a new texture buffer. It can be accessed with the RID that is returned.

Once finished with your RID, you will want to free the RID using the RenderingDevice's FreeRid(Rid) method.

public Rid TextureBufferCreate(uint sizeBytes, RenderingDevice.DataFormat format, byte[] data = null)

Parameters

sizeBytes uint
format RenderingDevice.DataFormat
data byte[]

If the parameter is null, then the default value is Array.Empty<byte>().

Returns

Rid

TextureClear(Rid, Color, uint, uint, uint, uint, BarrierMask)

Clears the specified texture by replacing all of its pixels with the specified color. baseMipmap and mipmapCount determine which mipmaps of the texture are affected by this clear operation, while baseLayer and layerCount determine which layers of a 3D texture (or texture array) are affected by this clear operation. For 2D textures (which only have one layer by design), baseLayer must be 0 and layerCount must be 1.

Note: texture can't be cleared while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to Continue) to clear this texture.

public Error TextureClear(Rid texture, Color color, uint baseMipmap, uint mipmapCount, uint baseLayer, uint layerCount, RenderingDevice.BarrierMask postBarrier = BarrierMask.AllBarriers)

Parameters

texture Rid
color Color
baseMipmap uint
mipmapCount uint
baseLayer uint
layerCount uint
postBarrier RenderingDevice.BarrierMask

Returns

Error

TextureCopy(Rid, Rid, Vector3, Vector3, Vector3, uint, uint, uint, uint, BarrierMask)

Copies the fromTexture to toTexture with the specified fromPos, toPos and size coordinates. The Z axis of the fromPos, toPos and size must be 0 for 2-dimensional textures. Source and destination mipmaps/layers must also be specified, with these parameters being 0 for textures without mipmaps or single-layer textures. Returns Ok if the texture copy was successful or InvalidParameter otherwise.

Note: fromTexture texture can't be copied while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to Continue) to copy this texture.

Note: fromTexture texture requires the CanCopyFromBit to be retrieved.

Note: toTexture can't be copied while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to Continue) to copy this texture.

Note: toTexture requires the CanCopyToBit to be retrieved.

Note: fromTexture and toTexture must be of the same type (color or depth).

public Error TextureCopy(Rid fromTexture, Rid toTexture, Vector3 fromPos, Vector3 toPos, Vector3 size, uint srcMipmap, uint dstMipmap, uint srcLayer, uint dstLayer, RenderingDevice.BarrierMask postBarrier = BarrierMask.AllBarriers)

Parameters

fromTexture Rid
toTexture Rid
fromPos Vector3
toPos Vector3
size Vector3
srcMipmap uint
dstMipmap uint
srcLayer uint
dstLayer uint
postBarrier RenderingDevice.BarrierMask

Returns

Error

TextureCreate(RDTextureFormat, RDTextureView, Array<byte[]>)

Creates a new texture. It can be accessed with the RID that is returned.

Once finished with your RID, you will want to free the RID using the RenderingDevice's FreeRid(Rid) method.

Note: Not to be confused with Texture2DCreate(Image), which creates the Godot-specific Texture2D resource as opposed to the graphics API's own texture type.

public Rid TextureCreate(RDTextureFormat format, RDTextureView view, Array<byte[]> data = null)

Parameters

format RDTextureFormat
view RDTextureView
data Array<byte[]>

Returns

Rid

TextureCreateFromExtension(TextureType, DataFormat, TextureSamples, TextureUsageBits, ulong, ulong, ulong, ulong, ulong)

Returns an RID for an existing image (VkImage) with the given type, format, samples, usageFlags, width, height, depth, and layers. This can be used to allow Godot to render onto foreign images.

public Rid TextureCreateFromExtension(RenderingDevice.TextureType type, RenderingDevice.DataFormat format, RenderingDevice.TextureSamples samples, RenderingDevice.TextureUsageBits usageFlags, ulong image, ulong width, ulong height, ulong depth, ulong layers)

Parameters

type RenderingDevice.TextureType
format RenderingDevice.DataFormat
samples RenderingDevice.TextureSamples
usageFlags RenderingDevice.TextureUsageBits
image ulong
width ulong
height ulong
depth ulong
layers ulong

Returns

Rid

TextureCreateShared(RDTextureView, Rid)

Creates a shared texture using the specified view and the texture information from withTexture.

public Rid TextureCreateShared(RDTextureView view, Rid withTexture)

Parameters

view RDTextureView
withTexture Rid

Returns

Rid

TextureCreateSharedFromSlice(RDTextureView, Rid, uint, uint, uint, TextureSliceType)

Creates a shared texture using the specified view and the texture information from withTexture's layer and mipmap. The number of included mipmaps from the original texture can be controlled using the mipmaps parameter. Only relevant for textures with multiple layers, such as 3D textures, texture arrays and cubemaps. For single-layer textures, use TextureCreateShared(RDTextureView, Rid)

For 2D textures (which only have one layer), layer must be 0.

Note: Layer slicing is only supported for 2D texture arrays, not 3D textures or cubemaps.

public Rid TextureCreateSharedFromSlice(RDTextureView view, Rid withTexture, uint layer, uint mipmap, uint mipmaps = 1, RenderingDevice.TextureSliceType sliceType = TextureSliceType.Slice2D)

Parameters

view RDTextureView
withTexture Rid
layer uint
mipmap uint
mipmaps uint
sliceType RenderingDevice.TextureSliceType

Returns

Rid

TextureGetData(Rid, uint)

Returns the texture data for the specified layer as raw binary data. For 2D textures (which only have one layer), layer must be 0.

Note: texture can't be retrieved while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to Continue) to retrieve this texture. Otherwise, an error is printed and a empty byte[] is returned.

Note: texture requires the CanCopyFromBit to be retrieved. Otherwise, an error is printed and a empty byte[] is returned.

public byte[] TextureGetData(Rid texture, uint layer)

Parameters

texture Rid
layer uint

Returns

byte[]

TextureGetFormat(Rid)

Returns the data format used to create this texture.

public RDTextureFormat TextureGetFormat(Rid texture)

Parameters

texture Rid

Returns

RDTextureFormat

TextureGetNativeHandle(Rid)

Returns the internal graphics handle for this texture object. For use when communicating with third-party APIs mostly with GDExtension.

Note: This function returns a uint64_t which internally maps to a GLuint (OpenGL) or VkImage (Vulkan).

public ulong TextureGetNativeHandle(Rid texture)

Parameters

texture Rid

Returns

ulong

TextureIsFormatSupportedForUsage(DataFormat, TextureUsageBits)

Returns true if the specified format is supported for the given usageFlags, false otherwise.

public bool TextureIsFormatSupportedForUsage(RenderingDevice.DataFormat format, RenderingDevice.TextureUsageBits usageFlags)

Parameters

format RenderingDevice.DataFormat
usageFlags RenderingDevice.TextureUsageBits

Returns

bool

TextureIsShared(Rid)

Returns true if the texture is shared, false otherwise. See RDTextureView.

public bool TextureIsShared(Rid texture)

Parameters

texture Rid

Returns

bool

TextureIsValid(Rid)

Returns true if the texture is valid, false otherwise.

public bool TextureIsValid(Rid texture)

Parameters

texture Rid

Returns

bool

TextureResolveMultisample(Rid, Rid, BarrierMask)

Resolves the fromTexture texture onto toTexture with multisample antialiasing enabled. This must be used when rendering a framebuffer for MSAA to work. Returns Ok if successful, InvalidParameter otherwise.

Note: fromTexture and toTexture textures must have the same dimension, format and type (color or depth).

Note: fromTexture can't be copied while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to Continue) to resolve this texture.

Note: fromTexture requires the CanCopyFromBit to be retrieved.

Note: fromTexture must be multisampled and must also be 2D (or a slice of a 3D/cubemap texture).

Note: toTexture can't be copied while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to Continue) to resolve this texture.

Note: toTexture texture requires the CanCopyToBit to be retrieved.

Note: toTexture texture must not be multisampled and must also be 2D (or a slice of a 3D/cubemap texture).

public Error TextureResolveMultisample(Rid fromTexture, Rid toTexture, RenderingDevice.BarrierMask postBarrier = BarrierMask.AllBarriers)

Parameters

fromTexture Rid
toTexture Rid
postBarrier RenderingDevice.BarrierMask

Returns

Error

TextureUpdate(Rid, uint, byte[], BarrierMask)

Updates texture data with new data, replacing the previous data in place. The updated texture data must have the same dimensions and format. For 2D textures (which only have one layer), layer must be 0. Returns Ok if the update was successful, InvalidParameter otherwise.

Note: Updating textures is forbidden during creation of a draw or compute list.

Note: The existing texture can't be updated while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to Continue) to update this texture.

Note: The existing texture requires the CanUpdateBit to be updatable.

public Error TextureUpdate(Rid texture, uint layer, byte[] data, RenderingDevice.BarrierMask postBarrier = BarrierMask.AllBarriers)

Parameters

texture Rid
layer uint
data byte[]
postBarrier RenderingDevice.BarrierMask

Returns

Error

UniformBufferCreate(uint, byte[])

Creates a new uniform buffer. It can be accessed with the RID that is returned.

Once finished with your RID, you will want to free the RID using the RenderingDevice's FreeRid(Rid) method.

public Rid UniformBufferCreate(uint sizeBytes, byte[] data = null)

Parameters

sizeBytes uint
data byte[]

If the parameter is null, then the default value is Array.Empty<byte>().

Returns

Rid

UniformSetCreate(Array<RDUniform>, Rid, uint)

Creates a new uniform set. It can be accessed with the RID that is returned.

Once finished with your RID, you will want to free the RID using the RenderingDevice's FreeRid(Rid) method.

public Rid UniformSetCreate(Array<RDUniform> uniforms, Rid shader, uint shaderSet)

Parameters

uniforms Array<RDUniform>
shader Rid
shaderSet uint

Returns

Rid

UniformSetIsValid(Rid)

Checks if the uniformSet is valid, i.e. is owned.

public bool UniformSetIsValid(Rid uniformSet)

Parameters

uniformSet Rid

Returns

bool

VertexArrayCreate(uint, long, Array<Rid>, long[])

Creates a vertex array based on the specified buffers. Optionally, offsets (in bytes) may be defined for each buffer.

public Rid VertexArrayCreate(uint vertexCount, long vertexFormat, Array<Rid> srcBuffers, long[] offsets = null)

Parameters

vertexCount uint
vertexFormat long
srcBuffers Array<Rid>
offsets long[]

If the parameter is null, then the default value is Array.Empty<long>().

Returns

Rid

VertexBufferCreate(uint, byte[], bool)

It can be accessed with the RID that is returned.

Once finished with your RID, you will want to free the RID using the RenderingDevice's FreeRid(Rid) method.

public Rid VertexBufferCreate(uint sizeBytes, byte[] data = null, bool useAsStorage = false)

Parameters

sizeBytes uint
data byte[]

If the parameter is null, then the default value is Array.Empty<byte>().

useAsStorage bool

Returns

Rid

VertexFormatCreate(Array<RDVertexAttribute>)

Creates a new vertex format with the specified vertexDescriptions. Returns a unique vertex format ID corresponding to the newly created vertex format.

public long VertexFormatCreate(Array<RDVertexAttribute> vertexDescriptions)

Parameters

vertexDescriptions Array<RDVertexAttribute>

Returns

long