Updating end-2-end tests to use new RenderPipelineDescriptor format

Bug: dawn:642
Change-Id: Ie38dfe7286b51eb7f3ecd8902e5249321ff63c11
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/44980
Auto-Submit: Brandon Jones <bajones@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Brandon Jones 2021-03-18 02:54:27 +00:00 committed by Commit Bot service account
parent 27c4f03de1
commit bff9d3a357
55 changed files with 849 additions and 833 deletions

View File

@ -133,35 +133,35 @@ namespace dawn_native {
ShaderModuleBase* fragmentModule = store->copyTextureForBrowserFS.Get(); ShaderModuleBase* fragmentModule = store->copyTextureForBrowserFS.Get();
// Prepare vertex stage. // Prepare vertex stage.
ProgrammableStageDescriptor vertexStage = {}; VertexState vertex = {};
vertexStage.module = vertexModule; vertex.module = vertexModule;
vertexStage.entryPoint = "main"; vertex.entryPoint = "main";
// Prepare frgament stage. // Prepare frgament stage.
ProgrammableStageDescriptor fragmentStage = {}; FragmentState fragment = {};
fragmentStage.module = fragmentModule; fragment.module = fragmentModule;
fragmentStage.entryPoint = "main"; fragment.entryPoint = "main";
// Prepare color state. // Prepare color state.
ColorStateDescriptor colorState = {}; ColorTargetState target = {};
colorState.format = wgpu::TextureFormat::RGBA8Unorm; target.format = wgpu::TextureFormat::RGBA8Unorm;
// Create RenderPipeline. // Create RenderPipeline.
RenderPipelineDescriptor renderPipelineDesc = {}; RenderPipelineDescriptor2 renderPipelineDesc = {};
// Generate the layout based on shader modules. // Generate the layout based on shader modules.
renderPipelineDesc.layout = nullptr; renderPipelineDesc.layout = nullptr;
renderPipelineDesc.vertexStage = vertexStage; renderPipelineDesc.vertex = vertex;
renderPipelineDesc.fragmentStage = &fragmentStage; renderPipelineDesc.fragment = &fragment;
renderPipelineDesc.primitiveTopology = wgpu::PrimitiveTopology::TriangleList; renderPipelineDesc.primitive.topology = wgpu::PrimitiveTopology::TriangleList;
renderPipelineDesc.colorStateCount = 1; fragment.targetCount = 1;
renderPipelineDesc.colorStates = &colorState; fragment.targets = &target;
store->copyTextureForBrowserPipeline = store->copyTextureForBrowserPipeline =
AcquireRef(device->CreateRenderPipeline(&renderPipelineDesc)); AcquireRef(device->CreateRenderPipeline2(&renderPipelineDesc));
} }
return store->copyTextureForBrowserPipeline.Get(); return store->copyTextureForBrowserPipeline.Get();

View File

@ -100,19 +100,23 @@ class BindGroupTests : public DawnTest {
wgpu::PipelineLayout pipelineLayout = MakeBasicPipelineLayout(bindGroupLayouts); wgpu::PipelineLayout pipelineLayout = MakeBasicPipelineLayout(bindGroupLayouts);
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.layout = pipelineLayout; pipelineDescriptor.layout = pipelineLayout;
pipelineDescriptor.vertexStage.module = vsModule; pipelineDescriptor.vertex.module = vsModule;
pipelineDescriptor.cFragmentStage.module = fsModule; pipelineDescriptor.cFragment.module = fsModule;
pipelineDescriptor.cColorStates[0].format = renderPass.colorFormat; pipelineDescriptor.cTargets[0].format = renderPass.colorFormat;
pipelineDescriptor.cColorStates[0].colorBlend.operation = wgpu::BlendOperation::Add;
pipelineDescriptor.cColorStates[0].colorBlend.srcFactor = wgpu::BlendFactor::One;
pipelineDescriptor.cColorStates[0].colorBlend.dstFactor = wgpu::BlendFactor::One;
pipelineDescriptor.cColorStates[0].alphaBlend.operation = wgpu::BlendOperation::Add;
pipelineDescriptor.cColorStates[0].alphaBlend.srcFactor = wgpu::BlendFactor::One;
pipelineDescriptor.cColorStates[0].alphaBlend.dstFactor = wgpu::BlendFactor::One;
return device.CreateRenderPipeline(&pipelineDescriptor); wgpu::BlendState blend;
blend.color.operation = wgpu::BlendOperation::Add;
blend.color.srcFactor = wgpu::BlendFactor::One;
blend.color.dstFactor = wgpu::BlendFactor::One;
blend.alpha.operation = wgpu::BlendOperation::Add;
blend.alpha.srcFactor = wgpu::BlendFactor::One;
blend.alpha.dstFactor = wgpu::BlendFactor::One;
pipelineDescriptor.cTargets[0].blend = &blend;
return device.CreateRenderPipeline2(&pipelineDescriptor);
} }
}; };
@ -187,12 +191,12 @@ TEST_P(BindGroupTests, ReusedUBO) {
fragColor = fragmentUbo.color; fragColor = fragmentUbo.color;
})"); })");
utils::ComboRenderPipelineDescriptor textureDescriptor(device); utils::ComboRenderPipelineDescriptor2 textureDescriptor;
textureDescriptor.vertexStage.module = vsModule; textureDescriptor.vertex.module = vsModule;
textureDescriptor.cFragmentStage.module = fsModule; textureDescriptor.cFragment.module = fsModule;
textureDescriptor.cColorStates[0].format = renderPass.colorFormat; textureDescriptor.cTargets[0].format = renderPass.colorFormat;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&textureDescriptor); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&textureDescriptor);
struct Data { struct Data {
float transform[8]; float transform[8];
@ -269,12 +273,12 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) {
fragColor = textureSample(tex, samp, FragCoord.xy); fragColor = textureSample(tex, samp, FragCoord.xy);
})"); })");
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertexStage.module = vsModule; pipelineDescriptor.vertex.module = vsModule;
pipelineDescriptor.cFragmentStage.module = fsModule; pipelineDescriptor.cFragment.module = fsModule;
pipelineDescriptor.cColorStates[0].format = renderPass.colorFormat; pipelineDescriptor.cTargets[0].format = renderPass.colorFormat;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDescriptor); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&pipelineDescriptor);
constexpr float transform[] = {1.f, 0.f, 0.f, 1.f}; constexpr float transform[] = {1.f, 0.f, 0.f, 1.f};
wgpu::Buffer buffer = utils::CreateBufferFromData(device, &transform, sizeof(transform), wgpu::Buffer buffer = utils::CreateBufferFromData(device, &transform, sizeof(transform),
@ -395,12 +399,12 @@ TEST_P(BindGroupTests, MultipleBindLayouts) {
fragColor = fragmentUbo1.color + fragmentUbo2.color; fragColor = fragmentUbo1.color + fragmentUbo2.color;
})"); })");
utils::ComboRenderPipelineDescriptor textureDescriptor(device); utils::ComboRenderPipelineDescriptor2 textureDescriptor;
textureDescriptor.vertexStage.module = vsModule; textureDescriptor.vertex.module = vsModule;
textureDescriptor.cFragmentStage.module = fsModule; textureDescriptor.cFragment.module = fsModule;
textureDescriptor.cColorStates[0].format = renderPass.colorFormat; textureDescriptor.cTargets[0].format = renderPass.colorFormat;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&textureDescriptor); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&textureDescriptor);
struct Data { struct Data {
float transform[4]; float transform[4];
@ -984,12 +988,12 @@ TEST_P(BindGroupTests, ArbitraryBindingNumbers) {
fragColor = ubo1.color + 2.0 * ubo2.color + 4.0 * ubo3.color; fragColor = ubo1.color + 2.0 * ubo2.color + 4.0 * ubo3.color;
})"); })");
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertexStage.module = vsModule; pipelineDescriptor.vertex.module = vsModule;
pipelineDescriptor.cFragmentStage.module = fsModule; pipelineDescriptor.cFragment.module = fsModule;
pipelineDescriptor.cColorStates[0].format = renderPass.colorFormat; pipelineDescriptor.cTargets[0].format = renderPass.colorFormat;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDescriptor); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&pipelineDescriptor);
wgpu::Buffer black = wgpu::Buffer black =
utils::CreateBufferFromData(device, wgpu::BufferUsage::Uniform, {0.f, 0.f, 0.f, 0.f}); utils::CreateBufferFromData(device, wgpu::BufferUsage::Uniform, {0.f, 0.f, 0.f, 0.f});
@ -1100,9 +1104,9 @@ TEST_P(BindGroupTests, EmptyLayout) {
// This is a regression test for crbug.com/dawn/410 which tests that it can successfully compile and // This is a regression test for crbug.com/dawn/410 which tests that it can successfully compile and
// execute the shader. // execute the shader.
TEST_P(BindGroupTests, ReadonlyStorage) { TEST_P(BindGroupTests, ReadonlyStorage) {
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertexStage.module = utils::CreateShaderModuleFromWGSL(device, R"( pipelineDescriptor.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[builtin(vertex_index)]] var<in> VertexIndex : u32; [[builtin(vertex_index)]] var<in> VertexIndex : u32;
[[builtin(position)]] var<out> Position : vec4<f32>; [[builtin(position)]] var<out> Position : vec4<f32>;
@ -1115,7 +1119,7 @@ TEST_P(BindGroupTests, ReadonlyStorage) {
Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0); Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
})"); })");
pipelineDescriptor.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"( pipelineDescriptor.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[block]] struct Buffer0 { [[block]] struct Buffer0 {
color : vec4<f32>; color : vec4<f32>;
}; };
@ -1128,14 +1132,14 @@ TEST_P(BindGroupTests, ReadonlyStorage) {
constexpr uint32_t kRTSize = 4; constexpr uint32_t kRTSize = 4;
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
pipelineDescriptor.cColorStates[0].format = renderPass.colorFormat; pipelineDescriptor.cTargets[0].format = renderPass.colorFormat;
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout( wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Storage}}); device, {{0, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Storage}});
pipelineDescriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl); pipelineDescriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl);
wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline(&pipelineDescriptor); wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline2(&pipelineDescriptor);
wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);

View File

