blob: 02e5d860508b039ed8cc00f26c05ec13e8986d4a [file] [log] [blame]
Nicolas Capens0bac2852016-05-07 06:09:58 -04001// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
Nicolas Capensee16f0d2015-07-16 17:40:10 -04002//
Nicolas Capens0bac2852016-05-07 06:09:58 -04003// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
Nicolas Capensee16f0d2015-07-16 17:40:10 -04006//
Nicolas Capens0bac2852016-05-07 06:09:58 -04007// http://www.apache.org/licenses/LICENSE-2.0
Nicolas Capensee16f0d2015-07-16 17:40:10 -04008//
Nicolas Capens0bac2852016-05-07 06:09:58 -04009// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
Nicolas Capensee16f0d2015-07-16 17:40:10 -040014
15#ifndef D3D9_Capabilities_hpp
16#define D3D9_Capabilities_hpp
17
Nicolas Capensec0936c2016-05-18 12:32:02 -040018#include "Config.hpp"
19#include "MetaMacro.hpp"
20
Nicolas Capensee16f0d2015-07-16 17:40:10 -040021#include <d3d9.h>
22
23namespace D3D9
24{
25 enum
26 {
27 D3DFMT_ATI1 = MAKEFOURCC('A', 'T', 'I', '1'),
28 D3DFMT_ATI2 = MAKEFOURCC('A', 'T', 'I', '2'),
29 D3DFMT_INST = MAKEFOURCC('I', 'N', 'S', 'T'),
30 D3DFMT_DF24 = MAKEFOURCC('D', 'F', '2', '4'),
31 D3DFMT_DF16 = MAKEFOURCC('D', 'F', '1', '6'),
32 D3DFMT_NULL = MAKEFOURCC('N', 'U', 'L', 'L'),
33 D3DFMT_GET4 = MAKEFOURCC('G', 'E', 'T', '4'),
34 D3DFMT_GET1 = MAKEFOURCC('G', 'E', 'T', '1'),
35 D3DFMT_NVDB = MAKEFOURCC('N', 'V', 'D', 'B'),
36 D3DFMT_A2M1 = MAKEFOURCC('A', '2', 'M', '1'),
37 D3DFMT_A2M0 = MAKEFOURCC('A', '2', 'M', '0'),
38 D3DFMT_ATOC = MAKEFOURCC('A', 'T', 'O', 'C'),
39 D3DFMT_INTZ = MAKEFOURCC('I', 'N', 'T', 'Z')
40 };
41
42 struct Capabilities
43 {
44 struct Surface
45 {
46 struct RenderTarget
47 {
48 static bool NULL_;
49 static bool R8G8B8;
50 static bool R5G6B5;
51 static bool X1R5G5B5;
52 static bool A1R5G5B5;
53 static bool A4R4G4B4;
54 static bool R3G3B2;
55 static bool A8R3G3B2;
56 static bool X4R4G4B4;
57 static bool A8R8G8B8;
58 static bool X8R8G8B8;
59 static bool A8B8G8R8;
60 static bool X8B8G8R8;
61 // Integer HDR formats
62 static bool G16R16;
63 static bool A2B10G10R10;
64 static bool A2R10G10B10;
65 static bool A16B16G16R16;
66 // Floating-point formats
67 static bool R16F;
68 static bool G16R16F;
69 static bool A16B16G16R16F;
70 static bool R32F;
71 static bool G32R32F;
72 static bool A32B32G32R32F;
73 };
74
75 struct DepthStencil
76 {
77 static bool D32;
78 static bool D24S8;
79 static bool D24X8;
80 static bool D16;
81 static bool D24FS8;
82 static bool D32F_LOCKABLE;
83 static bool DF24;
84 static bool DF16;
85 static bool INTZ;
86 };
87
88 static bool A8;
89 static bool R5G6B5;
90 static bool X1R5G5B5;
91 static bool A1R5G5B5;
92 static bool A4R4G4B4;
93 static bool R3G3B2;
94 static bool A8R3G3B2;
95 static bool X4R4G4B4;
96 static bool R8G8B8;
97 static bool X8R8G8B8;
98 static bool A8R8G8B8;
99 static bool A8B8G8R8;
100 static bool X8B8G8R8;
101 // Paletted formats
102 static bool P8;
103 static bool A8P8;
104 // Integer HDR formats
105 static bool G16R16;
106 static bool A2R10G10B10;
107 static bool A2B10G10R10;
108 static bool A16B16G16R16;
109 // Compressed formats
110 static bool DXT1;
111 static bool DXT2;
112 static bool DXT3;
113 static bool DXT4;
114 static bool DXT5;
115 static bool ATI1;
116 static bool ATI2;
117 // Floating-point formats
118 static bool R16F;
119 static bool G16R16F;
120 static bool A16B16G16R16F;
121 static bool R32F;
122 static bool G32R32F;
123 static bool A32B32G32R32F;
124 // Bump map formats
125 static bool V8U8;
126 static bool L6V5U5;
127 static bool X8L8V8U8;
128 static bool Q8W8V8U8;
129 static bool V16U16;
130 static bool A2W10V10U10;
131 static bool Q16W16V16U16;
132 // Luminance formats
133 static bool L8;
134 static bool A4L4;
135 static bool L16;
136 static bool A8L8;
137 // Depth Bounds Test
138 static bool NVDB;
139 // Transparency anti-aliasing
140 static bool ATOC;
141 };
142
143 struct Volume
144 {
145 static bool A8;
146 static bool R5G6B5;
147 static bool X1R5G5B5;
148 static bool A1R5G5B5;
149 static bool A4R4G4B4;
150 static bool R3G3B2;
151 static bool A8R3G3B2;
152 static bool X4R4G4B4;
153 static bool R8G8B8;
154 static bool X8R8G8B8;
155 static bool A8R8G8B8;
156 static bool A8B8G8R8;
157 static bool X8B8G8R8;
158 // Paletted formats
159 static bool P8;
160 static bool A8P8;
161 // Integer HDR formats
162 static bool G16R16;
163 static bool A2R10G10B10;
164 static bool A2B10G10R10;
165 static bool A16B16G16R16;
166 // Compressed formats
167 static bool DXT1;
168 static bool DXT2;
169 static bool DXT3;
170 static bool DXT4;
171 static bool DXT5;
172 static bool ATI1;
173 static bool ATI2;
174 // Floating-point formats
175 static bool R16F;
176 static bool G16R16F;
177 static bool A16B16G16R16F;
178 static bool R32F;
179 static bool G32R32F;
180 static bool A32B32G32R32F;
181 // Bump map formats
182 static bool V8U8;
183 static bool L6V5U5;
184 static bool X8L8V8U8;
185 static bool Q8W8V8U8;
186 static bool V16U16;
187 static bool A2W10V10U10;
188 static bool Q16W16V16U16;
189 // Luminance formats
190 static bool L8;
191 static bool A4L4;
192 static bool L16;
193 static bool A8L8;
194 };
195
196 struct CubeMap
197 {
198 struct RenderTarget
199 {
200 static bool NULL_;
201 static bool R8G8B8;
202 static bool R5G6B5;
203 static bool X1R5G5B5;
204 static bool A1R5G5B5;
205 static bool A4R4G4B4;
206 static bool R3G3B2;
207 static bool A8R3G3B2;
208 static bool X4R4G4B4;
209 static bool A8R8G8B8;
210 static bool X8R8G8B8;
211 static bool A8B8G8R8;
212 static bool X8B8G8R8;
213 // Integer HDR formats
214 static bool G16R16;
215 static bool A2B10G10R10;
216 static bool A2R10G10B10;
217 static bool A16B16G16R16;
218 // Floating-point formats
219 static bool R16F;
220 static bool G16R16F;
221 static bool A16B16G16R16F;
222 static bool R32F;
223 static bool G32R32F;
224 static bool A32B32G32R32F;
225 };
226
227 struct DepthStencil
228 {
229 static bool D32;
230 static bool D24S8;
231 static bool D24X8;
232 static bool D16;
233 static bool D24FS8;
234 static bool D32F_LOCKABLE;
235 static bool DF24;
236 static bool DF16;
237 static bool INTZ;
238 };
239
240 static bool A8;
241 static bool R5G6B5;
242 static bool X1R5G5B5;
243 static bool A1R5G5B5;
244 static bool A4R4G4B4;
245 static bool R3G3B2;
246 static bool A8R3G3B2;
247 static bool X4R4G4B4;
248 static bool R8G8B8;
249 static bool X8R8G8B8;
250 static bool A8R8G8B8;
251 static bool A8B8G8R8;
252 static bool X8B8G8R8;
253 // Paletted formats
254 static bool P8;
255 static bool A8P8;
256 // Integer HDR formats
257 static bool G16R16;
258 static bool A2R10G10B10;
259 static bool A2B10G10R10;
260 static bool A16B16G16R16;
261 // Compressed formats
262 static bool DXT1;
263 static bool DXT2;
264 static bool DXT3;
265 static bool DXT4;
266 static bool DXT5;
267 static bool ATI1;
268 static bool ATI2;
269 // Floating-point formats
270 static bool R16F;
271 static bool G16R16F;
272 static bool A16B16G16R16F;
273 static bool R32F;
274 static bool G32R32F;
275 static bool A32B32G32R32F;
276 // Bump map formats
277 static bool V8U8;
278 static bool L6V5U5;
279 static bool X8L8V8U8;
280 static bool Q8W8V8U8;
281 static bool V16U16;
282 static bool A2W10V10U10;
283 static bool Q16W16V16U16;
284 // Luminance formats
285 static bool L8;
286 static bool A4L4;
287 static bool L16;
288 static bool A8L8;
289 };
290
291 struct VolumeTexture
292 {
293 static bool A8;
294 static bool R5G6B5;
295 static bool X1R5G5B5;
296 static bool A1R5G5B5;
297 static bool A4R4G4B4;
298 static bool R3G3B2;
299 static bool A8R3G3B2;
300 static bool X4R4G4B4;
301 static bool R8G8B8;
302 static bool X8R8G8B8;
303 static bool A8R8G8B8;
304 static bool A8B8G8R8;
305 static bool X8B8G8R8;
306 // Paletted formats
307 static bool P8;
308 static bool A8P8;
309 // Integer HDR formats
310 static bool G16R16;
311 static bool A2R10G10B10;
312 static bool A2B10G10R10;
313 static bool A16B16G16R16;
314 // Compressed formats
315 static bool DXT1;
316 static bool DXT2;
317 static bool DXT3;
318 static bool DXT4;
319 static bool DXT5;
320 static bool ATI1;
321 static bool ATI2;
322 // Floating-point formats
323 static bool R16F;
324 static bool G16R16F;
325 static bool A16B16G16R16F;
326 static bool R32F;
327 static bool G32R32F;
328 static bool A32B32G32R32F;
329 // Bump map formats
330 static bool V8U8;
331 static bool L6V5U5;
332 static bool X8L8V8U8;
333 static bool Q8W8V8U8;
334 static bool V16U16;
335 static bool A2W10V10U10;
336 static bool Q16W16V16U16;
337 // Luminance formats
338 static bool L8;
339 static bool A4L4;
340 static bool L16;
341 static bool A8L8;
342 };
343
344 struct Texture
345 {
346 struct RenderTarget
347 {
348 static bool NULL_;
349 static bool R8G8B8;
350 static bool R5G6B5;
351 static bool X1R5G5B5;
352 static bool A1R5G5B5;
353 static bool A4R4G4B4;
354 static bool R3G3B2;
355 static bool A8R3G3B2;
356 static bool X4R4G4B4;
357 static bool A8R8G8B8;
358 static bool X8R8G8B8;
359 static bool A8B8G8R8;
360 static bool X8B8G8R8;
361 // Integer HDR formats
362 static bool G16R16;
363 static bool A2B10G10R10;
364 static bool A2R10G10B10;
365 static bool A16B16G16R16;
366 // Floating-point formats
367 static bool R16F;
368 static bool G16R16F;
369 static bool A16B16G16R16F;
370 static bool R32F;
371 static bool G32R32F;
372 static bool A32B32G32R32F;
373 };
374
375 struct DepthStencil
376 {
377 static bool D32;
378 static bool D24S8;
379 static bool D24X8;
380 static bool D16;
381 static bool D24FS8;
382 static bool D32F_LOCKABLE;
383 static bool DF24;
384 static bool DF16;
385 static bool INTZ;
386 };
387
388 static bool NULL_;
389 static bool A8;
390 static bool R5G6B5;
391 static bool X1R5G5B5;
392 static bool A1R5G5B5;
393 static bool A4R4G4B4;
394 static bool R3G3B2;
395 static bool A8R3G3B2;
396 static bool X4R4G4B4;
397 static bool R8G8B8;
398 static bool X8R8G8B8;
399 static bool A8R8G8B8;
400 static bool A8B8G8R8;
401 static bool X8B8G8R8;
402 // Paletted formats
403 static bool P8;
404 static bool A8P8;
405 // Integer HDR formats
406 static bool G16R16;
407 static bool A2R10G10B10;
408 static bool A2B10G10R10;
409 static bool A16B16G16R16;
410 // Compressed formats
411 static bool DXT1;
412 static bool DXT2;
413 static bool DXT3;
414 static bool DXT4;
415 static bool DXT5;
416 static bool ATI1;
417 static bool ATI2;
418 // Floating-point formats
419 static bool R16F;
420 static bool G16R16F;
421 static bool A16B16G16R16F;
422 static bool R32F;
423 static bool G32R32F;
424 static bool A32B32G32R32F;
425 // Bump map formats
426 static bool V8U8;
427 static bool L6V5U5;
428 static bool X8L8V8U8;
429 static bool Q8W8V8U8;
430 static bool V16U16;
431 static bool A2W10V10U10;
432 static bool Q16W16V16U16;
433 // Luminance formats
434 static bool L8;
435 static bool A4L4;
436 static bool L16;
437 static bool A8L8;
438 // Depth formats
439 static bool D32;
440 static bool D24S8;
441 static bool D24X8;
442 static bool D16;
443 static bool D24FS8;
444 static bool D32F_LOCKABLE;
445 static bool DF24;
446 static bool DF16;
447 static bool INTZ;
448 };
449
450 static bool isSRGBreadable(D3DFORMAT format);
451 static bool isSRGBwritable(D3DFORMAT format);
452 };
453
454 extern unsigned int pixelShaderVersionX;
455 extern unsigned int vertexShaderVersionX;
456
457 extern unsigned long pixelShaderArbitrarySwizzle;
458 extern unsigned long pixelShaderGradientInstructions;
459 extern unsigned long pixelShaderPredication;
460 extern unsigned long pixelShaderNoDependentReadLimit;
461 extern unsigned long pixelShaderNoTexInstructionLimit;
462
463 extern unsigned long pixelShaderDynamicFlowControlDepth;
464 extern unsigned long pixelShaderStaticFlowControlDepth;
465
466 extern unsigned long vertexShaderPredication;
467 extern unsigned long vertexShaderDynamicFlowControlDepth;
468
469 extern unsigned int textureMemory;
470 extern unsigned int maxAnisotropy;
Nicolas Capensec0936c2016-05-18 12:32:02 -0400471
472 enum
473 {
474 MAX_VERTEX_SHADER_CONST = 256,
475 MAX_PIXEL_SHADER_CONST = 224,
476 MAX_VERTEX_OUTPUTS = 12,
Nicolas Capens3b4c93f2016-05-18 12:51:37 -0400477 MAX_PIXEL_INPUTS = 10,
Nicolas Capensec0936c2016-05-18 12:32:02 -0400478 };
479
480 // Shader Model 3.0 requirements
481 META_ASSERT(MAX_VERTEX_SHADER_CONST >= 256);
482 META_ASSERT(MAX_PIXEL_SHADER_CONST == 224);
483 META_ASSERT(MAX_VERTEX_OUTPUTS == 12);
Nicolas Capens3b4c93f2016-05-18 12:51:37 -0400484 META_ASSERT(MAX_PIXEL_INPUTS == 10);
Nicolas Capensec0936c2016-05-18 12:32:02 -0400485
486 // Back-end minimum requirements
487 META_ASSERT(sw::VERTEX_UNIFORM_VECTORS >= MAX_VERTEX_SHADER_CONST);
488 META_ASSERT(sw::FRAGMENT_UNIFORM_VECTORS >= MAX_PIXEL_SHADER_CONST);
489 META_ASSERT(sw::MAX_VERTEX_OUTPUTS >= MAX_VERTEX_OUTPUTS);
Nicolas Capens3b4c93f2016-05-18 12:51:37 -0400490 META_ASSERT(sw::MAX_FRAGMENT_INPUTS >= MAX_PIXEL_INPUTS);
Nicolas Capensee16f0d2015-07-16 17:40:10 -0400491}
492
493#endif // D3D9_Capabilities_hpp