gfx/angle/src/libGLESv2/renderer/Renderer.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.

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 // Renderer.h: Defines a back-end specific class that hides the details of the
michael@0 8 // implementation-specific renderer.
michael@0 9
michael@0 10 #ifndef LIBGLESV2_RENDERER_RENDERER_H_
michael@0 11 #define LIBGLESV2_RENDERER_RENDERER_H_
michael@0 12
michael@0 13 #include "libGLESv2/Uniform.h"
michael@0 14 #include "libGLESv2/angletypes.h"
michael@0 15
michael@0 16 #if !defined(ANGLE_COMPILE_OPTIMIZATION_LEVEL)
michael@0 17 #define ANGLE_COMPILE_OPTIMIZATION_LEVEL D3DCOMPILE_OPTIMIZATION_LEVEL3
michael@0 18 #endif
michael@0 19
michael@0 20 const int versionWindowsVista = MAKEWORD(0x00, 0x06);
michael@0 21 const int versionWindows7 = MAKEWORD(0x01, 0x06);
michael@0 22
michael@0 23 // Return the version of the operating system in a format suitable for ordering
michael@0 24 // comparison.
michael@0 25 inline int getComparableOSVersion()
michael@0 26 {
michael@0 27 DWORD version = GetVersion();
michael@0 28 int majorVersion = LOBYTE(LOWORD(version));
michael@0 29 int minorVersion = HIBYTE(LOWORD(version));
michael@0 30 return MAKEWORD(minorVersion, majorVersion);
michael@0 31 }
michael@0 32
michael@0 33 namespace egl
michael@0 34 {
michael@0 35 class Display;
michael@0 36 }
michael@0 37
michael@0 38 namespace gl
michael@0 39 {
michael@0 40 class InfoLog;
michael@0 41 class ProgramBinary;
michael@0 42 class VertexAttribute;
michael@0 43 class Buffer;
michael@0 44 class Texture;
michael@0 45 class Framebuffer;
michael@0 46 }
michael@0 47
michael@0 48 namespace rx
michael@0 49 {
michael@0 50 class TextureStorageInterface2D;
michael@0 51 class TextureStorageInterfaceCube;
michael@0 52 class VertexBuffer;
michael@0 53 class IndexBuffer;
michael@0 54 class QueryImpl;
michael@0 55 class FenceImpl;
michael@0 56 class BufferStorage;
michael@0 57 class Blit;
michael@0 58 struct TranslatedIndexData;
michael@0 59 class ShaderExecutable;
michael@0 60 class SwapChain;
michael@0 61 class RenderTarget;
michael@0 62 class Image;
michael@0 63 class TextureStorage;
michael@0 64
michael@0 65 typedef void * ShaderBlob;
michael@0 66 typedef void (*pCompileFunc)();
michael@0 67
michael@0 68 struct ConfigDesc
michael@0 69 {
michael@0 70 GLenum renderTargetFormat;
michael@0 71 GLenum depthStencilFormat;
michael@0 72 GLint multiSample;
michael@0 73 bool fastConfig;
michael@0 74 };
michael@0 75
michael@0 76 struct dx_VertexConstants
michael@0 77 {
michael@0 78 float depthRange[4];
michael@0 79 float viewAdjust[4];
michael@0 80 };
michael@0 81
michael@0 82 struct dx_PixelConstants
michael@0 83 {
michael@0 84 float depthRange[4];
michael@0 85 float viewCoords[4];
michael@0 86 float depthFront[4];
michael@0 87 };
michael@0 88
michael@0 89 enum ShaderType
michael@0 90 {
michael@0 91 SHADER_VERTEX,
michael@0 92 SHADER_PIXEL,
michael@0 93 SHADER_GEOMETRY
michael@0 94 };
michael@0 95
michael@0 96 class Renderer
michael@0 97 {
michael@0 98 public:
michael@0 99 explicit Renderer(egl::Display *display);
michael@0 100 virtual ~Renderer();
michael@0 101
michael@0 102 virtual EGLint initialize() = 0;
michael@0 103 virtual bool resetDevice() = 0;
michael@0 104
michael@0 105 virtual int generateConfigs(ConfigDesc **configDescList) = 0;
michael@0 106 virtual void deleteConfigs(ConfigDesc *configDescList) = 0;
michael@0 107
michael@0 108 virtual void sync(bool block) = 0;
michael@0 109
michael@0 110 virtual SwapChain *createSwapChain(HWND window, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat) = 0;
michael@0 111
michael@0 112 virtual void setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &sampler) = 0;
michael@0 113 virtual void setTexture(gl::SamplerType type, int index, gl::Texture *texture) = 0;
michael@0 114
michael@0 115 virtual void setRasterizerState(const gl::RasterizerState &rasterState) = 0;
michael@0 116 virtual void setBlendState(const gl::BlendState &blendState, const gl::Color &blendColor,
michael@0 117 unsigned int sampleMask) = 0;
michael@0 118 virtual void setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef,
michael@0 119 int stencilBackRef, bool frontFaceCCW) = 0;
michael@0 120
michael@0 121 virtual void setScissorRectangle(const gl::Rectangle &scissor, bool enabled) = 0;
michael@0 122 virtual bool setViewport(const gl::Rectangle &viewport, float zNear, float zFar, GLenum drawMode, GLenum frontFace,
michael@0 123 bool ignoreViewport) = 0;
michael@0 124
michael@0 125 virtual bool applyRenderTarget(gl::Framebuffer *frameBuffer) = 0;
michael@0 126 virtual void applyShaders(gl::ProgramBinary *programBinary) = 0;
michael@0 127 virtual void applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArray *uniformArray) = 0;
michael@0 128 virtual bool applyPrimitiveType(GLenum primitiveType, GLsizei elementCount) = 0;
michael@0 129 virtual GLenum applyVertexBuffer(gl::ProgramBinary *programBinary, gl::VertexAttribute vertexAttributes[], GLint first, GLsizei count, GLsizei instances) = 0;
michael@0 130 virtual GLenum applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo) = 0;
michael@0 131
michael@0 132 virtual void drawArrays(GLenum mode, GLsizei count, GLsizei instances) = 0;
michael@0 133 virtual void drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, gl::Buffer *elementArrayBuffer, const TranslatedIndexData &indexInfo, GLsizei instances) = 0;
michael@0 134
michael@0 135 virtual void clear(const gl::ClearParameters &clearParams, gl::Framebuffer *frameBuffer) = 0;
michael@0 136
michael@0 137 virtual void markAllStateDirty() = 0;
michael@0 138
michael@0 139 // lost device
michael@0 140 virtual void notifyDeviceLost() = 0;
michael@0 141 virtual bool isDeviceLost() = 0;
michael@0 142 virtual bool testDeviceLost(bool notify) = 0;
michael@0 143 virtual bool testDeviceResettable() = 0;
michael@0 144
michael@0 145 // Renderer capabilities
michael@0 146 virtual DWORD getAdapterVendor() const = 0;
michael@0 147 virtual std::string getRendererDescription() const = 0;
michael@0 148 virtual GUID getAdapterIdentifier() const = 0;
michael@0 149
michael@0 150 virtual bool getBGRATextureSupport() const = 0;
michael@0 151 virtual bool getDXT1TextureSupport() = 0;
michael@0 152 virtual bool getDXT3TextureSupport() = 0;
michael@0 153 virtual bool getDXT5TextureSupport() = 0;
michael@0 154 virtual bool getEventQuerySupport() = 0;
michael@0 155 virtual bool getFloat32TextureSupport(bool *filtering, bool *renderable) = 0;
michael@0 156 virtual bool getFloat16TextureSupport(bool *filtering, bool *renderable) = 0;
michael@0 157 virtual bool getLuminanceTextureSupport() = 0;
michael@0 158 virtual bool getLuminanceAlphaTextureSupport() = 0;
michael@0 159 bool getVertexTextureSupport() const { return getMaxVertexTextureImageUnits() > 0; }
michael@0 160 virtual unsigned int getMaxVertexTextureImageUnits() const = 0;
michael@0 161 virtual unsigned int getMaxCombinedTextureImageUnits() const = 0;
michael@0 162 virtual unsigned int getReservedVertexUniformVectors() const = 0;
michael@0 163 virtual unsigned int getReservedFragmentUniformVectors() const = 0;
michael@0 164 virtual unsigned int getMaxVertexUniformVectors() const = 0;
michael@0 165 virtual unsigned int getMaxFragmentUniformVectors() const = 0;
michael@0 166 virtual unsigned int getMaxVaryingVectors() const = 0;
michael@0 167 virtual bool getNonPower2TextureSupport() const = 0;
michael@0 168 virtual bool getDepthTextureSupport() const = 0;
michael@0 169 virtual bool getOcclusionQuerySupport() const = 0;
michael@0 170 virtual bool getInstancingSupport() const = 0;
michael@0 171 virtual bool getTextureFilterAnisotropySupport() const = 0;
michael@0 172 virtual float getTextureMaxAnisotropy() const = 0;
michael@0 173 virtual bool getShareHandleSupport() const = 0;
michael@0 174 virtual bool getDerivativeInstructionSupport() const = 0;
michael@0 175 virtual bool getPostSubBufferSupport() const = 0;
michael@0 176
michael@0 177 virtual int getMajorShaderModel() const = 0;
michael@0 178 virtual float getMaxPointSize() const = 0;
michael@0 179 virtual int getMaxViewportDimension() const = 0;
michael@0 180 virtual int getMaxTextureWidth() const = 0;
michael@0 181 virtual int getMaxTextureHeight() const = 0;
michael@0 182 virtual bool get32BitIndexSupport() const = 0;
michael@0 183 virtual int getMinSwapInterval() const = 0;
michael@0 184 virtual int getMaxSwapInterval() const = 0;
michael@0 185
michael@0 186 virtual GLsizei getMaxSupportedSamples() const = 0;
michael@0 187
michael@0 188 virtual unsigned int getMaxRenderTargets() const = 0;
michael@0 189
michael@0 190 // Pixel operations
michael@0 191 virtual bool copyToRenderTarget(TextureStorageInterface2D *dest, TextureStorageInterface2D *source) = 0;
michael@0 192 virtual bool copyToRenderTarget(TextureStorageInterfaceCube *dest, TextureStorageInterfaceCube *source) = 0;
michael@0 193
michael@0 194 virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
michael@0 195 GLint xoffset, GLint yoffset, TextureStorageInterface2D *storage, GLint level) = 0;
michael@0 196 virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat,
michael@0 197 GLint xoffset, GLint yoffset, TextureStorageInterfaceCube *storage, GLenum target, GLint level) = 0;
michael@0 198
michael@0 199 virtual bool blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect,
michael@0 200 bool blitRenderTarget, bool blitDepthStencil) = 0;
michael@0 201 virtual void readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type,
michael@0 202 GLsizei outputPitch, bool packReverseRowOrder, GLint packAlignment, void* pixels) = 0;
michael@0 203
michael@0 204 // RenderTarget creation
michael@0 205 virtual RenderTarget *createRenderTarget(SwapChain *swapChain, bool depth) = 0;
michael@0 206 virtual RenderTarget *createRenderTarget(int width, int height, GLenum format, GLsizei samples, bool depth) = 0;
michael@0 207
michael@0 208 // Shader operations
michael@0 209 virtual ShaderExecutable *loadExecutable(const void *function, size_t length, rx::ShaderType type) = 0;
michael@0 210 virtual ShaderExecutable *compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, rx::ShaderType type) = 0;
michael@0 211
michael@0 212 // Image operations
michael@0 213 virtual Image *createImage() = 0;
michael@0 214 virtual void generateMipmap(Image *dest, Image *source) = 0;
michael@0 215 virtual TextureStorage *createTextureStorage2D(SwapChain *swapChain) = 0;
michael@0 216 virtual TextureStorage *createTextureStorage2D(int levels, GLenum internalformat, GLenum usage, bool forceRenderable, GLsizei width, GLsizei height) = 0;
michael@0 217 virtual TextureStorage *createTextureStorageCube(int levels, GLenum internalformat, GLenum usage, bool forceRenderable, int size) = 0;
michael@0 218
michael@0 219 // Buffer creation
michael@0 220 virtual VertexBuffer *createVertexBuffer() = 0;
michael@0 221 virtual IndexBuffer *createIndexBuffer() = 0;
michael@0 222 virtual BufferStorage *createBufferStorage() = 0;
michael@0 223
michael@0 224 // Query and Fence creation
michael@0 225 virtual QueryImpl *createQuery(GLenum type) = 0;
michael@0 226 virtual FenceImpl *createFence() = 0;
michael@0 227
michael@0 228 virtual bool getLUID(LUID *adapterLuid) const = 0;
michael@0 229
michael@0 230 protected:
michael@0 231 bool initializeCompiler();
michael@0 232 ShaderBlob *compileToBinary(gl::InfoLog &infoLog, const char *hlsl, const char *profile, UINT optimizationFlags, bool alternateFlags);
michael@0 233
michael@0 234 egl::Display *mDisplay;
michael@0 235
michael@0 236 private:
michael@0 237 DISALLOW_COPY_AND_ASSIGN(Renderer);
michael@0 238
michael@0 239 HMODULE mD3dCompilerModule;
michael@0 240 pCompileFunc mD3DCompileFunc;
michael@0 241 };
michael@0 242
michael@0 243 }
michael@0 244 #endif // LIBGLESV2_RENDERER_RENDERER_H_

mercurial