diff options
author | 2016-04-06 13:47:08 -0700 | |
---|---|---|
committer | 2016-04-06 13:47:08 -0700 | |
commit | b4aa36211ca66ef127ac2954108742af1ead5082 (patch) | |
tree | 753eb0f21477f96a6a6b996bed5f286bd2c1925b /src/gpu/vk | |
parent | a957b8a114bb003d0975a5d5737c30b00e5940ab (diff) |
Switch uniforms to be descriptor set 0 in Vulkan
This (plus some cleanup) gives us some minor perf gains and as a side effect
the perf debug layer no longer complains when we bind certain descriptor sets.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1864303002
Review URL: https://codereview.chromium.org/1864303002
Diffstat (limited to 'src/gpu/vk')
-rw-r--r-- | src/gpu/vk/GrVkGpu.cpp | 2 | ||||
-rw-r--r-- | src/gpu/vk/GrVkPipelineState.cpp | 25 | ||||
-rw-r--r-- | src/gpu/vk/GrVkPipelineStateBuilder.cpp | 6 | ||||
-rw-r--r-- | src/gpu/vk/GrVkUniformHandler.h | 4 |
4 files changed, 22 insertions, 15 deletions
diff --git a/src/gpu/vk/GrVkGpu.cpp b/src/gpu/vk/GrVkGpu.cpp index 62cf58087c..e35a814b03 100644 --- a/src/gpu/vk/GrVkGpu.cpp +++ b/src/gpu/vk/GrVkGpu.cpp @@ -98,7 +98,7 @@ GrVkGpu::GrVkGpu(GrContext* context, const GrContextOptions& options, VK_DEBUG_REPORT_WARNING_BIT_EXT;// | //VK_DEBUG_REPORT_INFORMATION_BIT_EXT | //VK_DEBUG_REPORT_DEBUG_BIT_EXT | - //VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT; + VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT; callbackCreateInfo.pfnCallback = &DebugReportCallback; callbackCreateInfo.pUserData = nullptr; diff --git a/src/gpu/vk/GrVkPipelineState.cpp b/src/gpu/vk/GrVkPipelineState.cpp index dacd66b0e7..90a27e35a7 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; diff --git a/src/gpu/vk/GrVkPipelineStateBuilder.cpp b/src/gpu/vk/GrVkPipelineStateBuilder.cpp index f9654c3af5..3ea9e1b5d2 100644 --- a/src/gpu/vk/GrVkPipelineStateBuilder.cpp +++ b/src/gpu/vk/GrVkPipelineStateBuilder.cpp @@ -170,7 +170,7 @@ GrVkPipelineState* GrVkPipelineStateBuilder::finalize(GrPrimitiveType primitiveT UniformHandle uniHandle = fSamplerUniforms[i]; GrVkUniformHandler::UniformInfo uniformInfo = fUniformHandler.getUniformInfo(uniHandle); SkASSERT(kSampler2D_GrSLType == uniformInfo.fVariable.getType()); - SkASSERT(0 == uniformInfo.fSetNumber); + SkASSERT(GrVkUniformHandler::kSamplerDescSet == uniformInfo.fSetNumber); SkASSERT(uniformInfo.fBinding == i); dsSamplerBindings[i].binding = uniformInfo.fBinding; dsSamplerBindings[i].descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; @@ -203,12 +203,12 @@ GrVkPipelineState* GrVkPipelineStateBuilder::finalize(GrPrimitiveType primitiveT memset(&dsUniBindings, 0, 2 * sizeof(VkDescriptorSetLayoutBinding)); dsUniBindings[0].binding = GrVkUniformHandler::kVertexBinding; dsUniBindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; - dsUniBindings[0].descriptorCount = fUniformHandler.hasVertexUniforms() ? 1 : 0; + dsUniBindings[0].descriptorCount = 1; dsUniBindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; dsUniBindings[0].pImmutableSamplers = nullptr; dsUniBindings[1].binding = GrVkUniformHandler::kFragBinding; dsUniBindings[1].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; - dsUniBindings[1].descriptorCount = fUniformHandler.hasFragmentUniforms() ? 1 : 0; + dsUniBindings[1].descriptorCount = 1; dsUniBindings[1].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; dsUniBindings[1].pImmutableSamplers = nullptr; diff --git a/src/gpu/vk/GrVkUniformHandler.h b/src/gpu/vk/GrVkUniformHandler.h index 8a3f314cb9..46d27cda7c 100644 --- a/src/gpu/vk/GrVkUniformHandler.h +++ b/src/gpu/vk/GrVkUniformHandler.h @@ -18,8 +18,8 @@ public: static const int kUniformsPerBlock = 8; enum { - kSamplerDescSet = 0, - kUniformBufferDescSet = 1, + kUniformBufferDescSet = 0, + kSamplerDescSet = 1, }; enum { kVertexBinding = 0, |