From 494552b886620ef7cc27e9c201a2c9a5a3db74bf Mon Sep 17 00:00:00 2001 From: Yunchao He Date: Thu, 28 Mar 2019 10:57:41 +0000 Subject: [PATCH] Some small optimizations and style issues for input state Bug=dawn:107 Change-Id: I8ecfb39a2bff11b678bd8548ec0725ba061ef333 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6081 Commit-Queue: Kai Ninomiya Reviewed-by: Corentin Wallez Reviewed-by: Kai Ninomiya --- src/dawn_native/d3d12/RenderPipelineD3D12.cpp | 7 +------ src/dawn_native/metal/RenderPipelineMTL.mm | 6 +----- src/dawn_native/opengl/RenderPipelineGL.cpp | 8 ++------ src/tests/end2end/InputStateTests.cpp | 2 +- 4 files changed, 5 insertions(+), 18 deletions(-) diff --git a/src/dawn_native/d3d12/RenderPipelineD3D12.cpp b/src/dawn_native/d3d12/RenderPipelineD3D12.cpp index 046b7ae4ba..0b0aa06f9a 100644 --- a/src/dawn_native/d3d12/RenderPipelineD3D12.cpp +++ b/src/dawn_native/d3d12/RenderPipelineD3D12.cpp @@ -396,13 +396,8 @@ namespace dawn_native { namespace d3d12 { D3D12_INPUT_LAYOUT_DESC RenderPipeline::ComputeInputLayout( std::array* inputElementDescriptors) { - const auto& attributesSetMask = GetAttributesSetMask(); unsigned int count = 0; - for (auto i : IterateBitSet(attributesSetMask)) { - if (!attributesSetMask[i]) { - continue; - } - + for (auto i : IterateBitSet(GetAttributesSetMask())) { D3D12_INPUT_ELEMENT_DESC& inputElementDescriptor = (*inputElementDescriptors)[count++]; const VertexAttributeDescriptor& attribute = GetAttribute(i); diff --git a/src/dawn_native/metal/RenderPipelineMTL.mm b/src/dawn_native/metal/RenderPipelineMTL.mm index 5020a43a9b..65e9a1090a 100644 --- a/src/dawn_native/metal/RenderPipelineMTL.mm +++ b/src/dawn_native/metal/RenderPipelineMTL.mm @@ -365,11 +365,7 @@ namespace dawn_native { namespace metal { MTLVertexDescriptor* RenderPipeline::MakeVertexDesc() { MTLVertexDescriptor* mtlVertexDescriptor = [MTLVertexDescriptor new]; - const auto& attributesSetMask = GetAttributesSetMask(); - for (uint32_t i = 0; i < attributesSetMask.size(); ++i) { - if (!attributesSetMask[i]) { - continue; - } + for (uint32_t i : IterateBitSet(GetAttributesSetMask())) { const VertexAttributeDescriptor& info = GetAttribute(i); auto attribDesc = [MTLVertexAttributeDescriptor new]; diff --git a/src/dawn_native/opengl/RenderPipelineGL.cpp b/src/dawn_native/opengl/RenderPipelineGL.cpp index 991b02222c..f729370f8a 100644 --- a/src/dawn_native/opengl/RenderPipelineGL.cpp +++ b/src/dawn_native/opengl/RenderPipelineGL.cpp @@ -197,12 +197,8 @@ namespace dawn_native { namespace opengl { void RenderPipeline::CreateVAOForInputState(const InputStateDescriptor* inputState) { glGenVertexArrays(1, &mVertexArrayObject); glBindVertexArray(mVertexArrayObject); - auto& attributesSetMask = GetAttributesSetMask(); - for (uint32_t location = 0; location < attributesSetMask.size(); ++location) { - if (!attributesSetMask[location]) { - continue; - } - auto attribute = GetAttribute(location); + for (uint32_t location : IterateBitSet(GetAttributesSetMask())) { + const auto& attribute = GetAttribute(location); glEnableVertexAttribArray(location); attributesUsingInput[attribute.inputSlot][location] = true; diff --git a/src/tests/end2end/InputStateTests.cpp b/src/tests/end2end/InputStateTests.cpp index 87c2ac070a..f848601287 100644 --- a/src/tests/end2end/InputStateTests.cpp +++ b/src/tests/end2end/InputStateTests.cpp @@ -66,7 +66,7 @@ class InputStateTest : public DawnTest { }; dawn::RenderPipeline MakeTestPipeline(const dawn::InputStateDescriptor& inputState, int multiplier, - std::vector testSpec) { + const std::vector& testSpec) { std::ostringstream vs; vs << "#version 450\n";