Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions layers/core_checks/cc_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -570,12 +570,13 @@ bool CoreChecks::PreCallValidateCmdFillMemoryKHR(VkCommandBuffer commandBuffer,
const ErrorObject& error_obj) const {
bool skip = false;

const auto& cb_state = *GetRead<vvl::CommandBuffer>(commandBuffer);
skip |= ValidateCmd(cb_state, error_obj.location);

skip |= ValidateDeviceAddressRange(pDstRange->address, pDstRange->size, false, error_obj.location.dot(Field::pDstRange),
LogObjectList(commandBuffer), VK_BUFFER_USAGE_2_TRANSFER_DST_BIT,
"VUID-vkCmdFillMemoryKHR-dstRange-13000");

auto cb_state_ptr = GetRead<vvl::CommandBuffer>(commandBuffer);
const vvl::CommandBuffer& cb_state = *cb_state_ptr;
if (!phys_dev_props_core11.protectedNoFault) {
if (cb_state.unprotected) {
if ((dstFlags & VK_ADDRESS_COMMAND_PROTECTED_BIT_KHR) != 0) {
Expand Down
11 changes: 10 additions & 1 deletion layers/core_checks/cc_cmd_buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,9 @@ bool CoreChecks::PreCallValidateCmdUpdateMemoryKHR(VkCommandBuffer commandBuffer
const ErrorObject& error_obj) const {
bool skip = false;

const auto& cb_state = *GetRead<vvl::CommandBuffer>(commandBuffer);
skip |= ValidateCmd(cb_state, error_obj.location);

skip |= ValidateDeviceAddressCommands(commandBuffer, pDstRange->address, pDstRange->size, dstFlags,
error_obj.location.dot(Field::pDstRange));

Expand All @@ -772,7 +775,6 @@ bool CoreChecks::PreCallValidateCmdUpdateMemoryKHR(VkCommandBuffer commandBuffer
"VUID-vkCmdUpdateMemoryKHR-dstRange-13005");

if (!phys_dev_props_core11.protectedNoFault) {
const auto& cb_state = *GetRead<vvl::CommandBuffer>(commandBuffer);
if (cb_state.unprotected) {
if ((dstFlags & VK_ADDRESS_COMMAND_PROTECTED_BIT_KHR) != 0) {
skip |= LogError("VUID-vkCmdUpdateMemoryKHR-commandBuffer-13010", commandBuffer,
Expand Down Expand Up @@ -2557,6 +2559,8 @@ bool CoreChecks::PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuff
bool skip = false;

auto cb_state = GetRead<vvl::CommandBuffer>(commandBuffer);
skip |= ValidateCmd(*cb_state, error_obj.location);

if (cb_state->transform_feedback_active) {
skip |= LogError("VUID-vkCmdBindTransformFeedbackBuffersEXT-None-02365", commandBuffer, error_obj.location,
"transform feedback is active.");
Expand Down Expand Up @@ -2603,6 +2607,8 @@ bool CoreChecks::PreCallValidateCmdBindTransformFeedbackBuffers2EXT(VkCommandBuf
bool skip = false;

auto cb_state = GetRead<vvl::CommandBuffer>(commandBuffer);
skip |= ValidateCmd(*cb_state, error_obj.location);

if (cb_state->transform_feedback_active) {
skip |= LogError("VUID-vkCmdBindTransformFeedbackBuffers2EXT-None-02365", commandBuffer, error_obj.location,
"transform feedback is active.");
Expand Down Expand Up @@ -2919,6 +2925,9 @@ bool CoreChecks::PreCallValidateCmdBindVertexBuffers3KHR(VkCommandBuffer command
const ErrorObject& error_obj) const {
bool skip = false;

auto cb_state = GetRead<vvl::CommandBuffer>(commandBuffer);
skip |= ValidateCmd(*cb_state, error_obj.location);

for (uint32_t i = 0; i < bindingCount; ++i) {
const Location binding_info_loc = error_obj.location.dot(Field::pBindingInfos, i);
const VkBindVertexBuffer3InfoKHR& info = pBindingInfos[i];
Expand Down
8 changes: 8 additions & 0 deletions layers/core_checks/cc_cmd_buffer_dynamic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2021,6 +2021,14 @@ bool CoreChecks::PreCallValidateCmdSetPrimitiveRestartEnable(VkCommandBuffer com
return ValidateCmdSetPrimitiveRestartEnable(commandBuffer, primitiveRestartEnable, error_obj);
}

bool CoreChecks::PreCallValidateCmdSetPrimitiveRestartIndexEXT(VkCommandBuffer commandBuffer, uint32_t primitiveRestartIndex,
const ErrorObject& error_obj) const {
bool skip = false;
auto cb_state = GetRead<vvl::CommandBuffer>(commandBuffer);
skip |= ValidateCmd(*cb_state, error_obj.location);
return skip;
}

bool CoreChecks::ValidateCmdSetCullMode(VkCommandBuffer commandBuffer, VkCullModeFlags cullMode,
const ErrorObject& error_obj) const {
bool skip = false;
Expand Down
20 changes: 15 additions & 5 deletions layers/core_checks/cc_copy_blit_resolve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4164,6 +4164,7 @@ bool CoreChecks::PreCallValidateCmdCopyMemoryIndirectKHR(VkCommandBuffer command
const ErrorObject& error_obj) const {
bool skip = false;
auto cb_state = GetRead<vvl::CommandBuffer>(commandBuffer);
skip |= ValidateCmd(*cb_state, error_obj.location);

if (!enabled_features.indirectMemoryCopy) {
skip |= LogError("VUID-vkCmdCopyMemoryIndirectKHR-indirectMemoryCopy-10935", commandBuffer, error_obj.location,
Expand Down Expand Up @@ -4366,6 +4367,7 @@ bool CoreChecks::PreCallValidateCmdCopyMemoryToImageIndirectKHR(
const ErrorObject& error_obj) const {
bool skip = false;
auto cb_state = GetRead<vvl::CommandBuffer>(commandBuffer);
skip |= ValidateCmd(*cb_state, error_obj.location);

if (!enabled_features.indirectMemoryToImageCopy) {
skip |= LogError("VUID-vkCmdCopyMemoryToImageIndirectKHR-indirectMemoryToImageCopy-10947", commandBuffer,
Expand Down Expand Up @@ -4393,13 +4395,12 @@ bool CoreChecks::PreCallValidateCmdCopyMemoryToImageIndirectKHR(

// vkCmdCopyMemoryToImageKHR and vkCmdCopyImageToMemoryKHR (VK_KHR_device_address_commands)
// TODO - We duplciate logic to not add more complexity to the already over-complicated templated ValidateMemoryImageCopyCommon()
bool CoreChecks::ValidateCmdCopyMemoryToImage(VkCommandBuffer command_buffer,
bool CoreChecks::ValidateCmdCopyMemoryToImage(const vvl::CommandBuffer& cb_state,
const VkCopyDeviceMemoryImageInfoKHR& copy_memory_info,
const Location& info_loc) const {
bool skip = false;

auto cb_state_ptr = GetRead<vvl::CommandBuffer>(command_buffer);
const vvl::CommandBuffer& cb_state = *cb_state_ptr;
const VkCommandBuffer command_buffer = cb_state.VkHandle();

auto image_state = Get<vvl::Image>(copy_memory_info.image);
ASSERT_AND_RETURN_SKIP(image_state);
Expand Down Expand Up @@ -4580,19 +4581,28 @@ bool CoreChecks::ValidateCmdCopyMemoryToImage(VkCommandBuffer command_buffer,
bool CoreChecks::PreCallValidateCmdCopyMemoryToImageKHR(VkCommandBuffer commandBuffer,
const VkCopyDeviceMemoryImageInfoKHR* pCopyMemoryInfo,
const ErrorObject& error_obj) const {
return ValidateCmdCopyMemoryToImage(commandBuffer, *pCopyMemoryInfo, error_obj.location.dot(Field::pCopyMemoryInfo));
bool skip = false;
auto cb_state = GetRead<vvl::CommandBuffer>(commandBuffer);
skip |= ValidateCmd(*cb_state, error_obj.location);
skip |= ValidateCmdCopyMemoryToImage(*cb_state, *pCopyMemoryInfo, error_obj.location.dot(Field::pCopyMemoryInfo));
return skip;
}

bool CoreChecks::PreCallValidateCmdCopyImageToMemoryKHR(VkCommandBuffer commandBuffer,
const VkCopyDeviceMemoryImageInfoKHR* pCopyMemoryInfo,
const ErrorObject& error_obj) const {
return ValidateCmdCopyMemoryToImage(commandBuffer, *pCopyMemoryInfo, error_obj.location.dot(Field::pCopyMemoryInfo));
bool skip = false;
auto cb_state = GetRead<vvl::CommandBuffer>(commandBuffer);
skip |= ValidateCmd(*cb_state, error_obj.location);
skip |= ValidateCmdCopyMemoryToImage(*cb_state, *pCopyMemoryInfo, error_obj.location.dot(Field::pCopyMemoryInfo));
return skip;
}

bool CoreChecks::PreCallValidateCmdCopyMemoryKHR(VkCommandBuffer commandBuffer, const VkCopyDeviceMemoryInfoKHR* pCopyMemoryInfo,
const ErrorObject& error_obj) const {
bool skip = false;
auto cb_state = GetRead<vvl::CommandBuffer>(commandBuffer);
skip |= ValidateCmd(*cb_state, error_obj.location);
const Location info_loc = error_obj.location.dot(Field::pCopyMemoryInfo);

for (uint32_t i = 0; i < pCopyMemoryInfo->regionCount; ++i) {
Expand Down
2 changes: 2 additions & 0 deletions layers/core_checks/cc_device_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3276,6 +3276,7 @@ bool CoreChecks::PreCallValidateCmdDecompressMemoryEXT(VkCommandBuffer commandBu
const ErrorObject& error_obj) const {
bool skip = false;
auto cb_state = GetRead<vvl::CommandBuffer>(commandBuffer);
skip |= ValidateCmd(*cb_state, error_obj.location);
const LogObjectList objlist(cb_state->Handle());

const Location memory_info_loc = error_obj.location.dot(Field::pDecompressMemoryInfoEXT);
Expand Down Expand Up @@ -3327,6 +3328,7 @@ bool CoreChecks::PreCallValidateCmdDecompressMemoryIndirectCountEXT(VkCommandBuf
const ErrorObject& error_obj) const {
bool skip = false;
auto cb_state = GetRead<vvl::CommandBuffer>(commandBuffer);
skip |= ValidateCmd(*cb_state, error_obj.location);
const LogObjectList objlist(cb_state->Handle());

{
Expand Down
2 changes: 2 additions & 0 deletions layers/core_checks/cc_query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,8 @@ bool CoreChecks::PreCallValidateCmdCopyQueryPoolResultsToMemoryKHR(VkCommandBuff
bool skip = false;
if (disabled[query_validation]) return skip;
auto cb_state = GetRead<vvl::CommandBuffer>(commandBuffer);
skip |= ValidateCmd(*cb_state, error_obj.location);

const auto query_pool_state = Get<vvl::QueryPool>(queryPool);
ASSERT_AND_RETURN_SKIP(query_pool_state);

Expand Down
4 changes: 3 additions & 1 deletion layers/core_checks/core_validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -2605,7 +2605,7 @@ class CoreChecks : public vvl::DeviceProxy {
bool PreCallValidateCmdCopyMemoryToImageIndirectKHR(VkCommandBuffer commandBuffer,
const VkCopyMemoryToImageIndirectInfoKHR* pCopyMemoryToImageIndirectInfo,
const ErrorObject& error_obj) const override;
bool ValidateCmdCopyMemoryToImage(VkCommandBuffer commandBuffer, const VkCopyDeviceMemoryImageInfoKHR& copy_memory_info,
bool ValidateCmdCopyMemoryToImage(const vvl::CommandBuffer& cb_state, const VkCopyDeviceMemoryImageInfoKHR& copy_memory_info,
const Location& info_loc) const;
bool PreCallValidateCmdCopyMemoryToImageKHR(VkCommandBuffer commandBuffer,
const VkCopyDeviceMemoryImageInfoKHR* pCopyMemoryInfo,
Expand Down Expand Up @@ -2681,6 +2681,8 @@ class CoreChecks : public vvl::DeviceProxy {
const ErrorObject& error_obj) const override;
bool PreCallValidateCmdSetPrimitiveRestartEnable(VkCommandBuffer commandBuffer, VkBool32 primitiveRestartEnable,
const ErrorObject& error_obj) const override;
bool PreCallValidateCmdSetPrimitiveRestartIndexEXT(VkCommandBuffer commandBuffer, uint32_t primitiveRestartIndex,
const ErrorObject& error_obj) const override;

bool ValidateCmdSetCullMode(VkCommandBuffer commandBuffer, VkCullModeFlags cullMode, const ErrorObject& error_obj) const;
bool PreCallValidateCmdSetCullModeEXT(VkCommandBuffer commandBuffer, VkCullModeFlags cullMode,
Expand Down
18 changes: 18 additions & 0 deletions tests/unit/device_address.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -787,3 +787,21 @@ TEST_F(NegativeDeviceAddress, TransformFeedback) {
m_default_queue->SubmitAndWait(m_command_buffer);
m_errorMonitor->VerifyFound();
}

TEST_F(NegativeDeviceAddress, CmdCopyMemoryIndirectNotRecording) {
AddRequiredExtensions(VK_KHR_COPY_MEMORY_INDIRECT_EXTENSION_NAME);
AddRequiredFeature(vkt::Feature::indirectMemoryCopy);
AddRequiredFeature(vkt::Feature::bufferDeviceAddress);
RETURN_IF_SKIP(Init());

const VkDeviceSize copy_size = sizeof(VkCopyMemoryIndirectCommandKHR);
vkt::Buffer indirect_buffer(*m_device, copy_size, VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT, vkt::device_address);

VkCopyMemoryIndirectInfoKHR indirect_info = vku::InitStructHelper();
indirect_info.copyCount = 1u;
indirect_info.copyAddressRange = {indirect_buffer.Address(), copy_size, copy_size};

m_errorMonitor->SetDesiredError("VUID-vkCmdCopyMemoryIndirectKHR-commandBuffer-recording");
vk::CmdCopyMemoryIndirectKHR(m_command_buffer, &indirect_info);
m_errorMonitor->VerifyFound();
}
52 changes: 50 additions & 2 deletions tests/unit/device_address_commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ TEST_F(NegativeDeviceAddressCommands, ComputeQueueDepthAspect) {

RETURN_IF_SKIP(InitBasicDeviceAddressCommands());

auto compute_queue = m_device->QueueFamily(VK_QUEUE_COMPUTE_BIT, VK_QUEUE_GRAPHICS_BIT);
auto compute_queue = m_device->QueueFamily(VK_QUEUE_COMPUTE_BIT | VK_QUEUE_TRANSFER_BIT, VK_QUEUE_GRAPHICS_BIT);
if (!compute_queue.has_value()) {
GTEST_SKIP() << "Need a queue that supports compute but not graphics";
GTEST_SKIP() << "Need a queue that supports compute and transfer but not graphics";
}
vkt::CommandPool pool(*m_device, *compute_queue);
vkt::CommandBuffer cb(*m_device, pool);
Expand Down Expand Up @@ -374,6 +374,54 @@ TEST_F(NegativeDeviceAddressCommands, CmdUpdateMemoryUsage) {
m_command_buffer.End();
}

TEST_F(NegativeDeviceAddressCommands, Recording) {
AddRequiredFeature(vkt::Feature::dynamicRendering);
RETURN_IF_SKIP(InitBasicDeviceAddressCommands());

vkt::Buffer buffer(*m_device, 256u, VK_BUFFER_USAGE_TRANSFER_DST_BIT, vkt::device_address);
const VkDeviceAddressRangeKHR range = buffer.AddressRange();

{
m_errorMonitor->SetDesiredError("VUID-vkCmdFillMemoryKHR-commandBuffer-recording");
vk::CmdFillMemoryKHR(m_command_buffer, &range, 0u, 0u);
m_errorMonitor->VerifyFound();
}

{
vkt::Image image(*m_device, 4u, 4u, VK_FORMAT_R8G8B8A8_UNORM, VK_IMAGE_USAGE_TRANSFER_SRC_BIT);

VkDeviceMemoryImageCopyKHR region = vku::InitStructHelper();
region.addressRange = buffer.AddressRange();
region.imageSubresource = {VK_IMAGE_ASPECT_COLOR_BIT, 0, 0, 1};
region.imageLayout = VK_IMAGE_LAYOUT_GENERAL;
region.imageExtent = {4u, 4u, 1u};
VkCopyDeviceMemoryImageInfoKHR copy_memory_info = vku::InitStructHelper();
copy_memory_info.image = image;
copy_memory_info.regionCount = 1u;
copy_memory_info.pRegions = &region;

m_errorMonitor->SetDesiredError("VUID-vkCmdCopyImageToMemoryKHR-commandBuffer-recording");
vk::CmdCopyImageToMemoryKHR(m_command_buffer, &copy_memory_info);
m_errorMonitor->VerifyFound();
}

{
const uint32_t data = 255;

VkRenderingInfo suspend_info = vku::InitStructHelper();
suspend_info.flags = VK_RENDERING_SUSPENDING_BIT;
suspend_info.layerCount = 1;
suspend_info.renderArea = {{0, 0}, {1, 1}};

m_command_buffer.Begin();
m_command_buffer.BeginRendering(suspend_info);
m_command_buffer.EndRendering();
m_errorMonitor->SetDesiredError("VUID-vkCmdUpdateMemoryKHR-suspended");
vk::CmdUpdateMemoryKHR(m_command_buffer, &range, 0u, sizeof(data), &data);
m_errorMonitor->VerifyFound();
}
}

TEST_F(NegativeDeviceAddressCommands, CmdUpdateMemoryAlignmentAndSize) {
RETURN_IF_SKIP(InitBasicDeviceAddressCommands());

Expand Down
33 changes: 33 additions & 0 deletions tests/unit/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,39 @@ TEST_F(NegativeMemory, MemoryDecompressionSrcAddressOutOfRange) {
m_command_buffer.End();
}

TEST_F(NegativeMemory, MemoryDecompressionNotRecording) {
AddRequiredExtensions(VK_EXT_MEMORY_DECOMPRESSION_EXTENSION_NAME);
AddRequiredExtensions(VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME);
AddRequiredFeature(vkt::Feature::memoryDecompression);
AddRequiredFeature(vkt::Feature::bufferDeviceAddress);
RETURN_IF_SKIP(Init());
VkPhysicalDeviceMemoryDecompressionPropertiesEXT props = vku::InitStructHelper();
GetPhysicalDeviceProperties2(props);
if ((props.decompressionMethods & VK_MEMORY_DECOMPRESSION_METHOD_GDEFLATE_1_0_BIT_EXT) == 0) {
GTEST_SKIP() << "GDeflate decompression method not supported";
}

VkBufferUsageFlags2CreateInfo usage2 = vku::InitStructHelper();
usage2.usage = VK_BUFFER_USAGE_2_MEMORY_DECOMPRESSION_BIT_EXT;
vkt::Buffer src_buffer(*m_device, 64u, usage2, vkt::device_address);
vkt::Buffer dst_buffer(*m_device, 64u, usage2, vkt::device_address);

VkDecompressMemoryRegionEXT region = {};
region.srcAddress = src_buffer.Address();
region.dstAddress = dst_buffer.Address();
region.compressedSize = 64u;
region.decompressedSize = 64u;

VkDecompressMemoryInfoEXT decompress_info = vku::InitStructHelper();
decompress_info.decompressionMethod = VK_MEMORY_DECOMPRESSION_METHOD_GDEFLATE_1_0_BIT_EXT;
decompress_info.regionCount = 1;
decompress_info.pRegions = &region;

m_errorMonitor->SetDesiredError("VUID-vkCmdDecompressMemoryEXT-commandBuffer-recording");
vk::CmdDecompressMemoryEXT(m_command_buffer, &decompress_info);
m_errorMonitor->VerifyFound();
}

TEST_F(NegativeMemory, MapMemory) {
RETURN_IF_SKIP(Init());

Expand Down
Loading