diff options
| author | Chris Forbes <chrisforbes@google.com> | 2016-07-25 18:10:41 +1200 |
|---|---|---|
| committer | Chris Forbes <chrisforbes@google.com> | 2016-08-01 09:13:51 +1200 |
| commit | a003ab3d2d94bd93246b98a36ab42d2c72f084ee (patch) | |
| tree | a3637df857ab0470f88596df711c7b2fb2e8bef0 /layers | |
| parent | 40f0fc36c8bf1eb0bb0440b43d7b723134ef13c9 (diff) | |
| download | usermoji-a003ab3d2d94bd93246b98a36ab42d2c72f084ee.tar.xz | |
layers: Add plumbing for descriptor requirements
We want to be able to impose requirements on images & views bound to
descriptor sets based on their usage in the shader. This adds the
plumbing from pipelines into descriptor sets to enable that.
Signed-off-by: Chris Forbes <chrisforbes@google.com>
Diffstat (limited to 'layers')
| -rw-r--r-- | layers/core_validation.cpp | 15 | ||||
| -rw-r--r-- | layers/core_validation.h | 2 | ||||
| -rw-r--r-- | layers/descriptor_sets.cpp | 10 | ||||
| -rw-r--r-- | layers/descriptor_sets.h | 4 |
4 files changed, 20 insertions, 11 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 030f42c6..bbc2fe70 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -2603,6 +2603,12 @@ static bool validate_shader_capabilities(debug_report_data *report_data, shader_ return pass; } + +static uint32_t descriptor_type_to_reqs(shader_module const *module, uint32_t type_id) { + return 0; +} + + static bool validate_pipeline_shader_stage(debug_report_data *report_data, VkPipelineShaderStageCreateInfo const *pStage, PIPELINE_NODE *pipeline, @@ -2646,7 +2652,8 @@ static bool validate_pipeline_shader_stage(debug_report_data *report_data, /* validate descriptor use */ for (auto use : descriptor_uses) { // While validating shaders capture which slots are used by the pipeline - pipeline->active_slots[use.first.first].insert(use.first.second); + auto & reqs = pipeline->active_slots[use.first.first][use.first.second]; + reqs = descriptor_req(reqs | descriptor_type_to_reqs(module, use.second.type_id)); /* verify given pipelineLayout has requested setLayout with requested binding */ const auto &binding = get_descriptor_binding(&pipelineLayout, use.first); @@ -2782,7 +2789,7 @@ cvdescriptorset::DescriptorSet *getSetNode(const layer_data *my_data, VkDescript // 3. Grow updateBuffers for pCB to include buffers from STORAGE*_BUFFER descriptor buffers static bool validate_and_update_drawtime_descriptor_state( layer_data *dev_data, GLOBAL_CB_NODE *pCB, - const vector<std::tuple<cvdescriptorset::DescriptorSet *, unordered_set<uint32_t>, + const vector<std::tuple<cvdescriptorset::DescriptorSet *, unordered_map<uint32_t, descriptor_req>, std::vector<uint32_t> const *>> &activeSetBindingsPairs) { bool result = false; for (auto set_bindings_pair : activeSetBindingsPairs) { @@ -2965,7 +2972,7 @@ static bool validate_and_update_draw_state(layer_data *my_data, GLOBAL_CB_NODE * auto pipeline_layout = pPipe->pipeline_layout; // Need a vector (vs. std::set) of active Sets for dynamicOffset validation in case same set bound w/ different offsets - vector<std::tuple<cvdescriptorset::DescriptorSet *, unordered_set<uint32_t>, std::vector<uint32_t> const *>> activeSetBindingsPairs; + vector<std::tuple<cvdescriptorset::DescriptorSet *, unordered_map<uint32_t, descriptor_req>, std::vector<uint32_t> const *>> activeSetBindingsPairs; for (auto & setBindingPair : pPipe->active_slots) { uint32_t setIndex = setBindingPair.first; // If valid set is not bound throw an error @@ -2995,7 +3002,7 @@ static bool validate_and_update_draw_state(layer_data *my_data, GLOBAL_CB_NODE * // If it has immutable samplers, we'll flag error later as needed depending on binding if (!pSet->IsUpdated()) { for (auto binding : setBindingPair.second) { - if (!pSet->GetImmutableSamplerPtrFromBinding(binding)) { + if (!pSet->GetImmutableSamplerPtrFromBinding(binding.first)) { result |= log_msg( my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, (uint64_t)pSet->GetSet(), __LINE__, DRAWSTATE_DESCRIPTOR_SET_NOT_UPDATED, "DS", diff --git a/layers/core_validation.h b/layers/core_validation.h index 6a5a0a4d..e444dbc1 100644 --- a/layers/core_validation.h +++ b/layers/core_validation.h @@ -134,7 +134,7 @@ class PIPELINE_NODE : public BASE_NODE { uint32_t active_shaders; uint32_t duplicate_shaders; // Capture which slots (set#->bindings) are actually used by the shaders of this pipeline - std::unordered_map<uint32_t, std::unordered_set<uint32_t>> active_slots; + std::unordered_map<uint32_t, std::unordered_map<uint32_t, descriptor_req>> active_slots; // Vtx input info (if any) std::vector<VkVertexInputBindingDescription> vertexBindingDescriptions; std::vector<VkVertexInputAttributeDescription> vertexAttributeDescriptions; diff --git a/layers/descriptor_sets.cpp b/layers/descriptor_sets.cpp index a149485f..b3a49670 100644 --- a/layers/descriptor_sets.cpp +++ b/layers/descriptor_sets.cpp @@ -335,10 +335,11 @@ bool cvdescriptorset::DescriptorSet::IsCompatible(const DescriptorSetLayout *lay // This includes validating that all descriptors in the given bindings are updated, // that any update buffers are valid, and that any dynamic offsets are within the bounds of their buffers. // Return true if state is acceptable, or false and write an error message into error string -bool cvdescriptorset::DescriptorSet::ValidateDrawState(const std::unordered_set<uint32_t> &bindings, +bool cvdescriptorset::DescriptorSet::ValidateDrawState(const std::unordered_map<uint32_t, descriptor_req> &bindings, const std::vector<uint32_t> &dynamic_offsets, std::string *error) const { auto dyn_offset_index = 0; - for (auto binding : bindings) { + for (auto binding_pair : bindings) { + auto binding = binding_pair.first; if (!p_layout_->HasBinding(binding)) { std::stringstream error_str; error_str << "Attempting to validate DrawState for binding #" << binding @@ -417,11 +418,12 @@ bool cvdescriptorset::DescriptorSet::ValidateDrawState(const std::unordered_set< return true; } // For given bindings, place any update buffers or images into the passed-in unordered_sets -uint32_t cvdescriptorset::DescriptorSet::GetStorageUpdates(const std::unordered_set<uint32_t> &bindings, +uint32_t cvdescriptorset::DescriptorSet::GetStorageUpdates(const std::unordered_map<uint32_t, descriptor_req> &bindings, std::unordered_set<VkBuffer> *buffer_set, std::unordered_set<VkImageView> *image_set) const { auto num_updates = 0; - for (auto binding : bindings) { + for (auto binding_pair : bindings) { + auto binding = binding_pair.first; // If a binding doesn't exist, skip it if (!p_layout_->HasBinding(binding)) { continue; diff --git a/layers/descriptor_sets.h b/layers/descriptor_sets.h index e97850e9..d8222a60 100644 --- a/layers/descriptor_sets.h +++ b/layers/descriptor_sets.h @@ -313,10 +313,10 @@ class DescriptorSet : public BASE_NODE { // Is this set compatible with the given layout? bool IsCompatible(const DescriptorSetLayout *, std::string *) const; // For given bindings validate state at time of draw is correct, returning false on error and writing error details into string* - bool ValidateDrawState(const std::unordered_set<uint32_t> &, const std::vector<uint32_t> &, std::string *) const; + bool ValidateDrawState(const std::unordered_map<uint32_t, descriptor_req> &, const std::vector<uint32_t> &, std::string *) const; // For given set of bindings, add any buffers and images that will be updated to their respective unordered_sets & return number // of objects inserted - uint32_t GetStorageUpdates(const std::unordered_set<uint32_t> &, std::unordered_set<VkBuffer> *, + uint32_t GetStorageUpdates(const std::unordered_map<uint32_t, descriptor_req> &, std::unordered_set<VkBuffer> *, std::unordered_set<VkImageView> *) const; // Descriptor Update functions. These functions validate state and perform update separately |
