Forráskód Böngészése

Allow for more descriptors in arrays

Panagiotis Christopoulos Charitos 3 éve
szülő
commit
9e7c009d5c

+ 6 - 6
AnKi/Gr/Vulkan/DescriptorSet.cpp

@@ -683,7 +683,7 @@ Error DSLayoutCacheEntry::init(const DescriptorBinding* bindings, U32 bindingCou
 		const DescriptorBinding& ak = bindings[i];
 		const DescriptorBinding& ak = bindings[i];
 
 
 		vk.binding = ak.m_binding;
 		vk.binding = ak.m_binding;
-		vk.descriptorCount = ak.m_arraySizeMinusOne + 1;
+		vk.descriptorCount = ak.m_arraySize;
 		vk.descriptorType = convertDescriptorType(ak.m_type);
 		vk.descriptorType = convertDescriptorType(ak.m_type);
 		vk.pImmutableSamplers = nullptr;
 		vk.pImmutableSamplers = nullptr;
 		vk.stageFlags = convertShaderTypeBit(ak.m_stageMask);
 		vk.stageFlags = convertShaderTypeBit(ak.m_stageMask);
@@ -691,7 +691,7 @@ Error DSLayoutCacheEntry::init(const DescriptorBinding* bindings, U32 bindingCou
 		ANKI_ASSERT(m_activeBindings.get(ak.m_binding) == false);
 		ANKI_ASSERT(m_activeBindings.get(ak.m_binding) == false);
 		m_activeBindings.set(ak.m_binding);
 		m_activeBindings.set(ak.m_binding);
 		m_bindingType[ak.m_binding] = ak.m_type;
 		m_bindingType[ak.m_binding] = ak.m_type;
-		m_bindingArraySize[ak.m_binding] = ak.m_arraySizeMinusOne + 1;
+		m_bindingArraySize[ak.m_binding] = ak.m_arraySize;
 		m_minBinding = min<U32>(m_minBinding, ak.m_binding);
 		m_minBinding = min<U32>(m_minBinding, ak.m_binding);
 		m_maxBinding = max<U32>(m_maxBinding, ak.m_binding);
 		m_maxBinding = max<U32>(m_maxBinding, ak.m_binding);
 	}
 	}
@@ -710,7 +710,7 @@ Error DSLayoutCacheEntry::init(const DescriptorBinding* bindings, U32 bindingCou
 		{
 		{
 			if(m_poolSizesCreateInf[j].type == convertDescriptorType(bindings[i].m_type))
 			if(m_poolSizesCreateInf[j].type == convertDescriptorType(bindings[i].m_type))
 			{
 			{
-				m_poolSizesCreateInf[j].descriptorCount += bindings[i].m_arraySizeMinusOne + 1;
+				m_poolSizesCreateInf[j].descriptorCount += bindings[i].m_arraySize;
 				break;
 				break;
 			}
 			}
 		}
 		}
@@ -718,7 +718,7 @@ Error DSLayoutCacheEntry::init(const DescriptorBinding* bindings, U32 bindingCou
 		if(j == poolSizeCount)
 		if(j == poolSizeCount)
 		{
 		{
 			m_poolSizesCreateInf[poolSizeCount].type = convertDescriptorType(bindings[i].m_type);
 			m_poolSizesCreateInf[poolSizeCount].type = convertDescriptorType(bindings[i].m_type);
-			m_poolSizesCreateInf[poolSizeCount].descriptorCount = bindings[i].m_arraySizeMinusOne + 1;
+			m_poolSizesCreateInf[poolSizeCount].descriptorCount = bindings[i].m_arraySize;
 			++poolSizeCount;
 			++poolSizeCount;
 		}
 		}
 	}
 	}
