Skip to content

Commit

Permalink
[util] Add a config option for shader input count validations
Browse files Browse the repository at this point in the history
  • Loading branch information
WinterSnowfall committed Dec 21, 2024
1 parent f7f9d3c commit cfbe28b
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/d3d9/d3d9_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "d3d9_caps.h"
#include "d3d9_device.h"
#include "d3d9_bridge.h"
#include "d3d9_shader_validator.h"

#include "../util/util_singleton.h"

Expand Down Expand Up @@ -67,6 +68,8 @@ namespace dxvk {
SetProcessDPIAware();
}
#endif

D3D9ShaderValidator::SetValidateShaderInputCount(m_d3d9Options.validateShaderInputCount);
}


Expand Down
1 change: 1 addition & 0 deletions src/d3d9/d3d9_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ namespace dxvk {
this->clampNegativeLodBias = config.getOption<bool> ("d3d9.clampNegativeLodBias", false);
this->countLosableResources = config.getOption<bool> ("d3d9.countLosableResources", true);
this->reproducibleCommandStream = config.getOption<bool> ("d3d9.reproducibleCommandStream", false);
this->validateShaderInputCount = config.getOption<bool> ("d3d9.validateShaderInputCount", false);

// D3D8 options
this->drefScaling = config.getOption<int32_t> ("d3d8.scaleDref", 0);
Expand Down
3 changes: 3 additions & 0 deletions src/d3d9/d3d9_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ namespace dxvk {
/// can negatively affect performance.
bool reproducibleCommandStream;

// Validate shader input count for PS 3.0 in D3D9ShaderValidator
bool validateShaderInputCount;

/// Enable depth texcoord Z (Dref) scaling (D3D8 quirk)
int32_t drefScaling;
};
Expand Down
7 changes: 6 additions & 1 deletion src/d3d9/d3d9_shader_validator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ namespace dxvk {
}*/

// a maximum of 10 inputs are supported with PS 3.0 (validation required by The Void)
if (m_isPixelShader && m_majorVersion == 3) {
if (s_validateShaderInputCount && m_isPixelShader && m_majorVersion == 3) {
switch (instContext.instruction.opcode) {
case DxsoOpcode::Comment:
case DxsoOpcode::Def:
Expand Down Expand Up @@ -202,4 +202,9 @@ namespace dxvk {
return E_FAIL;
}


// s_validateShaderInputCount will be parsed and set appropriately based
// on config options whenever a D3D9InterfaceEx type object is created
bool D3D9ShaderValidator::s_validateShaderInputCount = false;

}
6 changes: 6 additions & 0 deletions src/d3d9/d3d9_shader_validator.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ namespace dxvk {

HRESULT STDMETHODCALLTYPE End();

static void SetValidateShaderInputCount (bool value) {
s_validateShaderInputCount = value;
}

private:

HRESULT ValidateHeader(const char* pFile, UINT Line, const DWORD* pdwInst, DWORD cdw);
Expand All @@ -89,6 +93,8 @@ namespace dxvk {
D3D9ShaderValidatorMessage MessageID,
const std::string& Message);

static bool s_validateShaderInputCount;

bool m_isPixelShader = false;
uint32_t m_majorVersion = 0;
uint32_t m_minorVersion = 0;
Expand Down
5 changes: 5 additions & 0 deletions src/util/config/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,11 @@ namespace dxvk {
{ R"(\\DS\.exe$)", {{
{ "d3d9.textureMemory", "0" },
}} },
/* The Void - Crashes in several locations *
* without shader input count validations */
{ R"(\\The Void\\bin\\win32\\Game\.exe$)", {{
{ "d3d9.validateShaderInputCount", "True" },
}} },

/**********************************************/
/* D3D8 GAMES */
Expand Down

0 comments on commit cfbe28b

Please sign in to comment.