blob: 8bb89459a5c0eb21002590efd07b66488a4a8e4a [file] [log] [blame]
daniel@transgaming.com1d6aff22012-11-28 19:30:42 +00001//
Geoff Langeeba6e12014-02-03 13:12:30 -05002// Copyright (c) 2012-2014 The ANGLE Project Authors. All rights reserved.
daniel@transgaming.com1d6aff22012-11-28 19:30:42 +00003// 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.h: Defines a back-end specific class for the D3D11 renderer.
8
9#ifndef LIBGLESV2_RENDERER_RENDERER11_H_
10#define LIBGLESV2_RENDERER_RENDERER11_H_
11
daniel@transgaming.com1d6aff22012-11-28 19:30:42 +000012#include "common/angleutils.h"
daniel@transgaming.com6c872172012-11-28 19:39:33 +000013#include "libGLESv2/angletypes.h"
shannonwoods@chromium.orga2ecfcc2013-05-30 00:11:59 +000014#include "common/mathutil.h"
daniel@transgaming.com1d6aff22012-11-28 19:30:42 +000015
16#include "libGLESv2/renderer/Renderer.h"
Geoff Langdad5ed32014-02-10 12:59:17 -050017#include "libGLESv2/renderer/d3d/HLSLCompiler.h"
Brandon Jonesc7a41042014-06-23 12:03:25 -070018#include "libGLESv2/renderer/d3d/d3d11/RenderStateCache.h"
19#include "libGLESv2/renderer/d3d/d3d11/InputLayoutCache.h"
shannon.woods@transgaming.comd2811d62013-02-28 23:11:19 +000020#include "libGLESv2/renderer/RenderTarget.h"
daniel@transgaming.com1d6aff22012-11-28 19:30:42 +000021
shannon.woods%transgaming.com@gtempaccount.com00e3f0c2013-04-13 03:31:02 +000022namespace gl
23{
Jamie Madill3c7fa222014-06-05 13:08:51 -040024class FramebufferAttachment;
shannon.woods%transgaming.com@gtempaccount.com00e3f0c2013-04-13 03:31:02 +000025}
26
daniel@transgaming.com1d6aff22012-11-28 19:30:42 +000027namespace rx
28{
29
daniel@transgaming.comc5431eb2012-12-20 21:10:15 +000030class VertexDataManager;
31class IndexDataManager;
daniel@transgaming.comc5114302012-12-20 21:11:36 +000032class StreamingIndexBufferInterface;
Geoff Langb86b9792013-06-04 16:32:05 -040033class Blit11;
Geoff Langda507fe2013-08-20 12:01:42 -040034class Clear11;
Jamie Madilla21eea32013-09-18 14:36:25 -040035class PixelTransfer11;
Jamie Madill7538f7f2014-04-17 11:53:39 -040036struct PackPixelsParams;
daniel@transgaming.comc5431eb2012-12-20 21:10:15 +000037
shannon.woods@transgaming.com4e482042013-01-25 21:54:18 +000038enum
39{
40 MAX_VERTEX_UNIFORM_VECTORS_D3D11 = 1024,
41 MAX_FRAGMENT_UNIFORM_VECTORS_D3D11 = 1024
42};
43
daniel@transgaming.com1d6aff22012-11-28 19:30:42 +000044class Renderer11 : public Renderer
45{
46 public:
47 Renderer11(egl::Display *display, HDC hDc);
48 virtual ~Renderer11();
49
daniel@transgaming.comb64ed282012-11-28 20:54:02 +000050 static Renderer11 *makeRenderer11(Renderer *renderer);
51
daniel@transgaming.com1d6aff22012-11-28 19:30:42 +000052 virtual EGLint initialize();
53 virtual bool resetDevice();
54
55 virtual int generateConfigs(ConfigDesc **configDescList);
56 virtual void deleteConfigs(ConfigDesc *configDescList);
57
daniel@transgaming.com1d6aff22012-11-28 19:30:42 +000058 virtual void sync(bool block);
59
daniel@transgaming.comb9bb2792012-11-28 19:36:49 +000060 virtual SwapChain *createSwapChain(HWND window, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat);
61
Geoff Lange2e0ce02013-09-17 17:05:08 -040062 virtual void generateSwizzle(gl::Texture *texture);
daniel@transgaming.com1d6aff22012-11-28 19:30:42 +000063 virtual void setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &sampler);
64 virtual void setTexture(gl::SamplerType type, int index, gl::Texture *texture);
65
shannonwoods@chromium.org1bddfb92013-05-30 00:11:29 +000066 virtual bool setUniformBuffers(const gl::Buffer *vertexUniformBuffers[], const gl::Buffer *fragmentUniformBuffers[]);
67
daniel@transgaming.com237bc7e2012-11-28 21:01:06 +000068 virtual void setRasterizerState(const gl::RasterizerState &rasterState);
Geoff Langc142e9d2013-09-30 15:19:47 -040069 virtual void setBlendState(gl::Framebuffer *framebuffer, const gl::BlendState &blendState, const gl::ColorF &blendColor,
daniel@transgaming.com493d4f82012-11-28 19:35:45 +000070 unsigned int sampleMask);
daniel@transgaming.com08c331d2012-11-28 19:38:39 +000071 virtual void setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef,
daniel@transgaming.com3a0ef482012-11-28 21:01:20 +000072 int stencilBackRef, bool frontFaceCCW);
daniel@transgaming.com493d4f82012-11-28 19:35:45 +000073
daniel@transgaming.comd55e8c12012-11-28 21:07:02 +000074 virtual void setScissorRectangle(const gl::Rectangle &scissor, bool enabled);
daniel@transgaming.com12985182012-12-20 20:56:31 +000075 virtual bool setViewport(const gl::Rectangle &viewport, float zNear, float zFar, GLenum drawMode, GLenum frontFace,
shannon.woods@transgaming.com0b236e22013-01-25 21:57:07 +000076 bool ignoreViewport);
daniel@transgaming.com493d4f82012-11-28 19:35:45 +000077
daniel@transgaming.com91207b72012-11-28 20:56:43 +000078 virtual bool applyPrimitiveType(GLenum mode, GLsizei count);
daniel@transgaming.comae39ee22012-11-28 19:42:02 +000079 virtual bool applyRenderTarget(gl::Framebuffer *frameBuffer);
Geoff Lang04fb89a2014-06-09 15:05:36 -040080 virtual void applyShaders(gl::ProgramBinary *programBinary, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer,
81 bool rasterizerDiscard, bool transformFeedbackActive);
Jamie Madill8ff21ae2014-02-04 16:04:05 -050082 virtual void applyUniforms(const gl::ProgramBinary &programBinary);
Jamie Madill57a89722013-07-02 11:57:03 -040083 virtual GLenum applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::VertexAttribute vertexAttributes[], gl::VertexAttribCurrentValueData currentValues[],
Jamie Madilla857c362013-07-02 11:57:02 -040084 GLint first, GLsizei count, GLsizei instances);
daniel@transgaming.com31240482012-11-28 21:06:41 +000085 virtual GLenum applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo);
Geoff Langeeba6e12014-02-03 13:12:30 -050086 virtual void applyTransformFeedbackBuffers(gl::Buffer *transformFeedbackBuffers[], GLintptr offsets[]);
daniel@transgaming.com493d4f82012-11-28 19:35:45 +000087
Geoff Lang4c5c6bb2014-02-05 16:32:46 -050088 virtual void drawArrays(GLenum mode, GLsizei count, GLsizei instances, bool transformFeedbackActive);
89 virtual void drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices,
90 gl::Buffer *elementArrayBuffer, const TranslatedIndexData &indexInfo, GLsizei instances);
daniel@transgaming.comdef9f0f2012-11-28 20:53:20 +000091
daniel@transgaming.com084a2572012-11-28 20:55:17 +000092 virtual void clear(const gl::ClearParameters &clearParams, gl::Framebuffer *frameBuffer);
daniel@transgaming.comd084c622012-11-28 19:36:05 +000093
daniel@transgaming.comc43a6052012-11-28 19:41:51 +000094 virtual void markAllStateDirty();
95
daniel@transgaming.com1d6aff22012-11-28 19:30:42 +000096 // lost device
shannon.woods@transgaming.comeb049e22013-02-28 23:04:49 +000097 void notifyDeviceLost();
daniel@transgaming.com1d6aff22012-11-28 19:30:42 +000098 virtual bool isDeviceLost();
99 virtual bool testDeviceLost(bool notify);
100 virtual bool testDeviceResettable();
101
daniel@transgaming.com1d6aff22012-11-28 19:30:42 +0000102 virtual DWORD getAdapterVendor() const;
daniel@transgaming.comca1ac1f2013-01-11 04:13:05 +0000103 virtual std::string getRendererDescription() const;
daniel@transgaming.com1d6aff22012-11-28 19:30:42 +0000104 virtual GUID getAdapterIdentifier() const;
105
shannon.woods@transgaming.com233fe952013-01-25 21:51:57 +0000106 virtual unsigned int getMaxVertexTextureImageUnits() const;
shannon.woods@transgaming.com76cd88c2013-01-25 21:54:36 +0000107 virtual unsigned int getMaxCombinedTextureImageUnits() const;
shannon.woods@transgaming.comd8136cb2013-02-28 23:14:44 +0000108 virtual unsigned int getReservedVertexUniformVectors() const;
109 virtual unsigned int getReservedFragmentUniformVectors() const;
110 virtual unsigned int getMaxVertexUniformVectors() const;
111 virtual unsigned int getMaxFragmentUniformVectors() const;
112 virtual unsigned int getMaxVaryingVectors() const;
shannon.woods%transgaming.com@gtempaccount.com3f72ce32013-04-13 03:36:43 +0000113 virtual unsigned int getMaxVertexShaderUniformBuffers() const;
114 virtual unsigned int getMaxFragmentShaderUniformBuffers() const;
shannonwoods@chromium.org2b544222013-05-30 00:11:12 +0000115 virtual unsigned int getReservedVertexUniformBuffers() const;
116 virtual unsigned int getReservedFragmentUniformBuffers() const;
Geoff Lang1b6edcb2014-02-03 14:27:56 -0500117 unsigned int getReservedVaryings() const;
shannon.woods%transgaming.com@gtempaccount.com3f72ce32013-04-13 03:36:43 +0000118 virtual unsigned int getMaxTransformFeedbackBuffers() const;
Geoff Lang1b6edcb2014-02-03 14:27:56 -0500119 virtual unsigned int getMaxTransformFeedbackSeparateComponents() const;
120 virtual unsigned int getMaxTransformFeedbackInterleavedComponents() const;
shannonwoods@chromium.org33e798f2013-05-30 00:05:05 +0000121 virtual unsigned int getMaxUniformBufferSize() const;
daniel@transgaming.com1d6aff22012-11-28 19:30:42 +0000122 virtual bool getShareHandleSupport() const;
shannon.woods@transgaming.com8d2f0862013-02-28 23:09:19 +0000123 virtual bool getPostSubBufferSupport() const;
Jamie Madill13a2f852013-12-11 16:35:08 -0500124 virtual int getMaxRecommendedElementsIndices() const;
125 virtual int getMaxRecommendedElementsVertices() const;
Geoff Lang05b05022014-06-11 15:31:45 -0400126 virtual bool getSRGBTextureSupport() const;
daniel@transgaming.com1d6aff22012-11-28 19:30:42 +0000127
daniel@transgaming.com9549bea2012-11-28 20:57:23 +0000128 virtual int getMajorShaderModel() const;
daniel@transgaming.com1d6aff22012-11-28 19:30:42 +0000129 virtual int getMinSwapInterval() const;
130 virtual int getMaxSwapInterval() const;
131
132 virtual GLsizei getMaxSupportedSamples() const;
Geoff Lang005df412013-10-16 14:12:50 -0400133 virtual GLsizei getMaxSupportedFormatSamples(GLenum internalFormat) const;
134 virtual GLsizei getNumSampleCounts(GLenum internalFormat) const;
135 virtual void getSampleCounts(GLenum internalFormat, GLsizei bufSize, GLint *params) const;
shannon.woods@transgaming.com88fbd0f2013-02-28 23:05:46 +0000136 int getNearestSupportedSamples(DXGI_FORMAT format, unsigned int requested) const;
daniel@transgaming.com1d6aff22012-11-28 19:30:42 +0000137
daniel@transgaming.coma9c71422012-11-28 20:58:45 +0000138 // Pixel operations
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000139 virtual bool copyToRenderTarget(TextureStorageInterface2D *dest, TextureStorageInterface2D *source);
140 virtual bool copyToRenderTarget(TextureStorageInterfaceCube *dest, TextureStorageInterfaceCube *source);
shannon.woods%transgaming.com@gtempaccount.com414e82a2013-04-13 03:44:05 +0000141 virtual bool copyToRenderTarget(TextureStorageInterface3D *dest, TextureStorageInterface3D *source);
shannon.woods%transgaming.com@gtempaccount.com6c86bd52013-04-13 03:45:45 +0000142 virtual bool copyToRenderTarget(TextureStorageInterface2DArray *dest, TextureStorageInterface2DArray *source);
daniel@transgaming.comad6aee72012-11-28 19:33:42 +0000143
shannon.woods@transgaming.com664916b2013-01-25 21:50:32 +0000144 virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000145 GLint xoffset, GLint yoffset, TextureStorageInterface2D *storage, GLint level);
shannon.woods@transgaming.com664916b2013-01-25 21:50:32 +0000146 virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000147 GLint xoffset, GLint yoffset, TextureStorageInterfaceCube *storage, GLenum target, GLint level);
shannon.woods%transgaming.com@gtempaccount.com414e82a2013-04-13 03:44:05 +0000148 virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
149 GLint xoffset, GLint yoffset, GLint zOffset, TextureStorageInterface3D *storage, GLint level);
shannon.woods%transgaming.com@gtempaccount.com6c86bd52013-04-13 03:45:45 +0000150 virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
151 GLint xoffset, GLint yoffset, GLint zOffset, TextureStorageInterface2DArray *storage, GLint level);
daniel@transgaming.com38380882012-11-28 19:36:39 +0000152
shannon.woods@transgaming.comea4a0c62013-02-28 23:06:29 +0000153 virtual bool blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect,
Geoff Lang125deab2013-08-09 13:34:16 -0400154 const gl::Rectangle *scissor, bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter);
Jamie Madilleb9baab2014-03-24 13:19:43 -0400155 virtual void readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
156 GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, void* pixels);
daniel@transgaming.com6c872172012-11-28 19:39:33 +0000157
daniel@transgaming.coma9c71422012-11-28 20:58:45 +0000158 // RenderTarget creation
daniel@transgaming.comf2423652012-11-28 20:53:50 +0000159 virtual RenderTarget *createRenderTarget(SwapChain *swapChain, bool depth);
Geoff Langa2d97f12013-06-11 11:44:02 -0400160 virtual RenderTarget *createRenderTarget(int width, int height, GLenum format, GLsizei samples);
daniel@transgaming.comf2423652012-11-28 20:53:50 +0000161
daniel@transgaming.coma9c71422012-11-28 20:58:45 +0000162 // Shader operations
Geoff Lang48dcae72014-02-05 16:28:24 -0500163 virtual ShaderExecutable *loadExecutable(const void *function, size_t length, rx::ShaderType type,
164 const std::vector<gl::LinkedVarying> &transformFeedbackVaryings,
165 bool separatedOutputBuffers);
166 virtual ShaderExecutable *compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, rx::ShaderType type,
167 const std::vector<gl::LinkedVarying> &transformFeedbackVaryings,
168 bool separatedOutputBuffers, D3DWorkaroundType workaround);
Jamie Madill8ff21ae2014-02-04 16:04:05 -0500169 virtual UniformStorage *createUniformStorage(size_t storageSize);
daniel@transgaming.coma9c71422012-11-28 20:58:45 +0000170
daniel@transgaming.com244e1832012-12-20 20:52:35 +0000171 // Image operations
172 virtual Image *createImage();
daniel@transgaming.comf721fdb2012-12-20 20:53:11 +0000173 virtual void generateMipmap(Image *dest, Image *source);
daniel@transgaming.com413d2712012-12-20 21:11:04 +0000174 virtual TextureStorage *createTextureStorage2D(SwapChain *swapChain);
Nicolas Capensbf712d02014-03-31 14:23:35 -0400175 virtual TextureStorage *createTextureStorage2D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels);
176 virtual TextureStorage *createTextureStorageCube(GLenum internalformat, bool renderTarget, int size, int levels);
177 virtual TextureStorage *createTextureStorage3D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels);
178 virtual TextureStorage *createTextureStorage2DArray(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels);
daniel@transgaming.com244e1832012-12-20 20:52:35 +0000179
daniel@transgaming.com3f255b42012-12-20 21:07:35 +0000180 // Buffer creation
Brandon Jonesd38f9262014-06-18 16:26:45 -0700181 virtual BufferImpl *createBuffer();
daniel@transgaming.com3f255b42012-12-20 21:07:35 +0000182 virtual VertexBuffer *createVertexBuffer();
daniel@transgaming.com0b6d7742012-12-20 21:09:47 +0000183 virtual IndexBuffer *createIndexBuffer();
daniel@transgaming.com3f255b42012-12-20 21:07:35 +0000184
Brandon Jones5bf98292014-06-06 17:19:38 -0700185 // Vertex Array creation
186 virtual VertexArrayImpl *createVertexArray();
187
shannon.woods@transgaming.comcfe787e2013-02-28 23:03:35 +0000188 // Query and Fence creation
shannon.woods@transgaming.com50df6c52013-02-28 23:02:49 +0000189 virtual QueryImpl *createQuery(GLenum type);
shannon.woods@transgaming.comcfe787e2013-02-28 23:03:35 +0000190 virtual FenceImpl *createFence();
shannon.woods@transgaming.com50df6c52013-02-28 23:02:49 +0000191
daniel@transgaming.com1d6aff22012-11-28 19:30:42 +0000192 // D3D11-renderer specific methods
daniel@transgaming.com25072f62012-11-28 19:31:32 +0000193 ID3D11Device *getDevice() { return mDevice; }
daniel@transgaming.com1d6aff22012-11-28 19:30:42 +0000194 ID3D11DeviceContext *getDeviceContext() { return mDeviceContext; };
daniel@transgaming.coma60160b2012-11-28 19:41:15 +0000195 IDXGIFactory *getDxgiFactory() { return mDxgiFactory; };
daniel@transgaming.com1d6aff22012-11-28 19:30:42 +0000196
Geoff Langb86b9792013-06-04 16:32:05 -0400197 Blit11 *getBlitter() { return mBlit; }
198
Jamie Madilla21eea32013-09-18 14:36:25 -0400199 // Buffer-to-texture and Texture-to-buffer copies
Geoff Lang005df412013-10-16 14:12:50 -0400200 virtual bool supportsFastCopyBufferToTexture(GLenum internalFormat) const;
Jamie Madilla21eea32013-09-18 14:36:25 -0400201 virtual bool fastCopyBufferToTexture(const gl::PixelUnpackState &unpack, unsigned int offset, RenderTarget *destRenderTarget,
202 GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &destArea);
203
Jamie Madill3c7fa222014-06-05 13:08:51 -0400204 bool getRenderTargetResource(gl::FramebufferAttachment *colorbuffer, unsigned int *subresourceIndex, ID3D11Texture2D **resource);
shannon.woods%transgaming.com@gtempaccount.comba2744f2013-04-13 03:33:38 +0000205 void unapplyRenderTargets();
206 void setOneTimeRenderTarget(ID3D11RenderTargetView *renderTargetView);
Jamie Madill7538f7f2014-04-17 11:53:39 -0400207 void packPixels(ID3D11Texture2D *readTexture, const PackPixelsParams &params, void *pixelsOut);
shannon.woods@transgaming.comfdeacb82013-01-25 21:52:34 +0000208
shannonwoods@chromium.org6e4f2a62013-05-30 00:15:19 +0000209 virtual bool getLUID(LUID *adapterLuid) const;
Geoff Lang005df412013-10-16 14:12:50 -0400210 virtual GLenum getNativeTextureFormat(GLenum internalFormat) const;
Jamie Madill95ffb862014-01-29 09:26:59 -0500211 virtual rx::VertexConversionType getVertexConversionType(const gl::VertexFormat &vertexFormat) const;
212 virtual GLenum getVertexComponentType(const gl::VertexFormat &vertexFormat) const;
shannonwoods@chromium.org6e4f2a62013-05-30 00:15:19 +0000213
daniel@transgaming.com1d6aff22012-11-28 19:30:42 +0000214 private:
215 DISALLOW_COPY_AND_ASSIGN(Renderer11);
216
Geoff Langcec35902014-04-16 10:52:36 -0400217 virtual gl::Caps generateCaps() const;
218
daniel@transgaming.comc5114302012-12-20 21:11:36 +0000219 void drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer);
shannon.woods@transgaming.com00032cb2013-01-25 21:56:30 +0000220 void drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer, int instances);
daniel@transgaming.comc5114302012-12-20 21:11:36 +0000221
Jamie Madilleb9baab2014-03-24 13:19:43 -0400222 void readTextureData(ID3D11Texture2D *texture, unsigned int subResource, const gl::Rectangle &area, GLenum format,
223 GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, void *pixels);
daniel@transgaming.comee42a0a2013-01-11 04:09:15 +0000224
Geoff Lang685806d2013-06-12 11:16:36 -0400225 bool blitRenderbufferRect(const gl::Rectangle &readRect, const gl::Rectangle &drawRect, RenderTarget *readRenderTarget,
Geoff Lang125deab2013-08-09 13:34:16 -0400226 RenderTarget *drawRenderTarget, GLenum filter, const gl::Rectangle *scissor,
227 bool colorBlit, bool depthBlit, bool stencilBlit);
shannon.woods@transgaming.comd67f9ce2013-02-28 23:06:09 +0000228 ID3D11Texture2D *resolveMultisampledTexture(ID3D11Texture2D *source, unsigned int subresource);
229
Jamie Madill3c7fa222014-06-05 13:08:51 -0400230 static void invalidateFBOAttachmentSwizzles(gl::FramebufferAttachment *attachment, int mipLevel);
Geoff Lang42477a42013-09-17 17:07:02 -0400231 static void invalidateFramebufferSwizzles(gl::Framebuffer *framebuffer);
232
daniel@transgaming.com1d6aff22012-11-28 19:30:42 +0000233 HMODULE mD3d11Module;
234 HMODULE mDxgiModule;
235 HDC mDc;
236
Geoff Langdad5ed32014-02-10 12:59:17 -0500237 HLSLCompiler mCompiler;
238
daniel@transgaming.com1d6aff22012-11-28 19:30:42 +0000239 bool mDeviceLost;
240
241 void initializeDevice();
242 void releaseDeviceResources();
daniel@transgaming.comca1ac1f2013-01-11 04:13:05 +0000243 int getMinorShaderModel() const;
shannon.woods@transgaming.comddd6c802013-02-28 23:05:14 +0000244 void release();
daniel@transgaming.com1d6aff22012-11-28 19:30:42 +0000245
daniel@transgaming.comf8ba1092012-11-28 19:37:53 +0000246 RenderStateCache mStateCache;
247
shannon.woods@transgaming.comdf2fd572013-02-28 23:05:40 +0000248 // Multisample format support
249 struct MultisampleSupportInfo
250 {
251 unsigned int qualityLevels[D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT];
Geoff Lang61e49a52013-05-29 10:22:58 -0400252 unsigned int maxSupportedSamples;
shannon.woods@transgaming.comdf2fd572013-02-28 23:05:40 +0000253 };
Geoff Lang61e49a52013-05-29 10:22:58 -0400254 MultisampleSupportInfo getMultisampleSupportInfo(DXGI_FORMAT format);
shannon.woods@transgaming.comdf2fd572013-02-28 23:05:40 +0000255
256 typedef std::unordered_map<DXGI_FORMAT, MultisampleSupportInfo> MultisampleSupportMap;
257 MultisampleSupportMap mMultisampleSupportMap;
258
259 unsigned int mMaxSupportedSamples;
260
daniel@transgaming.com7b6b83e2012-11-28 21:00:30 +0000261 // current render target states
shannon.woods%transgaming.com@gtempaccount.comf4fe7102013-04-13 03:30:26 +0000262 unsigned int mAppliedRenderTargetSerials[gl::IMPLEMENTATION_MAX_DRAW_BUFFERS];
daniel@transgaming.com80fc3322012-11-28 21:02:13 +0000263 unsigned int mAppliedDepthbufferSerial;
264 unsigned int mAppliedStencilbufferSerial;
daniel@transgaming.com7b6b83e2012-11-28 21:00:30 +0000265 bool mDepthStencilInitialized;
266 bool mRenderTargetDescInitialized;
267 rx::RenderTarget::Desc mRenderTargetDesc;
daniel@transgaming.com7b6b83e2012-11-28 21:00:30 +0000268
daniel@transgaming.com54de24f2013-01-11 04:07:59 +0000269 // Currently applied sampler states
shannon.woods@transgaming.com233fe952013-01-25 21:51:57 +0000270 bool mForceSetVertexSamplerStates[gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS];
271 gl::SamplerState mCurVertexSamplerStates[gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS];
daniel@transgaming.com54de24f2013-01-11 04:07:59 +0000272
273 bool mForceSetPixelSamplerStates[gl::MAX_TEXTURE_IMAGE_UNITS];
274 gl::SamplerState mCurPixelSamplerStates[gl::MAX_TEXTURE_IMAGE_UNITS];
275
daniel@transgaming.come33c8bf2013-01-11 04:11:33 +0000276 // Currently applied textures
Geoff Lang91382e52014-01-07 16:16:30 -0500277 ID3D11ShaderResourceView *mCurVertexSRVs[gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS];
278 ID3D11ShaderResourceView *mCurPixelSRVs[gl::MAX_TEXTURE_IMAGE_UNITS];
daniel@transgaming.come33c8bf2013-01-11 04:11:33 +0000279
daniel@transgaming.comf8ba1092012-11-28 19:37:53 +0000280 // Currently applied blend state
281 bool mForceSetBlendState;
282 gl::BlendState mCurBlendState;
Geoff Lang2a64ee42013-05-31 11:22:40 -0400283 gl::ColorF mCurBlendColor;
daniel@transgaming.comf8ba1092012-11-28 19:37:53 +0000284 unsigned int mCurSampleMask;
285
daniel@transgaming.comdcf1e672012-11-28 19:38:19 +0000286 // Currently applied rasterizer state
287 bool mForceSetRasterState;
288 gl::RasterizerState mCurRasterState;
daniel@transgaming.comdcf1e672012-11-28 19:38:19 +0000289
daniel@transgaming.com5503fd02012-11-28 19:38:57 +0000290 // Currently applied depth stencil state
291 bool mForceSetDepthStencilState;
292 gl::DepthStencilState mCurDepthStencilState;
293 int mCurStencilRef;
294 int mCurStencilBackRef;
295
daniel@transgaming.comdcf1e672012-11-28 19:38:19 +0000296 // Currently applied scissor rectangle
297 bool mForceSetScissor;
daniel@transgaming.comd55e8c12012-11-28 21:07:02 +0000298 bool mScissorEnabled;
daniel@transgaming.comdcf1e672012-11-28 19:38:19 +0000299 gl::Rectangle mCurScissor;
daniel@transgaming.comdcf1e672012-11-28 19:38:19 +0000300
daniel@transgaming.com53670042012-11-28 20:55:51 +0000301 // Currently applied viewport
302 bool mForceSetViewport;
303 gl::Rectangle mCurViewport;
304 float mCurNear;
305 float mCurFar;
306
Geoff Lang4c095862013-07-22 10:43:36 -0400307 // Currently applied primitive topology
308 D3D11_PRIMITIVE_TOPOLOGY mCurrentPrimitiveTopology;
309
Geoff Langeeba6e12014-02-03 13:12:30 -0500310 // Currently applied index buffer
Geoff Lang7840b172014-03-13 11:20:44 -0400311 ID3D11Buffer *mAppliedIB;
312 DXGI_FORMAT mAppliedIBFormat;
daniel@transgaming.com7fbf4862013-01-11 04:09:22 +0000313 unsigned int mAppliedIBOffset;
314
Geoff Langeeba6e12014-02-03 13:12:30 -0500315 // Currently applied transform feedback buffers
316 ID3D11Buffer *mAppliedTFBuffers[gl::IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS];
317 GLintptr mAppliedTFOffsets[gl::IMPLEMENTATION_MAX_TRANSFORM_FEEDBACK_BUFFERS];
318
319 // Currently applied shaders
Jamie Madill6246dc82014-01-29 09:26:47 -0500320 ID3D11VertexShader *mAppliedVertexShader;
321 ID3D11GeometryShader *mAppliedGeometryShader;
Geoff Lang4c5c6bb2014-02-05 16:32:46 -0500322 ID3D11GeometryShader *mCurPointGeometryShader;
Jamie Madill6246dc82014-01-29 09:26:47 -0500323 ID3D11PixelShader *mAppliedPixelShader;
daniel@transgaming.come4991412012-12-20 20:55:34 +0000324
shannon.woods@transgaming.com5fb979d2013-01-25 21:53:04 +0000325 dx_VertexConstants mVertexConstants;
326 dx_VertexConstants mAppliedVertexConstants;
327 ID3D11Buffer *mDriverConstantBufferVS;
Geoff Langc6354ee2013-07-22 10:40:07 -0400328 ID3D11Buffer *mCurrentVertexConstantBuffer;
329 unsigned int mCurrentConstantBufferVS[gl::IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS];
shannon.woods@transgaming.com5fb979d2013-01-25 21:53:04 +0000330
331 dx_PixelConstants mPixelConstants;
332 dx_PixelConstants mAppliedPixelConstants;
333 ID3D11Buffer *mDriverConstantBufferPS;
Geoff Langc6354ee2013-07-22 10:40:07 -0400334 ID3D11Buffer *mCurrentPixelConstantBuffer;
335 unsigned int mCurrentConstantBufferPS[gl::IMPLEMENTATION_MAX_VERTEX_SHADER_UNIFORM_BUFFERS];
336
337 ID3D11Buffer *mCurrentGeometryConstantBuffer;
daniel@transgaming.comed36abd2013-01-11 21:15:58 +0000338
daniel@transgaming.comc5431eb2012-12-20 21:10:15 +0000339 // Vertex, index and input layouts
340 VertexDataManager *mVertexDataManager;
341 IndexDataManager *mIndexDataManager;
342 InputLayoutCache mInputLayoutCache;
343
daniel@transgaming.comc5114302012-12-20 21:11:36 +0000344 StreamingIndexBufferInterface *mLineLoopIB;
daniel@transgaming.com4fd1f982013-01-11 04:12:58 +0000345 StreamingIndexBufferInterface *mTriangleFanIB;
daniel@transgaming.comc5114302012-12-20 21:11:36 +0000346
shannon.woods@transgaming.com9d971ff2013-01-25 21:50:53 +0000347 // Texture copy resources
Geoff Langb86b9792013-06-04 16:32:05 -0400348 Blit11 *mBlit;
Jamie Madilla21eea32013-09-18 14:36:25 -0400349 PixelTransfer11 *mPixelTransfer;
shannonwoods@chromium.org7b61d5c2013-05-30 00:04:12 +0000350
shannon.woods@transgaming.com34f507c2013-01-25 21:52:15 +0000351 // Masked clear resources
Geoff Langda507fe2013-08-20 12:01:42 -0400352 Clear11 *mClear;
shannon.woods@transgaming.com34f507c2013-01-25 21:52:15 +0000353
daniel@transgaming.combdf787f2013-02-01 03:20:36 +0000354 // Sync query
355 ID3D11Query *mSyncQuery;
356
daniel@transgaming.com25072f62012-11-28 19:31:32 +0000357 ID3D11Device *mDevice;
358 D3D_FEATURE_LEVEL mFeatureLevel;
daniel@transgaming.com1d6aff22012-11-28 19:30:42 +0000359 ID3D11DeviceContext *mDeviceContext;
daniel@transgaming.com65e65372012-11-28 19:33:50 +0000360 IDXGIAdapter *mDxgiAdapter;
daniel@transgaming.com1f811f52012-11-28 20:57:39 +0000361 DXGI_ADAPTER_DESC mAdapterDescription;
362 char mDescription[128];
daniel@transgaming.coma60160b2012-11-28 19:41:15 +0000363 IDXGIFactory *mDxgiFactory;
daniel@transgaming.com1d6aff22012-11-28 19:30:42 +0000364};
365
366}
367#endif // LIBGLESV2_RENDERER_RENDERER11_H_