Index: src/gpu/vk/GrVkDescriptorSetManager.cpp |
diff --git a/src/gpu/vk/GrVkDescriptorSetManager.cpp b/src/gpu/vk/GrVkDescriptorSetManager.cpp |
index 51138e1a079814852f9aacd11671654989384e5e..703f2fde128d58febe8e85e67af48fdd670c6bf5 100644 |
--- a/src/gpu/vk/GrVkDescriptorSetManager.cpp |
+++ b/src/gpu/vk/GrVkDescriptorSetManager.cpp |
@@ -10,13 +10,29 @@ |
#include "GrVkDescriptorPool.h" |
#include "GrVkDescriptorSet.h" |
#include "GrVkGpu.h" |
+#include "GrVkUniformHandler.h" |
+#include "glsl/GrGLSLSampler.h" |
GrVkDescriptorSetManager::GrVkDescriptorSetManager(GrVkGpu* gpu, |
VkDescriptorSetLayout layout, |
VkDescriptorType type, |
- uint32_t samplerCount) |
- : fPoolManager(layout, type, samplerCount, gpu) |
- , fNumSamplerBindings(samplerCount) { |
+ uint32_t descCountPerSet, |
+ const GrVkUniformHandler* uniformHandler) |
+ : fPoolManager(layout, type, descCountPerSet, gpu) { |
+ if (type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) { |
+ SkASSERT(uniformHandler); |
+ SkASSERT((int)descCountPerSet == uniformHandler->numSamplers()); |
+ for (int i = 0; i < uniformHandler->numSamplers(); ++i) { |
+ fBindingVisibilities.push_back(uniformHandler->getSampler(i).visibility()); |
+ } |
+ } else { |
+ SkASSERT(type == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER); |
+ SkASSERT(2 == descCountPerSet); |
+ // We set the visibility of the first binding to the vertex shader and the second to the |
+ // fragment shader. |
+ fBindingVisibilities.push_back(kVertex_GrShaderFlag); |
+ fBindingVisibilities.push_back(kFragment_GrShaderFlag); |
+ } |
} |
const GrVkDescriptorSet* GrVkDescriptorSetManager::getDescriptorSet(GrVkGpu* gpu, |
@@ -59,6 +75,28 @@ void GrVkDescriptorSetManager::abandon() { |
fFreeSets.reset(); |
} |
+VkDescriptorSetLayout GrVkDescriptorSetManager::layout() const { return fPoolManager.fDescLayout; } |
jvanverth1
2016/07/25 19:12:56
Put in .h file?
egdaniel
2016/07/26 13:33:19
Done.
|
+ |
+bool GrVkDescriptorSetManager::isCompatible(VkDescriptorType type, |
+ const GrVkUniformHandler* uniHandler) const { |
+ SkASSERT(uniHandler); |
+ if (type != fPoolManager.fDescType) { |
+ return false; |
+ } |
+ |
+ if (type == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) { |
+ if (fBindingVisibilities.count() != uniHandler->numSamplers()) { |
+ return false; |
+ } |
+ for (int i = 0; i < uniHandler->numSamplers(); ++i) { |
+ if (uniHandler->getSampler(i).visibility() != fBindingVisibilities[i]) { |
+ return false; |
+ } |
+ } |
+ } |
+ return true; |
+} |
+ |
//////////////////////////////////////////////////////////////////////////////// |
void GrVkDescriptorSetManager::DescriptorPoolManager::getNewPool(GrVkGpu* gpu) { |
@@ -101,9 +139,11 @@ void GrVkDescriptorSetManager::DescriptorPoolManager::getNewDescriptorSet(GrVkGp |
} |
void GrVkDescriptorSetManager::DescriptorPoolManager::freeGPUResources(const GrVkGpu* gpu) { |
- // The layout should be owned by the class which owns the DescriptorSetManager so it will |
- // take care of destroying it. |
- fDescLayout = VK_NULL_HANDLE; |
+ if (fDescLayout) { |
+ GR_VK_CALL(gpu->vkInterface(), DestroyDescriptorSetLayout(gpu->device(), fDescLayout, |
jvanverth1
2016/07/25 19:12:56
Is there any way to create this in the DescriptorP
egdaniel
2016/07/26 13:33:19
Done.
|
+ nullptr)); |
+ fDescLayout = VK_NULL_HANDLE; |
+ } |
if (fPool) { |
fPool->unref(gpu); |