blob: d30ab990915adff4811051217ccad5850eedc7bf [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
20D3D11_BLEND ConvertBlendFunc(GLenum glBlend);
21D3D11_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.com8fb65c82012-12-20 21:07:49 +000031DXGI_FORMAT ConvertRenderbufferFormat(GLenum format);
32DXGI_FORMAT ConvertTextureInternalFormat(GLenum internalformat);
33
daniel@transgaming.comfa34b342012-11-28 19:38:01 +000034}
daniel@transgaming.com6b147712012-11-28 19:37:24 +000035
daniel@transgaming.comfeae9b32012-11-28 19:34:56 +000036namespace d3d11_gl
37{
38
39GLenum ConvertBackBufferFormat(DXGI_FORMAT format);
40GLenum ConvertDepthStencilFormat(DXGI_FORMAT format);
41GLenum ConvertRenderbufferFormat(DXGI_FORMAT format);
42GLenum ConvertTextureInternalFormat(DXGI_FORMAT format);
daniel@transgaming.com8fb65c82012-12-20 21:07:49 +000043
daniel@transgaming.comfeae9b32012-11-28 19:34:56 +000044}
45
daniel@transgaming.com8fb65c82012-12-20 21:07:49 +000046namespace d3d11
daniel@transgaming.comfeae9b32012-11-28 19:34:56 +000047{
daniel@transgaming.com8fb65c82012-12-20 21:07:49 +000048size_t ComputePixelSizeBits(DXGI_FORMAT format);
49size_t ComputeBlockSizeBits(DXGI_FORMAT format);
daniel@transgaming.comfeae9b32012-11-28 19:34:56 +000050}
daniel@transgaming.coma60160b2012-11-28 19:41:15 +000051
52inline bool isDeviceLostError(HRESULT errorCode)
53{
54 switch (errorCode)
55 {
56 case DXGI_ERROR_DEVICE_HUNG:
57 case DXGI_ERROR_DEVICE_REMOVED:
58 case DXGI_ERROR_DEVICE_RESET:
59 case DXGI_ERROR_DRIVER_INTERNAL_ERROR:
60 case DXGI_ERROR_NOT_CURRENTLY_AVAILABLE:
61 return true;
62 default:
63 return false;
64 }
daniel@transgaming.come3e826d2012-11-28 19:42:35 +000065}