From 120b51d1dd1a2cea8647beb2248e0040901ab95b Mon Sep 17 00:00:00 2001
From: Johann Muszynski <johann.muszynski@gmail.com>
Date: Sun, 24 Mar 2024 14:17:15 +0100
Subject: [PATCH] Code layout nitpicks

---
 src/pt/hybrid_renderer.cpp | 64 ++++++++++++++++++++------------------
 1 file changed, 33 insertions(+), 31 deletions(-)

diff --git a/src/pt/hybrid_renderer.cpp b/src/pt/hybrid_renderer.cpp
index 2039d58..67ce5f6 100644
--- a/src/pt/hybrid_renderer.cpp
+++ b/src/pt/hybrid_renderer.cpp
@@ -742,6 +742,38 @@ HybridRenderer::DebugPass::DebugPass(
         mUniformBuffer.bindGroupEntry(0)};
 
     {
+        // Pipeline layout
+
+        const std::array<WGPUBindGroupLayout, 2> bindGroupLayouts{
+            uniformBindGroupLayout.ptr(), gbufferBindGroupLayout.ptr()};
+
+        const WGPUPipelineLayoutDescriptor pipelineLayoutDesc{
+            .nextInChain = nullptr,
+            .label = "Debug pass pipeline layout",
+            .bindGroupLayoutCount = bindGroupLayouts.size(),
+            .bindGroupLayouts = bindGroupLayouts.data(),
+        };
+
+        const WGPUPipelineLayout pipelineLayout =
+            wgpuDeviceCreatePipelineLayout(gpuContext.device, &pipelineLayoutDesc);
+
+        // Vertex layout
+
+        const std::array<WGPUVertexAttribute, 1> vertexAttributes{WGPUVertexAttribute{
+            .format = WGPUVertexFormat_Float32x2,
+            .offset = 0,
+            .shaderLocation = 0,
+        }};
+
+        const WGPUVertexBufferLayout vertexBufferLayout{
+            .arrayStride = sizeof(float[2]),
+            .stepMode = WGPUVertexStepMode_Vertex,
+            .attributeCount = vertexAttributes.size(),
+            .attributes = vertexAttributes.data(),
+        };
+
+        // Shader module
+
         const WGPUShaderModule shaderModule = [&gpuContext]() -> WGPUShaderModule {
             const WGPUShaderModuleWGSLDescriptor wgslDesc = {
                 .chain =
@@ -761,7 +793,7 @@ HybridRenderer::DebugPass::DebugPass(
         }();
         NLRS_ASSERT(shaderModule != nullptr);
 
-        // Blend state for color target
+        // Fragment state
 
         const WGPUBlendState blendState{
             .color =
@@ -794,36 +826,6 @@ HybridRenderer::DebugPass::DebugPass(
             .targets = colorTargets.data(),
         };
 
-        // Vertex layout
-
-        const std::array<WGPUVertexAttribute, 1> vertexAttributes{WGPUVertexAttribute{
-            .format = WGPUVertexFormat_Float32x2,
-            .offset = 0,
-            .shaderLocation = 0,
-        }};
-
-        const WGPUVertexBufferLayout vertexBufferLayout{
-            .arrayStride = sizeof(float[2]),
-            .stepMode = WGPUVertexStepMode_Vertex,
-            .attributeCount = vertexAttributes.size(),
-            .attributes = vertexAttributes.data(),
-        };
-
-        // Pipeline layout
-
-        const std::array<WGPUBindGroupLayout, 2> bindGroupLayouts{
-            uniformBindGroupLayout.ptr(), gbufferBindGroupLayout.ptr()};
-
-        const WGPUPipelineLayoutDescriptor pipelineLayoutDesc{
-            .nextInChain = nullptr,
-            .label = "Debug pass pipeline layout",
-            .bindGroupLayoutCount = bindGroupLayouts.size(),
-            .bindGroupLayouts = bindGroupLayouts.data(),
-        };
-
-        const WGPUPipelineLayout pipelineLayout =
-            wgpuDeviceCreatePipelineLayout(gpuContext.device, &pipelineLayoutDesc);
-
         // Pipeline
 
         const WGPURenderPipelineDescriptor pipelineDesc{