Beispiel #1
0
        private void CreateTexture(VkDevice device, VkPhysicalDevice physicalDevice, VkQueue graphicsQueue)
        {
            SimpleTgaReader tex     = new SimpleTgaReader("resource/texture.tga");
            var             command = m_commandBuffers[1];

            SampleHelpers.CreateTexture(device, physicalDevice,
                                        tex.Width, tex.Height, tex.ImageData,
                                        out m_image, out m_imageMemory, graphicsQueue, command);

            // イメージビューの作成.
            var imageViewCreateInfo = new VkImageViewCreateInfo()
            {
                image            = m_image,
                viewType         = VkImageViewType.VK_IMAGE_VIEW_TYPE_2D,
                format           = VkFormat.VK_FORMAT_B8G8R8A8_UNORM,
                components       = new VkComponentMapping(),
                subresourceRange = new VkImageSubresourceRange()
                {
                    aspectMask     = VkImageAspectFlags.VK_IMAGE_ASPECT_COLOR_BIT,
                    baseArrayLayer = 0,
                    baseMipLevel   = 0,
                    levelCount     = 1,
                    layerCount     = 1,
                }
            };

            VulkanAPI.vkCreateImageView(device, ref imageViewCreateInfo, out m_imageView);

            // サンプラーの作成.
            var samplerCreateInfo = new VkSamplerCreateInfo()
            {
                magFilter    = VkFilter.VK_FILTER_LINEAR,
                minFilter    = VkFilter.VK_FILTER_LINEAR,
                mipmapMode   = VkSamplerMipmapMode.VK_SAMPLER_MIPMAP_MODE_NEAREST,
                addressModeU = VkSamplerAddressMode.VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
                addressModeV = VkSamplerAddressMode.VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE,
            };

            VulkanAPI.vkCreateSampler(device, ref samplerCreateInfo, out m_imageSampler);
        }