Donner SVG 0.8.0-pre
SVG editor and embeddable C⁠+⁠+⁠20 engine.
Loading...
Searching...
No Matches
VulkanResourceState.h File Reference

donner::gpu::vulkan::VulkanResourceState - the tracked per-texture synchronization state the Vulkan backend derives its barriers from. More...

#include <vulkan/vulkan.h>
#include <cstdint>
#include <map>
#include <ostream>
Include dependency graph for VulkanResourceState.h:

Classes

struct  donner::gpu::vulkan::TextureSyncState
 The synchronization state a texture is left in, as the backend's bookkeeping records it. More...
struct  donner::gpu::vulkan::ImageBarrierParams
 The six values an image barrier is built from, plus whether precision was available. More...
class  donner::gpu::vulkan::TextureSyncStateTable
 Tracked state for a set of textures, under the discipline the backend records against. More...

Namespaces

namespace  donner
 Top-level Donner namespace, which is split into different sub-namespaces such as donner::svg and donner::css.

Enumerations

enum class  donner::gpu::vulkan::TextureUsageKind : uint8_t {
  Undefined ,
  ColorAttachment ,
  SampledRead ,
  StorageWrite ,
  TransferRead ,
  TransferWrite
}
 What a texture is being used for at one point of a recorded command stream. More...

Functions

std::ostream & donner::gpu::vulkan::operator<< (std::ostream &os, TextureUsageKind value)
 Ostream output operator.
std::ostream & donner::gpu::vulkan::operator<< (std::ostream &os, const TextureSyncState &value)
 Ostream output operator.
std::ostream & donner::gpu::vulkan::operator<< (std::ostream &os, const ImageBarrierParams &value)
 Ostream output operator.
ImageBarrierParams donner::gpu::vulkan::ConservativeImageBarrier (VkImageLayout oldLayout, VkImageLayout newLayout)
 The maximal barrier: ALL_COMMANDS to ALL_COMMANDS with memory availability and visibility.
VkImageLayout donner::gpu::vulkan::LayoutForUsage (TextureUsageKind usage)
 The image layout a usage requires.
TextureSyncState donner::gpu::vulkan::StateAfterUsage (TextureUsageKind usage)
 The state a texture is left in once usage has executed against it.
ImageBarrierParams donner::gpu::vulkan::TransitionFor (const TextureSyncState &current, TextureUsageKind usage)
 The barrier that takes a texture from current to usage.

Detailed Description

donner::gpu::vulkan::VulkanResourceState - the tracked per-texture synchronization state the Vulkan backend derives its barriers from.

Each barrier names the stage and access that last touched the image and its next use. Render passes keep attachment layouts fixed; the barriers around them carry synchronization.

This is pure state machinery over Vulkan enums: it opens no device, calls no entry point, and records nothing. That keeps it testable on every platform the project builds on, rather than only where a Vulkan loader exists.

The tracked patterns are the ones the recorded command streams actually produce. Anything outside them resolves to ConservativeImageBarrier, which is the maximal ALL_COMMANDS/memory barrier this backend used everywhere before: unknown usage costs precision, never correctness.

Enumeration Type Documentation

◆ TextureUsageKind

enum class donner::gpu::vulkan::TextureUsageKind : uint8_t
strong

What a texture is being used for at one point of a recorded command stream.

Write-only storage textures are the only writable binding the runtime declares, so a storage usage is unambiguously a write and needs no read/write fallback. If a writable storage BUFFER binding kind ever enters the runtime, this enum and the table below must gain the host-visibility edge that goes with it, because every buffer this backend allocates is host-mapped and a kernel write to one would otherwise be invisible to the mapping.

Enumerator
Undefined 

Never used; contents undefined.

ColorAttachment 

Read and written as a render pass color attachment.

SampledRead 

Read through a sampled-texture binding.

StorageWrite 

Written through a write-only storage-texture binding.

TransferRead 

Read as the source of a copy.

TransferWrite 

Written as the destination of a copy or an upload.

Function Documentation

◆ ConservativeImageBarrier()

ImageBarrierParams donner::gpu::vulkan::ConservativeImageBarrier ( VkImageLayout oldLayout,
VkImageLayout newLayout )
nodiscard

The maximal barrier: ALL_COMMANDS to ALL_COMMANDS with memory availability and visibility.

The fallback for any usage pair the table does not name. VK_ACCESS_MEMORY_* is valid with any pipeline stage, so this is always legal, and it orders strictly more than any precise barrier would - which is why an unrecognised pattern degrades to it rather than to nothing.

Parameters
oldLayoutLayout the image is in.
newLayoutLayout the image moves to.

◆ LayoutForUsage()

VkImageLayout donner::gpu::vulkan::LayoutForUsage ( TextureUsageKind usage)
nodiscard

The image layout a usage requires.

Parameters
usageUsage the texture is put to.

◆ operator<<() [1/3]

std::ostream & donner::gpu::vulkan::operator<< ( std::ostream & os,
const ImageBarrierParams & value )

Ostream output operator.

Parameters
osOutput stream.
valueValue to output.

◆ operator<<() [2/3]

std::ostream & donner::gpu::vulkan::operator<< ( std::ostream & os,
const TextureSyncState & value )

Ostream output operator.

Parameters
osOutput stream.
valueValue to output.

◆ operator<<() [3/3]

std::ostream & donner::gpu::vulkan::operator<< ( std::ostream & os,
TextureUsageKind value )

Ostream output operator.

Parameters
osOutput stream.
valueValue to output.

◆ StateAfterUsage()

TextureSyncState donner::gpu::vulkan::StateAfterUsage ( TextureUsageKind usage)
nodiscard

The state a texture is left in once usage has executed against it.

Parameters
usageUsage the texture is put to.

◆ TransitionFor()

ImageBarrierParams donner::gpu::vulkan::TransitionFor ( const TextureSyncState & current,
TextureUsageKind usage )
nodiscard

The barrier that takes a texture from current to usage.

The source scope comes from what last touched the image and the destination scope from what is about to, so the tracked patterns - attachment write to sampled read, storage write to sampled read, transfer write to shader read, and their transfer counterparts - name the stages and accesses actually involved instead of every stage and every access.

Parameters
currentState the texture is tracked in.
usageUsage the texture is about to be put to.