2
3
4
5
9#include "Render/Vulkan/VulkanImage.h"
10#include "Render/Vulkan/VulkanRenderBackend.h"
11#include "Render/RendererResource/RendererResource.h"
24 m_Resource = std::make_shared<VulkanImage>(
25 VulkanRenderBackend::GetState(),
31 info.description.samples,
32 info.description.format,
33 VK_IMAGE_TILING_OPTIMAL,
35 VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT |
36 VK_IMAGE_USAGE_SAMPLED_BIT |
37 VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
38 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT |
39 VK_IMAGE_USAGE_STORAGE_BIT,
41 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
46 resourceptr->CreateImageView(info.description.format, VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_ASPECT_COLOR_BIT,
true);
48 if (info.usage & VK_IMAGE_USAGE_STORAGE_BIT)
50 resourceptr->TransitionImageLayout(
51 info.description.format,
52 VK_IMAGE_LAYOUT_UNDEFINED,
53 VK_IMAGE_LAYOUT_GENERAL
57 resourceptr->CreateSampler();
61 m_Resource = std::make_shared<VulkanImage>(
62 VulkanRenderBackend::GetState(),
68 info.description.samples,
69 info.description.format,
70 VK_IMAGE_TILING_OPTIMAL,
72 VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
73 VK_IMAGE_USAGE_SAMPLED_BIT |
74 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT,
76 VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
81 resourceptr->CreateImageView(info.description.format, VK_IMAGE_VIEW_TYPE_2D, VK_IMAGE_ASPECT_DEPTH_BIT);
83 resourceptr->TransitionImageLayout(
84 info.description.format,
85 VK_IMAGE_LAYOUT_UNDEFINED,
86 VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
89 resourceptr->CreateSampler();
Texture2D(const RendererResourceCreateInfo &info)
Constructor Function. Used for create render resource.
Texture2D(const std::string &path)
Constructor Function. Init class variable, load date immediately. Usually call it.
Texture2D Class. This class defines the basic behaves of texture2D.
static void Load(const std::string &fileName, Texture2D *outTexture)
Load image to a Texture2D object.
TextureLoader Class. This class only defines static function for load data from image file.
std::string m_ResourcePath
Texture's path in disk.
uint32_t width
Texture' width.
uint32_t height
Texture' height..
bool isDepthResource
True if this resource is a DepthResource.
float sizeScale
Texture's size scale.
This struct defines the data used to create a texture2d. From render pass.