Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | // |
michael@0 | 2 | // Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved. |
michael@0 | 3 | // Use of this source code is governed by a BSD-style license that can be |
michael@0 | 4 | // found in the LICENSE file. |
michael@0 | 5 | // |
michael@0 | 6 | |
michael@0 | 7 | // Renderer9.h: Defines a back-end specific class for the D3D9 renderer. |
michael@0 | 8 | |
michael@0 | 9 | #ifndef LIBGLESV2_RENDERER_RENDERER9_H_ |
michael@0 | 10 | #define LIBGLESV2_RENDERER_RENDERER9_H_ |
michael@0 | 11 | |
michael@0 | 12 | #include "common/angleutils.h" |
michael@0 | 13 | #include "libGLESv2/mathutil.h" |
michael@0 | 14 | #include "libGLESv2/renderer/ShaderCache.h" |
michael@0 | 15 | #include "libGLESv2/renderer/VertexDeclarationCache.h" |
michael@0 | 16 | #include "libGLESv2/renderer/Renderer.h" |
michael@0 | 17 | #include "libGLESv2/renderer/RenderTarget.h" |
michael@0 | 18 | |
michael@0 | 19 | namespace gl |
michael@0 | 20 | { |
michael@0 | 21 | class Renderbuffer; |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | namespace rx |
michael@0 | 25 | { |
michael@0 | 26 | class VertexDataManager; |
michael@0 | 27 | class IndexDataManager; |
michael@0 | 28 | class StreamingIndexBufferInterface; |
michael@0 | 29 | struct TranslatedAttribute; |
michael@0 | 30 | |
michael@0 | 31 | class Renderer9 : public Renderer |
michael@0 | 32 | { |
michael@0 | 33 | public: |
michael@0 | 34 | Renderer9(egl::Display *display, HDC hDc, bool softwareDevice); |
michael@0 | 35 | virtual ~Renderer9(); |
michael@0 | 36 | |
michael@0 | 37 | static Renderer9 *makeRenderer9(Renderer *renderer); |
michael@0 | 38 | |
michael@0 | 39 | virtual EGLint initialize(); |
michael@0 | 40 | virtual bool resetDevice(); |
michael@0 | 41 | |
michael@0 | 42 | virtual int generateConfigs(ConfigDesc **configDescList); |
michael@0 | 43 | virtual void deleteConfigs(ConfigDesc *configDescList); |
michael@0 | 44 | |
michael@0 | 45 | void startScene(); |
michael@0 | 46 | void endScene(); |
michael@0 | 47 | |
michael@0 | 48 | virtual void sync(bool block); |
michael@0 | 49 | |
michael@0 | 50 | virtual SwapChain *createSwapChain(HWND window, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat); |
michael@0 | 51 | |
michael@0 | 52 | IDirect3DQuery9* allocateEventQuery(); |
michael@0 | 53 | void freeEventQuery(IDirect3DQuery9* query); |
michael@0 | 54 | |
michael@0 | 55 | // resource creation |
michael@0 | 56 | IDirect3DVertexShader9 *createVertexShader(const DWORD *function, size_t length); |
michael@0 | 57 | IDirect3DPixelShader9 *createPixelShader(const DWORD *function, size_t length); |
michael@0 | 58 | HRESULT createVertexBuffer(UINT Length, DWORD Usage, IDirect3DVertexBuffer9 **ppVertexBuffer); |
michael@0 | 59 | HRESULT createIndexBuffer(UINT Length, DWORD Usage, D3DFORMAT Format, IDirect3DIndexBuffer9 **ppIndexBuffer); |
michael@0 | 60 | #if 0 |
michael@0 | 61 | void *createTexture2D(); |
michael@0 | 62 | void *createTextureCube(); |
michael@0 | 63 | void *createQuery(); |
michael@0 | 64 | void *createIndexBuffer(); |
michael@0 | 65 | void *createVertexbuffer(); |
michael@0 | 66 | |
michael@0 | 67 | // state setup |
michael@0 | 68 | void applyShaders(); |
michael@0 | 69 | void applyConstants(); |
michael@0 | 70 | #endif |
michael@0 | 71 | virtual void setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &sampler); |
michael@0 | 72 | virtual void setTexture(gl::SamplerType type, int index, gl::Texture *texture); |
michael@0 | 73 | |
michael@0 | 74 | virtual void setRasterizerState(const gl::RasterizerState &rasterState); |
michael@0 | 75 | virtual void setBlendState(const gl::BlendState &blendState, const gl::Color &blendColor, |
michael@0 | 76 | unsigned int sampleMask); |
michael@0 | 77 | virtual void setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef, |
michael@0 | 78 | int stencilBackRef, bool frontFaceCCW); |
michael@0 | 79 | |
michael@0 | 80 | virtual void setScissorRectangle(const gl::Rectangle &scissor, bool enabled); |
michael@0 | 81 | virtual bool setViewport(const gl::Rectangle &viewport, float zNear, float zFar, GLenum drawMode, GLenum frontFace, |
michael@0 | 82 | bool ignoreViewport); |
michael@0 | 83 | |
michael@0 | 84 | virtual bool applyRenderTarget(gl::Framebuffer *frameBuffer); |
michael@0 | 85 | virtual void applyShaders(gl::ProgramBinary *programBinary); |
michael@0 | 86 | virtual void applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArray *uniformArray); |
michael@0 | 87 | virtual bool applyPrimitiveType(GLenum primitiveType, GLsizei elementCount); |
michael@0 | 88 | virtual GLenum applyVertexBuffer(gl::ProgramBinary *programBinary, gl::VertexAttribute vertexAttributes[], GLint first, GLsizei count, GLsizei instances); |
michael@0 | 89 | virtual GLenum applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo); |
michael@0 | 90 | |
michael@0 | 91 | virtual void drawArrays(GLenum mode, GLsizei count, GLsizei instances); |
michael@0 | 92 | virtual void drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, gl::Buffer *elementArrayBuffer, const TranslatedIndexData &indexInfo, GLsizei instances); |
michael@0 | 93 | |
michael@0 | 94 | virtual void clear(const gl::ClearParameters &clearParams, gl::Framebuffer *frameBuffer); |
michael@0 | 95 | |
michael@0 | 96 | virtual void markAllStateDirty(); |
michael@0 | 97 | |
michael@0 | 98 | // lost device |
michael@0 | 99 | void notifyDeviceLost(); |
michael@0 | 100 | virtual bool isDeviceLost(); |
michael@0 | 101 | virtual bool testDeviceLost(bool notify); |
michael@0 | 102 | virtual bool testDeviceResettable(); |
michael@0 | 103 | |
michael@0 | 104 | // Renderer capabilities |
michael@0 | 105 | IDirect3DDevice9 *getDevice() { return mDevice; } |
michael@0 | 106 | virtual DWORD getAdapterVendor() const; |
michael@0 | 107 | virtual std::string getRendererDescription() const; |
michael@0 | 108 | virtual GUID getAdapterIdentifier() const; |
michael@0 | 109 | |
michael@0 | 110 | virtual bool getBGRATextureSupport() const; |
michael@0 | 111 | virtual bool getDXT1TextureSupport(); |
michael@0 | 112 | virtual bool getDXT3TextureSupport(); |
michael@0 | 113 | virtual bool getDXT5TextureSupport(); |
michael@0 | 114 | virtual bool getEventQuerySupport(); |
michael@0 | 115 | virtual bool getFloat32TextureSupport(bool *filtering, bool *renderable); |
michael@0 | 116 | virtual bool getFloat16TextureSupport(bool *filtering, bool *renderable); |
michael@0 | 117 | virtual bool getLuminanceTextureSupport(); |
michael@0 | 118 | virtual bool getLuminanceAlphaTextureSupport(); |
michael@0 | 119 | virtual unsigned int getMaxVertexTextureImageUnits() const; |
michael@0 | 120 | virtual unsigned int getMaxCombinedTextureImageUnits() const; |
michael@0 | 121 | virtual unsigned int getReservedVertexUniformVectors() const; |
michael@0 | 122 | virtual unsigned int getReservedFragmentUniformVectors() const; |
michael@0 | 123 | virtual unsigned int getMaxVertexUniformVectors() const; |
michael@0 | 124 | virtual unsigned int getMaxFragmentUniformVectors() const; |
michael@0 | 125 | virtual unsigned int getMaxVaryingVectors() const; |
michael@0 | 126 | virtual bool getNonPower2TextureSupport() const; |
michael@0 | 127 | virtual bool getDepthTextureSupport() const; |
michael@0 | 128 | virtual bool getOcclusionQuerySupport() const; |
michael@0 | 129 | virtual bool getInstancingSupport() const; |
michael@0 | 130 | virtual bool getTextureFilterAnisotropySupport() const; |
michael@0 | 131 | virtual float getTextureMaxAnisotropy() const; |
michael@0 | 132 | virtual bool getShareHandleSupport() const; |
michael@0 | 133 | virtual bool getDerivativeInstructionSupport() const; |
michael@0 | 134 | virtual bool getPostSubBufferSupport() const; |
michael@0 | 135 | |
michael@0 | 136 | virtual int getMajorShaderModel() const; |
michael@0 | 137 | virtual float getMaxPointSize() const; |
michael@0 | 138 | virtual int getMaxViewportDimension() const; |
michael@0 | 139 | virtual int getMaxTextureWidth() const; |
michael@0 | 140 | virtual int getMaxTextureHeight() const; |
michael@0 | 141 | virtual bool get32BitIndexSupport() const; |
michael@0 | 142 | DWORD getCapsDeclTypes() const; |
michael@0 | 143 | virtual int getMinSwapInterval() const; |
michael@0 | 144 | virtual int getMaxSwapInterval() const; |
michael@0 | 145 | |
michael@0 | 146 | virtual GLsizei getMaxSupportedSamples() const; |
michael@0 | 147 | int getNearestSupportedSamples(D3DFORMAT format, int requested) const; |
michael@0 | 148 | |
michael@0 | 149 | virtual unsigned int getMaxRenderTargets() const; |
michael@0 | 150 | |
michael@0 | 151 | D3DFORMAT ConvertTextureInternalFormat(GLint internalformat); |
michael@0 | 152 | |
michael@0 | 153 | // Pixel operations |
michael@0 | 154 | virtual bool copyToRenderTarget(TextureStorageInterface2D *dest, TextureStorageInterface2D *source); |
michael@0 | 155 | virtual bool copyToRenderTarget(TextureStorageInterfaceCube *dest, TextureStorageInterfaceCube *source); |
michael@0 | 156 | |
michael@0 | 157 | virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, |
michael@0 | 158 | GLint xoffset, GLint yoffset, TextureStorageInterface2D *storage, GLint level); |
michael@0 | 159 | virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, |
michael@0 | 160 | GLint xoffset, GLint yoffset, TextureStorageInterfaceCube *storage, GLenum target, GLint level); |
michael@0 | 161 | |
michael@0 | 162 | virtual bool blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect, |
michael@0 | 163 | bool blitRenderTarget, bool blitDepthStencil); |
michael@0 | 164 | virtual void readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, |
michael@0 | 165 | GLsizei outputPitch, bool packReverseRowOrder, GLint packAlignment, void* pixels); |
michael@0 | 166 | |
michael@0 | 167 | // RenderTarget creation |
michael@0 | 168 | virtual RenderTarget *createRenderTarget(SwapChain *swapChain, bool depth); |
michael@0 | 169 | virtual RenderTarget *createRenderTarget(int width, int height, GLenum format, GLsizei samples, bool depth); |
michael@0 | 170 | |
michael@0 | 171 | // Shader operations |
michael@0 | 172 | virtual ShaderExecutable *loadExecutable(const void *function, size_t length, rx::ShaderType type); |
michael@0 | 173 | virtual ShaderExecutable *compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, rx::ShaderType type); |
michael@0 | 174 | |
michael@0 | 175 | // Image operations |
michael@0 | 176 | virtual Image *createImage(); |
michael@0 | 177 | virtual void generateMipmap(Image *dest, Image *source); |
michael@0 | 178 | virtual TextureStorage *createTextureStorage2D(SwapChain *swapChain); |
michael@0 | 179 | virtual TextureStorage *createTextureStorage2D(int levels, GLenum internalformat, GLenum usage, bool forceRenderable, GLsizei width, GLsizei height); |
michael@0 | 180 | virtual TextureStorage *createTextureStorageCube(int levels, GLenum internalformat, GLenum usage, bool forceRenderable, int size); |
michael@0 | 181 | |
michael@0 | 182 | // Buffer creation |
michael@0 | 183 | virtual VertexBuffer *createVertexBuffer(); |
michael@0 | 184 | virtual IndexBuffer *createIndexBuffer(); |
michael@0 | 185 | virtual BufferStorage *createBufferStorage(); |
michael@0 | 186 | |
michael@0 | 187 | // Query and Fence creation |
michael@0 | 188 | virtual QueryImpl *createQuery(GLenum type); |
michael@0 | 189 | virtual FenceImpl *createFence(); |
michael@0 | 190 | |
michael@0 | 191 | // D3D9-renderer specific methods |
michael@0 | 192 | bool boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest); |
michael@0 | 193 | |
michael@0 | 194 | D3DPOOL getTexturePool(DWORD usage) const; |
michael@0 | 195 | |
michael@0 | 196 | virtual bool getLUID(LUID *adapterLuid) const; |
michael@0 | 197 | |
michael@0 | 198 | private: |
michael@0 | 199 | DISALLOW_COPY_AND_ASSIGN(Renderer9); |
michael@0 | 200 | |
michael@0 | 201 | void applyUniformnfv(gl::Uniform *targetUniform, const GLfloat *v); |
michael@0 | 202 | void applyUniformniv(gl::Uniform *targetUniform, const GLint *v); |
michael@0 | 203 | void applyUniformnbv(gl::Uniform *targetUniform, const GLint *v); |
michael@0 | 204 | |
michael@0 | 205 | void drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer); |
michael@0 | 206 | void drawIndexedPoints(GLsizei count, GLenum type, const GLvoid *indices, gl::Buffer *elementArrayBuffer); |
michael@0 | 207 | |
michael@0 | 208 | void getMultiSampleSupport(D3DFORMAT format, bool *multiSampleArray); |
michael@0 | 209 | bool copyToRenderTarget(IDirect3DSurface9 *dest, IDirect3DSurface9 *source, bool fromManaged); |
michael@0 | 210 | gl::Renderbuffer *getNullColorbuffer(gl::Renderbuffer *depthbuffer); |
michael@0 | 211 | |
michael@0 | 212 | D3DPOOL getBufferPool(DWORD usage) const; |
michael@0 | 213 | |
michael@0 | 214 | HMODULE mD3d9Module; |
michael@0 | 215 | HDC mDc; |
michael@0 | 216 | |
michael@0 | 217 | void initializeDevice(); |
michael@0 | 218 | D3DPRESENT_PARAMETERS getDefaultPresentParameters(); |
michael@0 | 219 | void releaseDeviceResources(); |
michael@0 | 220 | |
michael@0 | 221 | UINT mAdapter; |
michael@0 | 222 | D3DDEVTYPE mDeviceType; |
michael@0 | 223 | bool mSoftwareDevice; // FIXME: Deprecate |
michael@0 | 224 | IDirect3D9 *mD3d9; // Always valid after successful initialization. |
michael@0 | 225 | IDirect3D9Ex *mD3d9Ex; // Might be null if D3D9Ex is not supported. |
michael@0 | 226 | IDirect3DDevice9 *mDevice; |
michael@0 | 227 | IDirect3DDevice9Ex *mDeviceEx; // Might be null if D3D9Ex is not supported. |
michael@0 | 228 | |
michael@0 | 229 | Blit *mBlit; |
michael@0 | 230 | |
michael@0 | 231 | HWND mDeviceWindow; |
michael@0 | 232 | |
michael@0 | 233 | bool mDeviceLost; |
michael@0 | 234 | D3DCAPS9 mDeviceCaps; |
michael@0 | 235 | D3DADAPTER_IDENTIFIER9 mAdapterIdentifier; |
michael@0 | 236 | |
michael@0 | 237 | D3DPRIMITIVETYPE mPrimitiveType; |
michael@0 | 238 | int mPrimitiveCount; |
michael@0 | 239 | GLsizei mRepeatDraw; |
michael@0 | 240 | |
michael@0 | 241 | bool mSceneStarted; |
michael@0 | 242 | bool mSupportsNonPower2Textures; |
michael@0 | 243 | bool mSupportsTextureFilterAnisotropy; |
michael@0 | 244 | int mMinSwapInterval; |
michael@0 | 245 | int mMaxSwapInterval; |
michael@0 | 246 | |
michael@0 | 247 | bool mOcclusionQuerySupport; |
michael@0 | 248 | bool mEventQuerySupport; |
michael@0 | 249 | bool mVertexTextureSupport; |
michael@0 | 250 | |
michael@0 | 251 | bool mDepthTextureSupport; |
michael@0 | 252 | |
michael@0 | 253 | bool mFloat32TextureSupport; |
michael@0 | 254 | bool mFloat32FilterSupport; |
michael@0 | 255 | bool mFloat32RenderSupport; |
michael@0 | 256 | |
michael@0 | 257 | bool mFloat16TextureSupport; |
michael@0 | 258 | bool mFloat16FilterSupport; |
michael@0 | 259 | bool mFloat16RenderSupport; |
michael@0 | 260 | |
michael@0 | 261 | bool mDXT1TextureSupport; |
michael@0 | 262 | bool mDXT3TextureSupport; |
michael@0 | 263 | bool mDXT5TextureSupport; |
michael@0 | 264 | |
michael@0 | 265 | bool mLuminanceTextureSupport; |
michael@0 | 266 | bool mLuminanceAlphaTextureSupport; |
michael@0 | 267 | |
michael@0 | 268 | std::map<D3DFORMAT, bool *> mMultiSampleSupport; |
michael@0 | 269 | GLsizei mMaxSupportedSamples; |
michael@0 | 270 | |
michael@0 | 271 | // current render target states |
michael@0 | 272 | unsigned int mAppliedRenderTargetSerial; |
michael@0 | 273 | unsigned int mAppliedDepthbufferSerial; |
michael@0 | 274 | unsigned int mAppliedStencilbufferSerial; |
michael@0 | 275 | bool mDepthStencilInitialized; |
michael@0 | 276 | bool mRenderTargetDescInitialized; |
michael@0 | 277 | rx::RenderTarget::Desc mRenderTargetDesc; |
michael@0 | 278 | unsigned int mCurStencilSize; |
michael@0 | 279 | unsigned int mCurDepthSize; |
michael@0 | 280 | |
michael@0 | 281 | IDirect3DStateBlock9 *mMaskedClearSavedState; |
michael@0 | 282 | |
michael@0 | 283 | // previously set render states |
michael@0 | 284 | bool mForceSetDepthStencilState; |
michael@0 | 285 | gl::DepthStencilState mCurDepthStencilState; |
michael@0 | 286 | int mCurStencilRef; |
michael@0 | 287 | int mCurStencilBackRef; |
michael@0 | 288 | bool mCurFrontFaceCCW; |
michael@0 | 289 | |
michael@0 | 290 | bool mForceSetRasterState; |
michael@0 | 291 | gl::RasterizerState mCurRasterState; |
michael@0 | 292 | |
michael@0 | 293 | bool mForceSetScissor; |
michael@0 | 294 | gl::Rectangle mCurScissor; |
michael@0 | 295 | bool mScissorEnabled; |
michael@0 | 296 | |
michael@0 | 297 | bool mForceSetViewport; |
michael@0 | 298 | gl::Rectangle mCurViewport; |
michael@0 | 299 | float mCurNear; |
michael@0 | 300 | float mCurFar; |
michael@0 | 301 | |
michael@0 | 302 | bool mForceSetBlendState; |
michael@0 | 303 | gl::BlendState mCurBlendState; |
michael@0 | 304 | gl::Color mCurBlendColor; |
michael@0 | 305 | GLuint mCurSampleMask; |
michael@0 | 306 | |
michael@0 | 307 | // Currently applied sampler states |
michael@0 | 308 | bool mForceSetVertexSamplerStates[gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS]; |
michael@0 | 309 | gl::SamplerState mCurVertexSamplerStates[gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS]; |
michael@0 | 310 | |
michael@0 | 311 | bool mForceSetPixelSamplerStates[gl::MAX_TEXTURE_IMAGE_UNITS]; |
michael@0 | 312 | gl::SamplerState mCurPixelSamplerStates[gl::MAX_TEXTURE_IMAGE_UNITS]; |
michael@0 | 313 | |
michael@0 | 314 | // Currently applied textures |
michael@0 | 315 | unsigned int mCurVertexTextureSerials[gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS]; |
michael@0 | 316 | unsigned int mCurPixelTextureSerials[gl::MAX_TEXTURE_IMAGE_UNITS]; |
michael@0 | 317 | |
michael@0 | 318 | unsigned int mAppliedIBSerial; |
michael@0 | 319 | unsigned int mAppliedProgramBinarySerial; |
michael@0 | 320 | |
michael@0 | 321 | rx::dx_VertexConstants mVertexConstants; |
michael@0 | 322 | rx::dx_PixelConstants mPixelConstants; |
michael@0 | 323 | bool mDxUniformsDirty; |
michael@0 | 324 | |
michael@0 | 325 | // A pool of event queries that are currently unused. |
michael@0 | 326 | std::vector<IDirect3DQuery9*> mEventQueryPool; |
michael@0 | 327 | VertexShaderCache mVertexShaderCache; |
michael@0 | 328 | PixelShaderCache mPixelShaderCache; |
michael@0 | 329 | |
michael@0 | 330 | VertexDataManager *mVertexDataManager; |
michael@0 | 331 | VertexDeclarationCache mVertexDeclarationCache; |
michael@0 | 332 | |
michael@0 | 333 | IndexDataManager *mIndexDataManager; |
michael@0 | 334 | StreamingIndexBufferInterface *mLineLoopIB; |
michael@0 | 335 | |
michael@0 | 336 | enum { NUM_NULL_COLORBUFFER_CACHE_ENTRIES = 12 }; |
michael@0 | 337 | struct NullColorbufferCacheEntry |
michael@0 | 338 | { |
michael@0 | 339 | UINT lruCount; |
michael@0 | 340 | int width; |
michael@0 | 341 | int height; |
michael@0 | 342 | gl::Renderbuffer *buffer; |
michael@0 | 343 | } mNullColorbufferCache[NUM_NULL_COLORBUFFER_CACHE_ENTRIES]; |
michael@0 | 344 | UINT mMaxNullColorbufferLRU; |
michael@0 | 345 | |
michael@0 | 346 | }; |
michael@0 | 347 | |
michael@0 | 348 | } |
michael@0 | 349 | #endif // LIBGLESV2_RENDERER_RENDERER9_H_ |