class GpuDevice

Provides access to a particular GPU device.

Public

Methods

~GpuDevice

virtual ~GpuDevice() = default

Initialize

virtual bool Initialize() = 0

Initializes the GpuDevice.

Should be called after construction but before any other operations.

IsInitialized

virtual bool IsInitialized() const = 0

Returns true if Initialize() has been called.

GetCapabilities

virtual const GpuDeviceCapabilities &GetCapabilities() const = 0

GetVideoModeInfo

virtual const VideoModeInfo &GetVideoModeInfo() const = 0

Returns information about available output devices and their video modes.

IsGpuProgramLanguageSupported

virtual bool IsGpuProgramLanguageSupported(const StringView &language) const = 0

Query if a GPU program language is supported (for example "hlsl", "glsl").

Thread safe.

GetQueueCount

virtual u32 GetQueueCount(GpuQueueType type) const = 0

Returns the number of queues supported for the specific usage.

GetQueue

virtual SPtr<GpuQueue> GetQueue(GpuQueueType type, u32 index) const = 0

Retrieves a queue with the specified usage and index.

SubmitCommandBuffer

virtual void SubmitCommandBuffer(const SPtr<render::GpuCommandBuffer> &commandBuffer, GpuQueueMask syncMask = GpuQueueMask::kAll, u32 queueIndex = 0)

Submits the command buffer for execution on an automatically retrieved queue.

This mask is only relevant if your command buffers are executing on different queues, and are dependent. If they are executing on the same queue then they will execute sequentially in the order they are submitted. Otherwise, if there is a dependency you must make state it explicitly here.

commandBuffer
Command buffer to submit. Usage of the command buffer determines the queue to execute on.
syncMask
Optional synchronization mask that determines if the submitted command buffer depends on any other command buffers submitted on other queues.
queueIndex
In case there are multiple queues supported with the command buffer's usage, this determines which one to execute on.

PresentRenderWindow

virtual void PresentRenderWindow(const SPtr<render::RenderWindow> &renderWindow, GpuQueueMask syncMask = GpuQueueMask::kAll) = 0

Presents the back-buffer image from the provided window onto the window, using the appropriate queue that supports present operations.

renderWindow
Window whose back-buffer to present.
syncMask
Optional synchronization mask that determines if the present operation depends on command buffers submitted on other queues.

WaitUntilIdle

virtual void WaitUntilIdle() = 0

Blocks the calling thread until all operations on the device finish.

BeginFrame

virtual void BeginFrame() = 0

EndFrame

virtual void EndFrame() = 0

Notifies the device the rendering for the current frame has ended.

See BeginFrame().

GetOrCreateTransferCommandBuffer

const SPtr<render::GpuCommandBuffer> &GetOrCreateTransferCommandBuffer()

Retrieves or creates a transfer command buffer for the current thread.

The returned command buffer will be automatically submitted during EndFrame() or when SubmitTransferCommandBuffer() is called.

SubmitTransferCommandBuffers

virtual void SubmitTransferCommandBuffers(bool wait = false)

Submits the transfer command buffer for the current thread.

Optionally waits until the GPU is done processing it.

wait
If true, blocks until the GPU has finished executing the transfer command buffer.

CompileGpuProgramBytecode

virtual SPtr<GpuProgramBytecode> CompileGpuProgramBytecode(const GpuProgramCreateInformation &createInformation) const = 0

Compiles the GPU program to an intermediate bytecode format.

The bytecode can be cached and used for quicker compilation/creation of GPU programs.

CreateGpuCommandBufferPool

virtual SPtr<render::GpuCommandBufferPool> CreateGpuCommandBufferPool(const render::GpuCommandBufferPoolCreateInformation &createInformation) = 0

Creates a command buffer pool that may be used for allocating command buffers.

CreateTexture

virtual SPtr<render::Texture> CreateTexture(const TextureCreateInformation &createInformation, GpuObjectCreateFlags flags = GpuObjectCreateFlag::None) = 0

Creates a new GPU texture.

createInformation
Object describing the texture to create.
flags
Creation flags.

CreateGpuBuffer

virtual SPtr<render::GpuBuffer> CreateGpuBuffer(const GpuBufferCreateInformation &createInformation, GpuObjectCreateFlags flags = GpuObjectCreateFlag::None) = 0

Creates a new GPU buffer.

createInformation
Object describing the buffer to create.
flags
Creation flags.

FindOrCreateSamplerState

virtual SPtr<SamplerState> FindOrCreateSamplerState(const SamplerStateCreateInformation &createInformation)

