Hubris Engine
Dev
A Project to learn and get into Game Engine developement.
Loading...
Searching...
No Matches
Utility.h
Go to the documentation of this file.
1
#pragma once
2
#include "
../Format.h
"
3
#include "
../Shader.h
"
4
#include "volk.h"
5
6
namespace
Hubris::Graphics::Vulkan
{
7
inline
constexpr
VkShaderStageFlagBits
VkShaderStageToFlags
(
const
ShaderStage
& stage)
noexcept
{
8
switch
(stage)
9
{
10
case
ShaderStage::Vertex
:
11
return
VK_SHADER_STAGE_VERTEX_BIT;
12
case
ShaderStage::Fragment
:
13
return
VK_SHADER_STAGE_FRAGMENT_BIT;
14
case
ShaderStage::Geometry
:
15
return
VK_SHADER_STAGE_GEOMETRY_BIT;
16
case
ShaderStage::TessellationControl
:
17
return
VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT;
18
case
ShaderStage::TessellationEvaluation
:
19
return
VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT;
20
case
ShaderStage::Compute
:
21
return
VK_SHADER_STAGE_COMPUTE_BIT;
22
default
:
23
break
;
24
}
25
}
26
27
// Conversion from Format to VkFormat
28
constexpr
VkFormat
FormatToVkFormat
(
Format
format)
noexcept
{
29
switch
(format) {
30
case
Format::Undefined
:
return
VK_FORMAT_UNDEFINED;
31
case
Format::R8Unorm
:
return
VK_FORMAT_R8_UNORM;
32
case
Format::R8Snorm
:
return
VK_FORMAT_R8_SNORM;
33
case
Format::R8Uint
:
return
VK_FORMAT_R8_UINT;
34
case
Format::R8Sint
:
return
VK_FORMAT_R8_SINT;
35
case
Format::R8G8Unorm
:
return
VK_FORMAT_R8G8_UNORM;
36
case
Format::R8G8Snorm
:
return
VK_FORMAT_R8G8_SNORM;
37
case
Format::R8G8Uint
:
return
VK_FORMAT_R8G8_UINT;
38
case
Format::R8G8Sint
:
return
VK_FORMAT_R8G8_SINT;
39
case
Format::R8G8B8A8Unorm
:
return
VK_FORMAT_R8G8B8A8_UNORM;
40
case
Format::R8G8B8A8Snorm
:
return
VK_FORMAT_R8G8B8A8_SNORM;
41
case
Format::R8G8B8A8Uint
:
return
VK_FORMAT_R8G8B8A8_UINT;
42
case
Format::R8G8B8A8Sint
:
return
VK_FORMAT_R8G8B8A8_SINT;
43
case
Format::R8G8B8A8Srgb
:
return
VK_FORMAT_R8G8B8A8_SRGB;
44
case
Format::B8G8R8A8Unorm
:
return
VK_FORMAT_B8G8R8A8_UNORM;
45
case
Format::B8G8R8A8Srgb
:
return
VK_FORMAT_B8G8R8A8_SRGB;
46
case
Format::A2R10G10B10Unorm
:
return
VK_FORMAT_A2R10G10B10_UNORM_PACK32;
47
case
Format::R16Float
:
return
VK_FORMAT_R16_SFLOAT;
48
case
Format::R16Uint
:
return
VK_FORMAT_R16_UINT;
49
case
Format::R16Sint
:
return
VK_FORMAT_R16_SINT;
50
case
Format::R16G16Float
:
return
VK_FORMAT_R16G16_SFLOAT;
51
case
Format::R16G16Uint
:
return
VK_FORMAT_R16G16_UINT;
52
case
Format::R16G16Sint
:
return
VK_FORMAT_R16G16_SINT;
53
case
Format::R16G16B16A16Float
:
return
VK_FORMAT_R16G16B16A16_SFLOAT;
54
case
Format::R16G16B16A16Uint
:
return
VK_FORMAT_R16G16B16A16_UINT;
55
case
Format::R16G16B16A16Sint
:
return
VK_FORMAT_R16G16B16A16_SINT;
56
case
Format::R32Uint
:
return
VK_FORMAT_R32_UINT;
57
case
Format::R32Sint
:
return
VK_FORMAT_R32_SINT;
58
case
Format::R32Float
:
return
VK_FORMAT_R32_SFLOAT;
59
case
Format::R32G32Uint
:
return
VK_FORMAT_R32G32_UINT;
60
case
Format::R32G32Sint
:
return
VK_FORMAT_R32G32_SINT;
61
case
Format::R32G32Float
:
return
VK_FORMAT_R32G32_SFLOAT;
62
case
Format::R32G32B32A32Uint
:
return
VK_FORMAT_R32G32B32A32_UINT;
63
case
Format::R32G32B32A32Sint
:
return
VK_FORMAT_R32G32B32A32_SINT;
64
case
Format::R32G32B32A32Float
:
return
VK_FORMAT_R32G32B32A32_SFLOAT;
65
case
Format::D16Unorm
:
return
VK_FORMAT_D16_UNORM;
66
case
Format::D24UnormS8Uint
:
return
VK_FORMAT_D24_UNORM_S8_UINT;
67
case
Format::D32Sfloat
:
return
VK_FORMAT_D32_SFLOAT;
68
case
Format::D32SfloatS8Uint
:
return
VK_FORMAT_D32_SFLOAT_S8_UINT;
69
case
Format::Count
:
return
VK_FORMAT_UNDEFINED;
70
default
:
return
VK_FORMAT_UNDEFINED;
71
}
72
}
73
74
// Conversion from VkFormat to Format
75
constexpr
Format
VkFormatToFormat
(VkFormat format)
noexcept
{
76
switch
(format) {
77
case
VK_FORMAT_UNDEFINED:
return
Format::Undefined
;
78
case
VK_FORMAT_R8_UNORM:
return
Format::R8Unorm
;
79
case
VK_FORMAT_R8_SNORM:
return
Format::R8Snorm
;
80
case
VK_FORMAT_R8_UINT:
return
Format::R8Uint
;
81
case
VK_FORMAT_R8_SINT:
return
Format::R8Sint
;
82
case
VK_FORMAT_R8G8_UNORM:
return
Format::R8G8Unorm
;
83
case
VK_FORMAT_R8G8_SNORM:
return
Format::R8G8Snorm
;
84
case
VK_FORMAT_R8G8_UINT:
return
Format::R8G8Uint
;
85
case
VK_FORMAT_R8G8_SINT:
return
Format::R8G8Sint
;
86
case
VK_FORMAT_R8G8B8A8_UNORM:
return
Format::R8G8B8A8Unorm
;
87
case
VK_FORMAT_R8G8B8A8_SNORM:
return
Format::R8G8B8A8Snorm
;
88
case
VK_FORMAT_R8G8B8A8_UINT:
return
Format::R8G8B8A8Uint
;
89
case
VK_FORMAT_R8G8B8A8_SINT:
return
Format::R8G8B8A8Sint
;
90
case
VK_FORMAT_R8G8B8A8_SRGB:
return
Format::R8G8B8A8Srgb
;
91
case
VK_FORMAT_B8G8R8A8_UNORM:
return
Format::B8G8R8A8Unorm
;
92
case
VK_FORMAT_B8G8R8A8_SRGB:
return
Format::B8G8R8A8Srgb
;
93
case
VK_FORMAT_A2R10G10B10_UNORM_PACK32:
return
Format::A2R10G10B10Unorm
;
94
case
VK_FORMAT_R16_SFLOAT:
return
Format::R16Float
;
95
case
VK_FORMAT_R16_UINT:
return
Format::R16Uint
;
96
case
VK_FORMAT_R16_SINT:
return
Format::R16Sint
;
97
case
VK_FORMAT_R16G16_SFLOAT:
return
Format::R16G16Float
;
98
case
VK_FORMAT_R16G16_UINT:
return
Format::R16G16Uint
;
99
case
VK_FORMAT_R16G16_SINT:
return
Format::R16G16Sint
;
100
case
VK_FORMAT_R16G16B16A16_SFLOAT:
return
Format::R16G16B16A16Float
;
101
case
VK_FORMAT_R16G16B16A16_UINT:
return
Format::R16G16B16A16Uint
;
102
case
VK_FORMAT_R16G16B16A16_SINT:
return
Format::R16G16B16A16Sint
;
103
case
VK_FORMAT_R32_UINT:
return
Format::R32Uint
;
104
case
VK_FORMAT_R32_SINT:
return
Format::R32Sint
;
105
case
VK_FORMAT_R32_SFLOAT:
return
Format::R32Float
;
106
case
VK_FORMAT_R32G32_UINT:
return
Format::R32G32Uint
;
107
case
VK_FORMAT_R32G32_SINT:
return
Format::R32G32Sint
;
108
case
VK_FORMAT_R32G32_SFLOAT:
return
Format::R32G32Float
;
109
case
VK_FORMAT_R32G32B32A32_UINT:
return
Format::R32G32B32A32Uint
;
110
case
VK_FORMAT_R32G32B32A32_SINT:
return
Format::R32G32B32A32Sint
;
111
case
VK_FORMAT_R32G32B32A32_SFLOAT:
return
Format::R32G32B32A32Float
;
112
case
VK_FORMAT_D16_UNORM:
return
Format::D16Unorm
;
113
case
VK_FORMAT_D24_UNORM_S8_UINT:
return
Format::D24UnormS8Uint
;
114
case
VK_FORMAT_D32_SFLOAT:
return
Format::D32Sfloat
;
115
case
VK_FORMAT_D32_SFLOAT_S8_UINT:
return
Format::D32SfloatS8Uint
;
116
default
:
return
Format::Undefined
;
117
}
118
}
119
}
Format.h
Shader.h
Hubris::Graphics::Vulkan
Definition
Utility.h:6
Hubris::Graphics::Vulkan::FormatToVkFormat
constexpr VkFormat FormatToVkFormat(Format format) noexcept
Definition
Utility.h:28
Hubris::Graphics::Vulkan::VkShaderStageToFlags
constexpr VkShaderStageFlagBits VkShaderStageToFlags(const ShaderStage &stage) noexcept
Definition
Utility.h:7
Hubris::Graphics::Vulkan::VkFormatToFormat
constexpr Format VkFormatToFormat(VkFormat format) noexcept
Definition
Utility.h:75
Hubris::Graphics::Format
Format
Definition
Format.h:24
Hubris::Graphics::Format::R16G16B16A16Uint
@ R16G16B16A16Uint
Definition
Format.h:57
Hubris::Graphics::Format::R8G8Unorm
@ R8G8Unorm
Definition
Format.h:32
Hubris::Graphics::Format::R32Sint
@ R32Sint
Definition
Format.h:61
Hubris::Graphics::Format::R8G8B8A8Srgb
@ R8G8B8A8Srgb
Definition
Format.h:41
Hubris::Graphics::Format::R8Unorm
@ R8Unorm
Definition
Format.h:27
Hubris::Graphics::Format::R16Sint
@ R16Sint
Definition
Format.h:50
Hubris::Graphics::Format::R8G8Uint
@ R8G8Uint
Definition
Format.h:34
Hubris::Graphics::Format::R8G8Snorm
@ R8G8Snorm
Definition
Format.h:33
Hubris::Graphics::Format::D24UnormS8Uint
@ D24UnormS8Uint
Definition
Format.h:73
Hubris::Graphics::Format::D16Unorm
@ D16Unorm
Definition
Format.h:72
Hubris::Graphics::Format::R8G8Sint
@ R8G8Sint
Definition
Format.h:35
Hubris::Graphics::Format::R32G32B32A32Float
@ R32G32B32A32Float
Definition
Format.h:70
Hubris::Graphics::Format::B8G8R8A8Unorm
@ B8G8R8A8Unorm
Definition
Format.h:43
Hubris::Graphics::Format::D32Sfloat
@ D32Sfloat
Definition
Format.h:74
Hubris::Graphics::Format::R32G32Uint
@ R32G32Uint
Definition
Format.h:64
Hubris::Graphics::Format::B8G8R8A8Srgb
@ B8G8R8A8Srgb
Definition
Format.h:44
Hubris::Graphics::Format::R32G32Float
@ R32G32Float
Definition
Format.h:66
Hubris::Graphics::Format::R8Sint
@ R8Sint
Definition
Format.h:30
Hubris::Graphics::Format::R16G16Float
@ R16G16Float
Definition
Format.h:52
Hubris::Graphics::Format::R16G16Sint
@ R16G16Sint
Definition
Format.h:54
Hubris::Graphics::Format::R16Float
@ R16Float
Definition
Format.h:48
Hubris::Graphics::Format::R16G16Uint
@ R16G16Uint
Definition
Format.h:53
Hubris::Graphics::Format::R32G32Sint
@ R32G32Sint
Definition
Format.h:65
Hubris::Graphics::Format::R8G8B8A8Sint
@ R8G8B8A8Sint
Definition
Format.h:40
Hubris::Graphics::Format::R16G16B16A16Sint
@ R16G16B16A16Sint
Definition
Format.h:58
Hubris::Graphics::Format::D32SfloatS8Uint
@ D32SfloatS8Uint
Definition
Format.h:75
Hubris::Graphics::Format::R8G8B8A8Snorm
@ R8G8B8A8Snorm
Definition
Format.h:38
Hubris::Graphics::Format::R8Uint
@ R8Uint
Definition
Format.h:29
Hubris::Graphics::Format::R32G32B32A32Sint
@ R32G32B32A32Sint
Definition
Format.h:69
Hubris::Graphics::Format::R8G8B8A8Uint
@ R8G8B8A8Uint
Definition
Format.h:39
Hubris::Graphics::Format::R16G16B16A16Float
@ R16G16B16A16Float
Definition
Format.h:56
Hubris::Graphics::Format::R32Uint
@ R32Uint
Definition
Format.h:60
Hubris::Graphics::Format::A2R10G10B10Unorm
@ A2R10G10B10Unorm
Definition
Format.h:46
Hubris::Graphics::Format::R32G32B32A32Uint
@ R32G32B32A32Uint
Definition
Format.h:68
Hubris::Graphics::Format::R8Snorm
@ R8Snorm
Definition
Format.h:28
Hubris::Graphics::Format::R16Uint
@ R16Uint
Definition
Format.h:49
Hubris::Graphics::Format::R8G8B8A8Unorm
@ R8G8B8A8Unorm
Definition
Format.h:37
Hubris::Graphics::Format::R32Float
@ R32Float
Definition
Format.h:62
Hubris::Graphics::Format::Count
@ Count
Definition
Format.h:77
Hubris::Graphics::Format::Undefined
@ Undefined
Definition
Format.h:25
Hubris::Graphics::ShaderStage
ShaderStage
Definition
Shader.h:8
Hubris::Graphics::ShaderStage::Fragment
@ Fragment
Definition
Shader.h:11
Hubris::Graphics::ShaderStage::TessellationEvaluation
@ TessellationEvaluation
Definition
Shader.h:14
Hubris::Graphics::ShaderStage::TessellationControl
@ TessellationControl
Definition
Shader.h:13
Hubris::Graphics::ShaderStage::Compute
@ Compute
Definition
Shader.h:15
Hubris::Graphics::ShaderStage::Vertex
@ Vertex
Definition
Shader.h:10
Hubris::Graphics::ShaderStage::Geometry
@ Geometry
Definition
Shader.h:12
include
Core
Graphics
Vulkan
Utility.h
Generated by
1.13.2