Skip to content
This repository has been archived by the owner on Jul 19, 2018. It is now read-only.

Commit

Permalink
layers: Fixes from PR #2566
Browse files Browse the repository at this point in the history
  • Loading branch information
eskilsund authored and jzulauf-lunarg committed Apr 23, 2018
1 parent af1115e commit 5de1ff1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
20 changes: 10 additions & 10 deletions layers/core_validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1592,18 +1592,14 @@ static bool validateIdleDescriptorSetForPoolReset(const layer_data *dev_data, co
if (dev_data->instance_data->disabled.idle_descriptor_set) return false;
bool skip = false;
DESCRIPTOR_POOL_STATE *pPool = GetDescriptorPoolState(dev_data, pool);
for (auto ds : pPool->sets) {
if (ds != VK_NULL_HANDLE) {
auto set_node = dev_data->setMap.find(ds->GetSet());
if (set_node != dev_data->setMap.end()) {
if (set_node->second->in_use.load()) {
skip |=
log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
if (pPool != nullptr) {
for (auto ds : pPool->sets) {
if (ds && ds->in_use.load()) {
skip |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT,
VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT, HandleToUint64(pool), VALIDATION_ERROR_32a00272,
"It is invalid to call vkResetDescriptorPool() with descriptor sets in use by a command buffer. %s",
validation_error_map[VALIDATION_ERROR_32a00272]);
if (skip) break;
}
if (skip) break;
}
}
}
Expand Down Expand Up @@ -5759,16 +5755,20 @@ VKAPI_ATTR VkResult VKAPI_CALL CreateDescriptorPool(VkDevice device, const VkDes

VKAPI_ATTR VkResult VKAPI_CALL ResetDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool,
VkDescriptorPoolResetFlags flags) {
lock_guard_t lock(global_lock);
layer_data *dev_data = GetLayerDataPtr(get_dispatch_key(device), layer_data_map);

unique_lock_t lock(global_lock);
// Make sure sets being destroyed are not currently in-use
bool skip = validateIdleDescriptorSetForPoolReset(dev_data, descriptorPool);
lock.unlock();

if (skip) return VK_ERROR_VALIDATION_FAILED_EXT;

VkResult result = dev_data->dispatch_table.ResetDescriptorPool(device, descriptorPool, flags);
if (VK_SUCCESS == result) {
lock.lock();
clearDescriptorPool(dev_data, device, descriptorPool, flags);
lock.unlock();
}
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion layers/vk_validation_error_database.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3380,7 +3380,7 @@ VALIDATION_ERROR_32802801~^~Y~^~None~^~vkResetCommandPool~^~VUID-vkResetCommandP
VALIDATION_ERROR_32802807~^~Y~^~Unknown~^~vkResetCommandPool~^~VUID-vkResetCommandPool-commandPool-parent~^~core~^~The spec valid usage text states 'commandPool must have been created, allocated, or retrieved from device' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkResetCommandPool-commandPool-parent)~^~implicit
VALIDATION_ERROR_32805601~^~Y~^~None~^~vkResetCommandPool~^~VUID-vkResetCommandPool-device-parameter~^~core~^~The spec valid usage text states 'device must be a valid VkDevice handle' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkResetCommandPool-device-parameter)~^~implicit
VALIDATION_ERROR_32809001~^~Y~^~Unknown~^~vkResetCommandPool~^~VUID-vkResetCommandPool-flags-parameter~^~core~^~The spec valid usage text states 'flags must be a valid combination of VkCommandPoolResetFlagBits values' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkResetCommandPool-flags-parameter)~^~implicit, TBD in parameter validation layer.
VALIDATION_ERROR_32a00272~^~Y~^~Unknown~^~vkResetDescriptorPool~^~VUID-vkResetDescriptorPool-descriptorPool-00313~^~core~^~The spec valid usage text states 'All uses of descriptorPool (via any allocated descriptor sets) must have completed execution' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkResetDescriptorPool-descriptorPool-00313)~^~
VALIDATION_ERROR_32a00272~^~Y~^~DescriptorPoolInUseResetSignaled~^~vkResetDescriptorPool~^~VUID-vkResetDescriptorPool-descriptorPool-00313~^~core~^~The spec valid usage text states 'All uses of descriptorPool (via any allocated descriptor sets) must have completed execution' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkResetDescriptorPool-descriptorPool-00313)~^~
VALIDATION_ERROR_32a04601~^~Y~^~InvalidDescriptorPool~^~vkResetDescriptorPool~^~VUID-vkResetDescriptorPool-descriptorPool-parameter~^~core~^~The spec valid usage text states 'descriptorPool must be a valid VkDescriptorPool handle' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkResetDescriptorPool-descriptorPool-parameter)~^~implicit
VALIDATION_ERROR_32a04607~^~Y~^~Unknown~^~vkResetDescriptorPool~^~VUID-vkResetDescriptorPool-descriptorPool-parent~^~core~^~The spec valid usage text states 'descriptorPool must have been created, allocated, or retrieved from device' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkResetDescriptorPool-descriptorPool-parent)~^~implicit
VALIDATION_ERROR_32a05601~^~Y~^~None~^~vkResetDescriptorPool~^~VUID-vkResetDescriptorPool-device-parameter~^~core~^~The spec valid usage text states 'device must be a valid VkDevice handle' (https://www.khronos.org/registry/vulkan/specs/1.0/html/vkspec.html#VUID-vkResetDescriptorPool-device-parameter)~^~implicit
Expand Down
16 changes: 8 additions & 8 deletions tests/layer_validation_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8412,21 +8412,21 @@ TEST_F(VkLayerTest, DescriptorPoolInUseResetSignaled) {

VkDescriptorPoolCreateInfo ds_pool_ci = {};
ds_pool_ci.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
ds_pool_ci.pNext = NULL;
ds_pool_ci.pNext = nullptr;
ds_pool_ci.maxSets = 1;
ds_pool_ci.poolSizeCount = 1;
ds_pool_ci.pPoolSizes = &ds_type_count;

VkDescriptorPool ds_pool;
VkResult err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, NULL, &ds_pool);
VkResult err = vkCreateDescriptorPool(m_device->device(), &ds_pool_ci, nullptr, &ds_pool);
ASSERT_VK_SUCCESS(err);

VkDescriptorSetLayoutBinding dsl_binding = {};
dsl_binding.binding = 0;
dsl_binding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
dsl_binding.descriptorCount = 1;
dsl_binding.stageFlags = VK_SHADER_STAGE_ALL;
dsl_binding.pImmutableSamplers = NULL;
dsl_binding.pImmutableSamplers = nullptr;

const VkDescriptorSetLayoutObj ds_layout(m_device, {dsl_binding});

Expand All @@ -8450,7 +8450,7 @@ TEST_F(VkLayerTest, DescriptorPoolInUseResetSignaled) {
// Create Sampler
VkSamplerCreateInfo sampler_ci = SafeSaneSamplerCreateInfo();
VkSampler sampler;
err = vkCreateSampler(m_device->device(), &sampler_ci, NULL, &sampler);
err = vkCreateSampler(m_device->device(), &sampler_ci, nullptr, &sampler);
ASSERT_VK_SUCCESS(err);
// Update descriptor with image and sampler
VkDescriptorImageInfo img_info = {};
Expand All @@ -8467,7 +8467,7 @@ TEST_F(VkLayerTest, DescriptorPoolInUseResetSignaled) {
descriptor_write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
descriptor_write.pImageInfo = &img_info;

vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, NULL);
vkUpdateDescriptorSets(m_device->device(), 1, &descriptor_write, 0, nullptr);

// Create PSO to be used for draw-time errors below
char const *vsSource =
Expand Down Expand Up @@ -8496,7 +8496,7 @@ TEST_F(VkLayerTest, DescriptorPoolInUseResetSignaled) {
m_commandBuffer->BeginRenderPass(m_renderPassBeginInfo);
vkCmdBindPipeline(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipe.handle());
vkCmdBindDescriptorSets(m_commandBuffer->handle(), VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline_layout.handle(), 0, 1,
&descriptor_set, 0, NULL);
&descriptor_set, 0, nullptr);

VkViewport viewport = {0, 0, 16, 16, 0, 1};
VkRect2D scissor = {{0, 0}, {16, 16}};
Expand All @@ -8518,11 +8518,11 @@ TEST_F(VkLayerTest, DescriptorPoolInUseResetSignaled) {
m_errorMonitor->VerifyFound();
vkQueueWaitIdle(m_device->m_queue);
// Cleanup
vkDestroySampler(m_device->device(), sampler, NULL);
vkDestroySampler(m_device->device(), sampler, nullptr);
m_errorMonitor->SetUnexpectedError(
"If descriptorPool is not VK_NULL_HANDLE, descriptorPool must be a valid VkDescriptorPool handle");
m_errorMonitor->SetUnexpectedError("Unable to remove DescriptorPool obj");
vkDestroyDescriptorPool(m_device->device(), ds_pool, NULL);
vkDestroyDescriptorPool(m_device->device(), ds_pool, nullptr);
}

TEST_F(VkLayerTest, DescriptorImageUpdateNoMemoryBound) {
Expand Down

0 comments on commit 5de1ff1

Please sign in to comment.