@ -224,16 +224,16 @@ class BufferZeroInitTest : public DawnTest {
})"); })");
ASSERT(vertexBufferCount <= 1u); ASSERT(vertexBufferCount <= 1u);
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertexStage.module = vsModule; descriptor.vertex.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragment.module = fsModule;
descriptor.primitiveTopology = wgpu::PrimitiveTopology::PointList; descriptor.primitive.topology = wgpu::PrimitiveTopology::PointList;
descriptor.cVertexState.vertexBufferCount = vertexBufferCount; descriptor.vertex.bufferCount = vertexBufferCount;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float); descriptor.cBuffers[0].arrayStride = 4 * sizeof(float);
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1; descriptor.cBuffers[0].attributeCount = 1;
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4; descriptor.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
descriptor.cColorStates[0].format = kColorAttachmentFormat; descriptor.cTargets[0].format = kColorAttachmentFormat;
return device.CreateRenderPipeline(&descriptor); return device.CreateRenderPipeline2(&descriptor);
} }
void ExpectLazyClearSubmitAndCheckOutputs(wgpu::CommandEncoder encoder, void ExpectLazyClearSubmitAndCheckOutputs(wgpu::CommandEncoder encoder,

View File

@ -20,12 +20,12 @@
class ClipSpaceTest : public DawnTest { class ClipSpaceTest : public DawnTest {
protected: protected:
wgpu::RenderPipeline CreatePipelineForTest() { wgpu::RenderPipeline CreatePipelineForTest() {
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
// Draw two triangles: // Draw two triangles:
// 1. The depth value of the top-left one is >= 0.5 // 1. The depth value of the top-left one is >= 0.5
// 2. The depth value of the bottom-right one is <= 0.5 // 2. The depth value of the bottom-right one is <= 0.5
pipelineDescriptor.vertexStage.module = utils::CreateShaderModuleFromWGSL(device, R"( pipelineDescriptor.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
const pos : array<vec3<f32>, 6> = array<vec3<f32>, 6>( const pos : array<vec3<f32>, 6> = array<vec3<f32>, 6>(
vec3<f32>(-1.0, 1.0, 1.0), vec3<f32>(-1.0, 1.0, 1.0),
vec3<f32>(-1.0, -1.0, 0.5), vec3<f32>(-1.0, -1.0, 0.5),
@ -42,17 +42,17 @@ class ClipSpaceTest : public DawnTest {
return; return;
})"); })");
pipelineDescriptor.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"( pipelineDescriptor.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;; [[location(0)]] var<out> fragColor : vec4<f32>;;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(1.0, 0.0, 0.0, 1.0); fragColor = vec4<f32>(1.0, 0.0, 0.0, 1.0);
return; return;
})"); })");
pipelineDescriptor.cDepthStencilState.depthCompare = wgpu::CompareFunction::LessEqual; wgpu::DepthStencilState* depthStencil = pipelineDescriptor.EnableDepthStencil();
pipelineDescriptor.depthStencilState = &pipelineDescriptor.cDepthStencilState; depthStencil->depthCompare = wgpu::CompareFunction::LessEqual;
return device.CreateRenderPipeline(&pipelineDescriptor); return device.CreateRenderPipeline2(&pipelineDescriptor);
} }
wgpu::Texture Create2DTextureForTest(wgpu::TextureFormat format) { wgpu::Texture Create2DTextureForTest(wgpu::TextureFormat format) {

View File

@ -54,7 +54,7 @@ class ColorStateTest : public DawnTest {
// Set up basePipeline and testPipeline. testPipeline has the given blend state on the first // Set up basePipeline and testPipeline. testPipeline has the given blend state on the first
// attachment. basePipeline has no blending // attachment. basePipeline has no blending
void SetupSingleSourcePipelines(wgpu::ColorStateDescriptor colorStateDescriptor) { void SetupSingleSourcePipelines(wgpu::ColorTargetState colorTargetState) {
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[block]] struct MyBlock { [[block]] struct MyBlock {
color : vec4<f32>; color : vec4<f32>;
@ -70,20 +70,20 @@ class ColorStateTest : public DawnTest {
} }
)"); )");
utils::ComboRenderPipelineDescriptor baseDescriptor(device); utils::ComboRenderPipelineDescriptor2 baseDescriptor;
baseDescriptor.vertexStage.module = vsModule; baseDescriptor.vertex.module = vsModule;
baseDescriptor.cFragmentStage.module = fsModule; baseDescriptor.cFragment.module = fsModule;
baseDescriptor.cColorStates[0].format = renderPass.colorFormat; baseDescriptor.cTargets[0].format = renderPass.colorFormat;
basePipeline = device.CreateRenderPipeline(&baseDescriptor); basePipeline = device.CreateRenderPipeline2(&baseDescriptor);
utils::ComboRenderPipelineDescriptor testDescriptor(device); utils::ComboRenderPipelineDescriptor2 testDescriptor;
testDescriptor.vertexStage.module = vsModule; testDescriptor.vertex.module = vsModule;
testDescriptor.cFragmentStage.module = fsModule; testDescriptor.cFragment.module = fsModule;
testDescriptor.cColorStates[0] = colorStateDescriptor; testDescriptor.cTargets[0] = colorTargetState;
testDescriptor.cColorStates[0].format = renderPass.colorFormat; testDescriptor.cTargets[0].format = renderPass.colorFormat;
testPipeline = device.CreateRenderPipeline(&testDescriptor); testPipeline = device.CreateRenderPipeline2(&testDescriptor);
} }
// Create a bind group to set the colors as a uniform buffer // Create a bind group to set the colors as a uniform buffer
@ -138,14 +138,17 @@ class ColorStateTest : public DawnTest {
void CheckBlendOperation(RGBA8 base, void CheckBlendOperation(RGBA8 base,
wgpu::BlendOperation operation, wgpu::BlendOperation operation,
std::vector<std::pair<RGBA8, RGBA8>> tests) { std::vector<std::pair<RGBA8, RGBA8>> tests) {
wgpu::BlendDescriptor blend; wgpu::BlendComponent blendComponent;
blend.operation = operation; blendComponent.operation = operation;
blend.srcFactor = wgpu::BlendFactor::One; blendComponent.srcFactor = wgpu::BlendFactor::One;
blend.dstFactor = wgpu::BlendFactor::One; blendComponent.dstFactor = wgpu::BlendFactor::One;
wgpu::ColorStateDescriptor descriptor; wgpu::BlendState blend;
descriptor.alphaBlend = blend; blend.color = blendComponent;
descriptor.colorBlend = blend; blend.alpha = blendComponent;
wgpu::ColorTargetState descriptor;
descriptor.blend = &blend;
descriptor.writeMask = wgpu::ColorWriteMask::All; descriptor.writeMask = wgpu::ColorWriteMask::All;
SetupSingleSourcePipelines(descriptor); SetupSingleSourcePipelines(descriptor);
@ -163,19 +166,22 @@ class ColorStateTest : public DawnTest {
wgpu::BlendFactor alphaSrcFactor, wgpu::BlendFactor alphaSrcFactor,
wgpu::BlendFactor alphaDstFactor, wgpu::BlendFactor alphaDstFactor,
std::vector<std::pair<TriangleSpec, RGBA8>> tests) { std::vector<std::pair<TriangleSpec, RGBA8>> tests) {
wgpu::BlendDescriptor colorBlend; wgpu::BlendComponent colorBlend;
colorBlend.operation = wgpu::BlendOperation::Add; colorBlend.operation = wgpu::BlendOperation::Add;
colorBlend.srcFactor = colorSrcFactor; colorBlend.srcFactor = colorSrcFactor;
colorBlend.dstFactor = colorDstFactor; colorBlend.dstFactor = colorDstFactor;
wgpu::BlendDescriptor alphaBlend; wgpu::BlendComponent alphaBlend;
alphaBlend.operation = wgpu::BlendOperation::Add; alphaBlend.operation = wgpu::BlendOperation::Add;
alphaBlend.srcFactor = alphaSrcFactor; alphaBlend.srcFactor = alphaSrcFactor;
alphaBlend.dstFactor = alphaDstFactor; alphaBlend.dstFactor = alphaDstFactor;
wgpu::ColorStateDescriptor descriptor; wgpu::BlendState blend;
descriptor.colorBlend = colorBlend; blend.color = colorBlend;
descriptor.alphaBlend = alphaBlend; blend.alpha = alphaBlend;
wgpu::ColorTargetState descriptor;
descriptor.blend = &blend;
descriptor.writeMask = wgpu::ColorWriteMask::All; descriptor.writeMask = wgpu::ColorWriteMask::All;
SetupSingleSourcePipelines(descriptor); SetupSingleSourcePipelines(descriptor);
@ -289,13 +295,17 @@ namespace {
// Test compilation and usage of the fixture // Test compilation and usage of the fixture
TEST_P(ColorStateTest, Basic) { TEST_P(ColorStateTest, Basic) {
wgpu::BlendDescriptor blend; wgpu::BlendComponent blendComponent;
blend.operation = wgpu::BlendOperation::Add; blendComponent.operation = wgpu::BlendOperation::Add;
blend.srcFactor = wgpu::BlendFactor::One; blendComponent.srcFactor = wgpu::BlendFactor::One;
blend.dstFactor = wgpu::BlendFactor::Zero; blendComponent.dstFactor = wgpu::BlendFactor::Zero;
wgpu::ColorStateDescriptor descriptor;
descriptor.alphaBlend = blend; wgpu::BlendState blend;
descriptor.colorBlend = blend; blend.color = blendComponent;
blend.alpha = blendComponent;
wgpu::ColorTargetState descriptor;
descriptor.blend = &blend;
descriptor.writeMask = wgpu::ColorWriteMask::All; descriptor.writeMask = wgpu::ColorWriteMask::All;
SetupSingleSourcePipelines(descriptor); SetupSingleSourcePipelines(descriptor);
@ -668,14 +678,17 @@ TEST_P(ColorStateTest, DstBlendFactorOneMinusBlendColor) {
// Check that the color write mask works // Check that the color write mask works
TEST_P(ColorStateTest, ColorWriteMask) { TEST_P(ColorStateTest, ColorWriteMask) {
wgpu::BlendDescriptor blend; wgpu::BlendComponent blendComponent;
blend.operation = wgpu::BlendOperation::Add; blendComponent.operation = wgpu::BlendOperation::Add;
blend.srcFactor = wgpu::BlendFactor::One; blendComponent.srcFactor = wgpu::BlendFactor::One;
blend.dstFactor = wgpu::BlendFactor::One; blendComponent.dstFactor = wgpu::BlendFactor::One;
wgpu::ColorStateDescriptor descriptor; wgpu::BlendState blend;
descriptor.colorBlend = blend; blend.color = blendComponent;
descriptor.alphaBlend = blend; blend.alpha = blendComponent;
wgpu::ColorTargetState descriptor;
descriptor.blend = &blend;
{ {
// Test single channel color write // Test single channel color write
descriptor.writeMask = wgpu::ColorWriteMask::Red; descriptor.writeMask = wgpu::ColorWriteMask::Red;
@ -715,14 +728,17 @@ TEST_P(ColorStateTest, ColorWriteMask) {
// Check that the color write mask works when blending is disabled // Check that the color write mask works when blending is disabled
TEST_P(ColorStateTest, ColorWriteMaskBlendingDisabled) { TEST_P(ColorStateTest, ColorWriteMaskBlendingDisabled) {
{ {
wgpu::BlendDescriptor blend; wgpu::BlendComponent blendComponent;
blend.operation = wgpu::BlendOperation::Add; blendComponent.operation = wgpu::BlendOperation::Add;
blend.srcFactor = wgpu::BlendFactor::One; blendComponent.srcFactor = wgpu::BlendFactor::One;
blend.dstFactor = wgpu::BlendFactor::Zero; blendComponent.dstFactor = wgpu::BlendFactor::Zero;
wgpu::ColorStateDescriptor descriptor;
descriptor.alphaBlend = blend;
descriptor.colorBlend = blend;
wgpu::BlendState blend;
blend.color = blendComponent;
blend.alpha = blendComponent;
wgpu::ColorTargetState descriptor;
descriptor.blend = &blend;
descriptor.writeMask = wgpu::ColorWriteMask::Red; descriptor.writeMask = wgpu::ColorWriteMask::Red;
SetupSingleSourcePipelines(descriptor); SetupSingleSourcePipelines(descriptor);
@ -793,44 +809,53 @@ TEST_P(ColorStateTest, IndependentColorState) {
} }
)"); )");
utils::ComboRenderPipelineDescriptor baseDescriptor(device); utils::ComboRenderPipelineDescriptor2 baseDescriptor;
baseDescriptor.vertexStage.module = vsModule; baseDescriptor.vertex.module = vsModule;
baseDescriptor.cFragmentStage.module = fsModule; baseDescriptor.cFragment.module = fsModule;
baseDescriptor.colorStateCount = 4; baseDescriptor.cFragment.targetCount = 4;
basePipeline = device.CreateRenderPipeline(&baseDescriptor); basePipeline = device.CreateRenderPipeline2(&baseDescriptor);
utils::ComboRenderPipelineDescriptor testDescriptor(device); utils::ComboRenderPipelineDescriptor2 testDescriptor;
testDescriptor.vertexStage.module = vsModule; testDescriptor.vertex.module = vsModule;
testDescriptor.cFragmentStage.module = fsModule; testDescriptor.cFragment.module = fsModule;
testDescriptor.colorStateCount = 4; testDescriptor.cFragment.targetCount = 4;
// set color states // set color states
wgpu::BlendDescriptor blend1; wgpu::BlendComponent blendComponent0;
blend1.operation = wgpu::BlendOperation::Add; blendComponent0.operation = wgpu::BlendOperation::Add;
blend1.srcFactor = wgpu::BlendFactor::One; blendComponent0.srcFactor = wgpu::BlendFactor::One;
blend1.dstFactor = wgpu::BlendFactor::One; blendComponent0.dstFactor = wgpu::BlendFactor::One;
wgpu::BlendDescriptor blend2; wgpu::BlendState blend0;
blend2.operation = wgpu::BlendOperation::Subtract; blend0.color = blendComponent0;
blend2.srcFactor = wgpu::BlendFactor::One; blend0.alpha = blendComponent0;
blend2.dstFactor = wgpu::BlendFactor::One;
wgpu::BlendDescriptor blend3; wgpu::BlendComponent blendComponent1;
blend3.operation = wgpu::BlendOperation::Min; blendComponent1.operation = wgpu::BlendOperation::Subtract;
blend3.srcFactor = wgpu::BlendFactor::One; blendComponent1.srcFactor = wgpu::BlendFactor::One;
blend3.dstFactor = wgpu::BlendFactor::One; blendComponent1.dstFactor = wgpu::BlendFactor::One;
testDescriptor.cColorStates[0].colorBlend = blend1; wgpu::BlendState blend1;
testDescriptor.cColorStates[0].alphaBlend = blend1; blend1.color = blendComponent1;
blend1.alpha = blendComponent1;
testDescriptor.cColorStates[1].colorBlend = blend2; // Blend state intentionally omitted for target 2
testDescriptor.cColorStates[1].alphaBlend = blend2;
testDescriptor.cColorStates[3].colorBlend = blend3; wgpu::BlendDescriptor blendComponent3;
testDescriptor.cColorStates[3].alphaBlend = blend3; blendComponent3.operation = wgpu::BlendOperation::Min;
blendComponent3.srcFactor = wgpu::BlendFactor::One;
blendComponent3.dstFactor = wgpu::BlendFactor::One;
testPipeline = device.CreateRenderPipeline(&testDescriptor); wgpu::BlendState blend3;
blend3.color = blendComponent3;
blend3.alpha = blendComponent3;
testDescriptor.cTargets[0].blend = &blend0;
testDescriptor.cTargets[1].blend = &blend1;
testDescriptor.cTargets[3].blend = &blend3;
testPipeline = device.CreateRenderPipeline2(&testDescriptor);
for (unsigned int c = 0; c < kColors.size(); ++c) { for (unsigned int c = 0; c < kColors.size(); ++c) {
RGBA8 base = kColors[((c + 31) * 29) % kColors.size()]; RGBA8 base = kColors[((c + 31) * 29) % kColors.size()];
@ -894,26 +919,30 @@ TEST_P(ColorStateTest, DefaultBlendColor) {
} }
)"); )");
utils::ComboRenderPipelineDescriptor baseDescriptor(device); utils::ComboRenderPipelineDescriptor2 baseDescriptor;
baseDescriptor.vertexStage.module = vsModule; baseDescriptor.vertex.module = vsModule;
baseDescriptor.cFragmentStage.module = fsModule; baseDescriptor.cFragment.module = fsModule;
baseDescriptor.cColorStates[0].format = renderPass.colorFormat; baseDescriptor.cTargets[0].format = renderPass.colorFormat;
basePipeline = device.CreateRenderPipeline(&baseDescriptor); basePipeline = device.CreateRenderPipeline2(&baseDescriptor);
utils::ComboRenderPipelineDescriptor testDescriptor(device); utils::ComboRenderPipelineDescriptor2 testDescriptor;
testDescriptor.vertexStage.module = vsModule; testDescriptor.vertex.module = vsModule;
testDescriptor.cFragmentStage.module = fsModule; testDescriptor.cFragment.module = fsModule;
testDescriptor.cColorStates[0].format = renderPass.colorFormat; testDescriptor.cTargets[0].format = renderPass.colorFormat;
wgpu::BlendDescriptor blend; wgpu::BlendComponent blendComponent;
blend.operation = wgpu::BlendOperation::Add; blendComponent.operation = wgpu::BlendOperation::Add;
blend.srcFactor = wgpu::BlendFactor::BlendColor; blendComponent.srcFactor = wgpu::BlendFactor::BlendColor;
blend.dstFactor = wgpu::BlendFactor::One; blendComponent.dstFactor = wgpu::BlendFactor::One;
testDescriptor.cColorStates[0].colorBlend = blend;
testDescriptor.cColorStates[0].alphaBlend = blend;
testPipeline = device.CreateRenderPipeline(&testDescriptor); wgpu::BlendState blend;
blend.color = blendComponent;
blend.alpha = blendComponent;
testDescriptor.cTargets[0].blend = &blend;
testPipeline = device.CreateRenderPipeline2(&testDescriptor);
constexpr wgpu::Color kWhite{1.0f, 1.0f, 1.0f, 1.0f}; constexpr wgpu::Color kWhite{1.0f, 1.0f, 1.0f, 1.0f};
// Check that the initial blend color is (0,0,0,0) // Check that the initial blend color is (0,0,0,0)
@ -1017,20 +1046,20 @@ TEST_P(ColorStateTest, ColorWriteMaskDoesNotAffectRenderPassLoadOpClear) {
} }
)"); )");
utils::ComboRenderPipelineDescriptor baseDescriptor(device); utils::ComboRenderPipelineDescriptor2 baseDescriptor;
baseDescriptor.vertexStage.module = vsModule; baseDescriptor.vertex.module = vsModule;
baseDescriptor.cFragmentStage.module = fsModule; baseDescriptor.cFragment.module = fsModule;
baseDescriptor.cColorStates[0].format = renderPass.colorFormat; baseDescriptor.cTargets[0].format = renderPass.colorFormat;
basePipeline = device.CreateRenderPipeline(&baseDescriptor); basePipeline = device.CreateRenderPipeline2(&baseDescriptor);
utils::ComboRenderPipelineDescriptor testDescriptor(device); utils::ComboRenderPipelineDescriptor2 testDescriptor;
testDescriptor.vertexStage.module = vsModule; testDescriptor.vertex.module = vsModule;
testDescriptor.cFragmentStage.module = fsModule; testDescriptor.cFragment.module = fsModule;
testDescriptor.cColorStates[0].format = renderPass.colorFormat; testDescriptor.cTargets[0].format = renderPass.colorFormat;
testDescriptor.cColorStates[0].writeMask = wgpu::ColorWriteMask::Red; testDescriptor.cTargets[0].writeMask = wgpu::ColorWriteMask::Red;
testPipeline = device.CreateRenderPipeline(&testDescriptor); testPipeline = device.CreateRenderPipeline2(&testDescriptor);
RGBA8 base(32, 64, 128, 192); RGBA8 base(32, 64, 128, 192);
RGBA8 expected(0, 0, 0, 0); RGBA8 expected(0, 0, 0, 0);

View File

@ -138,7 +138,7 @@ class CompressedTextureBCFormatTest : public DawnTest {
wgpu::RenderPipeline CreateRenderPipelineForTest() { wgpu::RenderPipeline CreateRenderPipelineForTest() {
ASSERT(IsBCFormatSupported()); ASSERT(IsBCFormatSupported());
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 renderPipelineDescriptor;
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>; [[builtin(position)]] var<out> Position : vec4<f32>;
[[location(0)]] var<out> texCoord : vec2 <f32>; [[location(0)]] var<out> texCoord : vec2 <f32>;
@ -166,12 +166,11 @@ class CompressedTextureBCFormatTest : public DawnTest {
fragColor = textureSample(texture0, sampler0, texCoord); fragColor = textureSample(texture0, sampler0, texCoord);
return; return;
})"); })");
renderPipelineDescriptor.vertexStage.module = vsModule; renderPipelineDescriptor.vertex.module = vsModule;
renderPipelineDescriptor.cFragmentStage.module = fsModule; renderPipelineDescriptor.cFragment.module = fsModule;
renderPipelineDescriptor.cColorStates[0].format = renderPipelineDescriptor.cTargets[0].format = utils::BasicRenderPass::kDefaultColorFormat;
utils::BasicRenderPass::kDefaultColorFormat;
return device.CreateRenderPipeline(&renderPipelineDescriptor); return device.CreateRenderPipeline2(&renderPipelineDescriptor);
} }
// Run the given render pipeline and bind group and verify the pixels in the render target. // Run the given render pipeline and bind group and verify the pixels in the render target.

View File

@ -20,12 +20,12 @@
class CullingTest : public DawnTest { class CullingTest : public DawnTest {
protected: protected:
wgpu::RenderPipeline CreatePipelineForTest(wgpu::FrontFace frontFace, wgpu::CullMode cullMode) { wgpu::RenderPipeline CreatePipelineForTest(wgpu::FrontFace frontFace, wgpu::CullMode cullMode) {
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
// Draw two triangles with different winding orders: // Draw two triangles with different winding orders:
// 1. The top-left one is counterclockwise (CCW) // 1. The top-left one is counterclockwise (CCW)
// 2. The bottom-right one is clockwise (CW) // 2. The bottom-right one is clockwise (CW)
pipelineDescriptor.vertexStage.module = utils::CreateShaderModuleFromWGSL(device, R"( pipelineDescriptor.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
const pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>( const pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
vec2<f32>(-1.0, 1.0), vec2<f32>(-1.0, 1.0),
vec2<f32>(-1.0, 0.0), vec2<f32>(-1.0, 0.0),
@ -45,7 +45,7 @@ class CullingTest : public DawnTest {
// FragCoord of pixel(x, y) in framebuffer coordinate is (x + 0.5, y + 0.5). And we use // FragCoord of pixel(x, y) in framebuffer coordinate is (x + 0.5, y + 0.5). And we use
// RGBA8 format for the back buffer. So (FragCoord.xy - vec2(0.5)) / 255 in shader code // RGBA8 format for the back buffer. So (FragCoord.xy - vec2(0.5)) / 255 in shader code
// will make the pixel's R and G channels exactly equal to the pixel's x and y coordinates. // will make the pixel's R and G channels exactly equal to the pixel's x and y coordinates.
pipelineDescriptor.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"( pipelineDescriptor.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;; [[location(0)]] var<out> fragColor : vec4<f32>;;
[[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>; [[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>;
@ -57,10 +57,10 @@ class CullingTest : public DawnTest {
})"); })");
// Set culling mode and front face according to the parameters // Set culling mode and front face according to the parameters
pipelineDescriptor.cRasterizationState.frontFace = frontFace; pipelineDescriptor.primitive.frontFace = frontFace;
pipelineDescriptor.cRasterizationState.cullMode = cullMode; pipelineDescriptor.primitive.cullMode = cullMode;
return device.CreateRenderPipeline(&pipelineDescriptor); return device.CreateRenderPipeline2(&pipelineDescriptor);
} }
wgpu::Texture Create2DTextureForTest(wgpu::TextureFormat format) { wgpu::Texture Create2DTextureForTest(wgpu::TextureFormat format) {

View File

@ -118,26 +118,26 @@ TEST_P(D3D12CachingTests, SameShaderNoCache) {
// Store the WGSL shader into the cache. // Store the WGSL shader into the cache.
{ {
utils::ComboRenderPipelineDescriptor desc(device); utils::ComboRenderPipelineDescriptor2 desc;
desc.vertexStage.module = module; desc.vertex.module = module;
desc.vertexStage.entryPoint = "vertex_main"; desc.vertex.entryPoint = "vertex_main";
desc.cFragmentStage.module = module; desc.cFragment.module = module;
desc.cFragmentStage.entryPoint = "fragment_main"; desc.cFragment.entryPoint = "fragment_main";
EXPECT_CACHE_HIT(0u, device.CreateRenderPipeline(&desc)); EXPECT_CACHE_HIT(0u, device.CreateRenderPipeline2(&desc));
} }
EXPECT_EQ(mPersistentCache.mCache.size(), 0u); EXPECT_EQ(mPersistentCache.mCache.size(), 0u);
// Load the same WGSL shader from the cache. // Load the same WGSL shader from the cache.
{ {
utils::ComboRenderPipelineDescriptor desc(device); utils::ComboRenderPipelineDescriptor2 desc;
desc.vertexStage.module = module; desc.vertex.module = module;
desc.vertexStage.entryPoint = "vertex_main"; desc.vertex.entryPoint = "vertex_main";
desc.cFragmentStage.module = module; desc.cFragment.module = module;
desc.cFragmentStage.entryPoint = "fragment_main"; desc.cFragment.entryPoint = "fragment_main";
EXPECT_CACHE_HIT(0u, device.CreateRenderPipeline(&desc)); EXPECT_CACHE_HIT(0u, device.CreateRenderPipeline2(&desc));
} }
EXPECT_EQ(mPersistentCache.mCache.size(), 0u); EXPECT_EQ(mPersistentCache.mCache.size(), 0u);
@ -165,28 +165,28 @@ TEST_P(D3D12CachingTests, ReuseShaderWithMultipleEntryPointsPerStage) {
// Store the WGSL shader into the cache. // Store the WGSL shader into the cache.
{ {
utils::ComboRenderPipelineDescriptor desc(device); utils::ComboRenderPipelineDescriptor2 desc;
desc.vertexStage.module = module; desc.vertex.module = module;
desc.vertexStage.entryPoint = "vertex_main"; desc.vertex.entryPoint = "vertex_main";
desc.cFragmentStage.module = module; desc.cFragment.module = module;
desc.cFragmentStage.entryPoint = "fragment_main"; desc.cFragment.entryPoint = "fragment_main";
EXPECT_CACHE_HIT(0u, device.CreateRenderPipeline(&desc)); EXPECT_CACHE_HIT(0u, device.CreateRenderPipeline2(&desc));
} }
EXPECT_EQ(mPersistentCache.mCache.size(), 2u); EXPECT_EQ(mPersistentCache.mCache.size(), 2u);
// Load the same WGSL shader from the cache. // Load the same WGSL shader from the cache.
{ {
utils::ComboRenderPipelineDescriptor desc(device); utils::ComboRenderPipelineDescriptor2 desc;
desc.vertexStage.module = module; desc.vertex.module = module;
desc.vertexStage.entryPoint = "vertex_main"; desc.vertex.entryPoint = "vertex_main";
desc.cFragmentStage.module = module; desc.cFragment.module = module;
desc.cFragmentStage.entryPoint = "fragment_main"; desc.cFragment.entryPoint = "fragment_main";
// Cached HLSL shader calls LoadData twice (once to peek, again to get), so check 2 x // Cached HLSL shader calls LoadData twice (once to peek, again to get), so check 2 x
// kNumOfShaders hits. // kNumOfShaders hits.
EXPECT_CACHE_HIT(4u, device.CreateRenderPipeline(&desc)); EXPECT_CACHE_HIT(4u, device.CreateRenderPipeline2(&desc));
} }
EXPECT_EQ(mPersistentCache.mCache.size(), 2u); EXPECT_EQ(mPersistentCache.mCache.size(), 2u);
@ -209,12 +209,12 @@ TEST_P(D3D12CachingTests, ReuseShaderWithMultipleEntryPointsPerStage) {
)"); )");
{ {
utils::ComboRenderPipelineDescriptor desc(device); utils::ComboRenderPipelineDescriptor2 desc;
desc.vertexStage.module = newModule; desc.vertex.module = newModule;
desc.vertexStage.entryPoint = "vertex_main"; desc.vertex.entryPoint = "vertex_main";
desc.cFragmentStage.module = newModule; desc.cFragment.module = newModule;
desc.cFragmentStage.entryPoint = "fragment_main"; desc.cFragment.entryPoint = "fragment_main";
EXPECT_CACHE_HIT(0u, device.CreateRenderPipeline(&desc)); EXPECT_CACHE_HIT(0u, device.CreateRenderPipeline2(&desc));
} }
// Cached HLSL shader calls LoadData twice (once to peek, again to get), so check 2 x // Cached HLSL shader calls LoadData twice (once to peek, again to get), so check 2 x

View File

@ -273,10 +273,10 @@ TEST_P(D3D12VideoViewsTests, NV12SampleYtoR) {
viewDesc.aspect = wgpu::TextureAspect::Plane0Only; viewDesc.aspect = wgpu::TextureAspect::Plane0Only;
wgpu::TextureView textureView = wgpuTexture.CreateView(&viewDesc); wgpu::TextureView textureView = wgpuTexture.CreateView(&viewDesc);
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 renderPipelineDescriptor;
renderPipelineDescriptor.vertexStage.module = GetTestVertexShaderModule(); renderPipelineDescriptor.vertex.module = GetTestVertexShaderModule();
renderPipelineDescriptor.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"( renderPipelineDescriptor.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[set(0), binding(0)]] var sampler0 : sampler; [[set(0), binding(0)]] var sampler0 : sampler;
[[set(0), binding(1)]] var texture : texture_2d<f32>; [[set(0), binding(1)]] var texture : texture_2d<f32>;
@ -290,10 +290,10 @@ TEST_P(D3D12VideoViewsTests, NV12SampleYtoR) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass( utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(
device, kYUVImageDataWidthInTexels, kYUVImageDataHeightInTexels); device, kYUVImageDataWidthInTexels, kYUVImageDataHeightInTexels);
renderPipelineDescriptor.cColorStates[0].format = renderPass.colorFormat; renderPipelineDescriptor.cTargets[0].format = renderPass.colorFormat;
renderPipelineDescriptor.primitiveTopology = wgpu::PrimitiveTopology::TriangleList; renderPipelineDescriptor.primitive.topology = wgpu::PrimitiveTopology::TriangleList;
wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline(&renderPipelineDescriptor); wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline2(&renderPipelineDescriptor);
wgpu::Sampler sampler = device.CreateSampler(); wgpu::Sampler sampler = device.CreateSampler();
@ -326,10 +326,10 @@ TEST_P(D3D12VideoViewsTests, NV12SampleUVtoRG) {
viewDesc.aspect = wgpu::TextureAspect::Plane1Only; viewDesc.aspect = wgpu::TextureAspect::Plane1Only;
wgpu::TextureView textureView = wgpuTexture.CreateView(&viewDesc); wgpu::TextureView textureView = wgpuTexture.CreateView(&viewDesc);
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 renderPipelineDescriptor;
renderPipelineDescriptor.vertexStage.module = GetTestVertexShaderModule(); renderPipelineDescriptor.vertex.module = GetTestVertexShaderModule();
renderPipelineDescriptor.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"( renderPipelineDescriptor.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[set(0), binding(0)]] var sampler0 : sampler; [[set(0), binding(0)]] var sampler0 : sampler;
[[set(0), binding(1)]] var texture : texture_2d<f32>; [[set(0), binding(1)]] var texture : texture_2d<f32>;
@ -344,10 +344,10 @@ TEST_P(D3D12VideoViewsTests, NV12SampleUVtoRG) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass( utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(
device, kYUVImageDataWidthInTexels, kYUVImageDataHeightInTexels); device, kYUVImageDataWidthInTexels, kYUVImageDataHeightInTexels);
renderPipelineDescriptor.cColorStates[0].format = renderPass.colorFormat; renderPipelineDescriptor.cTargets[0].format = renderPass.colorFormat;
renderPipelineDescriptor.primitiveTopology = wgpu::PrimitiveTopology::TriangleList; renderPipelineDescriptor.primitive.topology = wgpu::PrimitiveTopology::TriangleList;
wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline(&renderPipelineDescriptor); wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline2(&renderPipelineDescriptor);
wgpu::Sampler sampler = device.CreateSampler(); wgpu::Sampler sampler = device.CreateSampler();
@ -384,10 +384,10 @@ TEST_P(D3D12VideoViewsTests, NV12SampleYUVtoRGB) {
chromaViewDesc.aspect = wgpu::TextureAspect::Plane1Only; chromaViewDesc.aspect = wgpu::TextureAspect::Plane1Only;
wgpu::TextureView chromaTextureView = wgpuTexture.CreateView(&chromaViewDesc); wgpu::TextureView chromaTextureView = wgpuTexture.CreateView(&chromaViewDesc);
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 renderPipelineDescriptor;
renderPipelineDescriptor.vertexStage.module = GetTestVertexShaderModule(); renderPipelineDescriptor.vertex.module = GetTestVertexShaderModule();
renderPipelineDescriptor.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"( renderPipelineDescriptor.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[set(0), binding(0)]] var sampler0 : sampler; [[set(0), binding(0)]] var sampler0 : sampler;
[[set(0), binding(1)]] var lumaTexture : texture_2d<f32>; [[set(0), binding(1)]] var lumaTexture : texture_2d<f32>;
[[set(0), binding(2)]] var chromaTexture : texture_2d<f32>; [[set(0), binding(2)]] var chromaTexture : texture_2d<f32>;
@ -404,9 +404,9 @@ TEST_P(D3D12VideoViewsTests, NV12SampleYUVtoRGB) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass( utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(
device, kYUVImageDataWidthInTexels, kYUVImageDataHeightInTexels); device, kYUVImageDataWidthInTexels, kYUVImageDataHeightInTexels);
renderPipelineDescriptor.cColorStates[0].format = renderPass.colorFormat; renderPipelineDescriptor.cTargets[0].format = renderPass.colorFormat;
wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline(&renderPipelineDescriptor); wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline2(&renderPipelineDescriptor);
wgpu::Sampler sampler = device.CreateSampler(); wgpu::Sampler sampler = device.CreateSampler();

View File

@ -229,25 +229,22 @@ class VertexFormatDeprecationTests : public DeprecationTests {
} }
)"); )");
utils::ComboVertexStateDescriptor vertexState; utils::ComboRenderPipelineDescriptor2 descriptor;
vertexState.vertexBufferCount = 1; descriptor.vertex.module = vsModule;
vertexState.cVertexBuffers[0].arrayStride = 32; descriptor.cFragment.module = fsModule;
vertexState.cVertexBuffers[0].attributeCount = 1; descriptor.primitive.topology = wgpu::PrimitiveTopology::PointList;
vertexState.cAttributes[0].format = vertexFormat; descriptor.vertex.bufferCount = 1;
vertexState.cAttributes[0].offset = 0; descriptor.cBuffers[0].arrayStride = 32;
vertexState.cAttributes[0].shaderLocation = 0; descriptor.cBuffers[0].attributeCount = 1;
descriptor.cAttributes[0].format = vertexFormat;
utils::ComboRenderPipelineDescriptor descriptor(device); descriptor.cAttributes[0].offset = 0;
descriptor.vertexStage.module = vsModule; descriptor.cAttributes[0].shaderLocation = 0;
descriptor.cFragmentStage.module = fsModule; descriptor.cTargets[0].format = utils::BasicRenderPass::kDefaultColorFormat;
descriptor.primitiveTopology = wgpu::PrimitiveTopology::PointList;
descriptor.vertexState = &vertexState;
descriptor.cColorStates[0].format = utils::BasicRenderPass::kDefaultColorFormat;
if (deprecated) { if (deprecated) {
EXPECT_DEPRECATION_WARNING(device.CreateRenderPipeline(&descriptor)); EXPECT_DEPRECATION_WARNING(device.CreateRenderPipeline2(&descriptor));
} else { } else {
device.CreateRenderPipeline(&descriptor); device.CreateRenderPipeline2(&descriptor);
} }
} }
}; };

View File

@ -101,24 +101,21 @@ class DepthBiasTests : public DawnTest {
renderPassDesc.cDepthStencilAttachmentInfo.clearDepth = depthClear; renderPassDesc.cDepthStencilAttachmentInfo.clearDepth = depthClear;
// Create a render pipeline to render the quad // Create a render pipeline to render the quad
utils::ComboRenderPipelineDescriptor renderPipelineDesc(device); utils::ComboRenderPipelineDescriptor2 renderPipelineDesc;
renderPipelineDesc.cRasterizationState.depthBias = bias; renderPipelineDesc.vertex.module = vertexModule;
renderPipelineDesc.cRasterizationState.depthBiasSlopeScale = biasSlopeScale; renderPipelineDesc.cFragment.module = fragmentModule;
renderPipelineDesc.cRasterizationState.depthBiasClamp = biasClamp; wgpu::DepthStencilState* depthStencil = renderPipelineDesc.EnableDepthStencil(depthFormat);
depthStencil->depthWriteEnabled = true;
renderPipelineDesc.vertexStage.module = vertexModule; depthStencil->depthBias = bias;
renderPipelineDesc.cFragmentStage.module = fragmentModule; depthStencil->depthBiasSlopeScale = biasSlopeScale;
renderPipelineDesc.cDepthStencilState.format = depthFormat; depthStencil->depthBiasClamp = biasClamp;
renderPipelineDesc.cDepthStencilState.depthWriteEnabled = true;
if (depthFormat != wgpu::TextureFormat::Depth32Float) { if (depthFormat != wgpu::TextureFormat::Depth32Float) {
renderPipelineDesc.cDepthStencilState.depthCompare = wgpu::CompareFunction::Greater; depthStencil->depthCompare = wgpu::CompareFunction::Greater;
} }
renderPipelineDesc.depthStencilState = &renderPipelineDesc.cDepthStencilState; wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&renderPipelineDesc);
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&renderPipelineDesc);
// Draw the quad (two triangles) // Draw the quad (two triangles)
wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();

View File

@ -68,10 +68,10 @@ class DepthStencilCopyTests : public DawnTest {
return device.CreateTexture(&texDescriptor); return device.CreateTexture(&texDescriptor);
} }
void PopulatePipelineDescriptorWriteDepth(utils::ComboRenderPipelineDescriptor* desc, void PopulatePipelineDescriptorWriteDepth(utils::ComboRenderPipelineDescriptor2* desc,
wgpu::TextureFormat format, wgpu::TextureFormat format,
float regionDepth) { float regionDepth) {
desc->vertexStage.module = mVertexModule; desc->vertex.module = mVertexModule;
std::string fsSource = R"( std::string fsSource = R"(
[[builtin(frag_depth)]] var<out> FragDepth : f32; [[builtin(frag_depth)]] var<out> FragDepth : f32;
@ -79,11 +79,10 @@ class DepthStencilCopyTests : public DawnTest {
FragDepth = )" + std::to_string(regionDepth) + FragDepth = )" + std::to_string(regionDepth) +
";\n}"; ";\n}";
desc->cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, fsSource.c_str()); desc->cFragment.module = utils::CreateShaderModuleFromWGSL(device, fsSource.c_str());
desc->cDepthStencilState.format = format; wgpu::DepthStencilState* depthStencil = desc->EnableDepthStencil(format);
desc->cDepthStencilState.depthWriteEnabled = true; depthStencil->depthWriteEnabled = true;
desc->depthStencilState = &desc->cDepthStencilState; desc->cFragment.targetCount = 0;
desc->colorStateCount = 0;
} }
// Initialize the depth/stencil values for the texture using a render pass. // Initialize the depth/stencil values for the texture using a render pass.
@ -100,11 +99,11 @@ class DepthStencilCopyTests : public DawnTest {
utils::ComboRenderPassDescriptor renderPassDesc({}, texture.CreateView(&viewDesc)); utils::ComboRenderPassDescriptor renderPassDesc({}, texture.CreateView(&viewDesc));
renderPassDesc.cDepthStencilAttachmentInfo.clearDepth = clearDepth; renderPassDesc.cDepthStencilAttachmentInfo.clearDepth = clearDepth;
utils::ComboRenderPipelineDescriptor renderPipelineDesc(device); utils::ComboRenderPipelineDescriptor2 renderPipelineDesc;
PopulatePipelineDescriptorWriteDepth(&renderPipelineDesc, wgpu::TextureFormat::Depth32Float, PopulatePipelineDescriptorWriteDepth(&renderPipelineDesc, wgpu::TextureFormat::Depth32Float,
regionDepth); regionDepth);
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&renderPipelineDesc); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&renderPipelineDesc);
wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPassDesc); wgpu::RenderPassEncoder pass = commandEncoder.BeginRenderPass(&renderPassDesc);
pass.SetPipeline(pipeline); pass.SetPipeline(pipeline);
@ -132,13 +131,12 @@ class DepthStencilCopyTests : public DawnTest {
renderPassDesc.cDepthStencilAttachmentInfo.clearDepth = clearDepth; renderPassDesc.cDepthStencilAttachmentInfo.clearDepth = clearDepth;
renderPassDesc.cDepthStencilAttachmentInfo.clearStencil = clearStencil; renderPassDesc.cDepthStencilAttachmentInfo.clearStencil = clearStencil;
utils::ComboRenderPipelineDescriptor renderPipelineDesc(device); utils::ComboRenderPipelineDescriptor2 renderPipelineDesc;
PopulatePipelineDescriptorWriteDepth(&renderPipelineDesc, PopulatePipelineDescriptorWriteDepth(&renderPipelineDesc,
wgpu::TextureFormat::Depth24PlusStencil8, regionDepth); wgpu::TextureFormat::Depth24PlusStencil8, regionDepth);
renderPipelineDesc.cDepthStencil.stencilFront.passOp = wgpu::StencilOperation::Replace;
renderPipelineDesc.cDepthStencilState.stencilFront.passOp = wgpu::StencilOperation::Replace; wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&renderPipelineDesc);
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&renderPipelineDesc);
// Draw the quad (two triangles) // Draw the quad (two triangles)
wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
@ -238,9 +236,9 @@ class DepthStencilCopyTests : public DawnTest {
commandEncoder.CopyBufferToTexture(&bufferCopy, &textureCopy, &depthDataDesc.size); commandEncoder.CopyBufferToTexture(&bufferCopy, &textureCopy, &depthDataDesc.size);
// Pipeline for a full screen quad. // Pipeline for a full screen quad.
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertexStage.module = utils::CreateShaderModuleFromWGSL(device, R"( pipelineDescriptor.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[builtin(vertex_index)]] var<in> VertexIndex : u32; [[builtin(vertex_index)]] var<in> VertexIndex : u32;
[[builtin(position)]] var<out> Position : vec4<f32>; [[builtin(position)]] var<out> Position : vec4<f32>;
@ -254,7 +252,7 @@ class DepthStencilCopyTests : public DawnTest {
// Sample the input texture and write out depth. |result| will only be set to 1 if we // Sample the input texture and write out depth. |result| will only be set to 1 if we
// pass the depth test. // pass the depth test.
pipelineDescriptor.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"( pipelineDescriptor.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[group(0), binding(0)]] var texture0 : texture_2d<f32>; [[group(0), binding(0)]] var texture0 : texture_2d<f32>;
[[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>; [[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>;
@ -267,16 +265,15 @@ class DepthStencilCopyTests : public DawnTest {
})"); })");
// Pass the depth test only if the depth is equal. // Pass the depth test only if the depth is equal.
pipelineDescriptor.primitiveTopology = wgpu::PrimitiveTopology::TriangleList; pipelineDescriptor.primitive.topology = wgpu::PrimitiveTopology::TriangleList;
pipelineDescriptor.depthStencilState = &pipelineDescriptor.cDepthStencilState; wgpu::DepthStencilState* depthStencil = pipelineDescriptor.EnableDepthStencil(depthFormat);
pipelineDescriptor.cDepthStencilState.format = depthFormat; depthStencil->depthCompare = wgpu::CompareFunction::Equal;
pipelineDescriptor.cDepthStencilState.depthCompare = wgpu::CompareFunction::Equal; pipelineDescriptor.cTargets[0].format = colorTexDesc.format;
pipelineDescriptor.cColorStates[0].format = colorTexDesc.format;
// TODO(jiawei.shao@intel.com): The Intel Mesa Vulkan driver can't set gl_FragDepth unless // TODO(jiawei.shao@intel.com): The Intel Mesa Vulkan driver can't set gl_FragDepth unless
// depthWriteEnabled == true. This either needs to be fixed in the driver or restricted by // depthWriteEnabled == true. This either needs to be fixed in the driver or restricted by
// the WebGPU API. // the WebGPU API.
pipelineDescriptor.cDepthStencilState.depthWriteEnabled = true; depthStencil->depthWriteEnabled = true;
wgpu::TextureViewDescriptor viewDesc = {}; wgpu::TextureViewDescriptor viewDesc = {};
viewDesc.baseMipLevel = mipLevel; viewDesc.baseMipLevel = mipLevel;
@ -287,7 +284,7 @@ class DepthStencilCopyTests : public DawnTest {
passDescriptor.cDepthStencilAttachmentInfo.depthLoadOp = wgpu::LoadOp::Load; passDescriptor.cDepthStencilAttachmentInfo.depthLoadOp = wgpu::LoadOp::Load;
passDescriptor.cDepthStencilAttachmentInfo.stencilLoadOp = wgpu::LoadOp::Load; passDescriptor.cDepthStencilAttachmentInfo.stencilLoadOp = wgpu::LoadOp::Load;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDescriptor); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&pipelineDescriptor);
// Bind the depth data texture. // Bind the depth data texture.
wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0), wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0),
@ -646,18 +643,17 @@ TEST_P(DepthStencilCopyTests, ToStencilAspect) {
wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder(); wgpu::CommandEncoder commandEncoder = device.CreateCommandEncoder();
// Create a render pipline which decrements the stencil value for passing fragments. // Create a render pipline which decrements the stencil value for passing fragments.
// A quad is drawn in the bottom left. // A quad is drawn in the bottom left.
utils::ComboRenderPipelineDescriptor renderPipelineDesc(device); utils::ComboRenderPipelineDescriptor2 renderPipelineDesc;
renderPipelineDesc.vertexStage.module = mVertexModule; renderPipelineDesc.vertex.module = mVertexModule;
renderPipelineDesc.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"( renderPipelineDesc.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
renderPipelineDesc.cDepthStencilState.format = wgpu::TextureFormat::Depth24PlusStencil8; wgpu::DepthStencilState* depthStencil =
renderPipelineDesc.cDepthStencilState.stencilFront.passOp = renderPipelineDesc.EnableDepthStencil(wgpu::TextureFormat::Depth24PlusStencil8);
wgpu::StencilOperation::DecrementClamp; depthStencil->stencilFront.passOp = wgpu::StencilOperation::DecrementClamp;
renderPipelineDesc.depthStencilState = &renderPipelineDesc.cDepthStencilState; renderPipelineDesc.cFragment.targetCount = 0;
renderPipelineDesc.colorStateCount = 0;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&renderPipelineDesc); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&renderPipelineDesc);
// Create a render pass which loads the stencil. We want to load the values we // Create a render pass which loads the stencil. We want to load the values we
// copied in. Also load the canary depth values so they're not lost. // copied in. Also load the canary depth values so they're not lost.

View File

@ -71,7 +71,7 @@ class DepthStencilSamplingTest : public DawnTest {
Position = vec4<f32>(0.0, 0.0, 0.0, 1.0); Position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"); })");
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
std::ostringstream shaderSource; std::ostringstream shaderSource;
std::ostringstream shaderBody; std::ostringstream shaderBody;
@ -88,7 +88,7 @@ class DepthStencilSamplingTest : public DawnTest {
shaderBody << "\nresult" << index << " = textureLoad(tex" << index shaderBody << "\nresult" << index << " = textureLoad(tex" << index
<< ", vec2<i32>(0, 0), 0)[" << componentIndex << "];\n"; << ", vec2<i32>(0, 0), 0)[" << componentIndex << "];\n";
pipelineDescriptor.cColorStates[index].format = wgpu::TextureFormat::R32Float; pipelineDescriptor.cTargets[index].format = wgpu::TextureFormat::R32Float;
break; break;
case TestAspect::Stencil: case TestAspect::Stencil:
shaderSource << "[[group(0), binding(" << index << ")]] var tex" << index shaderSource << "[[group(0), binding(" << index << ")]] var tex" << index
@ -99,7 +99,7 @@ class DepthStencilSamplingTest : public DawnTest {
shaderBody << "\nresult" << index << " = textureLoad(tex" << index shaderBody << "\nresult" << index << " = textureLoad(tex" << index
<< ", vec2<i32>(0, 0), 0)[" << componentIndex << "];\n"; << ", vec2<i32>(0, 0), 0)[" << componentIndex << "];\n";
pipelineDescriptor.cColorStates[index].format = wgpu::TextureFormat::R8Uint; pipelineDescriptor.cTargets[index].format = wgpu::TextureFormat::R8Uint;
break; break;
} }
@ -110,12 +110,12 @@ class DepthStencilSamplingTest : public DawnTest {
wgpu::ShaderModule fsModule = wgpu::ShaderModule fsModule =
utils::CreateShaderModuleFromWGSL(device, shaderSource.str().c_str()); utils::CreateShaderModuleFromWGSL(device, shaderSource.str().c_str());
pipelineDescriptor.vertexStage.module = vsModule; pipelineDescriptor.vertex.module = vsModule;
pipelineDescriptor.cFragmentStage.module = fsModule; pipelineDescriptor.cFragment.module = fsModule;
pipelineDescriptor.primitiveTopology = wgpu::PrimitiveTopology::PointList; pipelineDescriptor.primitive.topology = wgpu::PrimitiveTopology::PointList;
pipelineDescriptor.colorStateCount = static_cast<uint32_t>(aspects.size()); pipelineDescriptor.cFragment.targetCount = static_cast<uint32_t>(aspects.size());
return device.CreateRenderPipeline(&pipelineDescriptor); return device.CreateRenderPipeline2(&pipelineDescriptor);
} }
wgpu::ComputePipeline CreateSamplingComputePipeline(std::vector<TestAspect> aspects, wgpu::ComputePipeline CreateSamplingComputePipeline(std::vector<TestAspect> aspects,
@ -201,14 +201,14 @@ class DepthStencilSamplingTest : public DawnTest {
{1, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Depth}, {1, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Depth},
{2, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Uniform}}); {2, wgpu::ShaderStage::Fragment, wgpu::BufferBindingType::Uniform}});
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertexStage.module = vsModule; pipelineDescriptor.vertex.module = vsModule;
pipelineDescriptor.cFragmentStage.module = fsModule; pipelineDescriptor.cFragment.module = fsModule;
pipelineDescriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl); pipelineDescriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl);
pipelineDescriptor.primitiveTopology = wgpu::PrimitiveTopology::PointList; pipelineDescriptor.primitive.topology = wgpu::PrimitiveTopology::PointList;
pipelineDescriptor.cColorStates[0].format = wgpu::TextureFormat::R32Float; pipelineDescriptor.cTargets[0].format = wgpu::TextureFormat::R32Float;
return device.CreateRenderPipeline(&pipelineDescriptor); return device.CreateRenderPipeline2(&pipelineDescriptor);
} }
wgpu::ComputePipeline CreateComparisonComputePipeline() { wgpu::ComputePipeline CreateComparisonComputePipeline() {

View File

@ -87,7 +87,7 @@ class DepthStencilStateTest : public DawnTest {
} }
struct TestSpec { struct TestSpec {
const wgpu::DepthStencilStateDescriptor& depthStencilState; const wgpu::DepthStencilState& depthStencil;
RGBA8 color; RGBA8 color;
float depth; float depth;
uint32_t stencil; uint32_t stencil;
@ -101,13 +101,13 @@ class DepthStencilStateTest : public DawnTest {
bool less, bool less,
bool equal, bool equal,
bool greater) { bool greater) {
wgpu::StencilStateFaceDescriptor stencilFace; wgpu::StencilFaceState stencilFace;
stencilFace.compare = wgpu::CompareFunction::Always; stencilFace.compare = wgpu::CompareFunction::Always;
stencilFace.failOp = wgpu::StencilOperation::Keep; stencilFace.failOp = wgpu::StencilOperation::Keep;
stencilFace.depthFailOp = wgpu::StencilOperation::Keep; stencilFace.depthFailOp = wgpu::StencilOperation::Keep;
stencilFace.passOp = wgpu::StencilOperation::Keep; stencilFace.passOp = wgpu::StencilOperation::Keep;
wgpu::DepthStencilStateDescriptor baseState; wgpu::DepthStencilState baseState;
baseState.depthWriteEnabled = true; baseState.depthWriteEnabled = true;
baseState.depthCompare = wgpu::CompareFunction::Always; baseState.depthCompare = wgpu::CompareFunction::Always;
baseState.stencilBack = stencilFace; baseState.stencilBack = stencilFace;
@ -115,7 +115,7 @@ class DepthStencilStateTest : public DawnTest {
baseState.stencilReadMask = 0xff; baseState.stencilReadMask = 0xff;
baseState.stencilWriteMask = 0xff; baseState.stencilWriteMask = 0xff;
wgpu::DepthStencilStateDescriptor state; wgpu::DepthStencilState state;
state.depthWriteEnabled = true; state.depthWriteEnabled = true;
state.depthCompare = compareFunction; state.depthCompare = compareFunction;
state.stencilBack = stencilFace; state.stencilBack = stencilFace;
@ -151,12 +151,12 @@ class DepthStencilStateTest : public DawnTest {
bool less, bool less,
bool equal, bool equal,
bool greater) { bool greater) {
wgpu::StencilStateFaceDescriptor baseStencilFaceDescriptor; wgpu::StencilFaceState baseStencilFaceDescriptor;
baseStencilFaceDescriptor.compare = wgpu::CompareFunction::Always; baseStencilFaceDescriptor.compare = wgpu::CompareFunction::Always;
baseStencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep; baseStencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep;
baseStencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep; baseStencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep;
baseStencilFaceDescriptor.passOp = wgpu::StencilOperation::Replace; baseStencilFaceDescriptor.passOp = wgpu::StencilOperation::Replace;
wgpu::DepthStencilStateDescriptor baseState; wgpu::DepthStencilState baseState;
baseState.depthWriteEnabled = false; baseState.depthWriteEnabled = false;
baseState.depthCompare = wgpu::CompareFunction::Always; baseState.depthCompare = wgpu::CompareFunction::Always;
baseState.stencilBack = baseStencilFaceDescriptor; baseState.stencilBack = baseStencilFaceDescriptor;
@ -164,12 +164,12 @@ class DepthStencilStateTest : public DawnTest {
baseState.stencilReadMask = 0xff; baseState.stencilReadMask = 0xff;
baseState.stencilWriteMask = 0xff; baseState.stencilWriteMask = 0xff;
wgpu::StencilStateFaceDescriptor stencilFaceDescriptor; wgpu::StencilFaceState stencilFaceDescriptor;
stencilFaceDescriptor.compare = compareFunction; stencilFaceDescriptor.compare = compareFunction;
stencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep; stencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep;
stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep; stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep;
stencilFaceDescriptor.passOp = wgpu::StencilOperation::Keep; stencilFaceDescriptor.passOp = wgpu::StencilOperation::Keep;
wgpu::DepthStencilStateDescriptor state; wgpu::DepthStencilState state;
state.depthWriteEnabled = false; state.depthWriteEnabled = false;
state.depthCompare = wgpu::CompareFunction::Always; state.depthCompare = wgpu::CompareFunction::Always;
state.stencilBack = stencilFaceDescriptor; state.stencilBack = stencilFaceDescriptor;
@ -204,12 +204,12 @@ class DepthStencilStateTest : public DawnTest {
uint32_t initialStencil, uint32_t initialStencil,
uint32_t reference, uint32_t reference,
uint32_t expectedStencil) { uint32_t expectedStencil) {
wgpu::StencilStateFaceDescriptor baseStencilFaceDescriptor; wgpu::StencilFaceState baseStencilFaceDescriptor;
baseStencilFaceDescriptor.compare = wgpu::CompareFunction::Always; baseStencilFaceDescriptor.compare = wgpu::CompareFunction::Always;
baseStencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep; baseStencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep;
baseStencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep; baseStencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep;
baseStencilFaceDescriptor.passOp = wgpu::StencilOperation::Replace; baseStencilFaceDescriptor.passOp = wgpu::StencilOperation::Replace;
wgpu::DepthStencilStateDescriptor baseState; wgpu::DepthStencilState baseState;
baseState.depthWriteEnabled = false; baseState.depthWriteEnabled = false;
baseState.depthCompare = wgpu::CompareFunction::Always; baseState.depthCompare = wgpu::CompareFunction::Always;
baseState.stencilBack = baseStencilFaceDescriptor; baseState.stencilBack = baseStencilFaceDescriptor;
@ -217,12 +217,12 @@ class DepthStencilStateTest : public DawnTest {
baseState.stencilReadMask = 0xff; baseState.stencilReadMask = 0xff;
baseState.stencilWriteMask = 0xff; baseState.stencilWriteMask = 0xff;
wgpu::StencilStateFaceDescriptor stencilFaceDescriptor; wgpu::StencilFaceState stencilFaceDescriptor;
stencilFaceDescriptor.compare = wgpu::CompareFunction::Always; stencilFaceDescriptor.compare = wgpu::CompareFunction::Always;
stencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep; stencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep;
stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep; stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep;
stencilFaceDescriptor.passOp = stencilOperation; stencilFaceDescriptor.passOp = stencilOperation;
wgpu::DepthStencilStateDescriptor state; wgpu::DepthStencilState state;
state.depthWriteEnabled = false; state.depthWriteEnabled = false;
state.depthCompare = wgpu::CompareFunction::Always; state.depthCompare = wgpu::CompareFunction::Always;
state.stencilBack = stencilFaceDescriptor; state.stencilBack = stencilFaceDescriptor;
@ -243,12 +243,12 @@ class DepthStencilStateTest : public DawnTest {
// Draw a list of test specs, and check if the stencil value is equal to the expected value // Draw a list of test specs, and check if the stencil value is equal to the expected value
void CheckStencil(std::vector<TestSpec> testParams, uint32_t expectedStencil) { void CheckStencil(std::vector<TestSpec> testParams, uint32_t expectedStencil) {
wgpu::StencilStateFaceDescriptor stencilFaceDescriptor; wgpu::StencilFaceState stencilFaceDescriptor;
stencilFaceDescriptor.compare = wgpu::CompareFunction::Equal; stencilFaceDescriptor.compare = wgpu::CompareFunction::Equal;
stencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep; stencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep;
stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep; stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep;
stencilFaceDescriptor.passOp = wgpu::StencilOperation::Keep; stencilFaceDescriptor.passOp = wgpu::StencilOperation::Keep;
wgpu::DepthStencilStateDescriptor state; wgpu::DepthStencilState state;
state.depthWriteEnabled = false; state.depthWriteEnabled = false;
state.depthCompare = wgpu::CompareFunction::Always; state.depthCompare = wgpu::CompareFunction::Always;
state.stencilBack = stencilFaceDescriptor; state.stencilBack = stencilFaceDescriptor;
@ -290,15 +290,15 @@ class DepthStencilStateTest : public DawnTest {
// Create a pipeline for the triangles with the test spec's depth stencil state // Create a pipeline for the triangles with the test spec's depth stencil state
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertexStage.module = vsModule; descriptor.vertex.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragment.module = fsModule;
descriptor.cDepthStencilState = test.depthStencilState; wgpu::DepthStencilState* depthStencil = descriptor.EnableDepthStencil();
descriptor.cDepthStencilState.format = wgpu::TextureFormat::Depth24PlusStencil8; *depthStencil = test.depthStencil;
descriptor.cRasterizationState.frontFace = test.frontFace; depthStencil->format = wgpu::TextureFormat::Depth24PlusStencil8;
descriptor.depthStencilState = &descriptor.cDepthStencilState; descriptor.primitive.frontFace = test.frontFace;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&descriptor);
// Create a bind group for the data // Create a bind group for the data
wgpu::BindGroup bindGroup = utils::MakeBindGroup( wgpu::BindGroup bindGroup = utils::MakeBindGroup(
@ -335,13 +335,13 @@ class DepthStencilStateTest : public DawnTest {
// Test compilation and usage of the fixture // Test compilation and usage of the fixture
TEST_P(DepthStencilStateTest, Basic) { TEST_P(DepthStencilStateTest, Basic) {
wgpu::StencilStateFaceDescriptor stencilFace; wgpu::StencilFaceState stencilFace;
stencilFace.compare = wgpu::CompareFunction::Always; stencilFace.compare = wgpu::CompareFunction::Always;
stencilFace.failOp = wgpu::StencilOperation::Keep; stencilFace.failOp = wgpu::StencilOperation::Keep;
stencilFace.depthFailOp = wgpu::StencilOperation::Keep; stencilFace.depthFailOp = wgpu::StencilOperation::Keep;
stencilFace.passOp = wgpu::StencilOperation::Keep; stencilFace.passOp = wgpu::StencilOperation::Keep;
wgpu::DepthStencilStateDescriptor state; wgpu::DepthStencilState state;
state.depthWriteEnabled = false; state.depthWriteEnabled = false;
state.depthCompare = wgpu::CompareFunction::Always; state.depthCompare = wgpu::CompareFunction::Always;
state.stencilBack = stencilFace; state.stencilBack = stencilFace;
@ -358,13 +358,13 @@ TEST_P(DepthStencilStateTest, Basic) {
// Test defaults: depth and stencil tests disabled // Test defaults: depth and stencil tests disabled
TEST_P(DepthStencilStateTest, DepthStencilDisabled) { TEST_P(DepthStencilStateTest, DepthStencilDisabled) {
wgpu::StencilStateFaceDescriptor stencilFace; wgpu::StencilFaceState stencilFace;
stencilFace.compare = wgpu::CompareFunction::Always; stencilFace.compare = wgpu::CompareFunction::Always;
stencilFace.failOp = wgpu::StencilOperation::Keep; stencilFace.failOp = wgpu::StencilOperation::Keep;
stencilFace.depthFailOp = wgpu::StencilOperation::Keep; stencilFace.depthFailOp = wgpu::StencilOperation::Keep;
stencilFace.passOp = wgpu::StencilOperation::Keep; stencilFace.passOp = wgpu::StencilOperation::Keep;
wgpu::DepthStencilStateDescriptor state; wgpu::DepthStencilState state;
state.depthWriteEnabled = false; state.depthWriteEnabled = false;
state.depthCompare = wgpu::CompareFunction::Always; state.depthCompare = wgpu::CompareFunction::Always;
state.stencilBack = stencilFace; state.stencilBack = stencilFace;
@ -423,13 +423,13 @@ TEST_P(DepthStencilStateTest, DepthNotEqual) {
// Test that disabling depth writes works and leaves the depth buffer unchanged // Test that disabling depth writes works and leaves the depth buffer unchanged
TEST_P(DepthStencilStateTest, DepthWriteDisabled) { TEST_P(DepthStencilStateTest, DepthWriteDisabled) {
wgpu::StencilStateFaceDescriptor stencilFace; wgpu::StencilFaceState stencilFace;
stencilFace.compare = wgpu::CompareFunction::Always; stencilFace.compare = wgpu::CompareFunction::Always;
stencilFace.failOp = wgpu::StencilOperation::Keep; stencilFace.failOp = wgpu::StencilOperation::Keep;
stencilFace.depthFailOp = wgpu::StencilOperation::Keep; stencilFace.depthFailOp = wgpu::StencilOperation::Keep;
stencilFace.passOp = wgpu::StencilOperation::Keep; stencilFace.passOp = wgpu::StencilOperation::Keep;
wgpu::DepthStencilStateDescriptor baseState; wgpu::DepthStencilState baseState;
baseState.depthWriteEnabled = true; baseState.depthWriteEnabled = true;
baseState.depthCompare = wgpu::CompareFunction::Always; baseState.depthCompare = wgpu::CompareFunction::Always;
baseState.stencilBack = stencilFace; baseState.stencilBack = stencilFace;
@ -437,7 +437,7 @@ TEST_P(DepthStencilStateTest, DepthWriteDisabled) {
baseState.stencilReadMask = 0xff; baseState.stencilReadMask = 0xff;
baseState.stencilWriteMask = 0xff; baseState.stencilWriteMask = 0xff;
wgpu::DepthStencilStateDescriptor noDepthWrite; wgpu::DepthStencilState noDepthWrite;
noDepthWrite.depthWriteEnabled = false; noDepthWrite.depthWriteEnabled = false;
noDepthWrite.depthCompare = wgpu::CompareFunction::Always; noDepthWrite.depthCompare = wgpu::CompareFunction::Always;
noDepthWrite.stencilBack = stencilFace; noDepthWrite.stencilBack = stencilFace;
@ -445,7 +445,7 @@ TEST_P(DepthStencilStateTest, DepthWriteDisabled) {
noDepthWrite.stencilReadMask = 0xff; noDepthWrite.stencilReadMask = 0xff;
noDepthWrite.stencilWriteMask = 0xff; noDepthWrite.stencilWriteMask = 0xff;
wgpu::DepthStencilStateDescriptor checkState; wgpu::DepthStencilState checkState;
checkState.depthWriteEnabled = false; checkState.depthWriteEnabled = false;
checkState.depthCompare = wgpu::CompareFunction::Equal; checkState.depthCompare = wgpu::CompareFunction::Equal;
checkState.stencilBack = stencilFace; checkState.stencilBack = stencilFace;
@ -538,12 +538,12 @@ TEST_P(DepthStencilStateTest, StencilDecrementWrap) {
// Check that the setting a stencil read mask works // Check that the setting a stencil read mask works
TEST_P(DepthStencilStateTest, StencilReadMask) { TEST_P(DepthStencilStateTest, StencilReadMask) {
wgpu::StencilStateFaceDescriptor baseStencilFaceDescriptor; wgpu::StencilFaceState baseStencilFaceDescriptor;
baseStencilFaceDescriptor.compare = wgpu::CompareFunction::Always; baseStencilFaceDescriptor.compare = wgpu::CompareFunction::Always;
baseStencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep; baseStencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep;
baseStencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep; baseStencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep;
baseStencilFaceDescriptor.passOp = wgpu::StencilOperation::Replace; baseStencilFaceDescriptor.passOp = wgpu::StencilOperation::Replace;
wgpu::DepthStencilStateDescriptor baseState; wgpu::DepthStencilState baseState;
baseState.depthWriteEnabled = false; baseState.depthWriteEnabled = false;
baseState.depthCompare = wgpu::CompareFunction::Always; baseState.depthCompare = wgpu::CompareFunction::Always;
baseState.stencilBack = baseStencilFaceDescriptor; baseState.stencilBack = baseStencilFaceDescriptor;
@ -551,12 +551,12 @@ TEST_P(DepthStencilStateTest, StencilReadMask) {
baseState.stencilReadMask = 0xff; baseState.stencilReadMask = 0xff;
baseState.stencilWriteMask = 0xff; baseState.stencilWriteMask = 0xff;
wgpu::StencilStateFaceDescriptor stencilFaceDescriptor; wgpu::StencilFaceState stencilFaceDescriptor;
stencilFaceDescriptor.compare = wgpu::CompareFunction::Equal; stencilFaceDescriptor.compare = wgpu::CompareFunction::Equal;
stencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep; stencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep;
stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep; stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep;
stencilFaceDescriptor.passOp = wgpu::StencilOperation::Keep; stencilFaceDescriptor.passOp = wgpu::StencilOperation::Keep;
wgpu::DepthStencilStateDescriptor state; wgpu::DepthStencilState state;
state.depthWriteEnabled = false; state.depthWriteEnabled = false;
state.depthCompare = wgpu::CompareFunction::Always; state.depthCompare = wgpu::CompareFunction::Always;
state.stencilBack = stencilFaceDescriptor; state.stencilBack = stencilFaceDescriptor;
@ -577,12 +577,12 @@ TEST_P(DepthStencilStateTest, StencilReadMask) {
// Check that setting a stencil write mask works // Check that setting a stencil write mask works
TEST_P(DepthStencilStateTest, StencilWriteMask) { TEST_P(DepthStencilStateTest, StencilWriteMask) {
wgpu::StencilStateFaceDescriptor baseStencilFaceDescriptor; wgpu::StencilFaceState baseStencilFaceDescriptor;
baseStencilFaceDescriptor.compare = wgpu::CompareFunction::Always; baseStencilFaceDescriptor.compare = wgpu::CompareFunction::Always;
baseStencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep; baseStencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep;
baseStencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep; baseStencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep;
baseStencilFaceDescriptor.passOp = wgpu::StencilOperation::Replace; baseStencilFaceDescriptor.passOp = wgpu::StencilOperation::Replace;
wgpu::DepthStencilStateDescriptor baseState; wgpu::DepthStencilState baseState;
baseState.depthWriteEnabled = false; baseState.depthWriteEnabled = false;
baseState.depthCompare = wgpu::CompareFunction::Always; baseState.depthCompare = wgpu::CompareFunction::Always;
baseState.stencilBack = baseStencilFaceDescriptor; baseState.stencilBack = baseStencilFaceDescriptor;
@ -590,12 +590,12 @@ TEST_P(DepthStencilStateTest, StencilWriteMask) {
baseState.stencilReadMask = 0xff; baseState.stencilReadMask = 0xff;
baseState.stencilWriteMask = 0x1; baseState.stencilWriteMask = 0x1;
wgpu::StencilStateFaceDescriptor stencilFaceDescriptor; wgpu::StencilFaceState stencilFaceDescriptor;
stencilFaceDescriptor.compare = wgpu::CompareFunction::Equal; stencilFaceDescriptor.compare = wgpu::CompareFunction::Equal;
stencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep; stencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep;
stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep; stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep;
stencilFaceDescriptor.passOp = wgpu::StencilOperation::Keep; stencilFaceDescriptor.passOp = wgpu::StencilOperation::Keep;
wgpu::DepthStencilStateDescriptor state; wgpu::DepthStencilState state;
state.depthWriteEnabled = false; state.depthWriteEnabled = false;
state.depthCompare = wgpu::CompareFunction::Always; state.depthCompare = wgpu::CompareFunction::Always;
state.stencilBack = stencilFaceDescriptor; state.stencilBack = stencilFaceDescriptor;
@ -616,12 +616,12 @@ TEST_P(DepthStencilStateTest, StencilWriteMask) {
// Test that the stencil operation is executed on stencil fail // Test that the stencil operation is executed on stencil fail
TEST_P(DepthStencilStateTest, StencilFail) { TEST_P(DepthStencilStateTest, StencilFail) {
wgpu::StencilStateFaceDescriptor baseStencilFaceDescriptor; wgpu::StencilFaceState baseStencilFaceDescriptor;
baseStencilFaceDescriptor.compare = wgpu::CompareFunction::Always; baseStencilFaceDescriptor.compare = wgpu::CompareFunction::Always;
baseStencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep; baseStencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep;
baseStencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep; baseStencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep;
baseStencilFaceDescriptor.passOp = wgpu::StencilOperation::Replace; baseStencilFaceDescriptor.passOp = wgpu::StencilOperation::Replace;
wgpu::DepthStencilStateDescriptor baseState; wgpu::DepthStencilState baseState;
baseState.depthWriteEnabled = false; baseState.depthWriteEnabled = false;
baseState.depthCompare = wgpu::CompareFunction::Always; baseState.depthCompare = wgpu::CompareFunction::Always;
baseState.stencilBack = baseStencilFaceDescriptor; baseState.stencilBack = baseStencilFaceDescriptor;
@ -629,12 +629,12 @@ TEST_P(DepthStencilStateTest, StencilFail) {
baseState.stencilReadMask = 0xff; baseState.stencilReadMask = 0xff;
baseState.stencilWriteMask = 0xff; baseState.stencilWriteMask = 0xff;
wgpu::StencilStateFaceDescriptor stencilFaceDescriptor; wgpu::StencilFaceState stencilFaceDescriptor;
stencilFaceDescriptor.compare = wgpu::CompareFunction::Less; stencilFaceDescriptor.compare = wgpu::CompareFunction::Less;
stencilFaceDescriptor.failOp = wgpu::StencilOperation::Replace; stencilFaceDescriptor.failOp = wgpu::StencilOperation::Replace;
stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep; stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep;
stencilFaceDescriptor.passOp = wgpu::StencilOperation::Keep; stencilFaceDescriptor.passOp = wgpu::StencilOperation::Keep;
wgpu::DepthStencilStateDescriptor state; wgpu::DepthStencilState state;
state.depthWriteEnabled = false; state.depthWriteEnabled = false;
state.depthCompare = wgpu::CompareFunction::Always; state.depthCompare = wgpu::CompareFunction::Always;
state.stencilBack = stencilFaceDescriptor; state.stencilBack = stencilFaceDescriptor;
@ -653,12 +653,12 @@ TEST_P(DepthStencilStateTest, StencilFail) {
// Test that the stencil operation is executed on stencil pass, depth fail // Test that the stencil operation is executed on stencil pass, depth fail
TEST_P(DepthStencilStateTest, StencilDepthFail) { TEST_P(DepthStencilStateTest, StencilDepthFail) {
wgpu::StencilStateFaceDescriptor baseStencilFaceDescriptor; wgpu::StencilFaceState baseStencilFaceDescriptor;
baseStencilFaceDescriptor.compare = wgpu::CompareFunction::Always; baseStencilFaceDescriptor.compare = wgpu::CompareFunction::Always;
baseStencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep; baseStencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep;
baseStencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep; baseStencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep;
baseStencilFaceDescriptor.passOp = wgpu::StencilOperation::Replace; baseStencilFaceDescriptor.passOp = wgpu::StencilOperation::Replace;
wgpu::DepthStencilStateDescriptor baseState; wgpu::DepthStencilState baseState;
baseState.depthWriteEnabled = true; baseState.depthWriteEnabled = true;
baseState.depthCompare = wgpu::CompareFunction::Always; baseState.depthCompare = wgpu::CompareFunction::Always;
baseState.stencilBack = baseStencilFaceDescriptor; baseState.stencilBack = baseStencilFaceDescriptor;
@ -666,12 +666,12 @@ TEST_P(DepthStencilStateTest, StencilDepthFail) {
baseState.stencilReadMask = 0xff; baseState.stencilReadMask = 0xff;
baseState.stencilWriteMask = 0xff; baseState.stencilWriteMask = 0xff;
wgpu::StencilStateFaceDescriptor stencilFaceDescriptor; wgpu::StencilFaceState stencilFaceDescriptor;
stencilFaceDescriptor.compare = wgpu::CompareFunction::Greater; stencilFaceDescriptor.compare = wgpu::CompareFunction::Greater;
stencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep; stencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep;
stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Replace; stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Replace;
stencilFaceDescriptor.passOp = wgpu::StencilOperation::Keep; stencilFaceDescriptor.passOp = wgpu::StencilOperation::Keep;
wgpu::DepthStencilStateDescriptor state; wgpu::DepthStencilState state;
state.depthWriteEnabled = true; state.depthWriteEnabled = true;
state.depthCompare = wgpu::CompareFunction::Less; state.depthCompare = wgpu::CompareFunction::Less;
state.stencilBack = stencilFaceDescriptor; state.stencilBack = stencilFaceDescriptor;
@ -689,12 +689,12 @@ TEST_P(DepthStencilStateTest, StencilDepthFail) {
// Test that the stencil operation is executed on stencil pass, depth pass // Test that the stencil operation is executed on stencil pass, depth pass
TEST_P(DepthStencilStateTest, StencilDepthPass) { TEST_P(DepthStencilStateTest, StencilDepthPass) {
wgpu::StencilStateFaceDescriptor baseStencilFaceDescriptor; wgpu::StencilFaceState baseStencilFaceDescriptor;
baseStencilFaceDescriptor.compare = wgpu::CompareFunction::Always; baseStencilFaceDescriptor.compare = wgpu::CompareFunction::Always;
baseStencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep; baseStencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep;
baseStencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep; baseStencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep;
baseStencilFaceDescriptor.passOp = wgpu::StencilOperation::Replace; baseStencilFaceDescriptor.passOp = wgpu::StencilOperation::Replace;
wgpu::DepthStencilStateDescriptor baseState; wgpu::DepthStencilState baseState;
baseState.depthWriteEnabled = true; baseState.depthWriteEnabled = true;
baseState.depthCompare = wgpu::CompareFunction::Always; baseState.depthCompare = wgpu::CompareFunction::Always;
baseState.stencilBack = baseStencilFaceDescriptor; baseState.stencilBack = baseStencilFaceDescriptor;
@ -702,12 +702,12 @@ TEST_P(DepthStencilStateTest, StencilDepthPass) {
baseState.stencilReadMask = 0xff; baseState.stencilReadMask = 0xff;
baseState.stencilWriteMask = 0xff; baseState.stencilWriteMask = 0xff;
wgpu::StencilStateFaceDescriptor stencilFaceDescriptor; wgpu::StencilFaceState stencilFaceDescriptor;
stencilFaceDescriptor.compare = wgpu::CompareFunction::Greater; stencilFaceDescriptor.compare = wgpu::CompareFunction::Greater;
stencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep; stencilFaceDescriptor.failOp = wgpu::StencilOperation::Keep;
stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep; stencilFaceDescriptor.depthFailOp = wgpu::StencilOperation::Keep;
stencilFaceDescriptor.passOp = wgpu::StencilOperation::Replace; stencilFaceDescriptor.passOp = wgpu::StencilOperation::Replace;
wgpu::DepthStencilStateDescriptor state; wgpu::DepthStencilState state;
state.depthWriteEnabled = true; state.depthWriteEnabled = true;
state.depthCompare = wgpu::CompareFunction::Less; state.depthCompare = wgpu::CompareFunction::Less;
state.stencilBack = stencilFaceDescriptor; state.stencilBack = stencilFaceDescriptor;
@ -732,19 +732,18 @@ TEST_P(DepthStencilStateTest, CreatePipelineWithAllFormats) {
}; };
for (wgpu::TextureFormat depthStencilFormat : kDepthStencilFormats) { for (wgpu::TextureFormat depthStencilFormat : kDepthStencilFormats) {
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertexStage.module = vsModule; descriptor.vertex.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragment.module = fsModule;
descriptor.cDepthStencilState.format = depthStencilFormat; descriptor.EnableDepthStencil(depthStencilFormat);
descriptor.depthStencilState = &descriptor.cDepthStencilState;
device.CreateRenderPipeline(&descriptor); device.CreateRenderPipeline2(&descriptor);
} }
} }
// Test that the front and back stencil states are set correctly (and take frontFace into account) // Test that the front and back stencil states are set correctly (and take frontFace into account)
TEST_P(DepthStencilStateTest, StencilFrontAndBackFace) { TEST_P(DepthStencilStateTest, StencilFrontAndBackFace) {
wgpu::DepthStencilStateDescriptor state; wgpu::DepthStencilState state;
state.stencilFront.compare = wgpu::CompareFunction::Always; state.stencilFront.compare = wgpu::CompareFunction::Always;
state.stencilBack.compare = wgpu::CompareFunction::Never; state.stencilBack.compare = wgpu::CompareFunction::Never;

View File

@ -40,17 +40,17 @@ class DestroyTest : public DawnTest {
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0); fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertexStage.module = vsModule; descriptor.vertex.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragment.module = fsModule;
descriptor.primitiveTopology = wgpu::PrimitiveTopology::TriangleList; descriptor.primitive.topology = wgpu::PrimitiveTopology::TriangleList;
descriptor.cVertexState.vertexBufferCount = 1; descriptor.vertex.bufferCount = 1;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float); descriptor.cBuffers[0].arrayStride = 4 * sizeof(float);
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1; descriptor.cBuffers[0].attributeCount = 1;
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4; descriptor.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
descriptor.cColorStates[0].format = renderPass.colorFormat; descriptor.cTargets[0].format = renderPass.colorFormat;
pipeline = device.CreateRenderPipeline(&descriptor); pipeline = device.CreateRenderPipeline2(&descriptor);
vertexBuffer = utils::CreateBufferFromData<float>( vertexBuffer = utils::CreateBufferFromData<float>(
device, wgpu::BufferUsage::Vertex, device, wgpu::BufferUsage::Vertex,

View File

@ -196,8 +196,8 @@ TEST_P(DeviceLostTest, CreateComputePipelineFails) {
TEST_P(DeviceLostTest, CreateRenderPipelineFails) { TEST_P(DeviceLostTest, CreateRenderPipelineFails) {
SetCallbackAndLoseForTesting(); SetCallbackAndLoseForTesting();
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor2 descriptor;
ASSERT_DEVICE_ERROR(device.CreateRenderPipeline(&descriptor)); ASSERT_DEVICE_ERROR(device.CreateRenderPipeline2(&descriptor));
} }
// Tests that CreateSampler fails when device is lost // Tests that CreateSampler fails when device is lost

View File

@ -39,18 +39,18 @@ class DrawIndexedIndirectTest : public DawnTest {
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0); fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertexStage.module = vsModule; descriptor.vertex.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragment.module = fsModule;
descriptor.primitiveTopology = wgpu::PrimitiveTopology::TriangleStrip; descriptor.primitive.topology = wgpu::PrimitiveTopology::TriangleStrip;
descriptor.cVertexState.indexFormat = wgpu::IndexFormat::Uint32; descriptor.primitive.stripIndexFormat = wgpu::IndexFormat::Uint32;
descriptor.cVertexState.vertexBufferCount = 1; descriptor.vertex.bufferCount = 1;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float); descriptor.cBuffers[0].arrayStride = 4 * sizeof(float);
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1; descriptor.cBuffers[0].attributeCount = 1;
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4; descriptor.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
descriptor.cColorStates[0].format = renderPass.colorFormat; descriptor.cTargets[0].format = renderPass.colorFormat;
pipeline = device.CreateRenderPipeline(&descriptor); pipeline = device.CreateRenderPipeline2(&descriptor);
vertexBuffer = utils::CreateBufferFromData<float>( vertexBuffer = utils::CreateBufferFromData<float>(
device, wgpu::BufferUsage::Vertex, device, wgpu::BufferUsage::Vertex,

View File

@ -39,18 +39,18 @@ class DrawIndexedTest : public DawnTest {
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0); fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertexStage.module = vsModule; descriptor.vertex.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragment.module = fsModule;
descriptor.primitiveTopology = wgpu::PrimitiveTopology::TriangleStrip; descriptor.primitive.topology = wgpu::PrimitiveTopology::TriangleStrip;
descriptor.cVertexState.indexFormat = wgpu::IndexFormat::Uint32; descriptor.primitive.stripIndexFormat = wgpu::IndexFormat::Uint32;
descriptor.cVertexState.vertexBufferCount = 1; descriptor.vertex.bufferCount = 1;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float); descriptor.cBuffers[0].arrayStride = 4 * sizeof(float);
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1; descriptor.cBuffers[0].attributeCount = 1;
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4; descriptor.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
descriptor.cColorStates[0].format = renderPass.colorFormat; descriptor.cTargets[0].format = renderPass.colorFormat;
pipeline = device.CreateRenderPipeline(&descriptor); pipeline = device.CreateRenderPipeline2(&descriptor);
vertexBuffer = utils::CreateBufferFromData<float>( vertexBuffer = utils::CreateBufferFromData<float>(
device, wgpu::BufferUsage::Vertex, device, wgpu::BufferUsage::Vertex,

View File

@ -39,18 +39,18 @@ class DrawIndirectTest : public DawnTest {
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0); fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertexStage.module = vsModule; descriptor.vertex.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragment.module = fsModule;
descriptor.primitiveTopology = wgpu::PrimitiveTopology::TriangleStrip; descriptor.primitive.topology = wgpu::PrimitiveTopology::TriangleStrip;
descriptor.cVertexState.indexFormat = wgpu::IndexFormat::Uint32; descriptor.primitive.stripIndexFormat = wgpu::IndexFormat::Uint32;
descriptor.cVertexState.vertexBufferCount = 1; descriptor.vertex.bufferCount = 1;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float); descriptor.cBuffers[0].arrayStride = 4 * sizeof(float);
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1; descriptor.cBuffers[0].attributeCount = 1;
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4; descriptor.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
descriptor.cColorStates[0].format = renderPass.colorFormat; descriptor.cTargets[0].format = renderPass.colorFormat;
pipeline = device.CreateRenderPipeline(&descriptor); pipeline = device.CreateRenderPipeline2(&descriptor);
vertexBuffer = utils::CreateBufferFromData<float>( vertexBuffer = utils::CreateBufferFromData<float>(
device, wgpu::BufferUsage::Vertex, device, wgpu::BufferUsage::Vertex,

View File

@ -39,17 +39,17 @@ class DrawTest : public DawnTest {
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0); fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertexStage.module = vsModule; descriptor.vertex.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragment.module = fsModule;
descriptor.primitiveTopology = wgpu::PrimitiveTopology::TriangleList; descriptor.primitive.topology = wgpu::PrimitiveTopology::TriangleList;
descriptor.cVertexState.vertexBufferCount = 1; descriptor.vertex.bufferCount = 1;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float); descriptor.cBuffers[0].arrayStride = 4 * sizeof(float);
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1; descriptor.cBuffers[0].attributeCount = 1;
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4; descriptor.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
descriptor.cColorStates[0].format = renderPass.colorFormat; descriptor.cTargets[0].format = renderPass.colorFormat;
pipeline = device.CreateRenderPipeline(&descriptor); pipeline = device.CreateRenderPipeline2(&descriptor);
vertexBuffer = utils::CreateBufferFromData<float>( vertexBuffer = utils::CreateBufferFromData<float>(
device, wgpu::BufferUsage::Vertex, device, wgpu::BufferUsage::Vertex,

View File

@ -155,10 +155,10 @@ class DynamicBufferOffsetTests : public DawnTest {
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, fs.str().c_str()); wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, fs.str().c_str());
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertexStage.module = vsModule; pipelineDescriptor.vertex.module = vsModule;
pipelineDescriptor.cFragmentStage.module = fsModule; pipelineDescriptor.cFragment.module = fsModule;
pipelineDescriptor.cColorStates[0].format = wgpu::TextureFormat::RGBA8Unorm; pipelineDescriptor.cTargets[0].format = wgpu::TextureFormat::RGBA8Unorm;
wgpu::PipelineLayoutDescriptor pipelineLayoutDescriptor; wgpu::PipelineLayoutDescriptor pipelineLayoutDescriptor;
if (isInheritedPipeline) { if (isInheritedPipeline) {
@ -169,7 +169,7 @@ class DynamicBufferOffsetTests : public DawnTest {
pipelineLayoutDescriptor.bindGroupLayouts = mBindGroupLayouts; pipelineLayoutDescriptor.bindGroupLayouts = mBindGroupLayouts;
pipelineDescriptor.layout = device.CreatePipelineLayout(&pipelineLayoutDescriptor); pipelineDescriptor.layout = device.CreatePipelineLayout(&pipelineLayoutDescriptor);
return device.CreateRenderPipeline(&pipelineDescriptor); return device.CreateRenderPipeline2(&pipelineDescriptor);
} }
wgpu::ComputePipeline CreateComputePipeline(bool isInheritedPipeline = false) { wgpu::ComputePipeline CreateComputePipeline(bool isInheritedPipeline = false) {

View File

@ -40,14 +40,14 @@ TEST_P(EntryPointTests, FragAndVertexSameModule) {
)"); )");
// Create a point pipeline from the module. // Create a point pipeline from the module.
utils::ComboRenderPipelineDescriptor desc(device); utils::ComboRenderPipelineDescriptor2 desc;
desc.vertexStage.module = module; desc.vertex.module = module;
desc.vertexStage.entryPoint = "vertex_main"; desc.vertex.entryPoint = "vertex_main";
desc.cFragmentStage.module = module; desc.cFragment.module = module;
desc.cFragmentStage.entryPoint = "fragment_main"; desc.cFragment.entryPoint = "fragment_main";
desc.cColorStates[0].format = wgpu::TextureFormat::RGBA8Unorm; desc.cTargets[0].format = wgpu::TextureFormat::RGBA8Unorm;
desc.primitiveTopology = wgpu::PrimitiveTopology::PointList; desc.primitive.topology = wgpu::PrimitiveTopology::PointList;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&desc); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&desc);
// Render the point and check that it was rendered. // Render the point and check that it was rendered.
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 1, 1); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 1, 1);

View File

@ -154,19 +154,19 @@ void FirstIndexOffsetTests::TestImpl(DrawMode mode,
constexpr uint32_t kComponentsPerVertex = 4; constexpr uint32_t kComponentsPerVertex = 4;
utils::ComboRenderPipelineDescriptor pipelineDesc(device); utils::ComboRenderPipelineDescriptor2 pipelineDesc;
pipelineDesc.vertexStage.module = pipelineDesc.vertex.module =
utils::CreateShaderModuleFromWGSL(device, vertexShader.str().c_str()); utils::CreateShaderModuleFromWGSL(device, vertexShader.str().c_str());
pipelineDesc.cFragmentStage.module = pipelineDesc.cFragment.module =
utils::CreateShaderModuleFromWGSL(device, fragmentShader.str().c_str()); utils::CreateShaderModuleFromWGSL(device, fragmentShader.str().c_str());
pipelineDesc.primitiveTopology = wgpu::PrimitiveTopology::PointList; pipelineDesc.primitive.topology = wgpu::PrimitiveTopology::PointList;
pipelineDesc.cVertexState.vertexBufferCount = 1; pipelineDesc.vertex.bufferCount = 1;
pipelineDesc.cVertexState.cVertexBuffers[0].arrayStride = kComponentsPerVertex * sizeof(float); pipelineDesc.cBuffers[0].arrayStride = kComponentsPerVertex * sizeof(float);
pipelineDesc.cVertexState.cVertexBuffers[0].attributeCount = 1; pipelineDesc.cBuffers[0].attributeCount = 1;
pipelineDesc.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4; pipelineDesc.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
pipelineDesc.cColorStates[0].format = renderPass.colorFormat; pipelineDesc.cTargets[0].format = renderPass.colorFormat;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDesc); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&pipelineDesc);
std::vector<float> vertexData(firstVertex * kComponentsPerVertex); std::vector<float> vertexData(firstVertex * kComponentsPerVertex);
vertexData.insert(vertexData.end(), {0, 0, 0, 1}); vertexData.insert(vertexData.end(), {0, 0, 0, 1});

View File

@ -74,13 +74,13 @@ class GpuMemorySyncTests : public DawnTest {
fragColor = vec4<f32>(f32(data.i) / 255.0, 0.0, 0.0, 1.0); fragColor = vec4<f32>(f32(data.i) / 255.0, 0.0, 0.0, 1.0);
})"); })");
utils::ComboRenderPipelineDescriptor rpDesc(device); utils::ComboRenderPipelineDescriptor2 rpDesc;
rpDesc.vertexStage.module = vsModule; rpDesc.vertex.module = vsModule;
rpDesc.cFragmentStage.module = fsModule; rpDesc.cFragment.module = fsModule;
rpDesc.primitiveTopology = wgpu::PrimitiveTopology::PointList; rpDesc.primitive.topology = wgpu::PrimitiveTopology::PointList;
rpDesc.cColorStates[0].format = colorFormat; rpDesc.cTargets[0].format = colorFormat;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&rpDesc); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&rpDesc);
wgpu::BindGroup bindGroup = wgpu::BindGroup bindGroup =
utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0), {{0, buffer}}); utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0), {{0, buffer}});
@ -351,13 +351,13 @@ class StorageToUniformSyncTests : public DawnTest {
fragColor = vec4<f32>(contents.color, 0.0, 0.0, 1.0); fragColor = vec4<f32>(contents.color, 0.0, 0.0, 1.0);
})"); })");
utils::ComboRenderPipelineDescriptor rpDesc(device); utils::ComboRenderPipelineDescriptor2 rpDesc;
rpDesc.vertexStage.module = vsModule; rpDesc.vertex.module = vsModule;
rpDesc.cFragmentStage.module = fsModule; rpDesc.cFragment.module = fsModule;
rpDesc.primitiveTopology = wgpu::PrimitiveTopology::PointList; rpDesc.primitive.topology = wgpu::PrimitiveTopology::PointList;
rpDesc.cColorStates[0].format = colorFormat; rpDesc.cTargets[0].format = colorFormat;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&rpDesc); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&rpDesc);
wgpu::BindGroup bindGroup = wgpu::BindGroup bindGroup =
utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0), {{0, mBuffer}}); utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0), {{0, mBuffer}});
@ -595,17 +595,17 @@ TEST_P(MultipleWriteThenMultipleReadTests, SeparateBuffers) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
utils::ComboRenderPipelineDescriptor rpDesc(device); utils::ComboRenderPipelineDescriptor2 rpDesc;
rpDesc.vertexStage.module = vsModule; rpDesc.vertex.module = vsModule;
rpDesc.cFragmentStage.module = fsModule; rpDesc.cFragment.module = fsModule;
rpDesc.primitiveTopology = wgpu::PrimitiveTopology::TriangleList; rpDesc.primitive.topology = wgpu::PrimitiveTopology::TriangleList;
rpDesc.cVertexState.vertexBufferCount = 1; rpDesc.vertex.bufferCount = 1;
rpDesc.cVertexState.cVertexBuffers[0].arrayStride = kVertexBufferStride; rpDesc.cBuffers[0].arrayStride = kVertexBufferStride;
rpDesc.cVertexState.cVertexBuffers[0].attributeCount = 1; rpDesc.cBuffers[0].attributeCount = 1;
rpDesc.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4; rpDesc.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
rpDesc.cColorStates[0].format = renderPass.colorFormat; rpDesc.cTargets[0].format = renderPass.colorFormat;
wgpu::RenderPipeline rp = device.CreateRenderPipeline(&rpDesc); wgpu::RenderPipeline rp = device.CreateRenderPipeline2(&rpDesc);
wgpu::BindGroup bindGroup1 = utils::MakeBindGroup(device, rp.GetBindGroupLayout(0), wgpu::BindGroup bindGroup1 = utils::MakeBindGroup(device, rp.GetBindGroupLayout(0),
{{0, uniformBuffer}, {1, storageBuffer}}); {{0, uniformBuffer}, {1, storageBuffer}});
@ -712,17 +712,17 @@ TEST_P(MultipleWriteThenMultipleReadTests, OneBuffer) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
utils::ComboRenderPipelineDescriptor rpDesc(device); utils::ComboRenderPipelineDescriptor2 rpDesc;
rpDesc.vertexStage.module = vsModule; rpDesc.vertex.module = vsModule;
rpDesc.cFragmentStage.module = fsModule; rpDesc.cFragment.module = fsModule;
rpDesc.primitiveTopology = wgpu::PrimitiveTopology::TriangleList; rpDesc.primitive.topology = wgpu::PrimitiveTopology::TriangleList;
rpDesc.cVertexState.vertexBufferCount = 1; rpDesc.vertex.bufferCount = 1;
rpDesc.cVertexState.cVertexBuffers[0].arrayStride = kVertexBufferStride; rpDesc.cBuffers[0].arrayStride = kVertexBufferStride;
rpDesc.cVertexState.cVertexBuffers[0].attributeCount = 1; rpDesc.cBuffers[0].attributeCount = 1;
rpDesc.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4; rpDesc.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
rpDesc.cColorStates[0].format = renderPass.colorFormat; rpDesc.cTargets[0].format = renderPass.colorFormat;
wgpu::RenderPipeline rp = device.CreateRenderPipeline(&rpDesc); wgpu::RenderPipeline rp = device.CreateRenderPipeline2(&rpDesc);
wgpu::BindGroup bindGroup1 = wgpu::BindGroup bindGroup1 =
utils::MakeBindGroup(device, rp.GetBindGroupLayout(0), utils::MakeBindGroup(device, rp.GetBindGroupLayout(0),

View File

@ -285,12 +285,12 @@ class IOSurfaceUsageTests : public IOSurfaceTestBase {
} }
)"); )");
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertexStage.module = vs; descriptor.vertex.module = vs;
descriptor.cFragmentStage.module = fs; descriptor.cFragment.module = fs;
descriptor.cColorStates[0].format = wgpu::TextureFormat::RGBA8Unorm; descriptor.cTargets[0].format = wgpu::TextureFormat::RGBA8Unorm;
pipeline = device.CreateRenderPipeline(&descriptor); pipeline = device.CreateRenderPipeline2(&descriptor);
} }
// The bindgroup containing the texture view for the ioSurface as well as the sampler. // The bindgroup containing the texture view for the ioSurface as well as the sampler.

View File

@ -51,18 +51,18 @@ class IndexFormatTest : public DawnTest {
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0); fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertexStage.module = vsModule; descriptor.vertex.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragment.module = fsModule;
descriptor.primitiveTopology = primitiveTopology; descriptor.primitive.topology = primitiveTopology;
descriptor.cVertexState.indexFormat = format; descriptor.primitive.stripIndexFormat = format;
descriptor.cVertexState.vertexBufferCount = 1; descriptor.vertex.bufferCount = 1;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float); descriptor.cBuffers[0].arrayStride = 4 * sizeof(float);
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1; descriptor.cBuffers[0].attributeCount = 1;
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4; descriptor.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
descriptor.cColorStates[0].format = renderPass.colorFormat; descriptor.cTargets[0].format = renderPass.colorFormat;
return device.CreateRenderPipeline(&descriptor); return device.CreateRenderPipeline2(&descriptor);
} }
}; };

View File

@ -202,7 +202,7 @@ class MultisampledRenderingTest : public DawnTest {
uint32_t sampleMask = 0xFFFFFFFF, uint32_t sampleMask = 0xFFFFFFFF,
bool alphaToCoverageEnabled = false, bool alphaToCoverageEnabled = false,
bool flipTriangle = false) { bool flipTriangle = false) {
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
// Draw a bottom-right triangle. In standard 4xMSAA pattern, for the pixels on diagonal, // Draw a bottom-right triangle. In standard 4xMSAA pattern, for the pixels on diagonal,
// only two of the samples will be touched. // only two of the samples will be touched.
@ -222,33 +222,33 @@ class MultisampledRenderingTest : public DawnTest {
})"; })";
if (flipTriangle) { if (flipTriangle) {
pipelineDescriptor.vertexStage.module = pipelineDescriptor.vertex.module =
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, vsFlipped); utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, vsFlipped);
} else { } else {
pipelineDescriptor.vertexStage.module = pipelineDescriptor.vertex.module =
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, vs); utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, vs);
} }
pipelineDescriptor.cFragmentStage.module = pipelineDescriptor.cFragment.module =
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, fs); utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, fs);
if (hasDepthStencilAttachment) { if (hasDepthStencilAttachment) {
pipelineDescriptor.cDepthStencilState.format = kDepthStencilFormat; wgpu::DepthStencilState* depthStencil =
pipelineDescriptor.cDepthStencilState.depthWriteEnabled = true; pipelineDescriptor.EnableDepthStencil(kDepthStencilFormat);
pipelineDescriptor.cDepthStencilState.depthCompare = wgpu::CompareFunction::Less; depthStencil->depthWriteEnabled = true;
pipelineDescriptor.depthStencilState = &pipelineDescriptor.cDepthStencilState; depthStencil->depthCompare = wgpu::CompareFunction::Less;
} }
pipelineDescriptor.sampleCount = kSampleCount; pipelineDescriptor.multisample.count = kSampleCount;
pipelineDescriptor.sampleMask = sampleMask; pipelineDescriptor.multisample.mask = sampleMask;
pipelineDescriptor.alphaToCoverageEnabled = alphaToCoverageEnabled; pipelineDescriptor.multisample.alphaToCoverageEnabled = alphaToCoverageEnabled;
pipelineDescriptor.colorStateCount = numColorAttachments; pipelineDescriptor.cFragment.targetCount = numColorAttachments;
for (uint32_t i = 0; i < numColorAttachments; ++i) { for (uint32_t i = 0; i < numColorAttachments; ++i) {
pipelineDescriptor.cColorStates[i].format = kColorFormat; pipelineDescriptor.cTargets[i].format = kColorFormat;
} }
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDescriptor); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&pipelineDescriptor);
return pipeline; return pipeline;
} }

View File

@ -51,16 +51,16 @@ class MultisampledSamplingTest : public DawnTest {
DawnTest::SetUp(); DawnTest::SetUp();
{ {
utils::ComboRenderPipelineDescriptor desc(device); utils::ComboRenderPipelineDescriptor2 desc;
desc.vertexStage.module = utils::CreateShaderModuleFromWGSL(device, R"( desc.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[location(0)]] var<in> pos : vec2<f32>; [[location(0)]] var<in> pos : vec2<f32>;
[[builtin(position)]] var<out> Position : vec4<f32>; [[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void { [[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(pos, 0.0, 1.0); Position = vec4<f32>(pos, 0.0, 1.0);
})"); })");
desc.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"( desc.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[location(0)]] var<out> fragColor : f32; [[location(0)]] var<out> fragColor : f32;
[[builtin(frag_depth)]] var<out> FragDepth : f32; [[builtin(frag_depth)]] var<out> FragDepth : f32;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
@ -68,23 +68,22 @@ class MultisampledSamplingTest : public DawnTest {
FragDepth = 0.7; FragDepth = 0.7;
})"); })");
desc.cVertexState.indexFormat = wgpu::IndexFormat::Uint32; desc.primitive.stripIndexFormat = wgpu::IndexFormat::Uint32;
desc.cVertexState.vertexBufferCount = 1; desc.vertex.bufferCount = 1;
desc.cVertexState.cVertexBuffers[0].attributeCount = 1; desc.cBuffers[0].attributeCount = 1;
desc.cVertexState.cVertexBuffers[0].arrayStride = 2 * sizeof(float); desc.cBuffers[0].arrayStride = 2 * sizeof(float);
desc.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x2; desc.cAttributes[0].format = wgpu::VertexFormat::Float32x2;
desc.cDepthStencilState.format = kDepthFormat; wgpu::DepthStencilState* depthStencil = desc.EnableDepthStencil(kDepthFormat);
desc.cDepthStencilState.depthWriteEnabled = true; depthStencil->depthWriteEnabled = true;
desc.depthStencilState = &desc.cDepthStencilState;
desc.sampleCount = kSampleCount; desc.multisample.count = kSampleCount;
desc.colorStateCount = 1; desc.cFragment.targetCount = 1;
desc.cColorStates[0].format = kColorFormat; desc.cTargets[0].format = kColorFormat;
desc.primitiveTopology = wgpu::PrimitiveTopology::TriangleStrip; desc.primitive.topology = wgpu::PrimitiveTopology::TriangleStrip;
drawPipeline = device.CreateRenderPipeline(&desc); drawPipeline = device.CreateRenderPipeline2(&desc);
} }
{ {
wgpu::ComputePipelineDescriptor desc = {}; wgpu::ComputePipelineDescriptor desc = {};

View File

@ -210,24 +210,24 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnLayout) {
EXPECT_NE(pl.Get(), otherPl.Get()); EXPECT_NE(pl.Get(), otherPl.Get());
EXPECT_EQ(pl.Get() == samePl.Get(), !UsesWire()); EXPECT_EQ(pl.Get() == samePl.Get(), !UsesWire());
utils::ComboRenderPipelineDescriptor desc(device); utils::ComboRenderPipelineDescriptor2 desc;
desc.vertexStage.module = utils::CreateShaderModuleFromWGSL(device, R"( desc.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>; [[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void { [[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(0.0, 0.0, 0.0, 0.0); Position = vec4<f32>(0.0, 0.0, 0.0, 0.0);
})"); })");
desc.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"( desc.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
desc.layout = pl; desc.layout = pl;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&desc); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&desc);
desc.layout = samePl; desc.layout = samePl;
wgpu::RenderPipeline samePipeline = device.CreateRenderPipeline(&desc); wgpu::RenderPipeline samePipeline = device.CreateRenderPipeline2(&desc);
desc.layout = otherPl; desc.layout = otherPl;
wgpu::RenderPipeline otherPipeline = device.CreateRenderPipeline(&desc); wgpu::RenderPipeline otherPipeline = device.CreateRenderPipeline2(&desc);
EXPECT_NE(pipeline.Get(), otherPipeline.Get()); EXPECT_NE(pipeline.Get(), otherPipeline.Get());
EXPECT_EQ(pipeline.Get() == samePipeline.Get(), !UsesWire()); EXPECT_EQ(pipeline.Get() == samePipeline.Get(), !UsesWire());
@ -254,19 +254,19 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnVertexModule) {
EXPECT_NE(module.Get(), otherModule.Get()); EXPECT_NE(module.Get(), otherModule.Get());
EXPECT_EQ(module.Get() == sameModule.Get(), !UsesWire()); EXPECT_EQ(module.Get() == sameModule.Get(), !UsesWire());
utils::ComboRenderPipelineDescriptor desc(device); utils::ComboRenderPipelineDescriptor2 desc;
desc.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"( desc.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
desc.vertexStage.module = module; desc.vertex.module = module;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&desc); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&desc);
desc.vertexStage.module = sameModule; desc.vertex.module = sameModule;
wgpu::RenderPipeline samePipeline = device.CreateRenderPipeline(&desc); wgpu::RenderPipeline samePipeline = device.CreateRenderPipeline2(&desc);
desc.vertexStage.module = otherModule; desc.vertex.module = otherModule;
wgpu::RenderPipeline otherPipeline = device.CreateRenderPipeline(&desc); wgpu::RenderPipeline otherPipeline = device.CreateRenderPipeline2(&desc);
EXPECT_NE(pipeline.Get(), otherPipeline.Get()); EXPECT_NE(pipeline.Get(), otherPipeline.Get());
EXPECT_EQ(pipeline.Get() == samePipeline.Get(), !UsesWire()); EXPECT_EQ(pipeline.Get() == samePipeline.Get(), !UsesWire());
@ -289,21 +289,21 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnFragmentModule) {
EXPECT_NE(module.Get(), otherModule.Get()); EXPECT_NE(module.Get(), otherModule.Get());
EXPECT_EQ(module.Get() == sameModule.Get(), !UsesWire()); EXPECT_EQ(module.Get() == sameModule.Get(), !UsesWire());
utils::ComboRenderPipelineDescriptor desc(device); utils::ComboRenderPipelineDescriptor2 desc;
desc.vertexStage.module = utils::CreateShaderModuleFromWGSL(device, R"( desc.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>; [[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void { [[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(0.0, 0.0, 0.0, 0.0); Position = vec4<f32>(0.0, 0.0, 0.0, 0.0);
})"); })");
desc.cFragmentStage.module = module; desc.cFragment.module = module;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&desc); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&desc);
desc.cFragmentStage.module = sameModule; desc.cFragment.module = sameModule;
wgpu::RenderPipeline samePipeline = device.CreateRenderPipeline(&desc); wgpu::RenderPipeline samePipeline = device.CreateRenderPipeline2(&desc);
desc.cFragmentStage.module = otherModule; desc.cFragment.module = otherModule;
wgpu::RenderPipeline otherPipeline = device.CreateRenderPipeline(&desc); wgpu::RenderPipeline otherPipeline = device.CreateRenderPipeline2(&desc);
EXPECT_NE(pipeline.Get(), otherPipeline.Get()); EXPECT_NE(pipeline.Get(), otherPipeline.Get());
EXPECT_EQ(pipeline.Get() == samePipeline.Get(), !UsesWire()); EXPECT_EQ(pipeline.Get() == samePipeline.Get(), !UsesWire());

View File

@ -180,13 +180,13 @@ TEST_P(OpArrayLengthTest, Fragment) {
})") })")
.c_str()); .c_str());
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertexStage.module = vsModule; descriptor.vertex.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragment.module = fsModule;
descriptor.primitiveTopology = wgpu::PrimitiveTopology::PointList; descriptor.primitive.topology = wgpu::PrimitiveTopology::PointList;
descriptor.cColorStates[0].format = renderPass.colorFormat; descriptor.cTargets[0].format = renderPass.colorFormat;
descriptor.layout = utils::MakeBasicPipelineLayout(device, &mBindGroupLayout); descriptor.layout = utils::MakeBasicPipelineLayout(device, &mBindGroupLayout);
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&descriptor);
// "Draw" the lengths to the texture. // "Draw" the lengths to the texture.
wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
@ -240,13 +240,13 @@ TEST_P(OpArrayLengthTest, Vertex) {
fragColor = pointColor; fragColor = pointColor;
})"); })");
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertexStage.module = vsModule; descriptor.vertex.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragment.module = fsModule;
descriptor.primitiveTopology = wgpu::PrimitiveTopology::PointList; descriptor.primitive.topology = wgpu::PrimitiveTopology::PointList;
descriptor.cColorStates[0].format = renderPass.colorFormat; descriptor.cTargets[0].format = renderPass.colorFormat;
descriptor.layout = utils::MakeBasicPipelineLayout(device, &mBindGroupLayout); descriptor.layout = utils::MakeBasicPipelineLayout(device, &mBindGroupLayout);
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&descriptor);
// "Draw" the lengths to the texture. // "Draw" the lengths to the texture.
wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();

View File

@ -185,23 +185,23 @@ class PrimitiveTopologyTest : public DawnTest {
// locations // locations
void DoTest(wgpu::PrimitiveTopology primitiveTopology, void DoTest(wgpu::PrimitiveTopology primitiveTopology,
const std::vector<LocationSpec>& locationSpecs) { const std::vector<LocationSpec>& locationSpecs) {
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertexStage.module = vsModule; descriptor.vertex.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragment.module = fsModule;
descriptor.primitiveTopology = primitiveTopology; descriptor.primitive.topology = primitiveTopology;
if (primitiveTopology == wgpu::PrimitiveTopology::TriangleStrip || if (primitiveTopology == wgpu::PrimitiveTopology::TriangleStrip ||
primitiveTopology == wgpu::PrimitiveTopology::LineStrip) { primitiveTopology == wgpu::PrimitiveTopology::LineStrip) {
descriptor.cVertexState.indexFormat = wgpu::IndexFormat::Uint32; descriptor.primitive.stripIndexFormat = wgpu::IndexFormat::Uint32;
} }
descriptor.cVertexState.vertexBufferCount = 1; descriptor.vertex.bufferCount = 1;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float); descriptor.cBuffers[0].arrayStride = 4 * sizeof(float);
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1; descriptor.cBuffers[0].attributeCount = 1;
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4; descriptor.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
descriptor.cColorStates[0].format = renderPass.colorFormat; descriptor.cTargets[0].format = renderPass.colorFormat;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&descriptor);
wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {

View File

@ -121,24 +121,21 @@ class OcclusionQueryTests : public QueryTests {
void TestOcclusionQueryWithDepthStencilTest(bool depthTestEnabled, void TestOcclusionQueryWithDepthStencilTest(bool depthTestEnabled,
bool stencilTestEnabled, bool stencilTestEnabled,
OcclusionExpectation::Result expected) { OcclusionExpectation::Result expected) {
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertexStage.module = vsModule; descriptor.vertex.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragment.module = fsModule;
// Enable depth and stencil tests and set comparison tests never pass. // Enable depth and stencil tests and set comparison tests never pass.
wgpu::DepthStencilStateDescriptor depthStencilState; wgpu::DepthStencilState* depthStencil =
depthStencilState.depthCompare = descriptor.EnableDepthStencil(wgpu::TextureFormat::Depth24PlusStencil8);
depthStencil->depthCompare =
depthTestEnabled ? wgpu::CompareFunction::Never : wgpu::CompareFunction::Always; depthTestEnabled ? wgpu::CompareFunction::Never : wgpu::CompareFunction::Always;
depthStencilState.stencilFront.compare = depthStencil->stencilFront.compare =
stencilTestEnabled ? wgpu::CompareFunction::Never : wgpu::CompareFunction::Always; stencilTestEnabled ? wgpu::CompareFunction::Never : wgpu::CompareFunction::Always;
depthStencilState.stencilBack.compare = depthStencil->stencilBack.compare =
stencilTestEnabled ? wgpu::CompareFunction::Never : wgpu::CompareFunction::Always; stencilTestEnabled ? wgpu::CompareFunction::Never : wgpu::CompareFunction::Always;
descriptor.cDepthStencilState = depthStencilState; wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&descriptor);
descriptor.cDepthStencilState.format = wgpu::TextureFormat::Depth24PlusStencil8;
descriptor.depthStencilState = &descriptor.cDepthStencilState;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
wgpu::Texture renderTarget = CreateRenderTexture(wgpu::TextureFormat::RGBA8Unorm); wgpu::Texture renderTarget = CreateRenderTexture(wgpu::TextureFormat::RGBA8Unorm);
wgpu::TextureView renderTargetView = renderTarget.CreateView(); wgpu::TextureView renderTargetView = renderTarget.CreateView();
@ -173,11 +170,11 @@ class OcclusionQueryTests : public QueryTests {
void TestOcclusionQueryWithScissorTest(ScissorRect rect, void TestOcclusionQueryWithScissorTest(ScissorRect rect,
OcclusionExpectation::Result expected) { OcclusionExpectation::Result expected) {
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertexStage.module = vsModule; descriptor.vertex.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragment.module = fsModule;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&descriptor);
wgpu::QuerySet querySet = CreateOcclusionQuerySet(kQueryCount); wgpu::QuerySet querySet = CreateOcclusionQuerySet(kQueryCount);
wgpu::Buffer destination = CreateResolveBuffer(kQueryCount * sizeof(uint64_t)); wgpu::Buffer destination = CreateResolveBuffer(kQueryCount * sizeof(uint64_t));

View File

@ -49,17 +49,17 @@ class RenderBundleTest : public DawnTest {
fragColor = fragmentUniformBuffer.color; fragColor = fragmentUniformBuffer.color;
})"); })");
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertexStage.module = vsModule; descriptor.vertex.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragment.module = fsModule;
descriptor.primitiveTopology = wgpu::PrimitiveTopology::TriangleList; descriptor.primitive.topology = wgpu::PrimitiveTopology::TriangleList;
descriptor.cVertexState.vertexBufferCount = 1; descriptor.vertex.bufferCount = 1;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float); descriptor.cBuffers[0].arrayStride = 4 * sizeof(float);
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1; descriptor.cBuffers[0].attributeCount = 1;
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4; descriptor.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
descriptor.cColorStates[0].format = renderPass.colorFormat; descriptor.cTargets[0].format = renderPass.colorFormat;
pipeline = device.CreateRenderPipeline(&descriptor); pipeline = device.CreateRenderPipeline2(&descriptor);
float colors0[] = {kColors[0].r / 255.f, kColors[0].g / 255.f, kColors[0].b / 255.f, float colors0[] = {kColors[0].r / 255.f, kColors[0].g / 255.f, kColors[0].b / 255.f,
kColors[0].a / 255.f}; kColors[0].a / 255.f};

View File

@ -33,12 +33,12 @@ class DrawQuad {
} }
void Draw(wgpu::RenderPassEncoder* pass) { void Draw(wgpu::RenderPassEncoder* pass) {
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.layout = pipelineLayout; descriptor.layout = pipelineLayout;
descriptor.vertexStage.module = vsModule; descriptor.vertex.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragment.module = fsModule;
auto renderPipeline = device.CreateRenderPipeline(&descriptor); auto renderPipeline = device.CreateRenderPipeline2(&descriptor);
pass->SetPipeline(renderPipeline); pass->SetPipeline(renderPipeline);
pass->Draw(6, 1, 0, 0); pass->Draw(6, 1, 0, 0);

View File

@ -45,13 +45,13 @@ class RenderPassTest : public DawnTest {
fragColor = vec4<f32>(0.0, 0.0, 1.0, 1.0); fragColor = vec4<f32>(0.0, 0.0, 1.0, 1.0);
})"); })");
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertexStage.module = mVSModule; descriptor.vertex.module = mVSModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragment.module = fsModule;
descriptor.primitiveTopology = wgpu::PrimitiveTopology::TriangleList; descriptor.primitive.topology = wgpu::PrimitiveTopology::TriangleList;
descriptor.cColorStates[0].format = kFormat; descriptor.cTargets[0].format = kFormat;
pipeline = device.CreateRenderPipeline(&descriptor); pipeline = device.CreateRenderPipeline2(&descriptor);
} }
wgpu::Texture CreateDefault2DTexture() { wgpu::Texture CreateDefault2DTexture() {
@ -143,14 +143,14 @@ TEST_P(RenderPassTest, NoCorrespondingFragmentShaderOutputs) {
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"( wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
})"); })");
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertexStage.module = mVSModule; descriptor.vertex.module = mVSModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragment.module = fsModule;
descriptor.primitiveTopology = wgpu::PrimitiveTopology::TriangleList; descriptor.primitive.topology = wgpu::PrimitiveTopology::TriangleList;
descriptor.cColorStates[0].format = kFormat; descriptor.cTargets[0].format = kFormat;
wgpu::RenderPipeline pipelineWithNoFragmentOutput = wgpu::RenderPipeline pipelineWithNoFragmentOutput =
device.CreateRenderPipeline(&descriptor); device.CreateRenderPipeline2(&descriptor);
pass.SetPipeline(pipelineWithNoFragmentOutput); pass.SetPipeline(pipelineWithNoFragmentOutput);
pass.Draw(3); pass.Draw(3);

View File

@ -69,22 +69,19 @@ class SamplerFilterAnisotropicTest : public DawnTest {
fragColor = textureSample(texture0, sampler0, fragUV); fragColor = textureSample(texture0, sampler0, fragUV);
})"); })");
utils::ComboVertexStateDescriptor vertexState; utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
vertexState.cVertexBuffers[0].attributeCount = 2; pipelineDescriptor.vertex.module = vsModule;
vertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4; pipelineDescriptor.cFragment.module = fsModule;
vertexState.cAttributes[1].shaderLocation = 1; pipelineDescriptor.cBuffers[0].attributeCount = 2;
vertexState.cAttributes[1].offset = 4 * sizeof(float); pipelineDescriptor.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
vertexState.cAttributes[1].format = wgpu::VertexFormat::Float32x2; pipelineDescriptor.cAttributes[1].shaderLocation = 1;
vertexState.vertexBufferCount = 1; pipelineDescriptor.cAttributes[1].offset = 4 * sizeof(float);
vertexState.cVertexBuffers[0].arrayStride = 6 * sizeof(float); pipelineDescriptor.cAttributes[1].format = wgpu::VertexFormat::Float32x2;
pipelineDescriptor.vertex.bufferCount = 1;
pipelineDescriptor.cBuffers[0].arrayStride = 6 * sizeof(float);
pipelineDescriptor.cTargets[0].format = mRenderPass.colorFormat;
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); mPipeline = device.CreateRenderPipeline2(&pipelineDescriptor);
pipelineDescriptor.vertexStage.module = vsModule;
pipelineDescriptor.cFragmentStage.module = fsModule;
pipelineDescriptor.vertexState = &vertexState;
pipelineDescriptor.cColorStates[0].format = mRenderPass.colorFormat;
mPipeline = device.CreateRenderPipeline(&pipelineDescriptor);
mBindGroupLayout = mPipeline.GetBindGroupLayout(0); mBindGroupLayout = mPipeline.GetBindGroupLayout(0);
InitTexture(); InitTexture();

View File

@ -81,12 +81,12 @@ class SamplerTest : public DawnTest {
fragColor = textureSample(texture0, sampler0, FragCoord.xy / vec2<f32>(2.0, 2.0)); fragColor = textureSample(texture0, sampler0, FragCoord.xy / vec2<f32>(2.0, 2.0));
})"); })");
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertexStage.module = vsModule; pipelineDescriptor.vertex.module = vsModule;
pipelineDescriptor.cFragmentStage.module = fsModule; pipelineDescriptor.cFragment.module = fsModule;
pipelineDescriptor.cColorStates[0].format = mRenderPass.colorFormat; pipelineDescriptor.cTargets[0].format = mRenderPass.colorFormat;
mPipeline = device.CreateRenderPipeline(&pipelineDescriptor); mPipeline = device.CreateRenderPipeline2(&pipelineDescriptor);
mBindGroupLayout = mPipeline.GetBindGroupLayout(0); mBindGroupLayout = mPipeline.GetBindGroupLayout(0);
wgpu::TextureDescriptor descriptor; wgpu::TextureDescriptor descriptor;

View File

@ -42,12 +42,12 @@ class ScissorTest : public DawnTest {
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0); fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertexStage.module = vsModule; descriptor.vertex.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragment.module = fsModule;
descriptor.cColorStates[0].format = format; descriptor.cTargets[0].format = format;
return device.CreateRenderPipeline(&descriptor); return device.CreateRenderPipeline2(&descriptor);
} }
}; };

