GlistEngine
Loading...
Searching...
No Matches
gVKDeferred.h
Go to the documentation of this file.
1/*
2 * gVKDeferred.h
3 *
4 * Internal Vulkan G-buffer resources used by gDeferredLight. The public renderer
5 * API stays backend-neutral; this module owns the Vulkan images, render pass and
6 * per-frame framebuffers behind that API.
7 */
8
9#pragma once
10
11#ifndef CORE_GVKDEFERRED_H
12#define CORE_GVKDEFERRED_H
13
14#include "gVKContext.h"
15
16#ifdef GVK_VULKAN
17
18struct gVKDeferredResources;
19
20// Creates a single-sample position/normal/albedo/depth G-buffer with one private
21// attachment set per frame in flight. Failure destroys every partially-created
22// object and returns null.
23gVKDeferredResources* gvkCreateDeferredResources(gVKContext& ctx,
24 uint32_t width, uint32_t height);
25void gvkDestroyDeferredResources(gVKContext& ctx, gVKDeferredResources*& resources);
26
27// Allocates one three-sampler set per frame slot after the lighting pipeline has
28// supplied its reflected set-1 layout. These sets are recreated when the shared
29// descriptor pool is rebuilt by shader reload or an MSAA change.
30bool gvkCreateDeferredDescriptors(gVKContext& ctx, gVKDeferredResources& resources,
31 VkDescriptorSetLayout layout);
32void gvkReleaseDeferredDescriptors(gVKContext& ctx, gVKDeferredResources& resources,
33 bool freeSets = true);
34VkDescriptorSet gvkGetDeferredDescriptorSet(const gVKDeferredResources& resources,
35 uint32_t frame);
36
37// The geometry pass may interrupt the lazily-opened screen pass. Ending it leaves
38// the colour attachments shader-readable for the lighting pass implemented next.
39bool gvkBeginDeferredPass(gVKContext& ctx, gVKDeferredResources& resources);
40void gvkEndDeferredPass(gVKContext& ctx);
41
42// Ends the fullscreen lighting pass and copies the G-buffer depth into the
43// single-sampled default target. The next ordinary draw reopens the screen pass
44// with LOAD operations, so forward 3D geometry keeps the deferred scene's
45// occlusion just like the OpenGL depth blit.
46bool gvkRestoreDeferredDepth(gVKContext& ctx, gVKDeferredResources& resources);
47
48// Narrow internal accessors for the pipeline and lighting stages. Keeping the
49// resource layout opaque prevents those stages from taking ownership of handles.
50VkRenderPass gvkGetDeferredRenderPass(const gVKDeferredResources& resources);
51VkImageView gvkGetDeferredColorView(const gVKDeferredResources& resources,
52 uint32_t frame, uint32_t attachment);
53VkExtent2D gvkGetDeferredExtent(const gVKDeferredResources& resources);
54
55#endif /* GVK_VULKAN */
56
57#endif /* CORE_GVKDEFERRED_H */