Fix check for maxVertexAttributes in GrVkPipeline
BUG=skia:5461
GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2098933002
Review-Url: https://codereview.chromium.org/2098933002
diff --git a/src/gpu/vk/GrVkPipeline.cpp b/src/gpu/vk/GrVkPipeline.cpp
index 8227e12..0ba111a 100644
--- a/src/gpu/vk/GrVkPipeline.cpp
+++ b/src/gpu/vk/GrVkPipeline.cpp
@@ -41,8 +41,7 @@
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 @@
// 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 @@
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 6d5be09..23ad138 100644
--- a/tests/PrimitiveProcessorTest.cpp
+++ b/tests/PrimitiveProcessorTest.cpp
@@ -101,7 +101,7 @@
};
}
-DEF_GPUTEST_FOR_ALL_GL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) {
+DEF_GPUTEST_FOR_ALL_CONTEXTS(VertexAttributeCount, reporter, ctxInfo) {
GrContext* context = ctxInfo.grContext();
sk_sp<GrDrawContext> drawContext(context->newDrawContext(SkBackingFit::kApprox,