Generate quad for final composition pass in vertex shader
This commit is contained in:
parent
89f82e328c
commit
bfd0a2e0b4
3 changed files with 49 additions and 11 deletions
|
|
@ -536,6 +536,8 @@ public:
|
|||
// Move viewport to display final composition in lower right corner
|
||||
viewport.x = viewport.width * 0.5f;
|
||||
viewport.y = viewport.height * 0.5f;
|
||||
viewport.width = viewport.width * 0.5f;
|
||||
viewport.height = viewport.height * 0.5f;
|
||||
vkCmdSetViewport(drawCmdBuffers[i], 0, 1, &viewport);
|
||||
}
|
||||
|
||||
|
|
@ -593,12 +595,13 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
createBuffer(
|
||||
VK_CHECK_RESULT(vulkanDevice->createBuffer(
|
||||
VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,
|
||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
|
||||
vertexBuffer.size() * sizeof(Vertex),
|
||||
vertexBuffer.data(),
|
||||
&meshes.quad.vertices.buf,
|
||||
&meshes.quad.vertices.mem);
|
||||
&meshes.quad.vertices.mem,
|
||||
vertexBuffer.data()));
|
||||
|
||||
// Setup indices
|
||||
std::vector<uint32_t> indexBuffer = { 0,1,2, 2,3,0 };
|
||||
|
|
@ -612,12 +615,13 @@ public:
|
|||
}
|
||||
meshes.quad.indexCount = static_cast<uint32_t>(indexBuffer.size());
|
||||
|
||||
createBuffer(
|
||||
VK_CHECK_RESULT(vulkanDevice->createBuffer(
|
||||
VK_BUFFER_USAGE_INDEX_BUFFER_BIT,
|
||||
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
|
||||
indexBuffer.size() * sizeof(uint32_t),
|
||||
indexBuffer.data(),
|
||||
&meshes.quad.indices.buf,
|
||||
&meshes.quad.indices.mem);
|
||||
&meshes.quad.indices.mem,
|
||||
indexBuffer.data()));
|
||||
}
|
||||
|
||||
void setupVertexDescriptions()
|
||||
|
|
@ -911,19 +915,14 @@ public:
|
|||
static_cast<uint32_t>(dynamicStateEnables.size()),
|
||||
0);
|
||||
|
||||
// Final fullscreen pass pipeline
|
||||
std::array<VkPipelineShaderStageCreateInfo, 2> shaderStages;
|
||||
|
||||
shaderStages[0] = loadShader(getAssetPath() + "shaders/deferred/deferred.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[1] = loadShader(getAssetPath() + "shaders/deferred/deferred.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
|
||||
VkGraphicsPipelineCreateInfo pipelineCreateInfo =
|
||||
vkTools::initializers::pipelineCreateInfo(
|
||||
pipelineLayouts.deferred,
|
||||
renderPass,
|
||||
0);
|
||||
|
||||
pipelineCreateInfo.pVertexInputState = &vertices.inputState;
|
||||
pipelineCreateInfo.pInputAssemblyState = &inputAssemblyState;
|
||||
pipelineCreateInfo.pRasterizationState = &rasterizationState;
|
||||
pipelineCreateInfo.pColorBlendState = &colorBlendState;
|
||||
|
|
@ -934,9 +933,17 @@ public:
|
|||
pipelineCreateInfo.stageCount = static_cast<uint32_t>(shaderStages.size());
|
||||
pipelineCreateInfo.pStages = shaderStages.data();
|
||||
|
||||
// Final fullscreen composition pass pipeline
|
||||
shaderStages[0] = loadShader(getAssetPath() + "shaders/deferred/deferred.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[1] = loadShader(getAssetPath() + "shaders/deferred/deferred.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
// Empty vertex input state, quads are generated by the vertex shader
|
||||
VkPipelineVertexInputStateCreateInfo emptyInputState = vkTools::initializers::pipelineVertexInputStateCreateInfo();
|
||||
pipelineCreateInfo.pVertexInputState = &emptyInputState;
|
||||
pipelineCreateInfo.layout = pipelineLayouts.deferred;
|
||||
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.deferred));
|
||||
|
||||
// Debug display pipeline
|
||||
pipelineCreateInfo.pVertexInputState = &vertices.inputState;
|
||||
shaderStages[0] = loadShader(getAssetPath() + "shaders/deferred/debug.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
|
||||
shaderStages[1] = loadShader(getAssetPath() + "shaders/deferred/debug.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.debug));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue