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