1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/angle/src/libGLESv2/renderer/Renderer.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,244 @@ 1.4 +// 1.5 +// Copyright (c) 2012-2013 The ANGLE Project Authors. All rights reserved. 1.6 +// Use of this source code is governed by a BSD-style license that can be 1.7 +// found in the LICENSE file. 1.8 +// 1.9 + 1.10 +// Renderer.h: Defines a back-end specific class that hides the details of the 1.11 +// implementation-specific renderer. 1.12 + 1.13 +#ifndef LIBGLESV2_RENDERER_RENDERER_H_ 1.14 +#define LIBGLESV2_RENDERER_RENDERER_H_ 1.15 + 1.16 +#include "libGLESv2/Uniform.h" 1.17 +#include "libGLESv2/angletypes.h" 1.18 + 1.19 +#if !defined(ANGLE_COMPILE_OPTIMIZATION_LEVEL) 1.20 +#define ANGLE_COMPILE_OPTIMIZATION_LEVEL D3DCOMPILE_OPTIMIZATION_LEVEL3 1.21 +#endif 1.22 + 1.23 +const int versionWindowsVista = MAKEWORD(0x00, 0x06); 1.24 +const int versionWindows7 = MAKEWORD(0x01, 0x06); 1.25 + 1.26 +// Return the version of the operating system in a format suitable for ordering 1.27 +// comparison. 1.28 +inline int getComparableOSVersion() 1.29 +{ 1.30 + DWORD version = GetVersion(); 1.31 + int majorVersion = LOBYTE(LOWORD(version)); 1.32 + int minorVersion = HIBYTE(LOWORD(version)); 1.33 + return MAKEWORD(minorVersion, majorVersion); 1.34 +} 1.35 + 1.36 +namespace egl 1.37 +{ 1.38 +class Display; 1.39 +} 1.40 + 1.41 +namespace gl 1.42 +{ 1.43 +class InfoLog; 1.44 +class ProgramBinary; 1.45 +class VertexAttribute; 1.46 +class Buffer; 1.47 +class Texture; 1.48 +class Framebuffer; 1.49 +} 1.50 + 1.51 +namespace rx 1.52 +{ 1.53 +class TextureStorageInterface2D; 1.54 +class TextureStorageInterfaceCube; 1.55 +class VertexBuffer; 1.56 +class IndexBuffer; 1.57 +class QueryImpl; 1.58 +class FenceImpl; 1.59 +class BufferStorage; 1.60 +class Blit; 1.61 +struct TranslatedIndexData; 1.62 +class ShaderExecutable; 1.63 +class SwapChain; 1.64 +class RenderTarget; 1.65 +class Image; 1.66 +class TextureStorage; 1.67 + 1.68 +typedef void * ShaderBlob; 1.69 +typedef void (*pCompileFunc)(); 1.70 + 1.71 +struct ConfigDesc 1.72 +{ 1.73 + GLenum renderTargetFormat; 1.74 + GLenum depthStencilFormat; 1.75 + GLint multiSample; 1.76 + bool fastConfig; 1.77 +}; 1.78 + 1.79 +struct dx_VertexConstants 1.80 +{ 1.81 + float depthRange[4]; 1.82 + float viewAdjust[4]; 1.83 +}; 1.84 + 1.85 +struct dx_PixelConstants 1.86 +{ 1.87 + float depthRange[4]; 1.88 + float viewCoords[4]; 1.89 + float depthFront[4]; 1.90 +}; 1.91 + 1.92 +enum ShaderType 1.93 +{ 1.94 + SHADER_VERTEX, 1.95 + SHADER_PIXEL, 1.96 + SHADER_GEOMETRY 1.97 +}; 1.98 + 1.99 +class Renderer 1.100 +{ 1.101 + public: 1.102 + explicit Renderer(egl::Display *display); 1.103 + virtual ~Renderer(); 1.104 + 1.105 + virtual EGLint initialize() = 0; 1.106 + virtual bool resetDevice() = 0; 1.107 + 1.108 + virtual int generateConfigs(ConfigDesc **configDescList) = 0; 1.109 + virtual void deleteConfigs(ConfigDesc *configDescList) = 0; 1.110 + 1.111 + virtual void sync(bool block) = 0; 1.112 + 1.113 + virtual SwapChain *createSwapChain(HWND window, HANDLE shareHandle, GLenum backBufferFormat, GLenum depthBufferFormat) = 0; 1.114 + 1.115 + virtual void setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &sampler) = 0; 1.116 + virtual void setTexture(gl::SamplerType type, int index, gl::Texture *texture) = 0; 1.117 + 1.118 + virtual void setRasterizerState(const gl::RasterizerState &rasterState) = 0; 1.119 + virtual void setBlendState(const gl::BlendState &blendState, const gl::Color &blendColor, 1.120 + unsigned int sampleMask) = 0; 1.121 + virtual void setDepthStencilState(const gl::DepthStencilState &depthStencilState, int stencilRef, 1.122 + int stencilBackRef, bool frontFaceCCW) = 0; 1.123 + 1.124 + virtual void setScissorRectangle(const gl::Rectangle &scissor, bool enabled) = 0; 1.125 + virtual bool setViewport(const gl::Rectangle &viewport, float zNear, float zFar, GLenum drawMode, GLenum frontFace, 1.126 + bool ignoreViewport) = 0; 1.127 + 1.128 + virtual bool applyRenderTarget(gl::Framebuffer *frameBuffer) = 0; 1.129 + virtual void applyShaders(gl::ProgramBinary *programBinary) = 0; 1.130 + virtual void applyUniforms(gl::ProgramBinary *programBinary, gl::UniformArray *uniformArray) = 0; 1.131 + virtual bool applyPrimitiveType(GLenum primitiveType, GLsizei elementCount) = 0; 1.132 + virtual GLenum applyVertexBuffer(gl::ProgramBinary *programBinary, gl::VertexAttribute vertexAttributes[], GLint first, GLsizei count, GLsizei instances) = 0; 1.133 + virtual GLenum applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo) = 0; 1.134 + 1.135 + virtual void drawArrays(GLenum mode, GLsizei count, GLsizei instances) = 0; 1.136 + virtual void drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, gl::Buffer *elementArrayBuffer, const TranslatedIndexData &indexInfo, GLsizei instances) = 0; 1.137 + 1.138 + virtual void clear(const gl::ClearParameters &clearParams, gl::Framebuffer *frameBuffer) = 0; 1.139 + 1.140 + virtual void markAllStateDirty() = 0; 1.141 + 1.142 + // lost device 1.143 + virtual void notifyDeviceLost() = 0; 1.144 + virtual bool isDeviceLost() = 0; 1.145 + virtual bool testDeviceLost(bool notify) = 0; 1.146 + virtual bool testDeviceResettable() = 0; 1.147 + 1.148 + // Renderer capabilities 1.149 + virtual DWORD getAdapterVendor() const = 0; 1.150 + virtual std::string getRendererDescription() const = 0; 1.151 + virtual GUID getAdapterIdentifier() const = 0; 1.152 + 1.153 + virtual bool getBGRATextureSupport() const = 0; 1.154 + virtual bool getDXT1TextureSupport() = 0; 1.155 + virtual bool getDXT3TextureSupport() = 0; 1.156 + virtual bool getDXT5TextureSupport() = 0; 1.157 + virtual bool getEventQuerySupport() = 0; 1.158 + virtual bool getFloat32TextureSupport(bool *filtering, bool *renderable) = 0; 1.159 + virtual bool getFloat16TextureSupport(bool *filtering, bool *renderable) = 0; 1.160 + virtual bool getLuminanceTextureSupport() = 0; 1.161 + virtual bool getLuminanceAlphaTextureSupport() = 0; 1.162 + bool getVertexTextureSupport() const { return getMaxVertexTextureImageUnits() > 0; } 1.163 + virtual unsigned int getMaxVertexTextureImageUnits() const = 0; 1.164 + virtual unsigned int getMaxCombinedTextureImageUnits() const = 0; 1.165 + virtual unsigned int getReservedVertexUniformVectors() const = 0; 1.166 + virtual unsigned int getReservedFragmentUniformVectors() const = 0; 1.167 + virtual unsigned int getMaxVertexUniformVectors() const = 0; 1.168 + virtual unsigned int getMaxFragmentUniformVectors() const = 0; 1.169 + virtual unsigned int getMaxVaryingVectors() const = 0; 1.170 + virtual bool getNonPower2TextureSupport() const = 0; 1.171 + virtual bool getDepthTextureSupport() const = 0; 1.172 + virtual bool getOcclusionQuerySupport() const = 0; 1.173 + virtual bool getInstancingSupport() const = 0; 1.174 + virtual bool getTextureFilterAnisotropySupport() const = 0; 1.175 + virtual float getTextureMaxAnisotropy() const = 0; 1.176 + virtual bool getShareHandleSupport() const = 0; 1.177 + virtual bool getDerivativeInstructionSupport() const = 0; 1.178 + virtual bool getPostSubBufferSupport() const = 0; 1.179 + 1.180 + virtual int getMajorShaderModel() const = 0; 1.181 + virtual float getMaxPointSize() const = 0; 1.182 + virtual int getMaxViewportDimension() const = 0; 1.183 + virtual int getMaxTextureWidth() const = 0; 1.184 + virtual int getMaxTextureHeight() const = 0; 1.185 + virtual bool get32BitIndexSupport() const = 0; 1.186 + virtual int getMinSwapInterval() const = 0; 1.187 + virtual int getMaxSwapInterval() const = 0; 1.188 + 1.189 + virtual GLsizei getMaxSupportedSamples() const = 0; 1.190 + 1.191 + virtual unsigned int getMaxRenderTargets() const = 0; 1.192 + 1.193 + // Pixel operations 1.194 + virtual bool copyToRenderTarget(TextureStorageInterface2D *dest, TextureStorageInterface2D *source) = 0; 1.195 + virtual bool copyToRenderTarget(TextureStorageInterfaceCube *dest, TextureStorageInterfaceCube *source) = 0; 1.196 + 1.197 + virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, 1.198 + GLint xoffset, GLint yoffset, TextureStorageInterface2D *storage, GLint level) = 0; 1.199 + virtual bool copyImage(gl::Framebuffer *framebuffer, const gl::Rectangle &sourceRect, GLenum destFormat, 1.200 + GLint xoffset, GLint yoffset, TextureStorageInterfaceCube *storage, GLenum target, GLint level) = 0; 1.201 + 1.202 + virtual bool blitRect(gl::Framebuffer *readTarget, const gl::Rectangle &readRect, gl::Framebuffer *drawTarget, const gl::Rectangle &drawRect, 1.203 + bool blitRenderTarget, bool blitDepthStencil) = 0; 1.204 + virtual void readPixels(gl::Framebuffer *framebuffer, GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, 1.205 + GLsizei outputPitch, bool packReverseRowOrder, GLint packAlignment, void* pixels) = 0; 1.206 + 1.207 + // RenderTarget creation 1.208 + virtual RenderTarget *createRenderTarget(SwapChain *swapChain, bool depth) = 0; 1.209 + virtual RenderTarget *createRenderTarget(int width, int height, GLenum format, GLsizei samples, bool depth) = 0; 1.210 + 1.211 + // Shader operations 1.212 + virtual ShaderExecutable *loadExecutable(const void *function, size_t length, rx::ShaderType type) = 0; 1.213 + virtual ShaderExecutable *compileToExecutable(gl::InfoLog &infoLog, const char *shaderHLSL, rx::ShaderType type) = 0; 1.214 + 1.215 + // Image operations 1.216 + virtual Image *createImage() = 0; 1.217 + virtual void generateMipmap(Image *dest, Image *source) = 0; 1.218 + virtual TextureStorage *createTextureStorage2D(SwapChain *swapChain) = 0; 1.219 + virtual TextureStorage *createTextureStorage2D(int levels, GLenum internalformat, GLenum usage, bool forceRenderable, GLsizei width, GLsizei height) = 0; 1.220 + virtual TextureStorage *createTextureStorageCube(int levels, GLenum internalformat, GLenum usage, bool forceRenderable, int size) = 0; 1.221 + 1.222 + // Buffer creation 1.223 + virtual VertexBuffer *createVertexBuffer() = 0; 1.224 + virtual IndexBuffer *createIndexBuffer() = 0; 1.225 + virtual BufferStorage *createBufferStorage() = 0; 1.226 + 1.227 + // Query and Fence creation 1.228 + virtual QueryImpl *createQuery(GLenum type) = 0; 1.229 + virtual FenceImpl *createFence() = 0; 1.230 + 1.231 + virtual bool getLUID(LUID *adapterLuid) const = 0; 1.232 + 1.233 + protected: 1.234 + bool initializeCompiler(); 1.235 + ShaderBlob *compileToBinary(gl::InfoLog &infoLog, const char *hlsl, const char *profile, UINT optimizationFlags, bool alternateFlags); 1.236 + 1.237 + egl::Display *mDisplay; 1.238 + 1.239 + private: 1.240 + DISALLOW_COPY_AND_ASSIGN(Renderer); 1.241 + 1.242 + HMODULE mD3dCompilerModule; 1.243 + pCompileFunc mD3DCompileFunc; 1.244 +}; 1.245 + 1.246 +} 1.247 +#endif // LIBGLESV2_RENDERER_RENDERER_H_