Make ComboRenderPipelineDescriptor non copyable.

This causes subtle bugs in tests when pointers in combo render pipeline
descriptors point at other combo render pipeline descriptors.

BUG=dawn:22

Change-Id: I5234df26895986fd1d7a9b4e835598177581803a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/11340
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Corentin Wallez 2019-09-20 23:15:47 +00:00 committed by Commit Bot service account
parent 394553b02e
commit b8dbada76d
2 changed files with 35 additions and 19 deletions

View File

@ -704,25 +704,30 @@ TEST_F(RenderBundleValidationTest, PipelineColorFormatMismatch) {
renderBundleDesc.cColorFormats[1] = dawn::TextureFormat::RG16Float; renderBundleDesc.cColorFormats[1] = dawn::TextureFormat::RG16Float;
renderBundleDesc.cColorFormats[2] = dawn::TextureFormat::R16Sint; renderBundleDesc.cColorFormats[2] = dawn::TextureFormat::R16Sint;
utils::ComboRenderPipelineDescriptor renderPipelineDesc(device); auto SetupRenderPipelineDescForTest = [this](utils::ComboRenderPipelineDescriptor* desc) {
InitializeRenderPipelineDescriptor(&renderPipelineDesc); InitializeRenderPipelineDescriptor(desc);
renderPipelineDesc.colorStateCount = 3; desc->colorStateCount = 3;
renderPipelineDesc.cColorStates[0]->format = dawn::TextureFormat::RGBA8Unorm; desc->cColorStates[0]->format = dawn::TextureFormat::RGBA8Unorm;
renderPipelineDesc.cColorStates[1]->format = dawn::TextureFormat::RG16Float; desc->cColorStates[1]->format = dawn::TextureFormat::RG16Float;
renderPipelineDesc.cColorStates[2]->format = dawn::TextureFormat::R16Sint; desc->cColorStates[2]->format = dawn::TextureFormat::R16Sint;
};
// Test the success case. // Test the success case.
{ {
utils::ComboRenderPipelineDescriptor desc(device);
SetupRenderPipelineDescForTest(&desc);
dawn::RenderBundleEncoder renderBundleEncoder = dawn::RenderBundleEncoder renderBundleEncoder =
device.CreateRenderBundleEncoder(&renderBundleDesc); device.CreateRenderBundleEncoder(&renderBundleDesc);
dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&renderPipelineDesc); dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&desc);
renderBundleEncoder.SetPipeline(pipeline); renderBundleEncoder.SetPipeline(pipeline);
renderBundleEncoder.Finish(); renderBundleEncoder.Finish();
} }
// Test the failure case for mismatched format types. // Test the failure case for mismatched format types.
{ {
utils::ComboRenderPipelineDescriptor desc = renderPipelineDesc; utils::ComboRenderPipelineDescriptor desc(device);
SetupRenderPipelineDescForTest(&desc);
desc.cColorStates[1]->format = dawn::TextureFormat::RGBA8Unorm; desc.cColorStates[1]->format = dawn::TextureFormat::RGBA8Unorm;
dawn::RenderBundleEncoder renderBundleEncoder = dawn::RenderBundleEncoder renderBundleEncoder =
@ -734,7 +739,8 @@ TEST_F(RenderBundleValidationTest, PipelineColorFormatMismatch) {
// Test the failure case for missing format // Test the failure case for missing format
{ {
utils::ComboRenderPipelineDescriptor desc = renderPipelineDesc; utils::ComboRenderPipelineDescriptor desc(device);
SetupRenderPipelineDescForTest(&desc);
desc.colorStateCount = 2; desc.colorStateCount = 2;
dawn::RenderBundleEncoder renderBundleEncoder = dawn::RenderBundleEncoder renderBundleEncoder =
@ -752,27 +758,31 @@ TEST_F(RenderBundleValidationTest, PipelineDepthStencilFormatMismatch) {
renderBundleDesc.cColorFormats[0] = dawn::TextureFormat::RGBA8Unorm; renderBundleDesc.cColorFormats[0] = dawn::TextureFormat::RGBA8Unorm;
renderBundleDesc.depthStencilFormat = dawn::TextureFormat::Depth24PlusStencil8; renderBundleDesc.depthStencilFormat = dawn::TextureFormat::Depth24PlusStencil8;
utils::ComboRenderPipelineDescriptor renderPipelineDesc(device); auto SetupRenderPipelineDescForTest = [this](utils::ComboRenderPipelineDescriptor* desc) {
InitializeRenderPipelineDescriptor(&renderPipelineDesc); InitializeRenderPipelineDescriptor(desc);
renderPipelineDesc.colorStateCount = 1; desc->colorStateCount = 1;
renderPipelineDesc.cColorStates[0]->format = dawn::TextureFormat::RGBA8Unorm; desc->cColorStates[0]->format = dawn::TextureFormat::RGBA8Unorm;
renderPipelineDesc.depthStencilState = &renderPipelineDesc.cDepthStencilState; desc->depthStencilState = &desc->cDepthStencilState;
renderPipelineDesc.cDepthStencilState.format = dawn::TextureFormat::Depth24PlusStencil8; desc->cDepthStencilState.format = dawn::TextureFormat::Depth24PlusStencil8;
};
// Test the success case. // Test the success case.
{ {
utils::ComboRenderPipelineDescriptor desc(device);
SetupRenderPipelineDescForTest(&desc);
dawn::RenderBundleEncoder renderBundleEncoder = dawn::RenderBundleEncoder renderBundleEncoder =
device.CreateRenderBundleEncoder(&renderBundleDesc); device.CreateRenderBundleEncoder(&renderBundleDesc);
dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&renderPipelineDesc); dawn::RenderPipeline pipeline = device.CreateRenderPipeline(&desc);
renderBundleEncoder.SetPipeline(pipeline); renderBundleEncoder.SetPipeline(pipeline);
renderBundleEncoder.Finish(); renderBundleEncoder.Finish();
} }
// Test the failure case for mismatched format. // Test the failure case for mismatched format.
{ {
utils::ComboRenderPipelineDescriptor desc = renderPipelineDesc; utils::ComboRenderPipelineDescriptor desc(device);
SetupRenderPipelineDescForTest(&desc);
desc.cDepthStencilState.format = dawn::TextureFormat::Depth24Plus; desc.cDepthStencilState.format = dawn::TextureFormat::Depth24Plus;
desc.depthStencilState = &desc.cDepthStencilState;
dawn::RenderBundleEncoder renderBundleEncoder = dawn::RenderBundleEncoder renderBundleEncoder =
device.CreateRenderBundleEncoder(&renderBundleDesc); device.CreateRenderBundleEncoder(&renderBundleDesc);
@ -783,7 +793,8 @@ TEST_F(RenderBundleValidationTest, PipelineDepthStencilFormatMismatch) {
// Test the failure case for missing format. // Test the failure case for missing format.
{ {
utils::ComboRenderPipelineDescriptor desc = renderPipelineDesc; utils::ComboRenderPipelineDescriptor desc(device);
SetupRenderPipelineDescForTest(&desc);
desc.depthStencilState = nullptr; desc.depthStencilState = nullptr;
dawn::RenderBundleEncoder renderBundleEncoder = dawn::RenderBundleEncoder renderBundleEncoder =

View File

@ -35,6 +35,11 @@ namespace utils {
public: public:
ComboRenderPipelineDescriptor(const dawn::Device& device); ComboRenderPipelineDescriptor(const dawn::Device& device);
ComboRenderPipelineDescriptor(const ComboRenderPipelineDescriptor&) = delete;
ComboRenderPipelineDescriptor& operator=(const ComboRenderPipelineDescriptor&) = delete;
ComboRenderPipelineDescriptor(ComboRenderPipelineDescriptor&&) = delete;
ComboRenderPipelineDescriptor& operator=(ComboRenderPipelineDescriptor&&) = delete;
dawn::PipelineStageDescriptor cFragmentStage; dawn::PipelineStageDescriptor cFragmentStage;
ComboVertexInputDescriptor cVertexInput; ComboVertexInputDescriptor cVertexInput;