TachyonUI 1.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
tachyon::d3d12::D3D12GraphicsContext::Impl Struct Reference

#include <gui_core/graphics/d3d12/d3d12_device.h>

Classes

struct  Garbage
struct  ImageUpload
 A whole image's pixels, or with partial a band of rows from firstRow written into an image already up (UpdateImageRows): its other rows are kept. More...
struct  UploadScratch
 RecordPendingUploads' working lists, kept between frames for their storage. More...
struct  Resident
struct  Scene
 What RenderScene keeps for a key: its color texture (in the image set) and depth, both in liveImages, and a view of each. More...
struct  SceneRequest

Public Member Functions

void NoteFailure (HRESULT hr, const char *what)
 Notes a failed call: logged, and when it says the device is gone, removed is set.
UINT64 Submit (ID3D12CommandList *list)
 Runs list, after the frame waits, and signals the fence's next value, which it returns.
void Wait (UINT64 value)
 Waits on the CPU until the fence reaches value.
void WaitIdle ()
 Waits until everything submitted so far is done, presents included.
UINT64 Completed () const
Buffer CreateUploadBuffer (UINT64 size)
 A buffer the CPU writes and the GPU reads, mapped. Empty on failure.
Buffer CreateGpuBuffer (UINT64 size)
 A buffer in GPU memory, made ready for a copy into it.
void DestroyAfterGpu (ComPtr< D3D12MA::Allocation > allocation, UINT64 afterValue)
 What's let go is freed once the GPU is past afterValue: the next submit (submitted + 1) for anything a window frame being recorded may use, which is everything let go while frames are built; 0 for what no command list refers to.
void DestroyAfterGpu (std::unique_ptr< D3D12Image > image, UINT64 afterValue)
void DestroyAfterGpu (ComPtr< ID3D12Resource > resource, UINT64 afterValue)
void FlushDeletions ()
 Frees what the GPU is done with.
void RecordPendingUploads (ID3D12GraphicsCommandList *list)
 Records the queued image and resident-buffer copies into list.
RHI::ResidentBufferId CreateResidentBuffer (std::span< const RHI::UploadRequest > requests, std::span< DeviceAddress > addresses)
RHI::ResidentState ResidentState (RHI::ResidentBufferId id) const
void ReleaseResident (RHI::ResidentBufferId id)
bool EnsureQuadIndices (ID3D12GraphicsCommandList *list, uint32_t quads)
 Grows the quads' index buffer to hold quads, its copy recorded into list before the draw that needs it; false when it can't.
void RecordScenes (ID3D12GraphicsCommandList *list, ID window)
 Records the scenes asked for in window this frame, before its UI.
