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