mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-03-06 20:58:37 +01:00
[d3d8/9] Enforce SM1 when in D3D8 compatibility mode
This commit is contained in:
parent
896afe47c3
commit
110257b119
10 changed files with 51 additions and 70 deletions
|
@ -493,7 +493,8 @@
|
|||
# Reported shader model
|
||||
#
|
||||
# The shader model to state that we support in the device
|
||||
# capabilities that the applicatation queries.
|
||||
# capabilities that the application queries. Note that
|
||||
# the value will be limited to 1 for D3D8 applications.
|
||||
#
|
||||
# Supported values:
|
||||
# - 0: Fixed-function only
|
||||
|
|
|
@ -1815,17 +1815,6 @@ namespace dxvk {
|
|||
if (unlikely(pDeclaration == nullptr || pHandle == nullptr))
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
||||
// Validate VS version for non-FF shaders
|
||||
if (pFunction != nullptr) {
|
||||
const uint32_t majorVersion = D3DSHADER_VERSION_MAJOR(pFunction[0]);
|
||||
const uint32_t minorVersion = D3DSHADER_VERSION_MINOR(pFunction[0]);
|
||||
|
||||
if (unlikely(majorVersion != 1 || minorVersion > 1)) {
|
||||
Logger::err(str::format("D3D8Device::CreateVertexShader: Unsupported VS version ", majorVersion, ".", minorVersion));
|
||||
return D3DERR_INVALIDCALL;
|
||||
}
|
||||
}
|
||||
|
||||
D3D9VertexShaderCode translatedVS;
|
||||
HRESULT res = TranslateVertexShader8(pDeclaration, pFunction, m_d3d8Options, &translatedVS);
|
||||
if (unlikely(FAILED(res)))
|
||||
|
@ -2064,14 +2053,6 @@ namespace dxvk {
|
|||
if (unlikely(pFunction == nullptr || pHandle == nullptr))
|
||||
return D3DERR_INVALIDCALL;
|
||||
|
||||
const uint32_t majorVersion = D3DSHADER_VERSION_MAJOR(pFunction[0]);
|
||||
const uint32_t minorVersion = D3DSHADER_VERSION_MINOR(pFunction[0]);
|
||||
|
||||
if (unlikely(m_isFixedFunctionOnly || majorVersion != 1 || minorVersion > 4)) {
|
||||
Logger::err(str::format("D3D8Device::CreatePixelShader: Unsupported PS version ", majorVersion, ".", minorVersion));
|
||||
return D3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
Com<d3d9::IDirect3DPixelShader9> pPixelShader;
|
||||
HRESULT res = GetD3D9()->CreatePixelShader(pFunction, &pPixelShader);
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace dxvk {
|
|||
throw DxvkError("D3D8Interface: ERROR! Failed to get D3D9 Bridge. d3d9.dll might not be DXVK!");
|
||||
}
|
||||
|
||||
m_bridge->SetD3D8CompatibilityMode(true);
|
||||
m_bridge->EnableD3D8CompatibilityMode();
|
||||
|
||||
m_d3d8Options = D3D8Options(*m_bridge->GetConfig());
|
||||
|
||||
|
|
|
@ -297,6 +297,7 @@ namespace dxvk {
|
|||
|
||||
auto& options = m_parent->GetOptions();
|
||||
|
||||
const uint32_t maxShaderModel = m_parent->IsD3D8Compatible() ? std::min(1u, options.shaderModel) : options.shaderModel;
|
||||
const VkPhysicalDeviceLimits& limits = m_adapter->deviceProperties().limits;
|
||||
|
||||
// TODO: Actually care about what the adapter supports here.
|
||||
|
@ -575,8 +576,8 @@ namespace dxvk {
|
|||
|
||||
// Late fixed-function capable cards, such as the GeForce 4 MX series,
|
||||
// expose support for VS 1.1, while not advertising any PS support
|
||||
const uint32_t majorVersionVS = options.shaderModel == 0 ? 1 : options.shaderModel;
|
||||
const uint32_t majorVersionPS = options.shaderModel;
|
||||
const uint32_t majorVersionVS = maxShaderModel == 0 ? 1 : maxShaderModel;
|
||||
const uint32_t majorVersionPS = maxShaderModel;
|
||||
// Max supported SM1 is VS 1.1 and PS 1.4
|
||||
const uint32_t minorVersionVS = majorVersionVS != 1 ? 0 : 1;
|
||||
const uint32_t minorVersionPS = majorVersionPS != 1 ? 0 : 4;
|
||||
|
@ -588,7 +589,7 @@ namespace dxvk {
|
|||
// Max Vertex Shader Const
|
||||
pCaps->MaxVertexShaderConst = MaxFloatConstantsVS;
|
||||
// Max PS1 Value
|
||||
pCaps->PixelShader1xMaxValue = options.shaderModel > 0 ? std::numeric_limits<float>::max() : 0.0f;
|
||||
pCaps->PixelShader1xMaxValue = maxShaderModel > 0 ? std::numeric_limits<float>::max() : 0.0f;
|
||||
// Dev Caps 2
|
||||
pCaps->DevCaps2 = D3DDEVCAPS2_STREAMOFFSET
|
||||
/* | D3DDEVCAPS2_DMAPNPATCH */
|
||||
|
@ -635,41 +636,41 @@ namespace dxvk {
|
|||
/* | D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD */
|
||||
/* | D3DPTFILTERCAPS_MAGFGAUSSIANQUAD */;
|
||||
|
||||
pCaps->VS20Caps.Caps = options.shaderModel >= 2 ? D3DVS20CAPS_PREDICATION : 0;
|
||||
pCaps->VS20Caps.DynamicFlowControlDepth = options.shaderModel >= 2 ? D3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH : 0;
|
||||
pCaps->VS20Caps.NumTemps = options.shaderModel >= 2 ? D3DVS20_MAX_NUMTEMPS : 0;
|
||||
pCaps->VS20Caps.StaticFlowControlDepth = options.shaderModel >= 2 ? D3DVS20_MAX_STATICFLOWCONTROLDEPTH : 0;
|
||||
pCaps->VS20Caps.Caps = maxShaderModel >= 2 ? D3DVS20CAPS_PREDICATION : 0;
|
||||
pCaps->VS20Caps.DynamicFlowControlDepth = maxShaderModel >= 2 ? D3DVS20_MAX_DYNAMICFLOWCONTROLDEPTH : 0;
|
||||
pCaps->VS20Caps.NumTemps = maxShaderModel >= 2 ? D3DVS20_MAX_NUMTEMPS : 0;
|
||||
pCaps->VS20Caps.StaticFlowControlDepth = maxShaderModel >= 2 ? D3DVS20_MAX_STATICFLOWCONTROLDEPTH : 0;
|
||||
|
||||
pCaps->PS20Caps.Caps = options.shaderModel >= 2 ? D3DPS20CAPS_ARBITRARYSWIZZLE
|
||||
| D3DPS20CAPS_GRADIENTINSTRUCTIONS
|
||||
| D3DPS20CAPS_PREDICATION
|
||||
| D3DPS20CAPS_NODEPENDENTREADLIMIT
|
||||
| D3DPS20CAPS_NOTEXINSTRUCTIONLIMIT : 0;
|
||||
pCaps->PS20Caps.DynamicFlowControlDepth = options.shaderModel >= 2 ? D3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH : 0;
|
||||
pCaps->PS20Caps.NumTemps = options.shaderModel >= 2 ? D3DPS20_MAX_NUMTEMPS : 0;
|
||||
pCaps->PS20Caps.StaticFlowControlDepth = options.shaderModel >= 2 ? D3DPS20_MAX_STATICFLOWCONTROLDEPTH : 0;
|
||||
pCaps->PS20Caps.NumInstructionSlots = options.shaderModel >= 2 ? D3DPS20_MAX_NUMINSTRUCTIONSLOTS : 0;
|
||||
pCaps->PS20Caps.Caps = maxShaderModel >= 2 ? D3DPS20CAPS_ARBITRARYSWIZZLE
|
||||
| D3DPS20CAPS_GRADIENTINSTRUCTIONS
|
||||
| D3DPS20CAPS_PREDICATION
|
||||
| D3DPS20CAPS_NODEPENDENTREADLIMIT
|
||||
| D3DPS20CAPS_NOTEXINSTRUCTIONLIMIT : 0;
|
||||
pCaps->PS20Caps.DynamicFlowControlDepth = maxShaderModel >= 2 ? D3DPS20_MAX_DYNAMICFLOWCONTROLDEPTH : 0;
|
||||
pCaps->PS20Caps.NumTemps = maxShaderModel >= 2 ? D3DPS20_MAX_NUMTEMPS : 0;
|
||||
pCaps->PS20Caps.StaticFlowControlDepth = maxShaderModel >= 2 ? D3DPS20_MAX_STATICFLOWCONTROLDEPTH : 0;
|
||||
pCaps->PS20Caps.NumInstructionSlots = maxShaderModel >= 2 ? D3DPS20_MAX_NUMINSTRUCTIONSLOTS : 0;
|
||||
|
||||
// Vertex texture samplers are only available as part of SM3, the caps are 0 otherwise.
|
||||
pCaps->VertexTextureFilterCaps = options.shaderModel == 3 ? D3DPTFILTERCAPS_MINFPOINT
|
||||
| D3DPTFILTERCAPS_MINFLINEAR
|
||||
/* | D3DPTFILTERCAPS_MINFANISOTROPIC */
|
||||
/* | D3DPTFILTERCAPS_MINFPYRAMIDALQUAD */
|
||||
/* | D3DPTFILTERCAPS_MINFGAUSSIANQUAD */
|
||||
/* | D3DPTFILTERCAPS_MIPFPOINT */
|
||||
/* | D3DPTFILTERCAPS_MIPFLINEAR */
|
||||
/* | D3DPTFILTERCAPS_CONVOLUTIONMONO */
|
||||
| D3DPTFILTERCAPS_MAGFPOINT
|
||||
| D3DPTFILTERCAPS_MAGFLINEAR
|
||||
/* | D3DPTFILTERCAPS_MAGFANISOTROPIC */
|
||||
/* | D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD */
|
||||
/* | D3DPTFILTERCAPS_MAGFGAUSSIANQUAD */ : 0;
|
||||
pCaps->VertexTextureFilterCaps = maxShaderModel == 3 ? D3DPTFILTERCAPS_MINFPOINT
|
||||
| D3DPTFILTERCAPS_MINFLINEAR
|
||||
/* | D3DPTFILTERCAPS_MINFANISOTROPIC */
|
||||
/* | D3DPTFILTERCAPS_MINFPYRAMIDALQUAD */
|
||||
/* | D3DPTFILTERCAPS_MINFGAUSSIANQUAD */
|
||||
/* | D3DPTFILTERCAPS_MIPFPOINT */
|
||||
/* | D3DPTFILTERCAPS_MIPFLINEAR */
|
||||
/* | D3DPTFILTERCAPS_CONVOLUTIONMONO */
|
||||
| D3DPTFILTERCAPS_MAGFPOINT
|
||||
| D3DPTFILTERCAPS_MAGFLINEAR
|
||||
/* | D3DPTFILTERCAPS_MAGFANISOTROPIC */
|
||||
/* | D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD */
|
||||
/* | D3DPTFILTERCAPS_MAGFGAUSSIANQUAD */ : 0;
|
||||
|
||||
pCaps->MaxVShaderInstructionsExecuted = options.shaderModel >= 2 ? 4294967295 : 0;
|
||||
pCaps->MaxPShaderInstructionsExecuted = options.shaderModel >= 2 ? 4294967295 : 0;
|
||||
pCaps->MaxVShaderInstructionsExecuted = maxShaderModel >= 2 ? 4294967295 : 0;
|
||||
pCaps->MaxPShaderInstructionsExecuted = maxShaderModel >= 2 ? 4294967295 : 0;
|
||||
|
||||
pCaps->MaxVertexShader30InstructionSlots = options.shaderModel == 3 ? 32768 : 0;
|
||||
pCaps->MaxPixelShader30InstructionSlots = options.shaderModel == 3 ? 32768 : 0;
|
||||
pCaps->MaxVertexShader30InstructionSlots = maxShaderModel == 3 ? 32768 : 0;
|
||||
pCaps->MaxPixelShader30InstructionSlots = maxShaderModel == 3 ? 32768 : 0;
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
|
|
|
@ -114,8 +114,8 @@ namespace dxvk {
|
|||
return m_interface->QueryInterface(riid, ppvObject);
|
||||
}
|
||||
|
||||
void DxvkD3D8InterfaceBridge::SetD3D8CompatibilityMode(const bool compatMode) {
|
||||
m_interface->SetD3D8CompatibilityMode(compatMode);
|
||||
void DxvkD3D8InterfaceBridge::EnableD3D8CompatibilityMode() {
|
||||
m_interface->EnableD3D8CompatibilityMode();
|
||||
}
|
||||
|
||||
const Config* DxvkD3D8InterfaceBridge::GetConfig() const {
|
||||
|
|
|
@ -42,11 +42,9 @@ IDxvkD3D8Bridge : public IUnknown {
|
|||
MIDL_INTERFACE("D3D9D3D8-A407-773E-18E9-CAFEBEEF3000")
|
||||
IDxvkD3D8InterfaceBridge : public IUnknown {
|
||||
/**
|
||||
* \brief Enables or disables D3D9-specific features and validations
|
||||
*
|
||||
* \param [in] compatMode Compatibility state
|
||||
* \brief Enforces D3D8-specific features and validations
|
||||
*/
|
||||
virtual void SetD3D8CompatibilityMode(const bool compatMode) = 0;
|
||||
virtual void EnableD3D8CompatibilityMode() = 0;
|
||||
|
||||
/**
|
||||
* \brief Retrieves the DXVK configuration
|
||||
|
@ -106,7 +104,7 @@ namespace dxvk {
|
|||
REFIID riid,
|
||||
void** ppvObject);
|
||||
|
||||
void SetD3D8CompatibilityMode(const bool compatMode);
|
||||
void EnableD3D8CompatibilityMode();
|
||||
|
||||
const Config* GetConfig() const;
|
||||
|
||||
|
|
|
@ -3329,7 +3329,7 @@ namespace dxvk {
|
|||
const uint32_t minorVersion = D3DSHADER_VERSION_MINOR(pFunction[0]);
|
||||
|
||||
// Late fixed-function capable hardware exposed support for VS 1.1
|
||||
const uint32_t shaderModelVS = m_d3d9Options.shaderModel == 0 ? 1 : m_d3d9Options.shaderModel;
|
||||
const uint32_t shaderModelVS = m_isD3D8Compatible ? 1u : std::max(1u, m_d3d9Options.shaderModel);
|
||||
|
||||
if (unlikely(majorVersion > shaderModelVS
|
||||
|| (majorVersion == 1 && minorVersion > 1)
|
||||
|
@ -3706,7 +3706,9 @@ namespace dxvk {
|
|||
const uint32_t majorVersion = D3DSHADER_VERSION_MAJOR(pFunction[0]);
|
||||
const uint32_t minorVersion = D3DSHADER_VERSION_MINOR(pFunction[0]);
|
||||
|
||||
if (unlikely(majorVersion > m_d3d9Options.shaderModel
|
||||
const uint32_t shaderModelPS = m_isD3D8Compatible ? std::min(1u, m_d3d9Options.shaderModel) : m_d3d9Options.shaderModel;
|
||||
|
||||
if (unlikely(majorVersion > shaderModelPS
|
||||
|| (majorVersion == 1 && minorVersion > 4)
|
||||
// Skip checking the SM2 minor version, as it has a 2_x mode apparently
|
||||
|| (majorVersion == 3 && minorVersion != 0))) {
|
||||
|
|
|
@ -137,11 +137,9 @@ namespace dxvk {
|
|||
return m_isD3D8Compatible;
|
||||
}
|
||||
|
||||
void SetD3D8CompatibilityMode(bool compatMode) {
|
||||
if (compatMode)
|
||||
Logger::info("The D3D9 interface is now operating in D3D8 compatibility mode.");
|
||||
|
||||
m_isD3D8Compatible = compatMode;
|
||||
void EnableD3D8CompatibilityMode() {
|
||||
m_isD3D8Compatible = true;
|
||||
Logger::info("The D3D9 interface is now operating in D3D8 compatibility mode.");
|
||||
}
|
||||
|
||||
Rc<DxvkInstance> GetInstance() { return m_instance; }
|
||||
|
|
|
@ -44,7 +44,7 @@ namespace dxvk {
|
|||
this->maxFrameLatency = config.getOption<int32_t> ("d3d9.maxFrameLatency", 0);
|
||||
this->maxFrameRate = config.getOption<int32_t> ("d3d9.maxFrameRate", 0);
|
||||
this->presentInterval = config.getOption<int32_t> ("d3d9.presentInterval", -1);
|
||||
this->shaderModel = config.getOption<int32_t> ("d3d9.shaderModel", 3);
|
||||
this->shaderModel = config.getOption<int32_t> ("d3d9.shaderModel", 3u);
|
||||
this->dpiAware = config.getOption<bool> ("d3d9.dpiAware", true);
|
||||
this->strictConstantCopies = config.getOption<bool> ("d3d9.strictConstantCopies", false);
|
||||
this->strictPow = config.getOption<bool> ("d3d9.strictPow", true);
|
||||
|
|
|
@ -703,7 +703,7 @@ namespace dxvk {
|
|||
{ "d3d9.maxFrameRate", "60" },
|
||||
}} },
|
||||
/* Escape from Tarkov launcher
|
||||
Same issue as Warhammer: RoR above */
|
||||
Work around partial presentation issues */
|
||||
{ R"(\\BsgLauncher\.exe$)", {{
|
||||
{ "d3d9.shaderModel", "1" },
|
||||
}} },
|
||||
|
|
Loading…
Add table
Reference in a new issue