Bicameral Engine
GPU-resident engine for a magic-research open-world game
Loading...
Searching...
No Matches
bicameral::sim::GpuImplicit Class Reference

#include <gpu_implicit.h>

Collaboration diagram for bicameral::sim::GpuImplicit:
[legend]

Classes

struct  Constants
struct  CopyRegion

Public Member Functions

bool RecordUpload (ID3D12GraphicsCommandList *list, const ImplicitGrid &grid)
void RecordReset (ID3D12GraphicsCommandList *list)
void RecordCopySystem (ID3D12GraphicsCommandList *list, ID3D12Resource *source, uint64_t cellsOffset, uint64_t facesOffset, uint64_t listsOffset, ID3D12Resource *header, uint64_t faceCountOffset)
void RecordCopyLevels (ID3D12GraphicsCommandList *list, ID3D12Resource *header, ID3D12Resource *nodes, ID3D12Resource *links, ID3D12Resource *children)
bool RecordStep (ID3D12GraphicsCommandList *list, uint64_t debugRing, const ImplicitOptions &options, uint32_t maxLimitRounds=DEFAULT_MAX_LIMIT_ROUNDS, const GpuImplicitRecordShape &shape={})
void RecordRelease (ID3D12GraphicsCommandList *list)
ID3D12Resource * CellsBuffer () const
void RecordTimestamp (ID3D12GraphicsCommandList *list, uint32_t index)
void RecordReadback (ID3D12GraphicsCommandList *list)
void RecordCostReadback (ID3D12GraphicsCommandList *list)
bool Read (ImplicitGrid &grid, GpuImplicitCost &cost) const
bool ReadCost (GpuImplicitCost &cost) const
std::vector< uint64_t > ReadTimestamps (uint32_t count) const
uint32_t DispatchesPerCycle (const ImplicitOptions &options) const
void UsePredication (bool use)

Static Public Member Functions

static std::expected< GpuImplicit, std::string > Create (ID3D12Device5 *device, const GpuImplicitLimits &limits, const GpuImplicitTuning &tuning={})
static std::expected< GpuImplicit, std::string > Create (ID3D12Device5 *device, const ImplicitGrid &grid, const GpuImplicitTuning &tuning={})
static GpuImplicitLimits LimitsOf (const ImplicitGrid &grid)
static GpuImplicitRecordShape ShapeFrom (const GpuImplicitCost &previous)

Static Public Attributes

static constexpr uint32_t MAX_TIMESTAMPS = 64
static constexpr uint32_t DEFAULT_MAX_LIMIT_ROUNDS = 16

Private Types

enum  Buffer : uint8_t {
  BufferCells , BufferFaces , BufferLists , BufferNodes ,
  BufferLinks , BufferWork , BufferState , BufferWide ,
  BufferPredicate , BufferPlan , BufferArgs , BufferCount
}
enum  Pass : uint8_t {
  PassBegin , PassStart , PassSmooth , PassRestrict ,
  PassProlong , PassConverged , PassCycleEnd , PassFlows ,
  PassMark , PassLimitEnd , PassLimitFaces , PassApply ,
  PassTail , PassPlanLevels , PassPlanArgs , PassCount
}

Private Member Functions

 GpuImplicit ()=default
std::expected< void, std::string > CreatePipelines (ID3D12Device5 *device)
std::expected< void, std::string > CreateBuffers (ID3D12Device5 *device)
uint64_t BufferBytes (Buffer buffer) const
void Dispatch (ID3D12GraphicsCommandList *list, Pass pass, uint32_t groups)
void DispatchIndirect (ID3D12GraphicsCommandList *list, Pass pass, uint32_t slot)
void RecordPlan (ID3D12GraphicsCommandList *list)
void RecordCopies (ID3D12GraphicsCommandList *list, std::span< const CopyRegion > regions)
void RecordSmooth (ID3D12GraphicsCommandList *list, uint32_t depth, uint32_t slot, uint32_t sweeps)
void RecordVCycle (ID3D12GraphicsCommandList *list, const ImplicitOptions &options)
void BeginSkippable (ID3D12GraphicsCommandList *list, uint32_t word)
void EndSkippable (ID3D12GraphicsCommandList *list)

Private Attributes

