Merge pull request #152 from pbantolas/fix-pipelines-wireframe
Conditional wireframe rendering based on device supported features
This commit is contained in:
commit
1c12e06149
1 changed files with 23 additions and 14 deletions
|
|
@ -80,7 +80,10 @@ public:
|
||||||
// Clean up used Vulkan resources
|
// Clean up used Vulkan resources
|
||||||
// Note : Inherited destructor cleans up resources stored in base class
|
// Note : Inherited destructor cleans up resources stored in base class
|
||||||
vkDestroyPipeline(device, pipelines.solidColor, nullptr);
|
vkDestroyPipeline(device, pipelines.solidColor, nullptr);
|
||||||
vkDestroyPipeline(device, pipelines.wireFrame, nullptr);
|
if (deviceFeatures.fillModeNonSolid)
|
||||||
|
{
|
||||||
|
vkDestroyPipeline(device, pipelines.wireFrame, nullptr);
|
||||||
|
}
|
||||||
vkDestroyPipeline(device, pipelines.texture, nullptr);
|
vkDestroyPipeline(device, pipelines.texture, nullptr);
|
||||||
|
|
||||||
vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
|
vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
|
||||||
|
|
@ -166,11 +169,14 @@ public:
|
||||||
vkCmdSetLineWidth(drawCmdBuffers[i], 2.0f);
|
vkCmdSetLineWidth(drawCmdBuffers[i], 2.0f);
|
||||||
vkCmdDraw(drawCmdBuffers[i], vertices.count, 1, 0, 0);
|
vkCmdDraw(drawCmdBuffers[i], vertices.count, 1, 0, 0);
|
||||||
|
|
||||||
// Right : Wireframe
|
if (deviceFeatures.fillModeNonSolid)
|
||||||
viewport.x = (float)width / 3.0 + (float)width / 3.0;
|
{
|
||||||
vkCmdSetViewport(drawCmdBuffers[i], 0, 1, &viewport);
|
// Right : Wireframe
|
||||||
vkCmdBindPipeline(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.wireFrame);
|
viewport.x = (float)width / 3.0 + (float)width / 3.0;
|
||||||
vkCmdDraw(drawCmdBuffers[i], vertices.count, 1, 0, 0);
|
vkCmdSetViewport(drawCmdBuffers[i], 0, 1, &viewport);
|
||||||
|
vkCmdBindPipeline(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.wireFrame);
|
||||||
|
vkCmdDraw(drawCmdBuffers[i], vertices.count, 1, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
vkCmdEndRenderPass(drawCmdBuffers[i]);
|
vkCmdEndRenderPass(drawCmdBuffers[i]);
|
||||||
|
|
||||||
|
|
@ -500,13 +506,16 @@ public:
|
||||||
err = vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.texture);
|
err = vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.texture);
|
||||||
assert(!err);
|
assert(!err);
|
||||||
|
|
||||||
// Pipeline for wire frame rendering
|
if (deviceFeatures.fillModeNonSolid)
|
||||||
// Solid polygon fill
|
{
|
||||||
rasterizationState.polygonMode = VK_POLYGON_MODE_LINE;
|
// Pipeline for wire frame rendering
|
||||||
// Use different fragment shader
|
// Solid polygon fill
|
||||||
shaderStages[1] = loadShader(getAssetPath() + "shaders/pipelines/wireframe.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
rasterizationState.polygonMode = VK_POLYGON_MODE_LINE;
|
||||||
err = vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.wireFrame);
|
// Use different fragment shader
|
||||||
assert(!err);
|
shaderStages[1] = loadShader(getAssetPath() + "shaders/pipelines/wireframe.frag.spv", VK_SHADER_STAGE_FRAGMENT_BIT);
|
||||||
|
err = vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.wireFrame);
|
||||||
|
assert(!err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare and initialize uniform buffer containing shader uniforms
|
// Prepare and initialize uniform buffer containing shader uniforms
|
||||||
|
|
@ -648,4 +657,4 @@ int main(const int argc, const char *argv[])
|
||||||
#if !defined(__ANDROID__)
|
#if !defined(__ANDROID__)
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue