| Index: src/gpu/vk/GrVkPipelineState.cpp
|
| diff --git a/src/gpu/vk/GrVkPipelineState.cpp b/src/gpu/vk/GrVkPipelineState.cpp
|
| index dacd66b0e7e90fffad5ea7f55259b13d481e28a0..90a27e35a76a4b3e1f28310f7ec72da90ceb0955 100644
|
| --- a/src/gpu/vk/GrVkPipelineState.cpp
|
| +++ b/src/gpu/vk/GrVkPipelineState.cpp
|
| @@ -37,6 +37,8 @@ GrVkPipelineState::GrVkPipelineState(GrVkGpu* gpu,
|
| const GrGLSLFragProcs& fragmentProcessors)
|
| : fPipeline(pipeline)
|
| , fPipelineLayout(layout)
|
| + , fStartDS(SK_MaxS32)
|
| + , fDSCount(0)
|
| , fBuiltinUniformHandles(builtinUniformHandles)
|
| , fGeometryProcessor(geometryProcessor)
|
| , fXferProcessor(xferProcessor)
|
| @@ -46,7 +48,8 @@ GrVkPipelineState::GrVkPipelineState(GrVkGpu* gpu,
|
| , fSamplerPoolManager(dsLayout[GrVkUniformHandler::kSamplerDescSet],
|
| VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, numSamplers, gpu)
|
| , fUniformPoolManager(dsLayout[GrVkUniformHandler::kUniformBufferDescSet],
|
| - VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 2, gpu) {
|
| + VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
|
| + (vertexUniformSize || fragmentUniformSize) ? 2 : 0, gpu) {
|
| fSamplers.setReserve(numSamplers);
|
| fTextureViews.setReserve(numSamplers);
|
| fTextures.setReserve(numSamplers);
|
| @@ -55,8 +58,10 @@ GrVkPipelineState::GrVkPipelineState(GrVkGpu* gpu,
|
| fDescriptorSets[1] = VK_NULL_HANDLE;
|
|
|
| // Currently we are always binding a descriptor set for uniform buffers.
|
| - fStartDS = GrVkUniformHandler::kUniformBufferDescSet;
|
| - fDSCount = 1;
|
| + if (vertexUniformSize || fragmentUniformSize) {
|
| + fDSCount++;
|
| + fStartDS = GrVkUniformHandler::kUniformBufferDescSet;
|
| + }
|
| if (numSamplers) {
|
| fDSCount++;
|
| fStartDS = SkTMin(fStartDS, (int)GrVkUniformHandler::kSamplerDescSet);
|
| @@ -189,13 +194,15 @@ void GrVkPipelineState::setData(GrVkGpu* gpu,
|
| if (fNumSamplers) {
|
| fSamplerPoolManager.getNewDescriptorSet(gpu,
|
| &fDescriptorSets[GrVkUniformHandler::kSamplerDescSet]);
|
| + this->writeSamplers(gpu, textureBindings);
|
| }
|
| - fUniformPoolManager.getNewDescriptorSet(gpu,
|
| - &fDescriptorSets[GrVkUniformHandler::kUniformBufferDescSet]);
|
|
|
| - this->writeUniformBuffers(gpu);
|
|
|
| - this->writeSamplers(gpu, textureBindings);
|
| + if (fVertexUniformBuffer.get() || fFragmentUniformBuffer.get()) {
|
| + fUniformPoolManager.getNewDescriptorSet(gpu,
|
| + &fDescriptorSets[GrVkUniformHandler::kUniformBufferDescSet]);
|
| + this->writeUniformBuffers(gpu);
|
| + }
|
| }
|
|
|
| void GrVkPipelineState::writeUniformBuffers(const GrVkGpu* gpu) {
|
| @@ -218,7 +225,7 @@ void GrVkPipelineState::writeUniformBuffers(const GrVkGpu* gpu) {
|
|
|
| descriptorWrites[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
| descriptorWrites[0].pNext = nullptr;
|
| - descriptorWrites[0].dstSet = fDescriptorSets[1];
|
| + descriptorWrites[0].dstSet = fDescriptorSets[GrVkUniformHandler::kUniformBufferDescSet];
|
| descriptorWrites[0].dstBinding = GrVkUniformHandler::kVertexBinding;
|
| descriptorWrites[0].dstArrayElement = 0;
|
| descriptorWrites[0].descriptorCount = 1;
|
| @@ -249,7 +256,7 @@ void GrVkPipelineState::writeUniformBuffers(const GrVkGpu* gpu) {
|
|
|
| descriptorWrites[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
|
| descriptorWrites[1].pNext = nullptr;
|
| - descriptorWrites[1].dstSet = fDescriptorSets[1];
|
| + descriptorWrites[1].dstSet = fDescriptorSets[GrVkUniformHandler::kUniformBufferDescSet];
|
| descriptorWrites[1].dstBinding = GrVkUniformHandler::kFragBinding;;
|
| descriptorWrites[1].dstArrayElement = 0;
|
| descriptorWrites[1].descriptorCount = 1;
|
|
|