private void CreateImageViews() { vkSwapChainImageViews = new VkImageView[vkSwapChainImages.Length]; for (int i = 0; i < vkSwapChainImages.Length; i++) { VkImageViewCreateInfo createInfo = new VkImageViewCreateInfo() { sType = VkStructureType.VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO, image = vkSwapChainImages[i], viewType = VkImageViewType.VK_IMAGE_VIEW_TYPE_2D, format = vkSwapChainImageFormat, components = new VkComponentMapping() { r = VkComponentSwizzle.VK_COMPONENT_SWIZZLE_IDENTITY, g = VkComponentSwizzle.VK_COMPONENT_SWIZZLE_IDENTITY, b = VkComponentSwizzle.VK_COMPONENT_SWIZZLE_IDENTITY, a = VkComponentSwizzle.VK_COMPONENT_SWIZZLE_IDENTITY, }, subresourceRange = new VkImageSubresourceRange() { aspectMask = VkImageAspectFlagBits.VK_IMAGE_ASPECT_COLOR_BIT, baseMipLevel = 0, levelCount = 1, baseArrayLayer = 0, layerCount = 1 } }; VkImageView newImageView; var result = VulkanNative.vkCreateImageView(vkDevice, &createInfo, null, &newImageView); vkSwapChainImageViews[i] = newImageView; Helpers.CheckErrors(result); } }
private void CreateImageViews() { swapChainImageViews = new VkImageView[swapChainImages.Length]; for (int i = 0; i < swapChainImages.Length; i++) { VkImageViewCreateInfo createInfo = new VkImageViewCreateInfo(); createInfo.sType = VkStructureType.VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; createInfo.image = swapChainImages[i]; createInfo.viewType = VkImageViewType.VK_IMAGE_VIEW_TYPE_2D; createInfo.format = swapChainImageFormat; createInfo.components.r = VkComponentSwizzle.VK_COMPONENT_SWIZZLE_IDENTITY; createInfo.components.g = VkComponentSwizzle.VK_COMPONENT_SWIZZLE_IDENTITY; createInfo.components.b = VkComponentSwizzle.VK_COMPONENT_SWIZZLE_IDENTITY; createInfo.components.a = VkComponentSwizzle.VK_COMPONENT_SWIZZLE_IDENTITY; createInfo.subresourceRange.aspectMask = VkImageAspectFlags.VK_IMAGE_ASPECT_COLOR_BIT; createInfo.subresourceRange.baseMipLevel = 0; createInfo.subresourceRange.levelCount = 1; createInfo.subresourceRange.baseArrayLayer = 0; createInfo.subresourceRange.layerCount = 1; fixed(VkImageView *swapChainImageViewPtr = &swapChainImageViews[i]) { Helpers.CheckErrors(VulkanNative.vkCreateImageView(device, &createInfo, null, swapChainImageViewPtr)); } } }
public unsafe ImageView( Image image, VkImageAspectFlags aspectMask ) { _device = image.Device; _image = image; var imageViewInfo = new VkImageViewCreateInfo { sType = VkStructureType.ImageViewCreateInfo, image = image.Handle, viewType = VkImageViewType.Image2D, format = image.Format, components = new VkComponentMapping { r = VkComponentSwizzle.Identity, g = VkComponentSwizzle.Identity, b = VkComponentSwizzle.Identity, a = VkComponentSwizzle.Identity }, subresourceRange = new VkImageSubresourceRange { aspectMask = aspectMask, baseMipLevel = 0, levelCount = image.MipLevel, baseArrayLayer = 0, layerCount = 1 } }; VkImageView imageView; if (VulkanNative.vkCreateImageView( _device.Handle, &imageViewInfo, null, &imageView ) != VkResult.Success) { throw new Exception("failed to create image view"); } _handle = imageView; }