Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/d3d9/d3d9_bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ namespace dxvk {
}

HRESULT DxvkD3D8Bridge::SetColorKeyState(bool colorKeyState) {
return m_device->SetColorKeyState(colorKeyState);
return D3D_OK; //m_device->SetColorKeyState(colorKeyState);
}

HRESULT DxvkD3D8Bridge::SetColorKey(DWORD colorKeyLow, DWORD colorKeyHigh) {
return m_device->SetColorKey(colorKeyLow, colorKeyHigh);
return D3D_OK; //m_device->SetColorKey(colorKeyLow, colorKeyHigh);
}

HRESULT DxvkD3D8Bridge::SetLegacyLightsState(bool legacyLightsState, bool isD3DLight2) {
Expand Down
3 changes: 3 additions & 0 deletions src/d3d9/d3d9_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6895,6 +6895,9 @@ namespace dxvk {
key.Data.Contents.SpecularSource = m_state.renderStates[D3DRS_SPECULARMATERIALSOURCE] & mask;
key.Data.Contents.EmissiveSource = m_state.renderStates[D3DRS_EMISSIVEMATERIALSOURCE] & mask;

key.Data.Contents.UseLegacyLights = m_useLegacyLights;
key.Data.Contents.IsD3DLight2 = m_isD3DLight2;

uint32_t lightCount = 0;

if (key.Data.Contents.UseLighting) {
Expand Down
17 changes: 1 addition & 16 deletions src/d3d9/d3d9_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -928,12 +928,6 @@ namespace dxvk {
const D3D9ConstantLayout& GetPixelConstantLayout() { return m_psLayout; }

HRESULT ResetState(D3DPRESENT_PARAMETERS* pPresentationParameters);
HRESULT SetColorKeyState(bool colorKeyState) {
if (likely(m_colorKeyEnabled != colorKeyState)) {
m_colorKeyEnabled = colorKeyState;
}
return D3D_OK;
}

HRESULT SetLegacyLightsState(bool legacyLightState, bool isD3DLight2) {
if (likely(m_useLegacyLights != legacyLightState)) {
Expand All @@ -943,14 +937,6 @@ namespace dxvk {
return D3D_OK;
}

HRESULT SetColorKey(DWORD colorKeyLow, DWORD colorKeyHigh) {
if (likely(m_state.colorKeyLow != colorKeyLow || m_state.colorKeyHigh != colorKeyHigh)) {
m_state.colorKeyLow = colorKeyLow;
m_state.colorKeyHigh = colorKeyHigh;
}
return D3D_OK;
}

HRESULT ResetSwapChain(D3DPRESENT_PARAMETERS* pPresentationParameters, D3DDISPLAYMODEEX* pFullscreenDisplayMode);

HRESULT InitialReset(D3DPRESENT_PARAMETERS* pPresentationParameters, D3DDISPLAYMODEEX* pFullscreenDisplayMode);
Expand Down Expand Up @@ -1318,11 +1304,10 @@ namespace dxvk {
bool m_isD3D6Compatible;
bool m_isD3D7Compatible;

// D3D7 and earlier color key transparency state
bool m_colorKeyEnabled = false;
// D3D6 and earlier legacy light model state
bool m_useLegacyLights = false;
bool m_isD3DLight2 = false;

bool m_isD3D8Compatible;
bool m_amdATOC = false;
bool m_nvATOC = false;
Expand Down
15 changes: 13 additions & 2 deletions src/d3d9/d3d9_fixed_function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1082,16 +1082,25 @@ namespace dxvk {

uint32_t delta = m_module.opFSub(m_vec3Type, position, vtx3);
uint32_t d = m_module.opLength(m_floatType, delta);
if (m_vsKey.Data.Contents.UseLegacyLights && m_vsKey.Data.Contents.IsD3DLight2) {
d = m_module.opFSub(m_floatType, range, d);
d = m_module.opFDiv(m_floatType, d, range);
}
uint32_t hitDir = m_module.opFNegate(m_vec3Type, direction);
hitDir = m_module.opSelect(m_vec3Type, isDirectional3, hitDir, delta);
hitDir = m_module.opNormalize(m_vec3Type, hitDir);

uint32_t atten = m_module.opFFma (m_floatType, d, atten2, atten1);
atten = m_module.opFFma (m_floatType, d, atten, atten0);
atten = m_module.opFDiv (m_floatType, m_module.constf32(1.0f), atten);
if (m_vsKey.Data.Contents.UseLegacyLights)
atten = m_module.opFDiv (m_floatType, m_module.constf32(1.0f), atten);
atten = m_module.opNMin (m_floatType, atten, m_module.constf32(FLT_MAX));

atten = m_module.opSelect(m_floatType, m_module.opFOrdGreaterThan(bool_t, d, range), m_module.constf32(0.0f), atten);
if (m_vsKey.Data.Contents.UseLegacyLights && m_vsKey.Data.Contents.IsD3DLight2)
atten = m_module.opSelect(m_floatType, m_module.opFOrdLessThan(bool_t, d, m_module.constf32(0.0f)), m_module.constf32(0.0f), atten);
else
atten = m_module.opSelect(m_floatType, m_module.opFOrdGreaterThan(bool_t, d, range), m_module.constf32(0.0f), atten);

atten = m_module.opSelect(m_floatType, isDirectional, m_module.constf32(1.0f), atten);

// Spot Lighting
Expand Down Expand Up @@ -1130,6 +1139,8 @@ namespace dxvk {
uint32_t midDot = m_module.opDot(m_floatType, normal, mid);
midDot = m_module.opFClamp(m_floatType, midDot, m_module.constf32(0.0f), m_module.constf32(1.0f));
uint32_t doSpec = m_module.opFOrdGreaterThan(bool_t, midDot, m_module.constf32(0.0f));
if (m_vsKey.Data.Contents.UseLegacyLights)
doSpec = m_module.opLogicalAnd(bool_t, doSpec, m_module.opFOrdGreaterThan(bool_t, m_vs.constants.materialPower, m_module.constf32(0.0)));
uint32_t specularness = m_module.opPow(m_floatType, midDot, m_vs.constants.materialPower);
specularness = m_module.opFMul(m_floatType, specularness, atten);
specularness = m_module.opSelect(m_floatType, doSpec, specularness, m_module.constf32(0.0f));
Expand Down
3 changes: 3 additions & 0 deletions src/d3d9/d3d9_fixed_function.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,9 @@ namespace dxvk {

uint32_t LightCount : 4;

uint32_t UseLegacyLights : 1;
uint32_t IsD3DLight2 : 1;

uint32_t TexcoordDeclMask : 24;
uint32_t HasFog : 1;

Expand Down
2 changes: 0 additions & 2 deletions src/d3d9/d3d9_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@ namespace dxvk {
this->alphaTestWiggleRoom = config.getOption<bool> ("d3d9.alphaTestWiggleRoom", false);
this->cachedDynamicBuffers = config.getOption<bool> ("d3d9.cachedDynamicBuffers", false);
this->deviceLocalConstantBuffers = config.getOption<bool> ("d3d9.deviceLocalConstantBuffers", false);
// D3D7/6/5/DDraw options
this->colorKeyCompatibility = config.getOption<bool> ("ddraw.colorKeyCompatibility", false);

this->allowDirectBufferMapping = config.getOption<bool> ("d3d9.allowDirectBufferMapping", true);
this->seamlessCubes = config.getOption<bool> ("d3d9.seamlessCubes", false);
Expand Down
5 changes: 0 additions & 5 deletions src/d3d9/d3d9_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@ namespace dxvk {
/// for rendering hazards
bool generalHazards;

/// Color key compatibility mode for DDraw
///
/// Circumvents the texelFetch color key shader path.
bool colorKeyCompatibility;

/// Anisotropic filter override
///
/// Enforces anisotropic filtering with the
Expand Down
3 changes: 0 additions & 3 deletions src/d3d9/d3d9_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,9 +229,6 @@ namespace dxvk {

float nPatchSegments = 0.0f;

DWORD colorKeyLow = 0;
DWORD colorKeyHigh = 0;

bool IsLightEnabled(DWORD Index) {
const auto& indices = enabledLightIndices;
return std::find(indices.begin(), indices.end(), Index) != indices.end();
Expand Down
Loading
Loading