Skip to content

Commit ed9a4f2

Browse files
[meta] Also use static desc structs in EnumDevices
1 parent 3aaaed3 commit ed9a4f2

18 files changed

Lines changed: 401 additions & 472 deletions

‎src/ddraw/d3d3/d3d3_device.cpp‎

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,11 @@ namespace dxvk {
3434

3535
m_commonIntf = m_parent->GetCommonInterface();
3636

37-
const D3DOptions* d3dOptions = m_commonIntf->GetOptions();
38-
// Retrieve and cache the device capabilities
39-
m_desc = GetD3D3BaseCaps(d3dOptions);
40-
ApplyD3D3DeviceCaps(&m_desc, deviceGUID);
41-
42-
d3d9::IDirect3DDevice9* device9;
37+
d3d9::IDirect3DDevice9* device9 = nullptr;
4338

4439
if (likely(m_commonD3DDevice == nullptr)) {
40+
const D3DOptions* d3dOptions = m_commonIntf->GetOptions();
41+
4542
// Get the bridge interface to D3D9
4643
Com<IDxvkLegacyD3DDeviceBridge> deviceBridgeInst;
4744
HRESULT hr = pDevice9->QueryInterface(__uuidof(IDxvkLegacyD3DDeviceBridge), reinterpret_cast<void**>(&deviceBridgeInst));
@@ -171,29 +168,13 @@ namespace dxvk {
171168
|| !IsValidD3DDeviceDescSize(hel_desc->dwSize)))
172169
return DDERR_INVALIDPARAMS;
173170

174-
D3DDEVICEDESC3 desc_HAL = m_desc;
175-
D3DDEVICEDESC3 desc_HEL = m_desc;
176-
171+
const D3DOptions* d3dOptions = m_commonIntf->GetOptions();
177172
const GUID deviceGUID = m_commonD3DDevice->GetDeviceGUID();
178173

179-
if (deviceGUID == IID_IDirect3DRGBDevice) {
180-
desc_HAL.dwFlags = 0;
181-
desc_HAL.dcmColorModel = 0;
182-
// Some applications apparently care about HAL texture caps
183-
desc_HAL.dpcLineCaps.dwTextureCaps &= ~D3DPTEXTURECAPS_PERSPECTIVE
184-
& ~D3DPTEXTURECAPS_POW2
185-
& ~D3DPTEXTURECAPS_NONPOW2CONDITIONAL;
186-
desc_HAL.dpcTriCaps.dwTextureCaps &= ~D3DPTEXTURECAPS_PERSPECTIVE
187-
& ~D3DPTEXTURECAPS_POW2
188-
& ~D3DPTEXTURECAPS_NONPOW2CONDITIONAL;
189-
} else if (deviceGUID == IID_IDirect3DHALDevice) {
190-
desc_HEL.dcmColorModel = 0;
191-
desc_HEL.dwDevCaps &= ~D3DDEVCAPS_HWTRANSFORMANDLIGHT
192-
& ~D3DDEVCAPS_DRAWPRIMITIVES2
193-
& ~D3DDEVCAPS_DRAWPRIMITIVES2EX;
194-
} else {
195-
Logger::warn("D3D3Device::GetCaps: Unhandled device type");
196-
}
174+
D3DDEVICEDESC3 desc_HAL = GetD3D3BaseCaps(d3dOptions);
175+
ApplyD3D3DeviceCaps(&desc_HAL, deviceGUID, true);
176+
D3DDEVICEDESC3 desc_HEL = GetD3D3BaseCaps(d3dOptions);
177+
ApplyD3D3DeviceCaps(&desc_HAL, deviceGUID, false);
197178

198179
memcpy(hal_desc, &desc_HAL, hal_desc->dwSize);
199180
memcpy(hel_desc, &desc_HEL, hel_desc->dwSize);

‎src/ddraw/d3d3/d3d3_device.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,6 @@ namespace dxvk {
148148

149149
D3DMultithread m_multithread;
150150

151-
D3DDEVICEDESC3 m_desc;
152-
153151
// In D3D3, the RT is the parent of the device
154152
DDrawSurface* m_rt = nullptr;
155153
Com<DDrawSurface, false> m_ds;

‎src/ddraw/d3d3/d3d3_interface.cpp‎

Lines changed: 85 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ namespace dxvk {
3333
m_commonD3DIntf = new D3DCommonInterface(std::move(d3d9Intf), std::move(intfBridgeInst));
3434
}
3535

36-
const D3DOptions* d3dOptions = m_commonIntf->GetOptions();
37-
// Retrieve and cache the base capabilities
38-
m_desc = GetD3D3BaseCaps(d3dOptions);
39-
4036
m_commonD3DIntf->SetD3D3Interface(this);
4137

4238
// Don't enable D3D3 compatibility mode when coming from a higher interface
@@ -154,110 +150,99 @@ namespace dxvk {
154150

155151
HRESULT hr;
156152

153+
// Tests have shown all returned variables and structs are expected
154+
// to remain valid even after the enumeration completes. Moreover,
155+
// some applications may choose to overwrite various elements in place,
156+
// such as the device name/description, and reuse those strings.
157+
157158
// RAMP device (monochrome), this is expected to be exposed
158-
// The caps of a RAMP device are mostly identical to an RGB device
159-
D3DDEVICEDESC3 desc3RAMP_HAL = m_desc;
160-
ApplyD3D3DeviceCaps(&desc3RAMP_HAL, IID_IDirect3DRampDevice);
161-
D3DDEVICEDESC3 desc3RAMP_HEL = m_desc;
162-
ApplyD3D3DeviceCaps(&desc3RAMP_HEL, IID_IDirect3DRampDevice);
163-
D3DDEVICEDESC descRAMP_HAL = { };
164-
D3DDEVICEDESC descRAMP_HEL = { };
165-
desc3RAMP_HAL.dwFlags = 0u;
166-
desc3RAMP_HAL.dcmColorModel = 0u;
167-
// RAMP devices use a monochrome color model
168-
desc3RAMP_HEL.dcmColorModel = D3DCOLOR_MONO;
169-
// Some applications apparently care about HAL texture caps
170-
desc3RAMP_HAL.dpcLineCaps.dwTextureCaps &= ~D3DPTEXTURECAPS_PERSPECTIVE
171-
& ~D3DPTEXTURECAPS_POW2
172-
& ~D3DPTEXTURECAPS_NONPOW2CONDITIONAL;
173-
desc3RAMP_HAL.dpcTriCaps.dwTextureCaps &= ~D3DPTEXTURECAPS_PERSPECTIVE
174-
& ~D3DPTEXTURECAPS_POW2
175-
& ~D3DPTEXTURECAPS_NONPOW2CONDITIONAL;
176-
memcpy(&descRAMP_HAL, &desc3RAMP_HAL, sizeof(D3DDEVICEDESC3));
177-
memcpy(&descRAMP_HEL, &desc3RAMP_HEL, sizeof(D3DDEVICEDESC3));
178-
179-
static GUID deviceGuidRAMP = IID_IDirect3DRampDevice;
159+
static GUID deviceGuidRAMP;
160+
static char deviceDescRAMP[MAX_ENUM_DEVICES_IDENTIFIER_STRING];
161+
static char deviceNameRAMP[MAX_ENUM_DEVICES_IDENTIFIER_STRING];
162+
static D3DDEVICEDESC descDeviceRAMP_HAL;
163+
static D3DDEVICEDESC descDeviceRAMP_HEL;
164+
165+
D3DDEVICEDESC3 desc3RAMP_HAL = GetD3D3BaseCaps(d3dOptions);
166+
ApplyD3D3DeviceCaps(&desc3RAMP_HAL, IID_IDirect3DRampDevice, true);
167+
D3DDEVICEDESC3 desc3RAMP_HEL = GetD3D3BaseCaps(d3dOptions);
168+
ApplyD3D3DeviceCaps(&desc3RAMP_HEL, IID_IDirect3DRampDevice, false);
169+
170+
deviceGuidRAMP = IID_IDirect3DRampDevice;
180171
if (likely(!d3dOptions->legacyDeviceNames)) {
181-
static char deviceDescRAMP[MAX_ENUM_DEVICES_IDENTIFIER_STRING] = "D3VK Ramp";
182-
static char deviceNameRAMP[MAX_ENUM_DEVICES_IDENTIFIER_STRING] = "D3VK Ramp";
183-
hr = lpEnumDevicesCallback(&deviceGuidRAMP, &deviceDescRAMP[0], &deviceNameRAMP[0],
184-
&descRAMP_HAL, &descRAMP_HEL, lpUserArg);
172+
CopyToStringArrayAndPad(deviceDescRAMP, "D3VK Ramp");
173+
CopyToStringArrayAndPad(deviceNameRAMP, "D3VK Ramp");
174+
185175
} else {
186-
static char legacyDeviceDescRAMP[MAX_ENUM_DEVICES_IDENTIFIER_STRING] = "Ramp Emulation";
187-
static char legacyDeviceNameRAMP[MAX_ENUM_DEVICES_IDENTIFIER_STRING] = "Ramp Emulation";
188-
hr = lpEnumDevicesCallback(&deviceGuidRAMP, &legacyDeviceDescRAMP[0], &legacyDeviceNameRAMP[0],
189-
&descRAMP_HAL, &descRAMP_HEL, lpUserArg);
176+
CopyToStringArrayAndPad(deviceDescRAMP, "Ramp Emulation");
177+
CopyToStringArrayAndPad(deviceNameRAMP, "Ramp Emulation");
190178
}
179+
memset(&descDeviceRAMP_HAL, 0, sizeof(D3DDEVICEDESC));
180+
memset(&descDeviceRAMP_HEL, 0, sizeof(D3DDEVICEDESC));
181+
memcpy(&descDeviceRAMP_HAL, &desc3RAMP_HAL, sizeof(D3DDEVICEDESC3));
182+
memcpy(&descDeviceRAMP_HEL, &desc3RAMP_HEL, sizeof(D3DDEVICEDESC3));
183+
184+
hr = lpEnumDevicesCallback(&deviceGuidRAMP, &deviceDescRAMP[0], &deviceNameRAMP[0],
185+
&descDeviceRAMP_HAL, &descDeviceRAMP_HEL, lpUserArg);
191186
if (hr != D3DENUMRET_OK)
192187
return D3D_OK;
193188

194189
// Software emulation, this is expected to be exposed
195-
D3DDEVICEDESC3 desc3RGB_HAL = m_desc;
196-
ApplyD3D3DeviceCaps(&desc3RGB_HAL, IID_IDirect3DRGBDevice);
197-
D3DDEVICEDESC3 desc3RGB_HEL = m_desc;
198-
ApplyD3D3DeviceCaps(&desc3RGB_HEL, IID_IDirect3DRGBDevice);
199-
D3DDEVICEDESC descRGB_HAL = { };
200-
D3DDEVICEDESC descRGB_HEL = { };
201-
desc3RGB_HAL.dwFlags = 0u;
202-
desc3RGB_HAL.dcmColorModel = 0u;
203-
// Some applications apparently care about HAL texture caps
204-
desc3RGB_HAL.dpcLineCaps.dwTextureCaps &= ~D3DPTEXTURECAPS_PERSPECTIVE
205-
& ~D3DPTEXTURECAPS_POW2
206-
& ~D3DPTEXTURECAPS_NONPOW2CONDITIONAL;
207-
desc3RGB_HAL.dpcTriCaps.dwTextureCaps &= ~D3DPTEXTURECAPS_PERSPECTIVE
208-
& ~D3DPTEXTURECAPS_POW2
209-
& ~D3DPTEXTURECAPS_NONPOW2CONDITIONAL;
210-
memcpy(&descRGB_HAL, &desc3RGB_HAL, sizeof(D3DDEVICEDESC3));
211-
memcpy(&descRGB_HEL, &desc3RGB_HEL, sizeof(D3DDEVICEDESC3));
212-
213-
static GUID deviceGuidRGB = IID_IDirect3DRGBDevice;
190+
static GUID deviceGuidRGB;
191+
static char deviceDescRGB[MAX_ENUM_DEVICES_IDENTIFIER_STRING];
192+
static char deviceNameRGB[MAX_ENUM_DEVICES_IDENTIFIER_STRING];
193+
static D3DDEVICEDESC descDeviceRGB_HAL;
194+
static D3DDEVICEDESC descDeviceRGB_HEL;
195+
196+
D3DDEVICEDESC3 desc3RGB_HAL = GetD3D3BaseCaps(d3dOptions);
197+
ApplyD3D3DeviceCaps(&desc3RGB_HAL, IID_IDirect3DRGBDevice, true);
198+
D3DDEVICEDESC3 desc3RGB_HEL = GetD3D3BaseCaps(d3dOptions);
199+
ApplyD3D3DeviceCaps(&desc3RGB_HEL, IID_IDirect3DRGBDevice, false);
200+
201+
deviceGuidRGB = IID_IDirect3DRGBDevice;
214202
if (likely(!d3dOptions->legacyDeviceNames)) {
215-
static char deviceDescRGB[MAX_ENUM_DEVICES_IDENTIFIER_STRING] = "D3VK RGB";
216-
static char deviceNameRGB[MAX_ENUM_DEVICES_IDENTIFIER_STRING] = "D3VK RGB";
217-
hr = lpEnumDevicesCallback(&deviceGuidRGB, &deviceDescRGB[0], &deviceNameRGB[0],
218-
&descRGB_HAL, &descRGB_HEL, lpUserArg);
203+
CopyToStringArrayAndPad(deviceDescRGB, "D3VK RGB");
204+
CopyToStringArrayAndPad(deviceNameRGB, "D3VK RGB");
219205
} else {
220-
static char legacyDeviceDescRGB[MAX_ENUM_DEVICES_IDENTIFIER_STRING] = "RGB Emulation";
221-
static char legacyDeviceNameRGB[MAX_ENUM_DEVICES_IDENTIFIER_STRING] = "RGB Emulation";
222-
hr = lpEnumDevicesCallback(&deviceGuidRGB, &legacyDeviceDescRGB[0], &legacyDeviceNameRGB[0],
223-
&descRGB_HAL, &descRGB_HEL, lpUserArg);
206+
CopyToStringArrayAndPad(deviceDescRGB, "RGB Emulation");
207+
CopyToStringArrayAndPad(deviceNameRGB, "RGB Emulation");
224208
}
209+
memset(&descDeviceRGB_HAL, 0, sizeof(D3DDEVICEDESC));
210+
memset(&descDeviceRGB_HEL, 0, sizeof(D3DDEVICEDESC));
211+
memcpy(&descDeviceRGB_HAL, &desc3RGB_HAL, sizeof(D3DDEVICEDESC3));
212+
memcpy(&descDeviceRGB_HEL, &desc3RGB_HEL, sizeof(D3DDEVICEDESC3));
213+
214+
hr = lpEnumDevicesCallback(&deviceGuidRGB, &deviceDescRGB[0], &deviceNameRGB[0],
215+
&descDeviceRGB_HAL, &descDeviceRGB_HEL, lpUserArg);
225216
if (hr != D3DENUMRET_OK)
226217
return D3D_OK;
227218

228219
// Hardware acceleration
229-
D3DDEVICEDESC3 desc3HAL_HAL = m_desc;
230-
ApplyD3D3DeviceCaps(&desc3HAL_HAL, IID_IDirect3DHALDevice);
231-
D3DDEVICEDESC3 desc3HAL_HEL = m_desc;
232-
ApplyD3D3DeviceCaps(&desc3HAL_HEL, IID_IDirect3DHALDevice);
233-
D3DDEVICEDESC descHAL_HAL = { };
234-
D3DDEVICEDESC descHAL_HEL = { };
235-
desc3HAL_HEL.dcmColorModel = 0u;
236-
// Some applications apparently care about HEL texture caps
237-
desc3HAL_HEL.dpcLineCaps.dwTextureCaps &= ~D3DPTEXTURECAPS_PERSPECTIVE
238-
& ~D3DPTEXTURECAPS_POW2
239-
& ~D3DPTEXTURECAPS_NONPOW2CONDITIONAL;
240-
desc3HAL_HEL.dpcTriCaps.dwTextureCaps &= ~D3DPTEXTURECAPS_PERSPECTIVE
241-
& ~D3DPTEXTURECAPS_POW2
242-
& ~D3DPTEXTURECAPS_NONPOW2CONDITIONAL;
243-
desc3HAL_HEL.dwDevCaps &= ~D3DDEVCAPS_HWTRANSFORMANDLIGHT
244-
& ~D3DDEVCAPS_DRAWPRIMITIVES2
245-
& ~D3DDEVCAPS_DRAWPRIMITIVES2EX;
246-
memcpy(&descHAL_HAL, &desc3HAL_HAL, sizeof(D3DDEVICEDESC3));
247-
memcpy(&descHAL_HEL, &desc3HAL_HEL, sizeof(D3DDEVICEDESC3));
248-
249-
static GUID deviceGuidHAL = IID_IDirect3DHALDevice;
220+
static GUID deviceGuidHAL;
221+
static char deviceDescHAL[MAX_ENUM_DEVICES_IDENTIFIER_STRING];
222+
static char deviceNameHAL[MAX_ENUM_DEVICES_IDENTIFIER_STRING];
223+
static D3DDEVICEDESC descDeviceHAL_HAL;
224+
static D3DDEVICEDESC descDeviceHAL_HEL;
225+
226+
D3DDEVICEDESC3 desc3HAL_HAL = GetD3D3BaseCaps(d3dOptions);
227+
ApplyD3D3DeviceCaps(&desc3HAL_HAL, IID_IDirect3DHALDevice, true);
228+
D3DDEVICEDESC3 desc3HAL_HEL = GetD3D3BaseCaps(d3dOptions);
229+
ApplyD3D3DeviceCaps(&desc3HAL_HEL, IID_IDirect3DHALDevice, false);
230+
231+
deviceGuidHAL = IID_IDirect3DHALDevice;
250232
if (likely(!d3dOptions->legacyDeviceNames)) {
251-
static char deviceDescHAL[MAX_ENUM_DEVICES_IDENTIFIER_STRING] = "D3VK HAL";
252-
static char deviceNameHAL[MAX_ENUM_DEVICES_IDENTIFIER_STRING] = "D3VK HAL";
253-
hr = lpEnumDevicesCallback(&deviceGuidHAL, &deviceDescHAL[0], &deviceNameHAL[0],
254-
&descHAL_HAL, &descHAL_HEL, lpUserArg);
233+
CopyToStringArrayAndPad(deviceDescHAL, "D3VK HAL");
234+
CopyToStringArrayAndPad(deviceNameHAL, "D3VK HAL");
255235
} else {
256-
static char legacyDeviceDescHAL[MAX_ENUM_DEVICES_IDENTIFIER_STRING] = "Direct3D HAL";
257-
static char legacyDeviceNameHAL[MAX_ENUM_DEVICES_IDENTIFIER_STRING] = "Direct3D HAL";
258-
hr = lpEnumDevicesCallback(&deviceGuidHAL, &legacyDeviceDescHAL[0], &legacyDeviceNameHAL[0],
259-
&descHAL_HAL, &descHAL_HEL, lpUserArg);
236+
CopyToStringArrayAndPad(deviceDescHAL, "Direct3D HAL");
237+
CopyToStringArrayAndPad(deviceDescHAL, "Direct3D HAL");
260238
}
239+
memset(&descDeviceHAL_HAL, 0, sizeof(D3DDEVICEDESC));
240+
memset(&descDeviceHAL_HEL, 0, sizeof(D3DDEVICEDESC));
241+
memcpy(&descDeviceHAL_HAL, &desc3HAL_HAL, sizeof(D3DDEVICEDESC3));
242+
memcpy(&descDeviceHAL_HEL, &desc3HAL_HEL, sizeof(D3DDEVICEDESC3));
243+
244+
hr = lpEnumDevicesCallback(&deviceGuidHAL, &deviceDescHAL[0], &deviceNameHAL[0],
245+
&descDeviceHAL_HAL, &descDeviceHAL_HEL, lpUserArg);
261246
if (hr != D3DENUMRET_OK)
262247
return D3D_OK;
263248

@@ -304,37 +289,19 @@ namespace dxvk {
304289
if (unlikely(!IsValidFindDeviceResultSize(lpD3DFDR->dwSize)))
305290
return DDERR_INVALIDPARAMS;
306291

292+
const D3DOptions* d3dOptions = m_commonIntf->GetOptions();
293+
307294
// Software emulation, this is expected to be exposed
308-
D3DDEVICEDESC3 descRGB_HAL = m_desc;
309-
ApplyD3D3DeviceCaps(&descRGB_HAL, IID_IDirect3DRGBDevice);
310-
D3DDEVICEDESC3 descRGB_HEL = m_desc;
311-
ApplyD3D3DeviceCaps(&descRGB_HEL, IID_IDirect3DRGBDevice);
312-
descRGB_HAL.dwFlags = 0u;
313-
descRGB_HAL.dcmColorModel = 0u;
314-
// Some applications apparently care about HAL texture caps
315-
descRGB_HAL.dpcLineCaps.dwTextureCaps &= ~D3DPTEXTURECAPS_PERSPECTIVE
316-
& ~D3DPTEXTURECAPS_POW2
317-
& ~D3DPTEXTURECAPS_NONPOW2CONDITIONAL;
318-
descRGB_HAL.dpcTriCaps.dwTextureCaps &= ~D3DPTEXTURECAPS_PERSPECTIVE
319-
& ~D3DPTEXTURECAPS_POW2
320-
& ~D3DPTEXTURECAPS_NONPOW2CONDITIONAL;
295+
D3DDEVICEDESC3 descRGB_HAL = GetD3D3BaseCaps(d3dOptions);
296+
ApplyD3D3DeviceCaps(&descRGB_HAL, IID_IDirect3DRGBDevice, true);
297+
D3DDEVICEDESC3 descRGB_HEL = GetD3D3BaseCaps(d3dOptions);
298+
ApplyD3D3DeviceCaps(&descRGB_HEL, IID_IDirect3DRGBDevice, false);
321299

322300
// Hardware acceleration
323-
D3DDEVICEDESC3 descHAL_HAL = m_desc;
324-
ApplyD3D3DeviceCaps(&descHAL_HAL, IID_IDirect3DHALDevice);
325-
D3DDEVICEDESC3 descHAL_HEL = m_desc;
326-
ApplyD3D3DeviceCaps(&descHAL_HEL, IID_IDirect3DHALDevice);
327-
descHAL_HEL.dcmColorModel = 0u;
328-
// Some applications apparently care about HEL texture caps
329-
descHAL_HEL.dpcLineCaps.dwTextureCaps &= ~D3DPTEXTURECAPS_PERSPECTIVE
330-
& ~D3DPTEXTURECAPS_POW2
331-
& ~D3DPTEXTURECAPS_NONPOW2CONDITIONAL;
332-
descHAL_HEL.dpcTriCaps.dwTextureCaps &= ~D3DPTEXTURECAPS_PERSPECTIVE
333-
& ~D3DPTEXTURECAPS_POW2
334-
& ~D3DPTEXTURECAPS_NONPOW2CONDITIONAL;
335-
descHAL_HEL.dwDevCaps &= ~D3DDEVCAPS_HWTRANSFORMANDLIGHT
336-
& ~D3DDEVCAPS_DRAWPRIMITIVES2
337-
& ~D3DDEVCAPS_DRAWPRIMITIVES2EX;
301+
D3DDEVICEDESC3 descHAL_HAL = GetD3D3BaseCaps(d3dOptions);
302+
ApplyD3D3DeviceCaps(&descHAL_HAL, IID_IDirect3DHALDevice, true);
303+
D3DDEVICEDESC3 descHAL_HEL = GetD3D3BaseCaps(d3dOptions);
304+
ApplyD3D3DeviceCaps(&descHAL_HEL, IID_IDirect3DHALDevice, false);
338305

339306
D3DFINDDEVICERESULT3 lpD3DFRD3 = { };
340307
lpD3DFRD3.dwSize = sizeof(D3DFINDDEVICERESULT3);

‎src/ddraw/d3d3/d3d3_interface.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ namespace dxvk {
5353

5454
DDrawCommonInterface* m_commonIntf = nullptr;
5555

56-
D3DDEVICEDESC3 m_desc;
57-
5856
Com<D3D6Interface, false> m_d3d6Intf;
5957
Com<D3D5Interface, false> m_d3d5Intf;
6058

‎src/ddraw/d3d5/d3d5_device.cpp‎

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,11 @@ namespace dxvk {
4141
throw DxvkError("D3D5Device: ERROR! Failed to retrieve the common interface!");
4242
}
4343

44-
const D3DOptions* d3dOptions = m_commonIntf->GetOptions();
45-
// Retrieve and cache the device capabilities
46-
m_desc = GetD3D5BaseCaps(d3dOptions);
47-
ApplyD3D5DeviceCaps(&m_desc, deviceGUID);
48-
49-
d3d9::IDirect3DDevice9* device9;
44+
d3d9::IDirect3DDevice9* device9 = nullptr;
5045

5146
if (likely(m_commonD3DDevice == nullptr)) {
47+
const D3DOptions* d3dOptions = m_commonIntf->GetOptions();
48+
5249
// Get the bridge interface to D3D9
5350
Com<IDxvkLegacyD3DDeviceBridge> deviceBridgeInst;
5451
HRESULT hr = pDevice9->QueryInterface(__uuidof(IDxvkLegacyD3DDeviceBridge), reinterpret_cast<void**>(&deviceBridgeInst));
@@ -159,29 +156,13 @@ namespace dxvk {
159156
|| !IsValidD3DDeviceDescSize(hel_desc->dwSize)))
160157
return DDERR_INVALIDPARAMS;
161158

162-
D3DDEVICEDESC2 desc_HAL = m_desc;
163-
D3DDEVICEDESC2 desc_HEL = m_desc;
164-
159+
const D3DOptions* d3dOptions = m_commonIntf->GetOptions();
165160
const GUID deviceGUID = m_commonD3DDevice->GetDeviceGUID();
166161

167-
if (deviceGUID == IID_IDirect3DRGBDevice) {
168-
desc_HAL.dwFlags = 0;
169-
desc_HAL.dcmColorModel = 0;
170-
// Some applications apparently care about HAL texture caps
171-
desc_HAL.dpcLineCaps.dwTextureCaps &= ~D3DPTEXTURECAPS_PERSPECTIVE
172-
& ~D3DPTEXTURECAPS_POW2
173-
& ~D3DPTEXTURECAPS_NONPOW2CONDITIONAL;
174-
desc_HAL.dpcTriCaps.dwTextureCaps &= ~D3DPTEXTURECAPS_PERSPECTIVE
175-
& ~D3DPTEXTURECAPS_POW2
176-
& ~D3DPTEXTURECAPS_NONPOW2CONDITIONAL;
177-
} else if (deviceGUID == IID_IDirect3DHALDevice) {
178-
desc_HEL.dcmColorModel = 0;
179-
desc_HEL.dwDevCaps &= ~D3DDEVCAPS_HWTRANSFORMANDLIGHT
180-
& ~D3DDEVCAPS_DRAWPRIMITIVES2
181-
& ~D3DDEVCAPS_DRAWPRIMITIVES2EX;
182-
} else {
183-
Logger::warn("D3D5Device::GetCaps: Unhandled device type");
184-
}
162+
D3DDEVICEDESC2 desc_HAL = GetD3D5BaseCaps(d3dOptions);
163+
ApplyD3D5DeviceCaps(&desc_HAL, deviceGUID, true);
164+
D3DDEVICEDESC2 desc_HEL = GetD3D5BaseCaps(d3dOptions);
165+
ApplyD3D5DeviceCaps(&desc_HEL, deviceGUID, false);
185166

186167
memcpy(hal_desc, &desc_HAL, hal_desc->dwSize);
187168
memcpy(hel_desc, &desc_HEL, hel_desc->dwSize);

‎src/ddraw/d3d5/d3d5_device.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,6 @@ namespace dxvk {
162162

163163
D3DMultithread m_multithread;
164164

165-
D3DDEVICEDESC2 m_desc;
166-
167165
Com<DDrawSurface> m_rt;
168166
Com<DDrawSurface, false> m_ds;
169167

0 commit comments

Comments
 (0)