Toast Engine
Loading...
Searching...
No Matches
renderer::VulkanRenderer Class Reference
Collaboration diagram for renderer::VulkanRenderer:

Classes

struct  FrameContext
struct  InstanceData
 Mirrors mesh.slang depth_prepass.slang and shadow_depth.slang InstanceData. More...
struct  DirectionalLightData
struct  ReflectionProbeData
struct  IrradianceVolumeData
struct  FrameUBO
struct  GpuLight
 Mirrors GpuLight in lighting.slang and cluster_lighting.slang. More...
struct  ShadowView
struct  ShadowFrame
struct  MeshInstanceProxy
struct  VoxelVolumeProxy
struct  UIWorldPanelProxy
struct  SizeHandleDraw
struct  TransformGizmoDraw
struct  GizmoState
struct  ImGuiKeyEvent
struct  ImGuiInputSnapshot
struct  LightStats
struct  RenderFrame
struct  PassInfo
struct  PerfCounters
struct  UploadStats

Public Types

using PostProcessSettings = renderer::PostProcessSettings
using UIFrameBuilder = std::function<void(RenderFrame&)>

Public Member Functions

void setUIFrameBuilder (UIFrameBuilder builder)
 VulkanRenderer (const VulkanCore &core, std::unique_ptr< IOutputTarget > output_target) noexcept
 VulkanRenderer (const VulkanRenderer &)=delete
auto operator= (const VulkanRenderer &) -> VulkanRenderer &=delete
 VulkanRenderer (VulkanRenderer &&)=delete
auto operator= (VulkanRenderer &&) -> VulkanRenderer &=delete
void start () noexcept
auto getCurrentFrameBuild () noexcept -> RenderFrame &
void submitFrame () noexcept
void queueDebugLine (glm::vec3 a, glm::vec3 b, glm::vec4 color)
 For the next frame when called before frame construction begins.
void tick (float time) noexcept
void registerMeshNodeProxy (toast::MeshNode *node)
void registerDebugDraw (toast::Node3D *node, void(*draw)(toast::Node3D &))
void unregisterDebugDraw (toast::Node3D *node)
void unregisterMeshNodeProxy (toast::MeshNode *node)
void registerVoxelNodeProxy (toast::VoxelNode *node)
void unregisterVoxelNodeProxy (toast::VoxelNode *node)
void registerLightNodeProxy (toast::Light *node)
void unregisterLightNodeProxy (toast::Light *node)
void registerCameraNodeProxy (toast::Camera *node)
void unregisterCameraNodeProxy (toast::Camera *node)
void registerReflectionProbeProxy (toast::ReflectionProbe *node)
void unregisterReflectionProbeProxy (toast::ReflectionProbe *node)
void registerIrradianceVolumeProxy (toast::IrradianceVolume *node)
void registerPostProcessVolumeProxy (toast::PostProcessVolume *node)
void unregisterPostProcessVolumeProxy (toast::PostProcessVolume *node)
void unregisterIrradianceVolumeProxy (toast::IrradianceVolume *node)
void setFrameRateLimit (double max_fps) noexcept
 0 or negative is uncapped
auto frameRateLimit () const noexcept -> double
void setClampToSimulation (bool clamp) noexcept
 False repeats the last frame instead of waiting for a new one.
auto clampToSimulation () const noexcept -> bool
void setDebugWindowsVisible (bool visible) noexcept
auto debugWindowsVisible () const noexcept -> bool
void setApplicationFocused (bool focused) noexcept
auto applicationFocused () const noexcept -> bool
auto effectiveFrameRateLimit () const noexcept -> double
void setRenderingPaused (bool paused) noexcept
auto renderingPaused () const noexcept -> bool
void stop ()
void addRenderPass (std::unique_ptr< IRenderPass > pass)
void addComputePass (std::unique_ptr< IComputePass > pass)
void addPostProcessPass (std::unique_ptr< IPostProcessPass > pass)
 Runs in registration order.
auto setPostProcessPassEnabled (std::string_view name, bool enabled) -> bool
auto isPostProcessPassEnabled (std::string_view name) const -> bool
auto getSceneColorFormat () const noexcept -> vk::Format
auto getSceneColorView () const noexcept -> vk::ImageView
auto getSceneNormalView () const noexcept -> vk::ImageView
 xyz world normal w roughness
