org.graphiks.webgpu.descriptors¶
Types¶
BindGroupDescriptor¶
data class BindGroupDescriptor(
val layout: GPUBindGroupLayout,
val entries: List<GPUBindGroupEntry>,
val label: String = ""
) : GPUBindGroupDescriptor
Describes the layout and resources used to create a GPUBindGroup.
BindGroupEntry¶
data class BindGroupEntry(val binding: GPUIndex32, val resource: GPUBindingResource) : GPUBindGroupEntry
Associates a binding index with the GPU resource supplied for that binding.
BindGroupLayoutDescriptor¶
data class BindGroupLayoutDescriptor(val entries: List<GPUBindGroupLayoutEntry>, val label: String = "") : GPUBindGroupLayoutDescriptor
Describes the entries that define a GPUBindGroupLayout.
BindGroupLayoutEntry¶
data class BindGroupLayoutEntry(
val binding: GPUIndex32,
val visibility: GPUShaderStage,
val buffer: GPUBufferBindingLayout? = null,
val sampler: GPUSamplerBindingLayout? = null,
val texture: GPUTextureBindingLayout? = null,
val storageTexture: GPUStorageTextureBindingLayout? = null
) : GPUBindGroupLayoutEntry
Describes one binding's index, shader visibility, and resource-specific layout.
BlendComponent¶
data class BlendComponent(
val operation: GPUBlendOperation = GPUBlendOperation.Add,
val srcFactor: GPUBlendFactor = GPUBlendFactor.One,
val dstFactor: GPUBlendFactor = GPUBlendFactor.Zero
) : GPUBlendComponent
Describes one color or alpha blend component's operation and factors.
BlendState¶
data class BlendState(val color: GPUBlendComponent, val alpha: GPUBlendComponent) : GPUBlendState
Describes the color and alpha blend components applied to a color target.
BufferBinding¶
data class BufferBinding(
val buffer: GPUBuffer,
val offset: GPUSize64,
val size: GPUSize64? = null
) : GPUBufferBinding
A buffer resource and the byte range exposed to a shader through a bind group.
BufferBindingLayout¶
data class BufferBindingLayout(
val type: GPUBufferBindingType = GPUBufferBindingType.Uniform,
val hasDynamicOffset: Boolean = false,
val minBindingSize: GPUSize64
) : GPUBufferBindingLayout
Describes the type, dynamic-offset behavior, and minimum size of a buffer binding.
BufferDescriptor¶
data class BufferDescriptor(
val size: GPUSize64,
val usage: GPUBufferUsage,
val mappedAtCreation: Boolean = false,
val label: String = ""
) : GPUBufferDescriptor
Describes a GPUBuffer's size, usage, and optional mapped-at-creation state.
Color¶
An RGBA color represented by four components.
ColorTargetState¶
data class ColorTargetState(
val format: GPUTextureFormat,
val blend: GPUBlendState? = null,
val writeMask: GPUColorWrite = GPUColorWrite.All
) : GPUColorTargetState
Describes the format, write mask, and optional blending for a fragment color target.
CommandBufferDescriptor¶
data class CommandBufferDescriptor(val label: String = "") : GPUCommandBufferDescriptor
Options used when finishing a GPUCommandEncoder to create a GPUCommandBuffer.
CommandEncoderDescriptor¶
data class CommandEncoderDescriptor(val label: String = "") : GPUCommandEncoderDescriptor
Options used to create a GPUCommandEncoder.
ComputePassDescriptor¶
data class ComputePassDescriptor(val timestampWrites: GPUComputePassTimestampWrites? = null, val label: String = "") : GPUComputePassDescriptor
Options for beginning a compute pass, including optional timestamp writes.
ComputePassTimestampWrites¶
data class ComputePassTimestampWrites(
val querySet: GPUQuerySet,
val beginningOfPassWriteIndex: GPUSize32? = null,
val endOfPassWriteIndex: GPUSize32? = null
) : GPUComputePassTimestampWrites
Selects query slots for compute-pass beginning and end timestamps.
ComputePipelineDescriptor¶
data class ComputePipelineDescriptor(
val compute: GPUProgrammableStage,
val layout: GPUPipelineLayout? = null,
val label: String = ""
) : GPUComputePipelineDescriptor
Describes the layout and compute shader stage used to create a GPUComputePipeline.
DepthStencilState¶
data class DepthStencilState(
val format: GPUTextureFormat,
val depthWriteEnabled: Boolean? = null,
val depthCompare: GPUCompareFunction? = null,
val stencilFront: GPUStencilFaceState = StencilFaceState(),
val stencilBack: GPUStencilFaceState = StencilFaceState(),
val stencilReadMask: GPUStencilValue,
val stencilWriteMask: GPUStencilValue,
val depthBias: GPUDepthBias = 0,
val depthBiasSlopeScale: Float = 0.0f,
val depthBiasClamp: Float = 0.0f
) : GPUDepthStencilState
Describes depth testing, stencil testing, and depth bias for a render pipeline.
DeviceDescriptor¶
data class DeviceDescriptor(
val requiredFeatures: List<GPUFeatureName> = emptyList(),
val requiredLimits: GPURequiredLimits? = null,
val defaultQueue: GPUQueueDescriptor = QueueDescriptor(),
val label: String = "",
val onUncapturedError: GPUUncapturedErrorCallback? = null
) : GPUDeviceDescriptor
GPUDeviceDescriptor describes a device request.
Extent3D¶
data class Extent3D(
val width: GPUIntegerCoordinate,
val height: GPUIntegerCoordinate,
val depthOrArrayLayers: GPUIntegerCoordinate
) : GPUExtent3D
A three-dimensional extent represented by width, height, and depth or array-layer count.
FragmentState¶
data class FragmentState(
val targets: List<GPUColorTargetState?>,
val module: GPUShaderModule,
val entryPoint: String? = null,
val constants: Map<String, GPUPipelineConstantValue> = emptyMap()
) : GPUFragmentState
Describes the fragment shader stage and its color targets.
MultisampleState¶
data class MultisampleState(
val count: GPUSize32,
val mask: GPUSampleMask,
val alphaToCoverageEnabled: Boolean = false
) : GPUMultisampleState
Describes sample count, sample mask, and alpha-to-coverage behavior.
ObjectDescriptorBase¶
data class ObjectDescriptorBase(val label: String = "") : GPUObjectDescriptorBase
Common label field shared by descriptors that create WebGPU objects.
Origin2D¶
data class Origin2D(val x: GPUIntegerCoordinate, val y: GPUIntegerCoordinate) : GPUOrigin2D
A two-dimensional origin represented by x and y coordinates.
Origin3D¶
data class Origin3D(
val x: GPUIntegerCoordinate,
val y: GPUIntegerCoordinate,
val z: GPUIntegerCoordinate
) : GPUOrigin3D
A three-dimensional origin represented by x, y, and z coordinates.
PipelineDescriptorBase¶
data class PipelineDescriptorBase(val layout: GPUPipelineLayout? = null, val label: String = "") : GPUPipelineDescriptorBase
Common label field shared by render and compute pipeline descriptors.
PipelineLayoutDescriptor¶
data class PipelineLayoutDescriptor(
val bindGroupLayouts: List<GPUBindGroupLayout?>,
val immediateSize: GPUSize32,
val label: String = ""
) : GPUPipelineLayoutDescriptor
Lists the GPUBindGroupLayouts used by a pipeline.
PrimitiveState¶
data class PrimitiveState(
val topology: GPUPrimitiveTopology = GPUPrimitiveTopology.TriangleList,
val stripIndexFormat: GPUIndexFormat? = null,
val frontFace: GPUFrontFace = GPUFrontFace.CCW,
val cullMode: GPUCullMode = GPUCullMode.None,
val unclippedDepth: Boolean = false
) : GPUPrimitiveState
Describes primitive topology, strip format, front face, and culling for a render pipeline.
ProgrammableStage¶
data class ProgrammableStage(
val module: GPUShaderModule,
val entryPoint: String? = null,
val constants: Map<String, GPUPipelineConstantValue> = emptyMap()
) : GPUProgrammableStage
A GPUProgrammableStage describes the entry point in the user-provided GPUShaderModule that controls one of the programmable stages of a pipeline. Entry point names follow the rules defined in WGSL identifier comparison.
QuerySetDescriptor¶
data class QuerySetDescriptor(
val type: GPUQueryType,
val count: GPUSize32,
val label: String = ""
) : GPUQuerySetDescriptor
Describes the query type and number of queries in a GPUQuerySet.
QueueDescriptor¶
data class QueueDescriptor(val label: String = "") : GPUQueueDescriptor
GPUQueueDescriptor describes a queue request.
RenderBundleDescriptor¶
data class RenderBundleDescriptor(val label: String = "") : GPURenderBundleDescriptor
Options used when finishing a GPURenderBundleEncoder to create a GPURenderBundle.
RenderBundleEncoderDescriptor¶
data class RenderBundleEncoderDescriptor(
val colorFormats: List<GPUTextureFormat?>,
val depthReadOnly: Boolean = false,
val stencilReadOnly: Boolean = false,
val depthStencilFormat: GPUTextureFormat? = null,
val sampleCount: GPUSize32,
val label: String = ""
) : GPURenderBundleEncoderDescriptor
Options used to create a GPURenderBundleEncoder.
RenderPassColorAttachment¶
data class RenderPassColorAttachment(
val view: GPUTextureOrGPUTextureView,
val loadOp: GPULoadOp,
val storeOp: GPUStoreOp,
val depthSlice: GPUIntegerCoordinate? = null,
val resolveTarget: GPUTextureOrGPUTextureView? = null,
val clearValue: GPUColor? = null
) : GPURenderPassColorAttachment
Describes a color attachment and its load, store, and resolve operations for a render pass.
RenderPassDepthStencilAttachment¶
data class RenderPassDepthStencilAttachment(
val view: GPUTextureOrGPUTextureView,
val depthClearValue: Float? = null,
val depthLoadOp: GPULoadOp? = null,
val depthStoreOp: GPUStoreOp? = null,
val depthReadOnly: Boolean = false,
val stencilClearValue: GPUStencilValue,
val stencilLoadOp: GPULoadOp? = null,
val stencilStoreOp: GPUStoreOp? = null,
val stencilReadOnly: Boolean = false
) : GPURenderPassDepthStencilAttachment
Describes the depth and stencil operations for a render pass attachment.
RenderPassDescriptor¶
data class RenderPassDescriptor(
val colorAttachments: List<GPURenderPassColorAttachment?>,
val depthStencilAttachment: GPURenderPassDepthStencilAttachment? = null,
val occlusionQuerySet: GPUQuerySet? = null,
val timestampWrites: GPURenderPassTimestampWrites? = null,
val maxDrawCount: GPUSize64,
val label: String = ""
) : GPURenderPassDescriptor
Describes the color, depth/stencil, and optional timestamp attachments for a render pass.
RenderPassLayout¶
data class RenderPassLayout(
val colorFormats: List<GPUTextureFormat?>,
val depthStencilFormat: GPUTextureFormat? = null,
val sampleCount: GPUSize32,
val label: String = ""
) : GPURenderPassLayout
Describes the attachment formats and sample count used by a render pass or render bundle.
RenderPassTimestampWrites¶
data class RenderPassTimestampWrites(
val querySet: GPUQuerySet,
val beginningOfPassWriteIndex: GPUSize32? = null,
val endOfPassWriteIndex: GPUSize32? = null
) : GPURenderPassTimestampWrites
Selects query slots for render-pass beginning, end, and optional per-stage timestamps.
RenderPipelineDescriptor¶
data class RenderPipelineDescriptor(
val vertex: GPUVertexState,
val primitive: GPUPrimitiveState = PrimitiveState(),
val depthStencil: GPUDepthStencilState? = null,
val multisample: GPUMultisampleState = MultisampleState(),
val fragment: GPUFragmentState? = null,
val layout: GPUPipelineLayout? = null,
val label: String = ""
) : GPURenderPipelineDescriptor
Describes the layout and programmable stages and fixed-function state of a GPURenderPipeline.
RequestAdapterOptions¶
data class RequestAdapterOptions(
val featureLevel: GPUFeatureLevel = GPUFeatureLevel.Core,
val powerPreference: GPUPowerPreference? = null,
val forceFallbackAdapter: Boolean = false,
val xrCompatible: Boolean = false
) : GPURequestAdapterOptions
Options that constrain which GPU adapter is selected.
RequiredLimits¶
data class RequiredLimits(
val maxTextureDimension1D: UInt? = null,
val maxTextureDimension2D: UInt? = null,
val maxTextureDimension3D: UInt? = null,
val maxTextureArrayLayers: UInt? = null,
val maxBindGroups: UInt? = null,
val maxBindGroupsPlusVertexBuffers: UInt? = null,
val maxImmediateSize: UInt? = null,
val maxBindingsPerBindGroup: UInt? = null,
val maxDynamicUniformBuffersPerPipelineLayout: UInt? = null,
val maxDynamicStorageBuffersPerPipelineLayout: UInt? = null,
val maxSampledTexturesPerShaderStage: UInt? = null,
val maxSamplersPerShaderStage: UInt? = null,
val maxStorageBuffersPerShaderStage: UInt? = null,
val maxStorageBuffersInVertexStage: UInt? = null,
val maxStorageBuffersInFragmentStage: UInt? = null,
val maxStorageTexturesPerShaderStage: UInt? = null,
val maxStorageTexturesInVertexStage: UInt? = null,
val maxStorageTexturesInFragmentStage: UInt? = null,
val maxUniformBuffersPerShaderStage: UInt? = null,
val maxUniformBufferBindingSize: ULong? = null,
val maxStorageBufferBindingSize: ULong? = null,
val minUniformBufferOffsetAlignment: UInt? = null,
val minStorageBufferOffsetAlignment: UInt? = null,
val maxVertexBuffers: UInt? = null,
val maxBufferSize: ULong? = null,
val maxVertexAttributes: UInt? = null,
val maxVertexBufferArrayStride: UInt? = null,
val maxInterStageShaderVariables: UInt? = null,
val maxColorAttachments: UInt? = null,
val maxColorAttachmentBytesPerSample: UInt? = null,
val maxComputeWorkgroupStorageSize: UInt? = null,
val maxComputeInvocationsPerWorkgroup: UInt? = null,
val maxComputeWorkgroupSizeX: UInt? = null,
val maxComputeWorkgroupSizeY: UInt? = null,
val maxComputeWorkgroupSizeZ: UInt? = null,
val maxComputeWorkgroupsPerDimension: UInt? = null
) : GPURequiredLimits
SamplerBindingLayout¶
data class SamplerBindingLayout(val type: GPUSamplerBindingType = GPUSamplerBindingType.Filtering) : GPUSamplerBindingLayout
Describes the sampler binding type expected by a shader.
SamplerDescriptor¶
data class SamplerDescriptor(
val addressModeU: GPUAddressMode = GPUAddressMode.ClampToEdge,
val addressModeV: GPUAddressMode = GPUAddressMode.ClampToEdge,
val addressModeW: GPUAddressMode = GPUAddressMode.ClampToEdge,
val magFilter: GPUFilterMode = GPUFilterMode.Nearest,
val minFilter: GPUFilterMode = GPUFilterMode.Nearest,
val mipmapFilter: GPUMipmapFilterMode = GPUMipmapFilterMode.Nearest,
val lodMinClamp: Float = 0.0f,
val lodMaxClamp: Float = 32.0f,
val compare: GPUCompareFunction? = null,
val maxAnisotropy: UShort,
val label: String = ""
) : GPUSamplerDescriptor
Describes the address modes, filtering modes, and level-of-detail limits for a GPUSampler.
ShaderModuleCompilationHint¶
data class ShaderModuleCompilationHint(val entryPoint: String, val layout: GPUPipelineLayout? = null) : GPUShaderModuleCompilationHint
A hint associating a shader entry point with the pipeline layout expected to use it.
ShaderModuleDescriptor¶
data class ShaderModuleDescriptor(
val code: String,
val compilationHints: List<GPUShaderModuleCompilationHint> = emptyList(),
val label: String = ""
) : GPUShaderModuleDescriptor
Describes the shader code and compilation options used to create a GPUShaderModule.
StencilFaceState¶
data class StencilFaceState(
val compare: GPUCompareFunction = GPUCompareFunction.Always,
val failOp: GPUStencilOperation = GPUStencilOperation.Keep,
val depthFailOp: GPUStencilOperation = GPUStencilOperation.Keep,
val passOp: GPUStencilOperation = GPUStencilOperation.Keep
) : GPUStencilFaceState
Describes stencil comparison and the operations applied to a stencil face.
StorageTextureBindingLayout¶
data class StorageTextureBindingLayout(
val format: GPUTextureFormat,
val access: GPUStorageTextureAccess = GPUStorageTextureAccess.WriteOnly,
val viewDimension: GPUTextureViewDimension = GPUTextureViewDimension.TwoD
) : GPUStorageTextureBindingLayout
Describes the access mode, format, and view dimension of a storage texture binding.
TexelCopyBufferInfo¶
data class TexelCopyBufferInfo(
val buffer: GPUBuffer,
val offset: GPUSize64,
val bytesPerRow: GPUSize32? = null,
val rowsPerImage: GPUSize32? = null
) : GPUTexelCopyBufferInfo
"GPUTexelCopyBufferInfo" describes the "info" (GPUBuffer and GPUTexelCopyBufferLayout) about a "buffer" source or destination of a "texel copy" operation. Together with the copySize, it describes the footprint of a region of texels in a GPUBuffer.
TexelCopyBufferLayout¶
data class TexelCopyBufferLayout(
val offset: GPUSize64,
val bytesPerRow: GPUSize32? = null,
val rowsPerImage: GPUSize32? = null
) : GPUTexelCopyBufferLayout
"GPUTexelCopyBufferLayout" describes the "layout" of texels in a "buffer" of bytes (GPUBuffer or AllowSharedBufferSource) in a "texel copy" operation.
TexelCopyTextureInfo¶
data class TexelCopyTextureInfo(
val texture: GPUTexture,
val mipLevel: GPUIntegerCoordinate,
val origin: GPUOrigin3D = Origin3D(),
val aspect: GPUTextureAspect = GPUTextureAspect.All
) : GPUTexelCopyTextureInfo
"GPUTexelCopyTextureInfo" describes the "info" (GPUTexture, etc.) about a "texture" source or destination of a "texel copy" operation. Together with the copySize, it describes a sub-region of a texture (spanning one or more contiguous texture subresources at the same mip-map level).
TextureBindingLayout¶
data class TextureBindingLayout(
val sampleType: GPUTextureSampleType = GPUTextureSampleType.Float,
val viewDimension: GPUTextureViewDimension = GPUTextureViewDimension.TwoD,
val multisampled: Boolean = false
) : GPUTextureBindingLayout
Describes the sample type, view dimension, and multisampling of a texture binding.
TextureDescriptor¶
data class TextureDescriptor(
val size: GPUExtent3D,
val format: GPUTextureFormat,
val usage: GPUTextureUsage,
val mipLevelCount: GPUIntegerCoordinate,
val sampleCount: GPUSize32,
val dimension: GPUTextureDimension = GPUTextureDimension.TwoD,
val viewFormats: List<GPUTextureFormat> = emptyList(),
val textureBindingViewDimension: GPUTextureViewDimension? = null,
val label: String = ""
) : GPUTextureDescriptor
Describes a GPUTexture's size, format, usage, and optional view formats.
TextureViewDescriptor¶
data class TextureViewDescriptor(
val format: GPUTextureFormat? = null,
val dimension: GPUTextureViewDimension? = null,
val usage: GPUTextureUsage = GPUTextureUsage.None,
val aspect: GPUTextureAspect = GPUTextureAspect.All,
val baseMipLevel: GPUIntegerCoordinate,
val mipLevelCount: GPUIntegerCoordinate? = null,
val baseArrayLayer: GPUIntegerCoordinate,
val arrayLayerCount: GPUIntegerCoordinate? = null,
val swizzle: GPUTextureSwizzle = GPUTextureSwizzle(),
val label: String = ""
) : GPUTextureViewDescriptor
Describes the format, dimension, mip levels, array layers, and aspect of a GPUTextureView.
VertexAttribute¶
data class VertexAttribute(
val format: GPUVertexFormat,
val offset: GPUSize64,
val shaderLocation: GPUIndex32
) : GPUVertexAttribute
Describes one vertex attribute's format and byte offset in a vertex buffer.
VertexBufferLayout¶
data class VertexBufferLayout(
val arrayStride: GPUSize64,
val attributes: List<GPUVertexAttribute>,
val stepMode: GPUVertexStepMode = GPUVertexStepMode.Vertex
) : GPUVertexBufferLayout
Describes the stride, step mode, and attributes of a vertex buffer.
VertexState¶
data class VertexState(
val module: GPUShaderModule,
val buffers: List<GPUVertexBufferLayout?> = emptyList(),
val entryPoint: String? = null,
val constants: Map<String, GPUPipelineConstantValue> = emptyMap()
) : GPUVertexState
Describes the vertex shader stage and vertex buffer layouts for a render pipeline.