Polyphase Game Engine
Loading...
Searching...
No Matches
GraphicsVulkanAddon.h
Go to the documentation of this file.
1#pragma once
2
3// Vulkan handles exposed to native addons that want to run their own Vulkan
4// rendering inside an engine custom render pass. The engine's general GFX_*
5// API only covers a fixed set of draw shapes (meshes, lines, splats); addons
6// that need to bind their own pipelines (e.g. the Gaussian Splatting addon's
7// proper anisotropic-falloff path) need a deeper handle on the Vulkan device,
8// the currently-recording command buffer, and the active render pass.
9//
10// This header is Vulkan-only — it's included on Vulkan-backend builds in the
11// engine and only from addons that link against Polyphase.lib on those
12// platforms. GX / C3D backends do not provide an equivalent.
13//
14// Lifetime: every handle returned is owned by the engine. Addons must not
15// destroy any of them. The VkCommandBuffer and VkRenderPass are valid only
16// for the duration of the custom render pass callback that's currently
17// running — capture them, use them, do not store them across frames.
18
19#include <vulkan/vulkan.h>
20
21#include <cstdint>
22
24{
25 VkDevice mDevice = VK_NULL_HANDLE;
26 VkPhysicalDevice mPhysicalDevice = VK_NULL_HANDLE;
27 VkCommandBuffer mCurrentCommandBuffer = VK_NULL_HANDLE;
28 VkRenderPass mCurrentRenderPass = VK_NULL_HANDLE; // the one the engine is mid-pass on
29
30 // Scene viewport rectangle the engine just set with GFX_SetViewport.
31 // (x, y) is the offset within the swapchain image; (w, h) is the size.
32 // Addons MUST re-apply this with vkCmdSetViewport if they bind their own
33 // pipeline with VK_DYNAMIC_STATE_VIEWPORT; setting (0,0,w,h) would write
34 // into the wrong sub-region during editor-viewport / game-preview renders.
35 uint32_t mSceneViewportX = 0;
36 uint32_t mSceneViewportY = 0;
37 uint32_t mSceneViewportWidth = 0;
39
40 // Legacy aliases — same as mSceneViewport{Width,Height}, kept so older
41 // code that consumed these still works.
42 uint32_t mViewportWidth = 0;
43 uint32_t mViewportHeight = 0;
44
45 uint32_t mCurrentFrameIndex = 0;
46 uint32_t mMaxFramesInFlight = 0;
47 VkQueue mGraphicsQueue = VK_NULL_HANDLE;
48};
49
50// Returns true if the running backend is Vulkan and the values were filled.
51// Returns false on GX / C3D backends. Safe to call from any addon; on non-
52// Vulkan builds the addon should fall back to GFX_DrawSplats or a proxy mesh.
53//
54// Must be called from inside a custom render pass callback (registered via
55// Renderer::RegisterCustomRenderPass) — otherwise the command buffer and
56// render pass fields will be VK_NULL_HANDLE.
bool GFX_GetVulkanAddonHandles(GfxVulkanAddonHandles &out)
Definition GraphicsVulkanAddon.h:24
VkRenderPass mCurrentRenderPass
Definition GraphicsVulkanAddon.h:28
uint32_t mViewportWidth
Definition GraphicsVulkanAddon.h:42
uint32_t mSceneViewportY
Definition GraphicsVulkanAddon.h:36
VkPhysicalDevice mPhysicalDevice
Definition GraphicsVulkanAddon.h:26
VkQueue mGraphicsQueue
Definition GraphicsVulkanAddon.h:47
uint32_t mSceneViewportX
Definition GraphicsVulkanAddon.h:35
uint32_t mSceneViewportHeight
Definition GraphicsVulkanAddon.h:38
VkDevice mDevice
Definition GraphicsVulkanAddon.h:25
VkCommandBuffer mCurrentCommandBuffer
Definition GraphicsVulkanAddon.h:27
uint32_t mMaxFramesInFlight
Definition GraphicsVulkanAddon.h:46
uint32_t mViewportHeight
Definition GraphicsVulkanAddon.h:43
uint32_t mSceneViewportWidth
Definition GraphicsVulkanAddon.h:37
uint32_t mCurrentFrameIndex
Definition GraphicsVulkanAddon.h:45