@@ -988,12 +988,12 @@ Error DescriptorSetFactory::newDescriptorSetLayout(const DescriptorSetLayoutInit
 		{
 		{
 			const DescriptorBinding& binding = bindings[i];
 			const DescriptorBinding& binding = bindings[i];
 			if(binding.m_binding == 0 && binding.m_type == DescriptorType::TEXTURE
 			if(binding.m_binding == 0 && binding.m_type == DescriptorType::TEXTURE
-			   && binding.m_arraySizeMinusOne == m_bindlessTextureCount - 1)
+			   && binding.m_arraySize == m_bindlessTextureCount)
 			{
 			{
 				// All good
 				// All good
 			}
 			}
 			else if(binding.m_binding == 1 && binding.m_type == DescriptorType::IMAGE
 			else if(binding.m_binding == 1 && binding.m_type == DescriptorType::IMAGE
-					&& binding.m_arraySizeMinusOne == m_bindlessImageCount - 1)
+					&& binding.m_arraySize == m_bindlessImageCount)
 			{
 			{
 				// All good
 				// All good
 			}
 			}

+ 1 - 2
AnKi/Gr/Vulkan/DescriptorSet.h

@@ -26,11 +26,10 @@ class DSLayoutCacheEntry;
 class alignas(8) DescriptorBinding
 class alignas(8) DescriptorBinding
 {
 {
 public:
 public:
+	U32 m_arraySize = 0;
 	ShaderTypeBit m_stageMask = ShaderTypeBit::NONE;
 	ShaderTypeBit m_stageMask = ShaderTypeBit::NONE;
 	DescriptorType m_type = DescriptorType::COUNT;
 	DescriptorType m_type = DescriptorType::COUNT;
 	U8 m_binding = MAX_U8;
 	U8 m_binding = MAX_U8;
-	U8 m_arraySizeMinusOne = 0;
-	Array<U8, 3> m_padding = {};
 };
 };
 static_assert(sizeof(DescriptorBinding) == 8, "Should be packed because it will be hashed");
 static_assert(sizeof(DescriptorBinding) == 8, "Should be packed because it will be hashed");
 
 

+ 3 - 4
AnKi/Gr/Vulkan/ShaderImpl.cpp

@@ -143,7 +143,7 @@ void ShaderImpl::doReflection(ConstWeakArray<U8> spirv, SpecConstsVector& specCo
 			{
 			{
 				ANKI_ASSERT(typeInfo.array.size() == 1 && "Only 1D arrays are supported");
 				ANKI_ASSERT(typeInfo.array.size() == 1 && "Only 1D arrays are supported");
 				arraySize = typeInfo.array[0];
 				arraySize = typeInfo.array[0];
-				ANKI_ASSERT(arraySize > 0 && (arraySize - 1) <= MAX_U8);
+				ANKI_ASSERT(arraySize > 0);
 			}
 			}
 
 
 			m_descriptorSetMask.set(set);
 			m_descriptorSetMask.set(set);
@@ -167,14 +167,13 @@ void ShaderImpl::doReflection(ConstWeakArray<U8> spirv, SpecConstsVector& specCo
 				descriptor.m_binding = U8(binding);
 				descriptor.m_binding = U8(binding);
 				descriptor.m_type = type;
 				descriptor.m_type = type;
 				descriptor.m_stageMask = ShaderTypeBit(1 << m_shaderType);
 				descriptor.m_stageMask = ShaderTypeBit(1 << m_shaderType);
-				descriptor.m_arraySizeMinusOne = U8(arraySize - 1);
+				descriptor.m_arraySize = arraySize;
 			}
 			}
 			else
 			else
 			{
 			{
 				// Same binding, make sure the type is compatible
 				// Same binding, make sure the type is compatible
 				ANKI_ASSERT(type == descriptors[set][foundIdx].m_type && "Same binding different type");
 				ANKI_ASSERT(type == descriptors[set][foundIdx].m_type && "Same binding different type");
-				ANKI_ASSERT(arraySize - 1 == descriptors[set][foundIdx].m_arraySizeMinusOne
-							&& "Same binding different array size");
+				ANKI_ASSERT(arraySize == descriptors[set][foundIdx].m_arraySize && "Same binding different array size");
 			}
 			}
 		}
 		}
 	};
 	};