diff --git a/source/d3d8to9.hpp b/source/d3d8to9.hpp index 29ffe0a..b0fb76b 100644 --- a/source/d3d8to9.hpp +++ b/source/d3d8to9.hpp @@ -53,7 +53,7 @@ class Direct3DDevice8 : public IDirect3DDevice8 Direct3DDevice8 &operator=(const Direct3DDevice8 &) = delete; public: - Direct3DDevice8(Direct3D8 *d3d, IDirect3DDevice9 *ProxyInterface, BOOL EnableZBufferDiscarding = FALSE); + Direct3DDevice8(Direct3D8 *d3d, IDirect3DDevice9 *ProxyInterface, DWORD BehaviorFlags, BOOL EnableZBufferDiscarding = FALSE); ~Direct3DDevice8(); IDirect3DDevice9 *GetProxyInterface() const { return ProxyInterface; } @@ -171,6 +171,7 @@ class Direct3DDevice8 : public IDirect3DDevice8 IDirect3DSurface9 *pCurrentRenderTarget = nullptr; bool PaletteFlag = false; bool IsRecordingState = false; + bool IsMixedVPModeDevice = false; static constexpr size_t MAX_CLIP_PLANES = 6; float StoredClipPlanes[MAX_CLIP_PLANES][4] = {}; diff --git a/source/d3d8to9_base.cpp b/source/d3d8to9_base.cpp index 5aca4af..ccb1875 100644 --- a/source/d3d8to9_base.cpp +++ b/source/d3d8to9_base.cpp @@ -201,7 +201,7 @@ HRESULT STDMETHODCALLTYPE Direct3D8::CreateDevice(UINT Adapter, D3DDEVTYPE Devic if (FAILED(hr)) return hr; - *ppReturnedDeviceInterface = new Direct3DDevice8(this, DeviceInterface, (PresentParams.Flags & D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL) != 0); + *ppReturnedDeviceInterface = new Direct3DDevice8(this, DeviceInterface, BehaviorFlags, (PresentParams.Flags & D3DPRESENTFLAG_DISCARD_DEPTHSTENCIL) != 0); // Set default vertex declaration DeviceInterface->SetFVF(D3DFVF_XYZ); diff --git a/source/d3d8to9_device.cpp b/source/d3d8to9_device.cpp index 959e557..441fbf1 100644 --- a/source/d3d8to9_device.cpp +++ b/source/d3d8to9_device.cpp @@ -14,12 +14,13 @@ struct VertexShaderInfo IDirect3DVertexDeclaration9 *Declaration = nullptr; }; -Direct3DDevice8::Direct3DDevice8(Direct3D8 *d3d, IDirect3DDevice9 *ProxyInterface, BOOL EnableZBufferDiscarding) : +Direct3DDevice8::Direct3DDevice8(Direct3D8 *d3d, IDirect3DDevice9 *ProxyInterface, DWORD BehaviorFlags, BOOL EnableZBufferDiscarding) : D3D(d3d), ProxyInterface(ProxyInterface), ZBufferDiscarding(EnableZBufferDiscarding) { ProxyAddressLookupTable = new AddressLookupTable(this); PaletteFlag = SupportsPalettes(); + IsMixedVPModeDevice = BehaviorFlags & D3DCREATE_MIXED_VERTEXPROCESSING; // The default value of D3DRS_POINTSIZE_MIN is 0.0f in D3D8, // whereas in D3D9 it is 1.0f, so adjust it as needed ProxyInterface->SetRenderState(D3DRS_POINTSIZE_MIN, (DWORD) 0.0f); @@ -772,7 +773,12 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::SetRenderState(D3DRENDERSTATETYPE Sta case D3DRS_ZVISIBLE: case D3DRS_PATCHSEGMENTS: case D3DRS_LINEPATTERN: + return D3D_OK; case D3DRS_SOFTWAREVERTEXPROCESSING: + // SWVP can be modified by this render state only on devices + // created with the D3DCREATE_MIXED_VERTEXPROCESSING flag + if (IsMixedVPModeDevice) + return ProxyInterface->SetSoftwareVertexProcessing(static_cast(Value)); return D3D_OK; case D3DRS_EDGEANTIALIAS: return ProxyInterface->SetRenderState(D3DRS_ANTIALIASEDLINEENABLE, Value); @@ -810,7 +816,7 @@ HRESULT STDMETHODCALLTYPE Direct3DDevice8::GetRenderState(D3DRENDERSTATETYPE Sta *pValue = static_cast(*reinterpret_cast(pValue) * -200000.0f); return hr; case D3DRS_SOFTWAREVERTEXPROCESSING: - *pValue = ProxyInterface->GetSoftwareVertexProcessing(); + *pValue = static_cast(ProxyInterface->GetSoftwareVertexProcessing()); return D3D_OK; case D3DRS_PATCHSEGMENTS: *pValue = 1;