View File

@ -474,12 +474,12 @@ fn IsEqualTo(pixel : vec4<f32>, expected : vec4<f32>) -> bool {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, vertexShader); wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, vertexShader);
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, fragmentShader); wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, fragmentShader);
utils::ComboRenderPipelineDescriptor desc(device); utils::ComboRenderPipelineDescriptor2 desc;
desc.vertexStage.module = vsModule; desc.vertex.module = vsModule;
desc.cFragmentStage.module = fsModule; desc.cFragment.module = fsModule;
desc.cColorStates[0].format = kRenderAttachmentFormat; desc.cTargets[0].format = kRenderAttachmentFormat;
desc.primitiveTopology = wgpu::PrimitiveTopology::PointList; desc.primitive.topology = wgpu::PrimitiveTopology::PointList;
return device.CreateRenderPipeline(&desc); return device.CreateRenderPipeline2(&desc);
} }
void CheckDrawsGreen(const char* vertexShader, void CheckDrawsGreen(const char* vertexShader,

View File

@ -220,24 +220,24 @@ TEST_P(SwapChainValidationTests, ViewDestroyedAfterPresent) {
// Check that returned view is of the current format / usage / dimension / size / sample count // Check that returned view is of the current format / usage / dimension / size / sample count
TEST_P(SwapChainValidationTests, ReturnedViewCharacteristics) { TEST_P(SwapChainValidationTests, ReturnedViewCharacteristics) {
utils::ComboRenderPipelineDescriptor pipelineDesc(device); utils::ComboRenderPipelineDescriptor2 pipelineDesc;
pipelineDesc.vertexStage.module = utils::CreateShaderModuleFromWGSL(device, R"( pipelineDesc.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>; [[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void { [[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(0.0, 0.0, 0.0, 1.0); Position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"); })");
pipelineDesc.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"( pipelineDesc.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>; [[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0); fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");
// Validation will check that the sample count of the view matches this format. // Validation will check that the sample count of the view matches this format.
pipelineDesc.sampleCount = 1; pipelineDesc.multisample.count = 1;
pipelineDesc.colorStateCount = 2; pipelineDesc.cFragment.targetCount = 2;
// Validation will check that the format of the view matches this format. // Validation will check that the format of the view matches this format.
pipelineDesc.cColorStates[0].format = wgpu::TextureFormat::BGRA8Unorm; pipelineDesc.cTargets[0].format = wgpu::TextureFormat::BGRA8Unorm;
pipelineDesc.cColorStates[1].format = wgpu::TextureFormat::R8Unorm; pipelineDesc.cTargets[1].format = wgpu::TextureFormat::R8Unorm;
device.CreateRenderPipeline(&pipelineDesc); device.CreateRenderPipeline2(&pipelineDesc);
// Create a second texture to be used as render pass attachment. Validation will check that the // Create a second texture to be used as render pass attachment. Validation will check that the
// size of the view matches the size of this texture. // size of the view matches the size of this texture.

View File

@ -144,7 +144,7 @@ class TextureFormatTest : public DawnTest {
// bindgroup and output its decompressed values to the render target. // bindgroup and output its decompressed values to the render target.
wgpu::RenderPipeline CreateSamplePipeline(FormatTestInfo sampleFormatInfo, wgpu::RenderPipeline CreateSamplePipeline(FormatTestInfo sampleFormatInfo,
FormatTestInfo renderFormatInfo) { FormatTestInfo renderFormatInfo) {
utils::ComboRenderPipelineDescriptor desc(device); utils::ComboRenderPipelineDescriptor2 desc;
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[builtin(vertex_index)]] var<in> VertexIndex : u32; [[builtin(vertex_index)]] var<in> VertexIndex : u32;
@ -173,11 +173,11 @@ class TextureFormatTest : public DawnTest {
wgpu::ShaderModule fsModule = wgpu::ShaderModule fsModule =
utils::CreateShaderModuleFromWGSL(device, fsSource.str().c_str()); utils::CreateShaderModuleFromWGSL(device, fsSource.str().c_str());
desc.vertexStage.module = vsModule; desc.vertex.module = vsModule;
desc.cFragmentStage.module = fsModule; desc.cFragment.module = fsModule;
desc.cColorStates[0].format = renderFormatInfo.format; desc.cTargets[0].format = renderFormatInfo.format;
return device.CreateRenderPipeline(&desc); return device.CreateRenderPipeline2(&desc);
} }
// The sampling test uploads the sample data in a texture with the sampleFormatInfo.format. // The sampling test uploads the sample data in a texture with the sampleFormatInfo.format.

View File

@ -68,13 +68,13 @@ class TextureSubresourceTest : public DawnTest {
fragColor = vec4<f32>(1.0, 0.0, 0.0, 1.0); fragColor = vec4<f32>(1.0, 0.0, 0.0, 1.0);
})"); })");
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertexStage.module = vsModule; descriptor.vertex.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragment.module = fsModule;
descriptor.primitiveTopology = wgpu::PrimitiveTopology::TriangleList; descriptor.primitive.topology = wgpu::PrimitiveTopology::TriangleList;
descriptor.cColorStates[0].format = kFormat; descriptor.cTargets[0].format = kFormat;
wgpu::RenderPipeline rp = device.CreateRenderPipeline(&descriptor); wgpu::RenderPipeline rp = device.CreateRenderPipeline2(&descriptor);
wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
@ -117,15 +117,15 @@ class TextureSubresourceTest : public DawnTest {
fragColor = textureSample(tex, samp, FragCoord.xy / vec2<f32>(4.0, 4.0)); fragColor = textureSample(tex, samp, FragCoord.xy / vec2<f32>(4.0, 4.0));
})"); })");
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertexStage.module = vsModule; descriptor.vertex.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragment.module = fsModule;
descriptor.primitiveTopology = wgpu::PrimitiveTopology::TriangleList; descriptor.primitive.topology = wgpu::PrimitiveTopology::TriangleList;
descriptor.cColorStates[0].format = kFormat; descriptor.cTargets[0].format = kFormat;
wgpu::Sampler sampler = device.CreateSampler(); wgpu::Sampler sampler = device.CreateSampler();
wgpu::RenderPipeline rp = device.CreateRenderPipeline(&descriptor); wgpu::RenderPipeline rp = device.CreateRenderPipeline2(&descriptor);
wgpu::BindGroupLayout bgl = rp.GetBindGroupLayout(0); wgpu::BindGroupLayout bgl = rp.GetBindGroupLayout(0);
wgpu::BindGroup bindGroup = wgpu::BindGroup bindGroup =
utils::MakeBindGroup(device, bgl, {{0, sampler}, {1, samplerView}}); utils::MakeBindGroup(device, bgl, {{0, sampler}, {1, samplerView}});