Creates a new sampler state, or returns an existing one if one with the same create information was already created.

createInformation
Object describing the sampler state to create.

CreateSamplerState

virtual SPtr<SamplerState> CreateSamplerState(const SamplerStateCreateInformation &createInformation, GpuObjectCreateFlags flags = GpuObjectCreateFlag::None) = 0

Creates a sampler state.

createInformation
Object describing the sampler state to create.
flags
Creation flags.

CreateQueryPool

virtual SPtr<render::GpuQueryPool> CreateQueryPool(const render::GpuQueryPoolCreateInformation &createInformation) = 0

Creates a new query pool.

createInformation
Object describing the query pool to create.

CreateEventQuery

virtual SPtr<render::EventQuery> CreateEventQuery() = 0

Create a new event query.

CreateGpuProgram

virtual SPtr<GpuProgram> CreateGpuProgram(const GpuProgramCreateInformation &createInformation, GpuObjectCreateFlags flags = GpuObjectCreateFlag::None) = 0

Creates a new GPU program using the provided source code.

If compilation fails or program is not supported GpuProgram::IsCompiled() will return false, and you will be able to retrieve the error message via GpuProgram::GetCompileErrorMessage().

createInformation
Object describing the program to create.
flags
Creation flags.

CreateGpuGraphicsPipelineState

virtual SPtr<GpuGraphicsPipelineState> CreateGpuGraphicsPipelineState(const GpuGraphicsPipelineStateCreateInformation &createInformation, GpuObjectCreateFlags flags = GpuObjectCreateFlag::None) = 0

Creates a graphics pipeline.

createInformation
Object describing the pipeline to create.
flags
Creation flags.

CreateGpuComputePipelineState

virtual SPtr<GpuComputePipelineState> CreateGpuComputePipelineState(const GpuComputePipelineStateCreateInformation &createInformation, GpuObjectCreateFlags flags = GpuObjectCreateFlag::None) = 0

Creates a compute pipeline.

createInformation
Object describing the pipeline to create.
flags
Creation flags.

CreateGpuPipelineParameterLayout

virtual SPtr<GpuPipelineParameterLayout> CreateGpuPipelineParameterLayout(const GpuPipelineParameterLayoutCreateInformation &createInformation) = 0

Creates a pipeline layout from a set of GPU program parameter descriptions.

createInformation
Object describing the layout to create.

CreateGpuPipelineParameterSetLayout

virtual SPtr<GpuPipelineParameterSetLayout> CreateGpuPipelineParameterSetLayout(const GpuProgramParameterDescription &parameterDescription) = 0

Creates a single GPU pipeline parameter set layout from a parameter description.

parameterDescription
Description of parameters in the set.

Returns: The created set layout.

CreateParameterSetPool

virtual UPtr<GpuParameterSetPool> CreateParameterSetPool(const GpuParameterSetPoolCreateInformation &createInformation) = 0

Creates a parameter set pool for allocating GPU parameter sets.

createInformation
Pool configuration including mode and capacity limits.

Returns: Created parameter set pool.

ConvertProjectionMatrix

virtual void ConvertProjectionMatrix(const Matrix4 &input, Matrix4 &output) = 0

Contains a default matrix into a matrix suitable for use by this specific render system.

GenerateUniformBufferInformation

virtual GpuUniformBufferInformation GenerateUniformBufferInformation(const String &name, TArray<GpuUniformBufferMemberInformation> &inOutUniforms) = 0

Generates a uniform buffer description and calculates per-uniform offsets for the provided buffer members.

The generated offsets are GPU backend specific.

name
Name to assign the uniform block.
inOutUniforms
List of members in the uniform buffer. Only name, type and array size fields need to be populated, the rest will be populated when the method returns. If a parameter is a struct then the elementSize field needs to be populated with the size of the struct in bytes.

Returns: Descriptor for the uniform buffer holding the provided parameters as laid out by the active GPU backend's layout.

ConvertTimestampToMilliseconds

virtual float ConvertTimestampToMilliseconds(u64 timestamp) = 0

Converts a GPU timestamp into a time in milliseconds.

timestamp
Timestamp as the one retrieved from timestamp GPU query.

Returns: Time in milliseconds.

Protected

Fields

mTransferBufferHelper

UPtr<GpuTransferBufferHelper> mTransferBufferHelper

mCachedSamplerStates

UnorderedMap<SamplerStateCreateInformation, SPtr<SamplerState>> mCachedSamplerStates

mSamplerStateMutex

Mutex mSamplerStateMutex