10 #ifndef LIBANGLE_RENDERER_D3D_D3D11_RENDERER11_UTILS_H_ 11 #define LIBANGLE_RENDERER_D3D_D3D11_RENDERER11_UTILS_H_ 26 class FramebufferAttachment;
33 struct WorkaroundsD3D;
34 struct Renderer11DeviceCaps;
36 using RenderTargetArray = std::array<RenderTarget11 *, gl::IMPLEMENTATION_MAX_DRAW_BUFFERS>;
37 using RTVArray = std::array<ID3D11RenderTargetView *, gl::IMPLEMENTATION_MAX_DRAW_BUFFERS>;
44 UINT8
ConvertColorMask(
bool maskRed,
bool maskGreen,
bool maskBlue,
bool maskAlpha);
95 std::vector<D3D11_SUBRESOURCE_DATA> *outSubresourceData,
96 std::vector<std::vector<BYTE>> *outData);
114 unsigned int layer,
float u,
float v,
float s);
116 template <
typename T>
123 template <
typename T>
130 vertex->
r = color.
red;
132 vertex->
b = color.
blue;
138 template <
typename outType>
141 outType *outObject =
NULL;
142 HRESULT result =
object->QueryInterface(__uuidof(outType), reinterpret_cast<void**>(&outObject));
143 if (SUCCEEDED(result))
158 case DXGI_ERROR_DEVICE_HUNG:
159 case DXGI_ERROR_DEVICE_REMOVED:
160 case DXGI_ERROR_DEVICE_RESET:
161 case DXGI_ERROR_DRIVER_INTERNAL_ERROR:
162 case DXGI_ERROR_NOT_CURRENTLY_AVAILABLE:
169 inline ID3D11VertexShader *
CompileVS(ID3D11Device *device,
const BYTE *byteCode,
size_t N,
const char *name)
171 ID3D11VertexShader *vs =
nullptr;
172 HRESULT result = device->CreateVertexShader(byteCode, N,
nullptr, &vs);
173 ASSERT(SUCCEEDED(result));
174 if (SUCCEEDED(result))
182 template <
unsigned int N>
183 ID3D11VertexShader *
CompileVS(ID3D11Device *device,
const BYTE (&byteCode)[
N],
const char *name)
185 return CompileVS(device, byteCode, N, name);
188 inline ID3D11GeometryShader *
CompileGS(ID3D11Device *device,
const BYTE *byteCode,
size_t N,
const char *name)
190 ID3D11GeometryShader *gs =
nullptr;
191 HRESULT result = device->CreateGeometryShader(byteCode, N,
nullptr, &gs);
192 ASSERT(SUCCEEDED(result));
193 if (SUCCEEDED(result))
201 template <
unsigned int N>
202 ID3D11GeometryShader *
CompileGS(ID3D11Device *device,
const BYTE (&byteCode)[
N],
const char *name)
204 return CompileGS(device, byteCode, N, name);
207 inline ID3D11PixelShader *
CompilePS(ID3D11Device *device,
const BYTE *byteCode,
size_t N,
const char *name)
209 ID3D11PixelShader *ps =
nullptr;
210 HRESULT result = device->CreatePixelShader(byteCode, N,
nullptr, &ps);
211 ASSERT(SUCCEEDED(result));
212 if (SUCCEEDED(result))
220 template <
unsigned int N>
221 ID3D11PixelShader *
CompilePS(ID3D11Device *device,
const BYTE (&byteCode)[
N],
const char *name)
223 return CompilePS(device, byteCode, N, name);
226 template <
typename ResourceType>
233 virtual ResourceType *resolve(ID3D11Device *device) = 0;
237 void checkAssociatedDevice(ID3D11Device *device);
243 template <
typename ResourceType>
246 ASSERT(mAssociatedDevice ==
nullptr || device == mAssociatedDevice);
247 mAssociatedDevice = device;
250 template <
typename D3D11ShaderType>
258 : mByteCode(byteCode),
259 mByteCodeSize(byteCodeSize),
264 D3D11ShaderType *resolve(ID3D11Device *device)
override;
267 const BYTE *mByteCode;
268 size_t mByteCodeSize;
275 checkAssociatedDevice(device);
276 if (mResource ==
nullptr)
278 mResource =
CompileVS(device, mByteCode, mByteCodeSize, mName);
286 checkAssociatedDevice(device);
287 if (mResource ==
nullptr)
289 mResource =
CompileGS(device, mByteCode, mByteCodeSize, mName);
297 checkAssociatedDevice(device);
298 if (mResource ==
nullptr)
300 mResource =
CompilePS(device, mByteCode, mByteCodeSize, mName);
310 const BYTE *byteCode,
312 const char *debugName);
314 ID3D11InputLayout *resolve(ID3D11Device *device)
override;
317 std::vector<D3D11_INPUT_ELEMENT_DESC> mInputDesc;
319 const BYTE *mByteCode;
320 const char *mDebugName;
328 ID3D11BlendState *resolve(ID3D11Device *device)
override;
331 D3D11_BLEND_DESC mDesc;
332 const char *mDebugName;
340 D3D11_MAPPED_SUBRESOURCE mappedResource = {};
341 HRESULT result = context->Map(constantBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource);
342 ASSERT(SUCCEEDED(result));
343 if (SUCCEEDED(result))
345 memcpy(mappedResource.pData, &value,
sizeof(
T));
346 context->Unmap(constantBuffer, 0);
351 const DXGI_ADAPTER_DESC &adapterDesc);
373 static TextureHelper11 MakeAndReference(ID3D11Resource *genericResource,
387 ID3D11Resource *getResource()
const;
399 ID3D11Texture2D *mTexture2D;
400 ID3D11Texture3D *mTexture3D;
413 ID3D11Device *device);
419 #endif // LIBANGLE_RENDERER_D3D_D3D11_RENDERER11_UTILS_H_ int GLint
Definition: gl2.h:76
void GenerateCaps(ID3D11Device *device, ID3D11DeviceContext *deviceContext, const Renderer11DeviceCaps &renderer11DeviceCaps, gl::Caps *caps, gl::TextureCapsMap *textureCapsMap, gl::Extensions *extensions, gl::Limitations *limitations)
Definition: renderer11_utils.cpp:1046
ID3D11GeometryShader * CompileGS(ID3D11Device *device, const BYTE(&byteCode)[N], const char *name)
Definition: renderer11_utils.h:202
Definition: renderer11_utils.h:227
EGLStreamKHR EGLint EGLint EGLint size
Definition: eglext.h:984
EGLSurface EGLint EGLint EGLint EGLint height
Definition: eglext.h:950
StagingAccess
Definition: renderer11_utils.h:403
GLboolean GLboolean g
Definition: gl2ext.h:306
float z
Definition: renderer11_utils.h:119
GLint GLint GLint GLsizei GLsizei GLenum format
Definition: gl2.h:403
UINT8 ConvertStencilMask(GLuint stencilmask)
Definition: renderer11_utils.cpp:1435
D3D11_COMPARISON_FUNC ConvertComparison(GLenum comparison)
Definition: renderer11_utils.cpp:1394
D3D11_FILTER ConvertFilter(GLenum minFilter, GLenum magFilter, float maxAnisotropy, GLenum comparisonMode)
Definition: renderer11_utils.cpp:1477
GLuint GLint internalFormat
Definition: gl2ext.h:1280
Definition: renderer11_utils.h:82
OPENSSL_EXPORT pem_password_cb void * u
Definition: pem.h:398
D3D11_BLEND_OP ConvertBlendOp(GLenum glBlendOp)
Definition: renderer11_utils.cpp:1315
float y
Definition: renderer11_utils.h:109
gl::Extents getExtents() const
Definition: renderer11_utils.h:381
EGLSurface EGLint EGLint EGLint width
Definition: eglext.h:950
T r
Definition: renderer11_utils.h:120
Definition: renderer11_utils.h:355
EGLOutputLayerEXT layer
Definition: eglext.h:695
HRESULT SetDebugName(ID3D11DeviceChild *resource, const char *name)
Definition: renderer11_utils.cpp:1732
EGLStreamKHR void * texture
Definition: eglext.h:568
D3D11_CULL_MODE ConvertCullMode(bool cullEnabled, GLenum cullMode)
Definition: renderer11_utils.cpp:1365
LazyResource()
Definition: renderer11_utils.h:230
std::array< ID3D11RenderTargetView *, gl::IMPLEMENTATION_MAX_DRAW_BUFFERS > RTVArray
Definition: renderer11_utils.h:37
unsigned int GLenum
Definition: gl2.h:69
ReservedConstantBufferSlot
Definition: renderer11_utils.h:353
UINT ConvertMaxAnisotropy(float maxAnisotropy, D3D_FEATURE_LEVEL featureLevel)
Definition: renderer11_utils.cpp:1557
bool isDeviceLostError(HRESULT errorCode)
Definition: renderer11_utils.h:154
Definition: Renderer11.h:102
T blue
Definition: Color.h:20
Definition: angletypes.h:82
std::array< RenderTarget11 *, gl::IMPLEMENTATION_MAX_DRAW_BUFFERS > RenderTargetArray
Definition: renderer11_utils.h:36
HRESULT
Definition: RenderThemeWin.cpp:150
GLenum getTextureType() const
Definition: renderer11_utils.h:380
Definition: renderer11_utils.h:323
D3D11_TEXTURE_ADDRESS_MODE ConvertTextureWrap(GLenum wrap)
Definition: renderer11_utils.cpp:1540
GLint GetMaximumClientVersion(D3D_FEATURE_LEVEL featureLevel)
Definition: renderer11_utils.cpp:1025
void SetPositionLayerTexCoord3DVertex(PositionLayerTexCoord3DVertex *vertex, float x, float y, unsigned int layer, float u, float v, float s)
Definition: renderer11_utils.cpp:1721
Definition: WorkaroundsD3D.h:27
GLuint GetPrimitiveRestartIndex(GLenum indexType)
Definition: utilities.cpp:504
D3D11_STENCIL_OP ConvertStencilOp(GLenum stencilOp)
Definition: renderer11_utils.cpp:1440
#define desc
Definition: extension_set.h:320
void GenerateInitialTextureData(GLint internalFormat, const Renderer11DeviceCaps &renderer11DeviceCaps, GLuint width, GLuint height, GLuint depth, GLuint mipLevels, std::vector< D3D11_SUBRESOURCE_DATA > *outSubresourceData, std::vector< std::vector< BYTE >> *outData)
Definition: renderer11_utils.cpp:1672
ID3D11Texture2D * getTexture2D() const
Definition: renderer11_utils.h:385
ID3D11PixelShader * CompilePS(ID3D11Device *device, const BYTE(&byteCode)[N], const char *name)
Definition: renderer11_utils.h:221
DXGI_FORMAT getFormat() const
Definition: renderer11_utils.h:382
Definition: renderer11_utils.h:117
void release()
Definition: renderer11_utils.h:234
LazyShader(const BYTE *byteCode, size_t byteCodeSize, const char *name)
Definition: renderer11_utils.h:255
Definition: mathutil.h:804
T green
Definition: Color.h:19
Definition: Renderer11.h:46
TestSubObjConstructor T
Definition: TestTypedefs.idl:84
ID3D11Texture3D * getTexture3D() const
Definition: renderer11_utils.h:386
EGLSurface EGLint x
Definition: eglext.h:950
float x
Definition: renderer11_utils.h:119
GLuint color
Definition: gl2ext.h:1371
EGLAttrib * value
Definition: eglext.h:120
virtual ~LazyResource()
Definition: renderer11_utils.h:231
float y
Definition: renderer11_utils.h:102
unsigned int GLuint
Definition: gl2.h:70
ANGLED3D11DeviceType GetDeviceType(ID3D11Device *device)
Definition: renderer11_utils.cpp:1587
ANGLED3D11DeviceType
Definition: renderer11_utils.h:77
EGLImageKHR EGLint * name
Definition: eglext.h:851
Definition: renderer11_utils.h:365
Definition: ApplePayLineItem.idl:30
float v
Definition: renderer11_utils.h:111
EGLSurface EGLint EGLint y
Definition: eglext.h:950
Definition: renderer11_utils.h:358
Definition: renderer11_utils.h:81
Definition: base64_test.cc:34
outType * DynamicCastComObject(IUnknown *object)
Definition: com_utils.h:13
GLboolean GLboolean GLboolean GLboolean a
Definition: gl2ext.h:306
GLint GLenum GLsizei GLsizei GLsizei depth
Definition: gl2ext.h:572
T b
Definition: renderer11_utils.h:120
#define N
Definition: gcc-loops.cpp:14
Definition: FramebufferAttachment.h:52
ResourceType
Definition: InspectorProtocolObjects.h:6897
const d3d11::Format & getFormatSet() const
Definition: renderer11_utils.h:383
ResourceType * mResource
Definition: renderer11_utils.h:239
const GLfloat * v
Definition: gl2.h:514
bool UsePresentPathFast(const Renderer11 *renderer, const gl::FramebufferAttachment *framebufferAttachment)
Definition: renderer11_utils.cpp:2069
float v
Definition: renderer11_utils.h:103
typename lazy::wrap< A, B >::type wrap
Definition: Brigand.h:87
Definition: renderer11_utils.h:100
result
Definition: target-blank-opener-post-window.php:5
D3D11_QUERY ConvertQueryType(GLenum queryType)
Definition: renderer11_utils.cpp:1562
int getSampleCount() const
Definition: renderer11_utils.h:384
T red
Definition: Color.h:18
gl::ErrorOrResult< TextureHelper11 > CreateStagingTexture(GLenum textureType, const d3d11::Format &formatSet, const gl::Extents &size, StagingAccess readAndWriteAccess, ID3D11Device *device)
Definition: renderer11_utils.cpp:2009
Definition: renderer11_utils.h:80
WorkaroundsD3D GenerateWorkarounds(const Renderer11DeviceCaps &deviceCaps, const DXGI_ADAPTER_DESC &adapterDesc)
Definition: renderer11_utils.cpp:1820
D3D11_BLEND ConvertBlendFunc(GLenum glBlend, bool isAlpha)
Definition: renderer11_utils.cpp:1257
GLfloat GLfloat GLfloat z
Definition: gl2.h:517
void SetPositionTexCoordVertex(PositionTexCoordVertex *vertex, float x, float y, float u, float v)
Definition: renderer11_utils.cpp:1713
#define NULL
Definition: common_types.h:41
Definition: angleutils.h:26
T a
Definition: renderer11_utils.h:120
unsigned int GetReservedVertexUniformVectors(D3D_FEATURE_LEVEL featureLevel)
Definition: renderer11_utils.cpp:983
void SetPositionDepthColorVertex(PositionDepthColorVertex< T > *vertex, float x, float y, float z, const gl::Color< T > &color)
Definition: renderer11_utils.h:124
GLboolean GLboolean GLboolean b
Definition: gl2ext.h:306
int GLsizei
Definition: gl2.h:78
unsigned int l
Definition: renderer11_utils.h:110
void MakeValidSize(bool isImage, DXGI_FORMAT format, GLsizei *requestWidth, GLsizei *requestHeight, int *levelOffset)
Definition: renderer11_utils.cpp:1653
void SafeRelease(T(&resourceBlock)[N])
Definition: angleutils.h:46
unsigned int GetReservedFragmentUniformVectors(D3D_FEATURE_LEVEL featureLevel)
Definition: renderer11_utils.cpp:1004
D3D11_DEPTH_WRITE_MASK ConvertDepthMask(bool depthWriteEnabled)
Definition: renderer11_utils.cpp:1430
void InitConstantBufferDesc(D3D11_BUFFER_DESC *constantBufferDescription, size_t byteWidth)
Definition: renderer11_utils.cpp:1865
ID3D11Device * mAssociatedDevice
Definition: renderer11_utils.h:240
Definition: renderer11_utils.h:79
#define ASSERT(assertion)
Definition: Assertions.h:283
T alpha
Definition: Color.h:21
#define errorCode
Definition: xmlparse.c:612
ID3D11VertexShader * CompileVS(ID3D11Device *device, const BYTE(&byteCode)[N], const char *name)
Definition: renderer11_utils.h:183
Definition: renderer11_utils.h:356
void SetBufferData(ID3D11DeviceContext *context, ID3D11Buffer *constantBuffer, const T &value)
Definition: renderer11_utils.h:338
float y
Definition: renderer11_utils.h:119
Definition: entry_points_gles_2_0.h:15
UINT8 ConvertColorMask(bool red, bool green, bool blue, bool alpha)
Definition: renderer11_utils.cpp:1343
U_CDECL_BEGIN typedef void * context
Definition: ustring.h:1023
Definition: renderer11_utils.h:251
Definition: renderer11_utils.h:107
T g
Definition: renderer11_utils.h:120