Update majority of unittests to use RenderPipelineDescriptor2

Bug: dawn:642
Change-Id: I437967f590e03b7d85d7eda28400db9e3e5d0745
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/44820
Auto-Submit: Brandon Jones <bajones@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Brandon Jones <bajones@chromium.org>
This commit is contained in:
Brandon Jones 2021-03-17 17:48:59 +00:00 committed by Commit Bot service account
parent 6f9bc3ac2c
commit 6e5d47a396
14 changed files with 247 additions and 238 deletions

View File

@ -1100,13 +1100,13 @@ class SetBindGroupValidationTest : public ValidationTest {
[[stage(fragment)]] fn main() -> void {
})");
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device);
pipelineDescriptor.vertexStage.module = vsModule;
pipelineDescriptor.cFragmentStage.module = fsModule;
utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertex.module = vsModule;
pipelineDescriptor.cFragment.module = fsModule;
wgpu::PipelineLayout pipelineLayout =
utils::MakeBasicPipelineLayout(device, &mBindGroupLayout);
pipelineDescriptor.layout = pipelineLayout;
return device.CreateRenderPipeline(&pipelineDescriptor);
return device.CreateRenderPipeline2(&pipelineDescriptor);
}
wgpu::ComputePipeline CreateComputePipeline() {
@ -1559,11 +1559,11 @@ class SetBindGroupPersistenceValidationTest : public ValidationTest {
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, ss.str().c_str());
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device);
pipelineDescriptor.vertexStage.module = mVsModule;
pipelineDescriptor.cFragmentStage.module = fsModule;
utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertex.module = mVsModule;
pipelineDescriptor.cFragment.module = fsModule;
pipelineDescriptor.layout = pipelineLayout;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDescriptor);
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&pipelineDescriptor);
return std::make_tuple(bindGroupLayouts, pipeline);
}
@ -1697,12 +1697,12 @@ class BindGroupLayoutCompatibilityTest : public ValidationTest {
wgpu::PipelineLayoutDescriptor descriptor;
descriptor.bindGroupLayoutCount = bindGroupLayout.size();
descriptor.bindGroupLayouts = bindGroupLayout.data();
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device);
pipelineDescriptor.vertexStage.module = vsModule;
pipelineDescriptor.cFragmentStage.module = fsModule;
utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertex.module = vsModule;
pipelineDescriptor.cFragment.module = fsModule;
wgpu::PipelineLayout pipelineLayout = device.CreatePipelineLayout(&descriptor);
pipelineDescriptor.layout = pipelineLayout;
return device.CreateRenderPipeline(&pipelineDescriptor);
return device.CreateRenderPipeline2(&pipelineDescriptor);
}
wgpu::RenderPipeline CreateRenderPipeline(std::vector<wgpu::BindGroupLayout> bindGroupLayouts) {
@ -2058,13 +2058,13 @@ class ComparisonSamplerBindingTest : public ValidationTest {
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, fragmentSource);
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device);
pipelineDescriptor.vertexStage.module = vsModule;
pipelineDescriptor.cFragmentStage.module = fsModule;
utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertex.module = vsModule;
pipelineDescriptor.cFragment.module = fsModule;
wgpu::PipelineLayout pipelineLayout =
utils::MakeBasicPipelineLayout(device, bindGroupLayout);
pipelineDescriptor.layout = pipelineLayout;
return device.CreateRenderPipeline(&pipelineDescriptor);
return device.CreateRenderPipeline2(&pipelineDescriptor);
}
};

View File

