From c81a7173790b527e06d5c9376ebe053ca8fd643a Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Fri, 20 Sep 2019 23:22:27 +0000 Subject: [PATCH] Remove indirection for colorStates This is to match the work in progress webgpu.h header. BUG=dawn:22 Change-Id: Ia1077fef95e6bda541cddbd2f6ce40b79138e960 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9383 Commit-Queue: Corentin Wallez Reviewed-by: Austin Eng Reviewed-by: Kai Ninomiya --- dawn.json | 2 +- examples/Animometer.cpp | 2 +- examples/CHelloTriangle.cpp | 3 +- examples/ComputeBoids.cpp | 2 +- examples/CppHelloTriangle.cpp | 2 +- examples/CubeReflection.cpp | 6 ++-- src/dawn_native/AttachmentState.cpp | 3 +- src/dawn_native/RenderPipeline.cpp | 22 ++++++------- src/tests/end2end/BindGroupTests.cpp | 14 ++++---- src/tests/end2end/ColorStateTests.cpp | 32 +++++++++---------- .../end2end/CompressedTextureFormatTests.cpp | 2 +- src/tests/end2end/DestroyTests.cpp | 2 +- .../end2end/DrawIndexedIndirectTests.cpp | 2 +- src/tests/end2end/DrawIndexedTests.cpp | 2 +- src/tests/end2end/DrawIndirectTests.cpp | 2 +- src/tests/end2end/DrawTests.cpp | 2 +- .../end2end/DynamicBufferOffsetTests.cpp | 2 +- src/tests/end2end/IOSurfaceWrappingTests.cpp | 2 +- src/tests/end2end/IndexFormatTests.cpp | 2 +- .../end2end/MultisampledRenderingTests.cpp | 2 +- src/tests/end2end/OpArrayLengthTests.cpp | 4 +-- src/tests/end2end/PrimitiveTopologyTests.cpp | 2 +- src/tests/end2end/RenderBundleTests.cpp | 2 +- src/tests/end2end/RenderPassTests.cpp | 2 +- src/tests/end2end/SamplerTests.cpp | 2 +- src/tests/end2end/ScissorTests.cpp | 2 +- src/tests/end2end/TextureFormatTests.cpp | 2 +- src/tests/end2end/TextureViewTests.cpp | 4 +-- src/tests/end2end/TextureZeroInitTests.cpp | 2 +- src/tests/end2end/VertexFormatTests.cpp | 2 +- src/tests/end2end/VertexInputTests.cpp | 2 +- .../end2end/ViewportOrientationTests.cpp | 2 +- .../RenderBundleValidationTests.cpp | 12 +++---- .../RenderPipelineValidationTests.cpp | 4 +-- .../validation/VertexInputValidationTests.cpp | 2 +- .../unittests/wire/WireArgumentTests.cpp | 3 +- .../unittests/wire/WireOptionalTests.cpp | 3 +- src/utils/ComboRenderPipelineDescriptor.cpp | 5 ++- src/utils/ComboRenderPipelineDescriptor.h | 5 +-- 39 files changed, 81 insertions(+), 89 deletions(-) diff --git a/dawn.json b/dawn.json index 7fe8cfe4db..c4178d9c9c 100644 --- a/dawn.json +++ b/dawn.json @@ -1076,7 +1076,7 @@ {"name": "sample count", "type": "uint32_t", "default": "1"}, {"name": "depth stencil state", "type": "depth stencil state descriptor", "annotation": "const*", "optional": true}, {"name": "color state count", "type": "uint32_t"}, - {"name": "color states", "type": "color state descriptor", "annotation": "const*const*", "length": "color state count"}, + {"name": "color states", "type": "color state descriptor", "annotation": "const*", "length": "color state count"}, {"name": "sample mask", "type": "uint32_t", "default": "0xFFFFFFFF"}, {"name": "alpha to coverage enabled", "type": "bool", "default": "false"} ] diff --git a/examples/Animometer.cpp b/examples/Animometer.cpp index 1712f9ea89..4216fbfa05 100644 --- a/examples/Animometer.cpp +++ b/examples/Animometer.cpp @@ -119,7 +119,7 @@ void init() { descriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl); descriptor.vertexStage.module = vsModule; descriptor.cFragmentStage.module = fsModule; - descriptor.cColorStates[0]->format = GetPreferredSwapChainTextureFormat(); + descriptor.cColorStates[0].format = GetPreferredSwapChainTextureFormat(); pipeline = device.CreateRenderPipeline(&descriptor); diff --git a/examples/CHelloTriangle.cpp b/examples/CHelloTriangle.cpp index e04bd8e05e..629718deaf 100644 --- a/examples/CHelloTriangle.cpp +++ b/examples/CHelloTriangle.cpp @@ -85,8 +85,7 @@ void init() { colorStateDescriptor.writeMask = DAWN_COLOR_WRITE_MASK_ALL; descriptor.colorStateCount = 1; - DawnColorStateDescriptor* colorStatesPtr[] = {&colorStateDescriptor}; - descriptor.colorStates = colorStatesPtr; + descriptor.colorStates = &colorStateDescriptor; DawnPipelineLayoutDescriptor pl; pl.nextInChain = nullptr; diff --git a/examples/ComputeBoids.cpp b/examples/ComputeBoids.cpp index 2e7bedad3f..c01dd24ff4 100644 --- a/examples/ComputeBoids.cpp +++ b/examples/ComputeBoids.cpp @@ -141,7 +141,7 @@ void initRender() { descriptor.cVertexInput.cAttributes[2].format = dawn::VertexFormat::Float2; descriptor.depthStencilState = &descriptor.cDepthStencilState; descriptor.cDepthStencilState.format = dawn::TextureFormat::Depth24PlusStencil8; - descriptor.cColorStates[0]->format = GetPreferredSwapChainTextureFormat(); + descriptor.cColorStates[0].format = GetPreferredSwapChainTextureFormat(); renderPipeline = device.CreateRenderPipeline(&descriptor); } diff --git a/examples/CppHelloTriangle.cpp b/examples/CppHelloTriangle.cpp index f3af2c6af4..937c00669a 100644 --- a/examples/CppHelloTriangle.cpp +++ b/examples/CppHelloTriangle.cpp @@ -135,7 +135,7 @@ void init() { descriptor.cVertexInput.cAttributes[0].format = dawn::VertexFormat::Float4; descriptor.depthStencilState = &descriptor.cDepthStencilState; descriptor.cDepthStencilState.format = dawn::TextureFormat::Depth24PlusStencil8; - descriptor.cColorStates[0]->format = GetPreferredSwapChainTextureFormat(); + descriptor.cColorStates[0].format = GetPreferredSwapChainTextureFormat(); pipeline = device.CreateRenderPipeline(&descriptor); diff --git a/examples/CubeReflection.cpp b/examples/CubeReflection.cpp index 517e06f48f..e693105a67 100644 --- a/examples/CubeReflection.cpp +++ b/examples/CubeReflection.cpp @@ -210,7 +210,7 @@ void init() { descriptor.vertexInput = &vertexInput; descriptor.depthStencilState = &descriptor.cDepthStencilState; descriptor.cDepthStencilState.format = dawn::TextureFormat::Depth24PlusStencil8; - descriptor.cColorStates[0]->format = GetPreferredSwapChainTextureFormat(); + descriptor.cColorStates[0].format = GetPreferredSwapChainTextureFormat(); descriptor.cDepthStencilState.depthWriteEnabled = true; descriptor.cDepthStencilState.depthCompare = dawn::CompareFunction::Less; @@ -223,7 +223,7 @@ void init() { pDescriptor.vertexInput = &vertexInput; pDescriptor.depthStencilState = &pDescriptor.cDepthStencilState; pDescriptor.cDepthStencilState.format = dawn::TextureFormat::Depth24PlusStencil8; - pDescriptor.cColorStates[0]->format = GetPreferredSwapChainTextureFormat(); + pDescriptor.cColorStates[0].format = GetPreferredSwapChainTextureFormat(); pDescriptor.cDepthStencilState.stencilFront.passOp = dawn::StencilOperation::Replace; pDescriptor.cDepthStencilState.stencilBack.passOp = dawn::StencilOperation::Replace; pDescriptor.cDepthStencilState.depthCompare = dawn::CompareFunction::Less; @@ -237,7 +237,7 @@ void init() { rfDescriptor.vertexInput = &vertexInput; rfDescriptor.depthStencilState = &rfDescriptor.cDepthStencilState; rfDescriptor.cDepthStencilState.format = dawn::TextureFormat::Depth24PlusStencil8; - rfDescriptor.cColorStates[0]->format = GetPreferredSwapChainTextureFormat(); + rfDescriptor.cColorStates[0].format = GetPreferredSwapChainTextureFormat(); rfDescriptor.cDepthStencilState.stencilFront.compare = dawn::CompareFunction::Equal; rfDescriptor.cDepthStencilState.stencilBack.compare = dawn::CompareFunction::Equal; rfDescriptor.cDepthStencilState.stencilFront.passOp = dawn::StencilOperation::Replace; diff --git a/src/dawn_native/AttachmentState.cpp b/src/dawn_native/AttachmentState.cpp index febf6d6305..3cd6621404 100644 --- a/src/dawn_native/AttachmentState.cpp +++ b/src/dawn_native/AttachmentState.cpp @@ -34,9 +34,8 @@ namespace dawn_native { AttachmentStateBlueprint::AttachmentStateBlueprint(const RenderPipelineDescriptor* descriptor) : mSampleCount(descriptor->sampleCount) { for (uint32_t i = 0; i < descriptor->colorStateCount; ++i) { - ASSERT(descriptor->colorStates[i] != nullptr); mColorAttachmentsSet.set(i); - mColorFormats[i] = descriptor->colorStates[i]->format; + mColorFormats[i] = descriptor->colorStates[i].format; } if (descriptor->depthStencilState != nullptr) { mDepthStencilFormat = descriptor->depthStencilState->format; diff --git a/src/dawn_native/RenderPipeline.cpp b/src/dawn_native/RenderPipeline.cpp index 1550a26a46..4492817781 100644 --- a/src/dawn_native/RenderPipeline.cpp +++ b/src/dawn_native/RenderPipeline.cpp @@ -117,20 +117,20 @@ namespace dawn_native { } MaybeError ValidateColorStateDescriptor(const DeviceBase* device, - const ColorStateDescriptor* descriptor) { - if (descriptor->nextInChain != nullptr) { + const ColorStateDescriptor& descriptor) { + if (descriptor.nextInChain != nullptr) { return DAWN_VALIDATION_ERROR("nextInChain must be nullptr"); } - DAWN_TRY(ValidateBlendOperation(descriptor->alphaBlend.operation)); - DAWN_TRY(ValidateBlendFactor(descriptor->alphaBlend.srcFactor)); - DAWN_TRY(ValidateBlendFactor(descriptor->alphaBlend.dstFactor)); - DAWN_TRY(ValidateBlendOperation(descriptor->colorBlend.operation)); - DAWN_TRY(ValidateBlendFactor(descriptor->colorBlend.srcFactor)); - DAWN_TRY(ValidateBlendFactor(descriptor->colorBlend.dstFactor)); - DAWN_TRY(ValidateColorWriteMask(descriptor->writeMask)); + DAWN_TRY(ValidateBlendOperation(descriptor.alphaBlend.operation)); + DAWN_TRY(ValidateBlendFactor(descriptor.alphaBlend.srcFactor)); + DAWN_TRY(ValidateBlendFactor(descriptor.alphaBlend.dstFactor)); + DAWN_TRY(ValidateBlendOperation(descriptor.colorBlend.operation)); + DAWN_TRY(ValidateBlendFactor(descriptor.colorBlend.srcFactor)); + DAWN_TRY(ValidateBlendFactor(descriptor.colorBlend.dstFactor)); + DAWN_TRY(ValidateColorWriteMask(descriptor.writeMask)); const Format* format; - DAWN_TRY_ASSIGN(format, device->GetInternalFormat(descriptor->format)); + DAWN_TRY_ASSIGN(format, device->GetInternalFormat(descriptor.format)); if (!format->IsColor() || !format->isRenderable) { return DAWN_VALIDATION_ERROR("Color format must be color renderable"); } @@ -420,7 +420,7 @@ namespace dawn_native { } for (uint32_t i : IterateBitSet(mAttachmentState->GetColorAttachmentsMask())) { - mColorStates[i] = *descriptor->colorStates[i]; + mColorStates[i] = descriptor->colorStates[i]; } // 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 b70b1a1694..dbae686a79 100644 --- a/src/tests/end2end/BindGroupTests.cpp +++ b/src/tests/end2end/BindGroupTests.cpp @@ -106,10 +106,10 @@ protected: pipelineDescriptor.layout = pipelineLayout; pipelineDescriptor.vertexStage.module = vsModule; pipelineDescriptor.cFragmentStage.module = fsModule; - pipelineDescriptor.cColorStates[0]->format = renderPass.colorFormat; - pipelineDescriptor.cColorStates[0]->colorBlend.operation = dawn::BlendOperation::Add; - pipelineDescriptor.cColorStates[0]->colorBlend.srcFactor = dawn::BlendFactor::One; - pipelineDescriptor.cColorStates[0]->colorBlend.dstFactor = dawn::BlendFactor::One; + pipelineDescriptor.cColorStates[0].format = renderPass.colorFormat; + pipelineDescriptor.cColorStates[0].colorBlend.operation = dawn::BlendOperation::Add; + pipelineDescriptor.cColorStates[0].colorBlend.srcFactor = dawn::BlendFactor::One; + pipelineDescriptor.cColorStates[0].colorBlend.dstFactor = dawn::BlendFactor::One; return device.CreateRenderPipeline(&pipelineDescriptor); } @@ -193,7 +193,7 @@ TEST_P(BindGroupTests, ReusedUBO) { textureDescriptor.layout = pipelineLayout; textureDescriptor.vertexStage.module = vsModule; textureDescriptor.cFragmentStage.module = fsModule; - textureDescriptor.cColorStates[0]->format = renderPass.colorFormat; + textureDescriptor.cColorStates[0].format = renderPass.colorFormat; dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&textureDescriptor); @@ -274,7 +274,7 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) { pipelineDescriptor.layout = pipelineLayout; pipelineDescriptor.vertexStage.module = vsModule; pipelineDescriptor.cFragmentStage.module = fsModule; - pipelineDescriptor.cColorStates[0]->format = renderPass.colorFormat; + pipelineDescriptor.cColorStates[0].format = renderPass.colorFormat; dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDescriptor); @@ -398,7 +398,7 @@ TEST_P(BindGroupTests, MultipleBindLayouts) { textureDescriptor.layout = pipelineLayout; textureDescriptor.vertexStage.module = vsModule; textureDescriptor.cFragmentStage.module = fsModule; - textureDescriptor.cColorStates[0]->format = renderPass.colorFormat; + textureDescriptor.cColorStates[0].format = renderPass.colorFormat; dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&textureDescriptor); diff --git a/src/tests/end2end/ColorStateTests.cpp b/src/tests/end2end/ColorStateTests.cpp index fb28b060be..62dfee4c43 100644 --- a/src/tests/end2end/ColorStateTests.cpp +++ b/src/tests/end2end/ColorStateTests.cpp @@ -73,7 +73,7 @@ class ColorStateTest : public DawnTest { baseDescriptor.layout = pipelineLayout; baseDescriptor.vertexStage.module = vsModule; baseDescriptor.cFragmentStage.module = fsModule; - baseDescriptor.cColorStates[0]->format = renderPass.colorFormat; + baseDescriptor.cColorStates[0].format = renderPass.colorFormat; basePipeline = device.CreateRenderPipeline(&baseDescriptor); @@ -81,8 +81,8 @@ class ColorStateTest : public DawnTest { testDescriptor.layout = pipelineLayout; testDescriptor.vertexStage.module = vsModule; testDescriptor.cFragmentStage.module = fsModule; - testDescriptor.cColorStates[0] = &colorStateDescriptor; - testDescriptor.cColorStates[0]->format = renderPass.colorFormat; + testDescriptor.cColorStates[0] = colorStateDescriptor; + testDescriptor.cColorStates[0].format = renderPass.colorFormat; testPipeline = device.CreateRenderPipeline(&testDescriptor); } @@ -825,14 +825,14 @@ TEST_P(ColorStateTest, IndependentColorState) { blend3.srcFactor = dawn::BlendFactor::One; blend3.dstFactor = dawn::BlendFactor::One; - testDescriptor.cColorStates[0]->colorBlend = blend1; - testDescriptor.cColorStates[0]->alphaBlend = blend1; + testDescriptor.cColorStates[0].colorBlend = blend1; + testDescriptor.cColorStates[0].alphaBlend = blend1; - testDescriptor.cColorStates[1]->colorBlend = blend2; - testDescriptor.cColorStates[1]->alphaBlend = blend2; + testDescriptor.cColorStates[1].colorBlend = blend2; + testDescriptor.cColorStates[1].alphaBlend = blend2; - testDescriptor.cColorStates[3]->colorBlend = blend3; - testDescriptor.cColorStates[3]->alphaBlend = blend3; + testDescriptor.cColorStates[3].colorBlend = blend3; + testDescriptor.cColorStates[3].alphaBlend = blend3; testPipeline = device.CreateRenderPipeline(&testDescriptor); @@ -901,7 +901,7 @@ TEST_P(ColorStateTest, DefaultBlendColor) { baseDescriptor.layout = pipelineLayout; baseDescriptor.vertexStage.module = vsModule; baseDescriptor.cFragmentStage.module = fsModule; - baseDescriptor.cColorStates[0]->format = renderPass.colorFormat; + baseDescriptor.cColorStates[0].format = renderPass.colorFormat; basePipeline = device.CreateRenderPipeline(&baseDescriptor); @@ -909,14 +909,14 @@ TEST_P(ColorStateTest, DefaultBlendColor) { testDescriptor.layout = pipelineLayout; testDescriptor.vertexStage.module = vsModule; testDescriptor.cFragmentStage.module = fsModule; - testDescriptor.cColorStates[0]->format = renderPass.colorFormat; + testDescriptor.cColorStates[0].format = renderPass.colorFormat; dawn::BlendDescriptor blend; blend.operation = dawn::BlendOperation::Add; blend.srcFactor = dawn::BlendFactor::BlendColor; blend.dstFactor = dawn::BlendFactor::One; - testDescriptor.cColorStates[0]->colorBlend = blend; - testDescriptor.cColorStates[0]->alphaBlend = blend; + testDescriptor.cColorStates[0].colorBlend = blend; + testDescriptor.cColorStates[0].alphaBlend = blend; testPipeline = device.CreateRenderPipeline(&testDescriptor); constexpr dawn::Color kWhite{1.0f, 1.0f, 1.0f, 1.0f}; @@ -1025,7 +1025,7 @@ TEST_P(ColorStateTest, ColorWriteMaskDoesNotAffectRenderPassLoadOpClear) { baseDescriptor.layout = pipelineLayout; baseDescriptor.vertexStage.module = vsModule; baseDescriptor.cFragmentStage.module = fsModule; - baseDescriptor.cColorStates[0]->format = renderPass.colorFormat; + baseDescriptor.cColorStates[0].format = renderPass.colorFormat; basePipeline = device.CreateRenderPipeline(&baseDescriptor); @@ -1033,8 +1033,8 @@ TEST_P(ColorStateTest, ColorWriteMaskDoesNotAffectRenderPassLoadOpClear) { testDescriptor.layout = pipelineLayout; testDescriptor.vertexStage.module = vsModule; testDescriptor.cFragmentStage.module = fsModule; - testDescriptor.cColorStates[0]->format = renderPass.colorFormat; - testDescriptor.cColorStates[0]->writeMask = dawn::ColorWriteMask::Red; + testDescriptor.cColorStates[0].format = renderPass.colorFormat; + testDescriptor.cColorStates[0].writeMask = dawn::ColorWriteMask::Red; testPipeline = device.CreateRenderPipeline(&testDescriptor); diff --git a/src/tests/end2end/CompressedTextureFormatTests.cpp b/src/tests/end2end/CompressedTextureFormatTests.cpp index 216eca5de2..1a332b8527 100644 --- a/src/tests/end2end/CompressedTextureFormatTests.cpp +++ b/src/tests/end2end/CompressedTextureFormatTests.cpp @@ -166,7 +166,7 @@ class CompressedTextureBCFormatTest : public DawnTest { renderPipelineDescriptor.vertexStage.module = vsModule; renderPipelineDescriptor.cFragmentStage.module = fsModule; renderPipelineDescriptor.layout = pipelineLayout; - renderPipelineDescriptor.cColorStates[0]->format = + renderPipelineDescriptor.cColorStates[0].format = utils::BasicRenderPass::kDefaultColorFormat; return device.CreateRenderPipeline(&renderPipelineDescriptor); } diff --git a/src/tests/end2end/DestroyTests.cpp b/src/tests/end2end/DestroyTests.cpp index f9dfc3be27..2e8201016f 100644 --- a/src/tests/end2end/DestroyTests.cpp +++ b/src/tests/end2end/DestroyTests.cpp @@ -50,7 +50,7 @@ class DestroyTest : public DawnTest { descriptor.cVertexInput.cBuffers[0].stride = 4 * sizeof(float); descriptor.cVertexInput.cBuffers[0].attributeCount = 1; descriptor.cVertexInput.cAttributes[0].format = dawn::VertexFormat::Float4; - descriptor.cColorStates[0]->format = renderPass.colorFormat; + descriptor.cColorStates[0].format = renderPass.colorFormat; pipeline = device.CreateRenderPipeline(&descriptor); diff --git a/src/tests/end2end/DrawIndexedIndirectTests.cpp b/src/tests/end2end/DrawIndexedIndirectTests.cpp index c0e68b1433..e497d8b3e4 100644 --- a/src/tests/end2end/DrawIndexedIndirectTests.cpp +++ b/src/tests/end2end/DrawIndexedIndirectTests.cpp @@ -50,7 +50,7 @@ class DrawIndexedIndirectTest : public DawnTest { descriptor.cVertexInput.cBuffers[0].stride = 4 * sizeof(float); descriptor.cVertexInput.cBuffers[0].attributeCount = 1; descriptor.cVertexInput.cAttributes[0].format = dawn::VertexFormat::Float4; - descriptor.cColorStates[0]->format = renderPass.colorFormat; + descriptor.cColorStates[0].format = renderPass.colorFormat; pipeline = device.CreateRenderPipeline(&descriptor); diff --git a/src/tests/end2end/DrawIndexedTests.cpp b/src/tests/end2end/DrawIndexedTests.cpp index 159f1efe09..a484d1cf48 100644 --- a/src/tests/end2end/DrawIndexedTests.cpp +++ b/src/tests/end2end/DrawIndexedTests.cpp @@ -50,7 +50,7 @@ class DrawIndexedTest : public DawnTest { descriptor.cVertexInput.cBuffers[0].stride = 4 * sizeof(float); descriptor.cVertexInput.cBuffers[0].attributeCount = 1; descriptor.cVertexInput.cAttributes[0].format = dawn::VertexFormat::Float4; - descriptor.cColorStates[0]->format = renderPass.colorFormat; + descriptor.cColorStates[0].format = renderPass.colorFormat; pipeline = device.CreateRenderPipeline(&descriptor); diff --git a/src/tests/end2end/DrawIndirectTests.cpp b/src/tests/end2end/DrawIndirectTests.cpp index 8a89146f96..47d554d6b5 100644 --- a/src/tests/end2end/DrawIndirectTests.cpp +++ b/src/tests/end2end/DrawIndirectTests.cpp @@ -50,7 +50,7 @@ class DrawIndirectTest : public DawnTest { descriptor.cVertexInput.cBuffers[0].stride = 4 * sizeof(float); descriptor.cVertexInput.cBuffers[0].attributeCount = 1; descriptor.cVertexInput.cAttributes[0].format = dawn::VertexFormat::Float4; - descriptor.cColorStates[0]->format = renderPass.colorFormat; + descriptor.cColorStates[0].format = renderPass.colorFormat; pipeline = device.CreateRenderPipeline(&descriptor); diff --git a/src/tests/end2end/DrawTests.cpp b/src/tests/end2end/DrawTests.cpp index 30e48b8943..e12f8179f8 100644 --- a/src/tests/end2end/DrawTests.cpp +++ b/src/tests/end2end/DrawTests.cpp @@ -50,7 +50,7 @@ class DrawTest : public DawnTest { descriptor.cVertexInput.cBuffers[0].stride = 4 * sizeof(float); descriptor.cVertexInput.cBuffers[0].attributeCount = 1; descriptor.cVertexInput.cAttributes[0].format = dawn::VertexFormat::Float4; - descriptor.cColorStates[0]->format = renderPass.colorFormat; + descriptor.cColorStates[0].format = renderPass.colorFormat; pipeline = device.CreateRenderPipeline(&descriptor); diff --git a/src/tests/end2end/DynamicBufferOffsetTests.cpp b/src/tests/end2end/DynamicBufferOffsetTests.cpp index bf0457eaf1..cd1723a2d2 100644 --- a/src/tests/end2end/DynamicBufferOffsetTests.cpp +++ b/src/tests/end2end/DynamicBufferOffsetTests.cpp @@ -142,7 +142,7 @@ class DynamicBufferOffsetTests : public DawnTest { utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); pipelineDescriptor.vertexStage.module = vsModule; pipelineDescriptor.cFragmentStage.module = fsModule; - pipelineDescriptor.cColorStates[0]->format = dawn::TextureFormat::RGBA8Unorm; + pipelineDescriptor.cColorStates[0].format = dawn::TextureFormat::RGBA8Unorm; dawn::PipelineLayoutDescriptor pipelineLayoutDescriptor; if (isInheritedPipeline) { diff --git a/src/tests/end2end/IOSurfaceWrappingTests.cpp b/src/tests/end2end/IOSurfaceWrappingTests.cpp index e4823fffe1..9b33101634 100644 --- a/src/tests/end2end/IOSurfaceWrappingTests.cpp +++ b/src/tests/end2end/IOSurfaceWrappingTests.cpp @@ -306,7 +306,7 @@ class IOSurfaceUsageTests : public IOSurfaceTestBase { descriptor.vertexStage.module = vs; descriptor.cFragmentStage.module = fs; descriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl); - descriptor.cColorStates[0]->format = dawn::TextureFormat::RGBA8Unorm; + descriptor.cColorStates[0].format = dawn::TextureFormat::RGBA8Unorm; pipeline = device.CreateRenderPipeline(&descriptor); } diff --git a/src/tests/end2end/IndexFormatTests.cpp b/src/tests/end2end/IndexFormatTests.cpp index 0791b0b817..1a286abf88 100644 --- a/src/tests/end2end/IndexFormatTests.cpp +++ b/src/tests/end2end/IndexFormatTests.cpp @@ -56,7 +56,7 @@ class IndexFormatTest : public DawnTest { descriptor.cVertexInput.cBuffers[0].stride = 4 * sizeof(float); descriptor.cVertexInput.cBuffers[0].attributeCount = 1; descriptor.cVertexInput.cAttributes[0].format = dawn::VertexFormat::Float4; - descriptor.cColorStates[0]->format = renderPass.colorFormat; + descriptor.cColorStates[0].format = renderPass.colorFormat; return device.CreateRenderPipeline(&descriptor); } diff --git a/src/tests/end2end/MultisampledRenderingTests.cpp b/src/tests/end2end/MultisampledRenderingTests.cpp index c9fb5d95ff..ec979c23e1 100644 --- a/src/tests/end2end/MultisampledRenderingTests.cpp +++ b/src/tests/end2end/MultisampledRenderingTests.cpp @@ -221,7 +221,7 @@ class MultisampledRenderingTest : public DawnTest { pipelineDescriptor.colorStateCount = numColorAttachments; for (uint32_t i = 0; i < numColorAttachments; ++i) { - pipelineDescriptor.cColorStates[i]->format = kColorFormat; + pipelineDescriptor.cColorStates[i].format = kColorFormat; } return device.CreateRenderPipeline(&pipelineDescriptor); diff --git a/src/tests/end2end/OpArrayLengthTests.cpp b/src/tests/end2end/OpArrayLengthTests.cpp index 87645660bc..1d8ac402d9 100644 --- a/src/tests/end2end/OpArrayLengthTests.cpp +++ b/src/tests/end2end/OpArrayLengthTests.cpp @@ -180,7 +180,7 @@ TEST_P(OpArrayLengthTest, Fragment) { descriptor.vertexStage.module = vsModule; descriptor.cFragmentStage.module = fsModule; descriptor.primitiveTopology = dawn::PrimitiveTopology::PointList; - descriptor.cColorStates[0]->format = renderPass.colorFormat; + descriptor.cColorStates[0].format = renderPass.colorFormat; descriptor.layout = utils::MakeBasicPipelineLayout(device, &mBindGroupLayout); dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor); @@ -241,7 +241,7 @@ TEST_P(OpArrayLengthTest, Vertex) { descriptor.vertexStage.module = vsModule; descriptor.cFragmentStage.module = fsModule; descriptor.primitiveTopology = dawn::PrimitiveTopology::PointList; - descriptor.cColorStates[0]->format = renderPass.colorFormat; + descriptor.cColorStates[0].format = renderPass.colorFormat; descriptor.layout = utils::MakeBasicPipelineLayout(device, &mBindGroupLayout); dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor); diff --git a/src/tests/end2end/PrimitiveTopologyTests.cpp b/src/tests/end2end/PrimitiveTopologyTests.cpp index 8bec36600c..7d38267bd2 100644 --- a/src/tests/end2end/PrimitiveTopologyTests.cpp +++ b/src/tests/end2end/PrimitiveTopologyTests.cpp @@ -190,7 +190,7 @@ class PrimitiveTopologyTest : public DawnTest { descriptor.cVertexInput.cBuffers[0].stride = 4 * sizeof(float); descriptor.cVertexInput.cBuffers[0].attributeCount = 1; descriptor.cVertexInput.cAttributes[0].format = dawn::VertexFormat::Float4; - descriptor.cColorStates[0]->format = renderPass.colorFormat; + descriptor.cColorStates[0].format = renderPass.colorFormat; dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor); diff --git a/src/tests/end2end/RenderBundleTests.cpp b/src/tests/end2end/RenderBundleTests.cpp index 84f79f9886..5c78a9a2d8 100644 --- a/src/tests/end2end/RenderBundleTests.cpp +++ b/src/tests/end2end/RenderBundleTests.cpp @@ -81,7 +81,7 @@ class RenderBundleTest : public DawnTest { descriptor.cVertexInput.cBuffers[0].stride = 4 * sizeof(float); descriptor.cVertexInput.cBuffers[0].attributeCount = 1; descriptor.cVertexInput.cAttributes[0].format = dawn::VertexFormat::Float4; - descriptor.cColorStates[0]->format = renderPass.colorFormat; + descriptor.cColorStates[0].format = renderPass.colorFormat; pipeline = device.CreateRenderPipeline(&descriptor); diff --git a/src/tests/end2end/RenderPassTests.cpp b/src/tests/end2end/RenderPassTests.cpp index 1111c07cec..2676df6979 100644 --- a/src/tests/end2end/RenderPassTests.cpp +++ b/src/tests/end2end/RenderPassTests.cpp @@ -47,7 +47,7 @@ protected: descriptor.vertexStage.module = vsModule; descriptor.cFragmentStage.module = fsModule; descriptor.primitiveTopology = dawn::PrimitiveTopology::TriangleStrip; - descriptor.cColorStates[0]->format = kFormat; + descriptor.cColorStates[0].format = kFormat; pipeline = device.CreateRenderPipeline(&descriptor); } diff --git a/src/tests/end2end/SamplerTests.cpp b/src/tests/end2end/SamplerTests.cpp index b26d203f81..3ab4579364 100644 --- a/src/tests/end2end/SamplerTests.cpp +++ b/src/tests/end2end/SamplerTests.cpp @@ -77,7 +77,7 @@ protected: pipelineDescriptor.layout = pipelineLayout; pipelineDescriptor.vertexStage.module = vsModule; pipelineDescriptor.cFragmentStage.module = fsModule; - pipelineDescriptor.cColorStates[0]->format = mRenderPass.colorFormat; + pipelineDescriptor.cColorStates[0].format = mRenderPass.colorFormat; mPipeline = device.CreateRenderPipeline(&pipelineDescriptor); diff --git a/src/tests/end2end/ScissorTests.cpp b/src/tests/end2end/ScissorTests.cpp index 99be8b58c8..b7fa6130e8 100644 --- a/src/tests/end2end/ScissorTests.cpp +++ b/src/tests/end2end/ScissorTests.cpp @@ -42,7 +42,7 @@ class ScissorTest: public DawnTest { utils::ComboRenderPipelineDescriptor descriptor(device); descriptor.vertexStage.module = vsModule; descriptor.cFragmentStage.module = fsModule; - descriptor.cColorStates[0]->format = format; + descriptor.cColorStates[0].format = format; return device.CreateRenderPipeline(&descriptor); } diff --git a/src/tests/end2end/TextureFormatTests.cpp b/src/tests/end2end/TextureFormatTests.cpp index 9f1e01f74d..d2acc6b144 100644 --- a/src/tests/end2end/TextureFormatTests.cpp +++ b/src/tests/end2end/TextureFormatTests.cpp @@ -219,7 +219,7 @@ class TextureFormatTest : public DawnTest { desc.vertexStage.module = vsModule; desc.cFragmentStage.module = fsModule; desc.layout = utils::MakeBasicPipelineLayout(device, &bgl); - desc.cColorStates[0]->format = renderFormatInfo.format; + desc.cColorStates[0].format = renderFormatInfo.format; return device.CreateRenderPipeline(&desc); } diff --git a/src/tests/end2end/TextureViewTests.cpp b/src/tests/end2end/TextureViewTests.cpp index 27c0ff9456..688bd11ca3 100644 --- a/src/tests/end2end/TextureViewTests.cpp +++ b/src/tests/end2end/TextureViewTests.cpp @@ -170,7 +170,7 @@ protected: textureDescriptor.vertexStage.module = mVSModule; textureDescriptor.cFragmentStage.module = fsModule; textureDescriptor.layout = utils::MakeBasicPipelineLayout(device, &bindGroupLayout); - textureDescriptor.cColorStates[0]->format = mRenderPass.colorFormat; + textureDescriptor.cColorStates[0].format = mRenderPass.colorFormat; dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&textureDescriptor); @@ -507,7 +507,7 @@ class TextureViewRenderingTest : public DawnTest { utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); pipelineDescriptor.vertexStage.module = vsModule; pipelineDescriptor.cFragmentStage.module = oneColorFsModule; - pipelineDescriptor.cColorStates[0]->format = kDefaultFormat; + pipelineDescriptor.cColorStates[0].format = kDefaultFormat; dawn::RenderPipeline oneColorPipeline = device.CreateRenderPipeline(&pipelineDescriptor); diff --git a/src/tests/end2end/TextureZeroInitTests.cpp b/src/tests/end2end/TextureZeroInitTests.cpp index 7129c3c249..64e518bde6 100644 --- a/src/tests/end2end/TextureZeroInitTests.cpp +++ b/src/tests/end2end/TextureZeroInitTests.cpp @@ -474,7 +474,7 @@ TEST_P(TextureZeroInitTest, RenderPassSampledTextureClear) { void main() { fragColor = texelFetch(sampler2D(texture0, sampler0), ivec2(gl_FragCoord), 0); })"); - renderPipelineDescriptor.cColorStates[0]->format = kColorFormat; + renderPipelineDescriptor.cColorStates[0].format = kColorFormat; dawn::RenderPipeline renderPipeline = device.CreateRenderPipeline(&renderPipelineDescriptor); // Create bindgroup diff --git a/src/tests/end2end/VertexFormatTests.cpp b/src/tests/end2end/VertexFormatTests.cpp index edcefec084..e27994a8b0 100644 --- a/src/tests/end2end/VertexFormatTests.cpp +++ b/src/tests/end2end/VertexFormatTests.cpp @@ -366,7 +366,7 @@ class VertexFormatTest : public DawnTest { descriptor.cVertexInput.cBuffers[0].stride = strideBytes; descriptor.cVertexInput.cBuffers[0].attributeCount = 1; descriptor.cVertexInput.cAttributes[0].format = format; - descriptor.cColorStates[0]->format = renderPass.colorFormat; + descriptor.cColorStates[0].format = renderPass.colorFormat; return device.CreateRenderPipeline(&descriptor); } diff --git a/src/tests/end2end/VertexInputTests.cpp b/src/tests/end2end/VertexInputTests.cpp index 2a36479f33..477956db02 100644 --- a/src/tests/end2end/VertexInputTests.cpp +++ b/src/tests/end2end/VertexInputTests.cpp @@ -132,7 +132,7 @@ class VertexInputTest : public DawnTest { descriptor.vertexStage.module = vsModule; descriptor.cFragmentStage.module = fsModule; descriptor.vertexInput = &vertexInput; - descriptor.cColorStates[0]->format = renderPass.colorFormat; + descriptor.cColorStates[0].format = renderPass.colorFormat; return device.CreateRenderPipeline(&descriptor); } diff --git a/src/tests/end2end/ViewportOrientationTests.cpp b/src/tests/end2end/ViewportOrientationTests.cpp index 7a870b6131..4f70df51a3 100644 --- a/src/tests/end2end/ViewportOrientationTests.cpp +++ b/src/tests/end2end/ViewportOrientationTests.cpp @@ -43,7 +43,7 @@ TEST_P(ViewportOrientationTests, OriginAt0x0) { descriptor.vertexStage.module = vsModule; descriptor.cFragmentStage.module = fsModule; descriptor.primitiveTopology = dawn::PrimitiveTopology::PointList; - descriptor.cColorStates[0]->format = renderPass.colorFormat; + descriptor.cColorStates[0].format = renderPass.colorFormat; dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor); diff --git a/src/tests/unittests/validation/RenderBundleValidationTests.cpp b/src/tests/unittests/validation/RenderBundleValidationTests.cpp index 108463d5f1..0ac4fda1f9 100644 --- a/src/tests/unittests/validation/RenderBundleValidationTests.cpp +++ b/src/tests/unittests/validation/RenderBundleValidationTests.cpp @@ -707,9 +707,9 @@ TEST_F(RenderBundleValidationTest, PipelineColorFormatMismatch) { auto SetupRenderPipelineDescForTest = [this](utils::ComboRenderPipelineDescriptor* desc) { InitializeRenderPipelineDescriptor(desc); desc->colorStateCount = 3; - desc->cColorStates[0]->format = dawn::TextureFormat::RGBA8Unorm; - desc->cColorStates[1]->format = dawn::TextureFormat::RG16Float; - desc->cColorStates[2]->format = dawn::TextureFormat::R16Sint; + desc->cColorStates[0].format = dawn::TextureFormat::RGBA8Unorm; + desc->cColorStates[1].format = dawn::TextureFormat::RG16Float; + desc->cColorStates[2].format = dawn::TextureFormat::R16Sint; }; // Test the success case. @@ -728,7 +728,7 @@ TEST_F(RenderBundleValidationTest, PipelineColorFormatMismatch) { { utils::ComboRenderPipelineDescriptor desc(device); SetupRenderPipelineDescForTest(&desc); - desc.cColorStates[1]->format = dawn::TextureFormat::RGBA8Unorm; + desc.cColorStates[1].format = dawn::TextureFormat::RGBA8Unorm; dawn::RenderBundleEncoder renderBundleEncoder = device.CreateRenderBundleEncoder(&renderBundleDesc); @@ -761,7 +761,7 @@ TEST_F(RenderBundleValidationTest, PipelineDepthStencilFormatMismatch) { auto SetupRenderPipelineDescForTest = [this](utils::ComboRenderPipelineDescriptor* desc) { InitializeRenderPipelineDescriptor(desc); desc->colorStateCount = 1; - desc->cColorStates[0]->format = dawn::TextureFormat::RGBA8Unorm; + desc->cColorStates[0].format = dawn::TextureFormat::RGBA8Unorm; desc->depthStencilState = &desc->cDepthStencilState; desc->cDepthStencilState.format = dawn::TextureFormat::Depth24PlusStencil8; }; @@ -815,7 +815,7 @@ TEST_F(RenderBundleValidationTest, PipelineSampleCountMismatch) { utils::ComboRenderPipelineDescriptor renderPipelineDesc(device); InitializeRenderPipelineDescriptor(&renderPipelineDesc); renderPipelineDesc.colorStateCount = 1; - renderPipelineDesc.cColorStates[0]->format = dawn::TextureFormat::RGBA8Unorm; + renderPipelineDesc.cColorStates[0].format = dawn::TextureFormat::RGBA8Unorm; renderPipelineDesc.sampleCount = 4; // Test the success case. diff --git a/src/tests/unittests/validation/RenderPipelineValidationTests.cpp b/src/tests/unittests/validation/RenderPipelineValidationTests.cpp index c000322349..da11021c9d 100644 --- a/src/tests/unittests/validation/RenderPipelineValidationTests.cpp +++ b/src/tests/unittests/validation/RenderPipelineValidationTests.cpp @@ -98,7 +98,7 @@ TEST_F(RenderPipelineValidationTest, NonRenderableFormat) { utils::ComboRenderPipelineDescriptor descriptor(device); descriptor.vertexStage.module = vsModule; descriptor.cFragmentStage.module = fsModule; - descriptor.cColorStates[0]->format = dawn::TextureFormat::RGBA8Unorm; + descriptor.cColorStates[0].format = dawn::TextureFormat::RGBA8Unorm; device.CreateRenderPipeline(&descriptor); } @@ -108,7 +108,7 @@ TEST_F(RenderPipelineValidationTest, NonRenderableFormat) { utils::ComboRenderPipelineDescriptor descriptor(device); descriptor.vertexStage.module = vsModule; descriptor.cFragmentStage.module = fsModule; - descriptor.cColorStates[0]->format = dawn::TextureFormat::RG11B10Float; + descriptor.cColorStates[0].format = dawn::TextureFormat::RG11B10Float; ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor)); } diff --git a/src/tests/unittests/validation/VertexInputValidationTests.cpp b/src/tests/unittests/validation/VertexInputValidationTests.cpp index 9dbdbae501..b1bdedd6e9 100644 --- a/src/tests/unittests/validation/VertexInputValidationTests.cpp +++ b/src/tests/unittests/validation/VertexInputValidationTests.cpp @@ -37,7 +37,7 @@ class VertexInputTest : public ValidationTest { descriptor.vertexStage.module = vsModule; descriptor.cFragmentStage.module = fsModule; descriptor.vertexInput = &state; - descriptor.cColorStates[0]->format = dawn::TextureFormat::RGBA8Unorm; + descriptor.cColorStates[0].format = dawn::TextureFormat::RGBA8Unorm; if (!success) { ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor)); diff --git a/src/tests/unittests/wire/WireArgumentTests.cpp b/src/tests/unittests/wire/WireArgumentTests.cpp index 88c7cc0c06..f9a77335fa 100644 --- a/src/tests/unittests/wire/WireArgumentTests.cpp +++ b/src/tests/unittests/wire/WireArgumentTests.cpp @@ -173,8 +173,7 @@ TEST_F(WireArgumentTests, CStringArgument) { pipelineDescriptor.fragmentStage = &fragmentStage; pipelineDescriptor.colorStateCount = 1; - DawnColorStateDescriptor* colorStatesPtr[] = {&colorStateDescriptor}; - pipelineDescriptor.colorStates = colorStatesPtr; + pipelineDescriptor.colorStates = &colorStateDescriptor; pipelineDescriptor.sampleCount = 1; pipelineDescriptor.sampleMask = 0xFFFFFFFF; diff --git a/src/tests/unittests/wire/WireOptionalTests.cpp b/src/tests/unittests/wire/WireOptionalTests.cpp index 3684afa234..98270662c4 100644 --- a/src/tests/unittests/wire/WireOptionalTests.cpp +++ b/src/tests/unittests/wire/WireOptionalTests.cpp @@ -143,8 +143,7 @@ TEST_F(WireOptionalTests, OptionalStructPointer) { pipelineDescriptor.fragmentStage = &fragmentStage; pipelineDescriptor.colorStateCount = 1; - DawnColorStateDescriptor* colorStatesPtr[] = {&colorStateDescriptor}; - pipelineDescriptor.colorStates = colorStatesPtr; + pipelineDescriptor.colorStates = &colorStateDescriptor; pipelineDescriptor.sampleCount = 1; pipelineDescriptor.sampleMask = 0xFFFFFFFF; diff --git a/src/utils/ComboRenderPipelineDescriptor.cpp b/src/utils/ComboRenderPipelineDescriptor.cpp index 2da1f9fe76..66be4dee0a 100644 --- a/src/utils/ComboRenderPipelineDescriptor.cpp +++ b/src/utils/ComboRenderPipelineDescriptor.cpp @@ -78,7 +78,7 @@ namespace utils { // Set defaults for the color state descriptors. { descriptor->colorStateCount = 1; - descriptor->colorStates = &cColorStates[0]; + descriptor->colorStates = cColorStates.data(); dawn::BlendDescriptor blend; blend.operation = dawn::BlendOperation::Add; @@ -90,8 +90,7 @@ namespace utils { colorStateDescriptor.colorBlend = blend; colorStateDescriptor.writeMask = dawn::ColorWriteMask::All; for (uint32_t i = 0; i < kMaxColorAttachments; ++i) { - mColorStates[i] = colorStateDescriptor; - cColorStates[i] = &mColorStates[i]; + cColorStates[i] = colorStateDescriptor; } } diff --git a/src/utils/ComboRenderPipelineDescriptor.h b/src/utils/ComboRenderPipelineDescriptor.h index a0a921ea83..4d568b35f4 100644 --- a/src/utils/ComboRenderPipelineDescriptor.h +++ b/src/utils/ComboRenderPipelineDescriptor.h @@ -44,11 +44,8 @@ namespace utils { ComboVertexInputDescriptor cVertexInput; dawn::RasterizationStateDescriptor cRasterizationState; - std::array cColorStates; + std::array cColorStates; dawn::DepthStencilStateDescriptor cDepthStencilState; - - private: - dawn::ColorStateDescriptor mColorStates[kMaxColorAttachments]; }; } // namespace utils