diff options
| author | Tobin Ehlis <tobine@google.com> | 2016-08-17 07:55:55 -0600 |
|---|---|---|
| committer | Tobin Ehlis <tobine@google.com> | 2016-08-23 18:39:23 -0600 |
| commit | d792291b8651a1cc90a3f97bb5f01b31535e638e (patch) | |
| tree | 41b830a97dc267d34b7cc2ed039ccad520425f19 /layers | |
| parent | 21d3a543c6ce34b97f6d51089459142102da7672 (diff) | |
| download | usermoji-d792291b8651a1cc90a3f97bb5f01b31535e638e.tar.xz | |
layers: Migrate PIPELINE_NODE to core_validation_types.h
Move PIPELINE_NODE struct to core_validation_types.h so that it's visible to
descriptorSet class. Update cmd buffer lastBound state to store ptr to
PIPELINE_NODE instead of VkPipeline which saves extra lookups.
Diffstat (limited to 'layers')
| -rw-r--r-- | layers/core_validation.cpp | 18 | ||||
| -rw-r--r-- | layers/core_validation.h | 72 | ||||
| -rw-r--r-- | layers/core_validation_types.h | 80 |
3 files changed, 85 insertions, 85 deletions
diff --git a/layers/core_validation.cpp b/layers/core_validation.cpp index 29d969b6..fef906ad 100644 --- a/layers/core_validation.cpp +++ b/layers/core_validation.cpp @@ -2959,16 +2959,16 @@ static bool validatePipelineDrawtimeState(layer_data const *my_data, "The Pipeline State Object (0x%" PRIxLEAST64 ") expects that this Command Buffer's vertex binding Index %u " "should be set via vkCmdBindVertexBuffers. This is because VkVertexInputBindingDescription struct " "at index " PRINTF_SIZE_T_SPECIFIER " of pVertexBindingDescriptions has a binding value of %u.", - (uint64_t)state.pipeline, vertex_binding, i, vertex_binding); + (uint64_t)state.pipeline_node->pipeline, vertex_binding, i, vertex_binding); } } } else { if (!pCB->currentDrawData.buffers.empty()) { skip_call |= log_msg(my_data->report_data, VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT, (VkDebugReportObjectTypeEXT)0, - 0, __LINE__, DRAWSTATE_VTX_INDEX_OUT_OF_BOUNDS, "DS", - "Vertex buffers are bound to command buffer (0x%" PRIxLEAST64 - ") but no vertex buffers are attached to this Pipeline State Object (0x%" PRIxLEAST64 ").", - (uint64_t)pCB->commandBuffer, (uint64_t)state.pipeline); + 0, __LINE__, DRAWSTATE_VTX_INDEX_OUT_OF_BOUNDS, "DS", + "Vertex buffers are bound to command buffer (0x%" PRIxLEAST64 + ") but no vertex buffers are attached to this Pipeline State Object (0x%" PRIxLEAST64 ").", + (uint64_t)pCB->commandBuffer, (uint64_t)state.pipeline_node->pipeline); } } // If Viewport or scissors are dynamic, verify that dynamic count matches PSO count. @@ -3087,7 +3087,7 @@ static bool validate_and_update_draw_state(layer_data *my_data, GLOBAL_CB_NODE * const VkPipelineBindPoint bindPoint, const char *function) { bool result = false; auto const &state = pCB->lastBound[bindPoint]; - PIPELINE_NODE *pPipe = getPipeline(my_data, state.pipeline); + PIPELINE_NODE *pPipe = state.pipeline_node; if (nullptr == pPipe) { result |= log_msg( my_data->report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VkDebugReportObjectTypeEXT(0), 0, __LINE__, @@ -4063,7 +4063,7 @@ static bool printPipeline(layer_data *my_data, const VkCommandBuffer cb) { bool skip_call = false; GLOBAL_CB_NODE *pCB = getCBNode(my_data, cb); if (pCB) { - PIPELINE_NODE *pPipeTrav = getPipeline(my_data, pCB->lastBound[VK_PIPELINE_BIND_POINT_GRAPHICS].pipeline); + PIPELINE_NODE *pPipeTrav = pCB->lastBound[VK_PIPELINE_BIND_POINT_GRAPHICS].pipeline_node; if (!pPipeTrav) { // nothing to print } else { @@ -6813,7 +6813,7 @@ CmdBindPipeline(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindP PIPELINE_NODE *pPN = getPipeline(dev_data, pipeline); if (pPN) { - pCB->lastBound[pipelineBindPoint].pipeline = pipeline; + pCB->lastBound[pipelineBindPoint].pipeline_node = pPN; set_cb_pso_status(pCB, pPN); set_pipeline_state(pPN); } else { @@ -6870,7 +6870,7 @@ VKAPI_ATTR void VKAPI_CALL CmdSetLineWidth(VkCommandBuffer commandBuffer, float skip_call |= addCmd(dev_data, pCB, CMD_SETLINEWIDTHSTATE, "vkCmdSetLineWidth()"); pCB->status |= CBSTATUS_LINE_WIDTH_SET; - PIPELINE_NODE *pPipeTrav = getPipeline(dev_data, pCB->lastBound[VK_PIPELINE_BIND_POINT_GRAPHICS].pipeline); + PIPELINE_NODE *pPipeTrav = pCB->lastBound[VK_PIPELINE_BIND_POINT_GRAPHICS].pipeline_node; if (pPipeTrav != NULL && !isDynamic(pPipeTrav, VK_DYNAMIC_STATE_LINE_WIDTH)) { skip_call |= log_msg(dev_data->report_data, VK_DEBUG_REPORT_WARNING_BIT_EXT, (VkDebugReportObjectTypeEXT)0, reinterpret_cast<uint64_t &>(commandBuffer), __LINE__, DRAWSTATE_INVALID_SET, "DS", diff --git a/layers/core_validation.h b/layers/core_validation.h index 5bfbe014..d7374f6c 100644 --- a/layers/core_validation.h +++ b/layers/core_validation.h @@ -50,7 +50,6 @@ #include "core_validation_types.h" #include "descriptor_sets.h" #include "vk_layer_logging.h" -#include "vk_safe_struct.h" #include "vulkan/vk_layer.h" #include <atomic> #include <functional> @@ -126,77 +125,6 @@ struct IMAGE_LAYOUT_NODE { VkFormat format; }; -class PIPELINE_NODE : public BASE_NODE { - public: - VkPipeline pipeline; - safe_VkGraphicsPipelineCreateInfo graphicsPipelineCI; - safe_VkComputePipelineCreateInfo computePipelineCI; - // Flag of which shader stages are active for this pipeline - 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_map<uint32_t, descriptor_req>> active_slots; - // Vtx input info (if any) - std::vector<VkVertexInputBindingDescription> vertexBindingDescriptions; - std::vector<VkVertexInputAttributeDescription> vertexAttributeDescriptions; - std::vector<VkPipelineColorBlendAttachmentState> attachments; - bool blendConstantsEnabled; // Blend constants enabled for any attachments - // Store RPCI b/c renderPass may be destroyed after Pipeline creation - safe_VkRenderPassCreateInfo render_pass_ci; - PIPELINE_LAYOUT_NODE pipeline_layout; - - // Default constructor - PIPELINE_NODE() - : pipeline{}, graphicsPipelineCI{}, computePipelineCI{}, active_shaders(0), duplicate_shaders(0), active_slots(), - vertexBindingDescriptions(), vertexAttributeDescriptions(), attachments(), blendConstantsEnabled(false), render_pass_ci(), - pipeline_layout() {} - - void initGraphicsPipeline(const VkGraphicsPipelineCreateInfo *pCreateInfo) { - graphicsPipelineCI.initialize(pCreateInfo); - // Make sure compute pipeline is null - VkComputePipelineCreateInfo emptyComputeCI = {}; - computePipelineCI.initialize(&emptyComputeCI); - for (uint32_t i = 0; i < pCreateInfo->stageCount; i++) { - const VkPipelineShaderStageCreateInfo *pPSSCI = &pCreateInfo->pStages[i]; - this->duplicate_shaders |= this->active_shaders & pPSSCI->stage; - this->active_shaders |= pPSSCI->stage; - } - if (pCreateInfo->pVertexInputState) { - const VkPipelineVertexInputStateCreateInfo *pVICI = pCreateInfo->pVertexInputState; - if (pVICI->vertexBindingDescriptionCount) { - this->vertexBindingDescriptions = std::vector<VkVertexInputBindingDescription>( - pVICI->pVertexBindingDescriptions, pVICI->pVertexBindingDescriptions + pVICI->vertexBindingDescriptionCount); - } - if (pVICI->vertexAttributeDescriptionCount) { - this->vertexAttributeDescriptions = std::vector<VkVertexInputAttributeDescription>( - pVICI->pVertexAttributeDescriptions, - pVICI->pVertexAttributeDescriptions + pVICI->vertexAttributeDescriptionCount); - } - } - if (pCreateInfo->pColorBlendState) { - const VkPipelineColorBlendStateCreateInfo *pCBCI = pCreateInfo->pColorBlendState; - if (pCBCI->attachmentCount) { - this->attachments = std::vector<VkPipelineColorBlendAttachmentState>(pCBCI->pAttachments, - pCBCI->pAttachments + pCBCI->attachmentCount); - } - } - } - void initComputePipeline(const VkComputePipelineCreateInfo *pCreateInfo) { - computePipelineCI.initialize(pCreateInfo); - // Make sure gfx pipeline is null - VkGraphicsPipelineCreateInfo emptyGraphicsCI = {}; - graphicsPipelineCI.initialize(&emptyGraphicsCI); - switch (computePipelineCI.stage.stage) { - case VK_SHADER_STAGE_COMPUTE_BIT: - this->active_shaders |= VK_SHADER_STAGE_COMPUTE_BIT; - break; - default: - // TODO : Flag error - break; - } - } -}; - class PHYS_DEV_PROPERTIES_NODE { public: VkPhysicalDeviceProperties properties; diff --git a/layers/core_validation_types.h b/layers/core_validation_types.h index ce786210..6ac0bd76 100644 --- a/layers/core_validation_types.h +++ b/layers/core_validation_types.h @@ -44,13 +44,14 @@ #define NOEXCEPT #endif +#include "vk_safe_struct.h" #include "vulkan/vulkan.h" #include <atomic> +#include <functional> #include <string.h> -#include <unordered_set> #include <unordered_map> +#include <unordered_set> #include <vector> -#include <functional> // Fwd declarations namespace cvdescriptorset { @@ -478,9 +479,80 @@ struct PIPELINE_LAYOUT_NODE { } }; +class PIPELINE_NODE : public BASE_NODE { + public: + VkPipeline pipeline; + safe_VkGraphicsPipelineCreateInfo graphicsPipelineCI; + safe_VkComputePipelineCreateInfo computePipelineCI; + // Flag of which shader stages are active for this pipeline + 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_map<uint32_t, descriptor_req>> active_slots; + // Vtx input info (if any) + std::vector<VkVertexInputBindingDescription> vertexBindingDescriptions; + std::vector<VkVertexInputAttributeDescription> vertexAttributeDescriptions; + std::vector<VkPipelineColorBlendAttachmentState> attachments; + bool blendConstantsEnabled; // Blend constants enabled for any attachments + // Store RPCI b/c renderPass may be destroyed after Pipeline creation + safe_VkRenderPassCreateInfo render_pass_ci; + PIPELINE_LAYOUT_NODE pipeline_layout; + + // Default constructor + PIPELINE_NODE() + : pipeline{}, graphicsPipelineCI{}, computePipelineCI{}, active_shaders(0), duplicate_shaders(0), active_slots(), + vertexBindingDescriptions(), vertexAttributeDescriptions(), attachments(), blendConstantsEnabled(false), render_pass_ci(), + pipeline_layout() {} + + void initGraphicsPipeline(const VkGraphicsPipelineCreateInfo *pCreateInfo) { + graphicsPipelineCI.initialize(pCreateInfo); + // Make sure compute pipeline is null + VkComputePipelineCreateInfo emptyComputeCI = {}; + computePipelineCI.initialize(&emptyComputeCI); + for (uint32_t i = 0; i < pCreateInfo->stageCount; i++) { + const VkPipelineShaderStageCreateInfo *pPSSCI = &pCreateInfo->pStages[i]; + this->duplicate_shaders |= this->active_shaders & pPSSCI->stage; + this->active_shaders |= pPSSCI->stage; + } + if (pCreateInfo->pVertexInputState) { + const VkPipelineVertexInputStateCreateInfo *pVICI = pCreateInfo->pVertexInputState; + if (pVICI->vertexBindingDescriptionCount) { + this->vertexBindingDescriptions = std::vector<VkVertexInputBindingDescription>( + pVICI->pVertexBindingDescriptions, pVICI->pVertexBindingDescriptions + pVICI->vertexBindingDescriptionCount); + } + if (pVICI->vertexAttributeDescriptionCount) { + this->vertexAttributeDescriptions = std::vector<VkVertexInputAttributeDescription>( + pVICI->pVertexAttributeDescriptions, + pVICI->pVertexAttributeDescriptions + pVICI->vertexAttributeDescriptionCount); + } + } + if (pCreateInfo->pColorBlendState) { + const VkPipelineColorBlendStateCreateInfo *pCBCI = pCreateInfo->pColorBlendState; + if (pCBCI->attachmentCount) { + this->attachments = std::vector<VkPipelineColorBlendAttachmentState>(pCBCI->pAttachments, + pCBCI->pAttachments + pCBCI->attachmentCount); + } + } + } + void initComputePipeline(const VkComputePipelineCreateInfo *pCreateInfo) { + computePipelineCI.initialize(pCreateInfo); + // Make sure gfx pipeline is null + VkGraphicsPipelineCreateInfo emptyGraphicsCI = {}; + graphicsPipelineCI.initialize(&emptyGraphicsCI); + switch (computePipelineCI.stage.stage) { + case VK_SHADER_STAGE_COMPUTE_BIT: + this->active_shaders |= VK_SHADER_STAGE_COMPUTE_BIT; + break; + default: + // TODO : Flag error + break; + } + } +}; + // Track last states that are bound per pipeline bind point (Gfx & Compute) struct LAST_BOUND_STATE { - VkPipeline pipeline; + PIPELINE_NODE *pipeline_node; PIPELINE_LAYOUT_NODE pipeline_layout; // Track each set that has been bound // Ordered bound set tracking where index is set# that given set is bound to @@ -489,7 +561,7 @@ struct LAST_BOUND_STATE { std::vector<std::vector<uint32_t>> dynamicOffsets; void reset() { - pipeline = VK_NULL_HANDLE; + pipeline_node = nullptr; pipeline_layout.reset(); boundDescriptorSets.clear(); dynamicOffsets.clear(); |
