Esempio n. 1
0
        /**
         * Get the index of a memory type that has all the requested property bits set
         *
         * @param typeBits Bitmask with bits set for each memory type supported by the resource to request for (from VkMemoryRequirements)
         * @param properties Bitmask of properties for the memory type to request
         * @param (Optional) memTypeFound Pointer to a bool that is set to true if a matching memory type has been found
         *
         * @return Index of the requested memory type
         *
         * @throw Throws an exception if memTypeFound is null and no memory type could be found that supports the requested properties
         */
        public uint getMemoryType(uint typeBits, VkMemoryPropertyFlagBits properties, uint *memTypeFound = null)
        {
            for (uint i = 0; i < MemoryProperties.memoryTypeCount; i++)
            {
                if ((typeBits & 1) == 1)
                {
                    if ((MemoryProperties.GetMemoryType(i).propertyFlags & properties) == properties)
                    {
                        if (memTypeFound != null)
                        {
                            *memTypeFound = True;
                        }
                        return(i);
                    }
                }
                typeBits >>= 1;
            }

            if (memTypeFound != null)
            {
                *memTypeFound = False;
                return(0);
            }
            else
            {
                throw new InvalidOperationException("Could not find a matching memory type");
            }
        }
Esempio n. 2
0
        public static uint GetMemoryType(uint typeBits, VkMemoryPropertyFlags properties)
        {
            for (uint i = 0; i < MemoryProperties.memoryTypeCount; i++)
            {
                if ((typeBits & 1) == 1)
                {
                    if ((MemoryProperties.GetMemoryType(i).propertyFlags & properties) == properties)
                    {
                        return(i);
                    }
                }
                typeBits >>= 1;
            }

            return(0);
        }