GpuImplicitLimits m_limits
GpuImplicitTuning m_tuning
Constants m_constants
uint32_t m_maxDispatchLevels = 1
bool m_predication = true
ComPtr< ID3D12RootSignature > m_rootSignature
ComPtr< ID3D12CommandSignature > m_dispatchSignature
std::array< ComPtr< ID3D12PipelineState >, PassCount > m_pipelines
std::array< ComPtr< ID3D12Resource >, BufferCount > m_buffers
std::array< ComPtr< ID3D12Resource >, BufferCount > m_uploads
ComPtr< ID3D12Resource > m_cellsReadback
ComPtr< ID3D12Resource > m_stateReadback
ComPtr< ID3D12Resource > m_wideReadback
ComPtr< ID3D12Resource > m_planReadback
ComPtr< ID3D12QueryHeap > m_timestamps
ComPtr< ID3D12Resource > m_timestampReadback
uint32_t m_timestampCount = 0

Detailed Description

Definition at line 82 of file gpu_implicit.h.

Member Enumeration Documentation

◆ Buffer

enum bicameral::sim::GpuImplicit::Buffer : uint8_t
private
Enumerator
BufferCells 
BufferFaces 
BufferLists 
BufferNodes 
BufferLinks 
BufferWork 
BufferState 
BufferWide 
BufferPredicate 
BufferPlan 
BufferArgs 
BufferCount 

Definition at line 149 of file gpu_implicit.h.

◆ Pass

enum bicameral::sim::GpuImplicit::Pass : uint8_t
private
Enumerator
PassBegin 
PassStart 
PassSmooth 
PassRestrict 
PassProlong 
PassConverged 
PassCycleEnd 
PassFlows 
PassMark 
PassLimitEnd 
PassLimitFaces 
PassApply 
PassTail 
PassPlanLevels 
PassPlanArgs 
PassCount 

Definition at line 164 of file gpu_implicit.h.

Constructor & Destructor Documentation

◆ GpuImplicit()

bicameral::sim::GpuImplicit::GpuImplicit ( )
privatedefault

Referenced by Create().

Here is the caller graph for this function:

Member Function Documentation

◆ BeginSkippable()

void bicameral::sim::GpuImplicit::BeginSkippable ( ID3D12GraphicsCommandList * list,
uint32_t word )
private

Definition at line 565 of file gpu_implicit.cpp.

References BufferPredicate, m_buffers, m_predication, and bicameral::gpu::Transition().

Referenced by RecordStep().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ BufferBytes()

uint64_t bicameral::sim::GpuImplicit::BufferBytes ( Buffer buffer) const
nodiscardprivate

Definition at line 243 of file gpu_implicit.cpp.

References BufferArgs, BufferCells, BufferFaces, BufferLinks, BufferLists, BufferNodes, BufferPlan, BufferPredicate, BufferState, BufferWide, BufferWork, m_limits, and m_maxDispatchLevels.

Referenced by CreateBuffers(), RecordCopies(), RecordCopyLevels(), and RecordCopySystem().

Here is the caller graph for this function:

◆ CellsBuffer()

ID3D12Resource * bicameral::sim::GpuImplicit::CellsBuffer ( ) const
inlinenodiscard

Definition at line 130 of file gpu_implicit.h.

References BufferCells, and m_buffers.

◆ Create() [1/2]

std::expected< GpuImplicit, std::string > bicameral::sim::GpuImplicit::Create ( ID3D12Device5 * device,
const GpuImplicitLimits & limits,
const GpuImplicitTuning & tuning = {} )
staticnodiscard

Definition at line 184 of file gpu_implicit.cpp.

References bicameral::sim::GpuImplicitLimits::cells, bicameral::sim::GpuImplicitTuning::coarsestTailMaxNodes, CreateBuffers(), CreatePipelines(), bicameral::sim::GpuImplicit::Constants::dispatchLevels, bicameral::sim::GpuImplicitTuning::dispatchLevels, bicameral::sim::GpuImplicitLimits::faces, GpuImplicit(), bicameral::sim::GpuImplicitLimits::levels, m_constants, m_limits, m_maxDispatchLevels, m_tuning, bicameral::sim::GpuImplicitLimits::nodes, bicameral::sim::GpuImplicitTuning::tailMaxLinks, and bicameral::sim::GpuImplicitTuning::tailMaxNodes.

Referenced by Create(), and bicameral::sim::GpuMultiresImplicit::Create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Create() [2/2]

std::expected< GpuImplicit, std::string > bicameral::sim::GpuImplicit::Create ( ID3D12Device5 * device,
const ImplicitGrid & grid,
const GpuImplicitTuning & tuning = {} )
staticnodiscard

Definition at line 211 of file gpu_implicit.cpp.

References bicameral::sim::ImplicitGrid::cells, Create(), bicameral::sim::ImplicitGrid::levels, and LimitsOf().

Here is the call graph for this function:

◆ CreateBuffers()

std::expected< void, std::string > bicameral::sim::GpuImplicit::CreateBuffers ( ID3D12Device5 * device)
private

Definition at line 289 of file gpu_implicit.cpp.

References BufferBytes(), BufferCells, BufferCount, BufferPlan, BufferState, BufferWide, bicameral::gpu::CreateBuffer(), m_buffers, m_cellsReadback, m_planReadback, m_stateReadback, m_timestampReadback, m_timestamps, m_uploads, m_wideReadback, MAX_TIMESTAMPS, bicameral::gpu::Readback, bicameral::gpu::UnorderedAccess, and bicameral::gpu::Upload.

Referenced by Create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ CreatePipelines()

std::expected< void, std::string > bicameral::sim::GpuImplicit::CreatePipelines ( ID3D12Device5 * device)
private

Definition at line 264 of file gpu_implicit.cpp.

References bicameral::gpu::CreateComputePipeline(), bicameral::gpu::CreateRootSignature(), bicameral::gpu::LoadShader(), m_dispatchSignature, m_pipelines, m_rootSignature, and PassCount.

Referenced by Create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Dispatch()

void bicameral::sim::GpuImplicit::Dispatch ( ID3D12GraphicsCommandList * list,
Pass pass,
uint32_t groups )
private

Definition at line 505 of file gpu_implicit.cpp.

References m_constants, m_pipelines, and bicameral::gpu::RootSignatureLayout::RootConstantIndex().

Referenced by RecordPlan(), and RecordStep().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DispatchesPerCycle()

◆ DispatchIndirect()

void bicameral::sim::GpuImplicit::DispatchIndirect ( ID3D12GraphicsCommandList * list,
Pass pass,
uint32_t slot )
private

Definition at line 513 of file gpu_implicit.cpp.

References BufferArgs, m_buffers, m_constants, m_dispatchSignature, m_pipelines, and bicameral::gpu::RootSignatureLayout::RootConstantIndex().

Referenced by RecordSmooth(), RecordStep(), and RecordVCycle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ EndSkippable()

void bicameral::sim::GpuImplicit::EndSkippable ( ID3D12GraphicsCommandList * list)
private

Definition at line 576 of file gpu_implicit.cpp.

References BufferPredicate, m_buffers, m_predication, and bicameral::gpu::Transition().

Referenced by RecordStep().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ LimitsOf()

GpuImplicitLimits bicameral::sim::GpuImplicit::LimitsOf ( const ImplicitGrid & grid)
staticnodiscard

Definition at line 219 of file gpu_implicit.cpp.

References bicameral::sim::ImplicitGrid::cells, bicameral::sim::ImplicitGrid::faces, bicameral::sim::ImplicitGrid::levels, bicameral::sim::ImplicitGridLevel::levels, bicameral::sim::GpuImplicitLimits::links, bicameral::sim::ImplicitGridLevel::neighbors, and bicameral::sim::GpuImplicitLimits::nodes.

Referenced by Create(), and RecordUpload().

Here is the caller graph for this function:

◆ Read()

bool bicameral::sim::GpuImplicit::Read ( ImplicitGrid & grid,
GpuImplicitCost & cost ) const
nodiscard

Definition at line 697 of file gpu_implicit.cpp.

References bicameral::sim::ImplicitGrid::cells, m_cellsReadback, m_limits, bicameral::gpu::ReadBuffer(), and ReadCost().

Here is the call graph for this function:

◆ ReadCost()

bool bicameral::sim::GpuImplicit::ReadCost ( GpuImplicitCost & cost) const
nodiscard

Definition at line 713 of file gpu_implicit.cpp.

References m_planReadback, m_stateReadback, m_wideReadback, and bicameral::gpu::ReadBuffer().

Referenced by Read().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ReadTimestamps()

std::vector< uint64_t > bicameral::sim::GpuImplicit::ReadTimestamps ( uint32_t count) const
nodiscard

Definition at line 734 of file gpu_implicit.cpp.

References m_timestampCount, m_timestampReadback, and bicameral::gpu::ReadBuffer().

Here is the call graph for this function:

◆ RecordCopies()

void bicameral::sim::GpuImplicit::RecordCopies ( ID3D12GraphicsCommandList * list,
std::span< const CopyRegion > regions )
private

Definition at line 455 of file gpu_implicit.cpp.

References BufferBytes(), m_buffers, and bicameral::gpu::Transition().

Referenced by RecordCopyLevels(), and RecordCopySystem().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RecordCopyLevels()

void bicameral::sim::GpuImplicit::RecordCopyLevels ( ID3D12GraphicsCommandList * list,
ID3D12Resource * header,
ID3D12Resource * nodes,
ID3D12Resource * links,
ID3D12Resource * children )

