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
23// GFX_GetVulkanAddonHandles is part of the addon-facing surface (see above), so
24// it has to land in Polyphase.lib / PolyphaseEditor.lib. Nothing else under
25// Graphics/ is exported, and without the annotation every addon that calls it
26// gets LNK2019.
27#include "PolyphaseAPI.h"
28
30{
31 VkDevice mDevice = VK_NULL_HANDLE;
32 VkPhysicalDevice mPhysicalDevice = VK_NULL_HANDLE;
33 VkCommandBuffer mCurrentCommandBuffer = VK_NULL_HANDLE;
34 VkRenderPass mCurrentRenderPass = VK_NULL_HANDLE; // the one the engine is mid-pass on
35
36 // Scene viewport rectangle the engine just set with GFX_SetViewport.
37 // (x, y) is the offset within the swapchain image; (w, h) is the size.
38 // Addons MUST re-apply this with vkCmdSetViewport if they bind their own
39 // pipeline with VK_DYNAMIC_STATE_VIEWPORT; setting (0,0,w,h) would write
40 // into the wrong sub-region during editor-viewport / game-preview renders.
41 uint32_t mSceneViewportX = 0;
42 uint32_t mSceneViewportY = 0;
43 uint32_t mSceneViewportWidth = 0;
45
46 // Legacy aliases — same as mSceneViewport{Width,Height}, kept so older
47 // code that consumed these still works.
48 uint32_t mViewportWidth = 0;
49 uint32_t mViewportHeight = 0;
50
51 uint32_t mCurrentFrameIndex = 0;
52 uint32_t mMaxFramesInFlight = 0;
53 VkQueue mGraphicsQueue = VK_NULL_HANDLE;
54};
55
56// Returns true if the running backend is Vulkan and the values were filled.
57// Returns false on GX / C3D backends. Safe to call from any addon; on non-
58// Vulkan builds the addon should fall back to GFX_DrawSplats or a proxy mesh.
59//
60// Must be called from inside a custom render pass callback (registered via
61// Renderer::RegisterCustomRenderPass) — otherwise the command buffer and
62// render pass fields will be VK_NULL_HANDLE.
POLYPHASE_API bool GFX_GetVulkanAddonHandles(GfxVulkanAddonHandles &out)
Export macros for Polyphase Engine symbols.
#define POLYPHASE_API
Definition PolyphaseAPI.h:31
Definition GraphicsVulkanAddon.h:30
VkRenderPass mCurrentRenderPass
Definition GraphicsVulkanAddon.h:34
uint32_t mViewportWidth
Definition GraphicsVulkanAddon.h:48
uint32_t mSceneViewportY
Definition GraphicsVulkanAddon.h:42
VkPhysicalDevice mPhysicalDevice
Definition GraphicsVulkanAddon.h:32
VkQueue mGraphicsQueue
Definition GraphicsVulkanAddon.h:53
uint32_t mSceneViewportX
Definition GraphicsVulkanAddon.h:41
uint32_t mSceneViewportHeight
Definition GraphicsVulkanAddon.h:44
VkDevice mDevice
Definition GraphicsVulkanAddon.h:31
VkCommandBuffer mCurrentCommandBuffer
Definition GraphicsVulkanAddon.h:33
uint32_t mMaxFramesInFlight
Definition GraphicsVulkanAddon.h:52
uint32_t mViewportHeight
Definition GraphicsVulkanAddon.h:49
uint32_t mSceneViewportWidth
Definition GraphicsVulkanAddon.h:43
uint32_t mCurrentFrameIndex
Definition GraphicsVulkanAddon.h:51