Update samples to the new RenderPipelineDescriptor

Also does some updates for the new BindGroupLayoutEntry and
VertexFormats that were missed previously.

Bug: chromium:1177501
Change-Id: Icb336590673158538a1586a1f8d5ace398fb381e
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/45282
Reviewed-by: Brandon Jones <bajones@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez
2021-03-18 16:46:58 +00:00
committed by Commit Bot service account
parent 8ce8271c34
commit 9895c273d6
6 changed files with 147 additions and 140 deletions

View File

@@ -123,29 +123,29 @@ void initRender() {
depthStencilView = CreateDefaultDepthStencilView(device);
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.cVertexState.vertexBufferCount = 2;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = sizeof(Particle);
descriptor.cVertexState.cVertexBuffers[0].stepMode = wgpu::InputStepMode::Instance;
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 2;
descriptor.cVertexState.cAttributes[0].offset = offsetof(Particle, pos);
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float2;
descriptor.cVertexState.cAttributes[1].shaderLocation = 1;
descriptor.cVertexState.cAttributes[1].offset = offsetof(Particle, vel);
descriptor.cVertexState.cAttributes[1].format = wgpu::VertexFormat::Float2;
descriptor.cVertexState.cVertexBuffers[1].arrayStride = sizeof(glm::vec2);
descriptor.cVertexState.cVertexBuffers[1].attributeCount = 1;
descriptor.cVertexState.cVertexBuffers[1].attributes = &descriptor.cVertexState.cAttributes[2];
descriptor.cVertexState.cAttributes[2].shaderLocation = 2;
descriptor.cVertexState.cAttributes[2].format = wgpu::VertexFormat::Float2;
descriptor.depthStencilState = &descriptor.cDepthStencilState;
descriptor.cDepthStencilState.format = wgpu::TextureFormat::Depth24PlusStencil8;
descriptor.cColorStates[0].format = GetPreferredSwapChainTextureFormat();
descriptor.vertex.module = vsModule;
descriptor.vertex.bufferCount = 2;
descriptor.cBuffers[0].arrayStride = sizeof(Particle);
descriptor.cBuffers[0].stepMode = wgpu::InputStepMode::Instance;
descriptor.cBuffers[0].attributeCount = 2;
descriptor.cAttributes[0].offset = offsetof(Particle, pos);
descriptor.cAttributes[0].format = wgpu::VertexFormat::Float32x2;
descriptor.cAttributes[1].shaderLocation = 1;
descriptor.cAttributes[1].offset = offsetof(Particle, vel);
descriptor.cAttributes[1].format = wgpu::VertexFormat::Float32x2;
descriptor.cBuffers[1].arrayStride = sizeof(glm::vec2);
descriptor.cBuffers[1].attributeCount = 1;
descriptor.cBuffers[1].attributes = &descriptor.cAttributes[2];
descriptor.cAttributes[2].shaderLocation = 2;
descriptor.cAttributes[2].format = wgpu::VertexFormat::Float32x2;
renderPipeline = device.CreateRenderPipeline(&descriptor);
descriptor.cFragment.module = fsModule;
descriptor.EnableDepthStencil(wgpu::TextureFormat::Depth24PlusStencil8);
descriptor.cTargets[0].format = GetPreferredSwapChainTextureFormat();
renderPipeline = device.CreateRenderPipeline2(&descriptor);
}
void initSim() {
@@ -247,9 +247,9 @@ void initSim() {
auto bgl = utils::MakeBindGroupLayout(
device, {
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::UniformBuffer},
{1, wgpu::ShaderStage::Compute, wgpu::BindingType::StorageBuffer},
{2, wgpu::ShaderStage::Compute, wgpu::BindingType::StorageBuffer},
{0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Uniform},
{1, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Storage},
{2, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Storage},
});
wgpu::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl);