Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qsgrhisupport_mac.mm
Go to the documentation of this file.
1// Copyright (C) 2022 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include "qsgrhisupport_p.h"
5
6#include <Metal/MTLPixelFormat.h>
7
9
11
13{
14 auto rhiFormat = QRhiTexture::UnknownFormat;
15 bool sRGB = false;
16 switch (format) {
17 case MTLPixelFormatRGBA8Unorm_sRGB:
18 sRGB = true;
20 case MTLPixelFormatRGBA8Unorm:
21 case MTLPixelFormatInvalid:
22 rhiFormat = QRhiTexture::RGBA8;
23 break;
24 case MTLPixelFormatBGRA8Unorm_sRGB:
25 sRGB = true;
27 case MTLPixelFormatBGRA8Unorm:
28 rhiFormat = QRhiTexture::BGRA8;
29 break;
30#ifndef Q_OS_MACOS
31 case MTLPixelFormatR8Unorm_sRGB:
32 sRGB = true;
34#endif
35 case MTLPixelFormatR8Unorm:
36 rhiFormat = QRhiTexture::R8;
37 break;
38#ifndef Q_OS_MACOS
39 case MTLPixelFormatRG8Unorm_sRGB:
40 sRGB = true;
42#endif
43 case MTLPixelFormatRG8Unorm:
44 rhiFormat = QRhiTexture::RG8;
45 break;
46 case MTLPixelFormatR16Unorm:
47 rhiFormat = QRhiTexture::R16;
48 break;
49 case MTLPixelFormatRG16Unorm:
50 rhiFormat = QRhiTexture::RG16;
51 break;
52 case MTLPixelFormatRGBA16Float:
53 rhiFormat = QRhiTexture::RGBA16F;
54 break;
55 case MTLPixelFormatRGBA32Float:
56 rhiFormat = QRhiTexture::RGBA32F;
57 break;
58 case MTLPixelFormatR16Float:
59 rhiFormat = QRhiTexture::R16F;
60 break;
61 case MTLPixelFormatR32Float:
62 rhiFormat = QRhiTexture::R32F;
63 break;
64 case MTLPixelFormatRGB10A2Unorm:
65 rhiFormat = QRhiTexture::RGB10A2;
66 break;
67#ifdef Q_OS_MACOS
68 case MTLPixelFormatDepth16Unorm:
69 rhiFormat = QRhiTexture::D16;
70 break;
71 case MTLPixelFormatDepth24Unorm_Stencil8:
72 rhiFormat = QRhiTexture::D24S8;
73 break;
74#endif
75 case MTLPixelFormatDepth32Float_Stencil8:
76 rhiFormat = QRhiTexture::D24S8;
77 break;
78 case MTLPixelFormatDepth32Float:
79 rhiFormat = QRhiTexture::D32F;
80 break;
81#ifdef Q_OS_MACOS
82 case MTLPixelFormatBC1_RGBA_sRGB:
83 sRGB = true;
85 case MTLPixelFormatBC1_RGBA:
86 rhiFormat = QRhiTexture::BC1;
87 break;
88 case MTLPixelFormatBC2_RGBA_sRGB:
89 sRGB = true;
91 case MTLPixelFormatBC2_RGBA:
92 rhiFormat = QRhiTexture::BC2;
93 break;
94 case MTLPixelFormatBC3_RGBA_sRGB:
95 sRGB = true;
97 case MTLPixelFormatBC3_RGBA:
98 rhiFormat = QRhiTexture::BC3;
99 break;
100 case MTLPixelFormatBC4_RUnorm:
101 rhiFormat = QRhiTexture::BC4;
102 break;
103 case MTLPixelFormatBC6H_RGBUfloat:
104 rhiFormat = QRhiTexture::BC6H;
105 break;
106 case MTLPixelFormatBC7_RGBAUnorm_sRGB:
107 sRGB = true;
109 case MTLPixelFormatBC7_RGBAUnorm:
110 rhiFormat = QRhiTexture::BC7;
111 break;
112#endif
113#ifndef Q_OS_MACOS
114 case MTLPixelFormatETC2_RGB8_sRGB:
115 sRGB = true;
117 case MTLPixelFormatETC2_RGB8:
118 rhiFormat = QRhiTexture::ETC2_RGB8;
119 break;
120 case MTLPixelFormatETC2_RGB8A1_sRGB:
121 sRGB = true;
123 case MTLPixelFormatETC2_RGB8A1:
124 rhiFormat = QRhiTexture::ETC2_RGB8A1;
125 break;
126 case MTLPixelFormatEAC_RGBA8_sRGB:
127 sRGB = true;
129 case MTLPixelFormatEAC_RGBA8:
130 rhiFormat = QRhiTexture::ETC2_RGBA8;
131 break;
132 case MTLPixelFormatASTC_4x4_sRGB:
133 sRGB = true;
135 case MTLPixelFormatASTC_4x4_LDR:
136 rhiFormat = QRhiTexture::ASTC_4x4;
137 break;
138 case MTLPixelFormatASTC_5x4_sRGB:
139 sRGB = true;
141 case MTLPixelFormatASTC_5x4_LDR:
142 rhiFormat = QRhiTexture::ASTC_5x4;
143 break;
144 case MTLPixelFormatASTC_5x5_sRGB:
145 sRGB = true;
147 case MTLPixelFormatASTC_5x5_LDR:
148 rhiFormat = QRhiTexture::ASTC_5x5;
149 break;
150 case MTLPixelFormatASTC_6x5_sRGB:
151 sRGB = true;
153 case MTLPixelFormatASTC_6x5_LDR:
154 rhiFormat = QRhiTexture::ASTC_6x5;
155 break;
156 case MTLPixelFormatASTC_6x6_sRGB:
157 sRGB = true;
159 case MTLPixelFormatASTC_6x6_LDR:
160 rhiFormat = QRhiTexture::ASTC_6x6;
161 break;
162 case MTLPixelFormatASTC_8x5_sRGB:
163 sRGB = true;
165 case MTLPixelFormatASTC_8x5_LDR:
166 rhiFormat = QRhiTexture::ASTC_8x5;
167 break;
168 case MTLPixelFormatASTC_8x6_sRGB:
169 sRGB = true;
171 case MTLPixelFormatASTC_8x6_LDR:
172 rhiFormat = QRhiTexture::ASTC_8x6;
173 break;
174 case MTLPixelFormatASTC_8x8_sRGB:
175 sRGB = true;
177 case MTLPixelFormatASTC_8x8_LDR:
178 rhiFormat = QRhiTexture::ASTC_8x8;
179 break;
180 case MTLPixelFormatASTC_10x5_sRGB:
181 sRGB = true;
183 case MTLPixelFormatASTC_10x5_LDR:
184 rhiFormat = QRhiTexture::ASTC_10x5;
185 break;
186 case MTLPixelFormatASTC_10x6_sRGB:
187 sRGB = true;
189 case MTLPixelFormatASTC_10x6_LDR:
190 rhiFormat = QRhiTexture::ASTC_10x6;
191 break;
192 case MTLPixelFormatASTC_10x8_sRGB:
193 sRGB = true;
195 case MTLPixelFormatASTC_10x8_LDR:
196 rhiFormat = QRhiTexture::ASTC_10x8;
197 break;
198 case MTLPixelFormatASTC_10x10_sRGB:
199 sRGB = true;
201 case MTLPixelFormatASTC_10x10_LDR:
202 rhiFormat = QRhiTexture::ASTC_10x10;
203 break;
204 case MTLPixelFormatASTC_12x10_sRGB:
205 sRGB = true;
207 case MTLPixelFormatASTC_12x10_LDR:
208 rhiFormat = QRhiTexture::ASTC_12x10;
209 break;
210 case MTLPixelFormatASTC_12x12_sRGB:
211 sRGB = true;
213 case MTLPixelFormatASTC_12x12_LDR:
214 rhiFormat = QRhiTexture::ASTC_12x12;
215 break;
216#endif
217 default:
218 qWarning("MTLPixelFormat %d is not supported", format);
219 break;
220 }
221 if (sRGB)
222 (*flags) |=(QRhiTexture::sRGB);
223 return rhiFormat;
224}
225
226}
227
Format
Specifies the texture format.
Definition qrhi.h:914
@ ASTC_10x8
Definition qrhi.h:959
@ ASTC_12x12
Definition qrhi.h:962
@ ASTC_8x5
Definition qrhi.h:954
@ ASTC_10x5
Definition qrhi.h:957
@ RGBA32F
Definition qrhi.h:926
@ ETC2_RGBA8
Definition qrhi.h:947
@ ASTC_5x5
Definition qrhi.h:951
@ ASTC_4x4
Definition qrhi.h:949
@ ASTC_6x6
Definition qrhi.h:953
@ ASTC_12x10
Definition qrhi.h:961
@ ETC2_RGB8
Definition qrhi.h:945
@ ASTC_5x4
Definition qrhi.h:950
@ ASTC_6x5
Definition qrhi.h:952
@ ASTC_8x8
Definition qrhi.h:956
@ RGBA16F
Definition qrhi.h:925
@ RGB10A2
Definition qrhi.h:930
@ ASTC_10x6
Definition qrhi.h:958
@ ASTC_10x10
Definition qrhi.h:960
@ UnknownFormat
Definition qrhi.h:915
@ ETC2_RGB8A1
Definition qrhi.h:946
@ ASTC_8x6
Definition qrhi.h:955
QRhiTexture::Format toRhiTextureFormatFromMetal(uint format, QRhiTexture::Flags *flags)
Combined button and popup list for selecting options.
#define Q_FALLTHROUGH()
#define qWarning
Definition qlogging.h:166
GLbitfield flags
GLint GLsizei GLsizei GLenum format
unsigned int uint
Definition qtypes.h:34