diff options
author | Greg Daniel <egdaniel@google.com> | 2017-05-08 12:10:12 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-05-09 19:30:19 +0000 |
commit | 852d7155ddb212418b20ba5a81b3001fa9380471 (patch) | |
tree | 2d89f2211393da75db5fdc9237d16f95b4832068 /src | |
parent | ab8ce1a5ae0a0c87cb127634b9bdb94f3a17cec8 (diff) |
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 <egdaniel@google.com>
Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/vk/GrVkPipelineStateBuilder.cpp | 29 |
1 files changed, 22 insertions, 7 deletions
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, |