From c0f31e73e481f32d308cb6232e75e6d860d97063 Mon Sep 17 00:00:00 2001 From: Yunchao He Date: Mon, 21 Jan 2019 08:29:01 +0000 Subject: [PATCH] Use const*const* to annotate a sequence of descriptors BUG=dawn:77 Change-Id: I2a523e54a06173c157730e043c25e9629887fd1f Reviewed-on: https://dawn-review.googlesource.com/c/3820 Commit-Queue: Corentin Wallez Reviewed-by: Corentin Wallez --- dawn.json | 2 +- examples/Animometer.cpp | 3 +- examples/CHelloTriangle.cpp | 3 +- examples/ComputeBoids.cpp | 3 +- examples/CppHelloTriangle.cpp | 3 +- examples/CubeReflection.cpp | 9 ++---- examples/glTFViewer/glTFViewer.cpp | 3 +- generator/main.py | 2 ++ generator/templates/dawn_wire/WireCmd.cpp | 30 ++++++++++++++----- src/dawn_native/RenderPipeline.cpp | 4 +-- src/tests/end2end/BindGroupTests.cpp | 10 +++---- src/tests/end2end/BlendStateTests.cpp | 12 +++----- src/tests/end2end/DrawIndexedTests.cpp | 3 +- src/tests/end2end/IndexFormatTests.cpp | 3 +- src/tests/end2end/InputStateTests.cpp | 3 +- src/tests/end2end/PrimitiveTopologyTests.cpp | 3 +- src/tests/end2end/SamplerTests.cpp | 3 +- src/tests/end2end/ScissorTests.cpp | 3 +- src/tests/end2end/TextureViewTests.cpp | 5 ++-- .../end2end/ViewportOrientationTests.cpp | 3 +- src/tests/unittests/WireTests.cpp | 3 +- .../validation/InputStateValidationTests.cpp | 3 +- src/utils/ComboRenderPipelineDescriptor.cpp | 3 +- src/utils/ComboRenderPipelineDescriptor.h | 5 +++- 24 files changed, 62 insertions(+), 62 deletions(-) diff --git a/dawn.json b/dawn.json index 6848bd8f02..271fd990c2 100644 --- a/dawn.json +++ b/dawn.json @@ -654,7 +654,7 @@ "extensible": true, "members": [ {"name": "num color attachments", "type": "uint32_t"}, - {"name": "color attachments", "type": "attachment descriptor", "annotation": "const*", "length": "num color attachments"}, + {"name": "color attachments", "type": "attachment descriptor", "annotation": "const*const*", "length": "num color attachments"}, {"name": "has depth stencil attachment", "type": "bool"}, {"name": "depth stencil attachment", "type": "attachment descriptor", "annotation":"const*"} ] diff --git a/examples/Animometer.cpp b/examples/Animometer.cpp index ff8b93d297..30f42f1a56 100644 --- a/examples/Animometer.cpp +++ b/examples/Animometer.cpp @@ -115,8 +115,7 @@ void init() { descriptor.cFragmentStage.module = fsModule; descriptor.cAttachmentsState.hasDepthStencilAttachment = true; descriptor.cDepthStencilAttachment.format = dawn::TextureFormat::D32FloatS8Uint; - descriptor.cColorAttachments[0].format = - GetPreferredSwapChainTextureFormat(); + descriptor.cColorAttachments[0]->format = GetPreferredSwapChainTextureFormat(); pipeline = device.CreateRenderPipeline(&descriptor); diff --git a/examples/CHelloTriangle.cpp b/examples/CHelloTriangle.cpp index 287a8ac58c..486f0d5dae 100644 --- a/examples/CHelloTriangle.cpp +++ b/examples/CHelloTriangle.cpp @@ -75,7 +75,8 @@ void init() { attachmentsState.nextInChain = nullptr; attachmentsState.numColorAttachments = 1; dawnAttachmentDescriptor colorAttachment = {nullptr, swapChainFormat}; - attachmentsState.colorAttachments = &colorAttachment; + dawnAttachmentDescriptor* colorAttachmentPtr[] = {&colorAttachment}; + attachmentsState.colorAttachments = colorAttachmentPtr; attachmentsState.hasDepthStencilAttachment = false; // Even with hasDepthStencilAttachment = false, depthStencilAttachment must point to valid // data because we don't have optional substructures yet. diff --git a/examples/ComputeBoids.cpp b/examples/ComputeBoids.cpp index 9c8c79ab79..ce5668c960 100644 --- a/examples/ComputeBoids.cpp +++ b/examples/ComputeBoids.cpp @@ -130,8 +130,7 @@ void initRender() { descriptor.inputState = inputState; descriptor.cAttachmentsState.hasDepthStencilAttachment = true; descriptor.cDepthStencilAttachment.format = dawn::TextureFormat::D32FloatS8Uint; - descriptor.cColorAttachments[0].format = - GetPreferredSwapChainTextureFormat(); + descriptor.cColorAttachments[0]->format = GetPreferredSwapChainTextureFormat(); renderPipeline = device.CreateRenderPipeline(&descriptor); } diff --git a/examples/CppHelloTriangle.cpp b/examples/CppHelloTriangle.cpp index 81cbea86ab..7aca392ce9 100644 --- a/examples/CppHelloTriangle.cpp +++ b/examples/CppHelloTriangle.cpp @@ -133,8 +133,7 @@ void init() { descriptor.inputState = inputState; descriptor.cAttachmentsState.hasDepthStencilAttachment = true; descriptor.cDepthStencilAttachment.format = dawn::TextureFormat::D32FloatS8Uint; - descriptor.cColorAttachments[0].format = - GetPreferredSwapChainTextureFormat(); + descriptor.cColorAttachments[0]->format = GetPreferredSwapChainTextureFormat(); pipeline = device.CreateRenderPipeline(&descriptor); diff --git a/examples/CubeReflection.cpp b/examples/CubeReflection.cpp index 1e70901eab..7266539b5e 100644 --- a/examples/CubeReflection.cpp +++ b/examples/CubeReflection.cpp @@ -200,8 +200,7 @@ void init() { descriptor.inputState = inputState; descriptor.cAttachmentsState.hasDepthStencilAttachment = true; descriptor.cDepthStencilAttachment.format = dawn::TextureFormat::D32FloatS8Uint; - descriptor.cColorAttachments[0].format = - GetPreferredSwapChainTextureFormat(); + descriptor.cColorAttachments[0]->format = GetPreferredSwapChainTextureFormat(); descriptor.cDepthStencilState.depthWriteEnabled = true; descriptor.cDepthStencilState.depthCompare = dawn::CompareFunction::Less; @@ -214,8 +213,7 @@ void init() { pDescriptor.inputState = inputState; pDescriptor.cAttachmentsState.hasDepthStencilAttachment = true; pDescriptor.cDepthStencilAttachment.format = dawn::TextureFormat::D32FloatS8Uint; - pDescriptor.cColorAttachments[0].format = - GetPreferredSwapChainTextureFormat(); + pDescriptor.cColorAttachments[0]->format = GetPreferredSwapChainTextureFormat(); pDescriptor.cDepthStencilState.front.passOp = dawn::StencilOperation::Replace; pDescriptor.cDepthStencilState.back.passOp = dawn::StencilOperation::Replace; pDescriptor.cDepthStencilState.depthCompare = dawn::CompareFunction::Less; @@ -229,8 +227,7 @@ void init() { rfDescriptor.inputState = inputState; rfDescriptor.cAttachmentsState.hasDepthStencilAttachment = true; rfDescriptor.cDepthStencilAttachment.format = dawn::TextureFormat::D32FloatS8Uint; - rfDescriptor.cColorAttachments[0].format = - GetPreferredSwapChainTextureFormat(); + rfDescriptor.cColorAttachments[0]->format = GetPreferredSwapChainTextureFormat(); pDescriptor.cDepthStencilState.front.compare = dawn::CompareFunction::Equal; pDescriptor.cDepthStencilState.back.compare = dawn::CompareFunction::Equal; pDescriptor.cDepthStencilState.front.passOp = dawn::StencilOperation::Replace; diff --git a/examples/glTFViewer/glTFViewer.cpp b/examples/glTFViewer/glTFViewer.cpp index 4e2b3fe330..acefd2a4b0 100644 --- a/examples/glTFViewer/glTFViewer.cpp +++ b/examples/glTFViewer/glTFViewer.cpp @@ -292,8 +292,7 @@ namespace { descriptor.indexFormat = dawn::IndexFormat::Uint16; descriptor.cAttachmentsState.hasDepthStencilAttachment = true; descriptor.cDepthStencilAttachment.format = dawn::TextureFormat::D32FloatS8Uint; - descriptor.cColorAttachments[0].format = - GetPreferredSwapChainTextureFormat(); + descriptor.cColorAttachments[0]->format = GetPreferredSwapChainTextureFormat(); descriptor.cDepthStencilState.depthWriteEnabled = true; descriptor.cDepthStencilState.depthCompare = dawn::CompareFunction::Less; diff --git a/generator/main.py b/generator/main.py index 59fd37dcc5..53e3068ce0 100644 --- a/generator/main.py +++ b/generator/main.py @@ -243,6 +243,8 @@ def decorate(name, typ, arg): return typ + ' ' + name elif arg.annotation == 'const*': return typ + ' const * ' + name + elif arg.annotation == 'const*const*': + return 'const ' + typ + '* const * ' + name else: assert(False) diff --git a/generator/templates/dawn_wire/WireCmd.cpp b/generator/templates/dawn_wire/WireCmd.cpp index 782cbd3d91..75ac7f4a22 100644 --- a/generator/templates/dawn_wire/WireCmd.cpp +++ b/generator/templates/dawn_wire/WireCmd.cpp @@ -51,12 +51,13 @@ {%- if member.type.category == "object" -%} {%- set Optional = "Optional" if member.optional else "" -%} {{out}} = provider.Get{{Optional}}Id({{in}}); - {%- elif member.type.category == "structure" -%} - {{as_cType(member.type.name)}}Serialize({{in}}, &{{out}}, buffer - {%- if member.type.has_dawn_object -%} - , provider - {%- endif -%} - ); + {% elif member.type.category == "structure"%} + {%- set Provider = ", provider" if member.type.has_dawn_object else "" -%} + {% if member.annotation == "const*const*" %} + {{as_cType(member.type.name)}}Serialize(*{{in}}, &{{out}}, buffer{{Provider}}); + {% else %} + {{as_cType(member.type.name)}}Serialize({{in}}, &{{out}}, buffer{{Provider}}); + {% endif %} {%- else -%} {{out}} = {{in}}; {%- endif -%} @@ -126,7 +127,11 @@ //* Structures might contain more pointers so we need to add their extra size as well. {% if member.type.category == "structure" %} for (size_t i = 0; i < memberLength; ++i) { - result += {{as_cType(member.type.name)}}GetExtraRequiredSize(record.{{as_varName(member.name)}}[i]); + {% if member.annotation == "const*const*" %} + result += {{as_cType(member.type.name)}}GetExtraRequiredSize(*record.{{as_varName(member.name)}}[i]); + {% else %} + result += {{as_cType(member.type.name)}}GetExtraRequiredSize(record.{{as_varName(member.name)}}[i]); + {% endif %} } {% endif %} } @@ -279,7 +284,16 @@ {{as_cType(member.type.name)}}* copiedMembers = nullptr; DESERIALIZE_TRY(GetSpace(allocator, memberLength, &copiedMembers)); - record->{{memberName}} = copiedMembers; + {% if member.annotation == "const*const*" %} + {{as_cType(member.type.name)}}** pointerArray = nullptr; + DESERIALIZE_TRY(GetSpace(allocator, memberLength, &pointerArray)); + for (size_t i = 0; i < memberLength; ++i) { + pointerArray[i] = &copiedMembers[i]; + } + record->{{memberName}} = pointerArray; + {% else %} + record->{{memberName}} = copiedMembers; + {% endif %} for (size_t i = 0; i < memberLength; ++i) { {{deserialize_member(member, "memberBuffer[i]", "copiedMembers[i]")}} diff --git a/src/dawn_native/RenderPipeline.cpp b/src/dawn_native/RenderPipeline.cpp index fc25d37cdd..8d2f5e9130 100644 --- a/src/dawn_native/RenderPipeline.cpp +++ b/src/dawn_native/RenderPipeline.cpp @@ -61,7 +61,7 @@ namespace dawn_native { } for (uint32_t i = 0; i < descriptor->numColorAttachments; ++i) { - dawn::TextureFormat format = descriptor->colorAttachments[i].format; + dawn::TextureFormat format = descriptor->colorAttachments[i]->format; DAWN_TRY(ValidateTextureFormat(format)); if (!IsColorRenderableTextureFormat(format)) { @@ -190,7 +190,7 @@ namespace dawn_native { for (uint32_t i = 0; i < descriptor->attachmentsState->numColorAttachments; ++i) { mColorAttachmentsSet.set(i); mBlendStates[i] = descriptor->blendStates[i]; - mColorAttachmentFormats[i] = descriptor->attachmentsState->colorAttachments[i].format; + mColorAttachmentFormats[i] = descriptor->attachmentsState->colorAttachments[i]->format; } // TODO(cwallez@chromium.org): Check against the shader module that the correct color diff --git a/src/tests/end2end/BindGroupTests.cpp b/src/tests/end2end/BindGroupTests.cpp index 7db8eda2a5..6676042f15 100644 --- a/src/tests/end2end/BindGroupTests.cpp +++ b/src/tests/end2end/BindGroupTests.cpp @@ -130,8 +130,7 @@ TEST_P(BindGroupTests, ReusedUBO) { textureDescriptor.layout = pipelineLayout; textureDescriptor.cVertexStage.module = vsModule; textureDescriptor.cFragmentStage.module = fsModule; - textureDescriptor.cColorAttachments[0].format = - renderPass.colorFormat; + textureDescriptor.cColorAttachments[0]->format = renderPass.colorFormat; dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&textureDescriptor); @@ -216,8 +215,7 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) { pipelineDescriptor.layout = pipelineLayout; pipelineDescriptor.cVertexStage.module = vsModule; pipelineDescriptor.cFragmentStage.module = fsModule; - pipelineDescriptor.cColorAttachments[0].format = - renderPass.colorFormat; + pipelineDescriptor.cColorAttachments[0]->format = renderPass.colorFormat; dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDescriptor); @@ -339,7 +337,7 @@ TEST_P(BindGroupTests, MultipleBindLayouts) { textureDescriptor.layout = pipelineLayout; textureDescriptor.cVertexStage.module = vsModule; textureDescriptor.cFragmentStage.module = fsModule; - textureDescriptor.cColorAttachments[0].format = renderPass.colorFormat; + textureDescriptor.cColorAttachments[0]->format = renderPass.colorFormat; dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&textureDescriptor); @@ -433,7 +431,7 @@ TEST_P(BindGroupTests, DrawTwiceInSamePipelineWithFourBindGroupSets) pipelineDescriptor.layout = pipelineLayout; pipelineDescriptor.cVertexStage.module = vsModule; pipelineDescriptor.cFragmentStage.module = fsModule; - pipelineDescriptor.cColorAttachments[0].format = renderPass.colorFormat; + pipelineDescriptor.cColorAttachments[0]->format = renderPass.colorFormat; dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDescriptor); dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder(); diff --git a/src/tests/end2end/BlendStateTests.cpp b/src/tests/end2end/BlendStateTests.cpp index c2ff4ff2eb..510b9d00b1 100644 --- a/src/tests/end2end/BlendStateTests.cpp +++ b/src/tests/end2end/BlendStateTests.cpp @@ -71,8 +71,7 @@ class BlendStateTest : public DawnTest { baseDescriptor.layout = pipelineLayout; baseDescriptor.cVertexStage.module = vsModule; baseDescriptor.cFragmentStage.module = fsModule; - baseDescriptor.cColorAttachments[0].format = - renderPass.colorFormat; + baseDescriptor.cColorAttachments[0]->format = renderPass.colorFormat; basePipeline = device.CreateRenderPipeline(&baseDescriptor); @@ -80,8 +79,7 @@ class BlendStateTest : public DawnTest { testDescriptor.layout = pipelineLayout; testDescriptor.cVertexStage.module = vsModule; testDescriptor.cFragmentStage.module = fsModule; - testDescriptor.cColorAttachments[0].format = - renderPass.colorFormat; + testDescriptor.cColorAttachments[0]->format = renderPass.colorFormat; testDescriptor.cBlendStates[0] = blendStateDescriptor; testPipeline = device.CreateRenderPipeline(&testDescriptor); @@ -867,8 +865,7 @@ TEST_P(BlendStateTest, DefaultBlendColor) { baseDescriptor.layout = pipelineLayout; baseDescriptor.cVertexStage.module = vsModule; baseDescriptor.cFragmentStage.module = fsModule; - baseDescriptor.cColorAttachments[0].format = - renderPass.colorFormat; + baseDescriptor.cColorAttachments[0]->format = renderPass.colorFormat; basePipeline = device.CreateRenderPipeline(&baseDescriptor); @@ -876,8 +873,7 @@ TEST_P(BlendStateTest, DefaultBlendColor) { testDescriptor.layout = pipelineLayout; testDescriptor.cVertexStage.module = vsModule; testDescriptor.cFragmentStage.module = fsModule; - testDescriptor.cColorAttachments[0].format = - renderPass.colorFormat; + testDescriptor.cColorAttachments[0]->format = renderPass.colorFormat; dawn::BlendDescriptor blend; blend.operation = dawn::BlendOperation::Add; diff --git a/src/tests/end2end/DrawIndexedTests.cpp b/src/tests/end2end/DrawIndexedTests.cpp index e6c969de6c..4d0701cd47 100644 --- a/src/tests/end2end/DrawIndexedTests.cpp +++ b/src/tests/end2end/DrawIndexedTests.cpp @@ -53,8 +53,7 @@ class DrawIndexedTest : public DawnTest { descriptor.primitiveTopology = dawn::PrimitiveTopology::TriangleStrip; descriptor.indexFormat = dawn::IndexFormat::Uint32; descriptor.inputState = inputState; - descriptor.cColorAttachments[0].format = - renderPass.colorFormat; + descriptor.cColorAttachments[0]->format = renderPass.colorFormat; pipeline = device.CreateRenderPipeline(&descriptor); diff --git a/src/tests/end2end/IndexFormatTests.cpp b/src/tests/end2end/IndexFormatTests.cpp index de1b980c37..4191862f30 100644 --- a/src/tests/end2end/IndexFormatTests.cpp +++ b/src/tests/end2end/IndexFormatTests.cpp @@ -58,8 +58,7 @@ class IndexFormatTest : public DawnTest { descriptor.primitiveTopology = dawn::PrimitiveTopology::TriangleStrip; descriptor.indexFormat = format; descriptor.inputState = inputState; - descriptor.cColorAttachments[0].format = - renderPass.colorFormat; + descriptor.cColorAttachments[0]->format = renderPass.colorFormat; return device.CreateRenderPipeline(&descriptor); } diff --git a/src/tests/end2end/InputStateTests.cpp b/src/tests/end2end/InputStateTests.cpp index 922702d443..180d8a89e6 100644 --- a/src/tests/end2end/InputStateTests.cpp +++ b/src/tests/end2end/InputStateTests.cpp @@ -125,8 +125,7 @@ class InputStateTest : public DawnTest { descriptor.cVertexStage.module = vsModule; descriptor.cFragmentStage.module = fsModule; descriptor.inputState = inputState; - descriptor.cColorAttachments[0].format = - renderPass.colorFormat; + descriptor.cColorAttachments[0]->format = renderPass.colorFormat; return device.CreateRenderPipeline(&descriptor); } diff --git a/src/tests/end2end/PrimitiveTopologyTests.cpp b/src/tests/end2end/PrimitiveTopologyTests.cpp index 85a5eec515..465f502cae 100644 --- a/src/tests/end2end/PrimitiveTopologyTests.cpp +++ b/src/tests/end2end/PrimitiveTopologyTests.cpp @@ -192,8 +192,7 @@ class PrimitiveTopologyTest : public DawnTest { descriptor.cFragmentStage.module = fsModule; descriptor.primitiveTopology = primitiveTopology; descriptor.inputState = inputState; - descriptor.cColorAttachments[0].format = - renderPass.colorFormat; + descriptor.cColorAttachments[0]->format = renderPass.colorFormat; dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor); diff --git a/src/tests/end2end/SamplerTests.cpp b/src/tests/end2end/SamplerTests.cpp index cf9847752d..550dde7511 100644 --- a/src/tests/end2end/SamplerTests.cpp +++ b/src/tests/end2end/SamplerTests.cpp @@ -77,8 +77,7 @@ protected: pipelineDescriptor.layout = pipelineLayout; pipelineDescriptor.cVertexStage.module = vsModule; pipelineDescriptor.cFragmentStage.module = fsModule; - pipelineDescriptor.cColorAttachments[0].format = - mRenderPass.colorFormat; + pipelineDescriptor.cColorAttachments[0]->format = mRenderPass.colorFormat; mPipeline = device.CreateRenderPipeline(&pipelineDescriptor); diff --git a/src/tests/end2end/ScissorTests.cpp b/src/tests/end2end/ScissorTests.cpp index e24392dd9d..010c56b1eb 100644 --- a/src/tests/end2end/ScissorTests.cpp +++ b/src/tests/end2end/ScissorTests.cpp @@ -40,8 +40,7 @@ class ScissorTest: public DawnTest { utils::ComboRenderPipelineDescriptor descriptor(device); descriptor.cVertexStage.module = vsModule; descriptor.cFragmentStage.module = fsModule; - descriptor.cColorAttachments[0].format = - format; + descriptor.cColorAttachments[0]->format = format; return device.CreateRenderPipeline(&descriptor); } diff --git a/src/tests/end2end/TextureViewTests.cpp b/src/tests/end2end/TextureViewTests.cpp index ffb9d725e2..072f5a3c54 100644 --- a/src/tests/end2end/TextureViewTests.cpp +++ b/src/tests/end2end/TextureViewTests.cpp @@ -172,8 +172,7 @@ protected: textureDescriptor.cVertexStage.module = mVSModule; textureDescriptor.cFragmentStage.module = fsModule; textureDescriptor.layout = mPipelineLayout; - textureDescriptor.cColorAttachments[0].format = - mRenderPass.colorFormat; + textureDescriptor.cColorAttachments[0]->format = mRenderPass.colorFormat; dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&textureDescriptor); @@ -517,7 +516,7 @@ class TextureViewRenderingTest : public DawnTest { utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); pipelineDescriptor.cVertexStage.module = vsModule; pipelineDescriptor.cFragmentStage.module = oneColorFsModule; - pipelineDescriptor.cColorAttachments[0].format = kDefaultFormat; + pipelineDescriptor.cColorAttachments[0]->format = kDefaultFormat; dawn::RenderPipeline oneColorPipeline = device.CreateRenderPipeline(&pipelineDescriptor); diff --git a/src/tests/end2end/ViewportOrientationTests.cpp b/src/tests/end2end/ViewportOrientationTests.cpp index ca6e8e24c2..cec9224312 100644 --- a/src/tests/end2end/ViewportOrientationTests.cpp +++ b/src/tests/end2end/ViewportOrientationTests.cpp @@ -40,8 +40,7 @@ TEST_P(ViewportOrientationTests, OriginAt0x0) { descriptor.cVertexStage.module = vsModule; descriptor.cFragmentStage.module = fsModule; descriptor.primitiveTopology = dawn::PrimitiveTopology::PointList; - descriptor.cColorAttachments[0].format = - renderPass.colorFormat; + descriptor.cColorAttachments[0]->format = renderPass.colorFormat; dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor); diff --git a/src/tests/unittests/WireTests.cpp b/src/tests/unittests/WireTests.cpp index 51baef2bf4..48db4e6a7b 100644 --- a/src/tests/unittests/WireTests.cpp +++ b/src/tests/unittests/WireTests.cpp @@ -404,7 +404,8 @@ TEST_F(WireTests, CStringArgument) { attachmentsState.nextInChain = nullptr; attachmentsState.numColorAttachments = 1; dawnAttachmentDescriptor colorAttachment = {nullptr, DAWN_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM}; - attachmentsState.colorAttachments = &colorAttachment; + dawnAttachmentDescriptor* colorAttachmentPtr[] = {&colorAttachment}; + attachmentsState.colorAttachments = colorAttachmentPtr; attachmentsState.hasDepthStencilAttachment = false; // Even with hasDepthStencilAttachment = false, depthStencilAttachment must point to valid // data because we don't have optional substructures yet. diff --git a/src/tests/unittests/validation/InputStateValidationTests.cpp b/src/tests/unittests/validation/InputStateValidationTests.cpp index 97ac1b8f4c..eb62128245 100644 --- a/src/tests/unittests/validation/InputStateValidationTests.cpp +++ b/src/tests/unittests/validation/InputStateValidationTests.cpp @@ -35,8 +35,7 @@ class InputStateTest : public ValidationTest { descriptor.cVertexStage.module = vsModule; descriptor.cFragmentStage.module = fsModule; descriptor.inputState = inputState; - descriptor.cColorAttachments[0].format = - renderpassData.attachmentFormat; + descriptor.cColorAttachments[0]->format = renderpassData.attachmentFormat; if (!success) { ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor)); diff --git a/src/utils/ComboRenderPipelineDescriptor.cpp b/src/utils/ComboRenderPipelineDescriptor.cpp index edbe01f4aa..8a07da165c 100644 --- a/src/utils/ComboRenderPipelineDescriptor.cpp +++ b/src/utils/ComboRenderPipelineDescriptor.cpp @@ -46,7 +46,8 @@ namespace utils { cAttachmentsState.hasDepthStencilAttachment = false; for (uint32_t i = 0; i < kMaxColorAttachments; ++i) { - cColorAttachments[i].format = dawn::TextureFormat::R8G8B8A8Unorm; + colorAttachments[i].format = dawn::TextureFormat::R8G8B8A8Unorm; + cColorAttachments[i] = &colorAttachments[i]; } } diff --git a/src/utils/ComboRenderPipelineDescriptor.h b/src/utils/ComboRenderPipelineDescriptor.h index 8acbdb57b6..5bd104f407 100644 --- a/src/utils/ComboRenderPipelineDescriptor.h +++ b/src/utils/ComboRenderPipelineDescriptor.h @@ -31,10 +31,13 @@ namespace utils { dawn::PipelineStageDescriptor cFragmentStage; dawn::AttachmentsStateDescriptor cAttachmentsState; - std::array cColorAttachments; + std::array cColorAttachments; dawn::AttachmentDescriptor cDepthStencilAttachment; std::array cBlendStates; dawn::DepthStencilStateDescriptor cDepthStencilState; + + private: + dawn::AttachmentDescriptor colorAttachments[kMaxColorAttachments]; }; } // namespace utils