forked from KhronosGroup/Vulkan-ValidationLayers
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ray_tracing_state.h
135 lines (124 loc) · 6.16 KB
/
ray_tracing_state.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/* Copyright (c) 2015-2021 The Khronos Group Inc.
* Copyright (c) 2015-2021 Valve Corporation
* Copyright (c) 2015-2021 LunarG, Inc.
* Copyright (C) 2015-2021 Google Inc.
* Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Author: Courtney Goeltzenleuchter <[email protected]>
* Author: Tobin Ehlis <[email protected]>
* Author: Chris Forbes <[email protected]>
* Author: Mark Lobodzinski <[email protected]>
* Author: Dave Houlton <[email protected]>
* Author: John Zulauf <[email protected]>
* Author: Tobias Hector <[email protected]>
* Author: Jeremy Gebben <[email protected]>
*/
#pragma once
#include "device_memory_state.h"
class ACCELERATION_STRUCTURE_STATE : public BINDABLE {
public:
safe_VkAccelerationStructureCreateInfoNV create_infoNV = {};
safe_VkAccelerationStructureInfoNV build_info;
bool memory_requirements_checked = false;
VkMemoryRequirements2 memory_requirements;
bool build_scratch_memory_requirements_checked = false;
VkMemoryRequirements2 build_scratch_memory_requirements;
bool update_scratch_memory_requirements_checked = false;
VkMemoryRequirements2 update_scratch_memory_requirements;
bool built = false;
uint64_t opaque_handle = 0;
const VkAllocationCallbacks *allocator = NULL;
ACCELERATION_STRUCTURE_STATE(VkAccelerationStructureNV as, const VkAccelerationStructureCreateInfoNV *ci)
: BINDABLE(as, kVulkanObjectTypeAccelerationStructureNV),
create_infoNV(ci),
memory_requirements{},
build_scratch_memory_requirements_checked{},
build_scratch_memory_requirements{},
update_scratch_memory_requirements_checked{},
update_scratch_memory_requirements{} {}
ACCELERATION_STRUCTURE_STATE(const ACCELERATION_STRUCTURE_STATE &rh_obj) = delete;
VkAccelerationStructureNV acceleration_structure() const { return handle_.Cast<VkAccelerationStructureNV>(); }
};
class ACCELERATION_STRUCTURE_STATE_KHR : public BINDABLE {
public:
safe_VkAccelerationStructureCreateInfoKHR create_infoKHR = {};
safe_VkAccelerationStructureBuildGeometryInfoKHR build_info_khr;
bool memory_requirements_checked = false;
VkMemoryRequirements2 memory_requirements;
bool build_scratch_memory_requirements_checked = false;
VkMemoryRequirements2 build_scratch_memory_requirements;
bool update_scratch_memory_requirements_checked = false;
VkMemoryRequirements2 update_scratch_memory_requirements;
bool built = false;
uint64_t opaque_handle = 0;
const VkAllocationCallbacks *allocator = NULL;
ACCELERATION_STRUCTURE_STATE_KHR(VkAccelerationStructureKHR as, const VkAccelerationStructureCreateInfoKHR *ci)
: BINDABLE(as, kVulkanObjectTypeAccelerationStructureKHR),
create_infoKHR(ci),
memory_requirements{},
build_scratch_memory_requirements_checked{},
build_scratch_memory_requirements{},
update_scratch_memory_requirements_checked{},
update_scratch_memory_requirements{} {}
ACCELERATION_STRUCTURE_STATE_KHR(const ACCELERATION_STRUCTURE_STATE_KHR &rh_obj) = delete;
VkAccelerationStructureKHR acceleration_structure() const { return handle_.Cast<VkAccelerationStructureKHR>(); }
};
// Safe struct that spans NV and KHR VkRayTracingPipelineCreateInfo structures.
// It is a safe_VkRayTracingPipelineCreateInfoKHR and supports construction from
// a VkRayTracingPipelineCreateInfoNV.
class safe_VkRayTracingPipelineCreateInfoCommon : public safe_VkRayTracingPipelineCreateInfoKHR {
public:
safe_VkRayTracingPipelineCreateInfoCommon() : safe_VkRayTracingPipelineCreateInfoKHR() {}
safe_VkRayTracingPipelineCreateInfoCommon(const VkRayTracingPipelineCreateInfoNV *pCreateInfo)
: safe_VkRayTracingPipelineCreateInfoKHR() {
initialize(pCreateInfo);
}
void initialize(const VkRayTracingPipelineCreateInfoNV *pCreateInfo) {
safe_VkRayTracingPipelineCreateInfoNV nvStruct;
nvStruct.initialize(pCreateInfo);
sType = nvStruct.sType;
// Take ownership of the pointer and null it out in nvStruct
pNext = nvStruct.pNext;
nvStruct.pNext = nullptr;
flags = nvStruct.flags;
stageCount = nvStruct.stageCount;
pStages = nvStruct.pStages;
nvStruct.pStages = nullptr;
groupCount = nvStruct.groupCount;
maxRecursionDepth = nvStruct.maxRecursionDepth;
layout = nvStruct.layout;
basePipelineHandle = nvStruct.basePipelineHandle;
basePipelineIndex = nvStruct.basePipelineIndex;
assert(pGroups == nullptr);
if (nvStruct.groupCount && nvStruct.pGroups) {
pGroups = new safe_VkRayTracingShaderGroupCreateInfoKHR[groupCount];
for (uint32_t i = 0; i < groupCount; ++i) {
pGroups[i].sType = nvStruct.pGroups[i].sType;
pGroups[i].pNext = nvStruct.pGroups[i].pNext;
pGroups[i].type = nvStruct.pGroups[i].type;
pGroups[i].generalShader = nvStruct.pGroups[i].generalShader;
pGroups[i].closestHitShader = nvStruct.pGroups[i].closestHitShader;
pGroups[i].anyHitShader = nvStruct.pGroups[i].anyHitShader;
pGroups[i].intersectionShader = nvStruct.pGroups[i].intersectionShader;
pGroups[i].intersectionShader = nvStruct.pGroups[i].intersectionShader;
pGroups[i].pShaderGroupCaptureReplayHandle = nullptr;
}
}
}
void initialize(const VkRayTracingPipelineCreateInfoKHR *pCreateInfo) {
safe_VkRayTracingPipelineCreateInfoKHR::initialize(pCreateInfo);
}
uint32_t maxRecursionDepth; // NV specific
};