@ -38,12 +38,12 @@ class DrawIndirectValidationTest : public ValidationTest {
// Set up render pipeline
wgpu::PipelineLayout pipelineLayout = utils::MakeBasicPipelineLayout(device, nullptr);
utils::ComboRenderPipelineDescriptor descriptor(device);
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.layout = pipelineLayout;
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = fsModule;
pipeline = device.CreateRenderPipeline(&descriptor);
pipeline = device.CreateRenderPipeline2(&descriptor);
}
void ValidateExpectation(wgpu::CommandEncoder encoder, utils::Expectation expectation) {

View File

@ -26,12 +26,12 @@ class GetBindGroupLayoutTests : public ValidationTest {
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, shader);
utils::ComboRenderPipelineDescriptor descriptor(device);
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.layout = nullptr;
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = fsModule;
return device.CreateRenderPipeline(&descriptor);
return device.CreateRenderPipeline2(&descriptor);
}
};
@ -67,12 +67,12 @@ TEST_F(GetBindGroupLayoutTests, SameObject) {
[[stage(fragment)]] fn main() -> void {
})");
utils::ComboRenderPipelineDescriptor descriptor(device);
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.layout = nullptr;
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = fsModule;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&descriptor);
// The same value is returned for the same index.
EXPECT_EQ(pipeline.GetBindGroupLayout(0).Get(), pipeline.GetBindGroupLayout(0).Get());
@ -461,12 +461,12 @@ TEST_F(GetBindGroupLayoutTests, DuplicateBinding) {
[[stage(fragment)]] fn main() -> void {
})");
utils::ComboRenderPipelineDescriptor descriptor(device);
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.layout = nullptr;
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = fsModule;
device.CreateRenderPipeline(&descriptor);
device.CreateRenderPipeline2(&descriptor);
}
// Test that minBufferSize is set on the BGL and that the max of the min buffer sizes is used.
@ -527,30 +527,30 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
binding.buffer.minBindingSize = 64;
wgpu::BindGroupLayout bgl64 = device.CreateBindGroupLayout(&desc);
utils::ComboRenderPipelineDescriptor descriptor(device);
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.layout = nullptr;
// Check with both stages using 4 bytes.
{
descriptor.vertexStage.module = vsModule4;
descriptor.cFragmentStage.module = fsModule4;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
descriptor.vertex.module = vsModule4;
descriptor.cFragment.module = fsModule4;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&descriptor);
EXPECT_EQ(pipeline.GetBindGroupLayout(0).Get(), bgl4.Get());
}
// Check that the max is taken between 4 and 64.
{
descriptor.vertexStage.module = vsModule64;
descriptor.cFragmentStage.module = fsModule4;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
descriptor.vertex.module = vsModule64;
descriptor.cFragment.module = fsModule4;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&descriptor);
EXPECT_EQ(pipeline.GetBindGroupLayout(0).Get(), bgl64.Get());
}
// Check that the order doesn't change that the max is taken.
{
descriptor.vertexStage.module = vsModule4;
descriptor.cFragmentStage.module = fsModule64;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
descriptor.vertex.module = vsModule4;
descriptor.cFragment.module = fsModule64;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&descriptor);
EXPECT_EQ(pipeline.GetBindGroupLayout(0).Get(), bgl64.Get());
}
}
@ -589,14 +589,14 @@ TEST_F(GetBindGroupLayoutTests, StageAggregation) {
desc.entryCount = 1;
desc.entries = &binding;
utils::ComboRenderPipelineDescriptor descriptor(device);
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.layout = nullptr;
// Check with only the vertex shader using the sampler
{
descriptor.vertexStage.module = vsModuleSampler;
descriptor.cFragmentStage.module = fsModuleNoSampler;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
descriptor.vertex.module = vsModuleSampler;
descriptor.cFragment.module = fsModuleNoSampler;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&descriptor);
binding.visibility = wgpu::ShaderStage::Vertex;
EXPECT_EQ(pipeline.GetBindGroupLayout(0).Get(), device.CreateBindGroupLayout(&desc).Get());
@ -604,9 +604,9 @@ TEST_F(GetBindGroupLayoutTests, StageAggregation) {
// Check with only the fragment shader using the sampler
{
descriptor.vertexStage.module = vsModuleNoSampler;
descriptor.cFragmentStage.module = fsModuleSampler;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
descriptor.vertex.module = vsModuleNoSampler;
descriptor.cFragment.module = fsModuleSampler;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&descriptor);
binding.visibility = wgpu::ShaderStage::Fragment;
EXPECT_EQ(pipeline.GetBindGroupLayout(0).Get(), device.CreateBindGroupLayout(&desc).Get());
@ -614,9 +614,9 @@ TEST_F(GetBindGroupLayoutTests, StageAggregation) {
// Check with both shaders using the sampler
{
descriptor.vertexStage.module = vsModuleSampler;
descriptor.cFragmentStage.module = fsModuleSampler;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
descriptor.vertex.module = vsModuleSampler;
descriptor.cFragment.module = fsModuleSampler;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&descriptor);
binding.visibility = wgpu::ShaderStage::Fragment | wgpu::ShaderStage::Vertex;
EXPECT_EQ(pipeline.GetBindGroupLayout(0).Get(), device.CreateBindGroupLayout(&desc).Get());
@ -643,12 +643,12 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingType) {
[[stage(fragment)]] fn main() -> void {
})");
utils::ComboRenderPipelineDescriptor descriptor(device);
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.layout = nullptr;
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = fsModule;
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline2(&descriptor));
}
// Test it is invalid to have conflicting binding texture multisampling in the shaders.
@ -665,12 +665,12 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureMultisampling) {
[[stage(fragment)]] fn main() -> void {
})");
utils::ComboRenderPipelineDescriptor descriptor(device);
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.layout = nullptr;
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = fsModule;
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline2(&descriptor));
}
// Test it is invalid to have conflicting binding texture dimension in the shaders.
@ -687,12 +687,12 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingViewDimension) {
[[stage(fragment)]] fn main() -> void {
})");
utils::ComboRenderPipelineDescriptor descriptor(device);
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.layout = nullptr;
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = fsModule;
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline2(&descriptor));
}
// Test it is invalid to have conflicting binding texture component type in the shaders.
@ -709,12 +709,12 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureComponentType) {
[[stage(fragment)]] fn main() -> void {
})");
utils::ComboRenderPipelineDescriptor descriptor(device);
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.layout = nullptr;
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = fsModule;
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline2(&descriptor));
}
// Test it is an error to query an out of range bind group layout.
@ -797,12 +797,12 @@ TEST_F(GetBindGroupLayoutTests, Reflection) {
[[stage(fragment)]] fn main() -> void {
})");
utils::ComboRenderPipelineDescriptor pipelineDesc(device);
utils::ComboRenderPipelineDescriptor2 pipelineDesc;
pipelineDesc.layout = pipelineLayout;
pipelineDesc.vertexStage.module = vsModule;
pipelineDesc.cFragmentStage.module = fsModule;
pipelineDesc.vertex.module = vsModule;
pipelineDesc.cFragment.module = fsModule;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDesc);
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&pipelineDesc);
EXPECT_EQ(pipeline.GetBindGroupLayout(0).Get(), bindGroupLayout.Get());

View File

@ -34,14 +34,14 @@ class IndexBufferValidationTest : public ValidationTest {
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);
})");
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.primitiveTopology = primitiveTopology;
descriptor.cVertexState.indexFormat = format;
descriptor.cColorStates[0].format = wgpu::TextureFormat::RGBA8Unorm;
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = fsModule;
descriptor.primitive.topology = primitiveTopology;
descriptor.primitive.stripIndexFormat = format;
descriptor.cTargets[0].format = wgpu::TextureFormat::RGBA8Unorm;
return device.CreateRenderPipeline(&descriptor);
return device.CreateRenderPipeline2(&descriptor);
}
};

View File

@ -172,9 +172,9 @@ class MinBufferSizeTestsBase : public ValidationTest {
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, fragShader.c_str());
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device);
pipelineDescriptor.vertexStage.module = vsModule;
pipelineDescriptor.cFragmentStage.module = fsModule;
utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertex.module = vsModule;
pipelineDescriptor.cFragment.module = fsModule;
pipelineDescriptor.layout = nullptr;
if (!layouts.empty()) {
wgpu::PipelineLayoutDescriptor descriptor;
@ -183,7 +183,7 @@ class MinBufferSizeTestsBase : public ValidationTest {
pipelineDescriptor.layout = device.CreatePipelineLayout(&descriptor);
}
return device.CreateRenderPipeline(&pipelineDescriptor);
return device.CreateRenderPipeline2(&pipelineDescriptor);
}
// Creates render pipeline with default layout

View File

@ -67,9 +67,9 @@ namespace {
pipelineLayout = device.CreatePipelineLayout(&pipelineLayoutDesc);
utils::ComboRenderPipelineDescriptor descriptor(device);
utils::ComboRenderPipelineDescriptor2 descriptor;
InitializeRenderPipelineDescriptor(&descriptor);
pipeline = device.CreateRenderPipeline(&descriptor);
pipeline = device.CreateRenderPipeline2(&descriptor);
float data[8];
wgpu::Buffer buffer = utils::CreateBufferFromData(device, data, 8 * sizeof(float),
@ -99,15 +99,15 @@ namespace {
{1, vertexStorageBuffer, 0, sizeof(kVertices)}});
}
void InitializeRenderPipelineDescriptor(utils::ComboRenderPipelineDescriptor* descriptor) {
void InitializeRenderPipelineDescriptor(utils::ComboRenderPipelineDescriptor2* descriptor) {
descriptor->layout = pipelineLayout;
descriptor->vertexStage.module = vsModule;
descriptor->cFragmentStage.module = fsModule;
descriptor->cVertexState.vertexBufferCount = 1;
descriptor->cVertexState.cVertexBuffers[0].arrayStride = 2 * sizeof(float);
descriptor->cVertexState.cVertexBuffers[0].attributeCount = 1;
descriptor->cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x2;
descriptor->cVertexState.cAttributes[0].shaderLocation = 0;
descriptor->vertex.module = vsModule;
descriptor->cFragment.module = fsModule;
descriptor->vertex.bufferCount = 1;
descriptor->cBuffers[0].arrayStride = 2 * sizeof(float);
descriptor->cBuffers[0].attributeCount = 1;
descriptor->cAttributes[0].format = wgpu::VertexFormat::Float32x2;
descriptor->cAttributes[0].shaderLocation = 0;
}
wgpu::ShaderModule vsModule;
@ -730,48 +730,48 @@ TEST_F(RenderBundleValidationTest, PipelineColorFormatMismatch) {
renderBundleDesc.cColorFormats[1] = wgpu::TextureFormat::RG16Float;
renderBundleDesc.cColorFormats[2] = wgpu::TextureFormat::R16Sint;
auto SetupRenderPipelineDescForTest = [this](utils::ComboRenderPipelineDescriptor* desc) {
auto SetupRenderPipelineDescForTest = [this](utils::ComboRenderPipelineDescriptor2* desc) {
InitializeRenderPipelineDescriptor(desc);
desc->colorStateCount = 3;
desc->cColorStates[0].format = wgpu::TextureFormat::RGBA8Unorm;
desc->cColorStates[1].format = wgpu::TextureFormat::RG16Float;
desc->cColorStates[2].format = wgpu::TextureFormat::R16Sint;
desc->cFragment.targetCount = 3;
desc->cTargets[0].format = wgpu::TextureFormat::RGBA8Unorm;
desc->cTargets[1].format = wgpu::TextureFormat::RG16Float;
desc->cTargets[2].format = wgpu::TextureFormat::R16Sint;
};
// Test the success case.
{
utils::ComboRenderPipelineDescriptor desc(device);
utils::ComboRenderPipelineDescriptor2 desc;
SetupRenderPipelineDescForTest(&desc);
wgpu::RenderBundleEncoder renderBundleEncoder =
device.CreateRenderBundleEncoder(&renderBundleDesc);
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&desc);
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&desc);
renderBundleEncoder.SetPipeline(pipeline);
renderBundleEncoder.Finish();
}
// Test the failure case for mismatched format types.
{
utils::ComboRenderPipelineDescriptor desc(device);
utils::ComboRenderPipelineDescriptor2 desc;
SetupRenderPipelineDescForTest(&desc);
desc.cColorStates[1].format = wgpu::TextureFormat::RGBA8Unorm;
desc.cTargets[1].format = wgpu::TextureFormat::RGBA8Unorm;
wgpu::RenderBundleEncoder renderBundleEncoder =
device.CreateRenderBundleEncoder(&renderBundleDesc);
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&desc);
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&desc);
renderBundleEncoder.SetPipeline(pipeline);
ASSERT_DEVICE_ERROR(renderBundleEncoder.Finish());
}
// Test the failure case for missing format
{
utils::ComboRenderPipelineDescriptor desc(device);
utils::ComboRenderPipelineDescriptor2 desc;
SetupRenderPipelineDescForTest(&desc);
desc.colorStateCount = 2;
desc.cFragment.targetCount = 2;
wgpu::RenderBundleEncoder renderBundleEncoder =
device.CreateRenderBundleEncoder(&renderBundleDesc);
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&desc);
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&desc);
renderBundleEncoder.SetPipeline(pipeline);
ASSERT_DEVICE_ERROR(renderBundleEncoder.Finish());
}
@ -784,48 +784,47 @@ TEST_F(RenderBundleValidationTest, PipelineDepthStencilFormatMismatch) {
renderBundleDesc.cColorFormats[0] = wgpu::TextureFormat::RGBA8Unorm;
renderBundleDesc.depthStencilFormat = wgpu::TextureFormat::Depth24PlusStencil8;
auto SetupRenderPipelineDescForTest = [this](utils::ComboRenderPipelineDescriptor* desc) {
auto SetupRenderPipelineDescForTest = [this](utils::ComboRenderPipelineDescriptor2* desc) {
InitializeRenderPipelineDescriptor(desc);
desc->colorStateCount = 1;
desc->cColorStates[0].format = wgpu::TextureFormat::RGBA8Unorm;
desc->depthStencilState = &desc->cDepthStencilState;
desc->cDepthStencilState.format = wgpu::TextureFormat::Depth24PlusStencil8;
desc->cFragment.targetCount = 1;
desc->cTargets[0].format = wgpu::TextureFormat::RGBA8Unorm;
};
// Test the success case.
{
utils::ComboRenderPipelineDescriptor desc(device);
utils::ComboRenderPipelineDescriptor2 desc;
SetupRenderPipelineDescForTest(&desc);
desc.EnableDepthStencil(wgpu::TextureFormat::Depth24PlusStencil8);
wgpu::RenderBundleEncoder renderBundleEncoder =
device.CreateRenderBundleEncoder(&renderBundleDesc);
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&desc);
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&desc);
renderBundleEncoder.SetPipeline(pipeline);
renderBundleEncoder.Finish();
}
// Test the failure case for mismatched format.
{
utils::ComboRenderPipelineDescriptor desc(device);
utils::ComboRenderPipelineDescriptor2 desc;
SetupRenderPipelineDescForTest(&desc);
desc.cDepthStencilState.format = wgpu::TextureFormat::Depth24Plus;
desc.EnableDepthStencil(wgpu::TextureFormat::Depth24Plus);
wgpu::RenderBundleEncoder renderBundleEncoder =
device.CreateRenderBundleEncoder(&renderBundleDesc);
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&desc);
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&desc);
renderBundleEncoder.SetPipeline(pipeline);
ASSERT_DEVICE_ERROR(renderBundleEncoder.Finish());
}
// Test the failure case for missing format.
{
utils::ComboRenderPipelineDescriptor desc(device);
utils::ComboRenderPipelineDescriptor2 desc;
SetupRenderPipelineDescForTest(&desc);
desc.depthStencilState = nullptr;
desc.depthStencil = nullptr;
wgpu::RenderBundleEncoder renderBundleEncoder =
device.CreateRenderBundleEncoder(&renderBundleDesc);
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&desc);
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&desc);
renderBundleEncoder.SetPipeline(pipeline);
ASSERT_DEVICE_ERROR(renderBundleEncoder.Finish());
}
@ -838,28 +837,28 @@ TEST_F(RenderBundleValidationTest, PipelineSampleCountMismatch) {
renderBundleDesc.cColorFormats[0] = wgpu::TextureFormat::RGBA8Unorm;
renderBundleDesc.sampleCount = 4;
utils::ComboRenderPipelineDescriptor renderPipelineDesc(device);
utils::ComboRenderPipelineDescriptor2 renderPipelineDesc;
InitializeRenderPipelineDescriptor(&renderPipelineDesc);
renderPipelineDesc.colorStateCount = 1;
renderPipelineDesc.cColorStates[0].format = wgpu::TextureFormat::RGBA8Unorm;
renderPipelineDesc.sampleCount = 4;
renderPipelineDesc.cFragment.targetCount = 1;
renderPipelineDesc.cTargets[0].format = wgpu::TextureFormat::RGBA8Unorm;
renderPipelineDesc.multisample.count = 4;
// Test the success case.
{
wgpu::RenderBundleEncoder renderBundleEncoder =
device.CreateRenderBundleEncoder(&renderBundleDesc);
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&renderPipelineDesc);
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&renderPipelineDesc);
renderBundleEncoder.SetPipeline(pipeline);
renderBundleEncoder.Finish();
}
// Test the failure case.
{
renderPipelineDesc.sampleCount = 1;
renderPipelineDesc.multisample.count = 1;
wgpu::RenderBundleEncoder renderBundleEncoder =
device.CreateRenderBundleEncoder(&renderBundleDesc);
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&renderPipelineDesc);
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&renderPipelineDesc);
renderBundleEncoder.SetPipeline(pipeline);
ASSERT_DEVICE_ERROR(renderBundleEncoder.Finish());
}