Definition at line 427 of file gpu_implicit.cpp.

References BufferBytes(), BufferLinks, BufferLists, BufferNodes, BufferPlan, m_limits, and RecordCopies().

Referenced by bicameral::sim::GpuImplicitLevels::RecordCopyTo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RecordCopySystem()

void bicameral::sim::GpuImplicit::RecordCopySystem ( ID3D12GraphicsCommandList * list,
ID3D12Resource * source,
uint64_t cellsOffset,
uint64_t facesOffset,
uint64_t listsOffset,
ID3D12Resource * header,
uint64_t faceCountOffset )

Definition at line 400 of file gpu_implicit.cpp.

References BufferBytes(), BufferCells, BufferFaces, BufferLists, BufferPlan, m_limits, and RecordCopies().

Referenced by bicameral::sim::GpuImplicitBuild::RecordCopyTo().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RecordCostReadback()

void bicameral::sim::GpuImplicit::RecordCostReadback ( ID3D12GraphicsCommandList * list)

Definition at line 680 of file gpu_implicit.cpp.

References BufferPlan, BufferState, BufferWide, m_buffers, m_planReadback, m_stateReadback, m_timestampCount, m_timestampReadback, m_timestamps, m_wideReadback, bicameral::gpu::RecordCopyToReadback(), and bicameral::gpu::Transition().

Referenced by RecordReadback().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RecordPlan()

void bicameral::sim::GpuImplicit::RecordPlan ( ID3D12GraphicsCommandList * list)
private

Definition at line 522 of file gpu_implicit.cpp.

References BufferArgs, Dispatch(), m_buffers, m_constants, PassPlanArgs, PassPlanLevels, and bicameral::gpu::Transition().

Referenced by RecordStep().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RecordReadback()

void bicameral::sim::GpuImplicit::RecordReadback ( ID3D12GraphicsCommandList * list)

Definition at line 675 of file gpu_implicit.cpp.

References BufferCells, m_buffers, m_cellsReadback, bicameral::gpu::RecordCopyToReadback(), and RecordCostReadback().

Here is the call graph for this function:

◆ RecordRelease()

void bicameral::sim::GpuImplicit::RecordRelease ( ID3D12GraphicsCommandList * list)

Definition at line 665 of file gpu_implicit.cpp.

References BufferCount, m_buffers, and bicameral::gpu::Transition().

Here is the call graph for this function:

◆ RecordReset()

void bicameral::sim::GpuImplicit::RecordReset ( ID3D12GraphicsCommandList * list)

Definition at line 390 of file gpu_implicit.cpp.

References BufferCount, m_buffers, and bicameral::gpu::Transition().

Here is the call graph for this function:

◆ RecordSmooth()

void bicameral::sim::GpuImplicit::RecordSmooth ( ID3D12GraphicsCommandList * list,
uint32_t depth,
uint32_t slot,
uint32_t sweeps )
private

Definition at line 531 of file gpu_implicit.cpp.

References DispatchIndirect(), m_constants, and PassSmooth.

Referenced by RecordVCycle().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ RecordStep()

◆ RecordTimestamp()

void bicameral::sim::GpuImplicit::RecordTimestamp ( ID3D12GraphicsCommandList * list,
uint32_t index )

Definition at line 657 of file gpu_implicit.cpp.

References m_timestampCount, m_timestamps, and MAX_TIMESTAMPS.

◆ RecordUpload()

◆ RecordVCycle()

void bicameral::sim::GpuImplicit::RecordVCycle ( ID3D12GraphicsCommandList * list,
const ImplicitOptions & options )
private

Definition at line 543 of file gpu_implicit.cpp.

References bicameral::sim::ImplicitOptions::coarsestSweeps, DispatchIndirect(), m_constants, PassProlong, PassRestrict, PassTail, bicameral::sim::ImplicitOptions::postSmooth, bicameral::sim::ImplicitOptions::preSmooth, and RecordSmooth().

Referenced by RecordStep().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ShapeFrom()

GpuImplicitRecordShape bicameral::sim::GpuImplicit::ShapeFrom ( const GpuImplicitCost & previous)
staticnodiscard

Definition at line 235 of file gpu_implicit.cpp.

References bicameral::sim::GpuImplicitCost::levelCount, and bicameral::sim::GpuImplicitCost::wantedTailDepth.

Referenced by bicameral::sim::GpuMultiresImplicit::Record().

Here is the caller graph for this function:

◆ UsePredication()

void bicameral::sim::GpuImplicit::UsePredication ( bool use)
inline

