aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/vk/GrVkPipelineStateBuilder.cpp
diff options
context:
space:
mode:
authorGravatar egdaniel <egdaniel@google.com>2016-04-19 14:45:57 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-19 14:45:57 -0700
commit45b61a1c4c0be896e7b12fd1405abfece799114f (patch)
treed39781d14238a55da739d0174854cbfedb8b76f1 /src/gpu/vk/GrVkPipelineStateBuilder.cpp
parent4c13db2a6bb4c795bec6b050b6ebd2ff5177bb5e (diff)
Refactor how we store and use samplers in Ganesh
The main goal of this refactorization is to allow Vulkan to use separate sampler and texture objects in the shader and descriptor sets and combine them into a sampler2d in the shader where needed. A large part of this is separating how we store samplers and uniforms in the UniformHandler. We no longer need to store handles to samplers besides when we are initially emitting code. After we emit code all we ever do is loop over all samplers and do some processor independent work on them, so we have no need for direct access to individual samplers. In the GLProgram all we ever do is set the sampler uniforms in the ctor and never touch them again, so no need to save sampler info there. The texture access on program reuse just assume that they come in the same order as we set the texture units for the samplers For Vulkan, it is a similar story. We create the descriptor set layouts with the samplers, then when we get new textures, we just assume they come in in the same order as we set the samplers on the descriptor sets. Thus no need to save direct vulkan info. BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1885863004 Review URL: https://codereview.chromium.org/1885863004
Diffstat (limited to 'src/gpu/vk/GrVkPipelineStateBuilder.cpp')
-rw-r--r--src/gpu/vk/GrVkPipelineStateBuilder.cpp19
1 files changed, 8 insertions, 11 deletions
diff --git a/src/gpu/vk/GrVkPipelineStateBuilder.cpp b/src/gpu/vk/GrVkPipelineStateBuilder.cpp
index 2bd80033dd..be30bb3e4d 100644
--- a/src/gpu/vk/GrVkPipelineStateBuilder.cpp
+++ b/src/gpu/vk/GrVkPipelineStateBuilder.cpp
@@ -162,20 +162,18 @@ GrVkPipelineState* GrVkPipelineStateBuilder::finalize(GrPrimitiveType primitiveT
VkShaderModule vertShaderModule;
VkShaderModule fragShaderModule;
- uint32_t numSamplers = fSamplerUniforms.count();
+ uint32_t numSamplers = (uint32_t)fUniformHandler.numSamplers();
SkAutoTDeleteArray<VkDescriptorSetLayoutBinding> dsSamplerBindings(
new VkDescriptorSetLayoutBinding[numSamplers]);
for (uint32_t i = 0; i < numSamplers; ++i) {
- UniformHandle uniHandle = fSamplerUniforms[i];
- GrVkUniformHandler::UniformInfo uniformInfo = fUniformHandler.getUniformInfo(uniHandle);
- SkASSERT(kSampler2D_GrSLType == uniformInfo.fVariable.getType());
- SkASSERT(GrVkUniformHandler::kSamplerDescSet == uniformInfo.fSetNumber);
- SkASSERT(uniformInfo.fBinding == i);
- dsSamplerBindings[i].binding = uniformInfo.fBinding;
+ 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(uniformInfo.fVisibility);
+ dsSamplerBindings[i].stageFlags = visibility_to_vk_stage_flags(sampler.visibility());
dsSamplerBindings[i].pImmutableSamplers = nullptr;
}
@@ -184,11 +182,10 @@ GrVkPipelineState* GrVkPipelineStateBuilder::finalize(GrPrimitiveType primitiveT
dsSamplerLayoutCreateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
dsSamplerLayoutCreateInfo.pNext = nullptr;
dsSamplerLayoutCreateInfo.flags = 0;
- dsSamplerLayoutCreateInfo.bindingCount = fSamplerUniforms.count();
+ 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 = fSamplerUniforms.count() ? dsSamplerBindings.get() :
- nullptr;
+ dsSamplerLayoutCreateInfo.pBindings = numSamplers ? dsSamplerBindings.get() : nullptr;
GR_VK_CALL_ERRCHECK(fGpu->vkInterface(),
CreateDescriptorSetLayout(fGpu->device(),