auto getSceneIndirectView () const noexcept -> vk::ImageView
auto getSceneMotionView () const noexcept -> vk::ImageView
auto getVoxelAlbedoView () const noexcept -> vk::ImageView
auto getVoxelMaterialView () const noexcept -> vk::ImageView
auto getVoxelFaceNormalView () const noexcept -> vk::ImageView
 Holds flat face normals not the rounded scene normal ones.
void setVoxelCellBoxes (bool enabled) noexcept
 Edge rounding radius in voxels where 0 keeps the flat face normals.
void setVoxelOcclusion (bool enabled) noexcept
void setVoxelMeshShaders (bool enabled) noexcept
auto voxelMeshShaders () const noexcept -> bool
auto voxelOcclusion () const noexcept -> bool
void setVoxelRasterPixels (float pixels) noexcept
 Smallest on screen voxel size in pixels that is rasterized instead of marched and 0 marches everything.
auto voxelRasterPixels () const noexcept -> float
auto voxelCellBoxes () const noexcept -> bool
void setVoxelNormalRounding (float voxels) noexcept
auto voxelNormalRounding () const noexcept -> float
auto getDepthView () const noexcept -> vk::ImageView
 Left in eDepthReadOnlyOptimal.
auto listPasses () -> std::vector< PassInfo >
void setPassEnabled (std::string_view name, bool enabled)
auto getDefaultTextureView () const noexcept -> vk::ImageView
auto getFailsafeTextureView (bool has_reference, const VulkanTexture *texture) const noexcept -> vk::ImageView
auto getFailsafeSampler () const noexcept -> vk::Sampler
auto getDefaultBlackTextureView () const noexcept -> vk::ImageView
auto getDefaultNormalTextureView () const noexcept -> vk::ImageView
auto getDefaultSampler () const noexcept -> vk::Sampler
auto getDefaultShadowMapView () const noexcept -> vk::ImageView
auto getDefaultShadowSampler () const noexcept -> vk::Sampler
auto getDefaultCubeView () const noexcept -> vk::ImageView
void applyResize (vk::Extent2D extent)
void queueResourceUpload (std::unique_ptr< PendingResourceUpload > upload)
auto getFrameUBORes (uint32_t current_frame) const -> const FrameResources *
auto getInstanceBuffer (uint32_t frame_index) const -> vk::Buffer
auto getShadowInstanceBuffer (uint32_t frame_index) const -> vk::Buffer
auto getJointMatrixBuffer (uint32_t frame_index) const -> vk::Buffer
auto getDescriptorPoolHandle () const noexcept -> vk::DescriptorPool
void setClusterLightingPass (const ClusterLightingPass *pass) noexcept
auto getClusterLightingPass () const noexcept -> const ClusterLightingPass *
void setShadowPass (const ShadowPass *pass) noexcept
auto getShadowPass () const noexcept -> const ShadowPass *
void setEnvironmentPass (EnvironmentPass *pass) noexcept
auto getEnvironmentPass () const noexcept -> const EnvironmentPass *
void setVoxelPass (VoxelPass *pass) noexcept
 Still registered with addRenderPass so it lists and toggles like any pass.
