gfx/angle/src/libGLESv2/renderer/Renderer9.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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.

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

mercurial