D3D12Image * CreateTargetImage (uint2 size, DXGI_FORMAT format, D3D12_RESOURCE_FLAGS flags, D3D12_RESOURCE_STATES state, const D3D12_CLEAR_VALUE *clear, Sampler sampler)
 A texture the GPU draws into (a scene's), in liveImages so DestroyImageAtEnd frees it; null on failure.

Public Attributes

DebugConfig debug
ExternalDevice external
 the host's device and queue, when it gave them
std::string gpuPreference
std::string deviceName
bool debugLayer = false
 the debug layer is on: its messages go to debug
uint32_t imageSlots = 4096
 asked for with SetImageSlotCount
ComPtr< IDXGIFactory6 > factory
ComPtr< IDXGIAdapter1 > adapter
ComPtr< ID3D12Device > device
ComPtr< ID3D12CommandQueue > queue
ComPtr< D3D12MA::Allocator > allocator
 GPU memory: buffers and textures in its heaps.
ComPtr< ID3D12InfoQueue1 > infoQueue
DWORD messageCallback = 0
ComPtr< ID3D12Fence > submitFence
 Every submit signals the next value: submitted is the last one signalled.
std::atomic< UINT64 > submitted = 0
 Atomic: DestroyImageAtEnd, on any thread, reads it.
std::atomic< bool > removed = false
 The device was removed (a Present, a resize or the debug layer said so): told once, with the reason, and the GUI is told through DeviceLost.
HANDLE waitEvent = nullptr
std::vector< std::pair< ComPtr< ID3D12Fence >, UINT64 > > frameWaits
 What the next submit waits for on the queue (AddFrameWait), a fence once each.
std::mutex garbageMutex
 images are let go on any thread
std::vector< Garbage > garbage
std::mutex uploadMutex
 images are made on any thread
std::vector< ImageUpload > imageUploads
struct tachyon::d3d12::D3D12GraphicsContext::Impl::UploadScratch uploadScratch
std::unordered_map< RHI::ResidentBufferId, Resident > residents
std::vector< RHI::ResidentBufferId > pendingResidents
 Made and not copied yet, oldest first; one let go of meanwhile is no longer in residents and is passed over.
RHI::ResidentBufferId nextResident = 1
std::unordered_set< D3D12Image * > liveImages
 Every image made and not let go for a frame (DeviceScope::Frame): those handed over for the application's lifetime too.
D3D12ImageSet imageSet
RHI::ResidentBufferId boxStyles = 0
 The box styles in GPU memory (a resident buffer), made again when they change; 0: none.
RHI::ResidentBufferId colorStyles = 0
 The color styles, with their gradient pages' slots, likewise.
std::vector< ImageIndex > gradientPages
 each gradient page's index in the image set
StyleManager * lastStyles = nullptr
 PrepareFrame's, for a live resize's redraw.
GradientManager * lastGradients = nullptr
float lastTime = 0.0f
ComPtr< ID3D12RootSignature > rootSignature
std::vector< ComPtr< ID3D12PipelineState > > pipelineStates
 by PrimitiveKind
std::array< RHI::GpuPipeline, kPrimitiveKindCount > pipelines {}
Buffer quadIndices
 p * 4 + { 0, 1, 3, 0, 3, 2 } for each quad p, in GPU memory.
uint32_t quadCapacity = 0
GPUDrawPushConstants pushConstants {}
 the styles' addresses and the time, from PrepareFrame
std::unordered_map< ID, Scene > scenes
std::unordered_map< uint32_t, std::unique_ptr< D3D12Image > > externalImages
 By image index: what the image set points at for a host's texture.
std::unordered_map< ID, ID3D12Resource * > imageTargets
 The texture a render-to-image window is copied into, by window.
std::vector< SceneRequest > sceneRequests
uint64_t sceneFrame = 0

Static Public Attributes

static constexpr DXGI_FORMAT kSceneColorFormat = DXGI_FORMAT_R8G8B8A8_UNORM
static constexpr uint64_t kSceneKeepFrames = 4
 a scene not asked for this long goes

Member Function Documentation

◆ NoteFailure()

void tachyon::d3d12::D3D12GraphicsContext::Impl::NoteFailure ( HRESULT hr,
const char * what )

Notes a failed call: logged, and when it says the device is gone, removed is set.

◆ Submit()

UINT64 tachyon::d3d12::D3D12GraphicsContext::Impl::Submit ( ID3D12CommandList * list)

Runs list, after the frame waits, and signals the fence's next value, which it returns.

◆ Wait()

void tachyon::d3d12::D3D12GraphicsContext::Impl::Wait ( UINT64 value)

Waits on the CPU until the fence reaches value.

◆ WaitIdle()

void tachyon::d3d12::D3D12GraphicsContext::Impl::WaitIdle ( )

Waits until everything submitted so far is done, presents included.

◆ Completed()

UINT64 tachyon::d3d12::D3D12GraphicsContext::Impl::Completed ( ) const
inline

◆ CreateUploadBuffer()

Buffer tachyon::d3d12::D3D12GraphicsContext::Impl::CreateUploadBuffer ( UINT64 size)

A buffer the CPU writes and the GPU reads, mapped. Empty on failure.

◆ CreateGpuBuffer()

Buffer tachyon::d3d12::D3D12GraphicsContext::Impl::CreateGpuBuffer ( UINT64 size)

A buffer in GPU memory, made ready for a copy into it.

◆ DestroyAfterGpu() [1/3]

void tachyon::d3d12::D3D12GraphicsContext::Impl::DestroyAfterGpu ( ComPtr< D3D12MA::Allocation > allocation,
UINT64 afterValue )

What's let go is freed once the GPU is past afterValue: the next submit (submitted + 1) for anything a window frame being recorded may use, which is everything let go while frames are built; 0 for what no command list refers to.

◆ DestroyAfterGpu() [2/3]

void tachyon::d3d12::D3D12GraphicsContext::Impl::DestroyAfterGpu ( std::unique_ptr< D3D12Image > image,
UINT64 afterValue )

◆ DestroyAfterGpu() [3/3]

void tachyon::d3d12::D3D12GraphicsContext::Impl::DestroyAfterGpu ( ComPtr< ID3D12Resource > resource,
UINT64 afterValue )

◆ FlushDeletions()

void tachyon::d3d12::D3D12GraphicsContext::Impl::FlushDeletions ( )

Frees what the GPU is done with.

◆ RecordPendingUploads()

void tachyon::d3d12::D3D12GraphicsContext::Impl::RecordPendingUploads ( ID3D12GraphicsCommandList * list)

Records the queued image and resident-buffer copies into list.

◆ CreateResidentBuffer()

RHI::ResidentBufferId tachyon::d3d12::D3D12GraphicsContext::Impl::CreateResidentBuffer ( std::span< const RHI::UploadRequest > requests,
std::span< DeviceAddress > addresses )

◆ ResidentState()

RHI::ResidentState tachyon::d3d12::D3D12GraphicsContext::Impl::ResidentState ( RHI::ResidentBufferId id) const

◆ ReleaseResident()

void tachyon::d3d12::D3D12GraphicsContext::Impl::ReleaseResident ( RHI::ResidentBufferId id)

◆ EnsureQuadIndices()

bool tachyon::d3d12::D3D12GraphicsContext::Impl::EnsureQuadIndices ( ID3D12GraphicsCommandList * list,
uint32_t quads )

Grows the quads' index buffer to hold quads, its copy recorded into list before the draw that needs it; false when it can't.

◆ RecordScenes()

void tachyon::d3d12::D3D12GraphicsContext::Impl::RecordScenes ( ID3D12GraphicsCommandList * list,
ID window )

Records the scenes asked for in window this frame, before its UI.

◆ CreateTargetImage()

D3D12Image * tachyon::d3d12::D3D12GraphicsContext::Impl::CreateTargetImage ( uint2 size,
DXGI_FORMAT format,
D3D12_RESOURCE_FLAGS flags,
D3D12_RESOURCE_STATES state,
const D3D12_CLEAR_VALUE * clear,
Sampler sampler )

A texture the GPU draws into (a scene's), in liveImages so DestroyImageAtEnd frees it; null on failure.

clear: its optimized clear value, or null when it's cleared to values not known in advance.

Member Data Documentation

◆ debug

DebugConfig tachyon::d3d12::D3D12GraphicsContext::Impl::debug

◆ external

ExternalDevice tachyon::d3d12::D3D12GraphicsContext::Impl::external

the host's device and queue, when it gave them

◆ gpuPreference

std::string tachyon::d3d12::D3D12GraphicsContext::Impl::gpuPreference

◆ deviceName

std::string tachyon::d3d12::D3D12GraphicsContext::Impl::deviceName

◆ debugLayer

bool tachyon::d3d12::D3D12GraphicsContext::Impl::debugLayer = false

the debug layer is on: its messages go to debug

◆ imageSlots

uint32_t tachyon::d3d12::D3D12GraphicsContext::Impl::imageSlots = 4096

asked for with SetImageSlotCount

◆ factory

ComPtr<IDXGIFactory6> tachyon::d3d12::D3D12GraphicsContext::Impl::factory

◆ adapter

ComPtr<IDXGIAdapter1> tachyon::d3d12::D3D12GraphicsContext::Impl::adapter

◆ device

ComPtr<ID3D12Device> tachyon::d3d12::D3D12GraphicsContext::Impl::device

◆ queue

ComPtr<ID3D12CommandQueue> tachyon::d3d12::D3D12GraphicsContext::Impl::queue

◆ allocator

ComPtr<D3D12MA::Allocator> tachyon::d3d12::D3D12GraphicsContext::Impl::allocator

GPU memory: buffers and textures in its heaps.

◆ infoQueue

ComPtr<ID3D12InfoQueue1> tachyon::d3d12::D3D12GraphicsContext::Impl::infoQueue

◆ messageCallback

DWORD tachyon::d3d12::D3D12GraphicsContext::Impl::messageCallback = 0

◆ submitFence

ComPtr<ID3D12Fence> tachyon::d3d12::D3D12GraphicsContext::Impl::submitFence

Every submit signals the next value: submitted is the last one signalled.

◆ submitted

std::atomic<UINT64> tachyon::d3d12::D3D12GraphicsContext::Impl::submitted = 0

Atomic: DestroyImageAtEnd, on any thread, reads it.

◆ removed

std::atomic<bool> tachyon::d3d12::D3D12GraphicsContext::Impl::removed = false

The device was removed (a Present, a resize or the debug layer said so): told once, with the reason, and the GUI is told through DeviceLost.

◆ waitEvent

HANDLE tachyon::d3d12::D3D12GraphicsContext::Impl::waitEvent = nullptr

◆ frameWaits

std::vector<std::pair<ComPtr<ID3D12Fence>, UINT64> > tachyon::d3d12::D3D12GraphicsContext::Impl::frameWaits

What the next submit waits for on the queue (AddFrameWait), a fence once each.

◆ garbageMutex

std::mutex tachyon::d3d12::D3D12GraphicsContext::Impl::garbageMutex

images are let go on any thread

◆ garbage

std::vector<Garbage> tachyon::d3d12::D3D12GraphicsContext::Impl::garbage

◆ uploadMutex

std::mutex tachyon::d3d12::D3D12GraphicsContext::Impl::uploadMutex

images are made on any thread

◆ imageUploads

std::vector<ImageUpload> tachyon::d3d12::D3D12GraphicsContext::Impl::imageUploads

◆ uploadScratch

struct tachyon::d3d12::D3D12GraphicsContext::Impl::UploadScratch tachyon::d3d12::D3D12GraphicsContext::Impl::uploadScratch

◆ residents

std::unordered_map<RHI::ResidentBufferId, Resident> tachyon::d3d12::D3D12GraphicsContext::Impl::residents

◆ pendingResidents

std::vector<RHI::ResidentBufferId> tachyon::d3d12::D3D12GraphicsContext::Impl::pendingResidents

Made and not copied yet, oldest first; one let go of meanwhile is no longer in residents and is passed over.

Ids are never handed out twice.

◆ nextResident

RHI::ResidentBufferId tachyon::d3d12::D3D12GraphicsContext::Impl::nextResident = 1

◆ liveImages

std::unordered_set<D3D12Image*> tachyon::d3d12::D3D12GraphicsContext::Impl::liveImages

Every image made and not let go for a frame (DeviceScope::Frame): those handed over for the application's lifetime too.

Cleanup frees what's left.

◆ imageSet

D3D12ImageSet tachyon::d3d12::D3D12GraphicsContext::Impl::imageSet

◆ boxStyles

RHI::ResidentBufferId tachyon::d3d12::D3D12GraphicsContext::Impl::boxStyles = 0

The box styles in GPU memory (a resident buffer), made again when they change; 0: none.

◆ colorStyles

RHI::ResidentBufferId tachyon::d3d12::D3D12GraphicsContext::Impl::colorStyles = 0

The color styles, with their gradient pages' slots, likewise.

◆ gradientPages

std::vector<ImageIndex> tachyon::d3d12::D3D12GraphicsContext::Impl::gradientPages

each gradient page's index in the image set

◆ lastStyles

StyleManager* tachyon::d3d12::D3D12GraphicsContext::Impl::lastStyles = nullptr

PrepareFrame's, for a live resize's redraw.

◆ lastGradients

GradientManager* tachyon::d3d12::D3D12GraphicsContext::Impl::lastGradients = nullptr

◆ lastTime

float tachyon::d3d12::D3D12GraphicsContext::Impl::lastTime = 0.0f

◆ rootSignature

ComPtr<ID3D12RootSignature> tachyon::d3d12::D3D12GraphicsContext::Impl::rootSignature

◆ pipelineStates

std::vector<ComPtr<ID3D12PipelineState> > tachyon::d3d12::D3D12GraphicsContext::Impl::pipelineStates

◆ pipelines

std::array<RHI::GpuPipeline, kPrimitiveKindCount> tachyon::d3d12::D3D12GraphicsContext::Impl::pipelines {}

◆ quadIndices

Buffer tachyon::d3d12::D3D12GraphicsContext::Impl::quadIndices

p * 4 + { 0, 1, 3, 0, 3, 2 } for each quad p, in GPU memory.

◆ quadCapacity

uint32_t tachyon::d3d12::D3D12GraphicsContext::Impl::quadCapacity = 0

◆ pushConstants

GPUDrawPushConstants tachyon::d3d12::D3D12GraphicsContext::Impl::pushConstants {}

the styles' addresses and the time, from PrepareFrame

◆ kSceneColorFormat

DXGI_FORMAT tachyon::d3d12::D3D12GraphicsContext::Impl::kSceneColorFormat = DXGI_FORMAT_R8G8B8A8_UNORM
staticconstexpr

◆ kSceneKeepFrames

uint64_t tachyon::d3d12::D3D12GraphicsContext::Impl::kSceneKeepFrames = 4
staticconstexpr

a scene not asked for this long goes

◆ scenes

std::unordered_map<ID, Scene> tachyon::d3d12::D3D12GraphicsContext::Impl::scenes

◆ externalImages

std::unordered_map<uint32_t, std::unique_ptr<D3D12Image> > tachyon::d3d12::D3D12GraphicsContext::Impl::externalImages

By image index: what the image set points at for a host's texture.

◆ imageTargets

std::unordered_map<ID, ID3D12Resource*> tachyon::d3d12::D3D12GraphicsContext::Impl::imageTargets

The texture a render-to-image window is copied into, by window.

◆ sceneRequests

std::vector<SceneRequest> tachyon::d3d12::D3D12GraphicsContext::Impl::sceneRequests

◆ sceneFrame

uint64_t tachyon::d3d12::D3D12GraphicsContext::Impl::sceneFrame = 0

The documentation for this struct was generated from the following file: