blob: 875b5e0eb3a1c83f9f3ef9dff4b9c411a2fdf8d2 [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
shannon.woods@transgaming.comf5f59492013-02-28 23:04:40 +000010#ifndef LIBGLESV2_RENDERER_RENDERER11_UTILS_H
11#define LIBGLESV2_RENDERER_RENDERER11_UTILS_H
12
daniel@transgaming.com65e65372012-11-28 19:33:50 +000013#define GL_APICALL
14#include <GLES2/gl2.h>
15#include <GLES2/gl2ext.h>
daniel@transgaming.comfeae9b32012-11-28 19:34:56 +000016#include <d3d11.h>
17
daniel@transgaming.comfa34b342012-11-28 19:38:01 +000018#include "libGLESv2/angletypes.h"
19
20namespace gl_d3d11
21{
22
daniel@transgaming.com90c634a2013-01-11 04:10:01 +000023D3D11_BLEND ConvertBlendFunc(GLenum glBlend, bool isAlpha);
daniel@transgaming.comfa34b342012-11-28 19:38:01 +000024D3D11_BLEND_OP ConvertBlendOp(GLenum glBlendOp);
25UINT8 ConvertColorMask(bool maskRed, bool maskGreen, bool maskBlue, bool maskAlpha);
26
27D3D11_CULL_MODE ConvertCullMode(bool cullEnabled, GLenum cullMode);
28
daniel@transgaming.comc820c122012-11-28 19:38:30 +000029D3D11_COMPARISON_FUNC ConvertComparison(GLenum comparison);
30D3D11_DEPTH_WRITE_MASK ConvertDepthMask(bool depthWriteEnabled);
31UINT8 ConvertStencilMask(GLuint stencilmask);
32D3D11_STENCIL_OP ConvertStencilOp(GLenum stencilOp);
33
daniel@transgaming.com3d34a8a2013-01-11 04:07:48 +000034D3D11_FILTER ConvertFilter(GLenum minFilter, GLenum magFilter, float maxAnisotropy);
35D3D11_TEXTURE_ADDRESS_MODE ConvertTextureWrap(GLenum wrap);
36FLOAT ConvertMinLOD(GLenum minFilter);
37FLOAT ConvertMaxLOD(GLenum minFilter);
38
daniel@transgaming.com8fb65c82012-12-20 21:07:49 +000039DXGI_FORMAT ConvertRenderbufferFormat(GLenum format);
daniel@transgaming.coma8aac672012-12-20 21:08:00 +000040DXGI_FORMAT ConvertTextureFormat(GLenum format);
daniel@transgaming.comfa34b342012-11-28 19:38:01 +000041}
daniel@transgaming.com6b147712012-11-28 19:37:24 +000042
daniel@transgaming.comfeae9b32012-11-28 19:34:56 +000043namespace d3d11_gl
44{
45
46GLenum ConvertBackBufferFormat(DXGI_FORMAT format);
47GLenum ConvertDepthStencilFormat(DXGI_FORMAT format);
48GLenum ConvertRenderbufferFormat(DXGI_FORMAT format);
49GLenum ConvertTextureInternalFormat(DXGI_FORMAT format);
daniel@transgaming.com8fb65c82012-12-20 21:07:49 +000050
daniel@transgaming.comfeae9b32012-11-28 19:34:56 +000051}
52
daniel@transgaming.com8fb65c82012-12-20 21:07:49 +000053namespace d3d11
daniel@transgaming.comfeae9b32012-11-28 19:34:56 +000054{
shannon.woods@transgaming.comf3d82072013-01-25 21:50:43 +000055
56struct PositionTexCoordVertex
57{
58 float x, y;
59 float u, v;
60};
61void SetPositionTexCoordVertex(PositionTexCoordVertex* vertex, float x, float y, float u, float v);
62
shannon.woods@transgaming.com34f507c2013-01-25 21:52:15 +000063struct PositionDepthColorVertex
64{
65 float x, y, z;
66 float r, g, b, a;
67};
68void SetPositionDepthColorVertex(PositionDepthColorVertex* vertex, float x, float y, float z,
69 const gl::Color &color);
70
daniel@transgaming.com8fb65c82012-12-20 21:07:49 +000071size_t ComputePixelSizeBits(DXGI_FORMAT format);
72size_t ComputeBlockSizeBits(DXGI_FORMAT format);
daniel@transgaming.com00f2d9c2013-01-11 04:11:08 +000073
shannon.woods@transgaming.comeec5c632013-02-28 23:04:21 +000074bool IsDepthStencilFormat(DXGI_FORMAT format);
daniel@transgaming.com00f2d9c2013-01-11 04:11:08 +000075HRESULT SetDebugName(ID3D11DeviceChild *resource, const char *name);
daniel@transgaming.coma60160b2012-11-28 19:41:15 +000076
77inline 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.come3e826d2012-11-28 19:42:35 +000090}
shannon.woods@transgaming.comf5f59492013-02-28 23:04:40 +000091
92}
93
94#endif // LIBGLESV2_RENDERER_RENDERER11_UTILS_H