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
74
75
76
77
78
79
|
// Copyright 2016 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <memory>
#include "Common/CommonTypes.h"
#include "VideoBackends/Vulkan/Constants.h"
namespace Vulkan
{
class CommandBufferManager;
class ObjectCache;
class Texture2D
{
public:
// Custom image layouts, mainly used for switching to/from compute
enum class ComputeImageLayout
{
Undefined,
ReadOnly,
WriteOnly,
ReadWrite
};
Texture2D(u32 width, u32 height, u32 levels, u32 layers, VkFormat format,
VkSampleCountFlagBits samples, VkImageViewType view_type, VkImage image,
VkDeviceMemory device_memory, VkImageView view);
~Texture2D();
static std::unique_ptr<Texture2D> Create(u32 width, u32 height, u32 levels, u32 layers,
VkFormat format, VkSampleCountFlagBits samples,
VkImageViewType view_type, VkImageTiling tiling,
VkImageUsageFlags usage);
static std::unique_ptr<Texture2D> CreateFromExistingImage(u32 width, u32 height, u32 levels,
u32 layers, VkFormat format,
VkSampleCountFlagBits samples,
VkImageViewType view_type,
VkImage existing_image);
u32 GetWidth() const { return m_width; }
u32 GetHeight() const { return m_height; }
u32 GetLevels() const { return m_levels; }
u32 GetLayers() const { return m_layers; }
VkFormat GetFormat() const { return m_format; }
VkSampleCountFlagBits GetSamples() const { return m_samples; }
VkImageLayout GetLayout() const { return m_layout; }
VkImageViewType GetViewType() const { return m_view_type; }
VkImage GetImage() const { return m_image; }
VkDeviceMemory GetDeviceMemory() const { return m_device_memory; }
VkImageView GetView() const { return m_view; }
// Used when the render pass is changing the image layout, or to force it to
// VK_IMAGE_LAYOUT_UNDEFINED, if the existing contents of the image is
// irrelevant and will not be loaded.
void OverrideImageLayout(VkImageLayout new_layout);
void TransitionToLayout(VkCommandBuffer command_buffer, VkImageLayout new_layout);
void TransitionToLayout(VkCommandBuffer command_buffer, ComputeImageLayout new_layout);
private:
u32 m_width;
u32 m_height;
u32 m_levels;
u32 m_layers;
VkFormat m_format;
VkSampleCountFlagBits m_samples;
VkImageViewType m_view_type;
VkImageLayout m_layout = VK_IMAGE_LAYOUT_UNDEFINED;
ComputeImageLayout m_compute_layout = ComputeImageLayout::Undefined;
VkImage m_image;
VkDeviceMemory m_device_memory;
VkImageView m_view;
};
}
|