-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathVulkanTexture.h
73 lines (59 loc) · 1.93 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
73
/******************************************************************************
This file is part of the Newcastle Vulkan Tutorial Series
Author:Rich Davison
Contact:richgdavison@gmail.com
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 startLayout = vk::ImageLayout::eShaderReadOnlyOptimal,
vk::ImageLayout endLayout = vk::ImageLayout::eShaderReadOnlyOptimal,
vk::PipelineStageFlags2 endFlags = vk::PipelineStageFlagBits2::eFragmentShader);
template <typename T, uint32_t n>
static constexpr size_t GetMaxMips(const VectorTemplate<T, n>& texDims) {
T m = Vector::GetMaxElement(texDims);
return (size_t)std::floor(log2((float(m)))) + 1;
}
protected:
VulkanTexture();
vk::UniqueImageView defaultView;
vk::Image image; //Don't use 'Unique', uses VMA
vk::Format format = vk::Format::eUndefined;
vk::ImageAspectFlags aspectType;
vk::UniqueSemaphore workSemaphore;
VmaAllocation allocationHandle = {};
VmaAllocationInfo allocationInfo = {};
VmaAllocator allocator = {};
uint32_t mipCount = 0;
uint32_t layerCount = 0;
};
}