aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/vk
diff options
context:
space:
mode:
authorGravatar Mike Klein <mtklein@google.com>2018-06-19 01:40:57 +0000
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-06-19 01:41:10 +0000
commit5045e501d2aec23e5f1e4b46346033ac3202c6b0 (patch)
treeb0179c300d6bc1822b0d945be812fff267bb414a /src/gpu/vk
parent63b3bfb711d7e3d4f9ad75681d77a69a3c454ab0 (diff)
Revert "Change how vertex/instance attributes are handled in geometry processors."
This reverts commit 19c1233c447f625c2522e7ecd0a0adecc629bb2f. Reason for revert: want to make sure Google3 can roll Original change's description: > Change how vertex/instance attributes are handled in geometry processors. > > * No longer register vertex/instance attributes on base class, just counts > > * Separate instance and vertex attributes and remove InputRate and offset > > * Make attributes constexpr where possible > > Change-Id: I1f1d5e772fa177a96d2aeb805aab7b69f35bfae6 > Reviewed-on: https://skia-review.googlesource.com/132405 > Commit-Queue: Brian Salomon <bsalomon@google.com> > Reviewed-by: Chris Dalton <csmartdalton@google.com> TBR=egdaniel@google.com,bsalomon@google.com,csmartdalton@google.com Change-Id: I4800632515e14fbf54af52826928ac915657b59f No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/135661 Reviewed-by: Mike Klein <mtklein@google.com> Commit-Queue: Mike Klein <mtklein@google.com>
Diffstat (limited to 'src/gpu/vk')
-rw-r--r--src/gpu/vk/GrVkPipeline.cpp80
1 files changed, 29 insertions, 51 deletions
diff --git a/src/gpu/vk/GrVkPipeline.cpp b/src/gpu/vk/GrVkPipeline.cpp
index c5b4592950..500ab967cc 100644
--- a/src/gpu/vk/GrVkPipeline.cpp
+++ b/src/gpu/vk/GrVkPipeline.cpp
@@ -59,67 +59,46 @@ static void setup_vertex_input_state(const GrPrimitiveProcessor& primProc,
VkVertexInputAttributeDescription* attributeDesc) {
uint32_t vertexBinding = 0, instanceBinding = 0;
- int nextBinding = bindingDescs->count();
- if (primProc.hasVertexAttributes()) {
- vertexBinding = nextBinding++;
- }
-
- if (primProc.hasInstanceAttributes()) {
- instanceBinding = nextBinding;
- }
-
- // setup attribute descriptions
- int vaCount = primProc.numVertexAttributes();
- int attribIndex = 0;
- size_t vertexAttributeOffset = 0;
- for (; attribIndex < vaCount; attribIndex++) {
- const GrGeometryProcessor::Attribute& attrib = primProc.vertexAttribute(attribIndex);
- VkVertexInputAttributeDescription& vkAttrib = attributeDesc[attribIndex];
- vkAttrib.location = attribIndex; // for now assume location = attribIndex
- vkAttrib.binding = vertexBinding;
- vkAttrib.format = attrib_type_to_vkformat(attrib.type());
- vkAttrib.offset = vertexAttributeOffset;
- SkASSERT(vkAttrib.offset == primProc.debugOnly_vertexAttributeOffset(attribIndex));
- vertexAttributeOffset += attrib.sizeAlign4();
- }
- SkASSERT(vertexAttributeOffset == primProc.debugOnly_vertexStride());
-
- int iaCount = primProc.numInstanceAttributes();
- size_t instanceAttributeOffset = 0;
- for (int iaIndex = 0; iaIndex < iaCount; ++iaIndex, ++attribIndex) {
- const GrGeometryProcessor::Attribute& attrib = primProc.instanceAttribute(iaIndex);
- VkVertexInputAttributeDescription& vkAttrib = attributeDesc[attribIndex];
- vkAttrib.location = attribIndex; // for now assume location = attribIndex
- vkAttrib.binding = instanceBinding;
- vkAttrib.format = attrib_type_to_vkformat(attrib.type());
- vkAttrib.offset = instanceAttributeOffset;
- SkASSERT(vkAttrib.offset == primProc.debugOnly_instanceAttributeOffset(iaIndex));
- instanceAttributeOffset += attrib.sizeAlign4();
- }
- SkASSERT(instanceAttributeOffset == primProc.debugOnly_instanceStride());
-
- if (primProc.hasVertexAttributes()) {
+ if (primProc.hasVertexAttribs()) {
+ vertexBinding = bindingDescs->count();
bindingDescs->push_back() = {
- vertexBinding,
- (uint32_t) vertexAttributeOffset,
- VK_VERTEX_INPUT_RATE_VERTEX
+ vertexBinding,
+ (uint32_t) primProc.getVertexStride(),
+ VK_VERTEX_INPUT_RATE_VERTEX
};
}
- if (primProc.hasInstanceAttributes()) {
+
+ if (primProc.hasInstanceAttribs()) {
+ instanceBinding = bindingDescs->count();
bindingDescs->push_back() = {
- instanceBinding,
- (uint32_t) instanceAttributeOffset,
- VK_VERTEX_INPUT_RATE_INSTANCE
+ instanceBinding,
+ (uint32_t) primProc.getInstanceStride(),
+ VK_VERTEX_INPUT_RATE_INSTANCE
};
}
+ // setup attribute descriptions
+ int vaCount = primProc.numAttribs();
+ if (vaCount > 0) {
+ for (int attribIndex = 0; attribIndex < vaCount; attribIndex++) {
+ using InputRate = GrPrimitiveProcessor::Attribute::InputRate;
+ const GrGeometryProcessor::Attribute& attrib = primProc.getAttrib(attribIndex);
+ VkVertexInputAttributeDescription& vkAttrib = attributeDesc[attribIndex];
+ vkAttrib.location = attribIndex; // for now assume location = attribIndex
+ vkAttrib.binding =
+ InputRate::kPerInstance == attrib.inputRate() ? instanceBinding : vertexBinding;
+ vkAttrib.format = attrib_type_to_vkformat(attrib.type());
+ vkAttrib.offset = attrib.offsetInRecord();
+ }
+ }
+
memset(vertexInputInfo, 0, sizeof(VkPipelineVertexInputStateCreateInfo));
vertexInputInfo->sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
vertexInputInfo->pNext = nullptr;
vertexInputInfo->flags = 0;
vertexInputInfo->vertexBindingDescriptionCount = bindingDescs->count();
vertexInputInfo->pVertexBindingDescriptions = bindingDescs->begin();
- vertexInputInfo->vertexAttributeDescriptionCount = vaCount + iaCount;
+ vertexInputInfo->vertexAttributeDescriptionCount = vaCount;
vertexInputInfo->pVertexAttributeDescriptions = attributeDesc;
}
@@ -453,9 +432,8 @@ GrVkPipeline* GrVkPipeline::Create(GrVkGpu* gpu, const GrPipeline& pipeline,
VkPipelineVertexInputStateCreateInfo vertexInputInfo;
SkSTArray<2, VkVertexInputBindingDescription, true> bindingDescs;
SkSTArray<16, VkVertexInputAttributeDescription> attributeDesc;
- int totalAttributeCnt = primProc.numVertexAttributes() + primProc.numInstanceAttributes();
- SkASSERT(totalAttributeCnt <= gpu->vkCaps().maxVertexAttributes());
- VkVertexInputAttributeDescription* pAttribs = attributeDesc.push_back_n(totalAttributeCnt);
+ SkASSERT(primProc.numAttribs() <= gpu->vkCaps().maxVertexAttributes());
+ VkVertexInputAttributeDescription* pAttribs = attributeDesc.push_back_n(primProc.numAttribs());
setup_vertex_input_state(primProc, &vertexInputInfo, &bindingDescs, pAttribs);
VkPipelineInputAssemblyStateCreateInfo inputAssemblyInfo;