No wireframe pipeline and rendering if device doesn't support non-solid fill modes

This commit is contained in:
saschawillems 2017-03-15 21:04:53 +01:00
parent 6b3f194b9d
commit 627718f97f

View file

@ -196,10 +196,10 @@ public:
glm::vec4 lightPos = glm::vec4(0.0f, 5.0f, 15.0f, 1.0f); glm::vec4 lightPos = glm::vec4(0.0f, 5.0f, 15.0f, 1.0f);
} uboVS; } uboVS;
struct { struct Pipelines {
VkPipeline toonshading; VkPipeline toonshading;
VkPipeline color; VkPipeline color;
VkPipeline wireframe; VkPipeline wireframe = VK_NULL_HANDLE;
VkPipeline postprocess; VkPipeline postprocess;
} pipelines; } pipelines;
@ -243,9 +243,16 @@ public:
cameraPos = { 0.1f, 1.1f, 0.0f }; cameraPos = { 0.1f, 1.1f, 0.0f };
enableTextOverlay = true; enableTextOverlay = true;
title = "Vulkan Example - VK_EXT_debug_marker"; title = "Vulkan Example - VK_EXT_debug_marker";
// Enable required device features }
// Enable physical device features required for this example
virtual void getEnabledFeatures()
{
// Fill mode non solid is required for wireframe display
if (deviceFeatures.fillModeNonSolid) {
enabledFeatures.fillModeNonSolid = VK_TRUE; enabledFeatures.fillModeNonSolid = VK_TRUE;
enabledFeatures.wideLines = VK_TRUE; };
wireframe = deviceFeatures.fillModeNonSolid;
} }
~VulkanExample() ~VulkanExample()
@ -254,8 +261,10 @@ public:
// Note : Inherited destructor cleans up resources stored in base class // Note : Inherited destructor cleans up resources stored in base class
vkDestroyPipeline(device, pipelines.toonshading, nullptr); vkDestroyPipeline(device, pipelines.toonshading, nullptr);
vkDestroyPipeline(device, pipelines.color, nullptr); vkDestroyPipeline(device, pipelines.color, nullptr);
vkDestroyPipeline(device, pipelines.wireframe, nullptr);
vkDestroyPipeline(device, pipelines.postprocess, nullptr); vkDestroyPipeline(device, pipelines.postprocess, nullptr);
if (pipelines.wireframe != VK_NULL_HANDLE) {
vkDestroyPipeline(device, pipelines.wireframe, nullptr);
}
vkDestroyPipelineLayout(device, pipelineLayout, nullptr); vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
vkDestroyDescriptorSetLayout(device, descriptorSetLayout, nullptr); vkDestroyDescriptorSetLayout(device, descriptorSetLayout, nullptr);
@ -818,10 +827,12 @@ public:
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.color)); VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.color));
// Wire frame rendering pipeline // Wire frame rendering pipeline
if (deviceFeatures.fillModeNonSolid)
{
rasterizationState.polygonMode = VK_POLYGON_MODE_LINE; rasterizationState.polygonMode = VK_POLYGON_MODE_LINE;
rasterizationState.lineWidth = 1.0f;
pipelineCreateInfo.renderPass = renderPass; pipelineCreateInfo.renderPass = renderPass;
VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.wireframe)); VK_CHECK_RESULT(vkCreateGraphicsPipelines(device, pipelineCache, 1, &pipelineCreateInfo, nullptr, &pipelines.wireframe));
}
// Post processing effect // Post processing effect
shaderStages[0] = loadShader(getAssetPath() + "shaders/debugmarker/postprocess.vert.spv", VK_SHADER_STAGE_VERTEX_BIT); shaderStages[0] = loadShader(getAssetPath() + "shaders/debugmarker/postprocess.vert.spv", VK_SHADER_STAGE_VERTEX_BIT);
@ -958,8 +969,11 @@ public:
{ {
case 0x57: case 0x57:
case GAMEPAD_BUTTON_X: case GAMEPAD_BUTTON_X:
if (deviceFeatures.fillModeNonSolid)
{
wireframe = !wireframe; wireframe = !wireframe;
reBuildCommandBuffers(); reBuildCommandBuffers();
}
break; break;
case 0x47: case 0x47:
case GAMEPAD_BUTTON_A: case GAMEPAD_BUTTON_A: