mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-14 15:46:28 +00:00
Introduce render passes
* First API design (many features missing, including input attachments) * Metal implementation (no OpenGL yet) * Render-to-texture demo (a little broken until we have depth buffers) * Update examples to use render passes
This commit is contained in:
committed by
Kai Ninomiya
parent
ca309db58a
commit
68df8b0a3a
@@ -24,6 +24,8 @@ nxt::Buffer instanceBuffer;
|
||||
|
||||
nxt::Queue queue;
|
||||
nxt::Pipeline pipeline;
|
||||
nxt::RenderPass renderpass;
|
||||
nxt::Framebuffer framebuffer;
|
||||
|
||||
void initBuffers() {
|
||||
static const float vertexData[12] = {
|
||||
@@ -89,7 +91,9 @@ void init() {
|
||||
.SetInput(1, 2 * sizeof(float), nxt::InputStepMode::Instance)
|
||||
.GetResult();
|
||||
|
||||
CreateDefaultRenderPass(device, &renderpass, &framebuffer);
|
||||
pipeline = device.CreatePipelineBuilder()
|
||||
.SetSubpass(renderpass, 0)
|
||||
.SetStage(nxt::ShaderStage::Vertex, vsModule, "main")
|
||||
.SetStage(nxt::ShaderStage::Fragment, fsModule, "main")
|
||||
.SetInputState(inputState)
|
||||
@@ -99,10 +103,12 @@ void init() {
|
||||
void frame() {
|
||||
static const uint32_t vertexBufferOffsets[1] = {0};
|
||||
nxt::CommandBuffer commands = device.CreateCommandBufferBuilder()
|
||||
.SetPipeline(pipeline)
|
||||
.SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets)
|
||||
.SetVertexBuffers(1, 1, &instanceBuffer, vertexBufferOffsets)
|
||||
.DrawArrays(3, 4, 0, 0)
|
||||
.BeginRenderPass(renderpass, framebuffer)
|
||||
.SetPipeline(pipeline)
|
||||
.SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets)
|
||||
.SetVertexBuffers(1, 1, &instanceBuffer, vertexBufferOffsets)
|
||||
.DrawArrays(3, 4, 0, 0)
|
||||
.EndRenderPass()
|
||||
.GetResult();
|
||||
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
Reference in New Issue
Block a user