forked from SaschaWillems/Vulkan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvariablerateshading.h
71 lines (60 loc) · 1.71 KB
/
variablerateshading.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* Vulkan Example - Variable rate shading
*
* Copyright (C) 2020 by Sascha Willems - www.saschawillems.de
*
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
*/
#include "vulkanexamplebase.h"
#include "VulkanglTFModel.h"
#define ENABLE_VALIDATION false
class VulkanExample : public VulkanExampleBase
{
public:
vkglTF::Model scene;
struct ShadingRateImage {
VkImage image;
VkDeviceMemory memory;
VkImageView view;
} shadingRateImage;
bool enableShadingRate = true;
bool colorShadingRate = false;
struct ShaderData {
vks::Buffer buffer;
struct Values {
glm::mat4 projection;
glm::mat4 view;
glm::mat4 model = glm::mat4(1.0f);
glm::vec4 lightPos = glm::vec4(0.0f, 2.5f, 0.0f, 1.0f);
glm::vec4 viewPos;
int32_t colorShadingRate;
} values;
} shaderData;
struct Pipelines {
VkPipeline opaque;
VkPipeline masked;
};
Pipelines basePipelines;
Pipelines shadingRatePipelines;
VkPipelineLayout pipelineLayout;
VkDescriptorSet descriptorSet;
VkDescriptorSetLayout descriptorSetLayout;
VkPhysicalDeviceShadingRateImagePropertiesNV physicalDeviceShadingRateImagePropertiesNV{};
VkPhysicalDeviceShadingRateImageFeaturesNV enabledPhysicalDeviceShadingRateImageFeaturesNV{};
PFN_vkCmdBindShadingRateImageNV vkCmdBindShadingRateImageNV;
VulkanExample();
~VulkanExample();
virtual void getEnabledFeatures();
void handleResize();
void buildCommandBuffers();
void loadglTFFile(std::string filename);
void loadAssets();
void prepareShadingRateImage();
void setupDescriptors();
void preparePipelines();
void prepareUniformBuffers();
void updateUniformBuffers();
void prepare();
virtual void render();
virtual void OnUpdateUIOverlay(vks::UIOverlay* overlay);
};