blob: f0878436ba5e77c76d9254af0ab790a086548f1e [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{
shannon.woods@transgaming.comf3d82072013-01-25 21:50:43 +000052
53struct PositionTexCoordVertex
54{
55 float x, y;
56 float u, v;
57};
58void SetPositionTexCoordVertex(PositionTexCoordVertex* vertex, float x, float y, float u, float v);
59
shannon.woods@transgaming.com34f507c2013-01-25 21:52:15 +000060struct PositionDepthColorVertex
61{
62 float x, y, z;
63 float r, g, b, a;
64};
65void SetPositionDepthColorVertex(PositionDepthColorVertex* vertex, float x, float y, float z,
66 const gl::Color &color);
67
daniel@transgaming.com8fb65c82012-12-20 21:07:49 +000068size_t ComputePixelSizeBits(DXGI_FORMAT format);
69size_t ComputeBlockSizeBits(DXGI_FORMAT format);
daniel@transgaming.com00f2d9c2013-01-11 04:11:08 +000070
shannon.woods@transgaming.comeec5c632013-02-28 23:04:21 +000071bool IsDepthStencilFormat(DXGI_FORMAT format);
daniel@transgaming.com00f2d9c2013-01-11 04:11:08 +000072HRESULT SetDebugName(ID3D11DeviceChild *resource, const char *name);
daniel@transgaming.comfeae9b32012-11-28 19:34:56 +000073}
daniel@transgaming.coma60160b2012-11-28 19:41:15 +000074
75inline bool isDeviceLostError(HRESULT errorCode)
76{
77 switch (errorCode)
78 {
79 case DXGI_ERROR_DEVICE_HUNG:
80 case DXGI_ERROR_DEVICE_REMOVED:
81 case DXGI_ERROR_DEVICE_RESET:
82 case DXGI_ERROR_DRIVER_INTERNAL_ERROR:
83 case DXGI_ERROR_NOT_CURRENTLY_AVAILABLE:
84 return true;
85 default:
86 return false;
87 }
daniel@transgaming.come3e826d2012-11-28 19:42:35 +000088}