return skip_call;
}
-// Create binding link between given iamge node and command buffer node
+// Create binding link between given sampler and command buffer node
+void AddCommandBufferBindingSampler(GLOBAL_CB_NODE *cb_node, SAMPLER_NODE *sampler_node) {
+ sampler_node->cb_bindings.insert(cb_node);
+ cb_node->object_bindings.insert({reinterpret_cast<uint64_t &>(sampler_node->sampler), VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT});
+}
+
+// Create binding link between given image node and command buffer node
static bool addCommandBufferBindingImage(layer_data *dev_data, GLOBAL_CB_NODE *cb_node, IMAGE_NODE *img_node, const char *apiName) {
bool skip_call = false;
// Skip validation if this image was created through WSI
return "query pool";
case VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT:
return "pipeline";
+ case VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT:
+ return "sampler";
default:
return "unknown";
}
set_node->RemoveBoundCommandBuffer(cb_node);
break;
}
+ case VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT: {
+ auto sampler_node = getSamplerNode(dev_data, reinterpret_cast<const VkSampler &>(object->handle));
+ if (sampler_node)
+ sampler_node->cb_bindings.erase(cb_node);
+ break;
+ }
default:
assert(0); // unhandled object type
}
}
break;
}
+ case VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT: {
+ auto sampler_node = getSamplerNode(dev_data, reinterpret_cast<VkSampler &>(obj.handle));
+ if (!sampler_node) {
+ skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT,
+ obj.handle, __LINE__, DRAWSTATE_INVALID_SAMPLER, "DS",
+ "Cannot submit cmd buffer using deleted sampler 0x%" PRIx64 ".", obj.handle);
+ } else {
+ sampler_node->in_use.fetch_add(1);
+ }
+ break;
+ }
default:
// TODO : Merge handling of other objects types into this code
break;
set_node->in_use.fetch_sub(1);
break;
}
+ case VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT: {
+ auto sampler_node = getSamplerNode(dev_data, reinterpret_cast<VkSampler &>(obj.handle));
+ sampler_node->in_use.fetch_sub(1);
+ break;
+ }
default:
// TODO : Merge handling of other objects types into this code
break;
VKAPI_ATTR void VKAPI_CALL
DestroySampler(VkDevice device, VkSampler sampler, const VkAllocationCallbacks *pAllocator) {
- // TODO : Clean up any internal data structures using this obj.
- get_my_data_ptr(get_dispatch_key(device), layer_data_map)->device_dispatch_table->DestroySampler(device, sampler, pAllocator);
+ layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
+ // TODO : Add detection for in-flight sampler
+ std::unique_lock<std::mutex> lock(global_lock);
+ auto sampler_node = getSamplerNode(dev_data, sampler);
+ if (sampler_node) {
+ // Any bound cmd buffers are now invalid
+ invalidateCommandBuffers(sampler_node->cb_bindings,
+ {reinterpret_cast<uint64_t &>(sampler), VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT});
+ dev_data->samplerMap.erase(sampler);
+ }
+ lock.unlock();
+ dev_data->device_dispatch_table->DestroySampler(device, sampler, pAllocator);
}
VKAPI_ATTR void VKAPI_CALL
DRAWSTATE_INVALID_QUERY, // Invalid Query
DRAWSTATE_INVALID_FENCE, // Invalid Fence
DRAWSTATE_INVALID_EVENT, // Invalid Event
+ DRAWSTATE_INVALID_SAMPLER, // Invalid Sampler
DRAWSTATE_VTX_INDEX_OUT_OF_BOUNDS, // binding in vkCmdBindVertexData() too
// large for PSO's
// pVertexBindingDescriptions array
};
};
-struct SAMPLER_NODE {
+struct SAMPLER_NODE : public BASE_NODE {
VkSampler sampler;
VkSamplerCreateInfo createInfo;
SWAPCHAIN_NODE *getSwapchainNode(const layer_data *, VkSwapchainKHR);
void invalidateCommandBuffers(std::unordered_set<GLOBAL_CB_NODE *>, VK_OBJECT);
bool ValidateMemoryIsBoundToBuffer(const layer_data *, const BUFFER_NODE *, const char *);
+void AddCommandBufferBindingSampler(GLOBAL_CB_NODE *, SAMPLER_NODE *);
}
#endif // CORE_VALIDATION_TYPES_H_
// check active descriptor slots based on last bound state for this CB
// For the active slots, use set# to look up descriptorSet from boundDescriptorSets, and bind all of that descriptor set's
// resources
+ for (auto binding : bindings) {
+ auto start_idx = p_layout_->GetGlobalStartIndexFromBinding(binding);
+ auto end_idx = p_layout_->GetGlobalEndIndexFromBinding(binding);
+ for (uint32_t i = start_idx; i <= end_idx; ++i) {
+ descriptors_[i]->BindCommandBuffer(device_data_, cb_node);
+ }
+ }
}
cvdescriptorset::SamplerDescriptor::SamplerDescriptor() : sampler_(VK_NULL_HANDLE), immutable_(false) {
updated = true;
}
+void cvdescriptorset::SamplerDescriptor::BindCommandBuffer(const core_validation::layer_data *dev_data, GLOBAL_CB_NODE *cb_node) {
+ if (!immutable_) {
+ auto sampler_node = getSamplerNode(dev_data, sampler_);
+ if (sampler_node)
+ core_validation::AddCommandBufferBindingSampler(cb_node, sampler_node);
+ }
+}
+
cvdescriptorset::ImageSamplerDescriptor::ImageSamplerDescriptor()
: sampler_(VK_NULL_HANDLE), immutable_(false), image_view_(VK_NULL_HANDLE), image_layout_(VK_IMAGE_LAYOUT_UNDEFINED) {
updated = false;
image_layout_ = image_layout;
}
+void cvdescriptorset::ImageSamplerDescriptor::BindCommandBuffer(const core_validation::layer_data *dev_data,
+ GLOBAL_CB_NODE *cb_node) {
+ if (!immutable_) {
+ auto sampler_node = getSamplerNode(dev_data, sampler_);
+ if (sampler_node)
+ core_validation::AddCommandBufferBindingSampler(cb_node, sampler_node);
+ }
+ // TODO : add cb_binding for image
+}
+
cvdescriptorset::ImageDescriptor::ImageDescriptor(const VkDescriptorType type)
: storage_(false), image_view_(VK_NULL_HANDLE), image_layout_(VK_IMAGE_LAYOUT_UNDEFINED) {
updated = false;
image_layout_ = image_layout;
}
+void cvdescriptorset::ImageDescriptor::BindCommandBuffer(const core_validation::layer_data *dev_data, GLOBAL_CB_NODE *cb_node) {
+ // TODO : bind image and cmd buffer
+}
+
cvdescriptorset::BufferDescriptor::BufferDescriptor(const VkDescriptorType type)
: storage_(false), dynamic_(false), buffer_(VK_NULL_HANDLE), offset_(0), range_(0) {
updated = false;
range_ = buff_desc->range_;
}
+void cvdescriptorset::BufferDescriptor::BindCommandBuffer(const core_validation::layer_data *dev_data, GLOBAL_CB_NODE *cb_node) {
+ // TODO : bind buffer and cmd buffer
+}
+
cvdescriptorset::TexelDescriptor::TexelDescriptor(const VkDescriptorType type) : buffer_view_(VK_NULL_HANDLE), storage_(false) {
updated = false;
descriptor_class = TexelBuffer;
updated = true;
buffer_view_ = static_cast<const TexelDescriptor *>(src)->buffer_view_;
}
+
+void cvdescriptorset::TexelDescriptor::BindCommandBuffer(const core_validation::layer_data *dev_data, GLOBAL_CB_NODE *cb_node) {
+ // TODO : bind buffer and cmd buffer
+}
+
// This is a helper function that iterates over a set of Write and Copy updates, pulls the DescriptorSet* for updated
// sets, and then calls their respective Validate[Write|Copy]Update functions.
// If the update hits an issue for which the callback returns "true", meaning that the call down the chain should
virtual ~Descriptor(){};
virtual void WriteUpdate(const VkWriteDescriptorSet *, const uint32_t) = 0;
virtual void CopyUpdate(const Descriptor *) = 0;
+ // Create binding between resources of this descriptor and given cb_node
+ virtual void BindCommandBuffer(const core_validation::layer_data *, GLOBAL_CB_NODE *) = 0;
virtual DescriptorClass GetClass() const { return descriptor_class; };
// Special fast-path check for SamplerDescriptors that are immutable
virtual bool IsImmutableSampler() const { return false; };
SamplerDescriptor(const VkSampler *);
void WriteUpdate(const VkWriteDescriptorSet *, const uint32_t) override;
void CopyUpdate(const Descriptor *) override;
+ void BindCommandBuffer(const core_validation::layer_data *, GLOBAL_CB_NODE *) override;
virtual bool IsImmutableSampler() const override { return immutable_; };
VkSampler GetSampler() const { return sampler_; }
ImageSamplerDescriptor(const VkSampler *);
void WriteUpdate(const VkWriteDescriptorSet *, const uint32_t) override;
void CopyUpdate(const Descriptor *) override;
+ void BindCommandBuffer(const core_validation::layer_data *, GLOBAL_CB_NODE *) override;
virtual bool IsImmutableSampler() const override { return immutable_; };
VkSampler GetSampler() const { return sampler_; }
VkImageView GetImageView() const { return image_view_; }
ImageDescriptor(const VkDescriptorType);
void WriteUpdate(const VkWriteDescriptorSet *, const uint32_t) override;
void CopyUpdate(const Descriptor *) override;
+ void BindCommandBuffer(const core_validation::layer_data *, GLOBAL_CB_NODE *) override;
virtual bool IsStorage() const override { return storage_; }
VkImageView GetImageView() const { return image_view_; }
VkImageLayout GetImageLayout() const { return image_layout_; }
TexelDescriptor(const VkDescriptorType);
void WriteUpdate(const VkWriteDescriptorSet *, const uint32_t) override;
void CopyUpdate(const Descriptor *) override;
+ void BindCommandBuffer(const core_validation::layer_data *, GLOBAL_CB_NODE *) override;
virtual bool IsStorage() const override { return storage_; }
VkBufferView GetBufferView() const { return buffer_view_; }
BufferDescriptor(const VkDescriptorType);
void WriteUpdate(const VkWriteDescriptorSet *, const uint32_t) override;
void CopyUpdate(const Descriptor *) override;
+ void BindCommandBuffer(const core_validation::layer_data *, GLOBAL_CB_NODE *) override;
virtual bool IsDynamic() const override { return dynamic_; }
virtual bool IsStorage() const override { return storage_; }
VkBuffer GetBuffer() const { return buffer_; }