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:
parent
8ce8271c34
commit
9895c273d6
|
@ -113,15 +113,15 @@ void init() {
|
||||||
})");
|
})");
|
||||||
|
|
||||||
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
|
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
|
||||||
device, {{0, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer, true}});
|
device, {{0, wgpu::ShaderStage::Vertex, wgpu::BufferBindingType::Uniform, true}});
|
||||||
|
|
||||||
utils::ComboRenderPipelineDescriptor descriptor(device);
|
utils::ComboRenderPipelineDescriptor2 descriptor;
|
||||||
descriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl);
|
descriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl);
|
||||||
descriptor.vertexStage.module = vsModule;
|
descriptor.vertex.module = vsModule;
|
||||||
descriptor.cFragmentStage.module = fsModule;
|
descriptor.cFragment.module = fsModule;
|
||||||
descriptor.cColorStates[0].format = GetPreferredSwapChainTextureFormat();
|
descriptor.cTargets[0].format = GetPreferredSwapChainTextureFormat();
|
||||||
|
|
||||||
pipeline = device.CreateRenderPipeline(&descriptor);
|
pipeline = device.CreateRenderPipeline2(&descriptor);
|
||||||
|
|
||||||
shaderData.resize(kNumTriangles);
|
shaderData.resize(kNumTriangles);
|
||||||
for (auto& data : shaderData) {
|
for (auto& data : shaderData) {
|
||||||
|
|
|
@ -59,57 +59,48 @@ void init() {
|
||||||
WGPUShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, fs).Release();
|
WGPUShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, fs).Release();
|
||||||
|
|
||||||
{
|
{
|
||||||
WGPURenderPipelineDescriptor descriptor = {};
|
WGPURenderPipelineDescriptor2 descriptor = {};
|
||||||
|
|
||||||
descriptor.vertexStage.module = vsModule;
|
// Fragment state
|
||||||
descriptor.vertexStage.entryPoint = "main";
|
WGPUBlendState blend = {};
|
||||||
|
blend.color.operation = WGPUBlendOperation_Add;
|
||||||
|
blend.color.srcFactor = WGPUBlendFactor_One;
|
||||||
|
blend.color.dstFactor = WGPUBlendFactor_One;
|
||||||
|
blend.alpha.operation = WGPUBlendOperation_Add;
|
||||||
|
blend.alpha.srcFactor = WGPUBlendFactor_One;
|
||||||
|
blend.alpha.dstFactor = WGPUBlendFactor_One;
|
||||||
|
|
||||||
WGPUProgrammableStageDescriptor fragmentStage = {};
|
WGPUColorTargetState colorTarget = {};
|
||||||
fragmentStage.module = fsModule;
|
colorTarget.format = swapChainFormat;
|
||||||
fragmentStage.entryPoint = "main";
|
colorTarget.blend = &blend;
|
||||||
descriptor.fragmentStage = &fragmentStage;
|
colorTarget.writeMask = WGPUColorWriteMask_All;
|
||||||
|
|
||||||
descriptor.sampleCount = 1;
|
WGPUFragmentState fragment = {};
|
||||||
|
fragment.module = fsModule;
|
||||||
|
fragment.entryPoint = "main";
|
||||||
|
fragment.targetCount = 1;
|
||||||
|
fragment.targets = &colorTarget;
|
||||||
|
descriptor.fragment = &fragment;
|
||||||
|
|
||||||
WGPUBlendDescriptor blendDescriptor = {};
|
// Other state
|
||||||
blendDescriptor.operation = WGPUBlendOperation_Add;
|
descriptor.layout = nullptr;
|
||||||
blendDescriptor.srcFactor = WGPUBlendFactor_One;
|
descriptor.depthStencil = nullptr;
|
||||||
blendDescriptor.dstFactor = WGPUBlendFactor_One;
|
|
||||||
WGPUColorStateDescriptor colorStateDescriptor = {};
|
|
||||||
colorStateDescriptor.format = swapChainFormat;
|
|
||||||
colorStateDescriptor.alphaBlend = blendDescriptor;
|
|
||||||
colorStateDescriptor.colorBlend = blendDescriptor;
|
|
||||||
colorStateDescriptor.writeMask = WGPUColorWriteMask_All;
|
|
||||||
|
|
||||||
descriptor.colorStateCount = 1;
|
descriptor.vertex.module = vsModule;
|
||||||
descriptor.colorStates = &colorStateDescriptor;
|
descriptor.vertex.entryPoint = "main";
|
||||||
|
descriptor.vertex.bufferCount = 0;
|
||||||
|
descriptor.vertex.buffers = nullptr;
|
||||||
|
|
||||||
WGPUPipelineLayoutDescriptor pl = {};
|
descriptor.multisample.count = 1;
|
||||||
pl.bindGroupLayoutCount = 0;
|
descriptor.multisample.mask = 0xFFFFFFFF;
|
||||||
pl.bindGroupLayouts = nullptr;
|
descriptor.multisample.alphaToCoverageEnabled = false;
|
||||||
descriptor.layout = wgpuDeviceCreatePipelineLayout(device, &pl);
|
|
||||||
|
|
||||||
WGPUVertexStateDescriptor vertexState = {};
|
descriptor.primitive.frontFace = WGPUFrontFace_CCW;
|
||||||
vertexState.indexFormat = WGPUIndexFormat_Undefined;
|
descriptor.primitive.cullMode = WGPUCullMode_None;
|
||||||
vertexState.vertexBufferCount = 0;
|
descriptor.primitive.topology = WGPUPrimitiveTopology_TriangleList;
|
||||||
vertexState.vertexBuffers = nullptr;
|
descriptor.primitive.stripIndexFormat = WGPUIndexFormat_Undefined;
|
||||||
descriptor.vertexState = &vertexState;
|
|
||||||
|
|
||||||
WGPURasterizationStateDescriptor rasterizationState = {};
|
pipeline = wgpuDeviceCreateRenderPipeline2(device, &descriptor);
|
||||||
rasterizationState.frontFace = WGPUFrontFace_CCW;
|
|
||||||
rasterizationState.cullMode = WGPUCullMode_None;
|
|
||||||
rasterizationState.depthBias = 0;
|
|
||||||
rasterizationState.depthBiasSlopeScale = 0.0;
|
|
||||||
rasterizationState.depthBiasClamp = 0.0;
|
|
||||||
descriptor.rasterizationState = &rasterizationState;
|
|
||||||
|
|
||||||
descriptor.primitiveTopology = WGPUPrimitiveTopology_TriangleList;
|
|
||||||
descriptor.sampleMask = 0xFFFFFFFF;
|
|
||||||
descriptor.alphaToCoverageEnabled = false;
|
|
||||||
|
|
||||||
descriptor.depthStencilState = nullptr;
|
|
||||||
|
|
||||||
pipeline = wgpuDeviceCreateRenderPipeline(device, &descriptor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wgpuShaderModuleRelease(vsModule);
|
wgpuShaderModuleRelease(vsModule);
|
||||||
|
|
|
@ -123,29 +123,29 @@ void initRender() {
|
||||||
|
|
||||||
depthStencilView = CreateDefaultDepthStencilView(device);
|
depthStencilView = CreateDefaultDepthStencilView(device);
|
||||||
|
|
||||||
utils::ComboRenderPipelineDescriptor descriptor(device);
|
utils::ComboRenderPipelineDescriptor2 descriptor;
|
||||||
descriptor.vertexStage.module = vsModule;
|
|
||||||
descriptor.cFragmentStage.module = fsModule;
|
|
||||||
|
|
||||||
descriptor.cVertexState.vertexBufferCount = 2;
|
descriptor.vertex.module = vsModule;
|
||||||
descriptor.cVertexState.cVertexBuffers[0].arrayStride = sizeof(Particle);
|
descriptor.vertex.bufferCount = 2;
|
||||||
descriptor.cVertexState.cVertexBuffers[0].stepMode = wgpu::InputStepMode::Instance;
|
descriptor.cBuffers[0].arrayStride = sizeof(Particle);
|
||||||
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 2;
|
descriptor.cBuffers[0].stepMode = wgpu::InputStepMode::Instance;
|
||||||
descriptor.cVertexState.cAttributes[0].offset = offsetof(Particle, pos);
|
descriptor.cBuffers[0].attributeCount = 2;
|
||||||
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float2;
|
descriptor.cAttributes[0].offset = offsetof(Particle, pos);
|
||||||
descriptor.cVertexState.cAttributes[1].shaderLocation = 1;
|
descriptor.cAttributes[0].format = wgpu::VertexFormat::Float32x2;
|
||||||
descriptor.cVertexState.cAttributes[1].offset = offsetof(Particle, vel);
|
descriptor.cAttributes[1].shaderLocation = 1;
|
||||||
descriptor.cVertexState.cAttributes[1].format = wgpu::VertexFormat::Float2;
|
descriptor.cAttributes[1].offset = offsetof(Particle, vel);
|
||||||
descriptor.cVertexState.cVertexBuffers[1].arrayStride = sizeof(glm::vec2);
|
descriptor.cAttributes[1].format = wgpu::VertexFormat::Float32x2;
|
||||||
descriptor.cVertexState.cVertexBuffers[1].attributeCount = 1;
|
descriptor.cBuffers[1].arrayStride = sizeof(glm::vec2);
|
||||||
descriptor.cVertexState.cVertexBuffers[1].attributes = &descriptor.cVertexState.cAttributes[2];
|
descriptor.cBuffers[1].attributeCount = 1;
|
||||||
descriptor.cVertexState.cAttributes[2].shaderLocation = 2;
|
descriptor.cBuffers[1].attributes = &descriptor.cAttributes[2];
|
||||||
descriptor.cVertexState.cAttributes[2].format = wgpu::VertexFormat::Float2;
|
descriptor.cAttributes[2].shaderLocation = 2;
|
||||||
descriptor.depthStencilState = &descriptor.cDepthStencilState;
|
descriptor.cAttributes[2].format = wgpu::VertexFormat::Float32x2;
|
||||||
descriptor.cDepthStencilState.format = wgpu::TextureFormat::Depth24PlusStencil8;
|
|
||||||
descriptor.cColorStates[0].format = GetPreferredSwapChainTextureFormat();
|
|
||||||
|
|
||||||
renderPipeline = device.CreateRenderPipeline(&descriptor);
|
descriptor.cFragment.module = fsModule;
|
||||||
|
descriptor.EnableDepthStencil(wgpu::TextureFormat::Depth24PlusStencil8);
|
||||||
|
descriptor.cTargets[0].format = GetPreferredSwapChainTextureFormat();
|
||||||
|
|
||||||
|
renderPipeline = device.CreateRenderPipeline2(&descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initSim() {
|
void initSim() {
|
||||||
|
@ -247,9 +247,9 @@ void initSim() {
|
||||||
|
|
||||||
auto bgl = utils::MakeBindGroupLayout(
|
auto bgl = utils::MakeBindGroupLayout(
|
||||||
device, {
|
device, {
|
||||||
{0, wgpu::ShaderStage::Compute, wgpu::BindingType::UniformBuffer},
|
{0, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Uniform},
|
||||||
{1, wgpu::ShaderStage::Compute, wgpu::BindingType::StorageBuffer},
|
{1, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Storage},
|
||||||
{2, wgpu::ShaderStage::Compute, wgpu::BindingType::StorageBuffer},
|
{2, wgpu::ShaderStage::Compute, wgpu::BufferBindingType::Storage},
|
||||||
});
|
});
|
||||||
|
|
||||||
wgpu::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl);
|
wgpu::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl);
|
||||||
|
|
|
@ -116,27 +116,26 @@ void init() {
|
||||||
|
|
||||||
auto bgl = utils::MakeBindGroupLayout(
|
auto bgl = utils::MakeBindGroupLayout(
|
||||||
device, {
|
device, {
|
||||||
{0, wgpu::ShaderStage::Fragment, wgpu::BindingType::Sampler},
|
{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Filtering},
|
||||||
{1, wgpu::ShaderStage::Fragment, wgpu::BindingType::SampledTexture},
|
{1, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float},
|
||||||
});
|
});
|
||||||
|
|
||||||
wgpu::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl);
|
wgpu::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl);
|
||||||
|
|
||||||
depthStencilView = CreateDefaultDepthStencilView(device);
|
depthStencilView = CreateDefaultDepthStencilView(device);
|
||||||
|
|
||||||
utils::ComboRenderPipelineDescriptor descriptor(device);
|
utils::ComboRenderPipelineDescriptor2 descriptor;
|
||||||
descriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl);
|
descriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl);
|
||||||
descriptor.vertexStage.module = vsModule;
|
descriptor.vertex.module = vsModule;
|
||||||
descriptor.cFragmentStage.module = fsModule;
|
descriptor.vertex.bufferCount = 1;
|
||||||
descriptor.cVertexState.vertexBufferCount = 1;
|
descriptor.cBuffers[0].arrayStride = 4 * sizeof(float);
|
||||||
descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float);
|
descriptor.cBuffers[0].attributeCount = 1;
|
||||||
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1;
|
descriptor.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
|
||||||
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4;
|
descriptor.cFragment.module = fsModule;
|
||||||
descriptor.depthStencilState = &descriptor.cDepthStencilState;
|
descriptor.cTargets[0].format = GetPreferredSwapChainTextureFormat();
|
||||||
descriptor.cDepthStencilState.format = wgpu::TextureFormat::Depth24PlusStencil8;
|
descriptor.EnableDepthStencil(wgpu::TextureFormat::Depth24PlusStencil8);
|
||||||
descriptor.cColorStates[0].format = GetPreferredSwapChainTextureFormat();
|
|
||||||
|
|
||||||
pipeline = device.CreateRenderPipeline(&descriptor);
|
pipeline = device.CreateRenderPipeline2(&descriptor);
|
||||||
|
|
||||||
wgpu::TextureView view = texture.CreateView();
|
wgpu::TextureView view = texture.CreateView();
|
||||||
|
|
||||||
|
|
|
@ -143,20 +143,23 @@ void init() {
|
||||||
return;
|
return;
|
||||||
})");
|
})");
|
||||||
|
|
||||||
utils::ComboVertexStateDescriptor vertexState;
|
wgpu::VertexAttribute attributes[2];
|
||||||
vertexState.cVertexBuffers[0].attributeCount = 2;
|
attributes[0].shaderLocation = 0;
|
||||||
vertexState.cAttributes[0].format = wgpu::VertexFormat::Float3;
|
attributes[0].offset = 0;
|
||||||
vertexState.cAttributes[1].shaderLocation = 1;
|
attributes[0].format = wgpu::VertexFormat::Float32x3;
|
||||||
vertexState.cAttributes[1].offset = 3 * sizeof(float);
|
attributes[1].shaderLocation = 1;
|
||||||
vertexState.cAttributes[1].format = wgpu::VertexFormat::Float3;
|
attributes[1].offset = 3 * sizeof(float);
|
||||||
|
attributes[1].format = wgpu::VertexFormat::Float32x3;
|
||||||
|
|
||||||
vertexState.vertexBufferCount = 1;
|
wgpu::VertexBufferLayout vertexBufferLayout;
|
||||||
vertexState.cVertexBuffers[0].arrayStride = 6 * sizeof(float);
|
vertexBufferLayout.attributeCount = 2;
|
||||||
|
vertexBufferLayout.attributes = attributes;
|
||||||
|
vertexBufferLayout.arrayStride = 6 * sizeof(float);
|
||||||
|
|
||||||
auto bgl = utils::MakeBindGroupLayout(
|
auto bgl = utils::MakeBindGroupLayout(
|
||||||
device, {
|
device, {
|
||||||
{0, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer},
|
{0, wgpu::ShaderStage::Vertex, wgpu::BufferBindingType::Uniform},
|
||||||
{1, wgpu::ShaderStage::Vertex, wgpu::BindingType::UniformBuffer},
|
{1, wgpu::ShaderStage::Vertex, wgpu::BufferBindingType::Uniform},
|
||||||
});
|
});
|
||||||
|
|
||||||
wgpu::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl);
|
wgpu::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, &bgl);
|
||||||
|
@ -184,49 +187,64 @@ void init() {
|
||||||
|
|
||||||
depthStencilView = CreateDefaultDepthStencilView(device);
|
depthStencilView = CreateDefaultDepthStencilView(device);
|
||||||
|
|
||||||
utils::ComboRenderPipelineDescriptor descriptor(device);
|
{
|
||||||
descriptor.layout = pl;
|
utils::ComboRenderPipelineDescriptor2 descriptor;
|
||||||
descriptor.vertexStage.module = vsModule;
|
descriptor.vertex.module = vsModule;
|
||||||
descriptor.cFragmentStage.module = fsModule;
|
descriptor.vertex.bufferCount = 1;
|
||||||
descriptor.vertexState = &vertexState;
|
descriptor.vertex.buffers = &vertexBufferLayout;
|
||||||
descriptor.depthStencilState = &descriptor.cDepthStencilState;
|
|
||||||
descriptor.cDepthStencilState.format = wgpu::TextureFormat::Depth24PlusStencil8;
|
|
||||||
descriptor.cColorStates[0].format = GetPreferredSwapChainTextureFormat();
|
|
||||||
descriptor.cDepthStencilState.depthWriteEnabled = true;
|
|
||||||
descriptor.cDepthStencilState.depthCompare = wgpu::CompareFunction::Less;
|
|
||||||
|
|
||||||
pipeline = device.CreateRenderPipeline(&descriptor);
|
descriptor.layout = pl;
|
||||||
|
descriptor.cFragment.module = fsModule;
|
||||||
|
descriptor.cTargets[0].format = GetPreferredSwapChainTextureFormat();
|
||||||
|
|
||||||
utils::ComboRenderPipelineDescriptor pDescriptor(device);
|
wgpu::DepthStencilState* depthStencil =
|
||||||
pDescriptor.layout = pl;
|
descriptor.EnableDepthStencil(wgpu::TextureFormat::Depth24PlusStencil8);
|
||||||
pDescriptor.vertexStage.module = vsModule;
|
depthStencil->depthWriteEnabled = true;
|
||||||
pDescriptor.cFragmentStage.module = fsModule;
|
depthStencil->depthCompare = wgpu::CompareFunction::Less;
|
||||||
pDescriptor.vertexState = &vertexState;
|
|
||||||
pDescriptor.depthStencilState = &pDescriptor.cDepthStencilState;
|
|
||||||
pDescriptor.cDepthStencilState.format = wgpu::TextureFormat::Depth24PlusStencil8;
|
|
||||||
pDescriptor.cColorStates[0].format = GetPreferredSwapChainTextureFormat();
|
|
||||||
pDescriptor.cDepthStencilState.stencilFront.passOp = wgpu::StencilOperation::Replace;
|
|
||||||
pDescriptor.cDepthStencilState.stencilBack.passOp = wgpu::StencilOperation::Replace;
|
|
||||||
pDescriptor.cDepthStencilState.depthCompare = wgpu::CompareFunction::Less;
|
|
||||||
|
|
||||||
planePipeline = device.CreateRenderPipeline(&pDescriptor);
|
pipeline = device.CreateRenderPipeline2(&descriptor);
|
||||||
|
}
|
||||||
|
|
||||||
utils::ComboRenderPipelineDescriptor rfDescriptor(device);
|
{
|
||||||
rfDescriptor.layout = pl;
|
utils::ComboRenderPipelineDescriptor2 descriptor;
|
||||||
rfDescriptor.vertexStage.module = vsModule;
|
descriptor.vertex.module = vsModule;
|
||||||
rfDescriptor.cFragmentStage.module = fsReflectionModule;
|
descriptor.vertex.bufferCount = 1;
|
||||||
rfDescriptor.vertexState = &vertexState;
|
descriptor.vertex.buffers = &vertexBufferLayout;
|
||||||
rfDescriptor.depthStencilState = &rfDescriptor.cDepthStencilState;
|
|
||||||
rfDescriptor.cDepthStencilState.format = wgpu::TextureFormat::Depth24PlusStencil8;
|
|
||||||
rfDescriptor.cColorStates[0].format = GetPreferredSwapChainTextureFormat();
|
|
||||||
rfDescriptor.cDepthStencilState.stencilFront.compare = wgpu::CompareFunction::Equal;
|
|
||||||
rfDescriptor.cDepthStencilState.stencilBack.compare = wgpu::CompareFunction::Equal;
|
|
||||||
rfDescriptor.cDepthStencilState.stencilFront.passOp = wgpu::StencilOperation::Replace;
|
|
||||||
rfDescriptor.cDepthStencilState.stencilBack.passOp = wgpu::StencilOperation::Replace;
|
|
||||||
rfDescriptor.cDepthStencilState.depthWriteEnabled = true;
|
|
||||||
rfDescriptor.cDepthStencilState.depthCompare = wgpu::CompareFunction::Less;
|
|
||||||
|
|
||||||
reflectionPipeline = device.CreateRenderPipeline(&rfDescriptor);
|
descriptor.layout = pl;
|
||||||
|
descriptor.cFragment.module = fsModule;
|
||||||
|
descriptor.cTargets[0].format = GetPreferredSwapChainTextureFormat();
|
||||||
|
|
||||||
|
wgpu::DepthStencilState* depthStencil =
|
||||||
|
descriptor.EnableDepthStencil(wgpu::TextureFormat::Depth24PlusStencil8);
|
||||||
|
depthStencil->stencilFront.passOp = wgpu::StencilOperation::Replace;
|
||||||
|
depthStencil->stencilBack.passOp = wgpu::StencilOperation::Replace;
|
||||||
|
depthStencil->depthCompare = wgpu::CompareFunction::Less;
|
||||||
|
|
||||||
|
planePipeline = device.CreateRenderPipeline2(&descriptor);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
utils::ComboRenderPipelineDescriptor2 descriptor;
|
||||||
|
descriptor.vertex.module = vsModule;
|
||||||
|
descriptor.vertex.bufferCount = 1;
|
||||||
|
descriptor.vertex.buffers = &vertexBufferLayout;
|
||||||
|
|
||||||
|
descriptor.layout = pl;
|
||||||
|
descriptor.cFragment.module = fsReflectionModule;
|
||||||
|
descriptor.cTargets[0].format = GetPreferredSwapChainTextureFormat();
|
||||||
|
|
||||||
|
wgpu::DepthStencilState* depthStencil =
|
||||||
|
descriptor.EnableDepthStencil(wgpu::TextureFormat::Depth24PlusStencil8);
|
||||||
|
depthStencil->stencilFront.compare = wgpu::CompareFunction::Equal;
|
||||||
|
depthStencil->stencilBack.compare = wgpu::CompareFunction::Equal;
|
||||||
|
depthStencil->stencilFront.passOp = wgpu::StencilOperation::Replace;
|
||||||
|
depthStencil->stencilBack.passOp = wgpu::StencilOperation::Replace;
|
||||||
|
depthStencil->depthWriteEnabled = true;
|
||||||
|
depthStencil->depthCompare = wgpu::CompareFunction::Less;
|
||||||
|
|
||||||
|
reflectionPipeline = device.CreateRenderPipeline2(&descriptor);
|
||||||
|
}
|
||||||
|
|
||||||
cameraData.proj = glm::perspective(glm::radians(45.0f), 1.f, 1.0f, 100.0f);
|
cameraData.proj = glm::perspective(glm::radians(45.0f), 1.f, 1.0f, 100.0f);
|
||||||
}
|
}
|
||||||
|
|
|
@ -311,8 +311,8 @@ int main(int argc, const char* argv[]) {
|
||||||
queue = device.GetQueue();
|
queue = device.GetQueue();
|
||||||
|
|
||||||
// The hacky pipeline to render a triangle.
|
// The hacky pipeline to render a triangle.
|
||||||
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>;
|
||||||
const pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
|
const pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
|
||||||
|
@ -324,16 +324,15 @@ int main(int argc, const char* argv[]) {
|
||||||
Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
|
Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
|
||||||
return;
|
return;
|
||||||
})");
|
})");
|
||||||
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>(1.0, 0.0, 0.0, 1.0);
|
fragColor = vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||||
return;
|
return;
|
||||||
})");
|
})");
|
||||||
pipelineDesc.colorStateCount = 1;
|
|
||||||
// BGRA shouldn't be hardcoded. Consider having a map[format -> pipeline].
|
// BGRA shouldn't be hardcoded. Consider having a map[format -> pipeline].
|
||||||
pipelineDesc.cColorStates[0].format = wgpu::TextureFormat::BGRA8Unorm;
|
pipelineDesc.cTargets[0].format = wgpu::TextureFormat::BGRA8Unorm;
|
||||||
trianglePipeline = device.CreateRenderPipeline(&pipelineDesc);
|
trianglePipeline = device.CreateRenderPipeline2(&pipelineDesc);
|
||||||
|
|
||||||
// Craete the first window, since the example exits when there are no windows.
|
// Craete the first window, since the example exits when there are no windows.
|
||||||
AddWindow();
|
AddWindow();
|
||||||
|
|
Loading…
Reference in New Issue