View File

@ -87,7 +87,7 @@ TEST_F(RenderPipelineValidationTest, DepthBiasParameterNotBeNaN) {
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = fsModule;
descriptor.depthStencil = &descriptor.cDepthStencil;
descriptor.EnableDepthStencil();
device.CreateRenderPipeline2(&descriptor);
}
@ -96,8 +96,8 @@ TEST_F(RenderPipelineValidationTest, DepthBiasParameterNotBeNaN) {
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = fsModule;
descriptor.cDepthStencil.depthBiasClamp = INFINITY;
descriptor.depthStencil = &descriptor.cDepthStencil;
wgpu::DepthStencilState* depthStencil = descriptor.EnableDepthStencil();
depthStencil->depthBiasClamp = INFINITY;
device.CreateRenderPipeline2(&descriptor);
}
// NAN depth bias clamp is invalid
@ -105,8 +105,8 @@ TEST_F(RenderPipelineValidationTest, DepthBiasParameterNotBeNaN) {
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = fsModule;
descriptor.cDepthStencil.depthBiasClamp = NAN;
descriptor.depthStencil = &descriptor.cDepthStencil;
wgpu::DepthStencilState* depthStencil = descriptor.EnableDepthStencil();
depthStencil->depthBiasClamp = NAN;
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline2(&descriptor));
}
@ -115,8 +115,8 @@ TEST_F(RenderPipelineValidationTest, DepthBiasParameterNotBeNaN) {
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = fsModule;
descriptor.cDepthStencil.depthBiasSlopeScale = INFINITY;
descriptor.depthStencil = &descriptor.cDepthStencil;
wgpu::DepthStencilState* depthStencil = descriptor.EnableDepthStencil();
depthStencil->depthBiasSlopeScale = INFINITY;
device.CreateRenderPipeline2(&descriptor);
}
// NAN depth bias slope is invalid
@ -124,8 +124,8 @@ TEST_F(RenderPipelineValidationTest, DepthBiasParameterNotBeNaN) {
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = fsModule;
descriptor.cDepthStencil.depthBiasSlopeScale = NAN;
descriptor.depthStencil = &descriptor.cDepthStencil;
wgpu::DepthStencilState* depthStencil = descriptor.EnableDepthStencil();
depthStencil->depthBiasSlopeScale = NAN;
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline2(&descriptor));
}
}
@ -185,9 +185,9 @@ TEST_F(RenderPipelineValidationTest, FragmentOutputFormatCompatibility) {
for (size_t i = 0; i < kNumTextureFormatBaseType; ++i) {
for (size_t j = 0; j < kNumTextureFormatBaseType; ++j) {
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.vertexStage.module = vsModule;
descriptor.cColorStates[0].format = kColorFormats[j];
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertex.module = vsModule;
descriptor.cTargets[0].format = kColorFormats[j];
std::ostringstream stream;
stream << R"(
@ -195,13 +195,13 @@ TEST_F(RenderPipelineValidationTest, FragmentOutputFormatCompatibility) {
<< kScalarTypes[i] << R"(>;
[[stage(fragment)]] fn main() -> void {
})";
descriptor.cFragmentStage.module =
descriptor.cFragment.module =
utils::CreateShaderModuleFromWGSL(device, stream.str().c_str());
if (i == j) {
device.CreateRenderPipeline(&descriptor);
device.CreateRenderPipeline2(&descriptor);
} else {
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline2(&descriptor));
}
}
}
@ -243,31 +243,29 @@ TEST_F(RenderPipelineValidationTest, SampleCountCompatibilityWithRenderPass) {
baseTextureDescriptor.dimension = wgpu::TextureDimension::e2D;
baseTextureDescriptor.usage = wgpu::TextureUsage::RenderAttachment;
utils::ComboRenderPipelineDescriptor nonMultisampledPipelineDescriptor(device);
nonMultisampledPipelineDescriptor.sampleCount = 1;
nonMultisampledPipelineDescriptor.vertexStage.module = vsModule;
nonMultisampledPipelineDescriptor.cFragmentStage.module = fsModule;
utils::ComboRenderPipelineDescriptor2 nonMultisampledPipelineDescriptor;
nonMultisampledPipelineDescriptor.multisample.count = 1;
nonMultisampledPipelineDescriptor.vertex.module = vsModule;
nonMultisampledPipelineDescriptor.cFragment.module = fsModule;
wgpu::RenderPipeline nonMultisampledPipeline =
device.CreateRenderPipeline(&nonMultisampledPipelineDescriptor);
device.CreateRenderPipeline2(&nonMultisampledPipelineDescriptor);
nonMultisampledPipelineDescriptor.colorStateCount = 0;
nonMultisampledPipelineDescriptor.depthStencilState =
&nonMultisampledPipelineDescriptor.cDepthStencilState;
nonMultisampledPipelineDescriptor.cFragment.targetCount = 0;
nonMultisampledPipelineDescriptor.EnableDepthStencil();
wgpu::RenderPipeline nonMultisampledPipelineWithDepthStencilOnly =
device.CreateRenderPipeline(&nonMultisampledPipelineDescriptor);
device.CreateRenderPipeline2(&nonMultisampledPipelineDescriptor);
utils::ComboRenderPipelineDescriptor multisampledPipelineDescriptor(device);
multisampledPipelineDescriptor.sampleCount = kMultisampledCount;
multisampledPipelineDescriptor.vertexStage.module = vsModule;
multisampledPipelineDescriptor.cFragmentStage.module = fsModule;
utils::ComboRenderPipelineDescriptor2 multisampledPipelineDescriptor;
multisampledPipelineDescriptor.multisample.count = kMultisampledCount;
multisampledPipelineDescriptor.vertex.module = vsModule;
multisampledPipelineDescriptor.cFragment.module = fsModule;
wgpu::RenderPipeline multisampledPipeline =
device.CreateRenderPipeline(&multisampledPipelineDescriptor);
device.CreateRenderPipeline2(&multisampledPipelineDescriptor);
multisampledPipelineDescriptor.colorStateCount = 0;
multisampledPipelineDescriptor.depthStencilState =
&multisampledPipelineDescriptor.cDepthStencilState;
multisampledPipelineDescriptor.cFragment.targetCount = 0;
multisampledPipelineDescriptor.EnableDepthStencil();
wgpu::RenderPipeline multisampledPipelineWithDepthStencilOnly =
device.CreateRenderPipeline(&multisampledPipelineDescriptor);
device.CreateRenderPipeline2(&multisampledPipelineDescriptor);
// It is not allowed to use multisampled render pass and non-multisampled render pipeline.
{
@ -406,8 +404,8 @@ TEST_F(RenderPipelineValidationTest, TextureComponentTypeCompatibility) {
for (size_t i = 0; i < kNumTextureComponentType; ++i) {
for (size_t j = 0; j < kNumTextureComponentType; ++j) {
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.vertexStage.module = vsModule;
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertex.module = vsModule;
std::ostringstream stream;
stream << R"(
@ -416,7 +414,7 @@ TEST_F(RenderPipelineValidationTest, TextureComponentTypeCompatibility) {
[[stage(fragment)]] fn main() -> void {
})";
descriptor.cFragmentStage.module =
descriptor.cFragment.module =
utils::CreateShaderModuleFromWGSL(device, stream.str().c_str());
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
@ -424,9 +422,9 @@ TEST_F(RenderPipelineValidationTest, TextureComponentTypeCompatibility) {
descriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl);
if (i == j) {
device.CreateRenderPipeline(&descriptor);
device.CreateRenderPipeline2(&descriptor);
} else {
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline2(&descriptor));
}
}
}
@ -455,8 +453,8 @@ TEST_F(RenderPipelineValidationTest, TextureViewDimensionCompatibility) {
for (size_t i = 0; i < kNumTextureViewDimensions; ++i) {
for (size_t j = 0; j < kNumTextureViewDimensions; ++j) {
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.vertexStage.module = vsModule;
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertex.module = vsModule;
std::ostringstream stream;
stream << R"(
@ -464,7 +462,7 @@ TEST_F(RenderPipelineValidationTest, TextureViewDimensionCompatibility) {
<< kTextureKeywords[i] << R"(<f32>;
[[stage(fragment)]] fn main() -> void {
})";
descriptor.cFragmentStage.module =
descriptor.cFragment.module =
utils::CreateShaderModuleFromWGSL(device, stream.str().c_str());
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
@ -473,9 +471,9 @@ TEST_F(RenderPipelineValidationTest, TextureViewDimensionCompatibility) {
descriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl);
if (i == j) {
device.CreateRenderPipeline(&descriptor);
device.CreateRenderPipeline2(&descriptor);
} else {
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline2(&descriptor));
}
}
}
@ -494,11 +492,11 @@ TEST_F(RenderPipelineValidationTest, StorageBufferInVertexShaderNoLayout) {
dst.data[VertexIndex] = 0x1234u;
})");
utils::ComboRenderPipelineDescriptor descriptor(device);
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.layout = nullptr;
descriptor.vertexStage.module = vsModuleWithStorageBuffer;
descriptor.cFragmentStage.module = fsModule;
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
descriptor.vertex.module = vsModuleWithStorageBuffer;
descriptor.cFragment.module = fsModule;
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline2(&descriptor));
}
// Tests that strip primitive topologies require an index format
@ -519,37 +517,37 @@ TEST_F(RenderPipelineValidationTest, StripIndexFormatRequired) {
for (wgpu::PrimitiveTopology primitiveTopology : kStripTopologyTypes) {
for (wgpu::IndexFormat indexFormat : kIndexFormatTypes) {
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.primitiveTopology = primitiveTopology;
descriptor.cVertexState.indexFormat = indexFormat;
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = fsModule;
descriptor.primitive.topology = primitiveTopology;
descriptor.primitive.stripIndexFormat = indexFormat;
if (indexFormat == wgpu::IndexFormat::Undefined) {
// Fail because the index format is undefined and the primitive
// topology is a strip type.
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline2(&descriptor));
} else {
// Succeeds because the index format is given.
device.CreateRenderPipeline(&descriptor);
device.CreateRenderPipeline2(&descriptor);
}
}
}
for (wgpu::PrimitiveTopology primitiveTopology : kListTopologyTypes) {
for (wgpu::IndexFormat indexFormat : kIndexFormatTypes) {
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.primitiveTopology = primitiveTopology;
descriptor.cVertexState.indexFormat = indexFormat;
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = fsModule;
descriptor.primitive.topology = primitiveTopology;
descriptor.primitive.stripIndexFormat = indexFormat;
if (indexFormat == wgpu::IndexFormat::Undefined) {
// Succeeds even when the index format is undefined because the
// primitive topology isn't a strip type.
device.CreateRenderPipeline(&descriptor);
device.CreateRenderPipeline2(&descriptor);
} else {
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline2(&descriptor));
}
}
}

