1 // Copyright 2016 The SwiftShader Authors. All Rights Reserved. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #ifndef D3D9_Direct3D9_hpp 16 #define D3D9_Direct3D9_hpp 17 18 #include "Unknown.hpp" 19 20 #include <stdio.h> 21 #include <d3d9.h> 22 23 namespace D3D9 24 { 25 class Direct3DDevice9; 26 27 class Direct3D9 : public IDirect3D9, public Unknown 28 { 29 public: 30 Direct3D9(int version, const HINSTANCE instance); 31 32 ~Direct3D9() override; 33 34 // IUnknown methods 35 long __stdcall QueryInterface(const IID &iid, void **object) override; 36 unsigned long __stdcall AddRef() override; 37 unsigned long __stdcall Release() override; 38 39 // IDirect3D9 methods 40 long __stdcall RegisterSoftwareDevice(void *initializeFunction) override; 41 unsigned int __stdcall GetAdapterCount() override; 42 long __stdcall GetAdapterIdentifier(unsigned int adapter, unsigned long flags, D3DADAPTER_IDENTIFIER9 *identifier) override; 43 unsigned int __stdcall GetAdapterModeCount(unsigned int adapter, D3DFORMAT format) override; 44 long __stdcall EnumAdapterModes(unsigned int adapter, D3DFORMAT format, unsigned int index, D3DDISPLAYMODE *mode) override; 45 long __stdcall GetAdapterDisplayMode(unsigned int adapter, D3DDISPLAYMODE *mode) override; 46 long __stdcall CheckDeviceType(unsigned int adapter, D3DDEVTYPE checkType, D3DFORMAT displayFormat, D3DFORMAT backBufferFormat, int windowed) override; 47 long __stdcall CheckDeviceFormat(unsigned int adapter, D3DDEVTYPE deviceType, D3DFORMAT adapterFormat, unsigned long usage, D3DRESOURCETYPE type, D3DFORMAT checkFormat) override; 48 long __stdcall CheckDeviceMultiSampleType(unsigned int adapter, D3DDEVTYPE deviceType, D3DFORMAT surfaceFormat, int windowed, D3DMULTISAMPLE_TYPE multiSampleType, unsigned long *qualityLevels) override; 49 long __stdcall CheckDepthStencilMatch(unsigned int adapter, D3DDEVTYPE deviceType, D3DFORMAT adapterFormat, D3DFORMAT renderTargetFormat, D3DFORMAT depthStencilFormat) override; 50 long __stdcall CheckDeviceFormatConversion(unsigned int adapter, D3DDEVTYPE deviceType, D3DFORMAT sourceFormat, D3DFORMAT targetFormat) override; 51 long __stdcall GetDeviceCaps(unsigned int adapter, D3DDEVTYPE deviceType, D3DCAPS9 *caps) override; 52 HMONITOR __stdcall GetAdapterMonitor(unsigned int adapter) override; 53 long __stdcall CreateDevice(unsigned int adapter, D3DDEVTYPE deviceType, HWND focusWindow, unsigned long behaviorFlags, D3DPRESENT_PARAMETERS *presentParameters, IDirect3DDevice9 **returnedDeviceInterface) override; 54 55 protected: 56 // Creation parameters 57 const int version; 58 const HINSTANCE instance; 59 60 // Real D3D9 library 61 HMODULE d3d9Lib; 62 63 private: 64 void loadSystemD3D9(); 65 66 DEVMODE *displayMode; 67 int numDisplayModes; 68 bool disableAlphaMode; // Disable A8R8G8B8 display mode support 69 bool disable10BitMode; // Disable A2R10G10B10 display mode support 70 71 //Real IDirect3D9 object 72 IDirect3D9 *d3d9; 73 }; 74 } 75 76 #endif // D3D9_Direct3D9_hpp 77