From 9812cc645dabc5e71b5fa5bffed61851e46973dd Mon Sep 17 00:00:00 2001 From: Tobin Ehlis Date: Wed, 16 Nov 2016 08:57:22 -0700 Subject: layers:Save memory requirements Add memory requirements member to the BINDABLE class and save memory requirements for images and buffers in their respective Get*MemoryRequirements() functions. --- layers/core_validation.cpp | 20 ++++++++++++-------- layers/core_validation_types.h | 6 ++++-- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index ea608367..ff340334 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -5957,18 +5957,22 @@ BindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory mem, VkDeviceS VKAPI_ATTR void VKAPI_CALL GetBufferMemoryRequirements(VkDevice device, VkBuffer buffer, VkMemoryRequirements *pMemoryRequirements) { - layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); - // TODO : What to track here? - // Could potentially save returned mem requirements and validate values passed into BindBufferMemory - my_data->dispatch_table.GetBufferMemoryRequirements(device, buffer, pMemoryRequirements); + layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); + dev_data->dispatch_table.GetBufferMemoryRequirements(device, buffer, pMemoryRequirements); + auto buffer_state = getBufferNode(dev_data, buffer); + if (buffer_state) { + buffer_state->requirements = *pMemoryRequirements; + } } VKAPI_ATTR void VKAPI_CALL GetImageMemoryRequirements(VkDevice device, VkImage image, VkMemoryRequirements *pMemoryRequirements) { - layer_data *my_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); - // TODO : What to track here? - // Could potentially save returned mem requirements and validate values passed into BindImageMemory - my_data->dispatch_table.GetImageMemoryRequirements(device, image, pMemoryRequirements); + layer_data *dev_data = get_my_data_ptr(get_dispatch_key(device), layer_data_map); + dev_data->dispatch_table.GetImageMemoryRequirements(device, image, pMemoryRequirements); + auto image_state = getImageState(dev_data, image); + if (image_state) { + image_state->requirements = *pMemoryRequirements; + } } static bool PreCallValidateDestroyImageView(layer_data *dev_data, VkImageView image_view, IMAGE_VIEW_STATE **image_view_state, diff --git a/layers/core_validation_types.h b/layers/core_validation_types.h index 8e6c5636..92401f8d 100644 --- a/layers/core_validation_types.h +++ b/layers/core_validation_types.h @@ -164,17 +164,19 @@ template <> struct hash { }; } -// Superclass for bindable object state (currently imagesa and buffers) +// Superclass for bindable object state (currently images and buffers) class BINDABLE : public BASE_NODE { public: bool sparse; // Is this object being bound with sparse memory or not? // Non-sparse binding data MEM_BINDING binding; + // Memory requirements for this BINDABLE + VkMemoryRequirements requirements; // Sparse binding data, initially just tracking MEM_BINDING per mem object // There's more data for sparse bindings so need better long-term solution // TODO : Need to update solution to track all sparse binding data std::unordered_set sparse_bindings; - BINDABLE() : sparse(false), binding{}, sparse_bindings{}{}; + BINDABLE() : sparse(false), binding{}, requirements{}, sparse_bindings{} {}; }; class BUFFER_NODE : public BINDABLE { -- cgit v1.2.3