diff --git a/examples/Animometer.cpp b/examples/Animometer.cpp
index ccbcb94..9e0eff9 100644
--- a/examples/Animometer.cpp
+++ b/examples/Animometer.cpp
@@ -137,24 +137,22 @@
 
     size_t i = 0;
 
-    dawn::CommandBuffer commands;
+    dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
     {
-        dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder()
-            .BeginRenderPass(renderPass)
-            .SetRenderPipeline(pipeline)
-            .Clone();
+        dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass);
+        pass.SetRenderPipeline(pipeline);
 
         for (int k = 0; k < 10000; k++) {
             shaderData[i].time = f / 60.0f;
-            builder.SetPushConstants(dawn::ShaderStageBit::Vertex, 0, 6, reinterpret_cast<uint32_t*>(&shaderData[i]))
-                   .DrawArrays(3, 1, 0, 0);
+            pass.SetPushConstants(dawn::ShaderStageBit::Vertex, 0, 6, reinterpret_cast<uint32_t*>(&shaderData[i]));
+            pass.DrawArrays(3, 1, 0, 0);
             i++;
         }
 
-        builder.EndRenderPass();
-        commands = builder.GetResult();
+        pass.EndPass();
     }
 
+    dawn::CommandBuffer commands = builder.GetResult();
     queue.Submit(1, &commands);
     swapchain.Present(backbuffer);
     DoFlush();
diff --git a/examples/CHelloTriangle.cpp b/examples/CHelloTriangle.cpp
index 075b442..1d87073 100644
--- a/examples/CHelloTriangle.cpp
+++ b/examples/CHelloTriangle.cpp
@@ -84,10 +84,13 @@
     dawnCommandBuffer commands;
     {
         dawnCommandBufferBuilder builder = dawnDeviceCreateCommandBufferBuilder(device);
-        dawnCommandBufferBuilderBeginRenderPass(builder, renderpassInfo);
-        dawnCommandBufferBuilderSetRenderPipeline(builder, pipeline);
-        dawnCommandBufferBuilderDrawArrays(builder, 3, 1, 0, 0);
-        dawnCommandBufferBuilderEndRenderPass(builder);
+
+        dawnRenderPassEncoder pass = dawnCommandBufferBuilderBeginRenderPass(builder, renderpassInfo);
+        dawnRenderPassEncoderSetRenderPipeline(pass, pipeline);
+        dawnRenderPassEncoderDrawArrays(pass, 3, 1, 0, 0);
+        dawnRenderPassEncoderEndPass(pass);
+        dawnRenderPassEncoderRelease(pass);
+
         commands = dawnCommandBufferBuilderGetResult(builder);
         dawnCommandBufferBuilderRelease(builder);
     }
diff --git a/examples/ComputeBoids.cpp b/examples/ComputeBoids.cpp
index 4a69710..77b2ad8 100644
--- a/examples/ComputeBoids.cpp
+++ b/examples/ComputeBoids.cpp
@@ -261,21 +261,26 @@
 dawn::CommandBuffer createCommandBuffer(const dawn::RenderPassDescriptor& renderPass, size_t i) {
     static const uint32_t zeroOffsets[1] = {0};
     auto& bufferDst = particleBuffers[(i + 1) % 2];
-    return device.CreateCommandBufferBuilder()
-        .BeginComputePass()
-            .SetComputePipeline(updatePipeline)
-            .SetBindGroup(0, updateBGs[i])
-            .Dispatch(kNumParticles, 1, 1)
-        .EndComputePass()
+    dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
 
-        .BeginRenderPass(renderPass)
-            .SetRenderPipeline(renderPipeline)
-            .SetVertexBuffers(0, 1, &bufferDst, zeroOffsets)
-            .SetVertexBuffers(1, 1, &modelBuffer, zeroOffsets)
-            .DrawArrays(3, kNumParticles, 0, 0)
-        .EndRenderPass()
+    {
+        dawn::ComputePassEncoder pass = builder.BeginComputePass();
+        pass.SetComputePipeline(updatePipeline);
+        pass.SetBindGroup(0, updateBGs[i]);
+        pass.Dispatch(kNumParticles, 1, 1);
+        pass.EndPass();
+    }
 
-        .GetResult();
+    {
+        dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass);
+        pass.SetRenderPipeline(renderPipeline);
+        pass.SetVertexBuffers(0, 1, &bufferDst, zeroOffsets);
+        pass.SetVertexBuffers(1, 1, &modelBuffer, zeroOffsets);
+        pass.DrawArrays(3, kNumParticles, 0, 0);
+        pass.EndPass();
+    }
+
+    return builder.GetResult();
 }
 
 void init() {
diff --git a/examples/CppHelloTriangle.cpp b/examples/CppHelloTriangle.cpp
index 3be8973..c9aa88c 100644
--- a/examples/CppHelloTriangle.cpp
+++ b/examples/CppHelloTriangle.cpp
@@ -151,16 +151,18 @@
     GetNextRenderPassDescriptor(device, swapchain, depthStencilView, &backbuffer, &renderPass);
 
     static const uint32_t vertexBufferOffsets[1] = {0};
-    dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
-        .BeginRenderPass(renderPass)
-            .SetRenderPipeline(pipeline)
-            .SetBindGroup(0, bindGroup)
-            .SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets)
-            .SetIndexBuffer(indexBuffer, 0)
-            .DrawElements(3, 1, 0, 0)
-        .EndRenderPass()
-        .GetResult();
+    dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
+    {
+        dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass);
+        pass.SetRenderPipeline(pipeline);
+        pass.SetBindGroup(0, bindGroup);
+        pass.SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets);
+        pass.SetIndexBuffer(indexBuffer, 0);
+        pass.DrawElements(3, 1, 0, 0);
+        pass.EndPass();
+    }
 
