OpenBarnyard
 
Loading...
Searching...
No Matches
TRenderAdapter_DX8.cpp
Go to the documentation of this file.
1#include "ToshiPCH.h"
4
5//-----------------------------------------------------------------------------
6// Enables memory debugging.
7// Note: Should be the last include!
8//-----------------------------------------------------------------------------
10
12
16
17// $Barnyard: FUNCTION 006c7070
18// $Barnyard: FUNCTION 006d6940
22
23// $Barnyard: FUNCTION 006d66c0
25{
26 return m_uiAdapterIndex;
27}
28
29// $Barnyard: FUNCTION 006d66d0
31{
32 return m_Driver;
33}
34
35// $Barnyard: FUNCTION 006d66e0
37{
38 return m_Description;
39}
40
41// $Barnyard: FUNCTION 006d66f0
43{
44 return m_DriverVersionHighPart >> 16;
45}
46
47// $Barnyard: FUNCTION 006d6700
49{
50 return m_DriverVersionHighPart & 0xFFFF;
51}
52
53// $Barnyard: FUNCTION 006d6710
55{
56 return m_DriverVersionLowPart >> 16;
57}
58
59// $Barnyard: FUNCTION 006d6720
61{
62 return m_DriverVersionLowPart & 0xFFFF;
63}
64
65// $Barnyard: FUNCTION 006d6730
67{
68 return &m_DeviceIdentifier;
69}
70
71// $Barnyard: FUNCTION 006d47b0
76
77// $Barnyard: FUNCTION 006d69a0
79{
80 TRenderD3DInterface* pRenderer = TSTATICCAST( TRenderD3DInterface, a_pRenderer );
81
82 TUINT32 uiAdapterIndex = GetAdapterIndex();
83 TUINT32 uiNumSupportedDevices = GetNumSupportedDevices();
84 TUINT32 uiAdapterModeCount = pRenderer->GetDirect3D()->GetAdapterModeCount( uiAdapterIndex );
85
86 for ( TUINT32 i = 0; i < uiAdapterModeCount; i++ )
87 {
88 auto pMode = new Mode();
89
90 pMode->SetOwnerAdapter( this );
91 pMode->SetModeIndex( i );
92
93 pRenderer->GetDirect3D()->EnumAdapterModes( uiAdapterIndex, i, &pMode->GetD3DDisplayMode() );
94
95 for ( TUINT32 k = 0; k < uiNumSupportedDevices; k++ )
96 {
97 auto pDevice = TSTATICCAST( TD3DAdapter::Mode::Device, pMode->GetDevice( k ) );
98
99 pDevice->SetOwnerMode( pMode );
100 pDevice->SetDeviceIndex( k );
101
102 pRenderer->GetDirect3D()->GetDeviceCaps( uiAdapterIndex, Mode::Device::DEVICETYPES[ k ], &pDevice->GetD3DCaps() );
103 HRESULT hRes = pRenderer->GetDirect3D()->CheckDeviceType(
104 uiAdapterIndex,
106 pMode->GetD3DDisplayMode().Format,
107 pMode->GetD3DDisplayMode().Format,
108 FALSE
109 );
110
111 if ( SUCCEEDED( hRes ) )
112 {
113 auto& caps = pDevice->GetD3DCaps();
114
115 if ( Mode::Device::DEVICETYPES[ k ] == D3DDEVTYPE_REF )
116 {
117 pDevice->m_bIsSoftware = TTRUE;
118 }
119
120 if ( caps.Caps2 & D3DCAPS2_CANRENDERWINDOWED )
121 {
122 pDevice->m_bCanRenderWindowed = TTRUE;
123 }
124
125 if ( caps.DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT )
126 {
127 pDevice->m_bSupportsTransformation = TTRUE;
128 pDevice->m_bSupportsPureDevice = caps.DevCaps & D3DDEVCAPS_PUREDEVICE;
129 }
130
131 if ( caps.DevCaps & D3DDEVCAPS_NPATCHES )
132 {
133 pDevice->m_bSupportsNPatches = TTRUE;
134 }
135
136 if ( pDevice->SupportsHardwareTransfomations() )
137 {
138 if ( pDevice->SupportsPureDevice() )
139 {
140 pDevice->m_eFlags |= D3DCREATE_HARDWARE_VERTEXPROCESSING;
141 }
142 else
143 {
144 pDevice->m_eFlags |= D3DCREATE_MIXED_VERTEXPROCESSING;
145 }
146 }
147 else
148 {
149 pDevice->m_eFlags |= D3DCREATE_SOFTWARE_VERTEXPROCESSING;
150 }
151
152 for ( TINT j = 0; j < Mode::Device::NUMDEPTHSTENCILFORMATS; j++ )
153 {
154 if ( Mode::Device::DEPTHSTENCILFORMATS[ j ] != D3DFMT_UNKNOWN )
155 {
156 HRESULT hCheck = pRenderer->GetDirect3D()->CheckDeviceFormat(
157 uiAdapterIndex,
159 pMode->GetD3DDisplayMode().Format,
160 D3DUSAGE_DEPTHSTENCIL,
161 D3DRTYPE_SURFACE,
163 );
164
165 if ( SUCCEEDED( hCheck ) )
166 {
167 HRESULT hMatch = pRenderer->GetDirect3D()->CheckDepthStencilMatch(
168 uiAdapterIndex,
170 pMode->GetD3DDisplayMode().Format,
171 pMode->GetD3DDisplayMode().Format,
173 );
174
175 if ( SUCCEEDED( hMatch ) )
176 {
177 pDevice->m_aSupportedDSFormats[ j ] = TTRUE;
178 }
179 }
180 }
181 }
182 }
183 }
184
185 GetModeList()->InsertTail( pMode );
186 }
187}
188
189// $Barnyard: FUNCTION 004ffb50
191{
192 return m_pOwnerAdapter;
193}
194
195// $Barnyard: FUNCTION 004ffe40
197{
198 return m_uiModeIndex;
199}
200
201// $Barnyard: FUNCTION 006d6760
203{
204 return m_DisplayMode.Width;
205}
206
207// $Barnyard: FUNCTION 005f7a30
209{
210 return m_DisplayMode.Height;
211}
212
213// $Barnyard: FUNCTION 006d6770
215{
216 return m_DisplayMode.Format == D3DFMT_X8R8G8B8;
217}
218
219// $Barnyard: FUNCTION 006d6780
221{
222 return m_DisplayMode.Format == D3DFMT_R5G6B5 ||
223 m_DisplayMode.Format == D3DFMT_X1R5G5B5 ||
224 m_DisplayMode.Format == D3DFMT_X4R4G4B4;
225}
226
227// $Barnyard: FUNCTION 006d67a0
229{
230 return m_DisplayMode.RefreshRate;
231}
232
233// $Barnyard: FUNCTION 006d67b0
235{
236 if ( a_iDevice >= 0 && a_iDevice < NUMSUPPORTEDDEVICES )
237 {
238 return &m_aDevices[ a_iDevice ];
239 }
240
241 return TNULL;
242}
243
244// $Barnyard: FUNCTION 006d67f0
246{
247 if ( a_uiColourDepth == 16 )
248 {
249 return D3DFORMAT( ( -(TUINT32)( ( *(TUINT8*)&( m_DisplayMode ).Format & 0x17 ) != 0 ) & 0xfffffff9 ) + D3DFMT_X4R4G4B4 );
250 }
251
252 return D3DFORMAT( ( a_uiColourDepth != 32 ) - 1 & 0x16 );
253}
254
255// $Barnyard: FUNCTION 006d6820
257{
258 return m_pOwnerMode;
259}
260
261// $Barnyard: FUNCTION 006d6830
263{
264 return m_uiDeviceIndex;
265}
266
267// $Barnyard: FUNCTION 006d6840
269{
270 return DEVICETYPESSTRINGS[ m_uiDeviceIndex ];
271}
272
273// $Barnyard: FUNCTION 006d6850
275{
276 return m_bIsSoftware;
277}
278
279// $Barnyard: FUNCTION 006d6860
281{
282 return m_bCanRenderWindowed;
283}
284
285// $Barnyard: FUNCTION 006d6870
287{
288 return m_bSupportsTransformation;
289}
290
291// $Barnyard: FUNCTION 006d6890
293{
294 return m_aSupportedDSFormats[ a_iIndex ];
295}
296
297// $Barnyard: FUNCTION 006d6880
299{
300 return m_bSupportsPureDevice;
301}
302
#define TSTATICCAST(POINTERTYPE, VALUE)
Definition Defines.h:69
#define TOSHI_NAMESPACE_START
Definition Defines.h:47
#define TOSHI_NAMESPACE_END
Definition Defines.h:50
uint16_t TUINT16
Definition Typedefs.h:15
size_t TSIZE
Definition Typedefs.h:9
char TCHAR
Definition Typedefs.h:20
uint8_t TUINT8
Definition Typedefs.h:17
#define TNULL
Definition Typedefs.h:23
uint32_t TUINT32
Definition Typedefs.h:13
int TINT
Definition Typedefs.h:7
#define TTRUE
Definition Typedefs.h:25
bool TBOOL
Definition Typedefs.h:6
virtual TUINT16 GetVersion() const override
virtual const void * GetDeviceIdentifier() const override
virtual TUINT32 GetAdapterIndex() const override
virtual TUINT16 GetSubVersion() const override
void EnumerateOutputs(TRenderInterface *a_pRenderer)
virtual TUINT32 GetNumSupportedDevices() const override
virtual TUINT16 GetBuild() const override
virtual const TString8 & GetDriver() const override
virtual TUINT16 GetProductID() const override
virtual const TString8 & GetDriverDescription() const override
virtual TBOOL Is32Bit() const override
virtual TUINT32 GetWidth() const override
virtual TRenderAdapter * GetAdapter() const override
D3DFORMAT GetBackBufferFormat(TUINT32 a_uiColourDepth)
virtual size_t GetModeIndex() const override
static constexpr TUINT32 NUMSUPPORTEDDEVICES
virtual TBOOL Is16Bit() const override
virtual TRenderAdapter::Mode::Device * GetDevice(TUINT32 a_iDevice) override
virtual TUINT32 GetRefreshRate() const override
virtual TUINT32 GetHeight() const override
virtual TBOOL IsSoftware() const override
virtual TBOOL SupportsHardwareTransfomations() const override
virtual TBOOL IsDepthStencilFormatSupported(TUINT32 a_iIndex) const override
virtual TUINT32 GetDeviceIndex() const override
static constexpr const TCHAR * DEVICETYPESSTRINGS[NUMSUPPORTEDDEVICES]
virtual TBOOL CanRenderWindowed() const override
virtual const TCHAR * GetTypeString() const override
virtual TBOOL SupportsPureDevice() const
virtual TRenderAdapter::Mode * GetMode() const override
static constexpr D3DFORMAT DEPTHSTENCILFORMATS[]
static constexpr TUINT32 NUMDEPTHSTENCILFORMATS
static constexpr D3DDEVTYPE DEVICETYPES[NUMSUPPORTEDDEVICES]
DirectX 8 implementation of the render interface Handles DirectX 8 specific rendering functionality a...
TFORCEINLINE IDirect3D8 * GetDirect3D() const
Gets the Direct3D interface.
TNodeList< Mode > * GetModeList()
TRenderAdapter()=default