forked from KhronosGroup/Vulkan-ValidationLayers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuffer_state.h
89 lines (79 loc) · 3.35 KB
/
buffer_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
/* 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 BUFFER_STATE : public BINDABLE {
public:
const safe_VkBufferCreateInfo safe_create_info;
const VkBufferCreateInfo &createInfo;
VkDeviceAddress deviceAddress;
VkMemoryRequirements requirements;
bool memory_requirements_checked;
BUFFER_STATE(VkBuffer buff, const VkBufferCreateInfo *pCreateInfo)
: BINDABLE(buff, kVulkanObjectTypeBuffer, (pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != 0,
(pCreateInfo->flags & VK_BUFFER_CREATE_PROTECTED_BIT) == 0, GetExternalHandleType(pCreateInfo)),
safe_create_info(pCreateInfo),
createInfo(*safe_create_info.ptr()),
deviceAddress(0),
requirements(),
memory_requirements_checked(false) {}
BUFFER_STATE(BUFFER_STATE const &rh_obj) = delete;
VkBuffer buffer() const { return handle_.Cast<VkBuffer>(); }
private:
static inline VkExternalMemoryHandleTypeFlags GetExternalHandleType(const VkBufferCreateInfo *pCreateInfo) {
auto *external_memory_info = LvlFindInChain<VkExternalMemoryBufferCreateInfo>(pCreateInfo->pNext);
return external_memory_info ? external_memory_info->handleTypes : 0;
}
};
class BUFFER_VIEW_STATE : public BASE_NODE {
public:
const VkBufferViewCreateInfo create_info;
std::shared_ptr<BUFFER_STATE> buffer_state;
const VkFormatFeatureFlags format_features;
BUFFER_VIEW_STATE(const std::shared_ptr<BUFFER_STATE> &bf, VkBufferView bv, const VkBufferViewCreateInfo *ci,
VkFormatFeatureFlags ff)
: BASE_NODE(bv, kVulkanObjectTypeBufferView), create_info(*ci), buffer_state(bf), format_features(ff) {
if (buffer_state) {
buffer_state->AddParent(this);
}
}
virtual ~BUFFER_VIEW_STATE() {
if (!Destroyed()) {
Destroy();
}
}
BUFFER_VIEW_STATE(const BUFFER_VIEW_STATE &rh_obj) = delete;
VkBufferView buffer_view() const { return handle_.Cast<VkBufferView>(); }
void Destroy() override {
if (buffer_state) {
buffer_state->RemoveParent(this);
buffer_state = nullptr;
}
BASE_NODE::Destroy();
}
};