+    dawn::CommandBuffer commands = builder.GetResult();
     queue.Submit(1, &commands);
     swapchain.Present(backbuffer);
     DoFlush();
diff --git a/examples/CubeReflection.cpp b/examples/CubeReflection.cpp
index 75ed5d7..5a5f658 100644
--- a/examples/CubeReflection.cpp
+++ b/examples/CubeReflection.cpp
@@ -277,27 +277,30 @@
     dawn::RenderPassDescriptor renderPass;
     GetNextRenderPassDescriptor(device, swapchain, depthStencilView, &backbuffer, &renderPass);
 
-    dawn::CommandBuffer commands = device.CreateCommandBufferBuilder()
-        .BeginRenderPass(renderPass)
-            .SetRenderPipeline(pipeline)
-            .SetBindGroup(0, bindGroup[0])
-            .SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets)
-            .SetIndexBuffer(indexBuffer, 0)
-            .DrawElements(36, 1, 0, 0)
+    dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
+    {
+        dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass);
+        pass.SetRenderPipeline(pipeline);
+        pass.SetBindGroup(0, bindGroup[0]);
+        pass.SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets);
+        pass.SetIndexBuffer(indexBuffer, 0);
+        pass.DrawElements(36, 1, 0, 0);
 
-            .SetStencilReference(0x1)
-            .SetRenderPipeline(planePipeline)
-            .SetBindGroup(0, bindGroup[0])
-            .SetVertexBuffers(0, 1, &planeBuffer, vertexBufferOffsets)
-            .DrawElements(6, 1, 0, 0)
+        pass.SetStencilReference(0x1);
+        pass.SetRenderPipeline(planePipeline);
+        pass.SetBindGroup(0, bindGroup[0]);
+        pass.SetVertexBuffers(0, 1, &planeBuffer, vertexBufferOffsets);
+        pass.DrawElements(6, 1, 0, 0);
 
-            .SetRenderPipeline(reflectionPipeline)
-            .SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets)
-            .SetBindGroup(0, bindGroup[1])
-            .DrawElements(36, 1, 0, 0)
-        .EndRenderPass()
-        .GetResult();
+        pass.SetRenderPipeline(reflectionPipeline);
+        pass.SetVertexBuffers(0, 1, &vertexBuffer, vertexBufferOffsets);
+        pass.SetBindGroup(0, bindGroup[1]);
+        pass.DrawElements(36, 1, 0, 0);
 
+        pass.EndPass();
+    }
+
+    dawn::CommandBuffer commands = builder.GetResult();
     queue.Submit(1, &commands);
     swapchain.Present(backbuffer);
     DoFlush();
