Index: src/gpu/vk/GrVkPipelineStateBuilder.cpp |
diff --git a/src/gpu/vk/GrVkPipelineStateBuilder.cpp b/src/gpu/vk/GrVkPipelineStateBuilder.cpp |
index d9d1b6cfb8c215c16e7aa22e1cf334005d0df702..a3032d7b6cef831a1953c41e69ddf6536cea2334 100644 |
--- a/src/gpu/vk/GrVkPipelineStateBuilder.cpp |
+++ b/src/gpu/vk/GrVkPipelineStateBuilder.cpp |
@@ -7,6 +7,7 @@ |
#include "vk/GrVkPipelineStateBuilder.h" |
+#include "vk/GrVkDescriptorSetManager.h" |
#include "vk/GrVkGpu.h" |
#include "vk/GrVkRenderPass.h" |
#if USE_SKSL |
@@ -60,21 +61,6 @@ void GrVkPipelineStateBuilder::finalizeFragmentSecondaryColor(GrGLSLShaderVar& o |
outputColor.setLayoutQualifier("location = 0, index = 1"); |
} |
-VkShaderStageFlags visibility_to_vk_stage_flags(uint32_t visibility) { |
- VkShaderStageFlags flags = 0; |
- |
- if (visibility & kVertex_GrShaderFlag) { |
- flags |= VK_SHADER_STAGE_VERTEX_BIT; |
- } |
- if (visibility & kGeometry_GrShaderFlag) { |
- flags |= VK_SHADER_STAGE_GEOMETRY_BIT; |
- } |
- if (visibility & kFragment_GrShaderFlag) { |
- flags |= VK_SHADER_STAGE_FRAGMENT_BIT; |
- } |
- return flags; |
-} |
- |
#if USE_SKSL |
SkSL::Program::Kind vk_shader_stage_to_skiasl_kind(VkShaderStageFlagBits stage) { |
if (VK_SHADER_STAGE_VERTEX_BIT == stage) { |
@@ -124,7 +110,7 @@ bool GrVkPipelineStateBuilder::CreateVkShaderModule(const GrVkGpu* gpu, |
} else { |
#if USE_SKSL |
- bool result = gpu->shaderCompiler()->toSPIRV(vk_shader_stage_to_skiasl_kind(stage), |
+ bool result = gpu->shaderCompiler()->toSPIRV(vk_shader_stage_to_skiasl_kind(stage), |
std::string(shaderString.c_str()), |
&code); |
if (!result) { |
@@ -194,39 +180,14 @@ GrVkPipelineState* GrVkPipelineStateBuilder::finalize(GrPrimitiveType primitiveT |
VkShaderModule vertShaderModule; |
VkShaderModule fragShaderModule; |
- uint32_t numSamplers = (uint32_t)fUniformHandler.numSamplers(); |
- |
- SkAutoTDeleteArray<VkDescriptorSetLayoutBinding> dsSamplerBindings( |
- new VkDescriptorSetLayoutBinding[numSamplers]); |
- for (uint32_t i = 0; i < numSamplers; ++i) { |
- const GrVkGLSLSampler& sampler = |
- static_cast<const GrVkGLSLSampler&>(fUniformHandler.getSampler(i)); |
- SkASSERT(sampler.binding() == i); |
- dsSamplerBindings[i].binding = sampler.binding(); |
- dsSamplerBindings[i].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; |
- dsSamplerBindings[i].descriptorCount = 1; |
- dsSamplerBindings[i].stageFlags = visibility_to_vk_stage_flags(sampler.visibility()); |
- dsSamplerBindings[i].pImmutableSamplers = nullptr; |
- } |
- |
- VkDescriptorSetLayoutCreateInfo dsSamplerLayoutCreateInfo; |
- memset(&dsSamplerLayoutCreateInfo, 0, sizeof(VkDescriptorSetLayoutCreateInfo)); |
- dsSamplerLayoutCreateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; |
- dsSamplerLayoutCreateInfo.pNext = nullptr; |
- dsSamplerLayoutCreateInfo.flags = 0; |
- dsSamplerLayoutCreateInfo.bindingCount = numSamplers; |
- // Setting to nullptr fixes an error in the param checker validation layer. Even though |
- // bindingCount is 0 (which is valid), it still tries to validate pBindings unless it is null. |
- dsSamplerLayoutCreateInfo.pBindings = numSamplers ? dsSamplerBindings.get() : nullptr; |
- |
- GR_VK_CALL_ERRCHECK(fGpu->vkInterface(), |
- CreateDescriptorSetLayout(fGpu->device(), |
- &dsSamplerLayoutCreateInfo, |
- nullptr, |
- &dsLayout[GrVkUniformHandler::kSamplerDescSet])); |
- |
+ GrVkResourceProvider& resourceProvider = fGpu->resourceProvider(); |
// This layout is not owned by the PipelineStateBuilder and thus should no be destroyed |
- dsLayout[GrVkUniformHandler::kUniformBufferDescSet] = fGpu->resourceProvider().getUniDSLayout(); |
+ dsLayout[GrVkUniformHandler::kUniformBufferDescSet] = resourceProvider.getUniformDSLayout(); |
+ |
+ GrVkDescriptorSetManager::Handle samplerDSHandle; |
+ resourceProvider.getSamplerDescriptorSetHandle(fUniformHandler, &samplerDSHandle); |
+ dsLayout[GrVkUniformHandler::kSamplerDescSet] = |
+ resourceProvider.getSamplerDSLayout(samplerDSHandle); |
// Create the VkPipelineLayout |
VkPipelineLayoutCreateInfo layoutCreateInfo; |
@@ -266,7 +227,6 @@ GrVkPipelineState* GrVkPipelineStateBuilder::finalize(GrPrimitiveType primitiveT |
&fragShaderModule, |
&shaderStageInfo[1])); |
- GrVkResourceProvider& resourceProvider = fGpu->resourceProvider(); |
GrVkPipeline* pipeline = resourceProvider.createPipeline(fPipeline, |
fPrimProc, |
shaderStageInfo, |
@@ -295,13 +255,14 @@ GrVkPipelineState* GrVkPipelineStateBuilder::finalize(GrPrimitiveType primitiveT |
desc, |
pipeline, |
pipelineLayout, |
- dsLayout[GrVkUniformHandler::kSamplerDescSet], |
+ samplerDSHandle, |
fUniformHandles, |
fUniformHandler.fUniforms, |
fUniformHandler.fCurrentVertexUBOOffset, |
fUniformHandler.fCurrentFragmentUBOOffset, |
- numSamplers, |
+ (uint32_t)fUniformHandler.numSamplers(), |
fGeometryProcessor, |
fXferProcessor, |
fFragmentProcessors); |
} |
+ |