View File

@ -53,11 +53,11 @@ namespace {
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[stage(fragment)]] fn main() -> void {
})");
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device);
pipelineDescriptor.vertexStage.module = vsModule;
pipelineDescriptor.cFragmentStage.module = fsModule;
utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertex.module = vsModule;
pipelineDescriptor.cFragment.module = fsModule;
pipelineDescriptor.layout = utils::MakeBasicPipelineLayout(device, nullptr);
return device.CreateRenderPipeline(&pipelineDescriptor);
return device.CreateRenderPipeline2(&pipelineDescriptor);
}
wgpu::ComputePipeline CreateNoOpComputePipeline() {
@ -782,11 +782,11 @@ namespace {
[[group(0), binding(0)]] var<storage_buffer> rBuffer : [[access(read)]] RBuffer;
[[stage(fragment)]] fn main() -> void {
})");
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device);
pipelineDescriptor.vertexStage.module = vsModule;
pipelineDescriptor.cFragmentStage.module = fsModule;
utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertex.module = vsModule;
pipelineDescriptor.cFragment.module = fsModule;
pipelineDescriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl0);
wgpu::RenderPipeline rp = device.CreateRenderPipeline(&pipelineDescriptor);
wgpu::RenderPipeline rp = device.CreateRenderPipeline2(&pipelineDescriptor);
// Resource in bg1 conflicts with resources used in bg0. However, bindings in bg1 is
// not used in pipeline. But we still track this binding.
@ -1557,11 +1557,11 @@ namespace {
[[group(0), binding(0)]] var tex : [[access(read)]] texture_storage_2d<rgba8unorm>;
[[stage(fragment)]] fn main() -> void {
})");
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device);
pipelineDescriptor.vertexStage.module = vsModule;
pipelineDescriptor.cFragmentStage.module = fsModule;
utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertex.module = vsModule;
pipelineDescriptor.cFragment.module = fsModule;
pipelineDescriptor.layout = utils::MakeBasicPipelineLayout(device, &readBGL);
wgpu::RenderPipeline rp = device.CreateRenderPipeline(&pipelineDescriptor);
wgpu::RenderPipeline rp = device.CreateRenderPipeline2(&pipelineDescriptor);
// Texture binding in readBG conflicts with texture binding in writeBG. The binding
// in writeBG is not used in pipeline. But we still track this binding.

