MCPcopy Create free account
hub / github.com/NVIDIA/cuda-samples / createImage

Function createImage

cpp/5_Domain_Specific/simpleVulkanMMAP/VulkanBaseApp.cpp:773–816  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

771}
772
773static void createImage(VkPhysicalDevice physicalDevice,
774 VkDevice device,
775 uint32_t width,
776 uint32_t height,
777 VkFormat format,
778 VkImageTiling tiling,
779 VkImageUsageFlags usage,
780 VkMemoryPropertyFlags properties,
781 VkImage &image,
782 VkDeviceMemory &imageMemory)
783{
784 VkImageCreateInfo imageInfo = {};
785 imageInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
786 imageInfo.imageType = VK_IMAGE_TYPE_2D;
787 imageInfo.extent.width = width;
788 imageInfo.extent.height = height;
789 imageInfo.extent.depth = 1;
790 imageInfo.mipLevels = 1;
791 imageInfo.arrayLayers = 1;
792 imageInfo.format = format;
793 imageInfo.tiling = tiling;
794 imageInfo.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
795 imageInfo.usage = usage;
796 imageInfo.samples = VK_SAMPLE_COUNT_1_BIT;
797 imageInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
798
799 if (vkCreateImage(device, &imageInfo, nullptr, &image) != VK_SUCCESS) {
800 throw std::runtime_error("failed to create image!");
801 }
802
803 VkMemoryRequirements memRequirements;
804 vkGetImageMemoryRequirements(device, image, &memRequirements);
805
806 VkMemoryAllocateInfo allocInfo = {};
807 allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO;
808 allocInfo.allocationSize = memRequirements.size;
809 allocInfo.memoryTypeIndex = findMemoryType(physicalDevice, memRequirements.memoryTypeBits, properties);
810
811 if (vkAllocateMemory(device, &allocInfo, nullptr, &imageMemory) != VK_SUCCESS) {
812 throw std::runtime_error("failed to allocate image memory!");
813 }
814
815 vkBindImageMemory(device, image, imageMemory, 0);
816}
817
818void VulkanBaseApp::createImageViews()
819{

Callers 1

createDepthResourcesMethod · 0.70

Calls 1

findMemoryTypeFunction · 0.70

Tested by

no test coverage detected