GetImageState(device_data, create_info->image));
}
+bool PreCallValidateCmdCopyBuffer(layer_data *device_data, GLOBAL_CB_NODE *cb_node, BUFFER_STATE *src_buffer_state,
+ BUFFER_STATE *dst_buffer_state) {
+ bool skip = false;
+ skip |= ValidateMemoryIsBoundToBuffer(device_data, src_buffer_state, "vkCmdCopyBuffer()", VALIDATION_ERROR_02531);
+ skip |= ValidateMemoryIsBoundToBuffer(device_data, dst_buffer_state, "vkCmdCopyBuffer()", VALIDATION_ERROR_02532);
+ // Validate that SRC & DST buffers have correct usage flags set
+ skip |= ValidateBufferUsageFlags(device_data, src_buffer_state, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, true, VALIDATION_ERROR_01164,
+ "vkCmdCopyBuffer()", "VK_BUFFER_USAGE_TRANSFER_SRC_BIT");
+ skip |= ValidateBufferUsageFlags(device_data, dst_buffer_state, VK_BUFFER_USAGE_TRANSFER_DST_BIT, true, VALIDATION_ERROR_01165,
+ "vkCmdCopyBuffer()", "VK_BUFFER_USAGE_TRANSFER_DST_BIT");
+ skip |= ValidateCmd(device_data, cb_node, CMD_COPYBUFFER, "vkCmdCopyBuffer()");
+ skip |= insideRenderPass(device_data, cb_node, "vkCmdCopyBuffer()", VALIDATION_ERROR_01172);
+ return skip;
+}
+void PreCallRecordCmdCopyBuffer(layer_data *device_data, GLOBAL_CB_NODE *cb_node, BUFFER_STATE *src_buffer_state,
+ BUFFER_STATE *dst_buffer_state) {
+ // Update bindings between buffers and cmd buffer
+ AddCommandBufferBindingBuffer(device_data, cb_node, src_buffer_state);
+ AddCommandBufferBindingBuffer(device_data, cb_node, dst_buffer_state);
+
+ std::function<bool()> function = [=]() {
+ return ValidateBufferMemoryIsValid(device_data, src_buffer_state, "vkCmdCopyBuffer()");
+ };
+ cb_node->validate_functions.push_back(function);
+ function = [=]() {
+ SetBufferMemoryValid(device_data, dst_buffer_state, true);
+ return false;
+ };
+ cb_node->validate_functions.push_back(function);
+ core_validation::UpdateCmdBufferLastCmd(cb_node, CMD_COPYBUFFER);
+}
return false;
}
// For given buffer_state, verify that the range it's bound to is valid
-static bool ValidateBufferMemoryIsValid(layer_data *dev_data, BUFFER_STATE *buffer_state, const char *functionName) {
+bool ValidateBufferMemoryIsValid(layer_data *dev_data, BUFFER_STATE *buffer_state, const char *functionName) {
return ValidateMemoryIsValid(dev_data, buffer_state->binding.mem, reinterpret_cast<uint64_t &>(buffer_state->buffer),
VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, functionName);
}
}
}
// For given buffer node set the buffer's bound memory range to valid param value
-static void SetBufferMemoryValid(layer_data *dev_data, BUFFER_STATE *buffer_state, bool valid) {
+void SetBufferMemoryValid(layer_data *dev_data, BUFFER_STATE *buffer_state, bool valid) {
SetMemoryValid(dev_data, buffer_state->binding.mem, reinterpret_cast<uint64_t &>(buffer_state->buffer), valid);
}
// Find CB Info and add mem reference to list container
VKAPI_ATTR void VKAPI_CALL CmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
uint32_t regionCount, const VkBufferCopy *pRegions) {
- bool skip_call = false;
- layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
+ layer_data *device_data = GetLayerDataPtr(get_dispatch_key(commandBuffer), layer_data_map);
std::unique_lock<std::mutex> lock(global_lock);
- auto cb_node = GetCBNode(dev_data, commandBuffer);
- auto src_buff_state = GetBufferState(dev_data, srcBuffer);
- auto dst_buff_state = GetBufferState(dev_data, dstBuffer);
- if (cb_node && src_buff_state && dst_buff_state) {
- skip_call |= ValidateMemoryIsBoundToBuffer(dev_data, src_buff_state, "vkCmdCopyBuffer()", VALIDATION_ERROR_02531);
- skip_call |= ValidateMemoryIsBoundToBuffer(dev_data, dst_buff_state, "vkCmdCopyBuffer()", VALIDATION_ERROR_02532);
- // Update bindings between buffers and cmd buffer
- AddCommandBufferBindingBuffer(dev_data, cb_node, src_buff_state);
- AddCommandBufferBindingBuffer(dev_data, cb_node, dst_buff_state);
- // Validate that SRC & DST buffers have correct usage flags set
- skip_call |= ValidateBufferUsageFlags(dev_data, src_buff_state, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, true,
- VALIDATION_ERROR_01164, "vkCmdCopyBuffer()", "VK_BUFFER_USAGE_TRANSFER_SRC_BIT");
- skip_call |= ValidateBufferUsageFlags(dev_data, dst_buff_state, VK_BUFFER_USAGE_TRANSFER_DST_BIT, true,
- VALIDATION_ERROR_01165, "vkCmdCopyBuffer()", "VK_BUFFER_USAGE_TRANSFER_DST_BIT");
-
- std::function<bool()> function = [=]() {
- return ValidateBufferMemoryIsValid(dev_data, src_buff_state, "vkCmdCopyBuffer()");
- };
- cb_node->validate_functions.push_back(function);
- function = [=]() {
- SetBufferMemoryValid(dev_data, dst_buff_state, true);
- return false;
- };
- cb_node->validate_functions.push_back(function);
+ auto cb_node = GetCBNode(device_data, commandBuffer);
+ auto src_buffer_state = GetBufferState(device_data, srcBuffer);
+ auto dst_buffer_state = GetBufferState(device_data, dstBuffer);
- skip_call |= ValidateCmd(dev_data, cb_node, CMD_COPYBUFFER, "vkCmdCopyBuffer()");
- UpdateCmdBufferLastCmd(cb_node, CMD_COPYBUFFER);
- skip_call |= insideRenderPass(dev_data, cb_node, "vkCmdCopyBuffer()", VALIDATION_ERROR_01172);
+ if (cb_node && src_buffer_state && dst_buffer_state) {
+ bool skip = PreCallValidateCmdCopyBuffer(device_data, cb_node, src_buffer_state, dst_buffer_state);
+ if (!skip) {
+ PreCallRecordCmdCopyBuffer(device_data, cb_node, src_buffer_state, dst_buffer_state);
+ lock.unlock();
+ device_data->dispatch_table.CmdCopyBuffer(commandBuffer, srcBuffer, dstBuffer, regionCount, pRegions);
+ }
} else {
- // Param_checker will flag errors on invalid objects, just assert here as debugging aid
+ lock.unlock();
assert(0);
}
- lock.unlock();
- if (!skip_call) dev_data->dispatch_table.CmdCopyBuffer(commandBuffer, srcBuffer, dstBuffer, regionCount, pRegions);
}
VKAPI_ATTR void VKAPI_CALL CmdCopyImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout,