Split AttachmentStateDescriptor, in order to match web idl

AttachmentStateDescriptor was removed in web idl. Its format info
for color attachment and depth/stencil attachment were split and
added into BlendStateDescriptor (renamed to ColorStateDescriptor)
and DepthStencilStateDescriptor (became optional) respectively.

This change makes dawn project match the revision in web idl.

BUG=dawn:106, dawn:102

Change-Id: If57b060db7b4b5d1124b4a79a3b92a3880047722
Reviewed-on: https://dawn-review.googlesource.com/c/4561
Commit-Queue: Yunchao He <yunchao.he@intel.com>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Yunchao He
2019-02-15 02:20:57 +00:00
committed by Commit Bot service account
parent 4dec7371a2
commit 108bcbd5c9
32 changed files with 178 additions and 270 deletions

View File

@@ -39,7 +39,7 @@ class InputStateTest : public ValidationTest {
descriptor.cVertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.inputState = inputState;
descriptor.cColorAttachments[0]->format = dawn::TextureFormat::R8G8B8A8Unorm;
descriptor.cColorStates[0].format = dawn::TextureFormat::R8G8B8A8Unorm;
if (!success) {
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));

View File

@@ -58,26 +58,16 @@ TEST_F(RenderPipelineValidationTest, BlendState) {
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.cVertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.numBlendStates = 1;
descriptor.numColorStates = 1;
device.CreateRenderPipeline(&descriptor);
}
{ // Fail because lack of blend states for color attachments
{ // Fail because lack of color states (and depth/stencil state)
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.cVertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.numBlendStates = 0;
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
}
{
// Fail because set blend states for empty color attachments
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.cVertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.numBlendStates = 2;
descriptor.numColorStates = 0;
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
}

View File

@@ -88,16 +88,17 @@ TEST_F(WireArgumentTests, CStringArgument) {
dawnShaderModule apiVsModule = api.GetNewShaderModule();
EXPECT_CALL(api, DeviceCreateShaderModule(apiDevice, _)).WillOnce(Return(apiVsModule));
// Create the blend state descriptor
// Create the color state descriptor
dawnBlendDescriptor blendDescriptor;
blendDescriptor.operation = DAWN_BLEND_OPERATION_ADD;
blendDescriptor.srcFactor = DAWN_BLEND_FACTOR_ONE;
blendDescriptor.dstFactor = DAWN_BLEND_FACTOR_ONE;
dawnBlendStateDescriptor blendStateDescriptor;
blendStateDescriptor.nextInChain = nullptr;
blendStateDescriptor.alphaBlend = blendDescriptor;
blendStateDescriptor.colorBlend = blendDescriptor;
blendStateDescriptor.colorWriteMask = DAWN_COLOR_WRITE_MASK_ALL;
dawnColorStateDescriptor colorStateDescriptor;
colorStateDescriptor.nextInChain = nullptr;
colorStateDescriptor.format = DAWN_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM;
colorStateDescriptor.alphaBlend = blendDescriptor;
colorStateDescriptor.colorBlend = blendDescriptor;
colorStateDescriptor.colorWriteMask = DAWN_COLOR_WRITE_MASK_ALL;
// Create the input state
dawnInputStateBuilder inputStateBuilder = dawnDeviceCreateInputStateBuilder(device);
@@ -119,6 +120,7 @@ TEST_F(WireArgumentTests, CStringArgument) {
dawnDepthStencilStateDescriptor depthStencilState;
depthStencilState.nextInChain = nullptr;
depthStencilState.format = DAWN_TEXTURE_FORMAT_D32_FLOAT_S8_UINT;
depthStencilState.depthWriteEnabled = false;
depthStencilState.depthCompare = DAWN_COMPARE_FUNCTION_ALWAYS;
depthStencilState.stencilBack = stencilFace;
@@ -151,20 +153,8 @@ TEST_F(WireArgumentTests, CStringArgument) {
fragmentStage.entryPoint = "main";
pipelineDescriptor.fragmentStage = &fragmentStage;
dawnAttachmentsStateDescriptor attachmentsState;
attachmentsState.nextInChain = nullptr;
attachmentsState.numColorAttachments = 1;
dawnAttachmentDescriptor colorAttachment = {nullptr, DAWN_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM};
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.
attachmentsState.depthStencilAttachment = &colorAttachment;
pipelineDescriptor.attachmentsState = &attachmentsState;
pipelineDescriptor.numBlendStates = 1;
pipelineDescriptor.blendStates = &blendStateDescriptor;
pipelineDescriptor.numColorStates = 1;
pipelineDescriptor.colorStates = &colorStateDescriptor;
pipelineDescriptor.sampleCount = 1;
pipelineDescriptor.layout = layout;

View File

@@ -73,16 +73,17 @@ TEST_F(WireOptionalTests, OptionalStructPointer) {
dawnShaderModule apiVsModule = api.GetNewShaderModule();
EXPECT_CALL(api, DeviceCreateShaderModule(apiDevice, _)).WillOnce(Return(apiVsModule));
// Create the blend state descriptor
// Create the color state descriptor
dawnBlendDescriptor blendDescriptor;
blendDescriptor.operation = DAWN_BLEND_OPERATION_ADD;
blendDescriptor.srcFactor = DAWN_BLEND_FACTOR_ONE;
blendDescriptor.dstFactor = DAWN_BLEND_FACTOR_ONE;
dawnBlendStateDescriptor blendStateDescriptor;
blendStateDescriptor.nextInChain = nullptr;
blendStateDescriptor.alphaBlend = blendDescriptor;
blendStateDescriptor.colorBlend = blendDescriptor;
blendStateDescriptor.colorWriteMask = DAWN_COLOR_WRITE_MASK_ALL;
dawnColorStateDescriptor colorStateDescriptor;
colorStateDescriptor.nextInChain = nullptr;
colorStateDescriptor.format = DAWN_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM;
colorStateDescriptor.alphaBlend = blendDescriptor;
colorStateDescriptor.colorBlend = blendDescriptor;
colorStateDescriptor.colorWriteMask = DAWN_COLOR_WRITE_MASK_ALL;
// Create the input state
dawnInputStateBuilder inputStateBuilder = dawnDeviceCreateInputStateBuilder(device);
@@ -104,6 +105,7 @@ TEST_F(WireOptionalTests, OptionalStructPointer) {
dawnDepthStencilStateDescriptor depthStencilState;
depthStencilState.nextInChain = nullptr;
depthStencilState.format = DAWN_TEXTURE_FORMAT_D32_FLOAT_S8_UINT;
depthStencilState.depthWriteEnabled = false;
depthStencilState.depthCompare = DAWN_COMPARE_FUNCTION_ALWAYS;
depthStencilState.stencilBack = stencilFace;
@@ -136,20 +138,8 @@ TEST_F(WireOptionalTests, OptionalStructPointer) {
fragmentStage.entryPoint = "main";
pipelineDescriptor.fragmentStage = &fragmentStage;
dawnAttachmentsStateDescriptor attachmentsState;
attachmentsState.nextInChain = nullptr;
attachmentsState.numColorAttachments = 1;
dawnAttachmentDescriptor colorAttachment = {nullptr, DAWN_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM};
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.
attachmentsState.depthStencilAttachment = &colorAttachment;
pipelineDescriptor.attachmentsState = &attachmentsState;
pipelineDescriptor.numBlendStates = 1;
pipelineDescriptor.blendStates = &blendStateDescriptor;
pipelineDescriptor.numColorStates = 1;
pipelineDescriptor.colorStates = &colorStateDescriptor;
pipelineDescriptor.sampleCount = 1;
pipelineDescriptor.layout = layout;