webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
texture_format_table_utils.h
Go to the documentation of this file.
1 //
2 // Copyright 2016 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 // Helper routines for the D3D11 texture format table.
7 
8 #ifndef LIBANGLE_RENDERER_D3D_D3D11_TEXTURE_FORMAT_TABLE_UTILS_H_
9 #define LIBANGLE_RENDERER_D3D_D3D11_TEXTURE_FORMAT_TABLE_UTILS_H_
10 
12 
13 namespace rx
14 {
15 
16 namespace d3d11
17 {
18 
19 using FormatSupportFunction = bool (*)(const Renderer11DeviceCaps &);
20 
21 inline bool OnlyFL10Plus(const Renderer11DeviceCaps &deviceCaps)
22 {
23  return (deviceCaps.featureLevel >= D3D_FEATURE_LEVEL_10_0);
24 }
25 
26 inline bool OnlyFL9_3(const Renderer11DeviceCaps &deviceCaps)
27 {
28  return (deviceCaps.featureLevel == D3D_FEATURE_LEVEL_9_3);
29 }
30 
31 inline bool SupportsFormat(DXGI_FORMAT format, const Renderer11DeviceCaps &deviceCaps)
32 {
33  // Must support texture, SRV and RTV support
34  UINT mustSupport = D3D11_FORMAT_SUPPORT_TEXTURE2D | D3D11_FORMAT_SUPPORT_TEXTURECUBE |
35  D3D11_FORMAT_SUPPORT_SHADER_SAMPLE | D3D11_FORMAT_SUPPORT_MIP |
36  D3D11_FORMAT_SUPPORT_RENDER_TARGET;
37 
39  {
40  mustSupport |= D3D11_FORMAT_SUPPORT_TEXTURE3D;
41  }
42 
43  bool fullSupport = false;
44  if (format == DXGI_FORMAT_B5G6R5_UNORM)
45  {
46  // All hardware that supports DXGI_FORMAT_B5G6R5_UNORM should support autogen mipmaps, but
47  // check anyway.
48  mustSupport |= D3D11_FORMAT_SUPPORT_MIP_AUTOGEN;
49  fullSupport = ((deviceCaps.B5G6R5support & mustSupport) == mustSupport);
50  }
51  else if (format == DXGI_FORMAT_B4G4R4A4_UNORM)
52  {
53  fullSupport = ((deviceCaps.B4G4R4A4support & mustSupport) == mustSupport);
54  }
55  else if (format == DXGI_FORMAT_B5G5R5A1_UNORM)
56  {
57  fullSupport = ((deviceCaps.B5G5R5A1support & mustSupport) == mustSupport);
58  }
59  else
60  {
61  UNREACHABLE();
62  return false;
63  }
64 
65  // This means that ANGLE would like to use the entry in the map if the inputted DXGI format
66  // *IS* supported.
67  // e.g. the entry might map GL_RGB5_A1 to DXGI_FORMAT_B5G5R5A1, which should only be used if
68  // DXGI_FORMAT_B5G5R5A1 is supported.
69  // In this case, we should only return 'true' if the format *IS* supported.
70  return fullSupport;
71 }
72 
73 } // namespace d3d11
74 
75 } // namespace rx
76 
77 #endif // LIBANGLE_RENDERER_D3D_D3D11_TEXTURE_FORMAT_TABLE_UTILS_H_
UINT B4G4R4A4support
Definition: Renderer11.h:53
GLint GLint GLint GLsizei GLsizei GLenum format
Definition: gl2.h:403
bool OnlyFL9_3(const Renderer11DeviceCaps &deviceCaps)
Definition: texture_format_table_utils.h:26
bool OnlyFL10Plus(const Renderer11DeviceCaps &deviceCaps)
Definition: texture_format_table_utils.h:21
GLint GetMaximumClientVersion(D3D_FEATURE_LEVEL featureLevel)
Definition: renderer11_utils.cpp:1025
#define UNREACHABLE
Definition: utils.h:36
Definition: mathutil.h:804
Definition: Renderer11.h:46
D3D_FEATURE_LEVEL featureLevel
Definition: Renderer11.h:48
bool(*)(const Renderer11DeviceCaps &) FormatSupportFunction
Definition: texture_format_table_utils.h:19
UINT B5G5R5A1support
Definition: Renderer11.h:54
bool SupportsFormat(DXGI_FORMAT format, const Renderer11DeviceCaps &deviceCaps)
Definition: texture_format_table_utils.h:31
UINT B5G6R5support
Definition: Renderer11.h:52