gfx/angle/src/libGLESv2/renderer/Renderer11.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 // Renderer11.h: Defines a back-end specific class for the D3D11 renderer.
     9 #ifndef LIBGLESV2_RENDERER_RENDERER11_H_
    10 #define LIBGLESV2_RENDERER_RENDERER11_H_
    12 #include "common/angleutils.h"
    13 #include "libGLESv2/angletypes.h"
    14 #include "libGLESv2/mathutil.h"
    16 #include "libGLESv2/renderer/Renderer.h"
    17 #include "libGLESv2/renderer/RenderStateCache.h"
    18 #include "libGLESv2/renderer/InputLayoutCache.h"
    19 #include "libGLESv2/renderer/RenderTarget.h"
    21 namespace gl
    22 {
    23 class Renderbuffer;
    24 }
    26 namespace rx
    27 {
    29 class VertexDataManager;
    30 class IndexDataManager;
    31 class StreamingIndexBufferInterface;
    33 enum
    34 {
    35     MAX_VERTEX_UNIFORM_VECTORS_D3D11 = 1024,
    36     MAX_FRAGMENT_UNIFORM_VECTORS_D3D11 = 1024
    37 };
    39 class Renderer11 : public Renderer
    40 {
    41   public:
    42     Renderer11(egl::Display *display, HDC hDc);
    43     virtual ~Renderer11();
    45     static Renderer11 *makeRenderer11(Renderer *renderer);
    47     virtual EGLint initialize();
    48     virtual bool resetDevice();
    50     virtual int generateConfigs(ConfigDesc **configDescList);
    51     virtual void deleteConfigs(ConfigDesc *configDescList);
    53     virtual void sync(bool block);
    55     virtual SwapChain *createSwapChain(HWND window, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat);
    57     virtual void setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &sampler);
    58     virtual void setTexture(gl::SamplerType type, int index, gl::Texture *texture);
    60     virtual void setRasterizerState(const gl::RasterizerState &rasterState);
    61     virtual void setBlendState(const gl::BlendState &blendState, const gl::Color &blendColor,
    62                                unsigned int sampleMask);
    63     virtual void setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef,
    64                                       int stencilBackRef, bool frontFaceCCW);
    66     virtual void setScissorRectangle(const gl::Rectangle &scissor, bool enabled);
    67     virtual bool setViewport(const gl::Rectangle &viewport, float zNear, float zFar, GLenum drawMode, GLenum frontFace,
    68                              bool ignoreViewport);
    70     virtual bool applyPrimitiveType(GLenum mode, GLsizei count);
    71     virtual bool applyRenderTarget(gl::Framebuffer *frameBuffer);
    72     virtual void applyShaders(gl::ProgramBinary *programBinary);
    73     virtual void applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArray *uniformArray);
    74     virtual GLenum applyVertexBuffer(gl::ProgramBinary *programBinary, gl::VertexAttribute vertexAttributes[], GLint first, GLsizei count, GLsizei instances);
    75     virtual GLenum applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo);
    77     virtual void drawArrays(GLenum mode, GLsizei count, GLsizei instances);
    78     virtual void drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, gl::Buffer *elementArrayBuffer, const TranslatedIndexData &indexInfo, GLsizei instances);
    80     virtual void clear(const gl::ClearParameters &clearParams, gl::Framebuffer *frameBuffer);
    82     virtual void markAllStateDirty();
    84     // lost device
    85     void notifyDeviceLost();
    86     virtual bool isDeviceLost();
    87     virtual bool testDeviceLost(bool notify);
    88     virtual bool testDeviceResettable();
    90     // Renderer capabilities
    91     virtual DWORD getAdapterVendor() const;
    92     virtual std::string getRendererDescription() const;
    93     virtual GUID getAdapterIdentifier() const;
    95     virtual bool getBGRATextureSupport() const;
    96     virtual bool getDXT1TextureSupport();
    97     virtual bool getDXT3TextureSupport();
    98     virtual bool getDXT5TextureSupport();
    99     virtual bool getEventQuerySupport();
   100     virtual bool getFloat32TextureSupport(bool *filtering, bool *renderable);
   101     virtual bool getFloat16TextureSupport(bool *filtering, bool *renderable);
   102     virtual bool getLuminanceTextureSupport();
   103     virtual bool getLuminanceAlphaTextureSupport();
   104     virtual unsigned int getMaxVertexTextureImageUnits() const;
   105     virtual unsigned int getMaxCombinedTextureImageUnits() const;
   106     virtual unsigned int getReservedVertexUniformVectors() const;
   107     virtual unsigned int getReservedFragmentUniformVectors() const;
   108     virtual unsigned int getMaxVertexUniformVectors() const;
   109     virtual unsigned int getMaxFragmentUniformVectors() const;
   110     virtual unsigned int getMaxVaryingVectors() const;
   111     virtual bool getNonPower2TextureSupport() const;
   112     virtual bool getDepthTextureSupport() const;
   113     virtual bool getOcclusionQuerySupport() const;
   114     virtual bool getInstancingSupport() const;
   115     virtual bool getTextureFilterAnisotropySupport() const;
   116     virtual float getTextureMaxAnisotropy() const;
   117     virtual bool getShareHandleSupport() const;
   118     virtual bool getDerivativeInstructionSupport() const;
   119     virtual bool getPostSubBufferSupport() const;
   121     virtual int getMajorShaderModel() const;
   122     virtual float getMaxPointSize() const;
   123     virtual int getMaxViewportDimension() const;
   124     virtual int getMaxTextureWidth() const;
   125     virtual int getMaxTextureHeight() const;
   126     virtual bool get32BitIndexSupport() const;
   127     virtual int getMinSwapInterval() const;
   128     virtual int getMaxSwapInterval() const;
   130     virtual GLsizei getMaxSupportedSamples() const;
   131     int getNearestSupportedSamples(DXGI_FORMAT format, unsigned int requested) const;
   133     virtual unsigned int getMaxRenderTargets() const;
   135     // Pixel operations
   136     virtual bool copyToRenderTarget(TextureStorageInterface2D *dest, TextureStorageInterface2D *source);
   137     virtual bool copyToRenderTarget(TextureStorageInterfaceCube *dest, TextureStorageInterfaceCube *source);
   139     virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
   140                            GLint xoffset, GLint yoffset, TextureStorageInterface2D *storage, GLint level);
   141     virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
   142                            GLint xoffset, GLint yoffset, TextureStorageInterfaceCube *storage, GLenum target, GLint level);
   144     bool copyTexture(ID3D11ShaderResourceView *source, const gl::Rectangle &sourceArea, unsigned int sourceWidth, unsigned int sourceHeight,
   145                      ID3D11RenderTargetView *dest, const gl::Rectangle &destArea, unsigned int destWidth, unsigned int destHeight, GLenum destFormat);
   147     virtual bool blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect,
   148                           bool blitRenderTarget, bool blitDepthStencil);
   149     virtual void readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type,
   150                             GLsizei outputPitch, bool packReverseRowOrder, GLint packAlignment, void* pixels);
   152     // RenderTarget creation
   153     virtual RenderTarget *createRenderTarget(SwapChain *swapChain, bool depth);
   154     virtual RenderTarget *createRenderTarget(int width, int height, GLenum format, GLsizei samples, bool depth);
   156     // Shader operations
   157     virtual ShaderExecutable *loadExecutable(const void *function, size_t length, rx::ShaderType type);
   158     virtual ShaderExecutable *compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, rx::ShaderType type);
   160     // Image operations
   161     virtual Image *createImage();
   162     virtual void generateMipmap(Image *dest, Image *source);
   163     virtual TextureStorage *createTextureStorage2D(SwapChain *swapChain);
   164     virtual TextureStorage *createTextureStorage2D(int levels, GLenum internalformat, GLenum usage, bool forceRenderable, GLsizei width, GLsizei height);
   165     virtual TextureStorage *createTextureStorageCube(int levels, GLenum internalformat, GLenum usage, bool forceRenderable, int size);
   167     // Buffer creation
   168     virtual VertexBuffer *createVertexBuffer();
   169     virtual IndexBuffer *createIndexBuffer();
   170     virtual BufferStorage *createBufferStorage();
   172     // Query and Fence creation
   173     virtual QueryImpl *createQuery(GLenum type);
   174     virtual FenceImpl *createFence();
   176     // D3D11-renderer specific methods
   177     ID3D11Device *getDevice() { return mDevice; }
   178     ID3D11DeviceContext *getDeviceContext() { return mDeviceContext; };
   179     IDXGIFactory *getDxgiFactory() { return mDxgiFactory; };
   181     bool getRenderTargetResource(gl::Renderbuffer *colorbuffer, unsigned int *subresourceIndex, ID3D11Texture2D **resource);
   182     void unapplyRenderTargets();
   183     void setOneTimeRenderTarget(ID3D11RenderTargetView *renderTargetView);
   185     virtual bool getLUID(LUID *adapterLuid) const;
   187   private:
   188     DISALLOW_COPY_AND_ASSIGN(Renderer11);
   190     void drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer);
   191     void drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indices, int minIndex, gl::Buffer *elementArrayBuffer, int instances);
   193     void readTextureData(ID3D11Texture2D *texture, unsigned int subResource, const gl::Rectangle &area,
   194                          GLenum format, GLenum type, GLsizei outputPitch, bool packReverseRowOrder,
   195                          GLint packAlignment, void *pixels);
   197     void maskedClear(const gl::ClearParameters &clearParams, bool usingExtendedDrawBuffers);
   198     rx::Range getViewportBounds() const;
   200     bool blitRenderbufferRect(const gl::Rectangle &readRect, const gl::Rectangle &drawRect, RenderTarget *readRenderTarget, 
   201                               RenderTarget *drawRenderTarget, bool wholeBufferCopy);
   202     ID3D11Texture2D *resolveMultisampledTexture(ID3D11Texture2D *source, unsigned int subresource);
   204     HMODULE mD3d11Module;
   205     HMODULE mDxgiModule;
   206     HDC mDc;
   208     bool mDeviceLost;
   210     void initializeDevice();
   211     void releaseDeviceResources();
   212     int getMinorShaderModel() const;
   213     void release();
   215     RenderStateCache mStateCache;
   217     // Support flags
   218     bool mFloat16TextureSupport;
   219     bool mFloat16FilterSupport;
   220     bool mFloat16RenderSupport;
   222     bool mFloat32TextureSupport;
   223     bool mFloat32FilterSupport;
   224     bool mFloat32RenderSupport;
   226     bool mDXT1TextureSupport;
   227     bool mDXT3TextureSupport;
   228     bool mDXT5TextureSupport;
   230     bool mDepthTextureSupport;
   232     // Multisample format support
   233     struct MultisampleSupportInfo
   234     {
   235         unsigned int qualityLevels[D3D11_MAX_MULTISAMPLE_SAMPLE_COUNT];
   236     };
   238     typedef std::unordered_map<DXGI_FORMAT, MultisampleSupportInfo, std::hash<int> > MultisampleSupportMap;
   239     MultisampleSupportMap mMultisampleSupportMap;
   241     unsigned int mMaxSupportedSamples;
   243     // current render target states
   244     unsigned int mAppliedRenderTargetSerials[gl::IMPLEMENTATION_MAX_DRAW_BUFFERS];
   245     unsigned int mAppliedDepthbufferSerial;
   246     unsigned int mAppliedStencilbufferSerial;
   247     bool mDepthStencilInitialized;
   248     bool mRenderTargetDescInitialized;
   249     rx::RenderTarget::Desc mRenderTargetDesc;
   250     unsigned int mCurDepthSize;
   251     unsigned int mCurStencilSize;
   253     // Currently applied sampler states
   254     bool mForceSetVertexSamplerStates[gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS];
   255     gl::SamplerState mCurVertexSamplerStates[gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS];
   257     bool mForceSetPixelSamplerStates[gl::MAX_TEXTURE_IMAGE_UNITS];
   258     gl::SamplerState mCurPixelSamplerStates[gl::MAX_TEXTURE_IMAGE_UNITS];
   260     // Currently applied textures
   261     unsigned int mCurVertexTextureSerials[gl::IMPLEMENTATION_MAX_VERTEX_TEXTURE_IMAGE_UNITS];
   262     unsigned int mCurPixelTextureSerials[gl::MAX_TEXTURE_IMAGE_UNITS];
   264     // Currently applied blend state
   265     bool mForceSetBlendState;
   266     gl::BlendState mCurBlendState;
   267     gl::Color mCurBlendColor;
   268     unsigned int mCurSampleMask;
   270     // Currently applied rasterizer state
   271     bool mForceSetRasterState;
   272     gl::RasterizerState mCurRasterState;
   274     // Currently applied depth stencil state
   275     bool mForceSetDepthStencilState;
   276     gl::DepthStencilState mCurDepthStencilState;
   277     int mCurStencilRef;
   278     int mCurStencilBackRef;
   280     // Currently applied scissor rectangle
   281     bool mForceSetScissor;
   282     bool mScissorEnabled;
   283     gl::Rectangle mCurScissor;
   285     // Currently applied viewport
   286     bool mForceSetViewport;
   287     gl::Rectangle mCurViewport;
   288     float mCurNear;
   289     float mCurFar;
   291     // Currently applied primitive topology
   292     D3D11_PRIMITIVE_TOPOLOGY mCurrentPrimitiveTopology;
   294     unsigned int mAppliedIBSerial;
   295     unsigned int mAppliedStorageIBSerial;
   296     unsigned int mAppliedIBOffset;
   298     unsigned int mAppliedProgramBinarySerial;
   299     bool mIsGeometryShaderActive;
   301     dx_VertexConstants mVertexConstants;
   302     dx_VertexConstants mAppliedVertexConstants;
   303     ID3D11Buffer *mDriverConstantBufferVS;
   304     ID3D11Buffer *mCurrentVertexConstantBuffer;
   306     dx_PixelConstants mPixelConstants;
   307     dx_PixelConstants mAppliedPixelConstants;
   308     ID3D11Buffer *mDriverConstantBufferPS;
   309     ID3D11Buffer *mCurrentPixelConstantBuffer;
   311     ID3D11Buffer *mCurrentGeometryConstantBuffer;
   313     // Vertex, index and input layouts
   314     VertexDataManager *mVertexDataManager;
   315     IndexDataManager *mIndexDataManager;
   316     InputLayoutCache mInputLayoutCache;
   318     StreamingIndexBufferInterface *mLineLoopIB;
   319     StreamingIndexBufferInterface *mTriangleFanIB;
   321     // Texture copy resources
   322     bool mCopyResourcesInitialized;
   323     ID3D11Buffer *mCopyVB;
   324     ID3D11SamplerState *mCopySampler;
   325     ID3D11InputLayout *mCopyIL;
   326     ID3D11VertexShader *mCopyVS;
   327     ID3D11PixelShader *mCopyRGBAPS;
   328     ID3D11PixelShader *mCopyRGBPS;
   329     ID3D11PixelShader *mCopyLumPS;
   330     ID3D11PixelShader *mCopyLumAlphaPS;
   332     // Masked clear resources
   333     bool mClearResourcesInitialized;
   334     ID3D11Buffer *mClearVB;
   335     ID3D11InputLayout *mClearIL;
   336     ID3D11VertexShader *mClearVS;
   337     ID3D11PixelShader *mClearSinglePS;
   338     ID3D11PixelShader *mClearMultiplePS;
   339     ID3D11RasterizerState *mClearScissorRS;
   340     ID3D11RasterizerState *mClearNoScissorRS;
   342     // Sync query
   343     ID3D11Query *mSyncQuery;
   345     ID3D11Device *mDevice;
   346     D3D_FEATURE_LEVEL mFeatureLevel;
   347     ID3D11DeviceContext *mDeviceContext;
   348     IDXGIAdapter *mDxgiAdapter;
   349     DXGI_ADAPTER_DESC mAdapterDescription;
   350     char mDescription[128];
   351     IDXGIFactory *mDxgiFactory;
   353     // Cached device caps
   354     bool mBGRATextureSupport;
   355 };
   357 }
   358 #endif // LIBGLESV2_RENDERER_RENDERER11_H_

mercurial