blob: 774068eb20780b65abcc9a1165307d0bd55f2652 [file] [log] [blame]
daniel@transgaming.comfeae9b32012-11-28 19:34:56 +00001//
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
daniel@transgaming.com65e65372012-11-28 19:33:50 +000010#define GL_APICALL
11#include <GLES2/gl2.h>
12#include <GLES2/gl2ext.h>
daniel@transgaming.comfeae9b32012-11-28 19:34:56 +000013#include <d3d11.h>
14
daniel@transgaming.comfa34b342012-11-28 19:38:01 +000015#include "libGLESv2/angletypes.h"
16
17namespace gl_d3d11
18{
19
daniel@transgaming.com90c634a2013-01-11 04:10:01 +000020D3D11_BLEND ConvertBlendFunc(GLenum glBlend, bool isAlpha);
daniel@transgaming.comfa34b342012-11-28 19:38:01 +000021D3D11_BLEND_OP ConvertBlendOp(GLenum glBlendOp);
22UINT8 ConvertColorMask(bool maskRed, bool maskGreen, bool maskBlue, bool maskAlpha);
23
24D3D11_CULL_MODE ConvertCullMode(bool cullEnabled, GLenum cullMode);
25
daniel@transgaming.comc820c122012-11-28 19:38:30 +000026D3D11_COMPARISON_FUNC ConvertComparison(GLenum comparison);
27D3D11_DEPTH_WRITE_MASK ConvertDepthMask(bool depthWriteEnabled);
28UINT8 ConvertStencilMask(GLuint stencilmask);
29D3D11_STENCIL_OP ConvertStencilOp(GLenum stencilOp);
30
daniel@transgaming.com3d34a8a2013-01-11 04:07:48 +000031D3D11_FILTER ConvertFilter(GLenum minFilter, GLenum magFilter, float maxAnisotropy);
32D3D11_TEXTURE_ADDRESS_MODE ConvertTextureWrap(GLenum wrap);
33FLOAT ConvertMinLOD(GLenum minFilter);
34FLOAT ConvertMaxLOD(GLenum minFilter);
35
daniel@transgaming.com8fb65c82012-12-20 21:07:49 +000036DXGI_FORMAT ConvertRenderbufferFormat(GLenum format);
daniel@transgaming.coma8aac672012-12-20 21:08:00 +000037DXGI_FORMAT ConvertTextureFormat(GLenum format);
daniel@transgaming.comfa34b342012-11-28 19:38:01 +000038}
daniel@transgaming.com6b147712012-11-28 19:37:24 +000039
daniel@transgaming.comfeae9b32012-11-28 19:34:56 +000040namespace d3d11_gl
41{
42
43GLenum ConvertBackBufferFormat(DXGI_FORMAT format);
44GLenum ConvertDepthStencilFormat(DXGI_FORMAT format);
45GLenum ConvertRenderbufferFormat(DXGI_FORMAT format);
46GLenum ConvertTextureInternalFormat(DXGI_FORMAT format);
daniel@transgaming.com8fb65c82012-12-20 21:07:49 +000047
daniel@transgaming.comfeae9b32012-11-28 19:34:56 +000048}
49
daniel@transgaming.com8fb65c82012-12-20 21:07:49 +000050namespace d3d11
daniel@transgaming.comfeae9b32012-11-28 19:34:56 +000051{
daniel@transgaming.com8fb65c82012-12-20 21:07:49 +000052size_t ComputePixelSizeBits(DXGI_FORMAT format);
53size_t ComputeBlockSizeBits(DXGI_FORMAT format);
daniel@transgaming.comfeae9b32012-11-28 19:34:56 +000054}
daniel@transgaming.coma60160b2012-11-28 19:41:15 +000055
56inline bool isDeviceLostError(HRESULT errorCode)
57{
58 switch (errorCode)
59 {
60 case DXGI_ERROR_DEVICE_HUNG:
61 case DXGI_ERROR_DEVICE_REMOVED:
62 case DXGI_ERROR_DEVICE_RESET:
63 case DXGI_ERROR_DRIVER_INTERNAL_ERROR:
64 case DXGI_ERROR_NOT_CURRENTLY_AVAILABLE:
65 return true;
66 default:
67 return false;
68 }
daniel@transgaming.come3e826d2012-11-28 19:42:35 +000069}