Skip to content

Commit

Permalink
Code layout nitpicks
Browse files Browse the repository at this point in the history
  • Loading branch information
Nelarius committed Mar 24, 2024
1 parent 8b5c5e8 commit 120b51d
Showing 1 changed file with 33 additions and 31 deletions.
64 changes: 33 additions & 31 deletions src/pt/hybrid_renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -761,7 +793,7 @@ HybridRenderer::DebugPass::DebugPass(
}();
NLRS_ASSERT(shaderModule != nullptr);

// Blend state for color target
// Fragment state

const WGPUBlendState blendState{
.color =
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit 120b51d

Please sign in to comment.