Plasma Engine  2.0
Loading...
Searching...
No Matches
ResourceFormats_inl.h
1
2// static
3PL_ALWAYS_INLINE plUInt32 plGALResourceFormat::GetBitsPerElement(plGALResourceFormat::Enum format)
4{
5 return s_BitsPerElement[format];
6}
7
8// static
9PL_ALWAYS_INLINE plUInt8 plGALResourceFormat::GetChannelCount(plGALResourceFormat::Enum format)
10{
11 return s_ChannelCount[format];
12}
13
14// static
15PL_FORCE_INLINE bool plGALResourceFormat::IsDepthFormat(plGALResourceFormat::Enum format)
16{
17 return format == DFloat || format == D16 || format == D24S8;
18}
19
20// static
21PL_FORCE_INLINE bool plGALResourceFormat::IsStencilFormat(Enum format)
22{
23 return format == D24S8;
24}
25
26// static
27PL_FORCE_INLINE bool plGALResourceFormat::IsSrgb(plGALResourceFormat::Enum format)
28{
29 return format == BGRAUByteNormalizedsRGB || format == RGBAUByteNormalizedsRGB || format == BC1sRGB || format == BC2sRGB || format == BC3sRGB ||
30 format == BC7UNormalizedsRGB;
31}
32
33PL_FORCE_INLINE bool plGALResourceFormat::IsIntegerFormat(Enum format)
34{
35 switch (format)
36 {
37 // D16 is actually a 16 bit unorm format
38 case plGALResourceFormat::D16:
39 // 32bit, 4 channel
40 case plGALResourceFormat::RGBAUInt:
41 case plGALResourceFormat::RGBAInt:
42 // 32bit, 3 channel
43 case plGALResourceFormat::RGBUInt:
44 case plGALResourceFormat::RGBInt:
45 // 16bit, 4 channel
46 case plGALResourceFormat::RGBAUShort:
47 case plGALResourceFormat::RGBAShort:
48 // 16bit, 2 channel
49 case plGALResourceFormat::RGUInt:
50 case plGALResourceFormat::RGInt:
51 // packed 32bit, 4 channel
52 case plGALResourceFormat::RGB10A2UInt:
53 // 8bit, 4 channel
54 case plGALResourceFormat::RGBAUByte:
55 case plGALResourceFormat::RGBAByte:
56 // 16bit, 2 channel
57 case plGALResourceFormat::RGUShort:
58 case plGALResourceFormat::RGShort:
59 // 8bit, 2 channel
60 case plGALResourceFormat::RGUByte:
61 case plGALResourceFormat::RGByte:
62 // 32bit, 1 channel
63 case plGALResourceFormat::RUInt:
64 case plGALResourceFormat::RInt:
65 // 16bit, 1 channel
66 case plGALResourceFormat::RUShort:
67 case plGALResourceFormat::RShort:
68 // 8bit, 1 channel
69 case plGALResourceFormat::RUByte:
70 case plGALResourceFormat::RByte:
71 return true;
72 default:
73 return false;
74 }
75}
76
77PL_FORCE_INLINE bool plGALResourceFormat::IsSignedFormat(Enum format)
78{
79 switch (format)
80 {
81 case RGBAFloat:
82 case RGBAInt:
83 case RGBFloat:
84 case RGBInt:
85 case RGBAHalf:
86 case RGBAShort:
87 case RGBAShortNormalized:
88 case RGFloat:
89 case RGInt:
90 case RGB10A2UIntNormalized:
91 case RG11B10Float:
92 case RGBAByteNormalized:
93 case RGBAByte:
94 case RGHalf:
95 case RGShort:
96 case RGShortNormalized:
97 case RGByte:
98 case RGByteNormalized:
99 case RFloat:
100 case RInt:
101 case RHalf:
102 case RShort:
103 case RShortNormalized:
104 case RByte:
105 case RByteNormalized:
106 case BC4Normalized:
107 case BC5Normalized:
108 case BC6Float:
109 return true;
110 default:
111 return false;
112 }
113}
114
115template <typename NativeFormatType, NativeFormatType InvalidFormat>
117 : m_eStorage(InvalidFormat)
118 , m_eRenderTarget(InvalidFormat)
119 , m_eDepthOnlyType(InvalidFormat)
120 , m_eStencilOnlyType(InvalidFormat)
121 , m_eDepthStencilType(InvalidFormat)
122 , m_eVertexAttributeType(InvalidFormat)
123 , m_eResourceViewType(InvalidFormat)
124{
125}
126
127
128template <typename NativeFormatType, NativeFormatType InvalidFormat>
130 : m_eStorage(storage)
131 , m_eRenderTarget(InvalidFormat)
132 , m_eDepthOnlyType(InvalidFormat)
133 , m_eStencilOnlyType(InvalidFormat)
134 , m_eDepthStencilType(InvalidFormat)
135 , m_eVertexAttributeType(InvalidFormat)
136 , m_eResourceViewType(InvalidFormat)
137{
138}
139
140template <typename NativeFormatType, NativeFormatType InvalidFormat>
142 NativeFormatType renderTargetType)
143{
144 m_eRenderTarget = renderTargetType;
145 return *this;
146}
147
148template <typename NativeFormatType, NativeFormatType InvalidFormat>
150{
151 m_eDepthOnlyType = depthOnlyType;
152 return *this;
153}
154
155template <typename NativeFormatType, NativeFormatType InvalidFormat>
157{
158 m_eStencilOnlyType = stencilOnlyType;
159 return *this;
160}
161
162template <typename NativeFormatType, NativeFormatType InvalidFormat>
164 NativeFormatType depthStencilType)
165{
166 m_eDepthStencilType = depthStencilType;
167 return *this;
168}
169
170template <typename NativeFormatType, NativeFormatType InvalidFormat>
172 NativeFormatType vertexAttributeType)
173{
174 m_eVertexAttributeType = vertexAttributeType;
175 return *this;
176}
177
178template <typename NativeFormatType, NativeFormatType InvalidFormat>
180 NativeFormatType resourceViewType)
181{
182 m_eResourceViewType = resourceViewType;
183 return *this;
184}
185
186
187template <typename FormatClass>
189{
190 for (plUInt32 i = 0; i < plGALResourceFormat::ENUM_COUNT; i++)
191 {
192 m_Formats[i] = FormatClass();
193 }
194}
195
196template <typename FormatClass>
197const FormatClass& plGALFormatLookupTable<FormatClass>::GetFormatInfo(plGALResourceFormat::Enum format) const
198{
199 return m_Formats[format];
200}
201
202template <typename FormatClass>
203void plGALFormatLookupTable<FormatClass>::SetFormatInfo(plGALResourceFormat::Enum format, const FormatClass& newFormatInfo)
204{
205 m_Formats[format] = newFormatInfo;
206}
Definition ResourceFormats.h:136
Definition ResourceFormats.h:166
static bool IsIntegerFormat(plGALResourceFormat::Enum format)
Returns whether the given resource format returns integer values when sampled (e.g....
Definition ResourceFormats_inl.h:33
static plUInt8 GetChannelCount(plGALResourceFormat::Enum format)
The number of color channels this format contains.
Definition ResourceFormats_inl.h:9
static bool IsDepthFormat(plGALResourceFormat::Enum format)
Returns whether the given resource format is a depth format.
Definition ResourceFormats_inl.h:15
static bool IsSignedFormat(plGALResourceFormat::Enum format)
Returns whether the given resource format can store negative values.
Definition ResourceFormats_inl.h:77
static plUInt32 GetBitsPerElement(plGALResourceFormat::Enum format)
The size in bits per element (usually pixels, except for mesh stream elements) of a single element of...
Definition ResourceFormats_inl.h:3