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

Function createImage

cpp/5_Domain_Specific/simpleVulkan/VulkanBaseApp.cpp:780–823  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

createDepthResourcesMethod · 0.70

Calls 1

findMemoryTypeFunction · 0.70

Tested by

no test coverage detected