Photon Editor Library 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
ghi_enums.ipp
Go to the documentation of this file.
1#pragma once
2
4
5#include <Common/assertion.h>
6
7#include <type_traits>
8
9namespace ph::editor::ghi
10{
11
12inline std::size_t num_bytes(ESizedPixelFormat sizedFormat)
13{
14 switch(sizedFormat)
15 {
16 case ESizedPixelFormat::Empty: return 0;
17 case ESizedPixelFormat::RGB_8: return 3 * 1;
18 case ESizedPixelFormat::RGBA_8: return 4 * 1;
19 case ESizedPixelFormat::RGB_16F: return 3 * 2;
20 case ESizedPixelFormat::RGBA_16F: return 4 * 2;
21 case ESizedPixelFormat::RGB_32F: return 3 * 4;
22 case ESizedPixelFormat::RGBA_32F: return 4 * 4;
24 default: PH_ASSERT_UNREACHABLE_SECTION(); return 0;
25 }
26}
27
28inline std::size_t num_bytes(EPixelComponent component)
29{
30 switch(component)
31 {
32 case EPixelComponent::Empty: return 0;
33 case EPixelComponent::Int8: return 1;
34 case EPixelComponent::UInt8: return 1;
35 case EPixelComponent::Int16: return 2;
36 case EPixelComponent::UInt16: return 2;
37 case EPixelComponent::Int32: return 4;
38 case EPixelComponent::UInt32: return 4;
39 case EPixelComponent::Int64: return 8;
40 case EPixelComponent::UInt64: return 8;
41 case EPixelComponent::Float16: return 2;
42 case EPixelComponent::Float32: return 4;
43 case EPixelComponent::Float64: return 8;
44 default: PH_ASSERT_UNREACHABLE_SECTION(); return 0;
45 }
46}
47
48inline std::size_t num_bytes(EStorageElement element)
49{
50 switch(element)
51 {
52 case EStorageElement::Empty: return 0;
53 case EStorageElement::Int8: return 1;
54 case EStorageElement::UInt8: return 1;
55 case EStorageElement::Int16: return 2;
56 case EStorageElement::UInt16: return 2;
57 case EStorageElement::Int32: return 4;
58 case EStorageElement::UInt32: return 4;
59 case EStorageElement::Int64: return 8;
60 case EStorageElement::UInt64: return 8;
61 case EStorageElement::Float16: return 2;
62 case EStorageElement::Float32: return 4;
63 case EStorageElement::Float64: return 8;
64 default: PH_ASSERT_UNREACHABLE_SECTION(); return 0;
65 }
66}
67
68template<CEnum DstEnumType>
69DstEnumType translate_to(EPicturePixelComponent pictureComponent)
70{
71 if constexpr(std::is_same_v<DstEnumType, EPixelComponent>)
72 {
73 switch(pictureComponent)
74 {
75 case EPicturePixelComponent::Empty: return EPixelComponent::Empty;
76 case EPicturePixelComponent::Int8: return EPixelComponent::Int8;
77 case EPicturePixelComponent::UInt8: return EPixelComponent::UInt8;
78 case EPicturePixelComponent::Int16: return EPixelComponent::Int16;
79 case EPicturePixelComponent::UInt16: return EPixelComponent::UInt16;
80 case EPicturePixelComponent::Int32: return EPixelComponent::Int32;
81 case EPicturePixelComponent::UInt32: return EPixelComponent::UInt32;
82 case EPicturePixelComponent::Int64: return EPixelComponent::Int64;
83 case EPicturePixelComponent::UInt64: return EPixelComponent::UInt64;
84 case EPicturePixelComponent::Float16: return EPixelComponent::Float16;
85 case EPicturePixelComponent::Float32: return EPixelComponent::Float32;
86 case EPicturePixelComponent::Float64: return EPixelComponent::Float64;
87 default: PH_ASSERT_UNREACHABLE_SECTION(); return EPixelComponent::Empty;
88 }
89 }
90 else
91 {
92 PH_ASSERT_UNREACHABLE_SECTION();
93 return static_cast<DstEnumType>(0);
94 }
95}
96
97}// end namespace ph::editor::ghi
Definition PlatformDisplay.h:13
ESizedPixelFormat
Combined pixel layout and component type information. Unless stated explicitly, the characters RGB do...
Definition ghi_enums.h:19
EStorageElement
Definition ghi_enums.h:70
DstEnumType translate_to(EPicturePixelComponent pictureComponent)
Definition ghi_enums.ipp:69
EPixelComponent
Definition ghi_enums.h:42
std::size_t num_bytes(ESizedPixelFormat sizedFormat)
Definition ghi_enums.ipp:12