diff --git a/examples/glTFViewer/glTFViewer.cpp b/examples/glTFViewer/glTFViewer.cpp
index ecded7f..2418dba 100644
--- a/examples/glTFViewer/glTFViewer.cpp
+++ b/examples/glTFViewer/glTFViewer.cpp
@@ -460,7 +460,7 @@
 
 // Drawing
 namespace {
-    void drawMesh(dawn::CommandBufferBuilder& cmd, const tinygltf::Mesh& iMesh, const glm::mat4& model) {
+    void drawMesh(dawn::RenderPassEncoder& pass, const tinygltf::Mesh& iMesh, const glm::mat4& model) {
         for (const auto& iPrim : iMesh.primitives) {
             if (iPrim.mode != gl::Triangles) {
                 fprintf(stderr, "unsupported primitive mode %d\n", iPrim.mode);
@@ -484,9 +484,9 @@
                 }
             }
             const MaterialInfo& material = getMaterial(iPrim.material, strides[0], strides[1], strides[2]);
-            cmd.SetRenderPipeline(material.pipeline);
-            cmd.SetBindGroup(0, material.bindGroup0);
-            cmd.SetPushConstants(dawn::ShaderStageBit::Vertex,
+            pass.SetRenderPipeline(material.pipeline);
+            pass.SetBindGroup(0, material.bindGroup0);
+            pass.SetPushConstants(dawn::ShaderStageBit::Vertex,
                     0, sizeof(u_transform_block) / sizeof(uint32_t),
                     reinterpret_cast<const uint32_t*>(&transforms));
 
@@ -496,7 +496,7 @@
                 auto it = iPrim.attributes.find(s.second);
                 if (it == iPrim.attributes.end()) {
                     uint32_t zero = 0;
-                    cmd.SetVertexBuffers(slot, 1, &defaultBuffer, &zero);
+                    pass.SetVertexBuffers(slot, 1, &defaultBuffer, &zero);
                     continue;
                 }
                 const auto& iAccessor = scene.accessors.at(it->second);
@@ -511,7 +511,7 @@
                 }
                 const auto& oBuffer = buffers.at(iAccessor.bufferView);
                 uint32_t iBufferOffset = static_cast<uint32_t>(iAccessor.byteOffset);
-                cmd.SetVertexBuffers(slot, 1, &oBuffer, &iBufferOffset);
+                pass.SetVertexBuffers(slot, 1, &oBuffer, &iBufferOffset);
             }
 
             if (!iPrim.indices.empty()) {
@@ -522,16 +522,16 @@
                     continue;
                 }
                 const auto& oIndicesBuffer = buffers.at(iIndices.bufferView);
-                cmd.SetIndexBuffer(oIndicesBuffer, static_cast<uint32_t>(iIndices.byteOffset));
-                cmd.DrawElements(static_cast<uint32_t>(iIndices.count), 1, 0, 0);
+                pass.SetIndexBuffer(oIndicesBuffer, static_cast<uint32_t>(iIndices.byteOffset));
+                pass.DrawElements(static_cast<uint32_t>(iIndices.count), 1, 0, 0);
             } else {
                 // DrawArrays
-                cmd.DrawArrays(vertexCount, 1, 0, 0);
+                pass.DrawArrays(vertexCount, 1, 0, 0);
             }
         }
     }
 
-    void drawNode(dawn::CommandBufferBuilder& cmd, const tinygltf::Node& node, const glm::mat4& parent = glm::mat4()) {
+    void drawNode(dawn::RenderPassEncoder& pass, const tinygltf::Node& node, const glm::mat4& parent = glm::mat4()) {
         glm::mat4 model;
         if (node.matrix.size() == 16) {
             model = glm::make_mat4(node.matrix.data());
@@ -552,10 +552,10 @@
         model = parent * model;
 
         for (const auto& meshID : node.meshes) {
-            drawMesh(cmd, scene.meshes[meshID], model);
+            drawMesh(pass, scene.meshes[meshID], model);
         }
         for (const auto& child : node.children) {
-            drawNode(cmd, scene.nodes.at(child), model);
+            drawNode(pass, scene.nodes.at(child), model);
         }
     }
 
@@ -565,15 +565,17 @@
         GetNextRenderPassDescriptor(device, swapchain, depthStencilView, &backbuffer, &renderPass);
 
         const auto& defaultSceneNodes = scene.scenes.at(scene.defaultScene);
-        dawn::CommandBufferBuilder cmd = device.CreateCommandBufferBuilder()
-            .BeginRenderPass(renderPass)
-            .Clone();
-        for (const auto& n : defaultSceneNodes) {
-            const auto& node = scene.nodes.at(n);
-            drawNode(cmd, node);
+        dawn::CommandBufferBuilder builder = device.CreateCommandBufferBuilder();
+        {
+            dawn::RenderPassEncoder pass = builder.BeginRenderPass(renderPass);
+            for (const auto& n : defaultSceneNodes) {
+                const auto& node = scene.nodes.at(n);
+                drawNode(pass, node);
+            }
+            pass.EndPass();
         }
-        auto commands = cmd.EndRenderPass()
-            .GetResult();
+
+        dawn::CommandBuffer commands = builder.GetResult();
         queue.Submit(1, &commands);
 
         swapchain.Present(backbuffer);