View File

@ -163,12 +163,12 @@ class TextureViewSamplingTest : public DawnTest {
wgpu::ShaderModule fsModule = wgpu::ShaderModule fsModule =
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, fragmentShader); utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, fragmentShader);
utils::ComboRenderPipelineDescriptor textureDescriptor(device); utils::ComboRenderPipelineDescriptor2 textureDescriptor;
textureDescriptor.vertexStage.module = mVSModule; textureDescriptor.vertex.module = mVSModule;
textureDescriptor.cFragmentStage.module = fsModule; textureDescriptor.cFragment.module = fsModule;
textureDescriptor.cColorStates[0].format = mRenderPass.colorFormat; textureDescriptor.cTargets[0].format = mRenderPass.colorFormat;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&textureDescriptor); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&textureDescriptor);
wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0), wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0),
{{0, mSampler}, {1, textureView}}); {{0, mSampler}, {1, textureView}});
@ -513,12 +513,12 @@ class TextureViewRenderingTest : public DawnTest {
wgpu::ShaderModule oneColorFsModule = utils::CreateShaderModule( wgpu::ShaderModule oneColorFsModule = utils::CreateShaderModule(
device, utils::SingleShaderStage::Fragment, oneColorFragmentShader); device, utils::SingleShaderStage::Fragment, oneColorFragmentShader);
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertexStage.module = vsModule; pipelineDescriptor.vertex.module = vsModule;
pipelineDescriptor.cFragmentStage.module = oneColorFsModule; pipelineDescriptor.cFragment.module = oneColorFsModule;
pipelineDescriptor.cColorStates[0].format = kDefaultFormat; pipelineDescriptor.cTargets[0].format = kDefaultFormat;
wgpu::RenderPipeline oneColorPipeline = device.CreateRenderPipeline(&pipelineDescriptor); wgpu::RenderPipeline oneColorPipeline = device.CreateRenderPipeline2(&pipelineDescriptor);
wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {

View File

@ -66,21 +66,20 @@ class TextureZeroInitTest : public DawnTest {
return descriptor; return descriptor;
} }
wgpu::RenderPipeline CreatePipelineForTest(float depth = 0.f) { wgpu::RenderPipeline CreatePipelineForTest(float depth = 0.f) {
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertexStage.module = CreateBasicVertexShaderForTest(depth); pipelineDescriptor.vertex.module = CreateBasicVertexShaderForTest(depth);
const char* fs = R"( const char* fs = R"(
[[location(0)]] var<out> fragColor : vec4<f32>; [[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(1.0, 0.0, 0.0, 1.0); fragColor = vec4<f32>(1.0, 0.0, 0.0, 1.0);
} }
)"; )";
pipelineDescriptor.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, fs); pipelineDescriptor.cFragment.module = utils::CreateShaderModuleFromWGSL(device, fs);
wgpu::DepthStencilState* depthStencil = pipelineDescriptor.EnableDepthStencil();
depthStencil->depthCompare = wgpu::CompareFunction::Equal;
depthStencil->stencilFront.compare = wgpu::CompareFunction::Equal;
pipelineDescriptor.cDepthStencilState.depthCompare = wgpu::CompareFunction::Equal; return device.CreateRenderPipeline2(&pipelineDescriptor);
pipelineDescriptor.cDepthStencilState.stencilFront.compare = wgpu::CompareFunction::Equal;
pipelineDescriptor.depthStencilState = &pipelineDescriptor.cDepthStencilState;
return device.CreateRenderPipeline(&pipelineDescriptor);
} }
wgpu::ShaderModule CreateBasicVertexShaderForTest(float depth = 0.f) { wgpu::ShaderModule CreateBasicVertexShaderForTest(float depth = 0.f) {
std::string source = R"( std::string source = R"(
@ -857,11 +856,11 @@ TEST_P(TextureZeroInitTest, RenderPassSampledTextureClear) {
wgpu::Texture renderTexture = device.CreateTexture(&renderTextureDescriptor); wgpu::Texture renderTexture = device.CreateTexture(&renderTextureDescriptor);
// Create render pipeline // Create render pipeline
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 renderPipelineDescriptor;
renderPipelineDescriptor.cColorStates[0].format = kColorFormat; renderPipelineDescriptor.cTargets[0].format = kColorFormat;
renderPipelineDescriptor.vertexStage.module = CreateBasicVertexShaderForTest(); renderPipelineDescriptor.vertex.module = CreateBasicVertexShaderForTest();
renderPipelineDescriptor.cFragmentStage.module = CreateSampledTextureFragmentShaderForTest(); renderPipelineDescriptor.cFragment.module = CreateSampledTextureFragmentShaderForTest();
wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline(&renderPipelineDescriptor); wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline2(&renderPipelineDescriptor);
// Create bindgroup // Create bindgroup
wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, renderPipeline.GetBindGroupLayout(0), wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, renderPipeline.GetBindGroupLayout(0),
@ -916,11 +915,11 @@ TEST_P(TextureZeroInitTest, TextureBothSampledAndAttachmentClear) {
wgpu::TextureView sampleView = texture.CreateView(&viewDesc); wgpu::TextureView sampleView = texture.CreateView(&viewDesc);
// Create render pipeline // Create render pipeline
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 renderPipelineDescriptor;
renderPipelineDescriptor.cColorStates[0].format = wgpu::TextureFormat::RGBA8Unorm; renderPipelineDescriptor.cTargets[0].format = wgpu::TextureFormat::RGBA8Unorm;
renderPipelineDescriptor.vertexStage.module = CreateBasicVertexShaderForTest(); renderPipelineDescriptor.vertex.module = CreateBasicVertexShaderForTest();
renderPipelineDescriptor.cFragmentStage.module = CreateSampledTextureFragmentShaderForTest(); renderPipelineDescriptor.cFragment.module = CreateSampledTextureFragmentShaderForTest();
wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline(&renderPipelineDescriptor); wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline2(&renderPipelineDescriptor);
wgpu::BindGroup bindGroup = wgpu::BindGroup bindGroup =
utils::MakeBindGroup(device, renderPipeline.GetBindGroupLayout(0), {{0, sampleView}}); utils::MakeBindGroup(device, renderPipeline.GetBindGroupLayout(0), {{0, sampleView}});
@ -1142,11 +1141,11 @@ TEST_P(TextureZeroInitTest, RenderPassStoreOpClear) {
EXPECT_LAZY_CLEAR(0u, queue.Submit(1, &commands)); EXPECT_LAZY_CLEAR(0u, queue.Submit(1, &commands));
// Create render pipeline // Create render pipeline
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 renderPipelineDescriptor;
renderPipelineDescriptor.vertexStage.module = CreateBasicVertexShaderForTest(); renderPipelineDescriptor.vertex.module = CreateBasicVertexShaderForTest();
renderPipelineDescriptor.cFragmentStage.module = CreateSampledTextureFragmentShaderForTest(); renderPipelineDescriptor.cFragment.module = CreateSampledTextureFragmentShaderForTest();
renderPipelineDescriptor.cColorStates[0].format = kColorFormat; renderPipelineDescriptor.cTargets[0].format = kColorFormat;
wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline(&renderPipelineDescriptor); wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline2(&renderPipelineDescriptor);
// Create bindgroup // Create bindgroup
wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, renderPipeline.GetBindGroupLayout(0), wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, renderPipeline.GetBindGroupLayout(0),
@ -1288,11 +1287,11 @@ TEST_P(TextureZeroInitTest, PreservesInitializedMip) {
EXPECT_LAZY_CLEAR(0u, queue.Submit(1, &commands)); EXPECT_LAZY_CLEAR(0u, queue.Submit(1, &commands));
// Create render pipeline // Create render pipeline
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 renderPipelineDescriptor;
renderPipelineDescriptor.vertexStage.module = CreateBasicVertexShaderForTest(); renderPipelineDescriptor.vertex.module = CreateBasicVertexShaderForTest();
renderPipelineDescriptor.cFragmentStage.module = CreateSampledTextureFragmentShaderForTest(); renderPipelineDescriptor.cFragment.module = CreateSampledTextureFragmentShaderForTest();
renderPipelineDescriptor.cColorStates[0].format = kColorFormat; renderPipelineDescriptor.cTargets[0].format = kColorFormat;
wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline(&renderPipelineDescriptor); wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline2(&renderPipelineDescriptor);
// Create bindgroup // Create bindgroup
wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, renderPipeline.GetBindGroupLayout(0), wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, renderPipeline.GetBindGroupLayout(0),
@ -1365,11 +1364,11 @@ TEST_P(TextureZeroInitTest, PreservesInitializedArrayLayer) {
EXPECT_LAZY_CLEAR(0u, queue.Submit(1, &commands)); EXPECT_LAZY_CLEAR(0u, queue.Submit(1, &commands));
// Create render pipeline // Create render pipeline
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 renderPipelineDescriptor;
renderPipelineDescriptor.vertexStage.module = CreateBasicVertexShaderForTest(); renderPipelineDescriptor.vertex.module = CreateBasicVertexShaderForTest();
renderPipelineDescriptor.cFragmentStage.module = CreateSampledTextureFragmentShaderForTest(); renderPipelineDescriptor.cFragment.module = CreateSampledTextureFragmentShaderForTest();
renderPipelineDescriptor.cColorStates[0].format = kColorFormat; renderPipelineDescriptor.cTargets[0].format = kColorFormat;
wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline(&renderPipelineDescriptor); wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline2(&renderPipelineDescriptor);
// Only sample from the uninitialized first layer. // Only sample from the uninitialized first layer.
wgpu::TextureViewDescriptor textureViewDescriptor; wgpu::TextureViewDescriptor textureViewDescriptor;
@ -1790,13 +1789,12 @@ class CompressedTextureZeroInitTest : public TextureZeroInitTest {
wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 renderPipelineDescriptor;
renderPipelineDescriptor.cColorStates[0].format = kColorFormat; renderPipelineDescriptor.cTargets[0].format = kColorFormat;
renderPipelineDescriptor.vertexStage.module = CreateBasicVertexShaderForTest(); renderPipelineDescriptor.vertex.module = CreateBasicVertexShaderForTest();
renderPipelineDescriptor.cFragmentStage.module = renderPipelineDescriptor.cFragment.module = CreateSampledTextureFragmentShaderForTest();
CreateSampledTextureFragmentShaderForTest();
wgpu::RenderPipeline renderPipeline = wgpu::RenderPipeline renderPipeline =
device.CreateRenderPipeline(&renderPipelineDescriptor); device.CreateRenderPipeline2(&renderPipelineDescriptor);
pass.SetPipeline(renderPipeline); pass.SetPipeline(renderPipeline);
wgpu::TextureViewDescriptor textureViewDescriptor = CreateTextureViewDescriptor( wgpu::TextureViewDescriptor textureViewDescriptor = CreateTextureViewDescriptor(

View File

@ -68,15 +68,16 @@ class VertexBufferRobustnessTest : public DawnTest {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 1, 1); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 1, 1);
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertexStage.module = vsModule; descriptor.vertex.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragment.module = fsModule;
descriptor.primitiveTopology = wgpu::PrimitiveTopology::PointList; descriptor.primitive.topology = wgpu::PrimitiveTopology::PointList;
descriptor.vertexState = &vertexState; descriptor.vertex.bufferCount = vertexState.vertexBufferCount;
descriptor.cColorStates[0].format = renderPass.colorFormat; descriptor.vertex.buffers = &vertexState.cVertexBuffers[0];
descriptor.cTargets[0].format = renderPass.colorFormat;
renderPass.renderPassInfo.cColorAttachments[0].clearColor = {0, 0, 0, 1}; renderPass.renderPassInfo.cColorAttachments[0].clearColor = {0, 0, 0, 1};
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&descriptor);
wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);

View File

@ -359,16 +359,16 @@ class VertexFormatTest : public DawnTest {
strideBytes += (4 - strideBytes % 4); strideBytes += (4 - strideBytes % 4);
} }
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertexStage.module = vsModule; descriptor.vertex.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragment.module = fsModule;
descriptor.cVertexState.vertexBufferCount = 1; descriptor.vertex.bufferCount = 1;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = strideBytes; descriptor.cBuffers[0].arrayStride = strideBytes;
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1; descriptor.cBuffers[0].attributeCount = 1;
descriptor.cVertexState.cAttributes[0].format = format; descriptor.cAttributes[0].format = format;
descriptor.cColorStates[0].format = renderPass.colorFormat; descriptor.cTargets[0].format = renderPass.colorFormat;
return device.CreateRenderPipeline(&descriptor); return device.CreateRenderPipeline2(&descriptor);
} }
template <typename VertexType, typename ExpectedType> template <typename VertexType, typename ExpectedType>

View File

@ -132,13 +132,14 @@ class VertexStateTest : public DawnTest {
} }
)"); )");
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertexStage.module = vsModule; descriptor.vertex.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragment.module = fsModule;
descriptor.vertexState = &vertexState; descriptor.vertex.bufferCount = vertexState.vertexBufferCount;
descriptor.cColorStates[0].format = renderPass.colorFormat; descriptor.vertex.buffers = vertexState.vertexBuffers;
descriptor.cTargets[0].format = renderPass.colorFormat;
return device.CreateRenderPipeline(&descriptor); return device.CreateRenderPipeline2(&descriptor);
} }
struct VertexAttributeSpec { struct VertexAttributeSpec {
@ -567,8 +568,8 @@ TEST_P(VertexStateTest, OverlappingVertexAttributes) {
wgpu::Buffer vertexBuffer = wgpu::Buffer vertexBuffer =
utils::CreateBufferFromData(device, &data, sizeof(data), wgpu::BufferUsage::Vertex); utils::CreateBufferFromData(device, &data, sizeof(data), wgpu::BufferUsage::Vertex);
utils::ComboRenderPipelineDescriptor pipelineDesc(device); utils::ComboRenderPipelineDescriptor2 pipelineDesc;
pipelineDesc.vertexStage.module = utils::CreateShaderModuleFromWGSL(device, R"( pipelineDesc.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[location(0)]] var<in> attr0 : vec4<f32>; [[location(0)]] var<in> attr0 : vec4<f32>;
[[location(1)]] var<in> attr1 : vec2<u32>; [[location(1)]] var<in> attr1 : vec2<u32>;
[[location(2)]] var<in> attr2 : vec4<f32>; [[location(2)]] var<in> attr2 : vec4<f32>;
@ -594,17 +595,18 @@ TEST_P(VertexStateTest, OverlappingVertexAttributes) {
color = vec4<f32>(1.0, 0.0, 0.0, 1.0); color = vec4<f32>(1.0, 0.0, 0.0, 1.0);
} }
})"); })");
pipelineDesc.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"( pipelineDesc.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[location(0)]] var<in> color : vec4<f32>; [[location(0)]] var<in> color : vec4<f32>;
[[location(0)]] var<out> fragColor : vec4<f32>; [[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
fragColor = color; fragColor = color;
})"); })");
pipelineDesc.vertexState = &vertexState; pipelineDesc.vertex.bufferCount = vertexState.vertexBufferCount;
pipelineDesc.cColorStates[0].format = renderPass.colorFormat; pipelineDesc.vertex.buffers = &vertexState.cVertexBuffers[0];
pipelineDesc.primitiveTopology = wgpu::PrimitiveTopology::PointList; pipelineDesc.cTargets[0].format = renderPass.colorFormat;
pipelineDesc.primitive.topology = wgpu::PrimitiveTopology::PointList;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDesc); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&pipelineDesc);
wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo); wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
@ -651,13 +653,14 @@ TEST_P(OptionalVertexStateTest, Basic) {
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0); fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertexStage.module = vsModule; descriptor.vertex.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragment.module = fsModule;
descriptor.primitiveTopology = wgpu::PrimitiveTopology::PointList; descriptor.primitive.topology = wgpu::PrimitiveTopology::PointList;
descriptor.vertexState = nullptr; descriptor.vertex.bufferCount = 0;
descriptor.vertex.buffers = nullptr;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&descriptor);
wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {

View File

@ -36,13 +36,13 @@ TEST_P(ViewportOrientationTests, OriginAt0x0) {
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0); fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);
})"); })");
utils::ComboRenderPipelineDescriptor descriptor(device); utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertexStage.module = vsModule; descriptor.vertex.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragment.module = fsModule;
descriptor.primitiveTopology = wgpu::PrimitiveTopology::PointList; descriptor.primitive.topology = wgpu::PrimitiveTopology::PointList;
descriptor.cColorStates[0].format = renderPass.colorFormat; descriptor.cTargets[0].format = renderPass.colorFormat;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&descriptor);
wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
{ {

View File

@ -60,11 +60,11 @@ class ViewportTest : public DawnTest {
uint32_t height, uint32_t height,
bool doViewportCall = true) { bool doViewportCall = true) {
// Create a pipeline that will draw a white quad. // Create a pipeline that will draw a white quad.
utils::ComboRenderPipelineDescriptor pipelineDesc(device); utils::ComboRenderPipelineDescriptor2 pipelineDesc;
pipelineDesc.vertexStage.module = mQuadVS; pipelineDesc.vertex.module = mQuadVS;
pipelineDesc.cFragmentStage.module = mQuadFS; pipelineDesc.cFragment.module = mQuadFS;
pipelineDesc.cColorStates[0].format = wgpu::TextureFormat::RGBA8Unorm; pipelineDesc.cTargets[0].format = wgpu::TextureFormat::RGBA8Unorm;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDesc); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&pipelineDesc);
// Render the quad with the viewport call. // Render the quad with the viewport call.
utils::BasicRenderPass rp = utils::CreateBasicRenderPass(device, kWidth, kHeight); utils::BasicRenderPass rp = utils::CreateBasicRenderPass(device, kWidth, kHeight);
@ -94,8 +94,8 @@ class ViewportTest : public DawnTest {
void TestViewportDepth(float minDepth, float maxDepth, bool doViewportCall = true) { void TestViewportDepth(float minDepth, float maxDepth, bool doViewportCall = true) {
// Create a pipeline drawing 3 points at depth 1.0, 0.5 and 0.0. // Create a pipeline drawing 3 points at depth 1.0, 0.5 and 0.0.
utils::ComboRenderPipelineDescriptor pipelineDesc(device); utils::ComboRenderPipelineDescriptor2 pipelineDesc;
pipelineDesc.vertexStage.module = utils::CreateShaderModuleFromWGSL(device, R"( pipelineDesc.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[builtin(vertex_index)]] var<in> VertexIndex : u32; [[builtin(vertex_index)]] var<in> VertexIndex : u32;
[[builtin(position)]] var<out> Position : vec4<f32>; [[builtin(position)]] var<out> Position : vec4<f32>;
@ -107,13 +107,13 @@ class ViewportTest : public DawnTest {
[[stage(vertex)]] fn main() -> void { [[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(points[VertexIndex], 1.0); Position = vec4<f32>(points[VertexIndex], 1.0);
})"); })");
pipelineDesc.cFragmentStage.module = mQuadFS; pipelineDesc.cFragment.module = mQuadFS;
pipelineDesc.colorStateCount = 0; pipelineDesc.cFragment.targetCount = 0;
pipelineDesc.primitiveTopology = wgpu::PrimitiveTopology::PointList; pipelineDesc.primitive.topology = wgpu::PrimitiveTopology::PointList;
pipelineDesc.depthStencilState = &pipelineDesc.cDepthStencilState; wgpu::DepthStencilState* depthStencil =
pipelineDesc.cDepthStencilState.depthWriteEnabled = true; pipelineDesc.EnableDepthStencil(wgpu::TextureFormat::Depth32Float);
pipelineDesc.cDepthStencilState.format = wgpu::TextureFormat::Depth32Float; depthStencil->depthWriteEnabled = true;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDesc); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&pipelineDesc);
// Create the texture that will store the post-viewport-transform depth. // Create the texture that will store the post-viewport-transform depth.
wgpu::TextureDescriptor depthDesc; wgpu::TextureDescriptor depthDesc;
@ -187,11 +187,11 @@ TEST_P(ViewportTest, ViewportDepth) {
// Test that a draw with an empty viewport doesn't draw anything. // Test that a draw with an empty viewport doesn't draw anything.
TEST_P(ViewportTest, EmptyViewport) { TEST_P(ViewportTest, EmptyViewport) {
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.cColorStates[0].format = wgpu::TextureFormat::RGBA8Unorm; pipelineDescriptor.cTargets[0].format = wgpu::TextureFormat::RGBA8Unorm;
pipelineDescriptor.vertexStage.module = mQuadVS; pipelineDescriptor.vertex.module = mQuadVS;
pipelineDescriptor.cFragmentStage.module = mQuadFS; pipelineDescriptor.cFragment.module = mQuadFS;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDescriptor); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&pipelineDescriptor);
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 1, 1); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 1, 1);

View File

@ -351,14 +351,13 @@ void DrawCallPerf::SetUp() {
} }
// Setup the base render pipeline descriptor. // Setup the base render pipeline descriptor.
utils::ComboRenderPipelineDescriptor renderPipelineDesc(device); utils::ComboRenderPipelineDescriptor2 renderPipelineDesc;
renderPipelineDesc.cVertexState.vertexBufferCount = 1; renderPipelineDesc.vertex.bufferCount = 1;
renderPipelineDesc.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float); renderPipelineDesc.cBuffers[0].arrayStride = 4 * sizeof(float);
renderPipelineDesc.cVertexState.cVertexBuffers[0].attributeCount = 1; renderPipelineDesc.cBuffers[0].attributeCount = 1;
renderPipelineDesc.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4; renderPipelineDesc.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
renderPipelineDesc.depthStencilState = &renderPipelineDesc.cDepthStencilState; renderPipelineDesc.EnableDepthStencil(wgpu::TextureFormat::Depth24PlusStencil8);
renderPipelineDesc.cDepthStencilState.format = wgpu::TextureFormat::Depth24PlusStencil8; renderPipelineDesc.cTargets[0].format = wgpu::TextureFormat::RGBA8Unorm;
renderPipelineDesc.cColorStates[0].format = wgpu::TextureFormat::RGBA8Unorm;
// Create the pipeline layout for the first pipeline. // Create the pipeline layout for the first pipeline.
wgpu::PipelineLayoutDescriptor pipelineLayoutDesc = {}; wgpu::PipelineLayoutDescriptor pipelineLayoutDesc = {};
@ -372,9 +371,9 @@ void DrawCallPerf::SetUp() {
// Create the first pipeline. // Create the first pipeline.
renderPipelineDesc.layout = pipelineLayout; renderPipelineDesc.layout = pipelineLayout;
renderPipelineDesc.vertexStage.module = vsModule; renderPipelineDesc.vertex.module = vsModule;
renderPipelineDesc.cFragmentStage.module = fsModule; renderPipelineDesc.cFragment.module = fsModule;
mPipelines[0] = device.CreateRenderPipeline(&renderPipelineDesc); mPipelines[0] = device.CreateRenderPipeline2(&renderPipelineDesc);
// If the test is using a dynamic pipeline, create the second pipeline. // If the test is using a dynamic pipeline, create the second pipeline.
if (GetParam().pipelineType == Pipeline::Dynamic) { if (GetParam().pipelineType == Pipeline::Dynamic) {
@ -400,8 +399,8 @@ void DrawCallPerf::SetUp() {
// Create the pipeline. // Create the pipeline.
renderPipelineDesc.layout = pipelineLayout; renderPipelineDesc.layout = pipelineLayout;
renderPipelineDesc.cFragmentStage.module = fsModule; renderPipelineDesc.cFragment.module = fsModule;
mPipelines[1] = device.CreateRenderPipeline(&renderPipelineDesc); mPipelines[1] = device.CreateRenderPipeline2(&renderPipelineDesc);
// Create the buffer and bind group to bind to the constant bind group layout slot. // Create the buffer and bind group to bind to the constant bind group layout slot.
constexpr float kConstantData[] = {0.01, 0.02, 0.03}; constexpr float kConstantData[] = {0.01, 0.02, 0.03};
@ -459,8 +458,8 @@ void DrawCallPerf::SetUp() {
if (GetParam().withRenderBundle == RenderBundle::Yes) { if (GetParam().withRenderBundle == RenderBundle::Yes) {
wgpu::RenderBundleEncoderDescriptor descriptor = {}; wgpu::RenderBundleEncoderDescriptor descriptor = {};
descriptor.colorFormatsCount = 1; descriptor.colorFormatsCount = 1;
descriptor.colorFormats = &renderPipelineDesc.cColorStates[0].format; descriptor.colorFormats = &renderPipelineDesc.cTargets[0].format;
descriptor.depthStencilFormat = renderPipelineDesc.cDepthStencilState.format; descriptor.depthStencilFormat = wgpu::TextureFormat::Depth24PlusStencil8;
wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&descriptor); wgpu::RenderBundleEncoder encoder = device.CreateRenderBundleEncoder(&descriptor);
RecordRenderCommands(encoder); RecordRenderCommands(encoder);

View File

@ -69,21 +69,21 @@ class SubresourceTrackingPerf : public DawnPerfTestWithParams<SubresourceTrackin
uploadTexDesc.usage = wgpu::TextureUsage::CopySrc; uploadTexDesc.usage = wgpu::TextureUsage::CopySrc;
mUploadTexture = device.CreateTexture(&uploadTexDesc); mUploadTexture = device.CreateTexture(&uploadTexDesc);
utils::ComboRenderPipelineDescriptor pipelineDesc(device); utils::ComboRenderPipelineDescriptor2 pipelineDesc;
pipelineDesc.vertexStage.module = utils::CreateShaderModuleFromWGSL(device, R"( pipelineDesc.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>; [[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void { [[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(1.0, 0.0, 0.0, 1.0); Position = vec4<f32>(1.0, 0.0, 0.0, 1.0);
} }
)"); )");
pipelineDesc.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"( pipelineDesc.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[location(0)]] var<out> FragColor : vec4<f32>; [[location(0)]] var<out> FragColor : vec4<f32>;
[[group(0), binding(0)]] var materials : texture_2d<f32>; [[group(0), binding(0)]] var materials : texture_2d<f32>;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
FragColor = vec4<f32>(1.0, 0.0, 0.0, 1.0); FragColor = vec4<f32>(1.0, 0.0, 0.0, 1.0);
} }
)"); )");
mPipeline = device.CreateRenderPipeline(&pipelineDesc); mPipeline = device.CreateRenderPipeline2(&pipelineDesc);
} }
private: private:

