Split Pipeline in Render and Compute, examples part
This commit is contained in:
parent
b085eecb31
commit
66ff447216
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
nxt::Device device;
|
nxt::Device device;
|
||||||
nxt::Queue queue;
|
nxt::Queue queue;
|
||||||
nxt::Pipeline pipeline;
|
nxt::RenderPipeline pipeline;
|
||||||
nxt::RenderPass renderpass;
|
nxt::RenderPass renderpass;
|
||||||
nxt::Framebuffer framebuffer;
|
nxt::Framebuffer framebuffer;
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ void init() {
|
||||||
);
|
);
|
||||||
|
|
||||||
utils::CreateDefaultRenderPass(device, &renderpass, &framebuffer);
|
utils::CreateDefaultRenderPass(device, &renderpass, &framebuffer);
|
||||||
pipeline = device.CreatePipelineBuilder()
|
pipeline = device.CreateRenderPipelineBuilder()
|
||||||
.SetSubpass(renderpass, 0)
|
.SetSubpass(renderpass, 0)
|
||||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||||
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
||||||
|
@ -134,7 +134,7 @@ void frame() {
|
||||||
nxt::CommandBufferBuilder builder = device.CreateCommandBufferBuilder()
|
nxt::CommandBufferBuilder builder = device.CreateCommandBufferBuilder()
|
||||||
.BeginRenderPass(renderpass, framebuffer)
|
.BeginRenderPass(renderpass, framebuffer)
|
||||||
.BeginRenderSubpass()
|
.BeginRenderSubpass()
|
||||||
.SetPipeline(pipeline)
|
.SetRenderPipeline(pipeline)
|
||||||
.Clone();
|
.Clone();
|
||||||
|
|
||||||
for (int k = 0; k < 200; k++) {
|
for (int k = 0; k < 200; k++) {
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
nxtDevice device;
|
nxtDevice device;
|
||||||
nxtQueue queue;
|
nxtQueue queue;
|
||||||
nxtPipeline pipeline;
|
nxtRenderPipeline pipeline;
|
||||||
nxtRenderPass renderpass;
|
nxtRenderPass renderpass;
|
||||||
nxtFramebuffer framebuffer;
|
nxtFramebuffer framebuffer;
|
||||||
|
|
||||||
|
@ -64,12 +64,12 @@ void init() {
|
||||||
nxtFramebufferBuilderRelease(builder);
|
nxtFramebufferBuilderRelease(builder);
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
nxtPipelineBuilder builder = nxtDeviceCreatePipelineBuilder(device);
|
nxtRenderPipelineBuilder builder = nxtDeviceCreateRenderPipelineBuilder(device);
|
||||||
nxtPipelineBuilderSetSubpass(builder, renderpass, 0);
|
nxtRenderPipelineBuilderSetSubpass(builder, renderpass, 0);
|
||||||
nxtPipelineBuilderSetStage(builder, NXT_SHADER_STAGE_VERTEX, vsModule, "main");
|
nxtRenderPipelineBuilderSetStage(builder, NXT_SHADER_STAGE_VERTEX, vsModule, "main");
|
||||||
nxtPipelineBuilderSetStage(builder, NXT_SHADER_STAGE_FRAGMENT, fsModule, "main");
|
nxtRenderPipelineBuilderSetStage(builder, NXT_SHADER_STAGE_FRAGMENT, fsModule, "main");
|
||||||
pipeline = nxtPipelineBuilderGetResult(builder);
|
pipeline = nxtRenderPipelineBuilderGetResult(builder);
|
||||||
nxtPipelineBuilderRelease(builder);
|
nxtRenderPipelineBuilderRelease(builder);
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtShaderModuleRelease(vsModule);
|
nxtShaderModuleRelease(vsModule);
|
||||||
|
@ -82,7 +82,7 @@ void frame() {
|
||||||
nxtCommandBufferBuilder builder = nxtDeviceCreateCommandBufferBuilder(device);
|
nxtCommandBufferBuilder builder = nxtDeviceCreateCommandBufferBuilder(device);
|
||||||
nxtCommandBufferBuilderBeginRenderPass(builder, renderpass, framebuffer);
|
nxtCommandBufferBuilderBeginRenderPass(builder, renderpass, framebuffer);
|
||||||
nxtCommandBufferBuilderBeginRenderSubpass(builder);
|
nxtCommandBufferBuilderBeginRenderSubpass(builder);
|
||||||
nxtCommandBufferBuilderSetPipeline(builder, pipeline);
|
nxtCommandBufferBuilderSetRenderPipeline(builder, pipeline);
|
||||||
nxtCommandBufferBuilderDrawArrays(builder, 3, 1, 0, 0);
|
nxtCommandBufferBuilderDrawArrays(builder, 3, 1, 0, 0);
|
||||||
nxtCommandBufferBuilderEndRenderSubpass(builder);
|
nxtCommandBufferBuilderEndRenderSubpass(builder);
|
||||||
nxtCommandBufferBuilderEndRenderPass(builder);
|
nxtCommandBufferBuilderEndRenderPass(builder);
|
||||||
|
|
|
@ -28,12 +28,12 @@ nxt::Queue queue;
|
||||||
nxt::Buffer modelBuffer;
|
nxt::Buffer modelBuffer;
|
||||||
std::array<nxt::Buffer, 2> particleBuffers;
|
std::array<nxt::Buffer, 2> particleBuffers;
|
||||||
|
|
||||||
nxt::Pipeline renderPipeline;
|
nxt::RenderPipeline renderPipeline;
|
||||||
nxt::RenderPass renderpass;
|
nxt::RenderPass renderpass;
|
||||||
nxt::Framebuffer framebuffer;
|
nxt::Framebuffer framebuffer;
|
||||||
|
|
||||||
nxt::Buffer updateParams;
|
nxt::Buffer updateParams;
|
||||||
nxt::Pipeline updatePipeline;
|
nxt::ComputePipeline updatePipeline;
|
||||||
std::array<nxt::BindGroup, 2> updateBGs;
|
std::array<nxt::BindGroup, 2> updateBGs;
|
||||||
|
|
||||||
std::array<nxt::CommandBuffer, 2> commandBuffers;
|
std::array<nxt::CommandBuffer, 2> commandBuffers;
|
||||||
|
@ -124,7 +124,7 @@ void initRender() {
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
utils::CreateDefaultRenderPass(device, &renderpass, &framebuffer);
|
utils::CreateDefaultRenderPass(device, &renderpass, &framebuffer);
|
||||||
renderPipeline = device.CreatePipelineBuilder()
|
renderPipeline = device.CreateRenderPipelineBuilder()
|
||||||
.SetSubpass(renderpass, 0)
|
.SetSubpass(renderpass, 0)
|
||||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||||
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
||||||
|
@ -231,7 +231,7 @@ void initSim() {
|
||||||
.SetBindGroupLayout(0, bgl)
|
.SetBindGroupLayout(0, bgl)
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
updatePipeline = device.CreatePipelineBuilder()
|
updatePipeline = device.CreateComputePipelineBuilder()
|
||||||
.SetLayout(pl)
|
.SetLayout(pl)
|
||||||
.SetStage(nxt::ShaderStage::Compute, module, "main")
|
.SetStage(nxt::ShaderStage::Compute, module, "main")
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
@ -265,7 +265,7 @@ void initCommandBuffers() {
|
||||||
auto& bufferDst = particleBuffers[(i + 1) % 2];
|
auto& bufferDst = particleBuffers[(i + 1) % 2];
|
||||||
commandBuffers[i] = device.CreateCommandBufferBuilder()
|
commandBuffers[i] = device.CreateCommandBufferBuilder()
|
||||||
.BeginComputePass()
|
.BeginComputePass()
|
||||||
.SetPipeline(updatePipeline)
|
.SetComputePipeline(updatePipeline)
|
||||||
.TransitionBufferUsage(bufferSrc, nxt::BufferUsageBit::Storage)
|
.TransitionBufferUsage(bufferSrc, nxt::BufferUsageBit::Storage)
|
||||||
.TransitionBufferUsage(bufferDst, nxt::BufferUsageBit::Storage)
|
.TransitionBufferUsage(bufferDst, nxt::BufferUsageBit::Storage)
|
||||||
.SetBindGroup(0, updateBGs[i])
|
.SetBindGroup(0, updateBGs[i])
|
||||||
|
@ -274,7 +274,7 @@ void initCommandBuffers() {
|
||||||
|
|
||||||
.BeginRenderPass(renderpass, framebuffer)
|
.BeginRenderPass(renderpass, framebuffer)
|
||||||
.BeginRenderSubpass()
|
.BeginRenderSubpass()
|
||||||
.SetPipeline(renderPipeline)
|
.SetRenderPipeline(renderPipeline)
|
||||||
.TransitionBufferUsage(bufferDst, nxt::BufferUsageBit::Vertex)
|
.TransitionBufferUsage(bufferDst, nxt::BufferUsageBit::Vertex)
|
||||||
.SetVertexBuffers(0, 1, &bufferDst, zeroOffsets)
|
.SetVertexBuffers(0, 1, &bufferDst, zeroOffsets)
|
||||||
.SetVertexBuffers(1, 1, &modelBuffer, zeroOffsets)
|
.SetVertexBuffers(1, 1, &modelBuffer, zeroOffsets)
|
||||||
|
|
|
@ -21,11 +21,11 @@
|
||||||
nxt::Device device;
|
nxt::Device device;
|
||||||
nxt::Queue queue;
|
nxt::Queue queue;
|
||||||
nxt::Buffer buffer;
|
nxt::Buffer buffer;
|
||||||
nxt::Pipeline renderPipeline;
|
nxt::RenderPipeline renderPipeline;
|
||||||
nxt::BindGroup renderBindGroup;
|
nxt::BindGroup renderBindGroup;
|
||||||
nxt::RenderPass renderpass;
|
nxt::RenderPass renderpass;
|
||||||
nxt::Framebuffer framebuffer;
|
nxt::Framebuffer framebuffer;
|
||||||
nxt::Pipeline computePipeline;
|
nxt::ComputePipeline computePipeline;
|
||||||
nxt::BindGroup computeBindGroup;
|
nxt::BindGroup computeBindGroup;
|
||||||
|
|
||||||
void init() {
|
void init() {
|
||||||
|
@ -67,7 +67,7 @@ void init() {
|
||||||
.SetBindGroupLayout(0, bgl)
|
.SetBindGroupLayout(0, bgl)
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
computePipeline = device.CreatePipelineBuilder()
|
computePipeline = device.CreateComputePipelineBuilder()
|
||||||
.SetLayout(pl)
|
.SetLayout(pl)
|
||||||
.SetStage(nxt::ShaderStage::Compute, module, "main")
|
.SetStage(nxt::ShaderStage::Compute, module, "main")
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
@ -109,7 +109,7 @@ void init() {
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
utils::CreateDefaultRenderPass(device, &renderpass, &framebuffer);
|
utils::CreateDefaultRenderPass(device, &renderpass, &framebuffer);
|
||||||
renderPipeline = device.CreatePipelineBuilder()
|
renderPipeline = device.CreateRenderPipelineBuilder()
|
||||||
.SetSubpass(renderpass, 0)
|
.SetSubpass(renderpass, 0)
|
||||||
.SetLayout(pl)
|
.SetLayout(pl)
|
||||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||||
|
@ -127,7 +127,7 @@ void init() {
|
||||||
void frame() {
|
void frame() {
|
||||||
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder()
|
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder()
|
||||||
.BeginComputePass()
|
.BeginComputePass()
|
||||||
.SetPipeline(computePipeline)
|
.SetComputePipeline(computePipeline)
|
||||||
.TransitionBufferUsage(buffer, nxt::BufferUsageBit::Storage)
|
.TransitionBufferUsage(buffer, nxt::BufferUsageBit::Storage)
|
||||||
.SetBindGroup(0, computeBindGroup)
|
.SetBindGroup(0, computeBindGroup)
|
||||||
.Dispatch(1, 1, 1)
|
.Dispatch(1, 1, 1)
|
||||||
|
@ -135,7 +135,7 @@ void frame() {
|
||||||
|
|
||||||
.BeginRenderPass(renderpass, framebuffer)
|
.BeginRenderPass(renderpass, framebuffer)
|
||||||
.BeginRenderSubpass()
|
.BeginRenderSubpass()
|
||||||
.SetPipeline(renderPipeline)
|
.SetRenderPipeline(renderPipeline)
|
||||||
.TransitionBufferUsage(buffer, nxt::BufferUsageBit::Uniform)
|
.TransitionBufferUsage(buffer, nxt::BufferUsageBit::Uniform)
|
||||||
.SetBindGroup(0, renderBindGroup)
|
.SetBindGroup(0, renderBindGroup)
|
||||||
.DrawArrays(3, 1, 0, 0)
|
.DrawArrays(3, 1, 0, 0)
|
||||||
|
|
|
@ -34,9 +34,9 @@ nxt::BindGroup bindGroup[2];
|
||||||
nxt::BindGroup cubeTransformBindGroup[2];
|
nxt::BindGroup cubeTransformBindGroup[2];
|
||||||
|
|
||||||
nxt::Queue queue;
|
nxt::Queue queue;
|
||||||
nxt::Pipeline pipeline;
|
nxt::RenderPipeline pipeline;
|
||||||
nxt::Pipeline planePipeline;
|
nxt::RenderPipeline planePipeline;
|
||||||
nxt::Pipeline reflectionPipeline;
|
nxt::RenderPipeline reflectionPipeline;
|
||||||
nxt::RenderPass renderpass;
|
nxt::RenderPass renderpass;
|
||||||
nxt::Framebuffer framebuffer;
|
nxt::Framebuffer framebuffer;
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ void init() {
|
||||||
.SetDepthWriteEnabled(true)
|
.SetDepthWriteEnabled(true)
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
pipeline = device.CreatePipelineBuilder()
|
pipeline = device.CreateRenderPipelineBuilder()
|
||||||
.SetSubpass(renderpass, 0)
|
.SetSubpass(renderpass, 0)
|
||||||
.SetLayout(pl)
|
.SetLayout(pl)
|
||||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
.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)
|
.SetStencilFunction(nxt::Face::Both, nxt::CompareFunction::Always, nxt::StencilOperation::Keep, nxt::StencilOperation::Keep, nxt::StencilOperation::Replace)
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
planePipeline = device.CreatePipelineBuilder()
|
planePipeline = device.CreateRenderPipelineBuilder()
|
||||||
.SetSubpass(renderpass, 0)
|
.SetSubpass(renderpass, 0)
|
||||||
.SetLayout(pl)
|
.SetLayout(pl)
|
||||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
.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)
|
.SetStencilFunction(nxt::Face::Both, nxt::CompareFunction::Equal, nxt::StencilOperation::Keep, nxt::StencilOperation::Keep, nxt::StencilOperation::Replace)
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
reflectionPipeline = device.CreatePipelineBuilder()
|
reflectionPipeline = device.CreateRenderPipelineBuilder()
|
||||||
.SetSubpass(renderpass, 0)
|
.SetSubpass(renderpass, 0)
|
||||||
.SetLayout(pl)
|
.SetLayout(pl)
|
||||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||||
|
@ -273,7 +273,7 @@ void frame() {
|
||||||
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder()
|
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder()
|
||||||
.BeginRenderPass(renderpass, framebuffer)
|
.BeginRenderPass(renderpass, framebuffer)
|
||||||
.BeginRenderSubpass()
|
.BeginRenderSubpass()
|
||||||
.SetPipeline(pipeline)
|
.SetRenderPipeline(pipeline)
|
||||||
.TransitionBufferUsage(cameraBuffer, nxt::BufferUsageBit::Uniform)
|
.TransitionBufferUsage(cameraBuffer, nxt::BufferUsageBit::Uniform)
|
||||||
.SetBindGroup(0, bindGroup[0])
|
.SetBindGroup(0, bindGroup[0])
|
||||||
.SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets)
|
.SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets)
|
||||||
|
@ -281,11 +281,11 @@ void frame() {
|
||||||
.DrawElements(36, 1, 0, 0)
|
.DrawElements(36, 1, 0, 0)
|
||||||
|
|
||||||
.SetStencilReference(0x1)
|
.SetStencilReference(0x1)
|
||||||
.SetPipeline(planePipeline)
|
.SetRenderPipeline(planePipeline)
|
||||||
.SetVertexBuffers(0, 1, &planeBuffer, vertexBufferOffsets)
|
.SetVertexBuffers(0, 1, &planeBuffer, vertexBufferOffsets)
|
||||||
.DrawElements(6, 1, 0, 0)
|
.DrawElements(6, 1, 0, 0)
|
||||||
|
|
||||||
.SetPipeline(reflectionPipeline)
|
.SetRenderPipeline(reflectionPipeline)
|
||||||
.SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets)
|
.SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets)
|
||||||
.SetBindGroup(0, bindGroup[1])
|
.SetBindGroup(0, bindGroup[1])
|
||||||
.DrawElements(36, 1, 0, 0)
|
.DrawElements(36, 1, 0, 0)
|
||||||
|
|
|
@ -24,7 +24,7 @@ nxt::Buffer indexBuffer;
|
||||||
nxt::Buffer vertexBuffer;
|
nxt::Buffer vertexBuffer;
|
||||||
|
|
||||||
nxt::Queue queue;
|
nxt::Queue queue;
|
||||||
nxt::Pipeline pipeline;
|
nxt::RenderPipeline pipeline;
|
||||||
nxt::RenderPass renderpass;
|
nxt::RenderPass renderpass;
|
||||||
nxt::Framebuffer framebuffer;
|
nxt::Framebuffer framebuffer;
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ void init() {
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
utils::CreateDefaultRenderPass(device, &renderpass, &framebuffer);
|
utils::CreateDefaultRenderPass(device, &renderpass, &framebuffer);
|
||||||
pipeline = device.CreatePipelineBuilder()
|
pipeline = device.CreateRenderPipelineBuilder()
|
||||||
.SetSubpass(renderpass, 0)
|
.SetSubpass(renderpass, 0)
|
||||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||||
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
||||||
|
@ -84,7 +84,7 @@ void frame() {
|
||||||
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder()
|
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder()
|
||||||
.BeginRenderPass(renderpass, framebuffer)
|
.BeginRenderPass(renderpass, framebuffer)
|
||||||
.BeginRenderSubpass()
|
.BeginRenderSubpass()
|
||||||
.SetPipeline(pipeline)
|
.SetRenderPipeline(pipeline)
|
||||||
.SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets)
|
.SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets)
|
||||||
.SetIndexBuffer(indexBuffer, 0, nxt::IndexFormat::Uint32)
|
.SetIndexBuffer(indexBuffer, 0, nxt::IndexFormat::Uint32)
|
||||||
.DrawElements(3, 1, 0, 0)
|
.DrawElements(3, 1, 0, 0)
|
||||||
|
|
|
@ -24,7 +24,7 @@ nxt::Buffer vertexBuffer;
|
||||||
nxt::Buffer instanceBuffer;
|
nxt::Buffer instanceBuffer;
|
||||||
|
|
||||||
nxt::Queue queue;
|
nxt::Queue queue;
|
||||||
nxt::Pipeline pipeline;
|
nxt::RenderPipeline pipeline;
|
||||||
nxt::RenderPass renderpass;
|
nxt::RenderPass renderpass;
|
||||||
nxt::Framebuffer framebuffer;
|
nxt::Framebuffer framebuffer;
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ void init() {
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
utils::CreateDefaultRenderPass(device, &renderpass, &framebuffer);
|
utils::CreateDefaultRenderPass(device, &renderpass, &framebuffer);
|
||||||
pipeline = device.CreatePipelineBuilder()
|
pipeline = device.CreateRenderPipelineBuilder()
|
||||||
.SetSubpass(renderpass, 0)
|
.SetSubpass(renderpass, 0)
|
||||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||||
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
||||||
|
@ -90,7 +90,7 @@ void frame() {
|
||||||
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder()
|
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder()
|
||||||
.BeginRenderPass(renderpass, framebuffer)
|
.BeginRenderPass(renderpass, framebuffer)
|
||||||
.BeginRenderSubpass()
|
.BeginRenderSubpass()
|
||||||
.SetPipeline(pipeline)
|
.SetRenderPipeline(pipeline)
|
||||||
.SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets)
|
.SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets)
|
||||||
.SetVertexBuffers(1, 1, &instanceBuffer, vertexBufferOffsets)
|
.SetVertexBuffers(1, 1, &instanceBuffer, vertexBufferOffsets)
|
||||||
.DrawArrays(3, 4, 0, 0)
|
.DrawArrays(3, 4, 0, 0)
|
||||||
|
|
|
@ -27,7 +27,7 @@ nxt::Texture texture;
|
||||||
nxt::Sampler sampler;
|
nxt::Sampler sampler;
|
||||||
|
|
||||||
nxt::Queue queue;
|
nxt::Queue queue;
|
||||||
nxt::Pipeline pipeline;
|
nxt::RenderPipeline pipeline;
|
||||||
nxt::RenderPass renderpass;
|
nxt::RenderPass renderpass;
|
||||||
nxt::Framebuffer framebuffer;
|
nxt::Framebuffer framebuffer;
|
||||||
nxt::BindGroup bindGroup;
|
nxt::BindGroup bindGroup;
|
||||||
|
@ -118,7 +118,7 @@ void init() {
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
utils::CreateDefaultRenderPass(device, &renderpass, &framebuffer);
|
utils::CreateDefaultRenderPass(device, &renderpass, &framebuffer);
|
||||||
pipeline = device.CreatePipelineBuilder()
|
pipeline = device.CreateRenderPipelineBuilder()
|
||||||
.SetSubpass(renderpass, 0)
|
.SetSubpass(renderpass, 0)
|
||||||
.SetLayout(pl)
|
.SetLayout(pl)
|
||||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||||
|
@ -145,7 +145,7 @@ void frame() {
|
||||||
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder()
|
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder()
|
||||||
.BeginRenderPass(renderpass, framebuffer)
|
.BeginRenderPass(renderpass, framebuffer)
|
||||||
.BeginRenderSubpass()
|
.BeginRenderSubpass()
|
||||||
.SetPipeline(pipeline)
|
.SetRenderPipeline(pipeline)
|
||||||
.SetBindGroup(0, bindGroup)
|
.SetBindGroup(0, bindGroup)
|
||||||
.SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets)
|
.SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets)
|
||||||
.SetIndexBuffer(indexBuffer, 0, nxt::IndexFormat::Uint32)
|
.SetIndexBuffer(indexBuffer, 0, nxt::IndexFormat::Uint32)
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
nxt::Device device;
|
nxt::Device device;
|
||||||
nxt::Queue queue;
|
nxt::Queue queue;
|
||||||
nxt::Pipeline pipeline;
|
nxt::RenderPipeline pipeline;
|
||||||
nxt::RenderPass renderpass;
|
nxt::RenderPass renderpass;
|
||||||
nxt::Framebuffer framebuffer;
|
nxt::Framebuffer framebuffer;
|
||||||
nxt::Buffer buffer;
|
nxt::Buffer buffer;
|
||||||
|
@ -60,7 +60,7 @@ void init() {
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
utils::CreateDefaultRenderPass(device, &renderpass, &framebuffer);
|
utils::CreateDefaultRenderPass(device, &renderpass, &framebuffer);
|
||||||
pipeline = device.CreatePipelineBuilder()
|
pipeline = device.CreateRenderPipelineBuilder()
|
||||||
.SetSubpass(renderpass, 0)
|
.SetSubpass(renderpass, 0)
|
||||||
.SetLayout(pl)
|
.SetLayout(pl)
|
||||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||||
|
@ -95,7 +95,7 @@ void frame() {
|
||||||
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder()
|
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder()
|
||||||
.BeginRenderPass(renderpass, framebuffer)
|
.BeginRenderPass(renderpass, framebuffer)
|
||||||
.BeginRenderSubpass()
|
.BeginRenderSubpass()
|
||||||
.SetPipeline(pipeline)
|
.SetRenderPipeline(pipeline)
|
||||||
.TransitionBufferUsage(buffer, nxt::BufferUsageBit::Uniform)
|
.TransitionBufferUsage(buffer, nxt::BufferUsageBit::Uniform)
|
||||||
.SetBindGroup(0, bindGroup)
|
.SetBindGroup(0, bindGroup)
|
||||||
.DrawArrays(3, 1, 0, 0)
|
.DrawArrays(3, 1, 0, 0)
|
||||||
|
|
|
@ -23,7 +23,7 @@ nxt::Device device;
|
||||||
nxt::Buffer vertexBuffer;
|
nxt::Buffer vertexBuffer;
|
||||||
|
|
||||||
nxt::Queue queue;
|
nxt::Queue queue;
|
||||||
nxt::Pipeline pipeline;
|
nxt::RenderPipeline pipeline;
|
||||||
nxt::RenderPass renderpass;
|
nxt::RenderPass renderpass;
|
||||||
nxt::Framebuffer framebuffer;
|
nxt::Framebuffer framebuffer;
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ void init() {
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
utils::CreateDefaultRenderPass(device, &renderpass, &framebuffer);
|
utils::CreateDefaultRenderPass(device, &renderpass, &framebuffer);
|
||||||
pipeline = device.CreatePipelineBuilder()
|
pipeline = device.CreateRenderPipelineBuilder()
|
||||||
.SetSubpass(renderpass, 0)
|
.SetSubpass(renderpass, 0)
|
||||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||||
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
||||||
|
@ -78,7 +78,7 @@ void frame() {
|
||||||
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder()
|
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder()
|
||||||
.BeginRenderPass(renderpass, framebuffer)
|
.BeginRenderPass(renderpass, framebuffer)
|
||||||
.BeginRenderSubpass()
|
.BeginRenderSubpass()
|
||||||
.SetPipeline(pipeline)
|
.SetRenderPipeline(pipeline)
|
||||||
.SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets)
|
.SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets)
|
||||||
.DrawArrays(3, 1, 0, 0)
|
.DrawArrays(3, 1, 0, 0)
|
||||||
.EndRenderSubpass()
|
.EndRenderSubpass()
|
||||||
|
|
|
@ -28,8 +28,8 @@ nxt::TextureView renderTargetView;
|
||||||
nxt::Sampler samplerPost;
|
nxt::Sampler samplerPost;
|
||||||
|
|
||||||
nxt::Queue queue;
|
nxt::Queue queue;
|
||||||
nxt::Pipeline pipeline;
|
nxt::RenderPipeline pipeline;
|
||||||
nxt::Pipeline pipelinePost;
|
nxt::RenderPipeline pipelinePost;
|
||||||
nxt::BindGroup bindGroup;
|
nxt::BindGroup bindGroup;
|
||||||
nxt::RenderPass renderpass;
|
nxt::RenderPass renderpass;
|
||||||
nxt::Framebuffer framebuffer;
|
nxt::Framebuffer framebuffer;
|
||||||
|
@ -112,7 +112,7 @@ void initPipeline() {
|
||||||
.SetInput(0, 4 * sizeof(float), nxt::InputStepMode::Vertex)
|
.SetInput(0, 4 * sizeof(float), nxt::InputStepMode::Vertex)
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
pipeline = device.CreatePipelineBuilder()
|
pipeline = device.CreateRenderPipelineBuilder()
|
||||||
.SetSubpass(renderpass, 0)
|
.SetSubpass(renderpass, 0)
|
||||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||||
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
||||||
|
@ -153,7 +153,7 @@ void initPipelinePost() {
|
||||||
.SetBindGroupLayout(0, bgl)
|
.SetBindGroupLayout(0, bgl)
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
|
||||||
pipelinePost = device.CreatePipelineBuilder()
|
pipelinePost = device.CreateRenderPipelineBuilder()
|
||||||
.SetSubpass(renderpass, 1)
|
.SetSubpass(renderpass, 1)
|
||||||
.SetLayout(pl)
|
.SetLayout(pl)
|
||||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||||
|
@ -187,13 +187,13 @@ void frame() {
|
||||||
.BeginRenderPass(renderpass, framebuffer)
|
.BeginRenderPass(renderpass, framebuffer)
|
||||||
.BeginRenderSubpass()
|
.BeginRenderSubpass()
|
||||||
// renderTarget implicitly locked to to Attachment usage (if not already frozen)
|
// renderTarget implicitly locked to to Attachment usage (if not already frozen)
|
||||||
.SetPipeline(pipeline)
|
.SetRenderPipeline(pipeline)
|
||||||
.SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets)
|
.SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets)
|
||||||
.DrawArrays(3, 1, 0, 0)
|
.DrawArrays(3, 1, 0, 0)
|
||||||
.EndRenderSubpass()
|
.EndRenderSubpass()
|
||||||
// renderTarget usage unlocked, but left in Attachment usage
|
// renderTarget usage unlocked, but left in Attachment usage
|
||||||
.BeginRenderSubpass()
|
.BeginRenderSubpass()
|
||||||
.SetPipeline(pipelinePost)
|
.SetRenderPipeline(pipelinePost)
|
||||||
.SetVertexBuffers(0, 1, &vertexBufferQuad, vertexBufferOffsets)
|
.SetVertexBuffers(0, 1, &vertexBufferQuad, vertexBufferOffsets)
|
||||||
.TransitionTextureUsage(renderTarget, nxt::TextureUsageBit::Sampled)
|
.TransitionTextureUsage(renderTarget, nxt::TextureUsageBit::Sampled)
|
||||||
.SetBindGroup(0, bindGroup)
|
.SetBindGroup(0, bindGroup)
|
||||||
|
|
|
@ -62,7 +62,7 @@ namespace gl {
|
||||||
|
|
||||||
struct MaterialInfo {
|
struct MaterialInfo {
|
||||||
nxt::Buffer uniformBuffer;
|
nxt::Buffer uniformBuffer;
|
||||||
nxt::Pipeline pipeline;
|
nxt::RenderPipeline pipeline;
|
||||||
nxt::BindGroup bindGroup0;
|
nxt::BindGroup bindGroup0;
|
||||||
std::map<uint32_t, std::string> slotSemantics;
|
std::map<uint32_t, std::string> slotSemantics;
|
||||||
};
|
};
|
||||||
|
@ -257,7 +257,7 @@ namespace {
|
||||||
auto pipelineLayout = device.CreatePipelineLayoutBuilder()
|
auto pipelineLayout = device.CreatePipelineLayoutBuilder()
|
||||||
.SetBindGroupLayout(0, bindGroupLayout)
|
.SetBindGroupLayout(0, bindGroupLayout)
|
||||||
.GetResult();
|
.GetResult();
|
||||||
auto pipeline = device.CreatePipelineBuilder()
|
auto pipeline = device.CreateRenderPipelineBuilder()
|
||||||
.SetSubpass(renderpass, 0)
|
.SetSubpass(renderpass, 0)
|
||||||
.SetLayout(pipelineLayout)
|
.SetLayout(pipelineLayout)
|
||||||
.SetStage(nxt::ShaderStage::Vertex, oVSModule, "main")
|
.SetStage(nxt::ShaderStage::Vertex, oVSModule, "main")
|
||||||
|
@ -486,7 +486,7 @@ namespace {
|
||||||
reinterpret_cast<const uint32_t*>(&transforms));
|
reinterpret_cast<const uint32_t*>(&transforms));
|
||||||
cmd.BeginRenderPass(renderpass, framebuffer);
|
cmd.BeginRenderPass(renderpass, framebuffer);
|
||||||
cmd.BeginRenderSubpass();
|
cmd.BeginRenderSubpass();
|
||||||
cmd.SetPipeline(material.pipeline);
|
cmd.SetRenderPipeline(material.pipeline);
|
||||||
cmd.TransitionBufferUsage(material.uniformBuffer, nxt::BufferUsageBit::Uniform);
|
cmd.TransitionBufferUsage(material.uniformBuffer, nxt::BufferUsageBit::Uniform);
|
||||||
cmd.SetBindGroup(0, material.bindGroup0);
|
cmd.SetBindGroup(0, material.bindGroup0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue