From 2e91df7b21dab0b258e9d81282cb07d543e6d94a Mon Sep 17 00:00:00 2001 From: Bill Hollings Date: Fri, 22 May 2020 11:49:14 -0400 Subject: [PATCH] Use MVKSmallVector for pipeline stages. Remove getStages() from MVKPipeline and MVKComputePipeline, as it applies only to graphics pipelines. --- MoltenVK/MoltenVK/Commands/MVKCmdDraw.mm | 8 ++++---- MoltenVK/MoltenVK/GPUObjects/MVKPipeline.h | 14 +++++--------- MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm | 6 +----- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/MoltenVK/MoltenVK/Commands/MVKCmdDraw.mm b/MoltenVK/MoltenVK/Commands/MVKCmdDraw.mm index 26f833e6..14abfc7a 100644 --- a/MoltenVK/MoltenVK/Commands/MVKCmdDraw.mm +++ b/MoltenVK/MoltenVK/Commands/MVKCmdDraw.mm @@ -108,7 +108,7 @@ void MVKCmdDraw::encode(MVKCommandEncoder* cmdEncoder) { auto* pipeline = (MVKGraphicsPipeline*)cmdEncoder->_graphicsPipelineState.getPipeline(); - MVKVectorInline stages; + MVKPiplineStages stages; pipeline->getStages(stages); const MVKMTLBufferAllocation* vtxOutBuff = nullptr; @@ -302,7 +302,7 @@ void MVKCmdDrawIndexed::encode(MVKCommandEncoder* cmdEncoder) { auto* pipeline = (MVKGraphicsPipeline*)cmdEncoder->_graphicsPipelineState.getPipeline(); - MVKVectorInline stages; + MVKPiplineStages stages; pipeline->getStages(stages); MVKIndexMTLBufferBinding& ibb = cmdEncoder->_graphicsResourcesState._mtlIndexBufferBinding; @@ -588,7 +588,7 @@ void MVKCmdDrawIndirect::encode(MVKCommandEncoder* cmdEncoder) { } } - MVKVectorInline stages; + MVKPiplineStages stages; pipeline->getStages(stages); VkDeviceSize mtlIndBuffOfst = _mtlIndirectBufferOffset; @@ -816,7 +816,7 @@ void MVKCmdDrawIndexedIndirect::encode(MVKCommandEncoder* cmdEncoder) { tcIndexBuff = cmdEncoder->getTempMTLBuffer(patchCount * outControlPointCount * idxSize); } - MVKVectorInline stages; + MVKPiplineStages stages; pipeline->getStages(stages); VkDeviceSize mtlIndBuffOfst = _mtlIndirectBufferOffset; diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.h b/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.h index 14e1be2f..8f53dd5d 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.h +++ b/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.h @@ -22,7 +22,7 @@ #include "MVKDescriptorSet.h" #include "MVKShaderModule.h" #include "MVKSync.h" -#include "MVKVector.h" +#include "MVKSmallVector.h" #include #include #include @@ -143,9 +143,6 @@ public: /** Returns the debug report object type of this object. */ VkDebugReportObjectTypeEXT getVkDebugReportObjectType() override { return VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT; } - /** Returns the order of stages in this pipeline. Draws and dispatches must encode this pipeline once per stage. */ - virtual void getStages(MVKVector& stages) = 0; - /** Binds this pipeline to the specified command encoder. */ virtual void encode(MVKCommandEncoder* cmdEncoder, uint32_t stage = 0) = 0; @@ -187,6 +184,8 @@ protected: #pragma mark - #pragma mark MVKGraphicsPipeline +typedef MVKSmallVector MVKPiplineStages; + /** The number of dynamic states possible in Vulkan. */ static const uint32_t kMVKVkDynamicStateCount = 32; @@ -195,8 +194,8 @@ class MVKGraphicsPipeline : public MVKPipeline { public: - /** Returns the number and order of stages in this pipeline. Draws and dispatches must encode this pipeline once per stage. */ - void getStages(MVKVector& stages) override; + /** Returns the number and order of stages in this pipeline. Draws commands must encode this pipeline once per stage. */ + void getStages(MVKPiplineStages& stages); /** Binds this pipeline to the specified command encoder. */ void encode(MVKCommandEncoder* cmdEncoder, uint32_t stage = 0) override; @@ -316,9 +315,6 @@ class MVKComputePipeline : public MVKPipeline { public: - /** Returns the number and order of stages in this pipeline. Draws and dispatches must encode this pipeline once per stage. */ - void getStages(MVKVector& stages) override; - /** Binds this pipeline to the specified command encoder. */ void encode(MVKCommandEncoder* cmdEncoder, uint32_t = 0) override; diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm b/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm index 394b6dd7..912159ef 100644 --- a/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm +++ b/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm @@ -176,7 +176,7 @@ MVKPipeline::MVKPipeline(MVKDevice* device, MVKPipelineCache* pipelineCache, MVK #pragma mark - #pragma mark MVKGraphicsPipeline -void MVKGraphicsPipeline::getStages(MVKVector& stages) { +void MVKGraphicsPipeline::getStages(MVKPiplineStages& stages) { if (isTessellationPipeline()) { stages.push_back(kMVKGraphicsStageVertex); stages.push_back(kMVKGraphicsStageTessControl); @@ -1288,10 +1288,6 @@ MVKGraphicsPipeline::~MVKGraphicsPipeline() { #pragma mark - #pragma mark MVKComputePipeline -void MVKComputePipeline::getStages(MVKVector& stages) { - stages.push_back(0); -} - void MVKComputePipeline::encode(MVKCommandEncoder* cmdEncoder, uint32_t) { if ( !_hasValidMTLPipelineStates ) { return; }