View File

@ -59,7 +59,7 @@ TEST_F(RenderPipelineValidationTest, CreationSuccess) {
descriptor.vertexStage.module = vsModule; descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragmentStage.module = fsModule;
device.CreateRenderPipeline(&descriptor); EXPECT_DEPRECATION_WARNING(device.CreateRenderPipeline(&descriptor));
} }
{ {
// Vertex input should be optional // Vertex input should be optional
@ -68,7 +68,7 @@ TEST_F(RenderPipelineValidationTest, CreationSuccess) {
descriptor.cFragmentStage.module = fsModule; descriptor.cFragmentStage.module = fsModule;
descriptor.vertexState = nullptr; descriptor.vertexState = nullptr;
device.CreateRenderPipeline(&descriptor); EXPECT_DEPRECATION_WARNING(device.CreateRenderPipeline(&descriptor));
} }
{ {
// Rasterization state should be optional // Rasterization state should be optional
@ -76,7 +76,7 @@ TEST_F(RenderPipelineValidationTest, CreationSuccess) {
descriptor.vertexStage.module = vsModule; descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule; descriptor.cFragmentStage.module = fsModule;
descriptor.rasterizationState = nullptr; descriptor.rasterizationState = nullptr;
device.CreateRenderPipeline(&descriptor); EXPECT_DEPRECATION_WARNING(device.CreateRenderPipeline(&descriptor));
} }
} }

