Skip to content

Commit cd632f9

Browse files
[d3d7] Backport latest d7vk features
1 parent d0a0635 commit cd632f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+2177
-896
lines changed

src/d3d9/d3d9_bridge.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ namespace dxvk {
3939
}
4040

4141
HRESULT DxvkD3D8Bridge::SetColorKeyState(bool colorKeyState) {
42-
return m_device->SetColorKeyState(colorKeyState);
42+
return D3D_OK; //m_device->SetColorKeyState(colorKeyState);
4343
}
4444

4545
HRESULT DxvkD3D8Bridge::SetColorKey(DWORD colorKeyLow, DWORD colorKeyHigh) {
46-
return m_device->SetColorKey(colorKeyLow, colorKeyHigh);
46+
return D3D_OK; //m_device->SetColorKey(colorKeyLow, colorKeyHigh);
4747
}
4848

4949
HRESULT DxvkD3D8Bridge::SetLegacyLightsState(bool legacyLightsState, bool isD3DLight2) {

src/d3d9/d3d9_device.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6895,6 +6895,9 @@ namespace dxvk {
68956895
key.Data.Contents.SpecularSource = m_state.renderStates[D3DRS_SPECULARMATERIALSOURCE] & mask;
68966896
key.Data.Contents.EmissiveSource = m_state.renderStates[D3DRS_EMISSIVEMATERIALSOURCE] & mask;
68976897

6898+
key.Data.Contents.UseLegacyLights = m_useLegacyLights;
6899+
key.Data.Contents.IsD3DLight2 = m_isD3DLight2;
6900+
68986901
uint32_t lightCount = 0;
68996902

69006903
if (key.Data.Contents.UseLighting) {

src/d3d9/d3d9_device.h

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -928,12 +928,6 @@ namespace dxvk {
928928
const D3D9ConstantLayout& GetPixelConstantLayout() { return m_psLayout; }
929929

930930
HRESULT ResetState(D3DPRESENT_PARAMETERS* pPresentationParameters);
931-
HRESULT SetColorKeyState(bool colorKeyState) {
932-
if (likely(m_colorKeyEnabled != colorKeyState)) {
933-
m_colorKeyEnabled = colorKeyState;
934-
}
935-
return D3D_OK;
936-
}
937931

938932
HRESULT SetLegacyLightsState(bool legacyLightState, bool isD3DLight2) {
939933
if (likely(m_useLegacyLights != legacyLightState)) {
@@ -943,14 +937,6 @@ namespace dxvk {
943937
return D3D_OK;
944938
}
945939

946-
HRESULT SetColorKey(DWORD colorKeyLow, DWORD colorKeyHigh) {
947-
if (likely(m_state.colorKeyLow != colorKeyLow || m_state.colorKeyHigh != colorKeyHigh)) {
948-
m_state.colorKeyLow = colorKeyLow;
949-
m_state.colorKeyHigh = colorKeyHigh;
950-
}
951-
return D3D_OK;
952-
}
953-
954940
HRESULT ResetSwapChain(D3DPRESENT_PARAMETERS* pPresentationParameters, D3DDISPLAYMODEEX* pFullscreenDisplayMode);
955941

956942
HRESULT InitialReset(D3DPRESENT_PARAMETERS* pPresentationParameters, D3DDISPLAYMODEEX* pFullscreenDisplayMode);
@@ -1318,11 +1304,10 @@ namespace dxvk {
13181304
bool m_isD3D6Compatible;
13191305
bool m_isD3D7Compatible;
13201306

1321-
// D3D7 and earlier color key transparency state
1322-
bool m_colorKeyEnabled = false;
13231307
// D3D6 and earlier legacy light model state
13241308
bool m_useLegacyLights = false;
13251309
bool m_isD3DLight2 = false;
1310+
13261311
bool m_isD3D8Compatible;
13271312
bool m_amdATOC = false;
13281313
bool m_nvATOC = false;

src/d3d9/d3d9_fixed_function.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,16 +1082,25 @@ namespace dxvk {
10821082

10831083
uint32_t delta = m_module.opFSub(m_vec3Type, position, vtx3);
10841084
uint32_t d = m_module.opLength(m_floatType, delta);
1085+
if (m_vsKey.Data.Contents.UseLegacyLights && m_vsKey.Data.Contents.IsD3DLight2) {
1086+
d = m_module.opFSub(m_floatType, range, d);
1087+
d = m_module.opFDiv(m_floatType, d, range);
1088+
}
10851089
uint32_t hitDir = m_module.opFNegate(m_vec3Type, direction);
10861090
hitDir = m_module.opSelect(m_vec3Type, isDirectional3, hitDir, delta);
10871091
hitDir = m_module.opNormalize(m_vec3Type, hitDir);
10881092

10891093
uint32_t atten = m_module.opFFma (m_floatType, d, atten2, atten1);
10901094
atten = m_module.opFFma (m_floatType, d, atten, atten0);
1091-
atten = m_module.opFDiv (m_floatType, m_module.constf32(1.0f), atten);
1095+
if (m_vsKey.Data.Contents.UseLegacyLights)
1096+
atten = m_module.opFDiv (m_floatType, m_module.constf32(1.0f), atten);
10921097
atten = m_module.opNMin (m_floatType, atten, m_module.constf32(FLT_MAX));
10931098

1094-
atten = m_module.opSelect(m_floatType, m_module.opFOrdGreaterThan(bool_t, d, range), m_module.constf32(0.0f), atten);
1099+
if (m_vsKey.Data.Contents.UseLegacyLights && m_vsKey.Data.Contents.IsD3DLight2)
1100+
atten = m_module.opSelect(m_floatType, m_module.opFOrdLessThan(bool_t, d, m_module.constf32(0.0f)), m_module.constf32(0.0f), atten);
1101+
else
1102+
atten = m_module.opSelect(m_floatType, m_module.opFOrdGreaterThan(bool_t, d, range), m_module.constf32(0.0f), atten);
1103+
10951104
atten = m_module.opSelect(m_floatType, isDirectional, m_module.constf32(1.0f), atten);
10961105

10971106
// Spot Lighting
@@ -1130,6 +1139,8 @@ namespace dxvk {
11301139
uint32_t midDot = m_module.opDot(m_floatType, normal, mid);
11311140
midDot = m_module.opFClamp(m_floatType, midDot, m_module.constf32(0.0f), m_module.constf32(1.0f));
11321141
uint32_t doSpec = m_module.opFOrdGreaterThan(bool_t, midDot, m_module.constf32(0.0f));
1142+
if (m_vsKey.Data.Contents.UseLegacyLights)
1143+
doSpec = m_module.opLogicalAnd(bool_t, doSpec, m_module.opFOrdGreaterThan(bool_t, m_vs.constants.materialPower, m_module.constf32(0.0)));
11331144
uint32_t specularness = m_module.opPow(m_floatType, midDot, m_vs.constants.materialPower);
11341145
specularness = m_module.opFMul(m_floatType, specularness, atten);
11351146
specularness = m_module.opSelect(m_floatType, doSpec, specularness, m_module.constf32(0.0f));

src/d3d9/d3d9_fixed_function.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ namespace dxvk {
113113

114114
uint32_t LightCount : 4;
115115

116+
uint32_t UseLegacyLights : 1;
117+
uint32_t IsD3DLight2 : 1;
118+
116119
uint32_t TexcoordDeclMask : 24;
117120
uint32_t HasFog : 1;
118121

src/d3d9/d3d9_options.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ namespace dxvk {
7272
this->alphaTestWiggleRoom = config.getOption<bool> ("d3d9.alphaTestWiggleRoom", false);
7373
this->cachedDynamicBuffers = config.getOption<bool> ("d3d9.cachedDynamicBuffers", false);
7474
this->deviceLocalConstantBuffers = config.getOption<bool> ("d3d9.deviceLocalConstantBuffers", false);
75-
// D3D7/6/5/DDraw options
76-
this->colorKeyCompatibility = config.getOption<bool> ("ddraw.colorKeyCompatibility", false);
7775

7876
this->allowDirectBufferMapping = config.getOption<bool> ("d3d9.allowDirectBufferMapping", true);
7977
this->seamlessCubes = config.getOption<bool> ("d3d9.seamlessCubes", false);

src/d3d9/d3d9_options.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,6 @@ namespace dxvk {
7474
/// for rendering hazards
7575
bool generalHazards;
7676

77-
/// Color key compatibility mode for DDraw
78-
///
79-
/// Circumvents the texelFetch color key shader path.
80-
bool colorKeyCompatibility;
81-
8277
/// Anisotropic filter override
8378
///
8479
/// Enforces anisotropic filtering with the

src/d3d9/d3d9_state.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,6 @@ namespace dxvk {
229229

230230
float nPatchSegments = 0.0f;
231231

232-
DWORD colorKeyLow = 0;
233-
DWORD colorKeyHigh = 0;
234-
235232
bool IsLightEnabled(DWORD Index) {
236233
const auto& indices = enabledLightIndices;
237234
return std::find(indices.begin(), indices.end(), Index) != indices.end();

0 commit comments

Comments
 (0)