blob: 71fc69ff6fd94689438c82b111dc410c27b39499 [file] [log] [blame]
daniel@transgaming.com2507f412012-10-31 18:46:48 +00001//
Geoff Langeeba6e12014-02-03 13:12:30 -05002// Copyright (c) 2012-2014 The ANGLE Project Authors. All rights reserved.
daniel@transgaming.com2507f412012-10-31 18:46:48 +00003// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
daniel@transgaming.com1d6aff22012-11-28 19:30:42 +00007// Renderer9.h: Defines a back-end specific class for the D3D9 renderer.
daniel@transgaming.com2507f412012-10-31 18:46:48 +00008
9#ifndef LIBGLESV2_RENDERER_RENDERER9_H_
10#define LIBGLESV2_RENDERER_RENDERER9_H_
11
daniel@transgaming.com2507f412012-10-31 18:46:48 +000012#include "common/angleutils.h"
shannonwoods@chromium.orga2ecfcc2013-05-30 00:11:59 +000013#include "common/mathutil.h"
Geoff Langdad5ed32014-02-10 12:59:17 -050014#include "libGLESv2/renderer/d3d/HLSLCompiler.h"
Geoff Lang7ea42a52014-02-10 12:49:15 -050015#include "libGLESv2/renderer/d3d9/ShaderCache.h"
Geoff Langd47e0fc2013-08-29 11:40:43 -040016#include "libGLESv2/renderer/d3d9/VertexDeclarationCache.h"
daniel@transgaming.com2507f412012-10-31 18:46:48 +000017#include "libGLESv2/renderer/Renderer.h"
shannon.woods@transgaming.comd2811d62013-02-28 23:11:19 +000018#include "libGLESv2/renderer/RenderTarget.h"
daniel@transgaming.com67094ee2012-11-28 20:53:04 +000019
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000020namespace gl
21{
Jamie Madill3c7fa222014-06-05 13:08:51 -040022class FramebufferAttachment;
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000023}
24
daniel@transgaming.com31240482012-11-28 21:06:41 +000025namespace rx
daniel@transgaming.com67094ee2012-11-28 20:53:04 +000026{
27class VertexDataManager;
shannon.woods@transgaming.com486d9e92013-02-28 23:15:41 +000028class IndexDataManager;
daniel@transgaming.com50cc7252012-12-20 21:09:23 +000029class StreamingIndexBufferInterface;
daniel@transgaming.com91207b72012-11-28 20:56:43 +000030struct TranslatedAttribute;
Geoff Langdce735c2013-06-04 10:21:18 -040031class Blit9;
daniel@transgaming.com2507f412012-10-31 18:46:48 +000032
33class Renderer9 : public Renderer
34{
35 public:
Geoff Lang64c83242014-05-06 10:49:24 -040036 Renderer9(egl::Display *display, HDC hDc);
daniel@transgaming.com2507f412012-10-31 18:46:48 +000037 virtual ~Renderer9();
38
daniel@transgaming.comb64ed282012-11-28 20:54:02 +000039 static Renderer9 *makeRenderer9(Renderer *renderer);
40
daniel@transgaming.com2507f412012-10-31 18:46:48 +000041 virtual EGLint initialize();
42 virtual bool resetDevice();
43
44 virtual int generateConfigs(ConfigDesc **configDescList);
45 virtual void deleteConfigs(ConfigDesc *configDescList);
46
daniel@transgaming.com91207b72012-11-28 20:56:43 +000047 void startScene();
48 void endScene();
daniel@transgaming.com2507f412012-10-31 18:46:48 +000049
50 virtual void sync(bool block);
daniel@transgaming.comb9bb2792012-11-28 19:36:49 +000051
52 virtual SwapChain *createSwapChain(HWND window, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat);
53
daniel@transgaming.com2507f412012-10-31 18:46:48 +000054 IDirect3DQuery9* allocateEventQuery();
55 void freeEventQuery(IDirect3DQuery9* query);
56
57 // resource creation
daniel@transgaming.com113f0eb2012-10-31 18:46:58 +000058 IDirect3DVertexShader9 *createVertexShader(const DWORD *function, size_t length);
59 IDirect3DPixelShader9 *createPixelShader(const DWORD *function, size_t length);
60 HRESULT createVertexBuffer(UINT Length, DWORD Usage, IDirect3DVertexBuffer9 **ppVertexBuffer);
61 HRESULT createIndexBuffer(UINT Length, DWORD Usage, D3DFORMAT Format, IDirect3DIndexBuffer9 **ppIndexBuffer);
Geoff Lange2e0ce02013-09-17 17:05:08 -040062 virtual void generateSwizzle(gl::Texture *texture);
daniel@transgaming.com2507f412012-10-31 18:46:48 +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.comae39ee22012-11-28 19:42:02 +000078 virtual bool applyRenderTarget(gl::Framebuffer *frameBuffer);
Geoff Lang04fb89a2014-06-09 15:05:36 -040079 virtual void applyShaders(gl::ProgramBinary *programBinary, const gl::VertexFormat inputLayout[], const gl::Framebuffer *framebuffer,
80 bool rasterizerDiscard, bool transformFeedbackActive);
Jamie Madill8ff21ae2014-02-04 16:04:05 -050081 virtual void applyUniforms(const gl::ProgramBinary &programBinary);
daniel@transgaming.com91207b72012-11-28 20:56:43 +000082 virtual bool applyPrimitiveType(GLenum primitiveType, GLsizei elementCount);
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);
daniel@transgaming.com493d4f82012-11-28 19:35:45 +000086
Geoff Langeeba6e12014-02-03 13:12:30 -050087 virtual void applyTransformFeedbackBuffers(gl::Buffer *transformFeedbackBuffers[], GLintptr offsets[]);
88
Geoff Lang4c5c6bb2014-02-05 16:32:46 -050089 virtual void drawArrays(GLenum mode, GLsizei count, GLsizei instances, bool transformFeedbackActive);
90 virtual void drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices,
91 gl::Buffer *elementArrayBuffer, const TranslatedIndexData &indexInfo, GLsizei instances);
daniel@transgaming.com67094ee2012-11-28 20:53:04 +000092
daniel@transgaming.com084a2572012-11-28 20:55:17 +000093 virtual void clear(const gl::ClearParameters &clearParams, gl::Framebuffer *frameBuffer);
daniel@transgaming.comd084c622012-11-28 19:36:05 +000094
daniel@transgaming.comc43a6052012-11-28 19:41:51 +000095 virtual void markAllStateDirty();
96
daniel@transgaming.com2507f412012-10-31 18:46:48 +000097 // lost device
shannon.woods@transgaming.comeb049e22013-02-28 23:04:49 +000098 void notifyDeviceLost();
daniel@transgaming.com2507f412012-10-31 18:46:48 +000099 virtual bool isDeviceLost();
100 virtual bool testDeviceLost(bool notify);
101 virtual bool testDeviceResettable();
102
daniel@transgaming.com1d6aff22012-11-28 19:30:42 +0000103 IDirect3DDevice9 *getDevice() { return mDevice; }
daniel@transgaming.com2507f412012-10-31 18:46:48 +0000104 virtual DWORD getAdapterVendor() const;
daniel@transgaming.comca1ac1f2013-01-11 04:13:05 +0000105 virtual std::string getRendererDescription() const;
daniel@transgaming.com2507f412012-10-31 18:46:48 +0000106 virtual GUID getAdapterIdentifier() const;
107
shannon.woods@transgaming.com233fe952013-01-25 21:51:57 +0000108 virtual unsigned int getMaxVertexTextureImageUnits() const;
shannon.woods@transgaming.com76cd88c2013-01-25 21:54:36 +0000109 virtual unsigned int getMaxCombinedTextureImageUnits() const;
shannon.woods@transgaming.comd8136cb2013-02-28 23:14:44 +0000110 virtual unsigned int getReservedVertexUniformVectors() const;
111 virtual unsigned int getReservedFragmentUniformVectors() const;
112 virtual unsigned int getMaxVertexUniformVectors() const;
113 virtual unsigned int getMaxFragmentUniformVectors() const;
114 virtual unsigned int getMaxVaryingVectors() const;
shannon.woods%transgaming.com@gtempaccount.com3f72ce32013-04-13 03:36:43 +0000115 virtual unsigned int getMaxVertexShaderUniformBuffers() const;
116 virtual unsigned int getMaxFragmentShaderUniformBuffers() const;
shannonwoods@chromium.org2b544222013-05-30 00:11:12 +0000117 virtual unsigned int getReservedVertexUniformBuffers() const;
118 virtual unsigned int getReservedFragmentUniformBuffers() const;
shannon.woods%transgaming.com@gtempaccount.com3f72ce32013-04-13 03:36:43 +0000119 virtual unsigned int getMaxTransformFeedbackBuffers() const;
Geoff Lang1b6edcb2014-02-03 14:27:56 -0500120 virtual unsigned int getMaxTransformFeedbackSeparateComponents() const;
121 virtual unsigned int getMaxTransformFeedbackInterleavedComponents() const;
shannonwoods@chromium.org33e798f2013-05-30 00:05:05 +0000122 virtual unsigned int getMaxUniformBufferSize() const;
daniel@transgaming.com2507f412012-10-31 18:46:48 +0000123 virtual bool getShareHandleSupport() const;
shannon.woods@transgaming.com8d2f0862013-02-28 23:09:19 +0000124 virtual bool getPostSubBufferSupport() const;
Jamie Madill13a2f852013-12-11 16:35:08 -0500125 virtual int getMaxRecommendedElementsIndices() const;
126 virtual int getMaxRecommendedElementsVertices() const;
daniel@transgaming.com2507f412012-10-31 18:46:48 +0000127
daniel@transgaming.com9549bea2012-11-28 20:57:23 +0000128 virtual int getMajorShaderModel() const;
daniel@transgaming.com2507f412012-10-31 18:46:48 +0000129 virtual float getMaxPointSize() const;
shannon.woods@transgaming.com8ce2f8f2013-02-28 23:07:10 +0000130 virtual int getMaxViewportDimension() const;
daniel@transgaming.com2507f412012-10-31 18:46:48 +0000131 virtual int getMaxTextureWidth() const;
132 virtual int getMaxTextureHeight() const;
shannon.woods%transgaming.com@gtempaccount.comc1fdf6b2013-04-13 03:44:41 +0000133 virtual int getMaxTextureDepth() const;
shannon.woods%transgaming.com@gtempaccount.coma98a8112013-04-13 03:45:57 +0000134 virtual int getMaxTextureArrayLayers() const;
daniel@transgaming.com204677a2013-01-11 21:16:09 +0000135 DWORD getCapsDeclTypes() const;
daniel@transgaming.com2507f412012-10-31 18:46:48 +0000136 virtual int getMinSwapInterval() const;
137 virtual int getMaxSwapInterval() const;
138
139 virtual GLsizei getMaxSupportedSamples() const;
Geoff Lang005df412013-10-16 14:12:50 -0400140 virtual GLsizei getMaxSupportedFormatSamples(GLenum internalFormat) const;
141 virtual GLsizei getNumSampleCounts(GLenum internalFormat) const;
142 virtual void getSampleCounts(GLenum internalFormat, GLsizei bufSize, GLint *params) const;
daniel@transgaming.com2507f412012-10-31 18:46:48 +0000143 int getNearestSupportedSamples(D3DFORMAT format, int requested) const;
shannon.woods%transgaming.com@gtempaccount.comb290ac12013-04-13 03:28:15 +0000144
Geoff Langcec35902014-04-16 10:52:36 -0400145 virtual unsigned int getMaxRenderTargets() const;
daniel@transgaming.com1d80eee2012-11-28 19:33:31 +0000146
daniel@transgaming.coma9c71422012-11-28 20:58:45 +0000147 // Pixel operations
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000148 virtual bool copyToRenderTarget(TextureStorageInterface2D *dest, TextureStorageInterface2D *source);
149 virtual bool copyToRenderTarget(TextureStorageInterfaceCube *dest, TextureStorageInterfaceCube *source);
shannon.woods%transgaming.com@gtempaccount.com414e82a2013-04-13 03:44:05 +0000150 virtual bool copyToRenderTarget(TextureStorageInterface3D *dest, TextureStorageInterface3D *source);
shannon.woods%transgaming.com@gtempaccount.com6c86bd52013-04-13 03:45:45 +0000151 virtual bool copyToRenderTarget(TextureStorageInterface2DArray *dest, TextureStorageInterface2DArray *source);
daniel@transgaming.com1d80eee2012-11-28 19:33:31 +0000152
shannon.woods@transgaming.com664916b2013-01-25 21:50:32 +0000153 virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000154 GLint xoffset, GLint yoffset, TextureStorageInterface2D *storage, GLint level);
shannon.woods@transgaming.com664916b2013-01-25 21:50:32 +0000155 virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
daniel@transgaming.com87705f82012-12-20 21:10:45 +0000156 GLint xoffset, GLint yoffset, TextureStorageInterfaceCube *storage, GLenum target, GLint level);
shannon.woods%transgaming.com@gtempaccount.com414e82a2013-04-13 03:44:05 +0000157 virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
158 GLint xoffset, GLint yoffset, GLint zOffset, TextureStorageInterface3D *storage, GLint level);
shannon.woods%transgaming.com@gtempaccount.com6c86bd52013-04-13 03:45:45 +0000159 virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
160 GLint xoffset, GLint yoffset, GLint zOffset, TextureStorageInterface2DArray *storage, GLint level);
daniel@transgaming.comde8a7ff2012-11-28 19:34:13 +0000161
shannon.woods@transgaming.comea4a0c62013-02-28 23:06:29 +0000162 virtual bool blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect,
Geoff Lang125deab2013-08-09 13:34:16 -0400163 const gl::Rectangle *scissor, bool blitRenderTarget, bool blitDepth, bool blitStencil, GLenum filter);
Jamie Madilleb9baab2014-03-24 13:19:43 -0400164 virtual void readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format,
165 GLenum type, GLuint outputPitch, const gl::PixelPackState &pack, void* pixels);
daniel@transgaming.com6c872172012-11-28 19:39:33 +0000166
daniel@transgaming.coma9c71422012-11-28 20:58:45 +0000167 // RenderTarget creation
daniel@transgaming.comf2423652012-11-28 20:53:50 +0000168 virtual RenderTarget *createRenderTarget(SwapChain *swapChain, bool depth);
Geoff Langa2d97f12013-06-11 11:44:02 -0400169 virtual RenderTarget *createRenderTarget(int width, int height, GLenum format, GLsizei samples);
daniel@transgaming.comf2423652012-11-28 20:53:50 +0000170
daniel@transgaming.coma9c71422012-11-28 20:58:45 +0000171 // Shader operations
Geoff Lang48dcae72014-02-05 16:28:24 -0500172 virtual ShaderExecutable *loadExecutable(const void *function, size_t length, rx::ShaderType type,
173 const std::vector<gl::LinkedVarying> &transformFeedbackVaryings,
174 bool separatedOutputBuffers);
175 virtual ShaderExecutable *compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, rx::ShaderType type,
176 const std::vector<gl::LinkedVarying> &transformFeedbackVaryings,
177 bool separatedOutputBuffers, D3DWorkaroundType workaround);
Jamie Madill8ff21ae2014-02-04 16:04:05 -0500178 virtual UniformStorage *createUniformStorage(size_t storageSize);
daniel@transgaming.coma9c71422012-11-28 20:58:45 +0000179
daniel@transgaming.com244e1832012-12-20 20:52:35 +0000180 // Image operations
181 virtual Image *createImage();
daniel@transgaming.comf721fdb2012-12-20 20:53:11 +0000182 virtual void generateMipmap(Image *dest, Image *source);
daniel@transgaming.com413d2712012-12-20 21:11:04 +0000183 virtual TextureStorage *createTextureStorage2D(SwapChain *swapChain);
Nicolas Capensbf712d02014-03-31 14:23:35 -0400184 virtual TextureStorage *createTextureStorage2D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, int levels);
185 virtual TextureStorage *createTextureStorageCube(GLenum internalformat, bool renderTarget, int size, int levels);
186 virtual TextureStorage *createTextureStorage3D(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels);
187 virtual TextureStorage *createTextureStorage2DArray(GLenum internalformat, bool renderTarget, GLsizei width, GLsizei height, GLsizei depth, int levels);
daniel@transgaming.com244e1832012-12-20 20:52:35 +0000188
daniel@transgaming.com3f255b42012-12-20 21:07:35 +0000189 // Buffer creation
190 virtual VertexBuffer *createVertexBuffer();
daniel@transgaming.com0b6d7742012-12-20 21:09:47 +0000191 virtual IndexBuffer *createIndexBuffer();
shannon.woods@transgaming.com4e52b632013-02-28 23:08:01 +0000192 virtual BufferStorage *createBufferStorage();
daniel@transgaming.com3f255b42012-12-20 21:07:35 +0000193
Brandon Jones5bf98292014-06-06 17:19:38 -0700194 // Vertex Array creation
195 virtual VertexArrayImpl *createVertexArray();
196
shannon.woods@transgaming.comcfe787e2013-02-28 23:03:35 +0000197 // Query and Fence creation
shannon.woods@transgaming.com50df6c52013-02-28 23:02:49 +0000198 virtual QueryImpl *createQuery(GLenum type);
shannon.woods@transgaming.comcfe787e2013-02-28 23:03:35 +0000199 virtual FenceImpl *createFence();
shannon.woods@transgaming.com50df6c52013-02-28 23:02:49 +0000200
Jamie Madilla21eea32013-09-18 14:36:25 -0400201 // Buffer-to-texture and Texture-to-buffer copies
Geoff Lang005df412013-10-16 14:12:50 -0400202 virtual bool supportsFastCopyBufferToTexture(GLenum internalFormat) const;
Jamie Madilla21eea32013-09-18 14:36:25 -0400203 virtual bool fastCopyBufferToTexture(const gl::PixelUnpackState &unpack, unsigned int offset, RenderTarget *destRenderTarget,
204 GLenum destinationFormat, GLenum sourcePixelsType, const gl::Box &destArea);
205
daniel@transgaming.coma9c71422012-11-28 20:58:45 +0000206 // D3D9-renderer specific methods
daniel@transgaming.comde8a7ff2012-11-28 19:34:13 +0000207 bool boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest);
208
daniel@transgaming.com2507f412012-10-31 18:46:48 +0000209 D3DPOOL getTexturePool(DWORD usage) const;
210
shannonwoods@chromium.org6e4f2a62013-05-30 00:15:19 +0000211 virtual bool getLUID(LUID *adapterLuid) const;
Geoff Lang005df412013-10-16 14:12:50 -0400212 virtual GLenum getNativeTextureFormat(GLenum internalFormat) const;
Jamie Madill95ffb862014-01-29 09:26:59 -0500213 virtual rx::VertexConversionType getVertexConversionType(const gl::VertexFormat &vertexFormat) const;
214 virtual GLenum getVertexComponentType(const gl::VertexFormat &vertexFormat) const;
shannonwoods@chromium.org6e4f2a62013-05-30 00:15:19 +0000215
daniel@transgaming.com2507f412012-10-31 18:46:48 +0000216 private:
217 DISALLOW_COPY_AND_ASSIGN(Renderer9);
218
Geoff Langcec35902014-04-16 10:52:36 -0400219 virtual gl::Caps generateCaps() const;
220
221 void release();
Jamie Madillb7935e52013-11-20 15:47:47 -0500222
Jamie Madill834e8b72014-04-11 13:33:58 -0400223 void applyUniformnfv(gl::LinkedUniform *targetUniform, const GLfloat *v);
224 void applyUniformniv(gl::LinkedUniform *targetUniform, const GLint *v);
225 void applyUniformnbv(gl::LinkedUniform *targetUniform, const GLint *v);
daniel@transgaming.comb6e55102012-12-20 21:08:14 +0000226
daniel@transgaming.com91207b72012-11-28 20:56:43 +0000227 void drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer);
Geoff Langf8c2f5c2013-12-05 13:52:33 -0500228 void drawIndexedPoints(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer);
daniel@transgaming.com91207b72012-11-28 20:56:43 +0000229
daniel@transgaming.com1d80eee2012-11-28 19:33:31 +0000230 bool copyToRenderTarget(IDirect3DSurface9 *dest, IDirect3DSurface9 *source, bool fromManaged);
Jamie Madill3c7fa222014-06-05 13:08:51 -0400231 gl::FramebufferAttachment *getNullColorbuffer(gl::FramebufferAttachment *depthbuffer);
daniel@transgaming.com2507f412012-10-31 18:46:48 +0000232
daniel@transgaming.com113f0eb2012-10-31 18:46:58 +0000233 D3DPOOL getBufferPool(DWORD usage) const;
234
daniel@transgaming.com2507f412012-10-31 18:46:48 +0000235 HMODULE mD3d9Module;
236 HDC mDc;
237
238 void initializeDevice();
239 D3DPRESENT_PARAMETERS getDefaultPresentParameters();
240 void releaseDeviceResources();
241
Jamie Madillb7935e52013-11-20 15:47:47 -0500242 HRESULT getDeviceStatusCode();
Jamie Madill88f779d2013-12-03 10:57:56 -0500243 bool isRemovedDeviceResettable() const;
244 bool resetRemovedDevice();
Jamie Madillb7935e52013-11-20 15:47:47 -0500245
daniel@transgaming.com2507f412012-10-31 18:46:48 +0000246 UINT mAdapter;
247 D3DDEVTYPE mDeviceType;
daniel@transgaming.com2507f412012-10-31 18:46:48 +0000248 IDirect3D9 *mD3d9; // Always valid after successful initialization.
249 IDirect3D9Ex *mD3d9Ex; // Might be null if D3D9Ex is not supported.
250 IDirect3DDevice9 *mDevice;
251 IDirect3DDevice9Ex *mDeviceEx; // Might be null if D3D9Ex is not supported.
252
Geoff Langdad5ed32014-02-10 12:59:17 -0500253 HLSLCompiler mCompiler;
254
Geoff Langdce735c2013-06-04 10:21:18 -0400255 Blit9 *mBlit;
daniel@transgaming.comde8a7ff2012-11-28 19:34:13 +0000256
daniel@transgaming.com2507f412012-10-31 18:46:48 +0000257 HWND mDeviceWindow;
258
259 bool mDeviceLost;
260 D3DCAPS9 mDeviceCaps;
261 D3DADAPTER_IDENTIFIER9 mAdapterIdentifier;
262
daniel@transgaming.com91207b72012-11-28 20:56:43 +0000263 D3DPRIMITIVETYPE mPrimitiveType;
264 int mPrimitiveCount;
265 GLsizei mRepeatDraw;
daniel@transgaming.com91207b72012-11-28 20:56:43 +0000266
daniel@transgaming.com2507f412012-10-31 18:46:48 +0000267 bool mSceneStarted;
daniel@transgaming.com2507f412012-10-31 18:46:48 +0000268 int mMinSwapInterval;
269 int mMaxSwapInterval;
270
daniel@transgaming.com669c9952013-01-11 04:08:16 +0000271 bool mVertexTextureSupport;
272
Geoff Lang61e49a52013-05-29 10:22:58 -0400273 struct MultisampleSupportInfo
274 {
275 bool supportedSamples[D3DMULTISAMPLE_16_SAMPLES + 1];
276 unsigned int maxSupportedSamples;
277 };
278 typedef std::map<D3DFORMAT, MultisampleSupportInfo> MultisampleSupportMap;
279 MultisampleSupportMap mMultiSampleSupport;
280 unsigned int mMaxSupportedSamples;
281
282 MultisampleSupportInfo getMultiSampleSupport(D3DFORMAT format);
daniel@transgaming.com2507f412012-10-31 18:46:48 +0000283
daniel@transgaming.com220e79a2012-11-28 19:42:11 +0000284 // current render target states
285 unsigned int mAppliedRenderTargetSerial;
286 unsigned int mAppliedDepthbufferSerial;
287 unsigned int mAppliedStencilbufferSerial;
288 bool mDepthStencilInitialized;
289 bool mRenderTargetDescInitialized;
290 rx::RenderTarget::Desc mRenderTargetDesc;
daniel@transgaming.com3a0ef482012-11-28 21:01:20 +0000291 unsigned int mCurStencilSize;
daniel@transgaming.com237bc7e2012-11-28 21:01:06 +0000292 unsigned int mCurDepthSize;
daniel@transgaming.com220e79a2012-11-28 19:42:11 +0000293
daniel@transgaming.com0393e5b2012-11-28 20:55:33 +0000294 IDirect3DStateBlock9 *mMaskedClearSavedState;
295
daniel@transgaming.com493d4f82012-11-28 19:35:45 +0000296 // previously set render states
297 bool mForceSetDepthStencilState;
298 gl::DepthStencilState mCurDepthStencilState;
daniel@transgaming.com08c331d2012-11-28 19:38:39 +0000299 int mCurStencilRef;
300 int mCurStencilBackRef;
daniel@transgaming.com493d4f82012-11-28 19:35:45 +0000301 bool mCurFrontFaceCCW;
daniel@transgaming.com493d4f82012-11-28 19:35:45 +0000302
303 bool mForceSetRasterState;
304 gl::RasterizerState mCurRasterState;
daniel@transgaming.com493d4f82012-11-28 19:35:45 +0000305
306 bool mForceSetScissor;
307 gl::Rectangle mCurScissor;
daniel@transgaming.comd55e8c12012-11-28 21:07:02 +0000308 bool mScissorEnabled;
daniel@transgaming.com493d4f82012-11-28 19:35:45 +0000309
daniel@transgaming.com83e80ee2012-11-28 19:40:53 +0000310 bool mForceSetViewport;
311 gl::Rectangle mCurViewport;
312 float mCurNear;
313 float mCurFar;
Geoff Langde14d602013-08-14 12:28:33 -0400314 float mCurDepthFront;
daniel@transgaming.com83e80ee2012-11-28 19:40:53 +0000315
daniel@transgaming.com493d4f82012-11-28 19:35:45 +0000316 bool mForceSetBlendState;
317 gl::BlendState mCurBlendState;
Geoff Lang2a64ee42013-05-31 11:22:40 -0400318 gl::ColorF mCurBlendColor;
daniel@transgaming.com493d4f82012-11-28 19:35:45 +0000319 GLuint mCurSampleMask;
320
daniel@transgaming.come33c8bf2013-01-11 04:11:33 +0000321 // Currently applied sampler states
shannon.woods@transgaming.com233fe952013-01-25 21:51:57 +0000322 bool mForceSetVertexSamplerStates[gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS];
323 gl::SamplerState mCurVertexSamplerStates[gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS];
daniel@transgaming.come33c8bf2013-01-11 04:11:33 +0000324
325 bool mForceSetPixelSamplerStates[gl::MAX_TEXTURE_IMAGE_UNITS];
326 gl::SamplerState mCurPixelSamplerStates[gl::MAX_TEXTURE_IMAGE_UNITS];
327
328 // Currently applied textures
shannon.woods@transgaming.com233fe952013-01-25 21:51:57 +0000329 unsigned int mCurVertexTextureSerials[gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS];
daniel@transgaming.come33c8bf2013-01-11 04:11:33 +0000330 unsigned int mCurPixelTextureSerials[gl::MAX_TEXTURE_IMAGE_UNITS];
331
daniel@transgaming.com91207b72012-11-28 20:56:43 +0000332 unsigned int mAppliedIBSerial;
Jamie Madill6246dc82014-01-29 09:26:47 -0500333 IDirect3DVertexShader9 *mAppliedVertexShader;
334 IDirect3DPixelShader9 *mAppliedPixelShader;
Jamie Madilla5c9a142014-05-26 16:39:33 -0400335 unsigned int mAppliedProgramSerial;
336
daniel@transgaming.comed36abd2013-01-11 21:15:58 +0000337 rx::dx_VertexConstants mVertexConstants;
338 rx::dx_PixelConstants mPixelConstants;
339 bool mDxUniformsDirty;
daniel@transgaming.com91207b72012-11-28 20:56:43 +0000340
daniel@transgaming.com2507f412012-10-31 18:46:48 +0000341 // A pool of event queries that are currently unused.
342 std::vector<IDirect3DQuery9*> mEventQueryPool;
343 VertexShaderCache mVertexShaderCache;
344 PixelShaderCache mPixelShaderCache;
daniel@transgaming.com67094ee2012-11-28 20:53:04 +0000345
daniel@transgaming.com31240482012-11-28 21:06:41 +0000346 VertexDataManager *mVertexDataManager;
daniel@transgaming.com67094ee2012-11-28 20:53:04 +0000347 VertexDeclarationCache mVertexDeclarationCache;
daniel@transgaming.com91207b72012-11-28 20:56:43 +0000348
daniel@transgaming.com31240482012-11-28 21:06:41 +0000349 IndexDataManager *mIndexDataManager;
daniel@transgaming.com50cc7252012-12-20 21:09:23 +0000350 StreamingIndexBufferInterface *mLineLoopIB;
daniel@transgaming.come4e1a332012-12-20 20:52:09 +0000351
352 enum { NUM_NULL_COLORBUFFER_CACHE_ENTRIES = 12 };
353 struct NullColorbufferCacheEntry
354 {
355 UINT lruCount;
356 int width;
357 int height;
Jamie Madill3c7fa222014-06-05 13:08:51 -0400358 gl::FramebufferAttachment *buffer;
daniel@transgaming.come4e1a332012-12-20 20:52:09 +0000359 } mNullColorbufferCache[NUM_NULL_COLORBUFFER_CACHE_ENTRIES];
360 UINT mMaxNullColorbufferLRU;
361
daniel@transgaming.com2507f412012-10-31 18:46:48 +0000362};
363
364}
365#endif // LIBGLESV2_RENDERER_RENDERER9_H_