daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 1 | // |
| 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.com | ef21ab2 | 2012-10-31 17:52:47 +0000 | [diff] [blame] | 13 | #include <set> |
| 14 | #include <vector> |
| 15 | |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 16 | #define GL_APICALL |
| 17 | #include <GLES2/gl2.h> |
| 18 | #include <GLES2/gl2ext.h> |
| 19 | #define EGLAPI |
| 20 | #include <EGL/egl.h> |
| 21 | |
| 22 | #include <d3d9.h> // D3D9_REPLACE |
| 23 | |
daniel@transgaming.com | e4733d7 | 2012-10-31 18:07:01 +0000 | [diff] [blame^] | 24 | #include "common/angleutils.h" |
| 25 | #include "libGLESv2/renderer/ShaderCache.h" |
| 26 | |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 27 | const int versionWindowsVista = MAKEWORD(0x00, 0x06); |
| 28 | const int versionWindows7 = MAKEWORD(0x01, 0x06); |
| 29 | |
| 30 | // Return the version of the operating system in a format suitable for ordering |
| 31 | // comparison. |
| 32 | inline int getComparableOSVersion() |
| 33 | { |
| 34 | DWORD version = GetVersion(); |
| 35 | int majorVersion = LOBYTE(LOWORD(version)); |
| 36 | int minorVersion = HIBYTE(LOWORD(version)); |
| 37 | return MAKEWORD(minorVersion, majorVersion); |
| 38 | } |
| 39 | |
daniel@transgaming.com | ef21ab2 | 2012-10-31 17:52:47 +0000 | [diff] [blame] | 40 | namespace egl |
| 41 | { |
| 42 | class Display; |
| 43 | } |
| 44 | |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 45 | namespace renderer |
| 46 | { |
| 47 | |
| 48 | class Renderer |
| 49 | { |
| 50 | public: |
daniel@transgaming.com | ef21ab2 | 2012-10-31 17:52:47 +0000 | [diff] [blame] | 51 | Renderer(egl::Display *display, HMODULE hModule, HDC hDc); |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 52 | virtual ~Renderer(); |
| 53 | |
| 54 | virtual EGLint initialize(); |
| 55 | virtual bool resetDevice(); |
| 56 | |
| 57 | virtual void startScene(); |
| 58 | virtual void endScene(); |
| 59 | |
daniel@transgaming.com | ef21ab2 | 2012-10-31 17:52:47 +0000 | [diff] [blame] | 60 | virtual void sync(bool block); |
| 61 | virtual IDirect3DQuery9* allocateEventQuery(); |
| 62 | virtual void freeEventQuery(IDirect3DQuery9* query); |
| 63 | |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 64 | // resource creation |
daniel@transgaming.com | e4733d7 | 2012-10-31 18:07:01 +0000 | [diff] [blame^] | 65 | virtual IDirect3DVertexShader9 *createVertexShader(const DWORD *function, size_t length); // D3D9_REPLACE |
| 66 | virtual IDirect3DPixelShader9 *createPixelShader(const DWORD *function, size_t length); // D3D9_REPLACE |
| 67 | #if 0 |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 68 | virtual void *createTexture2D(); |
| 69 | virtual void *createTextureCube(); |
| 70 | virtual void *createQuery();; |
| 71 | virtual void *createIndexBuffer(); |
| 72 | virtual void *createVertexbuffer(); |
| 73 | |
| 74 | // state setup |
| 75 | virtual void applyTexture(); |
| 76 | virtual void applyShaders(); |
| 77 | virtual void applyConstants(); |
| 78 | virtual void applyRenderTargets(); |
| 79 | virtual void applyState(); |
| 80 | #endif |
| 81 | |
| 82 | // lost device |
| 83 | virtual void markDeviceLost(); |
| 84 | virtual bool isDeviceLost(); |
daniel@transgaming.com | f688c0d | 2012-10-31 17:52:57 +0000 | [diff] [blame] | 85 | virtual bool testDeviceLost(bool notify); |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 86 | virtual bool testDeviceResettable(); |
| 87 | |
| 88 | // Renderer capabilities |
| 89 | virtual IDirect3DDevice9 *getDevice() {return mDevice;}; // D3D9_REPLACE |
| 90 | virtual D3DADAPTER_IDENTIFIER9 *getAdapterIdentifier() {return &mAdapterIdentifier;}; // D3D9_REPLACE |
| 91 | virtual D3DCAPS9 getDeviceCaps() {return mDeviceCaps;}; // D3D9_REMOVE |
| 92 | virtual IDirect3D9 *getD3D() {return mD3d9;}; // D3D9_REMOVE |
| 93 | virtual UINT getAdapter() {return mAdapter;}; // D3D9_REMOVE |
| 94 | virtual D3DDEVTYPE getDeviceType() {return mDeviceType;}; // D3D9_REMOVE |
| 95 | virtual bool isD3d9ExDevice() const { return mD3d9Ex != NULL; } // D3D9_REMOVE |
| 96 | |
| 97 | virtual void getMultiSampleSupport(D3DFORMAT format, bool *multiSampleArray); // D3D9_REPLACE |
| 98 | virtual bool getDXT1TextureSupport(); |
| 99 | virtual bool getDXT3TextureSupport(); |
| 100 | virtual bool getDXT5TextureSupport(); |
| 101 | virtual bool getEventQuerySupport(); |
| 102 | virtual bool getFloat32TextureSupport(bool *filtering, bool *renderable); |
| 103 | virtual bool getFloat16TextureSupport(bool *filtering, bool *renderable); |
| 104 | virtual bool getLuminanceTextureSupport(); |
| 105 | virtual bool getLuminanceAlphaTextureSupport(); |
| 106 | virtual bool getVertexTextureSupport() const; |
| 107 | virtual bool getNonPower2TextureSupport() const; |
| 108 | virtual bool getDepthTextureSupport() const; |
| 109 | virtual bool getOcclusionQuerySupport() const; |
| 110 | virtual bool getInstancingSupport() const; |
| 111 | virtual float getTextureFilterAnisotropySupport() const; |
daniel@transgaming.com | 313e392 | 2012-10-31 17:52:39 +0000 | [diff] [blame] | 112 | virtual bool getShareHandleSupport() const; |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 113 | |
| 114 | virtual D3DPOOL getBufferPool(DWORD usage) const; |
| 115 | virtual D3DPOOL getTexturePool(DWORD usage) const; |
| 116 | |
| 117 | private: |
| 118 | DISALLOW_COPY_AND_ASSIGN(Renderer); |
| 119 | |
daniel@transgaming.com | ef21ab2 | 2012-10-31 17:52:47 +0000 | [diff] [blame] | 120 | egl::Display *mDisplay; |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 121 | const HDC mDc; |
| 122 | HMODULE mD3d9Module; |
| 123 | |
| 124 | void initializeDevice(); |
| 125 | D3DPRESENT_PARAMETERS getDefaultPresentParameters(); |
daniel@transgaming.com | ef21ab2 | 2012-10-31 17:52:47 +0000 | [diff] [blame] | 126 | void releaseDeviceResources(); |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 127 | |
| 128 | UINT mAdapter; |
| 129 | D3DDEVTYPE mDeviceType; |
| 130 | IDirect3D9 *mD3d9; // Always valid after successful initialization. |
| 131 | IDirect3D9Ex *mD3d9Ex; // Might be null if D3D9Ex is not supported. |
| 132 | IDirect3DDevice9 *mDevice; |
| 133 | IDirect3DDevice9Ex *mDeviceEx; // Might be null if D3D9Ex is not supported. |
| 134 | |
| 135 | HWND mDeviceWindow; |
| 136 | |
| 137 | bool mDeviceLost; |
| 138 | D3DCAPS9 mDeviceCaps; |
| 139 | D3DADAPTER_IDENTIFIER9 mAdapterIdentifier; |
| 140 | |
| 141 | bool mSceneStarted; |
| 142 | bool mSupportsNonPower2Textures; |
daniel@transgaming.com | ef21ab2 | 2012-10-31 17:52:47 +0000 | [diff] [blame] | 143 | |
| 144 | // A pool of event queries that are currently unused. |
| 145 | std::vector<IDirect3DQuery9*> mEventQueryPool; |
daniel@transgaming.com | e4733d7 | 2012-10-31 18:07:01 +0000 | [diff] [blame^] | 146 | VertexShaderCache mVertexShaderCache; |
| 147 | PixelShaderCache mPixelShaderCache; |
daniel@transgaming.com | 621ce05 | 2012-10-31 17:52:29 +0000 | [diff] [blame] | 148 | }; |
| 149 | |
| 150 | } |
| 151 | #endif // LIBGLESV2_RENDERER_RENDERER_H_ |