View File

@ -127,14 +127,14 @@ TEST_P(D3D12DescriptorHeapTests, SwitchOverViewHeap) {
DAWN_SKIP_TEST_IF(!mD3DDevice->IsToggleEnabled( DAWN_SKIP_TEST_IF(!mD3DDevice->IsToggleEnabled(
dawn_native::Toggle::UseD3D12SmallShaderVisibleHeapForTesting)); dawn_native::Toggle::UseD3D12SmallShaderVisibleHeapForTesting));
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 renderPipelineDescriptor;
// Fill in a view heap with "view only" bindgroups (1x view per group) by creating a // Fill in a view heap with "view only" bindgroups (1x view per group) by creating a
// view bindgroup each draw. After HEAP_SIZE + 1 draws, the heaps must switch over. // view bindgroup each draw. After HEAP_SIZE + 1 draws, the heaps must switch over.
renderPipelineDescriptor.vertexStage.module = mSimpleVSModule; renderPipelineDescriptor.vertex.module = mSimpleVSModule;
renderPipelineDescriptor.cFragmentStage.module = mSimpleFSModule; renderPipelineDescriptor.cFragment.module = mSimpleFSModule;
wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline(&renderPipelineDescriptor); wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline2(&renderPipelineDescriptor);
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
Device* d3dDevice = reinterpret_cast<Device*>(device.Get()); Device* d3dDevice = reinterpret_cast<Device*>(device.Get());
@ -171,25 +171,25 @@ TEST_P(D3D12DescriptorHeapTests, SwitchOverViewHeap) {
// Verify the shader visible sampler heaps does not switch over within a single submit. // Verify the shader visible sampler heaps does not switch over within a single submit.
TEST_P(D3D12DescriptorHeapTests, NoSwitchOverSamplerHeap) { TEST_P(D3D12DescriptorHeapTests, NoSwitchOverSamplerHeap) {
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 renderPipelineDescriptor;
// Fill in a sampler heap with "sampler only" bindgroups (1x sampler per group) by creating a // Fill in a sampler heap with "sampler only" bindgroups (1x sampler per group) by creating a
// sampler bindgroup each draw. After HEAP_SIZE + 1 draws, the heaps WILL NOT switch over // sampler bindgroup each draw. After HEAP_SIZE + 1 draws, the heaps WILL NOT switch over
// because the sampler heap allocations are de-duplicated. // because the sampler heap allocations are de-duplicated.
renderPipelineDescriptor.vertexStage.module = utils::CreateShaderModuleFromWGSL(device, R"( renderPipelineDescriptor.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>; [[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void { [[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(0.0, 0.0, 0.0, 1.0); Position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
})"); })");
renderPipelineDescriptor.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"( renderPipelineDescriptor.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[location(0)]] var<out> FragColor : vec4<f32>; [[location(0)]] var<out> FragColor : vec4<f32>;
[[group(0), binding(0)]] var sampler0 : sampler; [[group(0), binding(0)]] var sampler0 : sampler;
[[stage(fragment)]] fn main() -> void { [[stage(fragment)]] fn main() -> void {
FragColor = vec4<f32>(0.0, 0.0, 0.0, 0.0); FragColor = vec4<f32>(0.0, 0.0, 0.0, 0.0);
})"); })");
wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline(&renderPipelineDescriptor); wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline2(&renderPipelineDescriptor);
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
wgpu::Sampler sampler = device.CreateSampler(); wgpu::Sampler sampler = device.CreateSampler();
@ -442,10 +442,10 @@ TEST_P(D3D12DescriptorHeapTests, EncodeManyUBO) {
utils::BasicRenderPass renderPass = utils::BasicRenderPass renderPass =
MakeRenderPass(kRTSize, kRTSize, wgpu::TextureFormat::R32Float); MakeRenderPass(kRTSize, kRTSize, wgpu::TextureFormat::R32Float);
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertexStage.module = mSimpleVSModule; pipelineDescriptor.vertex.module = mSimpleVSModule;
pipelineDescriptor.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"( pipelineDescriptor.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[block]] struct U { [[block]] struct U {
heapSize : f32; heapSize : f32;
}; };
@ -456,15 +456,18 @@ TEST_P(D3D12DescriptorHeapTests, EncodeManyUBO) {
FragColor = buffer0.heapSize; FragColor = buffer0.heapSize;
})"); })");
pipelineDescriptor.cColorStates[0].format = wgpu::TextureFormat::R32Float; wgpu::BlendState blend;
pipelineDescriptor.cColorStates[0].colorBlend.operation = wgpu::BlendOperation::Add; blend.color.operation = wgpu::BlendOperation::Add;
pipelineDescriptor.cColorStates[0].colorBlend.srcFactor = wgpu::BlendFactor::One; blend.color.srcFactor = wgpu::BlendFactor::One;
pipelineDescriptor.cColorStates[0].colorBlend.dstFactor = wgpu::BlendFactor::One; blend.color.dstFactor = wgpu::BlendFactor::One;
pipelineDescriptor.cColorStates[0].alphaBlend.operation = wgpu::BlendOperation::Add; blend.alpha.operation = wgpu::BlendOperation::Add;
pipelineDescriptor.cColorStates[0].alphaBlend.srcFactor = wgpu::BlendFactor::One; blend.alpha.srcFactor = wgpu::BlendFactor::One;
pipelineDescriptor.cColorStates[0].alphaBlend.dstFactor = wgpu::BlendFactor::One; blend.alpha.dstFactor = wgpu::BlendFactor::One;
wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline(&pipelineDescriptor); pipelineDescriptor.cTargets[0].format = wgpu::TextureFormat::R32Float;
pipelineDescriptor.cTargets[0].blend = &blend;
wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline2(&pipelineDescriptor);
const uint32_t heapSize = const uint32_t heapSize =
mD3DDevice->GetViewShaderVisibleDescriptorAllocator()->GetShaderVisibleHeapSizeForTesting(); mD3DDevice->GetViewShaderVisibleDescriptorAllocator()->GetShaderVisibleHeapSizeForTesting();
@ -515,12 +518,12 @@ TEST_P(D3D12DescriptorHeapTests, EncodeUBOOverflowMultipleSubmit) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertexStage.module = mSimpleVSModule; pipelineDescriptor.vertex.module = mSimpleVSModule;
pipelineDescriptor.cFragmentStage.module = mSimpleFSModule; pipelineDescriptor.cFragment.module = mSimpleFSModule;
pipelineDescriptor.cColorStates[0].format = renderPass.colorFormat; pipelineDescriptor.cTargets[0].format = renderPass.colorFormat;
wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline(&pipelineDescriptor); wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline2(&pipelineDescriptor);
// Encode the first descriptor and submit. // Encode the first descriptor and submit.
{ {
@ -600,12 +603,12 @@ TEST_P(D3D12DescriptorHeapTests, EncodeReuseUBOOverflow) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertexStage.module = mSimpleVSModule; pipelineDescriptor.vertex.module = mSimpleVSModule;
pipelineDescriptor.cFragmentStage.module = mSimpleFSModule; pipelineDescriptor.cFragment.module = mSimpleFSModule;
pipelineDescriptor.cColorStates[0].format = renderPass.colorFormat; pipelineDescriptor.cTargets[0].format = renderPass.colorFormat;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDescriptor); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&pipelineDescriptor);
std::array<float, 4> redColor = {1, 0, 0, 1}; std::array<float, 4> redColor = {1, 0, 0, 1};
wgpu::Buffer firstUniformBuffer = utils::CreateBufferFromData( wgpu::Buffer firstUniformBuffer = utils::CreateBufferFromData(
@ -661,12 +664,12 @@ TEST_P(D3D12DescriptorHeapTests, EncodeReuseUBOMultipleSubmits) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertexStage.module = mSimpleVSModule; pipelineDescriptor.vertex.module = mSimpleVSModule;
pipelineDescriptor.cFragmentStage.module = mSimpleFSModule; pipelineDescriptor.cFragment.module = mSimpleFSModule;
pipelineDescriptor.cColorStates[0].format = renderPass.colorFormat; pipelineDescriptor.cTargets[0].format = renderPass.colorFormat;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDescriptor); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&pipelineDescriptor);
// Encode heap worth of descriptors plus one more. // Encode heap worth of descriptors plus one more.
std::array<float, 4> redColor = {1, 0, 0, 1}; std::array<float, 4> redColor = {1, 0, 0, 1};
@ -773,9 +776,9 @@ TEST_P(D3D12DescriptorHeapTests, EncodeManyUBOAndSamplers) {
} }
{ {
utils::ComboRenderPipelineDescriptor pipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertexStage.module = utils::CreateShaderModuleFromWGSL(device, R"( pipelineDescriptor.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[block]] struct U { [[block]] struct U {
transform : mat2x2<f32>; transform : mat2x2<f32>;
}; };
@ -791,7 +794,7 @@ TEST_P(D3D12DescriptorHeapTests, EncodeManyUBOAndSamplers) {
); );
Position = vec4<f32>(buffer0.transform * (pos[VertexIndex]), 0.0, 1.0); Position = vec4<f32>(buffer0.transform * (pos[VertexIndex]), 0.0, 1.0);
})"); })");
pipelineDescriptor.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"( pipelineDescriptor.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[block]] struct U { [[block]] struct U {
color : vec4<f32>; color : vec4<f32>;
}; };
@ -807,9 +810,9 @@ TEST_P(D3D12DescriptorHeapTests, EncodeManyUBOAndSamplers) {
})"); })");
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
pipelineDescriptor.cColorStates[0].format = renderPass.colorFormat; pipelineDescriptor.cTargets[0].format = renderPass.colorFormat;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDescriptor); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&pipelineDescriptor);
// Encode a heap worth of descriptors |kNumOfHeaps| times. // Encode a heap worth of descriptors |kNumOfHeaps| times.
constexpr float dummy = 0.0f; constexpr float dummy = 0.0f;

View File

@ -330,11 +330,11 @@ TEST_P(D3D12ResourceResidencyTests, SetExternalReservation) {
// Checks that when a descriptor heap is bound, it is locked resident. Also checks that when a // Checks that when a descriptor heap is bound, it is locked resident. Also checks that when a
// previous descriptor heap becomes unbound, it is unlocked, placed in the LRU and can be evicted. // previous descriptor heap becomes unbound, it is unlocked, placed in the LRU and can be evicted.
TEST_P(D3D12DescriptorResidencyTests, SwitchedViewHeapResidency) { TEST_P(D3D12DescriptorResidencyTests, SwitchedViewHeapResidency) {
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor(device); utils::ComboRenderPipelineDescriptor2 renderPipelineDescriptor;
// Fill in a view heap with "view only" bindgroups (1x view per group) by creating a // Fill in a view heap with "view only" bindgroups (1x view per group) by creating a
// view bindgroup each draw. After HEAP_SIZE + 1 draws, the heaps must switch over. // view bindgroup each draw. After HEAP_SIZE + 1 draws, the heaps must switch over.
renderPipelineDescriptor.vertexStage.module = utils::CreateShaderModuleFromWGSL(device, R"( renderPipelineDescriptor.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>; [[builtin(position)]] var<out> Position : vec4<f32>;
[[builtin(vertex_index)]] var<in> VertexIndex : u32; [[builtin(vertex_index)]] var<in> VertexIndex : u32;
@ -347,7 +347,7 @@ TEST_P(D3D12DescriptorResidencyTests, SwitchedViewHeapResidency) {
Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0); Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
})"); })");
renderPipelineDescriptor.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"( renderPipelineDescriptor.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
[[block]] struct U { [[block]] struct U {
color : vec4<f32>; color : vec4<f32>;
}; };
@ -358,7 +358,7 @@ TEST_P(D3D12DescriptorResidencyTests, SwitchedViewHeapResidency) {
FragColor = colorBuffer.color; FragColor = colorBuffer.color;
})"); })");
wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline(&renderPipelineDescriptor); wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline2(&renderPipelineDescriptor);
constexpr uint32_t kSize = 512; constexpr uint32_t kSize = 512;
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kSize, kSize); utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kSize, kSize);

View File

@ -73,8 +73,6 @@ namespace utils {
std::array<wgpu::BlendState, kMaxColorAttachments> cBlends; std::array<wgpu::BlendState, kMaxColorAttachments> cBlends;
wgpu::FragmentState cFragment; wgpu::FragmentState cFragment;
private:
wgpu::DepthStencilState cDepthStencil; wgpu::DepthStencilState cDepthStencil;
}; };