Device
The Device class represents a GPU device abstraction and serves as the primary interface for creating and managing GPU resources, including buffers, textures, shaders, pipelines, and synchronization primitives. It supports querying device properties, capabilities, and features through the Features struct and provides functions for resource creation, data transfer, and memory operations. Devices can be initialized from a Context, Surface, or Window, and support multiple device types such as Compute, Command, or Copy. This class enables resource management and rendering control across a wide range of hardware platforms, leveraging various GPU features and extensions.
#include <platform/TellusimDevice.h>
Constructors
Device()
explicit Device(Context &context)
explicit Device(Surface &surface)
explicit Device(Window &window)
Methods
Device platform.
Platform getPlatform() const
const char *getPlatformName() const
Device index.
uint32_t getIndex() const
Device info.
String getName() const
String getVendor() const
String getVersion() const
const Features getFeatures() const
Device types.
bool hasQuery(Type type) const
bool hasShader(Type type) const
Device formats.
bool hasTarget(Format format) const
bool hasTexture(Format format) const
bool hasSurface(Format format) const
Create device.
Device createDevice(uint32_t index, uint32_t frames = 3) const
Device createCommandDevice(uint32_t frames = 3) const
Device createComputeDevice(uint32_t frames = 3) const
Device createCopyDevice(uint32_t frames = 3) const
Create query.
Query createQuery() const
Query createQuery(Type type) const
Create fence.
Fence createFence() const
Fence createFence(Fence &shared) const
Fence createFence(Flags flags) const
Create buffer.
Buffer createBuffer() const
Buffer createBuffer(Buffer &shared) const
Buffer createBuffer(Flags flags, size_t size, Format format = FormatUnknown) const
Buffer createBuffer(Flags flags, const void *src, size_t size, Format format = FormatUnknown) const
Create sampler.
Sampler createSampler() const
Sampler createSampler(const Sampler &sampler) const
Sampler createSampler(Filter filter, WrapMode mode = Sampler::WrapModeRepeat, uint32_t anisotropy = Sampler::MaxAnisotropy) const
Create texture.
Texture createTexture() const
Texture createTexture(Texture &shared) const
Texture createTexture(Type type, Format format, Size size, uint32_t layers, Flags flags = Texture::DefaultFlags) const
Texture createTexture(Type type, Format format, Size size, Flags flags = Texture::DefaultFlags) const
Texture createTexture(const Image &image, Flags flags = Texture::DefaultFlags, Async *async = nullptr) const
Texture createTexture2D(Format format, uint32_t size, Flags flags = Texture::DefaultFlags) const
Texture createTexture3D(Format format, uint32_t size, Flags flags = Texture::DefaultFlags) const
Texture createTextureCube(Format format, uint32_t size, Flags flags = Texture::DefaultFlags) const
Texture createTexture2D(Format format, uint32_t width, uint32_t height, Flags flags = Texture::DefaultFlags) const
Texture createTexture3D(Format format, uint32_t width, uint32_t height, uint32_t depth, Flags flags = Texture::DefaultFlags) const
Texture createTexture2D(Format format, uint32_t width, uint32_t height, uint32_t layers, Flags flags = Texture::DefaultFlags) const
Texture createTextureCube(Format format, uint32_t size, uint32_t layers, Flags flags = Texture::DefaultFlags) const
Texture loadTexture(const char *name, Flags flags = Texture::DefaultFlags, Flags image_flags = Image::FlagNone, uint32_t offset = 0, Async *async = nullptr) const
Texture loadTexture(const String &name, Flags flags = Texture::DefaultFlags, Flags image_flags = Image::FlagNone, uint32_t offset = 0, Async *async = nullptr) const
Texture loadTexture(Stream &stream, Flags flags = Texture::DefaultFlags, Flags image_flags = Image::FlagNone, uint32_t offset = 0, Async *async = nullptr) const
Create tracing.
Tracing createTracing() const
Tracing createTracing(const Tracing &tracing) const
Tracing createTracing(uint32_t num_instances, Buffer instance_buffer = Buffer::null, size_t instance_offset = 0, Flags flags = Tracing::DefaultFlags) const
Tracing createTracing(uint32_t num_vertices, Format vertex_format, size_t vertex_stride, uint32_t num_indices, Format index_format, Flags flags = Tracing::DefaultFlags) const
Tracing createTracing(uint32_t num_bounds, size_t bound_stride, Buffer bound_buffer = Buffer::null, size_t bound_offset = 0, Flags flags = Tracing::DefaultFlags) const
Create buffer table.
BufferTable createBufferTable() const
BufferTable createBufferTable(uint32_t size) const
BufferTable createBufferTable(Array<Buffer> buffers, bool owner = false) const
Create texture table.
TextureTable createTextureTable() const
TextureTable createTextureTable(Type type, uint32_t size) const
TextureTable createTextureTable(Array<Texture> textures, bool owner = false) const
Create shader.
Shader createShader() const
Shader loadShader(Type type, const char *name, const char *format) const
Shader loadShaderGLSL(Type type, const char *name, const char *format) const
Shader loadShader(Type type, const char *name, const String ¯os = String::null) const
Shader loadShaderGLSL(Type type, const char *name, const String ¯os = String::null) const
Shader loadShaderSPIRV(Type type, const char *name) const
Shader createShader(Type type, const char *src, const char *format) const
Shader createShaderGLSL(Type type, const char *src, const char *format) const
Shader createShader(Type type, const char *src, const String ¯os = String::null) const
Shader createShaderGLSL(Type type, const char *src, const String ¯os = String::null) const
Shader createShaderSPIRV(Type type, Array<uint32_t> data) const
Create kernel.
Kernel createKernel() const
Kernel createKernel(const Kernel &kernel) const
Release kernel.
void releaseKernel(Kernel &kernel) const
Create pipeline.
Pipeline createPipeline() const
Pipeline createPipeline(const Pipeline &pipeline) const
Release pipeline.
void releasePipeline(Pipeline &pipeline) const
Create traversal.
Traversal createTraversal() const
Traversal createTraversal(const Traversal &traversal) const
Release traversal.
void releaseTraversal(Traversal &traversal) const
Create target.
Target createTarget() const
Target createTarget(Surface &surface) const
Target createTarget(Window &window) const
Target createTarget(const InitializerList<Texture> &textures, Operation op = Target::OpDefault) const
Create compute.
Compute createCompute() const
Create command.
Command createCommand() const
Command createCommand(Target &target) const
Set buffer data.
bool setBuffer(Buffer &buffer, size_t offset, const void *src, size_t size) const
bool setBuffer(Buffer &buffer, const void *src, size_t size) const
bool setBuffer(Buffer &buffer, const void *src) const
Get buffer data.
bool getBuffer(Buffer &buffer, size_t offset, void *dest, size_t size) const
bool getBuffer(Buffer &buffer, void *dest, size_t size) const
bool getBuffer(Buffer &buffer, void *dest) const
Map buffer data.
void *mapBuffer(Buffer &buffer, size_t offset, size_t size) const
void *mapBuffer(Buffer &buffer, size_t size) const
void *mapBuffer(Buffer &buffer) const
bool unmapBuffer(Buffer &buffer) const
Copy buffer data.
bool copyBuffer(Buffer &buffer, size_t dest_offset, Buffer &src, size_t src_offset, size_t size) const
bool copyBuffer(Buffer &buffer, size_t dest_offset, Buffer &src, size_t size) const
bool copyBuffer(Buffer &buffer, Buffer &src, size_t size) const
bool copyBuffer(Buffer &buffer, Buffer &src) const
Clear buffer data.
bool clearBuffer(Buffer &buffer, Format format, size_t offset, const void *src, size_t size) const
bool clearBuffer(Buffer &buffer, Format format, const void *src, size_t size) const
bool clearBuffer(Buffer &buffer, Format format, const void *src) const
bool clearBuffer(Buffer &buffer) const
Bind buffer memory.
bool bindBuffer(Buffer &buffer, Array<size_t> offsets, Array<size_t> sizes, bool commit, Fence &fence) const
bool bindBuffer(Buffer &buffer, Array<size_t> offsets, Array<size_t> sizes, bool commit) const
bool bindBuffer(Buffer &buffer, size_t offset, size_t size, bool commit, Fence &fence) const
bool bindBuffer(Buffer &buffer, size_t offset, size_t size, bool commit) const
Flush buffer data.
bool flushBuffer(Buffer &buffer, Flags flags = Buffer::FlagNone) const
bool flushBuffers(Array<Buffer> buffers, Flags flags = Buffer::FlagNone) const
bool flushBuffers(const InitializerList<Buffer> &buffers, Flags flags = Buffer::FlagNone) const
Release buffer.
void releaseBuffer(Buffer &buffer) const
Release sampler.
void releaseSampler(Sampler &sampler) const
Set texture data.
bool setTexture(Texture &texture, Origin dest_origin, Slice dest_slice, const Image &image, Slice src_slice) const
bool setTexture(Texture &texture, Origin dest_origin, const Image &image) const
bool setTexture(Texture &texture, Slice dest_slice, const Image &image) const
bool setTexture(Texture &texture, const Image &image) const
Get texture data.
bool getTexture(Texture &texture, Slice src_slice, Image &image, Slice dest_slice) const
bool getTexture(Texture &texture, Image &image, Slice dest_slice) const
bool getTexture(Texture &texture, Image &image) const
Copy texture data.
bool copyTexture(Texture &texture, Origin dest_origin, Slice dest_slice, Texture &src, Region src_region, Slice src_slice) const
bool copyTexture(Texture &texture, Origin dest_origin, Texture &src, Region src_region) const
bool copyTexture(Texture &texture, Slice dest_slice, Texture &src, Slice src_slice) const
bool copyTexture(Texture &texture, Texture &src) const
Clear texture data.
bool clearTexture(Texture &texture, Region region, Slice slice, const void *src) const
bool clearTexture(Texture &texture, Region region, const void *src) const
bool clearTexture(Texture &texture, Slice slice, const void *src) const
bool clearTexture(Texture &texture, const void *src) const
Bind texture memory.
bool bindTexture(Texture &texture, const Region *regions, uint32_t num_regions, const Slice *slices, uint32_t num_slices, bool commit, Fence &fence) const
bool bindTexture(Texture &texture, const Region *regions, uint32_t num_regions, const Slice *slices, uint32_t num_slices, bool commit) const
bool bindTexture(Texture &texture, Region region, Slice slice, bool commit, Fence &fence) const
bool bindTexture(Texture &texture, Region region, Slice slice, bool commit) const
Create texture mipmaps.
bool createMipmaps(Texture &texture, Slice slice) const
bool createMipmaps(Texture &texture) const
Flush texture data.
bool flushTexture(Texture &texture, Flags flags = Texture::FlagNone) const
bool flushTexture(Texture &texture, Slice slice, Flags flags = Texture::FlagNone) const
bool flushTextures(Array<Texture> textures, Flags flags = Texture::FlagNone) const
bool flushTextures(const InitializerList<Texture> &textures, Flags flags = Texture::FlagNone) const
Release texture.
void releaseTexture(Texture &texture) const
Set tracing data.
virtual bool setTracing(Tracing &tracing, const Instance *instances, uint32_t num_instances) const
Build tracing.
bool buildTracing(Tracing &tracing, Buffer &buffer, Flags flags = Tracing::FlagNone) const
bool buildTracing(Tracing &tracing, Buffer &buffer, size_t offset, Flags flags = Tracing::FlagNone) const
bool buildTracings(Array<Tracing> tracings, Buffer &buffer, Flags flags = Tracing::FlagNone) const
bool buildTracings(Array<Tracing> tracings, Buffer &buffer, size_t offset, Flags flags = Tracing::FlagNone) const
Copy tracing address.
bool copyTracing(Tracing &tracing, Buffer &buffer, size_t offset = 0) const
bool copyTracings(Array<Tracing> tracings, Buffer &buffer, size_t offset, size_t stride = 0) const
Flush tracing.
bool flushTracing(Tracing &tracing) const
bool flushTracings(Array<Tracing> tracings) const
Release tracing.
void releaseTracing(Tracing &tracing) const
Set table buffer.
bool setBufferTable(BufferTable &table, uint32_t index, Buffer &buffer, bool owner = false) const
bool setBufferTable(BufferTable &table, uint32_t index, Array<Buffer> buffers, bool owner = false) const
Release buffer table.
void releaseBufferTable(BufferTable &table) const
Set table texture.
bool setTextureTable(TextureTable &table, uint32_t index, Texture &texture, bool owner = false) const
bool setTextureTable(TextureTable &table, uint32_t index, Array<Texture> textures, bool owner = false) const
Release texture table.
void releaseTextureTable(TextureTable &table) const
Begin/end query.
bool beginQuery(Query &query) const
void endQuery(Query &query) const
Copy query data.
bool copyQuery(Query &query, Buffer &buffer, size_t offset = 0) const
bool copyQueries(Array<Query> queries, Buffer &buffer, size_t offset = 0, size_t stride = 0) const
bool copyQueries(const InitializerList<Query> &queries, Buffer &buffer, size_t offset = 0, size_t stride = 0) const
Fence synchronization.
bool waitFence(Fence &fence) const
bool signalFence(Fence &fence) const
Execute context.
bool execute(Device &device) const
Flip context.
bool flip(Fence &fence) const
bool flip() const
Flush context.
bool flush() const
Finish context.
bool finish() const
Check errors.
bool check() const
Structs
Features
Device features.
Variables
Type | Name | Description |
---|---|---|
bool | threadAccess | Thread access support. |
bool | sparseBuffer | Sparse buffers support. |
bool | bufferTable | Buffer tables support. |
bool | sparseTexture | Sparse textures support. |
bool | sparseArrayTexture | Sparse array textures support. |
bool | cubeArrayTexture | Cube array textures support. |
bool | textureTable | Texture tables support. |
bool | baseInstanceIndex | Base instance index support. |
bool | drawIndirectIndex | Draw indirect index support. |
bool | drawIndirectCount | Draw indirect count support. |
bool | taskIndirectCount | Task indirect count support. |
bool | vertexStorage | Vertex shader storage support. |
bool | vertexIndexLayer | Vertex shader index layer support. |
bool | geometryPassthrough | Geometry shader passthrough support. |
bool | fragmentBarycentric | Fragment shader barycentric support. |
bool | fragmentStencilExport | Fragment shader stencil export support. |
bool | dualSourceBlending | Dual source blending support. |
bool | depthRangeOneToOne | Depth buffer range one to one. |
bool | conservativeRaster | Conservative raster support. |
bool | conditionalRendering | Conditional rendering support. |
bool | rayTracing | Ray tracing shaders support. |
bool | computeTracing | Compute shader tracing support. |
bool | fragmentTracing | Fragment shader tracing support. |
bool | indirectTracing | Build indirect tracing support. |
uint32_t | recursionDepth | Ray tracing recursion depth. |
bool | subgroupVote | Shader subgroup vote support. |
bool | subgroupMath | Shader subgroup math support. |
bool | subgroupShuffle | Shader subgroup shuffle support. |
uint32_t | subgroupSize | Shader subgroup operations size. |
uint32_t | minSubgroupSize | Shader minimum subgroup size. |
uint32_t | maxSubgroupSize | Shader maximum subgroup size. |
bool | shaderu8 | Shader 8-bit integer support. |
bool | shaderf16 | Shader 16-bit floating-point support. |
bool | shaderu16 | Shader 16-bit integer support. |
bool | shaderf64 | Shader 64-bit floating-point support. |
bool | shaderu64 | Shader 64-bit integer support. |
bool | atomicGroupf32 | Atomic group 32-bit floating-point support. |
bool | atomicGroupu64 | Atomic group 64-bit integer support. |
bool | atomicBufferf32 | Atomic buffer 32-bit floating-point support. |
bool | atomicBufferu64 | Atomic buffer 64-bit integer support. |
bool | atomicTexturef32 | Atomic texture 32-bit floating-point support. |
bool | atomicTextureu32 | Atomic texture 32-bit integer support. |
bool | atomicTextureu64 | Atomic texture 64-bit integer support. |
bool | matrix16f16 | Matrix 16x16x16 16-bit floating point support. |
bool | matrix16x8x8f16 | Matrix 16x8x8 16-bit floating point support. |
bool | matrix16x8x16f16 | Matrix 16x8x16 16-bit floating point support. |
bool | matrix16f16f32 | Matrix 16x16x16 16/32-bit floating point support. |
bool | matrix16x8x8f16f32 | Matrix 16x8x8 16/32-bit floating point support. |
bool | matrix16x8x16f16f32 | Matrix 16x8x16 16/32-bit floating point support. |
uint32_t | uniformAlignment | Uniform buffer alignment in bytes. |
uint32_t | storageAlignment | Storage buffer alignment in bytes. |
uint32_t | maxTextureSamples | Maximum texture samples. |
uint32_t | maxTexture2DSize | Maximum 2D texture size. |
uint32_t | maxTexture3DSize | Maximum 3D texture size. |
uint32_t | maxTextureLayers | Maximum texture layers. |
uint32_t | maxGroupSizeX | Maximum compute shader group size X. |
uint32_t | maxGroupSizeY | Maximum compute shader group size Y. |
uint32_t | maxGroupSizeZ | Maximum compute shader group size Z. |
uint32_t | maxGroupCountX | Maximum compute shader group count X. |
uint32_t | maxGroupCountY | Maximum compute shader group count Y. |
uint32_t | maxGroupCountZ | Maximum compute shader group count Z. |
uint32_t | maxTaskCount | Maximum task shader count. |
uint32_t | maxTaskMemory | Maximum task shader memory. |
uint32_t | maxTaskMeshes | Maximum task shader meshes. |
uint32_t | maxMeshMemory | Maximum mesh shader memory. |
uint32_t | maxMeshVertices | Maximum mesh shader vertices. |
uint32_t | maxMeshPrimitives | Maximum mesh shader primitives. |
uint32_t | maxViewportCount | Maximum viewport count. |
uint32_t | maxClipCullCount | Maximum clip cull count. |
uint64_t | maxUniformSize | Maximum uniform size in bytes. |
uint64_t | maxStorageSize | Maximum storage size in bytes. |
uint32_t | groupMemory | Shared group memory in bytes. |
uint64_t | videoMemory | Dedicated video memory in bytes. |
uint32_t | vendorID | Vendor identifier. |
uint32_t | deviceID | Device identifier. |
uint32_t | pciBusID | PCI bus identifier. |
uint32_t | pciDomainID | PCI domain identifier. |
uint32_t | pciDeviceID | PCI device identifier. |