Definition at line 146 of file gpu_implicit.h.

References m_predication.

Member Data Documentation

◆ DEFAULT_MAX_LIMIT_ROUNDS

uint32_t bicameral::sim::GpuImplicit::DEFAULT_MAX_LIMIT_ROUNDS = 16
staticconstexpr

Definition at line 85 of file gpu_implicit.h.

Referenced by bicameral::sim::GpuMultiresImplicit::Record().

◆ m_buffers

std::array<ComPtr<ID3D12Resource>, BufferCount> bicameral::sim::GpuImplicit::m_buffers
private

◆ m_cellsReadback

ComPtr<ID3D12Resource> bicameral::sim::GpuImplicit::m_cellsReadback
private

Definition at line 239 of file gpu_implicit.h.

Referenced by CreateBuffers(), Read(), and RecordReadback().

◆ m_constants

Constants bicameral::sim::GpuImplicit::m_constants
private

◆ m_dispatchSignature

ComPtr<ID3D12CommandSignature> bicameral::sim::GpuImplicit::m_dispatchSignature
private

Definition at line 235 of file gpu_implicit.h.

Referenced by CreatePipelines(), and DispatchIndirect().

◆ m_limits

GpuImplicitLimits bicameral::sim::GpuImplicit::m_limits
private

◆ m_maxDispatchLevels

uint32_t bicameral::sim::GpuImplicit::m_maxDispatchLevels = 1
private

Definition at line 230 of file gpu_implicit.h.

Referenced by BufferBytes(), Create(), and RecordStep().

◆ m_pipelines

std::array<ComPtr<ID3D12PipelineState>, PassCount> bicameral::sim::GpuImplicit::m_pipelines
private

Definition at line 236 of file gpu_implicit.h.

Referenced by CreatePipelines(), Dispatch(), and DispatchIndirect().

◆ m_planReadback

ComPtr<ID3D12Resource> bicameral::sim::GpuImplicit::m_planReadback
private

Definition at line 242 of file gpu_implicit.h.

Referenced by CreateBuffers(), ReadCost(), and RecordCostReadback().

◆ m_predication

bool bicameral::sim::GpuImplicit::m_predication = true
private

Definition at line 231 of file gpu_implicit.h.

Referenced by BeginSkippable(), EndSkippable(), and UsePredication().

◆ m_rootSignature

ComPtr<ID3D12RootSignature> bicameral::sim::GpuImplicit::m_rootSignature
private

Definition at line 234 of file gpu_implicit.h.

Referenced by CreatePipelines(), and RecordStep().

◆ m_stateReadback

ComPtr<ID3D12Resource> bicameral::sim::GpuImplicit::m_stateReadback
private

Definition at line 240 of file gpu_implicit.h.

Referenced by CreateBuffers(), ReadCost(), and RecordCostReadback().

◆ m_timestampCount

uint32_t bicameral::sim::GpuImplicit::m_timestampCount = 0
private

Definition at line 245 of file gpu_implicit.h.

Referenced by ReadTimestamps(), RecordCostReadback(), and RecordTimestamp().

◆ m_timestampReadback

ComPtr<ID3D12Resource> bicameral::sim::GpuImplicit::m_timestampReadback
private

Definition at line 244 of file gpu_implicit.h.

Referenced by CreateBuffers(), ReadTimestamps(), and RecordCostReadback().

◆ m_timestamps

ComPtr<ID3D12QueryHeap> bicameral::sim::GpuImplicit::m_timestamps
private

Definition at line 243 of file gpu_implicit.h.

Referenced by CreateBuffers(), RecordCostReadback(), and RecordTimestamp().

◆ m_tuning

GpuImplicitTuning bicameral::sim::GpuImplicit::m_tuning
private

Definition at line 228 of file gpu_implicit.h.

Referenced by Create().

◆ m_uploads

std::array<ComPtr<ID3D12Resource>, BufferCount> bicameral::sim::GpuImplicit::m_uploads
private

Definition at line 238 of file gpu_implicit.h.

Referenced by CreateBuffers(), and RecordUpload().

◆ m_wideReadback

ComPtr<ID3D12Resource> bicameral::sim::GpuImplicit::m_wideReadback
private

Definition at line 241 of file gpu_implicit.h.

Referenced by CreateBuffers(), ReadCost(), and RecordCostReadback().

◆ MAX_TIMESTAMPS

uint32_t bicameral::sim::GpuImplicit::MAX_TIMESTAMPS = 64
staticconstexpr

Definition at line 84 of file gpu_implicit.h.

Referenced by CreateBuffers(), and RecordTimestamp().


The documentation for this class was generated from the following files: