From 66ff4472169841111db9b63375a884d901329788 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Fri, 14 Jul 2017 11:32:57 -0400 Subject: [PATCH] Split Pipeline in Render and Compute, examples part --- examples/Animometer.cpp | 6 +++--- examples/CHelloTriangle.cpp | 16 ++++++++-------- examples/ComputeBoids.cpp | 12 ++++++------ examples/HelloCompute.cpp | 12 ++++++------ examples/HelloDepthStencil.cpp | 18 +++++++++--------- examples/HelloIndices.cpp | 6 +++--- examples/HelloInstancing.cpp | 6 +++--- examples/HelloTriangle.cpp | 6 +++--- examples/HelloUBO.cpp | 6 +++--- examples/HelloVertices.cpp | 6 +++--- examples/RenderToTexture.cpp | 12 ++++++------ examples/glTFViewer/glTFViewer.cpp | 6 +++--- 12 files changed, 56 insertions(+), 56 deletions(-) diff --git a/examples/Animometer.cpp b/examples/Animometer.cpp index 240b966464..d36f52c388 100644 --- a/examples/Animometer.cpp +++ b/examples/Animometer.cpp @@ -22,7 +22,7 @@ nxt::Device device; nxt::Queue queue; -nxt::Pipeline pipeline; +nxt::RenderPipeline pipeline; nxt::RenderPass renderpass; nxt::Framebuffer framebuffer; @@ -105,7 +105,7 @@ void init() { ); utils::CreateDefaultRenderPass(device, &renderpass, &framebuffer); - pipeline = device.CreatePipelineBuilder() + pipeline = device.CreateRenderPipelineBuilder() .SetSubpass(renderpass, 0) .SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(nxt::ShaderStage::Fragment, fsModule, "main") @@ -134,7 +134,7 @@ void frame() { nxt::CommandBufferBuilder builder = device.CreateCommandBufferBuilder() .BeginRenderPass(renderpass, framebuffer) .BeginRenderSubpass() - .SetPipeline(pipeline) + .SetRenderPipeline(pipeline) .Clone(); for (int k = 0; k < 200; k++) { diff --git a/examples/CHelloTriangle.cpp b/examples/CHelloTriangle.cpp index 2d88274696..b272adde93 100644 --- a/examples/CHelloTriangle.cpp +++ b/examples/CHelloTriangle.cpp @@ -18,7 +18,7 @@ nxtDevice device; nxtQueue queue; -nxtPipeline pipeline; +nxtRenderPipeline pipeline; nxtRenderPass renderpass; nxtFramebuffer framebuffer; @@ -64,12 +64,12 @@ void init() { nxtFramebufferBuilderRelease(builder); } { - nxtPipelineBuilder builder = nxtDeviceCreatePipelineBuilder(device); - nxtPipelineBuilderSetSubpass(builder, renderpass, 0); - nxtPipelineBuilderSetStage(builder, NXT_SHADER_STAGE_VERTEX, vsModule, "main"); - nxtPipelineBuilderSetStage(builder, NXT_SHADER_STAGE_FRAGMENT, fsModule, "main"); - pipeline = nxtPipelineBuilderGetResult(builder); - nxtPipelineBuilderRelease(builder); + nxtRenderPipelineBuilder builder = nxtDeviceCreateRenderPipelineBuilder(device); + nxtRenderPipelineBuilderSetSubpass(builder, renderpass, 0); + nxtRenderPipelineBuilderSetStage(builder, NXT_SHADER_STAGE_VERTEX, vsModule, "main"); + nxtRenderPipelineBuilderSetStage(builder, NXT_SHADER_STAGE_FRAGMENT, fsModule, "main"); + pipeline = nxtRenderPipelineBuilderGetResult(builder); + nxtRenderPipelineBuilderRelease(builder); } nxtShaderModuleRelease(vsModule); @@ -82,7 +82,7 @@ void frame() { nxtCommandBufferBuilder builder = nxtDeviceCreateCommandBufferBuilder(device); nxtCommandBufferBuilderBeginRenderPass(builder, renderpass, framebuffer); nxtCommandBufferBuilderBeginRenderSubpass(builder); - nxtCommandBufferBuilderSetPipeline(builder, pipeline); + nxtCommandBufferBuilderSetRenderPipeline(builder, pipeline); nxtCommandBufferBuilderDrawArrays(builder, 3, 1, 0, 0); nxtCommandBufferBuilderEndRenderSubpass(builder); nxtCommandBufferBuilderEndRenderPass(builder); diff --git a/examples/ComputeBoids.cpp b/examples/ComputeBoids.cpp index dd0d012d1e..213eeed419 100644 --- a/examples/ComputeBoids.cpp +++ b/examples/ComputeBoids.cpp @@ -28,12 +28,12 @@ nxt::Queue queue; nxt::Buffer modelBuffer; std::array particleBuffers; -nxt::Pipeline renderPipeline; +nxt::RenderPipeline renderPipeline; nxt::RenderPass renderpass; nxt::Framebuffer framebuffer; nxt::Buffer updateParams; -nxt::Pipeline updatePipeline; +nxt::ComputePipeline updatePipeline; std::array updateBGs; std::array commandBuffers; @@ -124,7 +124,7 @@ void initRender() { .GetResult(); utils::CreateDefaultRenderPass(device, &renderpass, &framebuffer); - renderPipeline = device.CreatePipelineBuilder() + renderPipeline = device.CreateRenderPipelineBuilder() .SetSubpass(renderpass, 0) .SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(nxt::ShaderStage::Fragment, fsModule, "main") @@ -231,7 +231,7 @@ void initSim() { .SetBindGroupLayout(0, bgl) .GetResult(); - updatePipeline = device.CreatePipelineBuilder() + updatePipeline = device.CreateComputePipelineBuilder() .SetLayout(pl) .SetStage(nxt::ShaderStage::Compute, module, "main") .GetResult(); @@ -265,7 +265,7 @@ void initCommandBuffers() { auto& bufferDst = particleBuffers[(i + 1) % 2]; commandBuffers[i] = device.CreateCommandBufferBuilder() .BeginComputePass() - .SetPipeline(updatePipeline) + .SetComputePipeline(updatePipeline) .TransitionBufferUsage(bufferSrc, nxt::BufferUsageBit::Storage) .TransitionBufferUsage(bufferDst, nxt::BufferUsageBit::Storage) .SetBindGroup(0, updateBGs[i]) @@ -274,7 +274,7 @@ void initCommandBuffers() { .BeginRenderPass(renderpass, framebuffer) .BeginRenderSubpass() - .SetPipeline(renderPipeline) + .SetRenderPipeline(renderPipeline) .TransitionBufferUsage(bufferDst, nxt::BufferUsageBit::Vertex) .SetVertexBuffers(0, 1, &bufferDst, zeroOffsets) .SetVertexBuffers(1, 1, &modelBuffer, zeroOffsets) diff --git a/examples/HelloCompute.cpp b/examples/HelloCompute.cpp index 9e611ddcd4..e3f49b966c 100644 --- a/examples/HelloCompute.cpp +++ b/examples/HelloCompute.cpp @@ -21,11 +21,11 @@ nxt::Device device; nxt::Queue queue; nxt::Buffer buffer; -nxt::Pipeline renderPipeline; +nxt::RenderPipeline renderPipeline; nxt::BindGroup renderBindGroup; nxt::RenderPass renderpass; nxt::Framebuffer framebuffer; -nxt::Pipeline computePipeline; +nxt::ComputePipeline computePipeline; nxt::BindGroup computeBindGroup; void init() { @@ -67,7 +67,7 @@ void init() { .SetBindGroupLayout(0, bgl) .GetResult(); - computePipeline = device.CreatePipelineBuilder() + computePipeline = device.CreateComputePipelineBuilder() .SetLayout(pl) .SetStage(nxt::ShaderStage::Compute, module, "main") .GetResult(); @@ -109,7 +109,7 @@ void init() { .GetResult(); utils::CreateDefaultRenderPass(device, &renderpass, &framebuffer); - renderPipeline = device.CreatePipelineBuilder() + renderPipeline = device.CreateRenderPipelineBuilder() .SetSubpass(renderpass, 0) .SetLayout(pl) .SetStage(nxt::ShaderStage::Vertex, vsModule, "main") @@ -127,7 +127,7 @@ void init() { void frame() { nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() .BeginComputePass() - .SetPipeline(computePipeline) + .SetComputePipeline(computePipeline) .TransitionBufferUsage(buffer, nxt::BufferUsageBit::Storage) .SetBindGroup(0, computeBindGroup) .Dispatch(1, 1, 1) @@ -135,7 +135,7 @@ void frame() { .BeginRenderPass(renderpass, framebuffer) .BeginRenderSubpass() - .SetPipeline(renderPipeline) + .SetRenderPipeline(renderPipeline) .TransitionBufferUsage(buffer, nxt::BufferUsageBit::Uniform) .SetBindGroup(0, renderBindGroup) .DrawArrays(3, 1, 0, 0) diff --git a/examples/HelloDepthStencil.cpp b/examples/HelloDepthStencil.cpp index 176762ba79..7ab56c9807 100644 --- a/examples/HelloDepthStencil.cpp +++ b/examples/HelloDepthStencil.cpp @@ -34,9 +34,9 @@ nxt::BindGroup bindGroup[2]; nxt::BindGroup cubeTransformBindGroup[2]; nxt::Queue queue; -nxt::Pipeline pipeline; -nxt::Pipeline planePipeline; -nxt::Pipeline reflectionPipeline; +nxt::RenderPipeline pipeline; +nxt::RenderPipeline planePipeline; +nxt::RenderPipeline reflectionPipeline; nxt::RenderPass renderpass; nxt::Framebuffer framebuffer; @@ -212,7 +212,7 @@ void init() { .SetDepthWriteEnabled(true) .GetResult(); - pipeline = device.CreatePipelineBuilder() + pipeline = device.CreateRenderPipelineBuilder() .SetSubpass(renderpass, 0) .SetLayout(pl) .SetStage(nxt::ShaderStage::Vertex, vsModule, "main") @@ -227,7 +227,7 @@ void init() { .SetStencilFunction(nxt::Face::Both, nxt::CompareFunction::Always, nxt::StencilOperation::Keep, nxt::StencilOperation::Keep, nxt::StencilOperation::Replace) .GetResult(); - planePipeline = device.CreatePipelineBuilder() + planePipeline = device.CreateRenderPipelineBuilder() .SetSubpass(renderpass, 0) .SetLayout(pl) .SetStage(nxt::ShaderStage::Vertex, vsModule, "main") @@ -242,7 +242,7 @@ void init() { .SetStencilFunction(nxt::Face::Both, nxt::CompareFunction::Equal, nxt::StencilOperation::Keep, nxt::StencilOperation::Keep, nxt::StencilOperation::Replace) .GetResult(); - reflectionPipeline = device.CreatePipelineBuilder() + reflectionPipeline = device.CreateRenderPipelineBuilder() .SetSubpass(renderpass, 0) .SetLayout(pl) .SetStage(nxt::ShaderStage::Vertex, vsModule, "main") @@ -273,7 +273,7 @@ void frame() { nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() .BeginRenderPass(renderpass, framebuffer) .BeginRenderSubpass() - .SetPipeline(pipeline) + .SetRenderPipeline(pipeline) .TransitionBufferUsage(cameraBuffer, nxt::BufferUsageBit::Uniform) .SetBindGroup(0, bindGroup[0]) .SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets) @@ -281,11 +281,11 @@ void frame() { .DrawElements(36, 1, 0, 0) .SetStencilReference(0x1) - .SetPipeline(planePipeline) + .SetRenderPipeline(planePipeline) .SetVertexBuffers(0, 1, &planeBuffer, vertexBufferOffsets) .DrawElements(6, 1, 0, 0) - .SetPipeline(reflectionPipeline) + .SetRenderPipeline(reflectionPipeline) .SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets) .SetBindGroup(0, bindGroup[1]) .DrawElements(36, 1, 0, 0) diff --git a/examples/HelloIndices.cpp b/examples/HelloIndices.cpp index ac0223b699..9a0067109c 100644 --- a/examples/HelloIndices.cpp +++ b/examples/HelloIndices.cpp @@ -24,7 +24,7 @@ nxt::Buffer indexBuffer; nxt::Buffer vertexBuffer; nxt::Queue queue; -nxt::Pipeline pipeline; +nxt::RenderPipeline pipeline; nxt::RenderPass renderpass; nxt::Framebuffer framebuffer; @@ -71,7 +71,7 @@ void init() { .GetResult(); utils::CreateDefaultRenderPass(device, &renderpass, &framebuffer); - pipeline = device.CreatePipelineBuilder() + pipeline = device.CreateRenderPipelineBuilder() .SetSubpass(renderpass, 0) .SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(nxt::ShaderStage::Fragment, fsModule, "main") @@ -84,7 +84,7 @@ void frame() { nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() .BeginRenderPass(renderpass, framebuffer) .BeginRenderSubpass() - .SetPipeline(pipeline) + .SetRenderPipeline(pipeline) .SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets) .SetIndexBuffer(indexBuffer, 0, nxt::IndexFormat::Uint32) .DrawElements(3, 1, 0, 0) diff --git a/examples/HelloInstancing.cpp b/examples/HelloInstancing.cpp index 136ac218ea..e74133c457 100644 --- a/examples/HelloInstancing.cpp +++ b/examples/HelloInstancing.cpp @@ -24,7 +24,7 @@ nxt::Buffer vertexBuffer; nxt::Buffer instanceBuffer; nxt::Queue queue; -nxt::Pipeline pipeline; +nxt::RenderPipeline pipeline; nxt::RenderPass renderpass; nxt::Framebuffer framebuffer; @@ -77,7 +77,7 @@ void init() { .GetResult(); utils::CreateDefaultRenderPass(device, &renderpass, &framebuffer); - pipeline = device.CreatePipelineBuilder() + pipeline = device.CreateRenderPipelineBuilder() .SetSubpass(renderpass, 0) .SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(nxt::ShaderStage::Fragment, fsModule, "main") @@ -90,7 +90,7 @@ void frame() { nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() .BeginRenderPass(renderpass, framebuffer) .BeginRenderSubpass() - .SetPipeline(pipeline) + .SetRenderPipeline(pipeline) .SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets) .SetVertexBuffers(1, 1, &instanceBuffer, vertexBufferOffsets) .DrawArrays(3, 4, 0, 0) diff --git a/examples/HelloTriangle.cpp b/examples/HelloTriangle.cpp index ffe328b0d0..15c07fde01 100644 --- a/examples/HelloTriangle.cpp +++ b/examples/HelloTriangle.cpp @@ -27,7 +27,7 @@ nxt::Texture texture; nxt::Sampler sampler; nxt::Queue queue; -nxt::Pipeline pipeline; +nxt::RenderPipeline pipeline; nxt::RenderPass renderpass; nxt::Framebuffer framebuffer; nxt::BindGroup bindGroup; @@ -118,7 +118,7 @@ void init() { .GetResult(); utils::CreateDefaultRenderPass(device, &renderpass, &framebuffer); - pipeline = device.CreatePipelineBuilder() + pipeline = device.CreateRenderPipelineBuilder() .SetSubpass(renderpass, 0) .SetLayout(pl) .SetStage(nxt::ShaderStage::Vertex, vsModule, "main") @@ -145,7 +145,7 @@ void frame() { nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() .BeginRenderPass(renderpass, framebuffer) .BeginRenderSubpass() - .SetPipeline(pipeline) + .SetRenderPipeline(pipeline) .SetBindGroup(0, bindGroup) .SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets) .SetIndexBuffer(indexBuffer, 0, nxt::IndexFormat::Uint32) diff --git a/examples/HelloUBO.cpp b/examples/HelloUBO.cpp index 251ca830a9..ccb6ed974b 100644 --- a/examples/HelloUBO.cpp +++ b/examples/HelloUBO.cpp @@ -18,7 +18,7 @@ nxt::Device device; nxt::Queue queue; -nxt::Pipeline pipeline; +nxt::RenderPipeline pipeline; nxt::RenderPass renderpass; nxt::Framebuffer framebuffer; nxt::Buffer buffer; @@ -60,7 +60,7 @@ void init() { .GetResult(); utils::CreateDefaultRenderPass(device, &renderpass, &framebuffer); - pipeline = device.CreatePipelineBuilder() + pipeline = device.CreateRenderPipelineBuilder() .SetSubpass(renderpass, 0) .SetLayout(pl) .SetStage(nxt::ShaderStage::Vertex, vsModule, "main") @@ -95,7 +95,7 @@ void frame() { nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() .BeginRenderPass(renderpass, framebuffer) .BeginRenderSubpass() - .SetPipeline(pipeline) + .SetRenderPipeline(pipeline) .TransitionBufferUsage(buffer, nxt::BufferUsageBit::Uniform) .SetBindGroup(0, bindGroup) .DrawArrays(3, 1, 0, 0) diff --git a/examples/HelloVertices.cpp b/examples/HelloVertices.cpp index ad5b7b8083..a20ce4d621 100644 --- a/examples/HelloVertices.cpp +++ b/examples/HelloVertices.cpp @@ -23,7 +23,7 @@ nxt::Device device; nxt::Buffer vertexBuffer; nxt::Queue queue; -nxt::Pipeline pipeline; +nxt::RenderPipeline pipeline; nxt::RenderPass renderpass; nxt::Framebuffer framebuffer; @@ -65,7 +65,7 @@ void init() { .GetResult(); utils::CreateDefaultRenderPass(device, &renderpass, &framebuffer); - pipeline = device.CreatePipelineBuilder() + pipeline = device.CreateRenderPipelineBuilder() .SetSubpass(renderpass, 0) .SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(nxt::ShaderStage::Fragment, fsModule, "main") @@ -78,7 +78,7 @@ void frame() { nxt::CommandBuffer commands = device.CreateCommandBufferBuilder() .BeginRenderPass(renderpass, framebuffer) .BeginRenderSubpass() - .SetPipeline(pipeline) + .SetRenderPipeline(pipeline) .SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets) .DrawArrays(3, 1, 0, 0) .EndRenderSubpass() diff --git a/examples/RenderToTexture.cpp b/examples/RenderToTexture.cpp index aea96e1948..023ae146eb 100644 --- a/examples/RenderToTexture.cpp +++ b/examples/RenderToTexture.cpp @@ -28,8 +28,8 @@ nxt::TextureView renderTargetView; nxt::Sampler samplerPost; nxt::Queue queue; -nxt::Pipeline pipeline; -nxt::Pipeline pipelinePost; +nxt::RenderPipeline pipeline; +nxt::RenderPipeline pipelinePost; nxt::BindGroup bindGroup; nxt::RenderPass renderpass; nxt::Framebuffer framebuffer; @@ -112,7 +112,7 @@ void initPipeline() { .SetInput(0, 4 * sizeof(float), nxt::InputStepMode::Vertex) .GetResult(); - pipeline = device.CreatePipelineBuilder() + pipeline = device.CreateRenderPipelineBuilder() .SetSubpass(renderpass, 0) .SetStage(nxt::ShaderStage::Vertex, vsModule, "main") .SetStage(nxt::ShaderStage::Fragment, fsModule, "main") @@ -153,7 +153,7 @@ void initPipelinePost() { .SetBindGroupLayout(0, bgl) .GetResult(); - pipelinePost = device.CreatePipelineBuilder() + pipelinePost = device.CreateRenderPipelineBuilder() .SetSubpass(renderpass, 1) .SetLayout(pl) .SetStage(nxt::ShaderStage::Vertex, vsModule, "main") @@ -187,13 +187,13 @@ void frame() { .BeginRenderPass(renderpass, framebuffer) .BeginRenderSubpass() // renderTarget implicitly locked to to Attachment usage (if not already frozen) - .SetPipeline(pipeline) + .SetRenderPipeline(pipeline) .SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets) .DrawArrays(3, 1, 0, 0) .EndRenderSubpass() // renderTarget usage unlocked, but left in Attachment usage .BeginRenderSubpass() - .SetPipeline(pipelinePost) + .SetRenderPipeline(pipelinePost) .SetVertexBuffers(0, 1, &vertexBufferQuad, vertexBufferOffsets) .TransitionTextureUsage(renderTarget, nxt::TextureUsageBit::Sampled) .SetBindGroup(0, bindGroup) diff --git a/examples/glTFViewer/glTFViewer.cpp b/examples/glTFViewer/glTFViewer.cpp index 645a90b56b..2baf61ab75 100644 --- a/examples/glTFViewer/glTFViewer.cpp +++ b/examples/glTFViewer/glTFViewer.cpp @@ -62,7 +62,7 @@ namespace gl { struct MaterialInfo { nxt::Buffer uniformBuffer; - nxt::Pipeline pipeline; + nxt::RenderPipeline pipeline; nxt::BindGroup bindGroup0; std::map slotSemantics; }; @@ -257,7 +257,7 @@ namespace { auto pipelineLayout = device.CreatePipelineLayoutBuilder() .SetBindGroupLayout(0, bindGroupLayout) .GetResult(); - auto pipeline = device.CreatePipelineBuilder() + auto pipeline = device.CreateRenderPipelineBuilder() .SetSubpass(renderpass, 0) .SetLayout(pipelineLayout) .SetStage(nxt::ShaderStage::Vertex, oVSModule, "main") @@ -486,7 +486,7 @@ namespace { reinterpret_cast(&transforms)); cmd.BeginRenderPass(renderpass, framebuffer); cmd.BeginRenderSubpass(); - cmd.SetPipeline(material.pipeline); + cmd.SetRenderPipeline(material.pipeline); cmd.TransitionBufferUsage(material.uniformBuffer, nxt::BufferUsageBit::Uniform); cmd.SetBindGroup(0, material.bindGroup0);