daniel@transgaming.com | feae9b3 | 2012-11-28 19:34:56 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright (c) 2012 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 | |
| 7 | // renderer11_utils.h: Conversion functions and other utility routines |
| 8 | // specific to the D3D11 renderer. |
| 9 | |
shannon.woods@transgaming.com | f5f5949 | 2013-02-28 23:04:40 +0000 | [diff] [blame^] | 10 | #ifndef LIBGLESV2_RENDERER_RENDERER11_UTILS_H |
| 11 | #define LIBGLESV2_RENDERER_RENDERER11_UTILS_H |
| 12 | |
daniel@transgaming.com | 65e6537 | 2012-11-28 19:33:50 +0000 | [diff] [blame] | 13 | #define GL_APICALL |
| 14 | #include <GLES2/gl2.h> |
| 15 | #include <GLES2/gl2ext.h> |
daniel@transgaming.com | feae9b3 | 2012-11-28 19:34:56 +0000 | [diff] [blame] | 16 | #include <d3d11.h> |
| 17 | |
daniel@transgaming.com | fa34b34 | 2012-11-28 19:38:01 +0000 | [diff] [blame] | 18 | #include "libGLESv2/angletypes.h" |
| 19 | |
| 20 | namespace gl_d3d11 |
| 21 | { |
| 22 | |
daniel@transgaming.com | 90c634a | 2013-01-11 04:10:01 +0000 | [diff] [blame] | 23 | D3D11_BLEND ConvertBlendFunc(GLenum glBlend, bool isAlpha); |
daniel@transgaming.com | fa34b34 | 2012-11-28 19:38:01 +0000 | [diff] [blame] | 24 | D3D11_BLEND_OP ConvertBlendOp(GLenum glBlendOp); |
| 25 | UINT8 ConvertColorMask(bool maskRed, bool maskGreen, bool maskBlue, bool maskAlpha); |
| 26 | |
| 27 | D3D11_CULL_MODE ConvertCullMode(bool cullEnabled, GLenum cullMode); |
| 28 | |
daniel@transgaming.com | c820c12 | 2012-11-28 19:38:30 +0000 | [diff] [blame] | 29 | D3D11_COMPARISON_FUNC ConvertComparison(GLenum comparison); |
| 30 | D3D11_DEPTH_WRITE_MASK ConvertDepthMask(bool depthWriteEnabled); |
| 31 | UINT8 ConvertStencilMask(GLuint stencilmask); |
| 32 | D3D11_STENCIL_OP ConvertStencilOp(GLenum stencilOp); |
| 33 | |
daniel@transgaming.com | 3d34a8a | 2013-01-11 04:07:48 +0000 | [diff] [blame] | 34 | D3D11_FILTER ConvertFilter(GLenum minFilter, GLenum magFilter, float maxAnisotropy); |
| 35 | D3D11_TEXTURE_ADDRESS_MODE ConvertTextureWrap(GLenum wrap); |
| 36 | FLOAT ConvertMinLOD(GLenum minFilter); |
| 37 | FLOAT ConvertMaxLOD(GLenum minFilter); |
| 38 | |
daniel@transgaming.com | 8fb65c8 | 2012-12-20 21:07:49 +0000 | [diff] [blame] | 39 | DXGI_FORMAT ConvertRenderbufferFormat(GLenum format); |
daniel@transgaming.com | a8aac67 | 2012-12-20 21:08:00 +0000 | [diff] [blame] | 40 | DXGI_FORMAT ConvertTextureFormat(GLenum format); |
daniel@transgaming.com | fa34b34 | 2012-11-28 19:38:01 +0000 | [diff] [blame] | 41 | } |
daniel@transgaming.com | 6b14771 | 2012-11-28 19:37:24 +0000 | [diff] [blame] | 42 | |
daniel@transgaming.com | feae9b3 | 2012-11-28 19:34:56 +0000 | [diff] [blame] | 43 | namespace d3d11_gl |
| 44 | { |
| 45 | |
| 46 | GLenum ConvertBackBufferFormat(DXGI_FORMAT format); |
| 47 | GLenum ConvertDepthStencilFormat(DXGI_FORMAT format); |
| 48 | GLenum ConvertRenderbufferFormat(DXGI_FORMAT format); |
| 49 | GLenum ConvertTextureInternalFormat(DXGI_FORMAT format); |
daniel@transgaming.com | 8fb65c8 | 2012-12-20 21:07:49 +0000 | [diff] [blame] | 50 | |
daniel@transgaming.com | feae9b3 | 2012-11-28 19:34:56 +0000 | [diff] [blame] | 51 | } |
| 52 | |
daniel@transgaming.com | 8fb65c8 | 2012-12-20 21:07:49 +0000 | [diff] [blame] | 53 | namespace d3d11 |
daniel@transgaming.com | feae9b3 | 2012-11-28 19:34:56 +0000 | [diff] [blame] | 54 | { |
shannon.woods@transgaming.com | f3d8207 | 2013-01-25 21:50:43 +0000 | [diff] [blame] | 55 | |
| 56 | struct PositionTexCoordVertex |
| 57 | { |
| 58 | float x, y; |
| 59 | float u, v; |
| 60 | }; |
| 61 | void SetPositionTexCoordVertex(PositionTexCoordVertex* vertex, float x, float y, float u, float v); |
| 62 | |
shannon.woods@transgaming.com | 34f507c | 2013-01-25 21:52:15 +0000 | [diff] [blame] | 63 | struct PositionDepthColorVertex |
| 64 | { |
| 65 | float x, y, z; |
| 66 | float r, g, b, a; |
| 67 | }; |
| 68 | void SetPositionDepthColorVertex(PositionDepthColorVertex* vertex, float x, float y, float z, |
| 69 | const gl::Color &color); |
| 70 | |
daniel@transgaming.com | 8fb65c8 | 2012-12-20 21:07:49 +0000 | [diff] [blame] | 71 | size_t ComputePixelSizeBits(DXGI_FORMAT format); |
| 72 | size_t ComputeBlockSizeBits(DXGI_FORMAT format); |
daniel@transgaming.com | 00f2d9c | 2013-01-11 04:11:08 +0000 | [diff] [blame] | 73 | |
shannon.woods@transgaming.com | eec5c63 | 2013-02-28 23:04:21 +0000 | [diff] [blame] | 74 | bool IsDepthStencilFormat(DXGI_FORMAT format); |
daniel@transgaming.com | 00f2d9c | 2013-01-11 04:11:08 +0000 | [diff] [blame] | 75 | HRESULT SetDebugName(ID3D11DeviceChild *resource, const char *name); |
daniel@transgaming.com | a60160b | 2012-11-28 19:41:15 +0000 | [diff] [blame] | 76 | |
| 77 | inline bool isDeviceLostError(HRESULT errorCode) |
| 78 | { |
| 79 | switch (errorCode) |
| 80 | { |
| 81 | case DXGI_ERROR_DEVICE_HUNG: |
| 82 | case DXGI_ERROR_DEVICE_REMOVED: |
| 83 | case DXGI_ERROR_DEVICE_RESET: |
| 84 | case DXGI_ERROR_DRIVER_INTERNAL_ERROR: |
| 85 | case DXGI_ERROR_NOT_CURRENTLY_AVAILABLE: |
| 86 | return true; |
| 87 | default: |
| 88 | return false; |
| 89 | } |
daniel@transgaming.com | e3e826d | 2012-11-28 19:42:35 +0000 | [diff] [blame] | 90 | } |
shannon.woods@transgaming.com | f5f5949 | 2013-02-28 23:04:40 +0000 | [diff] [blame^] | 91 | |
| 92 | } |
| 93 | |
| 94 | #endif // LIBGLESV2_RENDERER_RENDERER11_UTILS_H |