From 852d7155ddb212418b20ba5a81b3001fa9380471 Mon Sep 17 00:00:00 2001 From: Greg Daniel Date: Mon, 8 May 2017 12:10:12 -0400 Subject: Create geometry shader modules in vulkan when using geom shaders Looks like this was left off the original vulkan Geo shader change. Bug: skia: Change-Id: Iec1c09d6d7b347147e4237bad3e6b3eb4684154e Reviewed-on: https://skia-review.googlesource.com/15813 Commit-Queue: Greg Daniel Reviewed-by: Ethan Nicholas --- src/gpu/vk/GrVkPipelineStateBuilder.cpp | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/gpu/vk/GrVkPipelineStateBuilder.cpp b/src/gpu/vk/GrVkPipelineStateBuilder.cpp index 51c15fb30f..2ea72343e8 100644 --- a/src/gpu/vk/GrVkPipelineStateBuilder.cpp +++ b/src/gpu/vk/GrVkPipelineStateBuilder.cpp @@ -92,8 +92,9 @@ GrVkPipelineState* GrVkPipelineStateBuilder::finalize(const GrStencilSettings& s GrVkPipelineState::Desc* desc) { VkDescriptorSetLayout dsLayout[3]; VkPipelineLayout pipelineLayout; - VkShaderModule vertShaderModule; - VkShaderModule fragShaderModule; + VkShaderModule vertShaderModule = VK_NULL_HANDLE; + VkShaderModule geomShaderModule = VK_NULL_HANDLE; + VkShaderModule fragShaderModule = VK_NULL_HANDLE; GrVkResourceProvider& resourceProvider = fGpu->resourceProvider(); // These layouts are not owned by the PipelineStateBuilder and thus should not be destroyed @@ -136,7 +137,7 @@ GrVkPipelineState* GrVkPipelineStateBuilder::finalize(const GrStencilSettings& s this->finalizeShaders(); - VkPipelineShaderStageCreateInfo shaderStageInfo[2]; + VkPipelineShaderStageCreateInfo shaderStageInfo[3]; SkSL::Program::Settings settings; settings.fFlipY = this->pipeline().getRenderTarget()->origin() != kTopLeft_GrSurfaceOrigin; SkAssertResult(this->createVkShaderModule(VK_SHADER_STAGE_VERTEX_BIT, @@ -146,9 +147,6 @@ GrVkPipelineState* GrVkPipelineStateBuilder::finalize(const GrStencilSettings& s settings, desc)); - // TODO: geometry shader support. - SkASSERT(!this->primitiveProcessor().willUseGeoShader()); - SkAssertResult(this->createVkShaderModule(VK_SHADER_STAGE_FRAGMENT_BIT, fFS, &fragShaderModule, @@ -156,11 +154,22 @@ GrVkPipelineState* GrVkPipelineStateBuilder::finalize(const GrStencilSettings& s settings, desc)); + int numShaderStages = 2; // We always have at least vertex and fragment stages. + if (this->primitiveProcessor().willUseGeoShader()) { + SkAssertResult(this->createVkShaderModule(VK_SHADER_STAGE_GEOMETRY_BIT, + fGS, + &geomShaderModule, + &shaderStageInfo[2], + settings, + desc)); + ++numShaderStages; + } + GrVkPipeline* pipeline = resourceProvider.createPipeline(fPipeline, stencil, fPrimProc, shaderStageInfo, - 2, + numShaderStages, primitiveType, renderPass, pipelineLayout); @@ -168,6 +177,12 @@ GrVkPipelineState* GrVkPipelineStateBuilder::finalize(const GrStencilSettings& s nullptr)); GR_VK_CALL(fGpu->vkInterface(), DestroyShaderModule(fGpu->device(), fragShaderModule, nullptr)); + // This if check should not be needed since calling destroy on a VK_NULL_HANDLE is allowed. + // However this is causing a crash in certain drivers (e.g. NVidia). + if (this->primitiveProcessor().willUseGeoShader()) { + GR_VK_CALL(fGpu->vkInterface(), DestroyShaderModule(fGpu->device(), geomShaderModule, + nullptr)); + } if (!pipeline) { GR_VK_CALL(fGpu->vkInterface(), DestroyPipelineLayout(fGpu->device(), pipelineLayout, -- cgit v1.2.3