Documentation
¶
Overview ¶
Package gpucore provides shared GPU abstractions for the gg rendering pipeline.
This package defines the GPUAdapter interface, which abstracts over different GPU backend implementations, allowing the same rendering algorithms to work with:
- gogpu/wgpu (Pure Go WebGPU via HAL)
- gogpu/gogpu (High-level GPU framework with dual backends)
Architecture ¶
The gpucore package implements Option C from the GPU Backend Architecture: shared gpucore + thin adapters. The core rendering pipeline (flatten -> coarse -> fine) is implemented once in this package, while thin adapters translate between the GPUAdapter interface and specific backend APIs.
+-----------------+
| gpucore |
| (HybridPipeline)|
+--------+--------+
|
+--------------+--------------+
| |
+--------v--------+ +--------v--------+
| wgpu adapter | | gogpu adapter |
| (hal.Device) | | (gpu.Backend) |
+--------+--------+ +--------+--------+
| |
+--------v--------+ +--------v--------+
| gogpu/wgpu | | gogpu/gogpu |
| (Pure Go) | | (Rust or Go) |
+-----------------+ +-----------------+
Pipeline Stages ¶
The HybridPipeline orchestrates three stages:
Flatten: Converts Bezier curves to monotonic line segments using Wang's formula for adaptive subdivision.
Coarse: Bins segments into tiles for efficient parallel processing. Each tile tracks which segments intersect it.
Fine: Calculates per-pixel coverage using analytical area computation. Supports both NonZero and EvenOdd fill rules.
Resource Management ¶
GPU resources are managed via opaque IDs (BufferID, TextureID, etc.). The GPUAdapter interface provides creation and destruction methods for each resource type. Adapters are responsible for tracking the mapping between IDs and actual GPU resources.
CPU Fallback ¶
When GPU compute is unavailable or for debugging purposes, the pipeline can run entirely on CPU. Set [PipelineConfig.UseCPUFallback] to true to force CPU execution of all stages.
Usage Example ¶
// Create adapter (implementation-specific)
adapter := wgpuadapter.New(device, queue)
// Create pipeline
config := &gpucore.PipelineConfig{
Width: 1920,
Height: 1080,
MaxPaths: 10000,
MaxSegments: 100000,
}
pipeline, err := gpucore.NewHybridPipeline(adapter, config)
if err != nil {
return err
}
defer pipeline.Destroy()
// Render paths
result, err := pipeline.Execute(paths, transform, fillRule)
Index ¶
- Constants
- type AdapterCapabilities
- type AffineTransform
- type BindGroupDesc
- type BindGroupEntry
- type BindGroupID
- type BindGroupLayoutDesc
- type BindGroupLayoutEntry
- type BindGroupLayoutID
- type BindingType
- type BufferID
- type BufferUsage
- type CoarseConfig
- type ComputePassEncoder
- type ComputePipelineDesc
- type ComputePipelineID
- type CursorState
- type FillRule
- type FineConfig
- type FlattenConfig
- type GPUAdapter
- type HybridPipeline
- func (p *HybridPipeline) Config() PipelineConfig
- func (p *HybridPipeline) Destroy()
- func (p *HybridPipeline) Execute(paths interface{}, transform AffineTransform, fillRule FillRule) ([]uint8, error)
- func (p *HybridPipeline) ExecuteWithStats(paths interface{}, transform AffineTransform, fillRule FillRule) ([]uint8, *PipelineStats, error)
- func (p *HybridPipeline) IsInitialized() bool
- func (p *HybridPipeline) Resize(width, height int) error
- func (p *HybridPipeline) SetTolerance(tolerance float32)
- func (p *HybridPipeline) SetUseCPUFallback(useCPU bool)
- func (p *HybridPipeline) TileColumns() int
- func (p *HybridPipeline) TileCount() int
- func (p *HybridPipeline) TileRows() int
- func (p *HybridPipeline) Tolerance() float32
- func (p *HybridPipeline) UseGPU() bool
- type PathElement
- type PipelineConfig
- type PipelineLayoutID
- type PipelineStats
- type Segment
- type SegmentCount
- type ShaderModuleID
- type TextureFormat
- type TextureID
- type TextureUsage
- type TileInfo
- type TileSegmentRef
Constants ¶
const DefaultTolerance float32 = 0.25
DefaultTolerance is the default flattening tolerance in pixels.
const InvalidID = 0
InvalidID is the zero value, representing an invalid/null resource.
const MaxSegmentsPerCurve = 64
MaxSegmentsPerCurve is the maximum segments generated per curve.
const TileSize = 16
TileSize is the size of a tile in pixels.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AdapterCapabilities ¶
type AdapterCapabilities struct {
// SupportsCompute indicates compute shader support.
SupportsCompute bool
// MaxWorkgroupSizeX is the maximum workgroup size in X dimension.
MaxWorkgroupSizeX uint32
// MaxWorkgroupSizeY is the maximum workgroup size in Y dimension.
MaxWorkgroupSizeY uint32
// MaxWorkgroupSizeZ is the maximum workgroup size in Z dimension.
MaxWorkgroupSizeZ uint32
// MaxWorkgroupInvocations is the maximum total invocations per workgroup.
MaxWorkgroupInvocations uint32
// MaxBufferSize is the maximum buffer size in bytes.
MaxBufferSize uint64
// MaxStorageBufferBindingSize is the maximum storage buffer binding size.
MaxStorageBufferBindingSize uint64
// MaxComputeWorkgroupsPerDimension is the maximum workgroups per dispatch dimension.
MaxComputeWorkgroupsPerDimension uint32
}
AdapterCapabilities describes GPU adapter capabilities.
type AffineTransform ¶
type AffineTransform struct {
A float32 // Scale X
B float32 // Shear Y
C float32 // Shear X
D float32 // Scale Y
E float32 // Translate X
F float32 // Translate Y
Padding1 float32
Padding2 float32
}
AffineTransform represents an affine transform for GPU. Must match AffineTransform in flatten.wgsl. Matrix layout (column-major):
| A C E | | B D F | | 0 0 1 |
type BindGroupDesc ¶
type BindGroupDesc struct {
// Label is an optional debug label.
Label string
// Layout is the bind group layout.
Layout BindGroupLayoutID
// Entries are the resource bindings.
Entries []BindGroupEntry
}
BindGroupDesc describes a bind group.
type BindGroupEntry ¶
type BindGroupEntry struct {
// Binding is the binding index.
Binding uint32
// Buffer is the buffer to bind (for buffer bindings).
Buffer BufferID
// Offset is the offset into the buffer.
Offset uint64
// Size is the size of the buffer range to bind.
// Use 0 to bind the entire buffer from offset.
Size uint64
// Texture is the texture to bind (for texture bindings).
Texture TextureID
}
BindGroupEntry describes a single binding in a bind group.
type BindGroupLayoutDesc ¶
type BindGroupLayoutDesc struct {
// Label is an optional debug label.
Label string
// Entries defines the bindings in this layout.
Entries []BindGroupLayoutEntry
}
BindGroupLayoutDesc describes a bind group layout.
type BindGroupLayoutEntry ¶
type BindGroupLayoutEntry struct {
// Binding is the binding index.
Binding uint32
// Type is the type of resource bound at this index.
Type BindingType
// MinBindingSize is the minimum buffer size for buffer bindings.
// Set to 0 for non-buffer bindings.
MinBindingSize uint64
}
BindGroupLayoutEntry describes a single binding in a bind group layout.
type BindGroupLayoutID ¶
type BindGroupLayoutID uint64
BindGroupLayoutID is an opaque handle to a bind group layout.
type BindingType ¶
type BindingType uint32
BindingType specifies the type of a shader binding.
const ( // BindingTypeUniformBuffer is a uniform buffer binding. BindingTypeUniformBuffer BindingType = iota + 1 // BindingTypeStorageBuffer is a storage buffer binding (read-write). BindingTypeStorageBuffer // BindingTypeReadOnlyStorageBuffer is a read-only storage buffer binding. BindingTypeReadOnlyStorageBuffer // BindingTypeSampler is a texture sampler binding. BindingTypeSampler // BindingTypeSampledTexture is a sampled texture binding. BindingTypeSampledTexture // BindingTypeStorageTexture is a storage texture binding. BindingTypeStorageTexture )
Binding types.
type BufferUsage ¶
type BufferUsage uint32
BufferUsage is a bitmask specifying how a buffer will be used.
const ( // BufferUsageMapRead indicates the buffer can be mapped for reading. BufferUsageMapRead BufferUsage = 1 << 0 // BufferUsageMapWrite indicates the buffer can be mapped for writing. BufferUsageMapWrite BufferUsage = 1 << 1 // BufferUsageCopySrc indicates the buffer can be used as a copy source. BufferUsageCopySrc BufferUsage = 1 << 2 // BufferUsageCopyDst indicates the buffer can be used as a copy destination. BufferUsageCopyDst BufferUsage = 1 << 3 // BufferUsageIndex indicates the buffer can be used as an index buffer. BufferUsageIndex BufferUsage = 1 << 4 // BufferUsageVertex indicates the buffer can be used as a vertex buffer. BufferUsageVertex BufferUsage = 1 << 5 // BufferUsageUniform indicates the buffer can be used as a uniform buffer. BufferUsageUniform BufferUsage = 1 << 6 // BufferUsageStorage indicates the buffer can be used as a storage buffer. BufferUsageStorage BufferUsage = 1 << 7 // BufferUsageIndirect indicates the buffer can be used for indirect dispatch/draw. BufferUsageIndirect BufferUsage = 1 << 8 )
Buffer usage flags.
type CoarseConfig ¶
type CoarseConfig struct {
ViewportWidth uint32 // Viewport width in pixels
ViewportHeight uint32 // Viewport height in pixels
TileColumns uint32 // Number of tile columns
TileRows uint32 // Number of tile rows
SegmentCount uint32 // Number of segments to process
MaxEntries uint32 // Maximum number of tile entries
Padding1 uint32
Padding2 uint32
}
CoarseConfig contains GPU coarse rasterization configuration. Must match CoarseConfig in coarse.wgsl.
type ComputePassEncoder ¶
type ComputePassEncoder interface {
// SetPipeline sets the active compute pipeline.
SetPipeline(pipeline ComputePipelineID)
// SetBindGroup sets a bind group at the specified index.
// Index must be less than the number of bind group layouts in the pipeline.
SetBindGroup(index uint32, group BindGroupID)
// Dispatch dispatches compute workgroups.
// x, y, z are the number of workgroups in each dimension.
// Total threads = x * y * z * workgroup_size.
Dispatch(x, y, z uint32)
// End finishes the compute pass.
// After this call, the encoder cannot be used again.
End()
}
ComputePassEncoder records compute commands.
Usage:
- Obtain encoder from GPUAdapter.BeginComputePass()
- Set pipeline and bind groups
- Dispatch compute workgroups
- Call End() to finish recording
- Call GPUAdapter.Submit() to execute
The encoder is single-use and cannot be reused after End().
type ComputePipelineDesc ¶
type ComputePipelineDesc struct {
// Label is an optional debug label.
Label string
// Layout is the pipeline layout.
Layout PipelineLayoutID
// ShaderModule contains the compute shader.
ShaderModule ShaderModuleID
// EntryPoint is the name of the shader entry point function.
EntryPoint string
}
ComputePipelineDesc describes a compute pipeline.
type ComputePipelineID ¶
type ComputePipelineID uint64
ComputePipelineID is an opaque handle to a compute pipeline.
type CursorState ¶
type CursorState struct {
CurX float32 // Current cursor X
CurY float32 // Current cursor Y
StartX float32 // Subpath start X (for Close)
StartY float32 // Subpath start Y (for Close)
}
CursorState tracks the cursor position per path element. Must match CursorState in flatten.wgsl.
type FineConfig ¶
type FineConfig struct {
ViewportWidth uint32 // Viewport width in pixels
ViewportHeight uint32 // Viewport height in pixels
TileColumns uint32 // Number of tile columns
TileRows uint32 // Number of tile rows
TileCount uint32 // Number of tiles to process
FillRule uint32 // 0 = NonZero, 1 = EvenOdd
Padding1 uint32
Padding2 uint32
}
FineConfig contains GPU fine rasterization configuration. Must match FineConfig in fine.wgsl.
type FlattenConfig ¶
type FlattenConfig struct {
ElementCount uint32 // Number of path elements
Tolerance float32 // Flattening tolerance
MaxSegments uint32 // Maximum total segments
TileSize uint32 // Tile size in pixels
ViewportWidth uint32 // Viewport width
ViewportHeight uint32 // Viewport height
Padding1 uint32
Padding2 uint32
}
FlattenConfig contains GPU flattening configuration. Must match FlattenConfig in flatten.wgsl.
type GPUAdapter ¶
type GPUAdapter interface {
// SupportsCompute returns whether compute shaders are supported.
// If false, the pipeline will use CPU fallback for all stages.
SupportsCompute() bool
// MaxWorkgroupSize returns the maximum workgroup size in each dimension.
// Typical values are [256, 256, 64] or [1024, 1024, 1024].
MaxWorkgroupSize() [3]uint32
// MaxBufferSize returns the maximum buffer size in bytes.
// The pipeline will split buffers that exceed this limit.
MaxBufferSize() uint64
// CreateShaderModule creates a shader module from SPIR-V bytecode.
// The SPIR-V is compiled by naga before being passed here.
//
// Parameters:
// - spirv: SPIR-V bytecode as uint32 words
// - label: optional debug label
//
// Returns the module ID or an error if compilation fails.
CreateShaderModule(spirv []uint32, label string) (ShaderModuleID, error)
// DestroyShaderModule releases a shader module.
DestroyShaderModule(id ShaderModuleID)
// CreateBuffer creates a GPU buffer.
//
// Parameters:
// - size: buffer size in bytes
// - usage: buffer usage flags (bitmask of BufferUsage*)
//
// Returns the buffer ID or an error if allocation fails.
CreateBuffer(size int, usage BufferUsage) (BufferID, error)
// DestroyBuffer releases a GPU buffer.
DestroyBuffer(id BufferID)
// WriteBuffer writes data to a buffer.
// The data is copied to the GPU immediately or staged for later upload.
//
// Parameters:
// - id: target buffer
// - offset: byte offset into the buffer
// - data: data to write
WriteBuffer(id BufferID, offset uint64, data []byte)
// ReadBuffer reads data from a buffer.
// This may cause a GPU-CPU synchronization stall.
//
// Parameters:
// - id: source buffer
// - offset: byte offset into the buffer
// - size: number of bytes to read
//
// Returns the data or an error if reading fails.
ReadBuffer(id BufferID, offset, size uint64) ([]byte, error)
// CreateTexture creates a GPU texture.
//
// Parameters:
// - width: texture width in pixels
// - height: texture height in pixels
// - format: pixel format
//
// Returns the texture ID or an error if allocation fails.
CreateTexture(width, height int, format TextureFormat) (TextureID, error)
// DestroyTexture releases a GPU texture.
DestroyTexture(id TextureID)
// WriteTexture writes data to a texture.
// The data must match the texture format and dimensions.
WriteTexture(id TextureID, data []byte)
// ReadTexture reads data from a texture.
// This may cause a GPU-CPU synchronization stall.
ReadTexture(id TextureID) ([]byte, error)
// CreateBindGroupLayout creates a bind group layout.
// Bind group layouts describe the structure of resource bindings.
CreateBindGroupLayout(desc *BindGroupLayoutDesc) (BindGroupLayoutID, error)
// DestroyBindGroupLayout releases a bind group layout.
DestroyBindGroupLayout(id BindGroupLayoutID)
// CreatePipelineLayout creates a pipeline layout.
// Pipeline layouts combine multiple bind group layouts.
//
// Parameters:
// - layouts: bind group layouts used by the pipeline
//
// Returns the layout ID or an error if creation fails.
CreatePipelineLayout(layouts []BindGroupLayoutID) (PipelineLayoutID, error)
// DestroyPipelineLayout releases a pipeline layout.
DestroyPipelineLayout(id PipelineLayoutID)
// CreateComputePipeline creates a compute pipeline.
CreateComputePipeline(desc *ComputePipelineDesc) (ComputePipelineID, error)
// DestroyComputePipeline releases a compute pipeline.
DestroyComputePipeline(id ComputePipelineID)
// CreateBindGroup creates a bind group.
// Bind groups bind actual resources to a bind group layout.
//
// Parameters:
// - layout: the bind group layout
// - entries: resource bindings
//
// Returns the bind group ID or an error if creation fails.
CreateBindGroup(layout BindGroupLayoutID, entries []BindGroupEntry) (BindGroupID, error)
// DestroyBindGroup releases a bind group.
DestroyBindGroup(id BindGroupID)
// BeginComputePass begins a compute pass.
// Returns an encoder for recording compute commands.
// The encoder must be ended with ComputePassEncoder.End().
BeginComputePass() ComputePassEncoder
// Submit submits recorded commands to the GPU.
// Call this after ending all compute passes to execute them.
Submit()
// WaitIdle waits for all GPU operations to complete.
// Use sparingly as this causes a full GPU-CPU synchronization.
WaitIdle()
}
GPUAdapter abstracts over different GPU backend implementations.
This interface is the core abstraction that allows the rendering pipeline to work with multiple backends (gogpu/wgpu HAL, gogpu/gogpu backends). Implementations must be thread-safe for concurrent use.
Resource lifecycle:
- Resources are created via Create* methods
- Resources must be explicitly destroyed via Destroy* methods
- Destroying a resource while in use is undefined behavior
- IDs become invalid after destruction and must not be reused
type HybridPipeline ¶
type HybridPipeline struct {
// contains filtered or unexported fields
}
HybridPipeline orchestrates the GPU rendering pipeline.
The pipeline consists of three stages:
- Flatten: Convert Bezier curves to line segments
- Coarse: Bin segments into tiles
- Fine: Calculate per-pixel coverage
Each stage can run on GPU or CPU depending on hardware support and configuration.
func NewHybridPipeline ¶
func NewHybridPipeline(adapter GPUAdapter, config *PipelineConfig) (*HybridPipeline, error)
NewHybridPipeline creates a new rendering pipeline.
Parameters:
- adapter: GPU adapter implementation
- config: pipeline configuration
Returns an error if initialization fails.
func (*HybridPipeline) Config ¶
func (p *HybridPipeline) Config() PipelineConfig
Config returns a copy of the pipeline configuration.
func (*HybridPipeline) Destroy ¶
func (p *HybridPipeline) Destroy()
Destroy releases all GPU resources.
func (*HybridPipeline) Execute ¶
func (p *HybridPipeline) Execute(paths interface{}, transform AffineTransform, fillRule FillRule) ([]uint8, error)
Execute runs the rendering pipeline.
This method orchestrates the three pipeline stages:
- Flatten paths to line segments
- Bin segments into tiles (coarse rasterization)
- Calculate pixel coverage (fine rasterization)
Parameters:
- paths: path data to render (format TBD in Phase 2)
- transform: world-to-viewport transform
- fillRule: NonZero or EvenOdd
Returns coverage data or an error.
func (*HybridPipeline) ExecuteWithStats ¶
func (p *HybridPipeline) ExecuteWithStats(paths interface{}, transform AffineTransform, fillRule FillRule) ([]uint8, *PipelineStats, error)
ExecuteWithStats runs the pipeline and returns execution statistics. This is useful for performance profiling and debugging.
func (*HybridPipeline) IsInitialized ¶
func (p *HybridPipeline) IsInitialized() bool
IsInitialized returns whether the pipeline is initialized.
func (*HybridPipeline) Resize ¶
func (p *HybridPipeline) Resize(width, height int) error
Resize updates the pipeline for a new viewport size.
func (*HybridPipeline) SetTolerance ¶
func (p *HybridPipeline) SetTolerance(tolerance float32)
SetTolerance updates the flattening tolerance.
func (*HybridPipeline) SetUseCPUFallback ¶
func (p *HybridPipeline) SetUseCPUFallback(useCPU bool)
SetUseCPUFallback enables or disables CPU fallback mode. When enabled, all stages run on CPU regardless of GPU support.
func (*HybridPipeline) TileColumns ¶
func (p *HybridPipeline) TileColumns() int
TileColumns returns the number of tile columns.
func (*HybridPipeline) TileCount ¶
func (p *HybridPipeline) TileCount() int
TileCount returns the total number of tiles.
func (*HybridPipeline) TileRows ¶
func (p *HybridPipeline) TileRows() int
TileRows returns the number of tile rows.
func (*HybridPipeline) Tolerance ¶
func (p *HybridPipeline) Tolerance() float32
Tolerance returns the current flattening tolerance.
func (*HybridPipeline) UseGPU ¶
func (p *HybridPipeline) UseGPU() bool
UseGPU returns whether the pipeline is using GPU acceleration.
type PathElement ¶
type PathElement struct {
Verb uint32 // Path verb type (0=MoveTo, 1=LineTo, 2=QuadTo, 3=CubicTo, 4=Close)
PointStart uint32 // Start index in points array
PointCount uint32 // Number of points for this element
Padding uint32
}
PathElement represents a path element for GPU processing. Must match PathElement in flatten.wgsl.
type PipelineConfig ¶
type PipelineConfig struct {
// Width is the viewport width in pixels.
Width int
// Height is the viewport height in pixels.
Height int
// MaxPaths is the maximum number of path elements to process.
// If 0, defaults to 10000.
MaxPaths int
// MaxSegments is the maximum number of output segments.
// If 0, defaults to MaxPaths * MaxSegmentsPerCurve.
MaxSegments int
// Tolerance is the flattening tolerance in pixels.
// If 0, defaults to DefaultTolerance.
Tolerance float32
// UseCPUFallback forces CPU execution of all stages.
// Useful for debugging or when GPU compute is unreliable.
UseCPUFallback bool
}
PipelineConfig configures a HybridPipeline.
type PipelineLayoutID ¶
type PipelineLayoutID uint64
PipelineLayoutID is an opaque handle to a pipeline layout.
type PipelineStats ¶
type PipelineStats struct {
// PathCount is the number of paths processed.
PathCount int
// SegmentCount is the number of segments generated.
SegmentCount int
// TileEntryCount is the number of tile entries generated.
TileEntryCount int
// FlattenTimeNS is the time spent in the flatten stage (nanoseconds).
FlattenTimeNS int64
// CoarseTimeNS is the time spent in the coarse stage (nanoseconds).
CoarseTimeNS int64
// FineTimeNS is the time spent in the fine stage (nanoseconds).
FineTimeNS int64
// TotalTimeNS is the total execution time (nanoseconds).
TotalTimeNS int64
// UsedGPU indicates whether GPU was used for this execution.
UsedGPU bool
}
PipelineStats contains pipeline execution statistics.
type Segment ¶
type Segment struct {
X0 float32 // Start X coordinate
Y0 float32 // Start Y coordinate
X1 float32 // End X coordinate
Y1 float32 // End Y coordinate
Winding int32 // Winding direction: +1 or -1
TileY0 int32 // Starting tile Y (precomputed)
TileY1 int32 // Ending tile Y (precomputed)
Padding int32 // Padding for alignment
}
Segment represents a monotonic line segment for GPU processing. Must match the Segment struct in fine.wgsl.
type SegmentCount ¶
type SegmentCount struct {
Count uint32 // Number of segments for this element
Offset uint32 // Prefix sum offset
Padding1 uint32
Padding2 uint32
}
SegmentCount holds segment count per path element. Must match SegmentCount in flatten.wgsl.
type ShaderModuleID ¶
type ShaderModuleID uint64
ShaderModuleID is an opaque handle to a compiled shader module.
type TextureFormat ¶
type TextureFormat uint32
TextureFormat specifies the format of texture data.
const ( // TextureFormatRGBA8Unorm is 8-bit RGBA, normalized unsigned integer. TextureFormatRGBA8Unorm TextureFormat = iota + 1 // TextureFormatRGBA8UnormSRGB is 8-bit RGBA, normalized unsigned integer in sRGB color space. TextureFormatRGBA8UnormSRGB // TextureFormatBGRA8Unorm is 8-bit BGRA, normalized unsigned integer. TextureFormatBGRA8Unorm // TextureFormatBGRA8UnormSRGB is 8-bit BGRA, normalized unsigned integer in sRGB color space. TextureFormatBGRA8UnormSRGB // TextureFormatR8Unorm is 8-bit red channel only, normalized unsigned integer. TextureFormatR8Unorm // TextureFormatR32Float is 32-bit red channel only, floating point. TextureFormatR32Float // TextureFormatRG32Float is 32-bit RG, floating point. TextureFormatRG32Float // TextureFormatRGBA32Float is 32-bit RGBA, floating point. TextureFormatRGBA32Float )
Texture formats.
type TextureUsage ¶
type TextureUsage uint32
TextureUsage is a bitmask specifying how a texture will be used.
const ( // TextureUsageCopySrc indicates the texture can be used as a copy source. TextureUsageCopySrc TextureUsage = 1 << 0 // TextureUsageCopyDst indicates the texture can be used as a copy destination. TextureUsageCopyDst TextureUsage = 1 << 1 // TextureUsageTextureBinding indicates the texture can be bound as a sampled texture. TextureUsageTextureBinding TextureUsage = 1 << 2 // TextureUsageStorageBinding indicates the texture can be bound as a storage texture. TextureUsageStorageBinding TextureUsage = 1 << 3 // TextureUsageRenderAttachment indicates the texture can be used as a render target. TextureUsageRenderAttachment TextureUsage = 1 << 4 )
Texture usage flags.
type TileInfo ¶
type TileInfo struct {
TileX uint32 // Tile X coordinate
TileY uint32 // Tile Y coordinate
StartIdx uint32 // Start index in tile_segments
Count uint32 // Number of segments for this tile
Backdrop int32 // Accumulated winding from left
Padding1 uint32 // Padding for alignment
Padding2 uint32 // Padding for alignment
Padding3 uint32 // Padding for alignment
}
TileInfo contains tile processing information. Must match TileInfo in fine.wgsl.
type TileSegmentRef ¶
type TileSegmentRef struct {
TileX uint32 // Tile X coordinate
TileY uint32 // Tile Y coordinate
SegmentIdx uint32 // Index into segments array
WindingFlag uint32 // Whether this contributes winding (0 or 1)
}
TileSegmentRef maps a segment to a tile. Must match TileSegmentRef in coarse.wgsl.