diff --git a/src/gpu/vk/GrVkPipeline.cpp b/src/gpu/vk/GrVkPipeline.cpp index 8227e12cb1..0ba111af09 100644 --- a/src/gpu/vk/GrVkPipeline.cpp +++ b/src/gpu/vk/GrVkPipeline.cpp @@ -41,8 +41,7 @@ static void setup_vertex_input_state(const GrPrimitiveProcessor& primProc, VkPipelineVertexInputStateCreateInfo* vertexInputInfo, VkVertexInputBindingDescription* bindingDesc, int maxBindingDescCount, - VkVertexInputAttributeDescription* attributeDesc, - int maxAttributeDescCount) { + VkVertexInputAttributeDescription* attributeDesc) { // for now we have only one vertex buffer and one binding memset(bindingDesc, 0, sizeof(VkVertexInputBindingDescription)); bindingDesc->binding = 0; @@ -51,7 +50,6 @@ static void setup_vertex_input_state(const GrPrimitiveProcessor& primProc, // setup attribute descriptions int vaCount = primProc.numAttribs(); - SkASSERT(vaCount < maxAttributeDescCount); if (vaCount > 0) { size_t offset = 0; for (int attribIndex = 0; attribIndex < vaCount; attribIndex++) { @@ -417,11 +415,10 @@ GrVkPipeline* GrVkPipeline::Create(GrVkGpu* gpu, const GrPipeline& pipeline, VkPipelineCache cache) { VkPipelineVertexInputStateCreateInfo vertexInputInfo; VkVertexInputBindingDescription bindingDesc; - // TODO: allocate this based on VkPhysicalDeviceLimits::maxVertexInputAttributes - static const int kMaxVertexAttributes = 16; - static VkVertexInputAttributeDescription attributeDesc[kMaxVertexAttributes]; - setup_vertex_input_state(primProc, &vertexInputInfo, &bindingDesc, 1, - attributeDesc, kMaxVertexAttributes); + SkSTArray<16, VkVertexInputAttributeDescription> attributeDesc; + SkASSERT(primProc.numAttribs() <= gpu->vkCaps().maxVertexAttributes()); + VkVertexInputAttributeDescription* pAttribs = attributeDesc.push_back_n(primProc.numAttribs()); + setup_vertex_input_state(primProc, &vertexInputInfo, &bindingDesc, 1, pAttribs); VkPipelineInputAssemblyStateCreateInfo inputAssemblyInfo; setup_input_assembly_state(primitiveType, &inputAssemblyInfo); diff --git a/tests/PrimitiveProcessorTest.cpp b/tests/PrimitiveProcessorTest.cpp index 6d5be09c24..23ad13815a 100644 --- a/tests/PrimitiveProcessorTest.cpp +++ b/tests/PrimitiveProcessorTest.cpp @@ -101,7 +101,7 @@ private: }; } -DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) { +DEF_GPUTEST_FOR_ALL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) { GrContext* context = ctxInfo.grContext(); sk_sp drawContext(context->newDrawContext(SkBackingFit::kApprox,