Documentation
¶
Overview ¶
graphics.gd/classdb/RenderingDevice is an abstraction for working with modern low-level graphics APIs such as Vulkan. Compared to graphics.gd/classdb/RenderingServer (which works with Godot's own rendering subsystems), graphics.gd/classdb/RenderingDevice is much lower-level and allows working more directly with the underlying graphics APIs. graphics.gd/classdb/RenderingDevice is used in Godot to provide support for several modern low-level graphics APIs while reducing the amount of code duplication required. graphics.gd/classdb/RenderingDevice can also be used in your own projects to perform things that are not exposed by graphics.gd/classdb/RenderingServer or high-level nodes, such as using compute shaders.
On startup, Godot creates a global graphics.gd/classdb/RenderingDevice which can be retrieved using graphics.gd/classdb/RenderingServer.GetRenderingDevice. This global graphics.gd/classdb/RenderingDevice performs drawing to the screen.
Local RenderingDevices: Using graphics.gd/classdb/RenderingServer.CreateLocalRenderingDevice, you can create "secondary" rendering devices to perform drawing and GPU compute operations on separate threads.
Note: graphics.gd/classdb/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: graphics.gd/classdb/RenderingDevice is not available when running in headless mode or when using the Compatibility rendering method.
Index ¶
- Constants
- type Advanced
- type Any
- type Expanded
- func (self Expanded) Barrier(from Rendering.BarrierMask, to Rendering.BarrierMask)
- func (self Expanded) BufferGetData(buffer RID.Buffer, offset_bytes int, size_bytes int) []byte
- func (self Expanded) BufferGetDataAsync(buffer RID.Buffer, callback func(data []byte), offset_bytes int, ...) error
- func (self Expanded) ComputePipelineCreate(shader RID.Shader, ...) RID.ComputePipeline
- func (self Expanded) DrawListBegin(framebuffer RID.Framebuffer, draw_flags Rendering.DrawFlags, ...) int
- func (self Expanded) DrawListBeginForScreen(screen int, clear_color Color.RGBA) int
- func (self Expanded) DrawListBeginSplit(framebuffer RID.Framebuffer, splits int, ...) []int64
- func (self Expanded) DrawListDraw(draw_list int, use_indices bool, instances int, procedural_vertex_count int)
- func (self Expanded) DrawListDrawIndirect(draw_list int, use_indices bool, buffer RID.Buffer, offset int, draw_count int, ...)
- func (self Expanded) DrawListEnableScissor(draw_list int, rect Rect2.PositionSize)
- func (self Expanded) FramebufferCreate(textures [][]RID.Texture, validate_with_format int, view_count int) RID.Framebuffer
- func (self Expanded) FramebufferCreateEmpty(size Vector2i.XY, samples Rendering.TextureSamples, validate_with_format int) RID.Framebuffer
- func (self Expanded) FramebufferCreateMultipass(textures [][]RID.Texture, passes []RDFramebufferPass.Instance, ...) RID.Framebuffer
- func (self Expanded) FramebufferFormatCreate(attachments []RDAttachmentFormat.Instance, view_count int) int
- func (self Expanded) FramebufferFormatCreateEmpty(samples Rendering.TextureSamples) int
- func (self Expanded) FramebufferFormatCreateMultipass(attachments []RDAttachmentFormat.Instance, passes []RDFramebufferPass.Instance, ...) int
- func (self Expanded) FramebufferFormatGetTextureSamples(format int, render_pass int) Rendering.TextureSamples
- func (self Expanded) IndexBufferCreate(size_indices int, format Rendering.IndexBufferFormat, data []byte, ...) RID.IndexBuffer
- func (self Expanded) RenderPipelineCreate(shader RID.Shader, framebuffer_format int, vertex_format int, ...) RID.RenderPipeline
- func (self Expanded) ScreenGetFramebufferFormat(screen int) int
- func (self Expanded) ScreenGetHeight(screen int) int
- func (self Expanded) ScreenGetWidth(screen int) int
- func (self Expanded) ShaderCompileBinaryFromSpirv(spirv_data RDShaderSPIRV.Instance, name string) []byte
- func (self Expanded) ShaderCompileSpirvFromSource(shader_source RDShaderSource.Instance, allow_cache bool) RDShaderSPIRV.Instance
- func (self Expanded) ShaderCreateFromBytecode(binary_data []byte, placeholder_rid RID.ShaderPlaceholder) RID.Shader
- func (self Expanded) ShaderCreateFromSpirv(spirv_data RDShaderSPIRV.Instance, name string) RID.Shader
- func (self Expanded) StorageBufferCreate(size_bytes int, data []byte, usage Rendering.StorageBufferUsage, ...) RID.StorageBuffer
- func (self Expanded) TextureBufferCreate(size_bytes int, format Rendering.DataFormat, data []byte) RID.TextureBuffer
- func (self Expanded) TextureCreate(format RDTextureFormat.Instance, view RDTextureView.Instance, data [][]byte) RID.Texture
- func (self Expanded) TextureCreateFromExtension(atype Rendering.TextureType, format Rendering.DataFormat, ...) RID.Texture
- func (self Expanded) TextureCreateSharedFromSlice(view RDTextureView.Instance, with_texture RID.Texture, layer int, mipmap int, ...) RID.Texture
- func (self Expanded) UniformBufferCreate(size_bytes int, data []byte, creation_bits Rendering.BufferCreationBits) RID.UniformBuffer
- func (self Expanded) VertexArrayCreate(vertex_count int, vertex_format int, src_buffers [][]RID.VertexBuffer, ...) RID.VertexArray
- func (self Expanded) VertexBufferCreate(size_bytes int, data []byte, creation_bits Rendering.BufferCreationBits) RID.VertexBuffer
- type Extension
- type ID
- type Instance
- func (self Instance) AsObject() [1]gd.Object
- func (self Instance) AsRenderingDevice() Instance
- func (self Instance) Barrier()
- func (self Instance) BufferClear(buffer RID.Buffer, offset int, size_bytes int) error
- func (self Instance) BufferCopy(src_buffer RID.Buffer, dst_buffer RID.Buffer, src_offset int, dst_offset int, ...) error
- func (self Instance) BufferGetData(buffer RID.Buffer) []byte
- func (self Instance) BufferGetDataAsync(buffer RID.Buffer, callback func(data []byte)) error
- func (self Instance) BufferGetDeviceAddress(buffer RID.Buffer) int
- func (self Instance) BufferUpdate(buffer RID.Buffer, offset int, size_bytes int, data []byte) error
- func (self Instance) CaptureTimestamp(name string)
- func (self Instance) ComputeListAddBarrier(compute_list int)
- func (self Instance) ComputeListBegin() int
- func (self Instance) ComputeListBindComputePipeline(compute_list int, compute_pipeline RID.ComputePipeline)
- func (self Instance) ComputeListBindUniformSet(compute_list int, uniform_set RID.UniformSet, set_index int)
- func (self Instance) ComputeListDispatch(compute_list int, x_groups int, y_groups int, z_groups int)
- func (self Instance) ComputeListDispatchIndirect(compute_list int, buffer RID.Buffer, offset int)
- func (self Instance) ComputeListEnd()
- func (self Instance) ComputeListSetPushConstant(compute_list int, buffer []byte, size_bytes int)
- func (self Instance) ComputePipelineCreate(shader RID.Shader) RID.ComputePipeline
- func (self Instance) ComputePipelineIsValid(compute_pipeline RID.ComputePipeline) bool
- func (self Instance) CreateLocalDevice() Instance
- func (self Instance) DrawCommandBeginLabel(name string, color Color.RGBA)
- func (self Instance) DrawCommandEndLabel()
- func (self Instance) DrawCommandInsertLabel(name string, color Color.RGBA)
- func (self Instance) DrawListBegin(framebuffer RID.Framebuffer) int
- func (self Instance) DrawListBeginForScreen() int
- func (self Instance) DrawListBeginSplit(framebuffer RID.Framebuffer, splits int, ...) []int64
- func (self Instance) DrawListBindIndexArray(draw_list int, index_array RID.IndexArray)
- func (self Instance) DrawListBindRenderPipeline(draw_list int, render_pipeline RID.RenderPipeline)
- func (self Instance) DrawListBindUniformSet(draw_list int, uniform_set RID.UniformSet, set_index int)
- func (self Instance) DrawListBindVertexArray(draw_list int, vertex_array RID.VertexArray)
- func (self Instance) DrawListDisableScissor(draw_list int)
- func (self Instance) DrawListDraw(draw_list int, use_indices bool, instances int)
- func (self Instance) DrawListDrawIndirect(draw_list int, use_indices bool, buffer RID.Buffer)
- func (self Instance) DrawListEnableScissor(draw_list int)
- func (self Instance) DrawListEnd()
- func (self Instance) DrawListSetBlendConstants(draw_list int, color Color.RGBA)
- func (self Instance) DrawListSetPushConstant(draw_list int, buffer []byte, size_bytes int)
- func (self Instance) DrawListSwitchToNextPass() int
- func (self Instance) DrawListSwitchToNextPassSplit(splits int) []int64
- func (self Instance) FramebufferCreate(textures [][]RID.Texture) RID.Framebuffer
- func (self Instance) FramebufferCreateEmpty(size Vector2i.XY) RID.Framebuffer
- func (self Instance) FramebufferCreateMultipass(textures [][]RID.Texture, passes []RDFramebufferPass.Instance) RID.Framebuffer
- func (self Instance) FramebufferFormatCreate(attachments []RDAttachmentFormat.Instance) int
- func (self Instance) FramebufferFormatCreateEmpty() int
- func (self Instance) FramebufferFormatCreateMultipass(attachments []RDAttachmentFormat.Instance, passes []RDFramebufferPass.Instance) int
- func (self Instance) FramebufferFormatGetTextureSamples(format int) Rendering.TextureSamples
- func (self Instance) FramebufferGetFormat(framebuffer RID.Framebuffer) int
- func (self Instance) FramebufferIsValid(framebuffer RID.Framebuffer) bool
- func (self Instance) FreeRid(rid RID.Any)
- func (self Instance) FullBarrier()
- func (self Instance) GetCapturedTimestampCpuTime(index int) int
- func (self Instance) GetCapturedTimestampGpuTime(index int) int
- func (self Instance) GetCapturedTimestampName(index int) string
- func (self Instance) GetCapturedTimestampsCount() int
- func (self Instance) GetCapturedTimestampsFrame() int
- func (self Instance) GetDeviceAllocationCount() int
- func (self Instance) GetDeviceAllocsByObjectType(atype int) int
- func (self Instance) GetDeviceMemoryByObjectType(atype int) int
- func (self Instance) GetDeviceName() string
- func (self Instance) GetDevicePipelineCacheUuid() string
- func (self Instance) GetDeviceTotalMemory() int
- func (self Instance) GetDeviceVendorName() string
- func (self Instance) GetDriverAllocationCount() int
- func (self Instance) GetDriverAllocsByObjectType(atype int) int
- func (self Instance) GetDriverAndDeviceMemoryReport() string
- func (self Instance) GetDriverMemoryByObjectType(atype int) int
- func (self Instance) GetDriverResource(resource Rendering.DriverResource, rid RID.Any, index int) int
- func (self Instance) GetDriverTotalMemory() int
- func (self Instance) GetFrameDelay() int
- func (self Instance) GetMemoryUsage(atype Rendering.MemoryType) int
- func (self Instance) GetPerfReport() string
- func (self Instance) GetTrackedObjectName(type_index int) string
- func (self Instance) GetTrackedObjectTypeCount() int
- func (self Instance) HasFeature(feature Rendering.Features) bool
- func (self Instance) ID() ID
- func (self Instance) IndexArrayCreate(index_buffer RID.IndexBuffer, index_offset int, index_count int) RID.IndexArray
- func (self Instance) IndexBufferCreate(size_indices int, format Rendering.IndexBufferFormat) RID.IndexBuffer
- func (self Instance) LimitGet(limit Rendering.Limit) int
- func (self Instance) RenderPipelineCreate(shader RID.Shader, framebuffer_format int, vertex_format int, ...) RID.RenderPipeline
- func (self Instance) RenderPipelineIsValid(render_pipeline RID.RenderPipeline) bool
- func (self Instance) SamplerCreate(state RDSamplerState.Instance) RID.Sampler
- func (self Instance) SamplerIsFormatSupportedForFilter(format Rendering.DataFormat, sampler_filter Rendering.SamplerFilter) bool
- func (self Instance) ScreenGetFramebufferFormat() int
- func (self Instance) ScreenGetHeight() int
- func (self Instance) ScreenGetWidth() int
- func (self *Instance) SetObject(obj [1]gd.Object) bool
- func (self Instance) SetResourceName(id RID.Any, name string)
- func (self Instance) ShaderCompileBinaryFromSpirv(spirv_data RDShaderSPIRV.Instance) []byte
- func (self Instance) ShaderCompileSpirvFromSource(shader_source RDShaderSource.Instance) RDShaderSPIRV.Instance
- func (self Instance) ShaderCreateFromBytecode(binary_data []byte) RID.Shader
- func (self Instance) ShaderCreateFromSpirv(spirv_data RDShaderSPIRV.Instance) RID.Shader
- func (self Instance) ShaderCreatePlaceholder() RID.ShaderPlaceholder
- func (self Instance) ShaderGetVertexInputAttributeMask(shader RID.Shader) int
- func (self Instance) StorageBufferCreate(size_bytes int) RID.StorageBuffer
- func (self Instance) Submit()
- func (self Instance) Sync()
- func (self Instance) TextureBufferCreate(size_bytes int, format Rendering.DataFormat) RID.TextureBuffer
- func (self Instance) TextureClear(texture RID.Texture, color Color.RGBA, base_mipmap int, mipmap_count int, ...) error
- func (self Instance) TextureCopy(from_texture RID.Texture, to_texture RID.Texture, from_pos Vector3.XYZ, ...) error
- func (self Instance) TextureCreate(format RDTextureFormat.Instance, view RDTextureView.Instance) RID.Texture
- func (self Instance) TextureCreateFromExtension(atype Rendering.TextureType, format Rendering.DataFormat, ...) RID.Texture
- func (self Instance) TextureCreateShared(view RDTextureView.Instance, with_texture RID.Texture) RID.Texture
- func (self Instance) TextureCreateSharedFromSlice(view RDTextureView.Instance, with_texture RID.Texture, layer int, mipmap int) RID.Texture
- func (self Instance) TextureGetData(texture RID.Texture, layer int) []byte
- func (self Instance) TextureGetDataAsync(texture RID.Texture, layer int, callback func(data []byte)) error
- func (self Instance) TextureGetFormat(texture RID.Texture) RDTextureFormat.Instance
- func (self Instance) TextureGetNativeHandle(texture RID.Texture) int
- func (self Instance) TextureIsDiscardable(texture RID.Texture) bool
- func (self Instance) TextureIsFormatSupportedForUsage(format Rendering.DataFormat, usage_flags Rendering.TextureUsageBits) bool
- func (self Instance) TextureIsShared(texture RID.Texture) bool
- func (self Instance) TextureIsValid(texture RID.Texture) bool
- func (self Instance) TextureResolveMultisample(from_texture RID.Texture, to_texture RID.Texture) error
- func (self Instance) TextureSetDiscardable(texture RID.Texture, discardable bool)
- func (self Instance) TextureUpdate(texture RID.Texture, layer int, data []byte) error
- func (self Instance) UniformBufferCreate(size_bytes int) RID.UniformBuffer
- func (self Instance) UniformSetCreate(uniforms []RDUniform.Instance, shader RID.Shader, shader_set int) RID.UniformSet
- func (self Instance) UniformSetIsValid(uniform_set RID.UniformSet) bool
- func (self Instance) VertexArrayCreate(vertex_count int, vertex_format int, src_buffers [][]RID.VertexBuffer) RID.VertexArray
- func (self Instance) VertexBufferCreate(size_bytes int) RID.VertexBuffer
- func (self Instance) VertexFormatCreate(vertex_descriptions []RDVertexAttribute.Instance) int
- func (self Instance) Virtual(name string) reflect.Value
Constants ¶
const InvalidFormatId = -1 //gd:RenderingDevice.INVALID_FORMAT_ID
const InvalidId = -1 //gd:RenderingDevice.INVALID_ID
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Advanced ¶
type Advanced = class
Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.
type Expanded ¶
type Expanded [1]gdclass.RenderingDevice
func (Expanded) Barrier ¶
func (self Expanded) Barrier(from Rendering.BarrierMask, to Rendering.BarrierMask)
This method does nothing.
func (Expanded) BufferGetData ¶
Returns a copy of the data of the specified 'buffer', optionally 'offset_bytes' and 'size_bytes' can be set to copy only a portion of the buffer.
Note: This method will block the GPU from working until the data is retrieved. Refer to Instance.BufferGetDataAsync for an alternative that returns the data in more performant way.
func (Expanded) BufferGetDataAsync ¶
func (self Expanded) BufferGetDataAsync(buffer RID.Buffer, callback func(data []byte), offset_bytes int, size_bytes int) error
Asynchronous version of Instance.BufferGetData. RenderingDevice will call 'callback' in a certain amount of frames with the data the buffer had at the time of the request.
Note: At the moment, the delay corresponds to the amount of frames specified by graphics.gd/classdb/ProjectSettings "rendering/rendering_device/vsync/frame_queue_size".
Note: Downloading large buffers can have a prohibitive cost for real-time even when using the asynchronous method due to hardware bandwidth limitations. When dealing with large resources, you can adjust settings such as graphics.gd/classdb/ProjectSettings "rendering/rendering_device/staging_buffer/block_size_kb" to improve the transfer speed at the cost of extra memory.
func (Expanded) ComputePipelineCreate ¶
func (self Expanded) ComputePipelineCreate(shader RID.Shader, specialization_constants []RDPipelineSpecializationConstant.Instance) RID.ComputePipeline
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 Instance.FreeRid method.
func (Expanded) DrawListBegin ¶
func (self Expanded) DrawListBegin(framebuffer RID.Framebuffer, draw_flags Rendering.DrawFlags, clear_color_values []Color.RGBA, clear_depth_value Float.X, clear_stencil_value int, region Rect2.PositionSize, breadcrumb int) int
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 Instance.DrawListEnd.
A simple drawing operation might look like this (code is not a complete example):
The 'draw_flags' indicates if the texture attachments of the framebuffer should be cleared or ignored. Only one of the two flags can be used for each individual attachment. Ignoring an attachment means that any contents that existed before the draw list will be completely discarded, reducing the memory bandwidth used by the render pass but producing garbage results if the pixels aren't replaced. The default behavior allows the engine to figure out the right operation to use if the texture is discardable, which can result in increased performance. See graphics.gd/classdb/RDTextureFormat or Instance.TextureSetDiscardable.
The 'breadcrumb' parameter can be an arbitrary 32-bit integer that is useful to diagnose GPU crashes. If Godot is built in dev or debug mode; when the GPU crashes Godot will dump all shaders that were being executed at the time of the crash and the breadcrumb is useful to diagnose what passes did those shaders belong to.
It does not affect rendering behavior and can be set to 0. It is recommended to use [BreadcrumbMarker] enumerations for consistency but it's not required. It is also possible to use bitwise operations to add extra data. e.g.
func (Expanded) DrawListBeginForScreen ¶
High-level variant of Instance.DrawListBegin, 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, Instance.DrawListBeginForScreen returns InvalidId.
func (Expanded) DrawListBeginSplit ¶
func (self Expanded) DrawListBeginSplit(framebuffer RID.Framebuffer, splits int, initial_color_action Rendering.InitialAction, final_color_action Rendering.FinalAction, initial_depth_action Rendering.InitialAction, final_depth_action Rendering.FinalAction, clear_color_values []Color.RGBA, clear_depth Float.X, clear_stencil int, region Rect2.PositionSize, storage_textures [][]RID.Texture) []int64
This method does nothing and always returns an empty []int64.
func (Expanded) DrawListDraw ¶
func (self Expanded) DrawListDraw(draw_list int, use_indices bool, instances int, procedural_vertex_count int)
Submits 'draw_list' for rendering on the GPU. This is the raster equivalent to Instance.ComputeListDispatch.
func (Expanded) DrawListDrawIndirect ¶
func (self Expanded) DrawListDrawIndirect(draw_list int, use_indices bool, buffer RID.Buffer, offset int, draw_count int, stride int)
Submits 'draw_list' for rendering on the GPU with the given parameters stored in the 'buffer' at 'offset'. Parameters being integers: vertex count, instance count, first vertex, first instance. And when using indices: index count, instance count, first index, vertex offset, first instance. Buffer must have been created with [StorageBufferUsageDispatchIndirect] flag.
func (Expanded) DrawListEnableScissor ¶
func (self Expanded) DrawListEnableScissor(draw_list int, rect Rect2.PositionSize)
Creates a scissor rectangle and enables it for the specified 'draw_list'. Scissor rectangles are used for clipping by discarding fragments that fall outside a specified rectangular portion of the screen. See also Instance.DrawListDisableScissor.
Note: The specified 'rect' is automatically intersected with the screen's dimensions, which means it cannot exceed the screen's dimensions.
func (Expanded) FramebufferCreate ¶
func (self Expanded) FramebufferCreate(textures [][]RID.Texture, validate_with_format int, view_count int) RID.Framebuffer
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 Instance.FreeRid method.
func (Expanded) FramebufferCreateEmpty ¶
func (self Expanded) FramebufferCreateEmpty(size Vector2i.XY, samples Rendering.TextureSamples, validate_with_format int) RID.Framebuffer
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 Instance.FreeRid method.
func (Expanded) FramebufferCreateMultipass ¶
func (self Expanded) FramebufferCreateMultipass(textures [][]RID.Texture, passes []RDFramebufferPass.Instance, validate_with_format int, view_count int) RID.Framebuffer
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 Instance.FreeRid method.
func (Expanded) FramebufferFormatCreate ¶
func (self Expanded) FramebufferFormatCreate(attachments []RDAttachmentFormat.Instance, view_count int) int
Creates a new framebuffer format with the specified 'attachments' and 'view_count'. Returns the new framebuffer's unique framebuffer format ID.
If 'view_count' is greater than or equal to 2, enables multiview which is used for VR rendering. This requires support for the Vulkan multiview extension.
func (Expanded) FramebufferFormatCreateEmpty ¶
func (self Expanded) FramebufferFormatCreateEmpty(samples Rendering.TextureSamples) int
Creates a new empty framebuffer format with the specified number of 'samples' and returns its ID.
func (Expanded) FramebufferFormatCreateMultipass ¶
func (self Expanded) FramebufferFormatCreateMultipass(attachments []RDAttachmentFormat.Instance, passes []RDFramebufferPass.Instance, view_count int) int
Creates a multipass framebuffer format with the specified 'attachments', 'passes' and 'view_count' and returns its ID. If 'view_count' is greater than or equal to 2, enables multiview which is used for VR rendering. This requires support for the Vulkan multiview extension.
func (Expanded) FramebufferFormatGetTextureSamples ¶
func (self Expanded) FramebufferFormatGetTextureSamples(format int, render_pass int) Rendering.TextureSamples
Returns the number of texture samples used for the given framebuffer 'format' ID (returned by Instance.FramebufferGetFormat).
func (Expanded) IndexBufferCreate ¶
func (self Expanded) IndexBufferCreate(size_indices int, format Rendering.IndexBufferFormat, data []byte, use_restart_indices bool, creation_bits Rendering.BufferCreationBits) RID.IndexBuffer
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 Instance.FreeRid method.
func (Expanded) RenderPipelineCreate ¶
func (self Expanded) RenderPipelineCreate(shader RID.Shader, framebuffer_format int, vertex_format int, primitive Rendering.RenderPrimitive, rasterization_state RDPipelineRasterizationState.Instance, multisample_state RDPipelineMultisampleState.Instance, stencil_state RDPipelineDepthStencilState.Instance, color_blend_state RDPipelineColorBlendState.Instance, dynamic_state_flags Rendering.PipelineDynamicStateFlags, for_render_pass int, specialization_constants []RDPipelineSpecializationConstant.Instance) RID.RenderPipeline
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 Instance.FreeRid method.
func (Expanded) ScreenGetFramebufferFormat ¶
Returns the framebuffer format of the given screen.
Note: Only the main graphics.gd/classdb/RenderingDevice returned by graphics.gd/classdb/RenderingServer.GetRenderingDevice has a format. If called on a local graphics.gd/classdb/RenderingDevice, this method prints an error and returns InvalidId.
func (Expanded) ScreenGetHeight ¶
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 Instance.ScreenGetWidth.
Note: Only the main graphics.gd/classdb/RenderingDevice returned by graphics.gd/classdb/RenderingServer.GetRenderingDevice has a height. If called on a local graphics.gd/classdb/RenderingDevice, this method prints an error and returns InvalidId.
func (Expanded) ScreenGetWidth ¶
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 Instance.ScreenGetHeight.
Note: Only the main graphics.gd/classdb/RenderingDevice returned by graphics.gd/classdb/RenderingServer.GetRenderingDevice has a width. If called on a local graphics.gd/classdb/RenderingDevice, this method prints an error and returns InvalidId.
func (Expanded) ShaderCompileBinaryFromSpirv ¶
func (self Expanded) ShaderCompileBinaryFromSpirv(spirv_data RDShaderSPIRV.Instance, name string) []byte
Compiles a binary shader from 'spirv_data' 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 Instance.ShaderCompileSpirvFromSource.
'name' is an optional human-readable name that can be given to the compiled shader for organizational purposes.
func (Expanded) ShaderCompileSpirvFromSource ¶
func (self Expanded) ShaderCompileSpirvFromSource(shader_source RDShaderSource.Instance, allow_cache bool) RDShaderSPIRV.Instance
Compiles a SPIR-V from the shader source code in 'shader_source' and returns the SPIR-V as an graphics.gd/classdb/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 Instance.ShaderCompileBinaryFromSpirv.
If 'allow_cache' 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 'allow_cache' is false, Godot's shader cache is ignored and the shader will always be recompiled.
func (Expanded) ShaderCreateFromBytecode ¶
func (self Expanded) ShaderCreateFromBytecode(binary_data []byte, placeholder_rid RID.ShaderPlaceholder) RID.Shader
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 Instance.FreeRid method. See also Instance.ShaderCompileBinaryFromSpirv and Instance.ShaderCreateFromSpirv.
func (Expanded) ShaderCreateFromSpirv ¶
func (self Expanded) ShaderCreateFromSpirv(spirv_data RDShaderSPIRV.Instance, name string) RID.Shader
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 Instance.FreeRid method. See also Instance.ShaderCompileSpirvFromSource and Instance.ShaderCreateFromBytecode.
func (Expanded) StorageBufferCreate ¶
func (self Expanded) StorageBufferCreate(size_bytes int, data []byte, usage Rendering.StorageBufferUsage, creation_bits Rendering.BufferCreationBits) RID.StorageBuffer
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 Instance.FreeRid method.
func (Expanded) TextureBufferCreate ¶
func (self Expanded) TextureBufferCreate(size_bytes int, format Rendering.DataFormat, data []byte) RID.TextureBuffer
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 Instance.FreeRid method.
func (Expanded) TextureCreate ¶
func (self Expanded) TextureCreate(format RDTextureFormat.Instance, view RDTextureView.Instance, data [][]byte) RID.Texture
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 Instance.FreeRid method.
Note: 'data' takes an slice of []bytes. For [TextureType1d], [TextureType2d], and [TextureType3d] types, this array should only have one element, a []byte containing all the data for the texture. For _ARRAY and _CUBE types, the length should be the same as the number of graphics.gd/classdb/RDTextureFormat.Instance.ArrayLayers in 'format'.
Note: Not to be confused with graphics.gd/classdb/RenderingServer.Texture2dCreate, which creates the Godot-specific graphics.gd/classdb/Texture2D resource as opposed to the graphics API's own texture type.
func (Expanded) TextureCreateFromExtension ¶
func (self Expanded) TextureCreateFromExtension(atype Rendering.TextureType, format Rendering.DataFormat, samples Rendering.TextureSamples, usage_flags Rendering.TextureUsageBits, image int, width int, height int, depth int, layers int, mipmaps int) RID.Texture
Returns an RID for an existing 'image' (VkImage) with the given 'type', 'format', 'samples', 'usage_flags', 'width', 'height', 'depth', 'layers', and 'mipmaps'. This can be used to allow Godot to render onto foreign images.
func (Expanded) TextureCreateSharedFromSlice ¶
func (self Expanded) TextureCreateSharedFromSlice(view RDTextureView.Instance, with_texture RID.Texture, layer int, mipmap int, mipmaps int, slice_type Rendering.TextureSliceType) RID.Texture
Creates a shared texture using the specified 'view' and the texture information from 'with_texture”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 Instance.TextureCreateShared.
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.
func (Expanded) UniformBufferCreate ¶
func (self Expanded) UniformBufferCreate(size_bytes int, data []byte, creation_bits Rendering.BufferCreationBits) RID.UniformBuffer
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 Instance.FreeRid method.
func (Expanded) VertexArrayCreate ¶
func (self Expanded) VertexArrayCreate(vertex_count int, vertex_format int, src_buffers [][]RID.VertexBuffer, offsets []int64) RID.VertexArray
Creates a vertex array based on the specified buffers. Optionally, 'offsets' (in bytes) may be defined for each buffer.
func (Expanded) VertexBufferCreate ¶
func (self Expanded) VertexBufferCreate(size_bytes int, data []byte, creation_bits Rendering.BufferCreationBits) RID.VertexBuffer
Creates a new vertex 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 Instance.FreeRid method.
type Extension ¶
Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension
func (*Extension[T]) AsRenderingDevice ¶
type ID ¶
ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.
type Instance ¶
type Instance [1]gdclass.RenderingDevice
Instance of the class with convieniently typed arguments and results.
var Nil Instance
Nil is a nil/null instance of the class. Equivalent to the zero value.
func (Instance) AsRenderingDevice ¶
func (Instance) BufferClear ¶
Clears the contents of the 'buffer', clearing 'size_bytes' bytes, starting at 'offset'.
Prints an error if:
- the size isn't a multiple of four
- the region specified by 'offset' + 'size_bytes' exceeds the buffer
- a draw list is currently active (created by Instance.DrawListBegin)
- a compute list is currently active (created by Instance.ComputeListBegin)
func (Instance) BufferCopy ¶
func (self Instance) BufferCopy(src_buffer RID.Buffer, dst_buffer RID.Buffer, src_offset int, dst_offset int, size int) error
Copies 'size' bytes from the 'src_buffer' at 'src_offset' into 'dst_buffer' at 'dst_offset'.
Prints an error if:
- 'size' exceeds the size of either 'src_buffer' or 'dst_buffer' at their corresponding offsets
- a draw list is currently active (created by Instance.DrawListBegin)
- a compute list is currently active (created by Instance.ComputeListBegin)
func (Instance) BufferGetData ¶
Returns a copy of the data of the specified 'buffer', optionally 'offset_bytes' and 'size_bytes' can be set to copy only a portion of the buffer.
Note: This method will block the GPU from working until the data is retrieved. Refer to Instance.BufferGetDataAsync for an alternative that returns the data in more performant way.
func (Instance) BufferGetDataAsync ¶
Asynchronous version of Instance.BufferGetData. RenderingDevice will call 'callback' in a certain amount of frames with the data the buffer had at the time of the request.
Note: At the moment, the delay corresponds to the amount of frames specified by graphics.gd/classdb/ProjectSettings "rendering/rendering_device/vsync/frame_queue_size".
Note: Downloading large buffers can have a prohibitive cost for real-time even when using the asynchronous method due to hardware bandwidth limitations. When dealing with large resources, you can adjust settings such as graphics.gd/classdb/ProjectSettings "rendering/rendering_device/staging_buffer/block_size_kb" to improve the transfer speed at the cost of extra memory.
func (Instance) BufferGetDeviceAddress ¶
Returns the address of the given 'buffer' which can be passed to shaders in any way to access underlying data. Buffer must have been created with this feature enabled.
Note: You must check that the GPU supports this functionality by calling Instance.HasFeature with [SupportsBufferDeviceAddress] as a parameter.
func (Instance) BufferUpdate ¶
Updates a region of 'size_bytes' bytes, starting at 'offset', in the buffer, with the specified 'data'.
Prints an error if:
- the region specified by 'offset' + 'size_bytes' exceeds the buffer
- a draw list is currently active (created by Instance.DrawListBegin)
- a compute list is currently active (created by Instance.ComputeListBegin)
func (Instance) CaptureTimestamp ¶
Creates a timestamp marker with the specified 'name'. This is used for performance reporting with the Instance.GetCapturedTimestampCpuTime, Instance.GetCapturedTimestampGpuTime and Instance.GetCapturedTimestampName methods.
func (Instance) ComputeListAddBarrier ¶
Raises a Vulkan compute barrier in the specified 'compute_list'.
func (Instance) ComputeListBegin ¶
Starts a list of compute commands created with the compute_* methods. The returned value should be passed to other compute_list_* functions.
Multiple compute lists cannot be created at the same time; you must finish the previous compute list first using Instance.ComputeListEnd.
A simple compute operation might look like this (code is not a complete example):
func (Instance) ComputeListBindComputePipeline ¶
func (self Instance) ComputeListBindComputePipeline(compute_list int, compute_pipeline RID.ComputePipeline)
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 Instance.ComputeListDispatch.
func (Instance) ComputeListBindUniformSet ¶
func (self Instance) ComputeListBindUniformSet(compute_list int, uniform_set RID.UniformSet, set_index int)
Binds the 'uniform_set' to this 'compute_list'. 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.
func (Instance) ComputeListDispatch ¶
func (self Instance) ComputeListDispatch(compute_list int, x_groups int, y_groups int, z_groups int)
Submits the compute list for processing on the GPU. This is the compute equivalent to Instance.DrawListDraw.
func (Instance) ComputeListDispatchIndirect ¶
Submits the compute list for processing on the GPU with the given group counts stored in the 'buffer' at 'offset'. Buffer must have been created with [StorageBufferUsageDispatchIndirect] flag.
func (Instance) ComputeListEnd ¶
func (self Instance) ComputeListEnd()
Finishes a list of compute commands created with the compute_* methods.
func (Instance) ComputeListSetPushConstant ¶
Sets the push constant data to 'buffer' for the specified 'compute_list'. The shader determines how this binary data is used. The buffer's size in bytes must also be specified in 'size_bytes' (this can be obtained by calling the graphics.gd/classdb/PackedByteArray.Instance.Size method on the passed 'buffer').
func (Instance) ComputePipelineCreate ¶
func (self Instance) ComputePipelineCreate(shader RID.Shader) RID.ComputePipeline
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 Instance.FreeRid method.
func (Instance) ComputePipelineIsValid ¶
func (self Instance) ComputePipelineIsValid(compute_pipeline RID.ComputePipeline) bool
Returns true if the compute pipeline specified by the 'compute_pipeline' RID is valid, false otherwise.
func (Instance) CreateLocalDevice ¶
Create a new local graphics.gd/classdb/RenderingDevice. This is most useful for performing compute operations on the GPU independently from the rest of the engine.
func (Instance) DrawCommandBeginLabel ¶
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 Instance.DrawCommandEndLabel call. When viewed from the linear series of submissions to a single queue, calls to Instance.DrawCommandBeginLabel and Instance.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 Instance.DrawCommandEndLabel.
func (Instance) DrawCommandEndLabel ¶
func (self Instance) DrawCommandEndLabel()
Ends the command buffer debug label region started by a Instance.DrawCommandBeginLabel call.
func (Instance) DrawCommandInsertLabel ¶
This method does nothing.
func (Instance) DrawListBegin ¶
func (self Instance) DrawListBegin(framebuffer RID.Framebuffer) int
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 Instance.DrawListEnd.
A simple drawing operation might look like this (code is not a complete example):
The 'draw_flags' indicates if the texture attachments of the framebuffer should be cleared or ignored. Only one of the two flags can be used for each individual attachment. Ignoring an attachment means that any contents that existed before the draw list will be completely discarded, reducing the memory bandwidth used by the render pass but producing garbage results if the pixels aren't replaced. The default behavior allows the engine to figure out the right operation to use if the texture is discardable, which can result in increased performance. See graphics.gd/classdb/RDTextureFormat or Instance.TextureSetDiscardable.
The 'breadcrumb' parameter can be an arbitrary 32-bit integer that is useful to diagnose GPU crashes. If Godot is built in dev or debug mode; when the GPU crashes Godot will dump all shaders that were being executed at the time of the crash and the breadcrumb is useful to diagnose what passes did those shaders belong to.
It does not affect rendering behavior and can be set to 0. It is recommended to use [BreadcrumbMarker] enumerations for consistency but it's not required. It is also possible to use bitwise operations to add extra data. e.g.
func (Instance) DrawListBeginForScreen ¶
High-level variant of Instance.DrawListBegin, 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, Instance.DrawListBeginForScreen returns InvalidId.
func (Instance) DrawListBeginSplit ¶
func (self Instance) DrawListBeginSplit(framebuffer RID.Framebuffer, splits int, initial_color_action Rendering.InitialAction, final_color_action Rendering.FinalAction, initial_depth_action Rendering.InitialAction, final_depth_action Rendering.FinalAction) []int64
This method does nothing and always returns an empty []int64.
func (Instance) DrawListBindIndexArray ¶
func (self Instance) DrawListBindIndexArray(draw_list int, index_array RID.IndexArray)
Binds 'index_array' to the specified 'draw_list'.
func (Instance) DrawListBindRenderPipeline ¶
func (self Instance) DrawListBindRenderPipeline(draw_list int, render_pipeline RID.RenderPipeline)
Binds 'render_pipeline' to the specified 'draw_list'.
func (Instance) DrawListBindUniformSet ¶
func (self Instance) DrawListBindUniformSet(draw_list int, uniform_set RID.UniformSet, set_index int)
Binds 'uniform_set' to the specified 'draw_list'. A 'set_index' must also be specified, which is an identifier starting from 0 that must match the one expected by the draw list.
func (Instance) DrawListBindVertexArray ¶
func (self Instance) DrawListBindVertexArray(draw_list int, vertex_array RID.VertexArray)
Binds 'vertex_array' to the specified 'draw_list'.
func (Instance) DrawListDisableScissor ¶
Removes and disables the scissor rectangle for the specified 'draw_list'. See also Instance.DrawListEnableScissor.
func (Instance) DrawListDraw ¶
Submits 'draw_list' for rendering on the GPU. This is the raster equivalent to Instance.ComputeListDispatch.
func (Instance) DrawListDrawIndirect ¶
Submits 'draw_list' for rendering on the GPU with the given parameters stored in the 'buffer' at 'offset'. Parameters being integers: vertex count, instance count, first vertex, first instance. And when using indices: index count, instance count, first index, vertex offset, first instance. Buffer must have been created with [StorageBufferUsageDispatchIndirect] flag.
func (Instance) DrawListEnableScissor ¶
Creates a scissor rectangle and enables it for the specified 'draw_list'. Scissor rectangles are used for clipping by discarding fragments that fall outside a specified rectangular portion of the screen. See also Instance.DrawListDisableScissor.
Note: The specified 'rect' is automatically intersected with the screen's dimensions, which means it cannot exceed the screen's dimensions.
func (Instance) DrawListEnd ¶
func (self Instance) DrawListEnd()
Finishes a list of raster drawing commands created with the draw_* methods.
func (Instance) DrawListSetBlendConstants ¶
Sets blend constants for the specified 'draw_list' to 'color'. Blend constants are used only if the graphics pipeline is created with [DynamicStateBlendConstants] flag set.
func (Instance) DrawListSetPushConstant ¶
Sets the push constant data to 'buffer' for the specified 'draw_list'. The shader determines how this binary data is used. The buffer's size in bytes must also be specified in 'size_bytes' (this can be obtained by calling the graphics.gd/classdb/PackedByteArray.Instance.Size method on the passed 'buffer').
func (Instance) DrawListSwitchToNextPass ¶
Switches to the next draw pass.
func (Instance) DrawListSwitchToNextPassSplit ¶
This method does nothing and always returns an empty []int64.
func (Instance) FramebufferCreate ¶
func (self Instance) FramebufferCreate(textures [][]RID.Texture) RID.Framebuffer
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 Instance.FreeRid method.
func (Instance) FramebufferCreateEmpty ¶
func (self Instance) FramebufferCreateEmpty(size Vector2i.XY) RID.Framebuffer
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 Instance.FreeRid method.
func (Instance) FramebufferCreateMultipass ¶
func (self Instance) FramebufferCreateMultipass(textures [][]RID.Texture, passes []RDFramebufferPass.Instance) RID.Framebuffer
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 Instance.FreeRid method.
func (Instance) FramebufferFormatCreate ¶
func (self Instance) FramebufferFormatCreate(attachments []RDAttachmentFormat.Instance) int
Creates a new framebuffer format with the specified 'attachments' and 'view_count'. Returns the new framebuffer's unique framebuffer format ID.
If 'view_count' is greater than or equal to 2, enables multiview which is used for VR rendering. This requires support for the Vulkan multiview extension.
func (Instance) FramebufferFormatCreateEmpty ¶
Creates a new empty framebuffer format with the specified number of 'samples' and returns its ID.
func (Instance) FramebufferFormatCreateMultipass ¶
func (self Instance) FramebufferFormatCreateMultipass(attachments []RDAttachmentFormat.Instance, passes []RDFramebufferPass.Instance) int
Creates a multipass framebuffer format with the specified 'attachments', 'passes' and 'view_count' and returns its ID. If 'view_count' is greater than or equal to 2, enables multiview which is used for VR rendering. This requires support for the Vulkan multiview extension.
func (Instance) FramebufferFormatGetTextureSamples ¶
func (self Instance) FramebufferFormatGetTextureSamples(format int) Rendering.TextureSamples
Returns the number of texture samples used for the given framebuffer 'format' ID (returned by Instance.FramebufferGetFormat).
func (Instance) FramebufferGetFormat ¶
func (self Instance) FramebufferGetFormat(framebuffer RID.Framebuffer) int
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.
func (Instance) FramebufferIsValid ¶
func (self Instance) FramebufferIsValid(framebuffer RID.Framebuffer) bool
Returns true if the framebuffer specified by the 'framebuffer' RID is valid, false otherwise.
func (Instance) FreeRid ¶
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.
func (Instance) GetCapturedTimestampCpuTime ¶
Returns the timestamp in CPU time for the rendering step specified by 'index' (in microseconds since the engine started). See also Instance.GetCapturedTimestampGpuTime and Instance.CaptureTimestamp.
func (Instance) GetCapturedTimestampGpuTime ¶
Returns the timestamp in GPU time for the rendering step specified by 'index' (in microseconds since the engine started). See also Instance.GetCapturedTimestampCpuTime and Instance.CaptureTimestamp.
func (Instance) GetCapturedTimestampName ¶
Returns the timestamp's name for the rendering step specified by 'index'. See also Instance.CaptureTimestamp.
func (Instance) GetCapturedTimestampsCount ¶
Returns the total number of timestamps (rendering steps) available for profiling.
func (Instance) GetCapturedTimestampsFrame ¶
Returns the index of the last frame rendered that has rendering timestamps available for querying.
func (Instance) GetDeviceAllocationCount ¶
Returns how many allocations the GPU has performed for internal driver structures.
This is only used by Vulkan in debug builds and can return 0 when this information is not tracked or unknown.
func (Instance) GetDeviceAllocsByObjectType ¶
Same as Instance.GetDeviceAllocationCount but filtered for a given object type.
The type argument must be in range [0; get_tracked_object_type_count - 1]. If Instance.GetTrackedObjectTypeCount is 0, then type argument is ignored and always returns 0.
This is only used by Vulkan in debug builds and can return 0 when this information is not tracked or unknown.
func (Instance) GetDeviceMemoryByObjectType ¶
Same as Instance.GetDeviceTotalMemory but filtered for a given object type.
The type argument must be in range [0; get_tracked_object_type_count - 1]. If Instance.GetTrackedObjectTypeCount is 0, then type argument is ignored and always returns 0.
This is only used by Vulkan in debug builds and can return 0 when this information is not tracked or unknown.
func (Instance) GetDeviceName ¶
Returns the name of the video adapter (e.g. "GeForce GTX 1080/PCIe/SSE2"). Equivalent to graphics.gd/classdb/RenderingServer.GetVideoAdapterName. See also Instance.GetDeviceVendorName.
func (Instance) 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.
func (Instance) GetDeviceTotalMemory ¶
Returns how much bytes the GPU is using.
This is only used by Vulkan in debug builds and can return 0 when this information is not tracked or unknown.
func (Instance) GetDeviceVendorName ¶
Returns the vendor of the video adapter (e.g. "NVIDIA Corporation"). Equivalent to graphics.gd/classdb/RenderingServer.GetVideoAdapterVendor. See also Instance.GetDeviceName.
func (Instance) GetDriverAllocationCount ¶
Returns how many allocations the GPU driver has performed for internal driver structures.
This is only used by Vulkan in debug builds and can return 0 when this information is not tracked or unknown.
func (Instance) GetDriverAllocsByObjectType ¶
Same as Instance.GetDriverAllocationCount but filtered for a given object type.
The type argument must be in range [0; get_tracked_object_type_count - 1]. If Instance.GetTrackedObjectTypeCount is 0, then type argument is ignored and always returns 0.
This is only used by Vulkan in debug builds and can return 0 when this information is not tracked or unknown.
func (Instance) GetDriverAndDeviceMemoryReport ¶
Returns string report in CSV format using the following methods:
- Instance.GetTrackedObjectName
- Instance.GetTrackedObjectTypeCount
- Instance.GetDriverTotalMemory
- Instance.GetDriverAllocationCount
- Instance.GetDriverMemoryByObjectType
- Instance.GetDriverAllocsByObjectType
- Instance.GetDeviceTotalMemory
- Instance.GetDeviceAllocationCount
- Instance.GetDeviceMemoryByObjectType
- Instance.GetDeviceAllocsByObjectType
This is only used by Vulkan in debug builds. Godot must also be started with the --extra-gpu-memory-tracking command line argument.
func (Instance) GetDriverMemoryByObjectType ¶
Same as Instance.GetDriverTotalMemory but filtered for a given object type.
The type argument must be in range [0; get_tracked_object_type_count - 1]. If Instance.GetTrackedObjectTypeCount is 0, then type argument is ignored and always returns 0.
This is only used by Vulkan in debug builds and can return 0 when this information is not tracked or unknown.
func (Instance) GetDriverResource ¶
func (self Instance) GetDriverResource(resource Rendering.DriverResource, rid RID.Any, index int) int
Returns the unique identifier of the driver 'resource' for the specified 'rid'. Some driver resource types ignore the specified 'rid'. 'index' is always ignored but must be specified anyway.
func (Instance) GetDriverTotalMemory ¶
Returns how much bytes the GPU driver is using for internal driver structures.
This is only used by Vulkan in debug builds and can return 0 when this information is not tracked or unknown.
func (Instance) 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 graphics.gd/classdb/RenderingDevice, frames are cycled (usually 3 with triple-buffered V-Sync enabled). However, local [graphics.gd/classdb/RenderingDevice]s only have 1 frame.
func (Instance) GetMemoryUsage ¶
func (self Instance) GetMemoryUsage(atype Rendering.MemoryType) int
Returns the memory usage in bytes corresponding to the given 'type'. When using Vulkan, these statistics are calculated by Vulkan Memory Allocator.
func (Instance) GetPerfReport ¶
Returns a string with a performance report from the past frame. Updates every frame.
func (Instance) GetTrackedObjectName ¶
Returns the name of the type of object for the given 'type_index'. This value must be in range [0; get_tracked_object_type_count - 1]. If Instance.GetTrackedObjectTypeCount is 0, then type argument is ignored and always returns the same string.
The return value is important because it gives meaning to the types passed to Instance.GetDriverMemoryByObjectType, Instance.GetDriverAllocsByObjectType, Instance.GetDeviceMemoryByObjectType, and Instance.GetDeviceAllocsByObjectType. Examples of strings it can return (not exhaustive):
- DEVICE_MEMORY
- PIPELINE_CACHE
- SWAPCHAIN_KHR
- COMMAND_POOL
Thus if e.g. get_tracked_object_name(5) returns "COMMAND_POOL", then get_device_memory_by_object_type(5) returns the bytes used by the GPU for command pools.
This is only used by Vulkan in debug builds. Godot must also be started with the --extra-gpu-memory-tracking command line argument.
func (Instance) GetTrackedObjectTypeCount ¶
Returns how many types of trackable objects there are.
This is only used by Vulkan in debug builds. Godot must also be started with the --extra-gpu-memory-tracking command line argument.
func (Instance) HasFeature ¶
Returns true if the 'feature' is supported by the GPU.
func (Instance) IndexArrayCreate ¶
func (self Instance) IndexArrayCreate(index_buffer RID.IndexBuffer, index_offset int, index_count int) RID.IndexArray
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 Instance.FreeRid method.
func (Instance) IndexBufferCreate ¶
func (self Instance) IndexBufferCreate(size_indices int, format Rendering.IndexBufferFormat) RID.IndexBuffer
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 Instance.FreeRid method.
func (Instance) LimitGet ¶
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.
func (Instance) RenderPipelineCreate ¶
func (self Instance) RenderPipelineCreate(shader RID.Shader, framebuffer_format int, vertex_format int, primitive Rendering.RenderPrimitive, rasterization_state RDPipelineRasterizationState.Instance, multisample_state RDPipelineMultisampleState.Instance, stencil_state RDPipelineDepthStencilState.Instance, color_blend_state RDPipelineColorBlendState.Instance) RID.RenderPipeline
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 Instance.FreeRid method.
func (Instance) RenderPipelineIsValid ¶
func (self Instance) RenderPipelineIsValid(render_pipeline RID.RenderPipeline) bool
Returns true if the render pipeline specified by the 'render_pipeline' RID is valid, false otherwise.
func (Instance) SamplerCreate ¶
func (self Instance) SamplerCreate(state RDSamplerState.Instance) RID.Sampler
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 Instance.FreeRid method.
func (Instance) SamplerIsFormatSupportedForFilter ¶
func (self Instance) SamplerIsFormatSupportedForFilter(format Rendering.DataFormat, sampler_filter Rendering.SamplerFilter) bool
Returns true if implementation supports using a texture of 'format' with the given 'sampler_filter'.
func (Instance) ScreenGetFramebufferFormat ¶
Returns the framebuffer format of the given screen.
Note: Only the main graphics.gd/classdb/RenderingDevice returned by graphics.gd/classdb/RenderingServer.GetRenderingDevice has a format. If called on a local graphics.gd/classdb/RenderingDevice, this method prints an error and returns InvalidId.
func (Instance) ScreenGetHeight ¶
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 Instance.ScreenGetWidth.
Note: Only the main graphics.gd/classdb/RenderingDevice returned by graphics.gd/classdb/RenderingServer.GetRenderingDevice has a height. If called on a local graphics.gd/classdb/RenderingDevice, this method prints an error and returns InvalidId.
func (Instance) ScreenGetWidth ¶
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 Instance.ScreenGetHeight.
Note: Only the main graphics.gd/classdb/RenderingDevice returned by graphics.gd/classdb/RenderingServer.GetRenderingDevice has a width. If called on a local graphics.gd/classdb/RenderingDevice, this method prints an error and returns InvalidId.
func (Instance) SetResourceName ¶
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 (graphics.gd/classdb/OS.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.
func (Instance) ShaderCompileBinaryFromSpirv ¶
func (self Instance) ShaderCompileBinaryFromSpirv(spirv_data RDShaderSPIRV.Instance) []byte
Compiles a binary shader from 'spirv_data' 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 Instance.ShaderCompileSpirvFromSource.
'name' is an optional human-readable name that can be given to the compiled shader for organizational purposes.
func (Instance) ShaderCompileSpirvFromSource ¶
func (self Instance) ShaderCompileSpirvFromSource(shader_source RDShaderSource.Instance) RDShaderSPIRV.Instance
Compiles a SPIR-V from the shader source code in 'shader_source' and returns the SPIR-V as an graphics.gd/classdb/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 Instance.ShaderCompileBinaryFromSpirv.
If 'allow_cache' 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 'allow_cache' is false, Godot's shader cache is ignored and the shader will always be recompiled.
func (Instance) ShaderCreateFromBytecode ¶
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 Instance.FreeRid method. See also Instance.ShaderCompileBinaryFromSpirv and Instance.ShaderCreateFromSpirv.
func (Instance) ShaderCreateFromSpirv ¶
func (self Instance) ShaderCreateFromSpirv(spirv_data RDShaderSPIRV.Instance) RID.Shader
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 Instance.FreeRid method. See also Instance.ShaderCompileSpirvFromSource and Instance.ShaderCreateFromBytecode.
func (Instance) ShaderCreatePlaceholder ¶
func (self Instance) ShaderCreatePlaceholder() RID.ShaderPlaceholder
Create a placeholder RID by allocating an RID without initializing it for use in Instance.ShaderCreateFromBytecode. This allows you to create an RID for a shader and pass it around, but defer compiling the shader to a later time.
func (Instance) ShaderGetVertexInputAttributeMask ¶
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).
func (Instance) StorageBufferCreate ¶
func (self Instance) StorageBufferCreate(size_bytes int) RID.StorageBuffer
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 Instance.FreeRid method.
func (Instance) Submit ¶
func (self Instance) Submit()
Pushes the frame setup and draw command buffers then marks the local device as currently processing (which allows calling Instance.Sync).
Note: Only available in local RenderingDevices.
func (Instance) Sync ¶
func (self Instance) 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: Instance.Sync can only be called after a Instance.Submit.
func (Instance) TextureBufferCreate ¶
func (self Instance) TextureBufferCreate(size_bytes int, format Rendering.DataFormat) RID.TextureBuffer
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 Instance.FreeRid method.
func (Instance) TextureClear ¶
func (self Instance) TextureClear(texture RID.Texture, color Color.RGBA, base_mipmap int, mipmap_count int, base_layer int, layer_count int) error
Clears the specified 'texture' by replacing all of its pixels with the specified 'color'. 'base_mipmap' and 'mipmap_count' determine which mipmaps of the texture are affected by this clear operation, while 'base_layer' and 'layer_count' 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), 'base_layer' must be 0 and 'layer_count' 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 [FinalActionContinue]) to clear this texture.
func (Instance) TextureCopy ¶
func (self Instance) TextureCopy(from_texture RID.Texture, to_texture RID.Texture, from_pos Vector3.XYZ, to_pos Vector3.XYZ, size Vector3.XYZ, src_mipmap int, dst_mipmap int, src_layer int, dst_layer int) error
Copies the 'from_texture' to 'to_texture' with the specified 'from_pos', 'to_pos' and 'size' coordinates. The Z axis of the 'from_pos', 'to_pos' 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 [@Globalscope.Ok] if the texture copy was successful or [@Globalscope.ErrInvalidParameter] otherwise.
Note: 'from_texture' 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 [FinalActionContinue]) to copy this texture.
Note: 'from_texture' texture requires the [TextureUsageCanCopyFromBit] to be retrieved.
Note: 'to_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 [FinalActionContinue]) to copy this texture.
Note: 'to_texture' requires the [TextureUsageCanCopyToBit] to be retrieved.
Note: 'from_texture' and 'to_texture' must be of the same type (color or depth).
func (Instance) TextureCreate ¶
func (self Instance) TextureCreate(format RDTextureFormat.Instance, view RDTextureView.Instance) RID.Texture
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 Instance.FreeRid method.
Note: 'data' takes an slice of []bytes. For [TextureType1d], [TextureType2d], and [TextureType3d] types, this array should only have one element, a []byte containing all the data for the texture. For _ARRAY and _CUBE types, the length should be the same as the number of graphics.gd/classdb/RDTextureFormat.Instance.ArrayLayers in 'format'.
Note: Not to be confused with graphics.gd/classdb/RenderingServer.Texture2dCreate, which creates the Godot-specific graphics.gd/classdb/Texture2D resource as opposed to the graphics API's own texture type.
func (Instance) TextureCreateFromExtension ¶
func (self Instance) TextureCreateFromExtension(atype Rendering.TextureType, format Rendering.DataFormat, samples Rendering.TextureSamples, usage_flags Rendering.TextureUsageBits, image int, width int, height int, depth int, layers int) RID.Texture
Returns an RID for an existing 'image' (VkImage) with the given 'type', 'format', 'samples', 'usage_flags', 'width', 'height', 'depth', 'layers', and 'mipmaps'. This can be used to allow Godot to render onto foreign images.
func (Instance) TextureCreateShared ¶
func (self Instance) TextureCreateShared(view RDTextureView.Instance, with_texture RID.Texture) RID.Texture
Creates a shared texture using the specified 'view' and the texture information from 'with_texture'.
func (Instance) TextureCreateSharedFromSlice ¶
func (self Instance) TextureCreateSharedFromSlice(view RDTextureView.Instance, with_texture RID.Texture, layer int, mipmap int) RID.Texture
Creates a shared texture using the specified 'view' and the texture information from 'with_texture”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 Instance.TextureCreateShared.
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.
func (Instance) TextureGetData ¶
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 [FinalActionContinue]) to retrieve this texture. Otherwise, an error is printed and an empty []byte is returned.
Note: 'texture' requires the [TextureUsageCanCopyFromBit] to be retrieved. Otherwise, an error is printed and an empty []byte is returned.
Note: This method will block the GPU from working until the data is retrieved. Refer to Instance.TextureGetDataAsync for an alternative that returns the data in more performant way.
func (Instance) TextureGetDataAsync ¶
func (self Instance) TextureGetDataAsync(texture RID.Texture, layer int, callback func(data []byte)) error
Asynchronous version of Instance.TextureGetData. RenderingDevice will call 'callback' in a certain amount of frames with the data the texture had at the time of the request.
Note: At the moment, the delay corresponds to the amount of frames specified by graphics.gd/classdb/ProjectSettings "rendering/rendering_device/vsync/frame_queue_size".
Note: Downloading large textures can have a prohibitive cost for real-time even when using the asynchronous method due to hardware bandwidth limitations. When dealing with large resources, you can adjust settings such as graphics.gd/classdb/ProjectSettings "rendering/rendering_device/staging_buffer/texture_download_region_size_px" and graphics.gd/classdb/ProjectSettings "rendering/rendering_device/staging_buffer/block_size_kb" to improve the transfer speed at the cost of extra memory.
func (Instance) TextureGetFormat ¶
func (self Instance) TextureGetFormat(texture RID.Texture) RDTextureFormat.Instance
Returns the data format used to create this texture.
func (Instance) TextureGetNativeHandle ¶
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).
func (Instance) TextureIsDiscardable ¶
Returns true if the 'texture' is discardable, false otherwise. See graphics.gd/classdb/RDTextureFormat or Instance.TextureSetDiscardable.
func (Instance) TextureIsFormatSupportedForUsage ¶
func (self Instance) TextureIsFormatSupportedForUsage(format Rendering.DataFormat, usage_flags Rendering.TextureUsageBits) bool
Returns true if the specified 'format' is supported for the given 'usage_flags', false otherwise.
func (Instance) TextureIsShared ¶
Returns true if the 'texture' is shared, false otherwise. See graphics.gd/classdb/RDTextureView.
func (Instance) TextureIsValid ¶
Returns true if the 'texture' is valid, false otherwise.
func (Instance) TextureResolveMultisample ¶
func (self Instance) TextureResolveMultisample(from_texture RID.Texture, to_texture RID.Texture) error
Resolves the 'from_texture' texture onto 'to_texture' with multisample antialiasing enabled. This must be used when rendering a framebuffer for MSAA to work. Returns [@Globalscope.Ok] if successful, [@Globalscope.ErrInvalidParameter] otherwise.
Note: 'from_texture' and 'to_texture' textures must have the same dimension, format and type (color or depth).
Note: 'from_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 [FinalActionContinue]) to resolve this texture.
Note: 'from_texture' requires the [TextureUsageCanCopyFromBit] to be retrieved.
Note: 'from_texture' must be multisampled and must also be 2D (or a slice of a 3D/cubemap texture).
Note: 'to_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 [FinalActionContinue]) to resolve this texture.
Note: 'to_texture' texture requires the [TextureUsageCanCopyToBit] to be retrieved.
Note: 'to_texture' texture must not be multisampled and must also be 2D (or a slice of a 3D/cubemap texture).
func (Instance) TextureSetDiscardable ¶
Updates the discardable property of 'texture'.
If a texture is discardable, its contents do not need to be preserved between frames. This flag is only relevant when the texture is used as target in a draw list.
This information is used by graphics.gd/classdb/RenderingDevice to figure out if a texture's contents can be discarded, eliminating unnecessary writes to memory and boosting performance.
func (Instance) TextureUpdate ¶
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 [@Globalscope.Ok] if the update was successful, [@Globalscope.ErrInvalidParameter] 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 [FinalActionContinue]) to update this texture.
Note: The existing 'texture' requires the [TextureUsageCanUpdateBit] to be updatable.
func (Instance) UniformBufferCreate ¶
func (self Instance) UniformBufferCreate(size_bytes int) RID.UniformBuffer
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 Instance.FreeRid method.
func (Instance) UniformSetCreate ¶
func (self Instance) UniformSetCreate(uniforms []RDUniform.Instance, shader RID.Shader, shader_set int) RID.UniformSet
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 Instance.FreeRid method.
func (Instance) UniformSetIsValid ¶
func (self Instance) UniformSetIsValid(uniform_set RID.UniformSet) bool
Checks if the 'uniform_set' is valid, i.e. is owned.
func (Instance) VertexArrayCreate ¶
func (self Instance) VertexArrayCreate(vertex_count int, vertex_format int, src_buffers [][]RID.VertexBuffer) RID.VertexArray
Creates a vertex array based on the specified buffers. Optionally, 'offsets' (in bytes) may be defined for each buffer.
func (Instance) VertexBufferCreate ¶
func (self Instance) VertexBufferCreate(size_bytes int) RID.VertexBuffer
Creates a new vertex 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 Instance.FreeRid method.
func (Instance) VertexFormatCreate ¶
func (self Instance) VertexFormatCreate(vertex_descriptions []RDVertexAttribute.Instance) int
Creates a new vertex format with the specified 'vertex_descriptions'. Returns a unique vertex format ID corresponding to the newly created vertex format.