Create BUFFER_VIEW_STATE class to hold VkBufferViewCreateInfo and update related
state tracking. This class derives from BASE_NODE in preparation for tracking
in_use for BufferViews consistent to other object in_use tracking.
unordered_map<VkSampler, unique_ptr<SAMPLER_NODE>> samplerMap;
unordered_map<VkImageView, unique_ptr<IMAGE_VIEW_STATE>> imageViewMap;
unordered_map<VkImage, unique_ptr<IMAGE_NODE>> imageMap;
- unordered_map<VkBufferView, unique_ptr<VkBufferViewCreateInfo>> bufferViewMap;
+ unordered_map<VkBufferView, unique_ptr<BUFFER_VIEW_STATE>> bufferViewMap;
unordered_map<VkBuffer, unique_ptr<BUFFER_NODE>> bufferMap;
unordered_map<VkPipeline, PIPELINE_NODE *> pipelineMap;
unordered_map<VkCommandPool, COMMAND_POOL_NODE> commandPoolMap;
return img_it->second;
}
// Return buffer node ptr for specified buffer or else NULL
-VkBufferViewCreateInfo *getBufferViewInfo(const layer_data *my_data, VkBufferView buffer_view) {
+BUFFER_VIEW_STATE *getBufferViewState(const layer_data *my_data, VkBufferView buffer_view) {
auto bv_it = my_data->bufferViewMap.find(buffer_view);
if (bv_it == my_data->bufferViewMap.end()) {
return nullptr;
layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map);
std::unique_lock<std::mutex> lock(global_lock);
- auto item = dev_data->bufferViewMap.find(bufferView);
- if (item != dev_data->bufferViewMap.end()) {
- dev_data->bufferViewMap.erase(item);
+ auto view_state = getBufferViewState(dev_data, bufferView);
+ if (view_state) {
+ dev_data->bufferViewMap.erase(bufferView);
}
lock.unlock();
dev_data->device_dispatch_table->DestroyBufferView(device, bufferView, pAllocator);
VkResult result = dev_data->device_dispatch_table->CreateBufferView(device, pCreateInfo, pAllocator, pView);
if (VK_SUCCESS == result) {
lock.lock();
- dev_data->bufferViewMap[*pView] = unique_ptr<VkBufferViewCreateInfo>(new VkBufferViewCreateInfo(*pCreateInfo));
+ dev_data->bufferViewMap[*pView] = unique_ptr<BUFFER_VIEW_STATE>(new BUFFER_VIEW_STATE(*pView, pCreateInfo));
lock.unlock();
}
return result;
createInfo(rh_obj.createInfo){};
};
+class BUFFER_VIEW_STATE : public BASE_NODE {
+ public:
+ using BASE_NODE::in_use;
+ VkBufferView buffer_view;
+ VkBufferViewCreateInfo create_info;
+ BUFFER_VIEW_STATE() : buffer_view(VK_NULL_HANDLE), create_info{} {};
+ BUFFER_VIEW_STATE(VkBufferView bv, const VkBufferViewCreateInfo *ci) : buffer_view(bv), create_info(*ci){};
+ BUFFER_VIEW_STATE(const BUFFER_VIEW_STATE &rh_obj) : buffer_view(rh_obj.buffer_view), create_info(rh_obj.create_info) {
+ in_use.store(rh_obj.in_use.load());
+ };
+};
+
struct SAMPLER_NODE : public BASE_NODE {
VkSampler sampler;
VkSamplerCreateInfo createInfo;
BUFFER_NODE *getBufferNode(const layer_data *, VkBuffer);
IMAGE_NODE *getImageNode(const layer_data *, VkImage);
DEVICE_MEM_INFO *getMemObjInfo(const layer_data *, VkDeviceMemory);
-VkBufferViewCreateInfo *getBufferViewInfo(const layer_data *, VkBufferView);
+BUFFER_VIEW_STATE *getBufferViewState(const layer_data *, VkBufferView);
SAMPLER_NODE *getSamplerNode(const layer_data *, VkSampler);
IMAGE_VIEW_STATE *getImageViewState(const layer_data *, VkImageView);
VkSwapchainKHR getSwapchainFromImage(const layer_data *, VkImage);
for (uint32_t i = 0; i < p_layout_->GetDescriptorCountFromBinding(binding); ++i) {
if (descriptors_[start_idx + i]->updated) {
auto bufferview = static_cast<TexelDescriptor *>(descriptors_[start_idx + i].get())->GetBufferView();
- auto bv_info = getBufferViewInfo(device_data_, bufferview);
- if (bv_info) {
- buffer_set->insert(bv_info->buffer);
+ auto bv_state = getBufferViewState(device_data_, bufferview);
+ if (bv_state) {
+ buffer_set->insert(bv_state->create_info.buffer);
num_updates++;
}
}
}
void cvdescriptorset::TexelDescriptor::BindCommandBuffer(const core_validation::layer_data *dev_data, GLOBAL_CB_NODE *cb_node) {
- auto bv_info = getBufferViewInfo(dev_data, buffer_view_);
- if (bv_info) {
- auto buffer_node = getBufferNode(dev_data, bv_info->buffer);
+ auto bv_state = getBufferViewState(dev_data, buffer_view_);
+ if (bv_state) {
+ auto buffer_node = getBufferNode(dev_data, bv_state->create_info.buffer);
if (buffer_node)
core_validation::AddCommandBufferBindingBuffer(dev_data, cb_node, buffer_node);
}
case VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER: {
for (uint32_t di = 0; di < update->descriptorCount; ++di) {
auto buffer_view = update->pTexelBufferView[di];
- auto bv_info = getBufferViewInfo(device_data_, buffer_view);
- if (!bv_info) {
+ auto bv_state = getBufferViewState(device_data_, buffer_view);
+ if (!bv_state) {
std::stringstream error_str;
error_str << "Attempted write update to texel buffer descriptor with invalid buffer view: " << buffer_view;
*error = error_str.str();
return false;
}
- auto buffer = bv_info->buffer;
+ auto buffer = bv_state->create_info.buffer;
if (!ValidateBufferUsage(getBufferNode(device_data_, buffer), update->descriptorType, error)) {
std::stringstream error_str;
error_str << "Attempted write update to texel buffer descriptor failed due to: " << error->c_str();
case TexelBuffer: {
for (uint32_t di = 0; di < update->descriptorCount; ++di) {
auto buffer_view = static_cast<TexelDescriptor *>(src_set->descriptors_[index + di].get())->GetBufferView();
- auto bv_info = getBufferViewInfo(device_data_, buffer_view);
- if (!bv_info) {
+ auto bv_state = getBufferViewState(device_data_, buffer_view);
+ if (!bv_state) {
std::stringstream error_str;
error_str << "Attempted copy update to texel buffer descriptor with invalid buffer view: " << buffer_view;
*error = error_str.str();
return false;
}
- auto buffer = bv_info->buffer;
+ auto buffer = bv_state->create_info.buffer;
if (!ValidateBufferUsage(getBufferNode(device_data_, buffer), type, error)) {
std::stringstream error_str;
error_str << "Attempted copy update to texel buffer descriptor failed due to: " << error->c_str();