aboutsummaryrefslogtreecommitdiff
path: root/layers/core_validation.cpp
diff options
context:
space:
mode:
authorMark Lobodzinski <mark@lunarg.com>2017-01-27 12:28:30 -0700
committerMark Lobodzinski <mark@lunarg.com>2017-01-31 09:55:10 -0700
commit627af0c8f4115bc0138f2f803abb66063eba6e18 (patch)
tree7ca124baa60fa9f3c060890eef92df9fbdc99a07 /layers/core_validation.cpp
parent7950325e9b1ed8d686abb072124433a06bff19cc (diff)
downloadusermoji-627af0c8f4115bc0138f2f803abb66063eba6e18.tar.xz
layers: Move DestroyImage code into buffer module
Moved CHECK_DISABLED into CV_types.h, moved validation and recording routines into buffer_validation.cpp. Change-Id: I103d0fc9c2e985d98943471ec6f83898c58bfdfe
Diffstat (limited to 'layers/core_validation.cpp')
-rw-r--r--layers/core_validation.cpp51
1 files changed, 16 insertions, 35 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp
index 4d1e30e1..01d6f41e 100644
--- a/layers/core_validation.cpp
+++ b/layers/core_validation.cpp
@@ -712,7 +712,7 @@ static bool ClearMemoryObjectBinding(layer_data *dev_data, uint64_t handle, VkDe
// ClearMemoryObjectBindings clears the binding of objects to memory
// For the given object it pulls the memory bindings and makes sure that the bindings
// no longer refer to the object being cleared. This occurs when objects are destroyed.
-static bool ClearMemoryObjectBindings(layer_data *dev_data, uint64_t handle, VkDebugReportObjectTypeEXT type) {
+bool ClearMemoryObjectBindings(layer_data *dev_data, uint64_t handle, VkDebugReportObjectTypeEXT type) {
bool skip = false;
BINDABLE *mem_binding = GetObjectMemBinding(dev_data, handle, type);
if (mem_binding) {
@@ -5634,7 +5634,7 @@ static void RemoveMemoryRange(uint64_t handle, DEVICE_MEM_INFO *mem_info, bool i
static void RemoveBufferMemoryRange(uint64_t handle, DEVICE_MEM_INFO *mem_info) { RemoveMemoryRange(handle, mem_info, false); }
-static void RemoveImageMemoryRange(uint64_t handle, DEVICE_MEM_INFO *mem_info) { RemoveMemoryRange(handle, mem_info, true); }
+void RemoveImageMemoryRange(uint64_t handle, DEVICE_MEM_INFO *mem_info) { RemoveMemoryRange(handle, mem_info, true); }
static bool PreCallValidateDestroyBuffer(layer_data *dev_data, VkBuffer buffer, BUFFER_STATE **buffer_state,
VK_OBJECT *obj_struct) {
@@ -5709,39 +5709,6 @@ VKAPI_ATTR void VKAPI_CALL DestroyBufferView(VkDevice device, VkBufferView buffe
}
}
-static bool PreCallValidateDestroyImage(layer_data *dev_data, VkImage image, IMAGE_STATE **image_state, VK_OBJECT *obj_struct) {
- *image_state = getImageState(dev_data, image);
- *obj_struct = {reinterpret_cast<uint64_t &>(image), VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT};
- if (dev_data->instance_data->disabled.destroy_image) return false;
- bool skip = false;
- if (*image_state) {
- skip |= ValidateObjectNotInUse(dev_data, *image_state, *obj_struct, VALIDATION_ERROR_00743);
- }
- return skip;
-}
-
-static void PostCallRecordDestroyImage(layer_data *dev_data, VkImage image, IMAGE_STATE *image_state, VK_OBJECT obj_struct) {
- invalidateCommandBuffers(dev_data, image_state->cb_bindings, obj_struct);
- // Clean up memory mapping, bindings and range references for image
- for (auto mem_binding : image_state->GetBoundMemory()) {
- auto mem_info = getMemObjInfo(dev_data, mem_binding);
- if (mem_info) {
- RemoveImageMemoryRange(obj_struct.handle, mem_info);
- }
- }
- ClearMemoryObjectBindings(dev_data, obj_struct.handle, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT);
- // Remove image from imageMap
- dev_data->imageMap.erase(image);
-
- const auto &sub_entry = dev_data->imageSubresourceMap.find(image);
- if (sub_entry != dev_data->imageSubresourceMap.end()) {
- for (const auto &pair : sub_entry->second) {
- dev_data->imageLayoutMap.erase(pair);
- }
- dev_data->imageSubresourceMap.erase(sub_entry);
- }
-}
-
VKAPI_ATTR void VKAPI_CALL DestroyImage(VkDevice device, VkImage image, const VkAllocationCallbacks *pAllocator) {
layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
IMAGE_STATE *image_state = nullptr;
@@ -6411,6 +6378,20 @@ const VkPhysicalDeviceProperties *GetPhysicalDeviceProperties(core_validation::l
return &device_data->phys_dev_props;
}
+const CHECK_DISABLED *GetDisables(core_validation::layer_data *device_data) { return &device_data->instance_data->disabled; }
+
+std::unordered_map<VkImage, std::unique_ptr<IMAGE_STATE>> *GetImageMap(core_validation::layer_data *device_data) {
+ return &device_data->imageMap;
+}
+
+std::unordered_map<VkImage, std::vector<ImageSubresourcePair>> *GetImageSubresourceMap(core_validation::layer_data *device_data) {
+ return &device_data->imageSubresourceMap;
+}
+
+std::unordered_map<ImageSubresourcePair, IMAGE_LAYOUT_NODE> *GetImageLayoutMap(layer_data *device_data) {
+ return &device_data->imageLayoutMap;
+}
+
VKAPI_ATTR VkResult VKAPI_CALL CreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
const VkAllocationCallbacks *pAllocator, VkImage *pImage) {
VkResult result = VK_ERROR_VALIDATION_FAILED_EXT;