forked from RichDavisonNCL/VulkanRendering
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVulkanTexture.h
72 lines (58 loc) · 1.84 KB
/
VulkanTexture.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/******************************************************************************
This file is part of the Newcastle Vulkan Tutorial Series
Author:Rich Davison
Contact:[email protected]
License: MIT (see LICENSE file at the top of the source tree)
*//////////////////////////////////////////////////////////////////////////////
#pragma once
#include "../NCLCoreClasses/Texture.h"
#include "VulkanTextureBuilder.h"
#include "SmartTypes.h"
namespace NCL::Rendering::Vulkan {
class VulkanRenderer;
class VulkanTexture : public Texture {
friend class VulkanRenderer;
friend class TextureBuilder;
public:
~VulkanTexture();
vk::ImageView GetDefaultView() const {
return *defaultView;
}
vk::Format GetFormat() const {
return format;
}
vk::Image GetImage() const {
return image;
}
//Allows us to pass a texture as vk type to various functions
operator vk::Image() const {
return image;
}
operator vk::ImageView() const {
return *defaultView;
}
operator vk::Format() const {
return format;
}
void GenerateMipMaps(vk::CommandBuffer buffer,
vk::ImageLayout endLayout = vk::ImageLayout::eShaderReadOnlyOptimal,
vk::PipelineStageFlags2 endFlags = vk::PipelineStageFlagBits2::eFragmentShader);
static size_t GetMaxMips(Vector2i dimensions) {
return (size_t)std::floor(log2(float(std::min(dimensions.x, dimensions.y)))) + 1;
}
static size_t GetMaxMips(Vector2ui dimensions) {
return (size_t)std::floor(log2(float(std::min(dimensions.x, dimensions.y)))) + 1;
}
protected:
VulkanTexture();
vk::UniqueImageView defaultView;
vk::Image image; //Don't use 'Unique', uses VMA
vk::Format format;
vk::ImageAspectFlags aspectType;
VmaAllocation allocationHandle;
VmaAllocationInfo allocationInfo;
VmaAllocator allocator;
uint32_t mipCount;
uint32_t layerCount;
};
}