blob: 169cb331135ce8ea5f674e9e10cefd3757bd6979 [file] [log] [blame]
daniel@transgaming.com621ce052012-10-31 17:52:29 +00001//
2// Copyright (c) 2012 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//
6
7// Renderer.h: Defines a back-end specific class that hides the details of the
8// implementation-specific renderer.
9
10#ifndef LIBGLESV2_RENDERER_RENDERER_H_
11#define LIBGLESV2_RENDERER_RENDERER_H_
12
daniel@transgaming.com621ce052012-10-31 17:52:29 +000013#define GL_APICALL
14#include <GLES2/gl2.h>
15#include <GLES2/gl2ext.h>
16#define EGLAPI
17#include <EGL/egl.h>
18
daniel@transgaming.comba0570e2012-10-31 18:07:39 +000019#include "libGLESv2/Texture.h"
daniel@transgaming.comef19da52012-11-28 19:35:08 +000020#include "libGLESv2/angletypes.h"
daniel@transgaming.come4733d72012-10-31 18:07:01 +000021
daniel@transgaming.com621ce052012-10-31 17:52:29 +000022const int versionWindowsVista = MAKEWORD(0x00, 0x06);
23const int versionWindows7 = MAKEWORD(0x01, 0x06);
24
25// Return the version of the operating system in a format suitable for ordering
26// comparison.
27inline int getComparableOSVersion()
28{
29 DWORD version = GetVersion();
30 int majorVersion = LOBYTE(LOWORD(version));
31 int minorVersion = HIBYTE(LOWORD(version));
32 return MAKEWORD(minorVersion, majorVersion);
33}
34
daniel@transgaming.comef21ab22012-10-31 17:52:47 +000035namespace egl
36{
37class Display;
38}
39
daniel@transgaming.com31b13e12012-11-28 19:34:30 +000040namespace rx
daniel@transgaming.com1d80eee2012-11-28 19:33:31 +000041{
42class TextureStorage2D;
43class TextureStorageCubeMap;
daniel@transgaming.comde8a7ff2012-11-28 19:34:13 +000044class Blit;
45
daniel@transgaming.com3281f972012-10-31 18:38:51 +000046struct ConfigDesc
47{
48 GLenum renderTargetFormat;
49 GLenum depthStencilFormat;
50 GLint multiSample;
51 bool fastConfig;
52};
53
daniel@transgaming.com621ce052012-10-31 17:52:29 +000054class Renderer
55{
56 public:
daniel@transgaming.com4f0af572012-10-31 19:55:46 +000057 explicit Renderer(egl::Display *display) : mDisplay(display) {};
daniel@transgaming.com2507f412012-10-31 18:46:48 +000058 virtual ~Renderer() {};
daniel@transgaming.com621ce052012-10-31 17:52:29 +000059
daniel@transgaming.com2507f412012-10-31 18:46:48 +000060 virtual EGLint initialize() = 0;
61 virtual bool resetDevice() = 0;
daniel@transgaming.com621ce052012-10-31 17:52:29 +000062
daniel@transgaming.com2507f412012-10-31 18:46:48 +000063 virtual int generateConfigs(ConfigDesc **configDescList) = 0;
64 virtual void deleteConfigs(ConfigDesc *configDescList) = 0;
daniel@transgaming.com3281f972012-10-31 18:38:51 +000065
daniel@transgaming.com2507f412012-10-31 18:46:48 +000066 virtual void startScene() = 0;
67 virtual void endScene() = 0;
daniel@transgaming.com621ce052012-10-31 17:52:29 +000068
daniel@transgaming.com2507f412012-10-31 18:46:48 +000069 virtual void sync(bool block) = 0;
daniel@transgaming.comef21ab22012-10-31 17:52:47 +000070
daniel@transgaming.com2507f412012-10-31 18:46:48 +000071 virtual void setSamplerState(gl::SamplerType type, int index, const gl::SamplerState &sampler) = 0;
72 virtual void setTexture(gl::SamplerType type, int index, gl::Texture *texture) = 0;
daniel@transgaming.com621ce052012-10-31 17:52:29 +000073
daniel@transgaming.com493d4f82012-11-28 19:35:45 +000074 virtual void setRasterizerState(const gl::RasterizerState &rasterState, unsigned int depthSize) = 0;
75 virtual void setBlendState(const gl::BlendState &blendState, const gl::Color &blendColor,
76 unsigned int sampleMask) = 0;
77 virtual void setDepthStencilState(const gl::DepthStencilState &depthStencilState, bool frontFaceCCW,
78 unsigned int stencilSize) = 0;
79
80 virtual void setScissorRectangle(const gl::Rectangle& scissor, unsigned int renderTargetWidth,
81 unsigned int renderTargetHeight) = 0;
82
83 virtual void applyRenderTarget(gl::Framebuffer *frameBuffer) = 0;
84
daniel@transgaming.comd084c622012-11-28 19:36:05 +000085 virtual void clear(GLbitfield mask, const gl::Color &colorClear, float depthClear, int stencilClear,
86 gl::Framebuffer *frameBuffer) = 0;
87
daniel@transgaming.com621ce052012-10-31 17:52:29 +000088 // lost device
daniel@transgaming.com2507f412012-10-31 18:46:48 +000089 virtual void markDeviceLost() = 0;
90 virtual bool isDeviceLost() = 0;
91 virtual bool testDeviceLost(bool notify) = 0;
92 virtual bool testDeviceResettable() = 0;
daniel@transgaming.com621ce052012-10-31 17:52:29 +000093
94 // Renderer capabilities
daniel@transgaming.com2507f412012-10-31 18:46:48 +000095 virtual DWORD getAdapterVendor() const = 0;
96 virtual const char *getAdapterDescription() const = 0;
97 virtual GUID getAdapterIdentifier() const = 0;
daniel@transgaming.com621ce052012-10-31 17:52:29 +000098
daniel@transgaming.com2507f412012-10-31 18:46:48 +000099 virtual bool getDXT1TextureSupport() = 0;
100 virtual bool getDXT3TextureSupport() = 0;
101 virtual bool getDXT5TextureSupport() = 0;
102 virtual bool getEventQuerySupport() = 0;
103 virtual bool getFloat32TextureSupport(bool *filtering, bool *renderable) = 0;
104 virtual bool getFloat16TextureSupport(bool *filtering, bool *renderable) = 0;
105 virtual bool getLuminanceTextureSupport() = 0;
106 virtual bool getLuminanceAlphaTextureSupport() = 0;
107 virtual bool getVertexTextureSupport() const = 0;
108 virtual bool getNonPower2TextureSupport() const = 0;
109 virtual bool getDepthTextureSupport() const = 0;
110 virtual bool getOcclusionQuerySupport() const = 0;
111 virtual bool getInstancingSupport() const = 0;
112 virtual bool getTextureFilterAnisotropySupport() const = 0;
113 virtual float getTextureMaxAnisotropy() const = 0;
114 virtual bool getShareHandleSupport() const = 0;
daniel@transgaming.com621ce052012-10-31 17:52:29 +0000115
daniel@transgaming.com2507f412012-10-31 18:46:48 +0000116 virtual bool getShaderModel3Support() const = 0;
117 virtual float getMaxPointSize() const = 0;
118 virtual int getMaxTextureWidth() const = 0;
119 virtual int getMaxTextureHeight() const = 0;
120 virtual bool get32BitIndexSupport() const = 0;
121 virtual int getMinSwapInterval() const = 0;
122 virtual int getMaxSwapInterval() const = 0;
daniel@transgaming.com5f4c1362012-10-31 18:29:00 +0000123
daniel@transgaming.com2507f412012-10-31 18:46:48 +0000124 virtual GLsizei getMaxSupportedSamples() const = 0;
daniel@transgaming.comb7833982012-10-31 18:31:46 +0000125
daniel@transgaming.com31b13e12012-11-28 19:34:30 +0000126 virtual bool copyToRenderTarget(TextureStorage2D *dest, TextureStorage2D *source) = 0;
127 virtual bool copyToRenderTarget(TextureStorageCubeMap *dest, TextureStorageCubeMap *source) = 0;
daniel@transgaming.com1d80eee2012-11-28 19:33:31 +0000128
daniel@transgaming.com31b13e12012-11-28 19:34:30 +0000129 virtual bool copyImage(gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, TextureStorage2D *storage, GLint level) = 0;
130 virtual bool copyImage(gl::Framebuffer *framebuffer, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, TextureStorageCubeMap *storage, GLenum target, GLint level) = 0;
daniel@transgaming.comde8a7ff2012-11-28 19:34:13 +0000131
daniel@transgaming.com2507f412012-10-31 18:46:48 +0000132 protected:
daniel@transgaming.comef21ab22012-10-31 17:52:47 +0000133 egl::Display *mDisplay;
daniel@transgaming.com4f0af572012-10-31 19:55:46 +0000134
135 private:
136 DISALLOW_COPY_AND_ASSIGN(Renderer);
137
daniel@transgaming.com621ce052012-10-31 17:52:29 +0000138};
139
140}
141#endif // LIBGLESV2_RENDERER_RENDERER_H_