cb_node->validate_functions.push_back(function);
core_validation::UpdateCmdBufferLastCmd(cb_node, CMD_COPYBUFFER);
}
+
+static bool validateIdleBuffer(layer_data *device_data, VkBuffer buffer) {
+ const debug_report_data *report_data = core_validation::GetReportData(device_data);
+ bool skip = false;
+ auto buffer_state = GetBufferState(device_data, buffer);
+ if (!buffer_state) {
+ skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, (uint64_t)(buffer),
+ __LINE__, DRAWSTATE_DOUBLE_DESTROY, "DS",
+ "Cannot free buffer 0x%" PRIxLEAST64 " that has not been allocated.", (uint64_t)(buffer));
+ } else {
+ if (buffer_state->in_use.load()) {
+ skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, (uint64_t)(buffer),
+ __LINE__, VALIDATION_ERROR_00676, "DS",
+ "Cannot free buffer 0x%" PRIxLEAST64 " that is in use by a command buffer. %s", (uint64_t)(buffer),
+ validation_error_map[VALIDATION_ERROR_00676]);
+ }
+ }
+ return skip;
+}
+
+bool PreCallValidateDestroyImageView(layer_data *device_data, VkImageView image_view, IMAGE_VIEW_STATE **image_view_state,
+ VK_OBJECT *obj_struct) {
+ *image_view_state = GetImageViewState(device_data, image_view);
+ *obj_struct = {reinterpret_cast<uint64_t &>(image_view), VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT};
+ if (GetDisables(device_data)->destroy_image_view) return false;
+ bool skip = false;
+ if (*image_view_state) {
+ skip |= ValidateObjectNotInUse(device_data, *image_view_state, *obj_struct, VALIDATION_ERROR_00776);
+ }
+ return skip;
+}
+
+void PostCallRecordDestroyImageView(layer_data *device_data, VkImageView image_view, IMAGE_VIEW_STATE *image_view_state,
+ VK_OBJECT obj_struct) {
+ // Any bound cmd buffers are now invalid
+ invalidateCommandBuffers(device_data, image_view_state->cb_bindings, obj_struct);
+ (*GetImageViewMap(device_data)).erase(image_view);
+}
+
+bool PreCallValidateDestroyBuffer(layer_data *device_data, VkBuffer buffer, BUFFER_STATE **buffer_state, VK_OBJECT *obj_struct) {
+ *buffer_state = GetBufferState(device_data, buffer);
+ *obj_struct = {reinterpret_cast<uint64_t &>(buffer), VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT};
+ if (GetDisables(device_data)->destroy_buffer) return false;
+ bool skip = false;
+ if (*buffer_state) {
+ skip |= validateIdleBuffer(device_data, buffer);
+ }
+ return skip;
+}
+
+void PostCallRecordDestroyBuffer(layer_data *device_data, VkBuffer buffer, BUFFER_STATE *buffer_state, VK_OBJECT obj_struct) {
+ invalidateCommandBuffers(device_data, buffer_state->cb_bindings, obj_struct);
+ for (auto mem_binding : buffer_state->GetBoundMemory()) {
+ auto mem_info = GetMemObjInfo(device_data, mem_binding);
+ if (mem_info) {
+ core_validation::RemoveBufferMemoryRange(reinterpret_cast<uint64_t &>(buffer), mem_info);
+ }
+ }
+ ClearMemoryObjectBindings(device_data, reinterpret_cast<uint64_t &>(buffer), VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT);
+ GetBufferMap(device_data)->erase(buffer_state->buffer);
+}
+
+bool PreCallValidateDestroyBufferView(layer_data *device_data, VkBufferView buffer_view, BUFFER_VIEW_STATE **buffer_view_state,
+ VK_OBJECT *obj_struct) {
+ *buffer_view_state = GetBufferViewState(device_data, buffer_view);
+ *obj_struct = {reinterpret_cast<uint64_t &>(buffer_view), VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT};
+ if (GetDisables(device_data)->destroy_buffer_view) return false;
+ bool skip = false;
+ if (*buffer_view_state) {
+ skip |= ValidateObjectNotInUse(device_data, *buffer_view_state, *obj_struct, VALIDATION_ERROR_00701);
+ }
+ return skip;
+}
+
+void PostCallRecordDestroyBufferView(layer_data *device_data, VkBufferView buffer_view, BUFFER_VIEW_STATE *buffer_view_state,
+ VK_OBJECT obj_struct) {
+ // Any bound cmd buffers are now invalid
+ invalidateCommandBuffers(device_data, buffer_view_state->cb_bindings, obj_struct);
+ GetBufferViewMap(device_data)->erase(buffer_view);
+}
void PreCallRecordCmdCopyBuffer(layer_data *device_data, GLOBAL_CB_NODE *cb_node, BUFFER_STATE *src_buffer_state,
BUFFER_STATE *dst_buffer_state);
+bool PreCallValidateDestroyImageView(layer_data *device_data, VkImageView image_view, IMAGE_VIEW_STATE **image_view_state,
+ VK_OBJECT *obj_struct);
+
+void PostCallRecordDestroyImageView(layer_data *device_data, VkImageView image_view, IMAGE_VIEW_STATE *image_view_state,
+ VK_OBJECT obj_struct);
+
+bool PreCallValidateDestroyBuffer(layer_data *device_data, VkBuffer buffer, BUFFER_STATE **buffer_state, VK_OBJECT *obj_struct);
+
+void PostCallRecordDestroyBuffer(layer_data *device_data, VkBuffer buffer, BUFFER_STATE *buffer_state, VK_OBJECT obj_struct);
+
+bool PreCallValidateDestroyBufferView(layer_data *device_data, VkBufferView buffer_view, BUFFER_VIEW_STATE **buffer_view_state,
+ VK_OBJECT *obj_struct);
+
+void PostCallRecordDestroyBufferView(layer_data *device_data, VkBufferView buffer_view, BUFFER_VIEW_STATE *buffer_view_state,
+ VK_OBJECT obj_struct);
+
#endif // CORE_VALIDATION_BUFFER_VALIDATION_H_
return result;
}
-static bool validateIdleBuffer(const layer_data *dev_data, VkBuffer buffer) {
- bool skip_call = false;
- auto buffer_state = GetBufferState(dev_data, buffer);
- if (!buffer_state) {
- skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT,
- (uint64_t)(buffer), __LINE__, DRAWSTATE_DOUBLE_DESTROY, "DS",
- "Cannot free buffer 0x%" PRIxLEAST64 " that has not been allocated.", (uint64_t)(buffer));
- } else {
- if (buffer_state->in_use.load()) {
- skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT,
- (uint64_t)(buffer), __LINE__, VALIDATION_ERROR_00676, "DS",
- "Cannot free buffer 0x%" PRIxLEAST64 " that is in use by a command buffer. %s", (uint64_t)(buffer),
- validation_error_map[VALIDATION_ERROR_00676]);
- }
- }
- return skip_call;
-}
-
// Return true if given ranges intersect, else false
// Prereq : For both ranges, range->end - range->start > 0. This case should have already resulted
// in an error so not checking that here
}
}
-static void RemoveBufferMemoryRange(uint64_t handle, DEVICE_MEM_INFO *mem_info) { RemoveMemoryRange(handle, mem_info, false); }
+void RemoveBufferMemoryRange(uint64_t handle, DEVICE_MEM_INFO *mem_info) { RemoveMemoryRange(handle, mem_info, false); }
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) {
- *buffer_state = GetBufferState(dev_data, buffer);
- *obj_struct = {reinterpret_cast<uint64_t &>(buffer), VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT};
- if (dev_data->instance_data->disabled.destroy_buffer) return false;
- bool skip = false;
- if (*buffer_state) {
- skip |= validateIdleBuffer(dev_data, buffer);
- }
- return skip;
-}
-
-static void PostCallRecordDestroyBuffer(layer_data *dev_data, VkBuffer buffer, BUFFER_STATE *buffer_state, VK_OBJECT obj_struct) {
- invalidateCommandBuffers(dev_data, buffer_state->cb_bindings, obj_struct);
- for (auto mem_binding : buffer_state->GetBoundMemory()) {
- auto mem_info = GetMemObjInfo(dev_data, mem_binding);
- if (mem_info) {
- RemoveBufferMemoryRange(reinterpret_cast<uint64_t &>(buffer), mem_info);
- }
- }
- ClearMemoryObjectBindings(dev_data, reinterpret_cast<uint64_t &>(buffer), VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT);
- dev_data->bufferMap.erase(buffer_state->buffer);
-}
-
VKAPI_ATTR void VKAPI_CALL DestroyBuffer(VkDevice device, VkBuffer buffer, const VkAllocationCallbacks *pAllocator) {
layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
BUFFER_STATE *buffer_state = nullptr;
}
}
-static bool PreCallValidateDestroyBufferView(layer_data *dev_data, VkBufferView buffer_view, BUFFER_VIEW_STATE **buffer_view_state,
- VK_OBJECT *obj_struct) {
- *buffer_view_state = GetBufferViewState(dev_data, buffer_view);
- *obj_struct = {reinterpret_cast<uint64_t &>(buffer_view), VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT};
- if (dev_data->instance_data->disabled.destroy_buffer_view) return false;
- bool skip = false;
- if (*buffer_view_state) {
- skip |= ValidateObjectNotInUse(dev_data, *buffer_view_state, *obj_struct, VALIDATION_ERROR_00701);
- }
- return skip;
-}
-
-static void PostCallRecordDestroyBufferView(layer_data *dev_data, VkBufferView buffer_view, BUFFER_VIEW_STATE *buffer_view_state,
- VK_OBJECT obj_struct) {
- // Any bound cmd buffers are now invalid
- invalidateCommandBuffers(dev_data, buffer_view_state->cb_bindings, obj_struct);
- dev_data->bufferViewMap.erase(buffer_view);
-}
-
VKAPI_ATTR void VKAPI_CALL DestroyBufferView(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks *pAllocator) {
layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
// Common data objects used pre & post call
}
}
-static bool PreCallValidateDestroyImageView(layer_data *dev_data, VkImageView image_view, IMAGE_VIEW_STATE **image_view_state,
- VK_OBJECT *obj_struct) {
- *image_view_state = GetImageViewState(dev_data, image_view);
- *obj_struct = {reinterpret_cast<uint64_t &>(image_view), VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT};
- if (dev_data->instance_data->disabled.destroy_image_view) return false;
- bool skip = false;
- if (*image_view_state) {
- skip |= ValidateObjectNotInUse(dev_data, *image_view_state, *obj_struct, VALIDATION_ERROR_00776);
- }
- return skip;
-}
-
-static void PostCallRecordDestroyImageView(layer_data *dev_data, VkImageView image_view, IMAGE_VIEW_STATE *image_view_state,
- VK_OBJECT obj_struct) {
- // Any bound cmd buffers are now invalid
- invalidateCommandBuffers(dev_data, image_view_state->cb_bindings, obj_struct);
- dev_data->imageViewMap.erase(image_view);
-}
-
VKAPI_ATTR void VKAPI_CALL DestroyImageView(VkDevice device, VkImageView imageView, const VkAllocationCallbacks *pAllocator) {
layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);
// Common data objects used pre & post call
bool ValidateObjectNotInUse(const layer_data *dev_data, BASE_NODE *obj_node, VK_OBJECT obj_struct, UNIQUE_VALIDATION_ERROR_CODE error_code);
void invalidateCommandBuffers(const layer_data *dev_data, std::unordered_set<GLOBAL_CB_NODE *> const &cb_nodes, VK_OBJECT obj);
void RemoveImageMemoryRange(uint64_t handle, DEVICE_MEM_INFO *mem_info);
+void RemoveBufferMemoryRange(uint64_t handle, DEVICE_MEM_INFO *mem_info);
bool ClearMemoryObjectBindings(layer_data *dev_data, uint64_t handle, VkDebugReportObjectTypeEXT type);
bool ValidateCmd(layer_data *my_data, GLOBAL_CB_NODE *pCB, const CMD_TYPE cmd, const char *caller_name);
bool insideRenderPass(const layer_data *my_data, GLOBAL_CB_NODE *pCB, const char *apiName, UNIQUE_VALIDATION_ERROR_CODE msgCode);