View File

@ -128,11 +128,11 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
Position = textureLoad(image0, vec2<i32>(i32(VertexIndex), 0));
})");
utils::ComboRenderPipelineDescriptor descriptor(device);
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.layout = nullptr;
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = mDefaultFSModule;
device.CreateRenderPipeline(&descriptor);
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = mDefaultFSModule;
device.CreateRenderPipeline2(&descriptor);
}
// Read-only storage textures can be declared in a fragment shader.
@ -145,11 +145,11 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
fragColor = textureLoad(image0, vec2<i32>(FragCoord.xy));
})");
utils::ComboRenderPipelineDescriptor descriptor(device);
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.layout = nullptr;
descriptor.vertexStage.module = mDefaultVSModule;
descriptor.cFragmentStage.module = fsModule;
device.CreateRenderPipeline(&descriptor);
descriptor.vertex.module = mDefaultVSModule;
descriptor.cFragment.module = fsModule;
device.CreateRenderPipeline2(&descriptor);
}
// Write-only storage textures cannot be declared in a vertex shader.
@ -161,11 +161,11 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
textureStore(image0, vec2<i32>(i32(vertex_index), 0), vec4<f32>(1.0, 0.0, 0.0, 1.0));
})");
utils::ComboRenderPipelineDescriptor descriptor(device);
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.layout = nullptr;
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = mDefaultFSModule;
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = mDefaultFSModule;
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline2(&descriptor));
}
// Write-only storage textures can be declared in a fragment shader.
@ -177,11 +177,11 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
textureStore(image0, vec2<i32>(frag_coord.xy), vec4<f32>(1.0, 0.0, 0.0, 1.0));
})");
utils::ComboRenderPipelineDescriptor descriptor(device);
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.layout = nullptr;
descriptor.vertexStage.module = mDefaultVSModule;
descriptor.cFragmentStage.module = fsModule;
device.CreateRenderPipeline(&descriptor);
descriptor.vertex.module = mDefaultVSModule;
descriptor.cFragment.module = fsModule;
device.CreateRenderPipeline2(&descriptor);
}
}