void setDebrisPass (DebrisPass *pass) noexcept
auto voxelCollisionWorld () const -> std::shared_ptr< const VoxelCollisionWorld >
void setReflectionProbePass (ReflectionProbePass *pass) noexcept
auto getReflectionProbePass () const noexcept -> ReflectionProbePass *
void requestReflectionProbeBake () noexcept
void requestIrradianceBake () noexcept
auto getIrradianceProbeCount () const noexcept -> uint32_t
auto getStaleIrradianceVolumeCount () const noexcept -> uint32_t
auto getOutOfOrderFrameCount () const noexcept -> uint32_t
void getFrameTimeStats (float &avg_ms, float &min_ms, float &max_ms) const noexcept
auto getSkippedBuildCount () const noexcept -> uint32_t
auto getDroppedFrameCount () const noexcept -> uint32_t
auto getVisibleInstanceCount () const noexcept -> uint32_t
void setCullDebugDraw (bool enabled) noexcept
auto getCullDebugDraw () const noexcept -> bool
void setCullFreeze (bool frozen) noexcept
auto getCullFreeze () const noexcept -> bool
auto getStaleReflectionProbeCount () const noexcept -> uint32_t
void requestMaterialFrameSetRebuild ()
auto getEnvironmentPassMutable () const noexcept -> EnvironmentPass *
auto getRayTracingScene () const noexcept -> RayTracingScene *
auto getPrepassDrawnCount () const noexcept -> uint32_t
auto getSkinningPass () const noexcept -> SkinningPass *
auto getPosedVertexBuffer (uint32_t frame_index) const -> vk::Buffer
auto getSkinnedBlasPool () const noexcept -> SkinnedBlasPool *
auto materialUsesCutout (assets::Material *material) const -> bool
auto getReflectionProbePassMutable () const noexcept -> ReflectionProbePass *
void setActiveCamera (toast::Camera *camera)
void forgetCamera (const toast::Camera *camera)
auto getCore () -> const VulkanCore &
auto getActiveCamera () -> toast::Camera *
void setGizmoState (const GizmoState &state) noexcept
void setDebugDrawEnabled (bool enabled) noexcept
auto debugDrawEnabled () const noexcept -> bool
auto perfCounters () const noexcept -> PerfCounters
auto uploadStats () -> UploadStats
auto uploadTimeline () const noexcept -> vk::Semaphore
 Signalled by every transfer submit so a submit needing an upload waits on its value.
auto uploadTimelineValue () const noexcept -> uint64_t
 Render thread only.
void retire (std::shared_ptr< void > object)
 Render thread and frees object once the frame being recorded finished on the GPU.
auto gpuTimer () const noexcept -> const GpuTimer *
void setTracedShadowsEnabled (bool enabled) noexcept
auto tracedShadowsEnabled () const noexcept -> bool
void setTaaEnabled (bool enabled) noexcept
auto taaEnabled () const noexcept -> bool
void setTaaHistoryWeight (float weight) noexcept
auto taaHistoryWeight () const noexcept -> float
void setPostProcessSettings (const PostProcessSettings &settings) noexcept
auto getPostProcessSettings () const noexcept -> const PostProcessSettings &
void requestPostProcessSettings (const PostProcessSettings &settings)
 Safe from any thread.
void setRenderOwnerFilter (const toast::INodeOwner *owner)
 nullptr renders every owner. Main thread only
void setVoxelHighlight (const toast::VoxelNode *node, const voxel::Volume *highlight)
void setSecondaryOwner (const toast::INodeOwner *owner, const glm::mat4 &transform, const toast::Node *hidden)
auto renderingFrame () const -> const RenderFrame *
auto getRenderDocAPI () const noexcept -> const RENDERDOC_API_1_6_0 *
auto getOutputTarget () const noexcept -> const IOutputTarget &

Static Public Member Functions

static auto selectDepthFormat (const VulkanCore &core) -> vk::Format

Static Public Attributes

static constexpr uint32_t k_frames_in_flight = 3
static constexpr uint8_t k_render_frames = 3
static constexpr uint32_t k_max_directional_lights = 4
static constexpr uint32_t k_max_joint_matrices = 4096
static constexpr uint32_t k_max_instances = 16384
static constexpr uint32_t k_instance_no_motion = 1u << 0
static constexpr uint32_t k_max_reflection_probes = 8
static constexpr uint32_t k_max_irradiance_volumes = 4
static constexpr uint32_t k_max_irradiance_probes = 4096
static constexpr uint32_t k_irradiance_capture_size = 64
static constexpr size_t k_max_size_handles = 6
static constexpr double k_background_frame_rate_limit = 30.0
static VulkanRenderer * instance = nullptr

Member Function Documentation

◆ getEnvironmentPassMutable()

auto renderer::VulkanRenderer::getEnvironmentPassMutable ( ) const -> EnvironmentPass *
inlinenodiscardnoexcept
Warning
Render thread only

◆ gpuTimer()

auto renderer::VulkanRenderer::gpuTimer ( ) const -> const GpuTimer *
inlinenodiscardnoexcept
Note
Render thread only

◆ setVoxelHighlight()

void renderer::VulkanRenderer::setVoxelHighlight ( const toast::VoxelNode * node,
const voxel::Volume * highlight )
inline

Tints the voxels of node that are solid in highlight

Note
nullptr clears it

◆ uploadStats()

auto renderer::VulkanRenderer::uploadStats ( ) -> UploadStats
nodiscard
Note
Render thread only
Here is the caller graph for this function:

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