GlistEngine
Loading...
Searching...
No Matches
gVKShadow.h
Go to the documentation of this file.
1/*
2 * gVKShadow.h
3 *
4 * The shadow map of the Vulkan 3D path: a depth-only render target that the scene
5 * is drawn into from the light's point of view, then sampled while shading.
6 *
7 * This is a second render pass with its own image, its own framebuffer and its own
8 * pipeline, and it runs before the one that draws to the screen. Which of the two
9 * a frame is currently recording is decided by gObject::renderpassno, the counter
10 * gAppManager already increments when gShadowMap asks for two passes - so the scene
11 * is drawn twice by the engine and this file only has to know which pass it is in.
12 *
13 * The depth image is both a depth attachment and a sampled texture, which is what
14 * lets the second pass read what the first one wrote. It carries its own descriptor
15 * set, shaped like a texture's, so the mesh shader binds it the same way it binds a
16 * material map.
17 *
18 * Created by: Veysel Burak Eroglu.
19 */
20
21#pragma once
22
23#ifndef CORE_GVKSHADOW_H
24#define CORE_GVKSHADOW_H
25
26#include "gVKContext.h"
27
28#ifdef GVK_VULKAN
29
30/*
31 * Creates the depth image, its view and sampler, the render pass and framebuffer
32 * that write into it, and the descriptor set that reads it back. Sized in texels;
33 * gShadowMap decides the size, defaulting to what the OpenGL path uses.
34 *
35 * Safe to call again with a different size: the previous resources are released
36 * first. Returns false and leaves nothing allocated on failure, which is what makes
37 * a scene fall back to being drawn unshadowed rather than not drawn at all.
38 */
39bool gvkCreateShadowResources(gVKContext& ctx, uint32_t width, uint32_t height);
40void gvkDestroyShadowResources(gVKContext& ctx);
41
42/*
43 * Opens the shadow render pass on the frame's command buffer and sets a viewport
44 * covering the whole shadow map. Unlike the main pass this one is begun eagerly:
45 * there is no clear colour to wait for, only a depth clear.
46 *
47 * Returns false when there is no shadow map, no frame in flight, or a render pass
48 * is already open - in each case the caller simply draws nothing.
49 */
50bool gvkBeginShadowPass(gVKContext& ctx);
51void gvkEndShadowPass(gVKContext& ctx);
52
53#endif /* GVK_VULKAN */
54
55#endif /* CORE_GVKSHADOW_H */