View File

@ -48,12 +48,12 @@ TEST_F(UnsafeAPIValidationTest, DrawIndexedIndirectDisallowed) {
bundleDesc.colorFormatsCount = 1;
bundleDesc.cColorFormats[0] = renderPass.attachmentFormat;
utils::ComboRenderPipelineDescriptor desc(device);
desc.vertexStage.module =
utils::ComboRenderPipelineDescriptor2 desc;
desc.vertex.module =
utils::CreateShaderModuleFromWGSL(device, "[[stage(vertex)]] fn main() -> void {}");
desc.cFragmentStage.module =
desc.cFragment.module =
utils::CreateShaderModuleFromWGSL(device, "[[stage(fragment)]] fn main() -> void {}");
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&desc);
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&desc);
// Control cases: DrawIndirect and DrawIndexed are allowed inside a render pass.
{
@ -249,7 +249,7 @@ TEST_F(UnsafeAPIValidationTest, CreateRenderPipelineAsyncDisallowed) {
desc.cColorStates[0].format = wgpu::TextureFormat::RGBA8Unorm;
// Control case: CreateRenderPipeline is allowed.
device.CreateRenderPipeline(&desc);
EXPECT_DEPRECATION_WARNING(device.CreateRenderPipeline(&desc));
testing::MockCallback<WGPUCreateRenderPipelineAsyncCallback> callback;
EXPECT_CALL(callback,

View File

@ -64,20 +64,19 @@ class VertexBufferValidationTest : public ValidationTest {
wgpu::RenderPipeline MakeRenderPipeline(const wgpu::ShaderModule& vsModule,
unsigned int bufferCount) {
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertex.module = vsModule;
descriptor.cFragment.module = fsModule;
for (unsigned int i = 0; i < bufferCount; ++i) {
descriptor.cVertexState.cVertexBuffers[i].attributeCount = 1;
descriptor.cVertexState.cVertexBuffers[i].attributes =
&descriptor.cVertexState.cAttributes[i];
descriptor.cVertexState.cAttributes[i].shaderLocation = i;
descriptor.cVertexState.cAttributes[i].format = wgpu::VertexFormat::Float32x3;
descriptor.cBuffers[i].attributeCount = 1;
descriptor.cBuffers[i].attributes = &descriptor.cAttributes[i];
descriptor.cAttributes[i].shaderLocation = i;
descriptor.cAttributes[i].format = wgpu::VertexFormat::Float32x3;
}
descriptor.cVertexState.vertexBufferCount = bufferCount;
descriptor.vertex.bufferCount = bufferCount;
return device.CreateRenderPipeline(&descriptor);
return device.CreateRenderPipeline2(&descriptor);
}
wgpu::ShaderModule fsModule;

View File

@ -30,16 +30,17 @@ class VertexStateTest : public ValidationTest {
}
)");
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.vertexState = &state;
descriptor.cColorStates[0].format = wgpu::TextureFormat::RGBA8Unorm;
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertex.module = vsModule;
descriptor.vertex.bufferCount = state.vertexBufferCount;
descriptor.vertex.buffers = &state.cVertexBuffers[0];
descriptor.cFragment.module = fsModule;
descriptor.cTargets[0].format = wgpu::TextureFormat::RGBA8Unorm;
if (!success) {
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor));
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline2(&descriptor));
} else {
device.CreateRenderPipeline(&descriptor);
device.CreateRenderPipeline2(&descriptor);
}
}

View File

@ -208,4 +208,11 @@ namespace utils {
}
}
wgpu::DepthStencilState* ComboRenderPipelineDescriptor2::EnableDepthStencil(
wgpu::TextureFormat format) {
this->depthStencil = &cDepthStencil;
cDepthStencil.format = format;
return &cDepthStencil;
}
} // namespace utils

View File

@ -64,13 +64,18 @@ namespace utils {
ComboRenderPipelineDescriptor2(ComboRenderPipelineDescriptor2&&) = delete;
ComboRenderPipelineDescriptor2& operator=(ComboRenderPipelineDescriptor2&&) = delete;
wgpu::DepthStencilState* EnableDepthStencil(
wgpu::TextureFormat format = wgpu::TextureFormat::Depth24PlusStencil8);
std::array<wgpu::VertexBufferLayout, kMaxVertexBuffers> cBuffers;
std::array<wgpu::VertexAttribute, kMaxVertexAttributes> cAttributes;
std::array<wgpu::ColorTargetState, kMaxColorAttachments> cTargets;
std::array<wgpu::BlendState, kMaxColorAttachments> cBlends;
wgpu::DepthStencilState cDepthStencil;
wgpu::FragmentState cFragment;
private:
wgpu::DepthStencilState cDepthStencil;
};
} // namespace utils