1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-18 20:52:10 +01:00

[d3d11] Added option to limit tessellation factors

d3d11.maxTessFactor accepts values ranging from 8 to 64, and limits
the maximum tessellation factor accordingly.
This commit is contained in:
Philip Rebohle 2018-09-09 23:14:00 +02:00
parent 2541aeb25c
commit f8dc5612f7
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
5 changed files with 41 additions and 2 deletions

View File

@ -612,6 +612,7 @@ namespace dxvk {
DxbcModuleInfo moduleInfo;
moduleInfo.options = m_dxbcOptions;
moduleInfo.tess = nullptr;
if (FAILED(this->CreateShaderModule(&module,
pShaderBytecode, BytecodeLength, pClassLinkage,
@ -636,6 +637,7 @@ namespace dxvk {
DxbcModuleInfo moduleInfo;
moduleInfo.options = m_dxbcOptions;
moduleInfo.tess = nullptr;
if (FAILED(this->CreateShaderModule(&module,
pShaderBytecode, BytecodeLength, pClassLinkage,
@ -679,6 +681,7 @@ namespace dxvk {
DxbcModuleInfo moduleInfo;
moduleInfo.options = m_dxbcOptions;
moduleInfo.tess = nullptr;
if (FAILED(this->CreateShaderModule(&module,
pShaderBytecode, BytecodeLength, pClassLinkage,
@ -701,8 +704,15 @@ namespace dxvk {
InitReturnPtr(ppHullShader);
D3D11CommonShader module;
DxbcTessInfo tessInfo;
tessInfo.maxTessFactor = float(m_d3d11Options.maxTessFactor);
DxbcModuleInfo moduleInfo;
moduleInfo.options = m_dxbcOptions;
moduleInfo.tess = nullptr;
if (tessInfo.maxTessFactor >= 8.0f)
moduleInfo.tess = &tessInfo;
if (FAILED(this->CreateShaderModule(&module,
pShaderBytecode, BytecodeLength, pClassLinkage,
@ -727,6 +737,7 @@ namespace dxvk {
DxbcModuleInfo moduleInfo;
moduleInfo.options = m_dxbcOptions;
moduleInfo.tess = nullptr;
if (FAILED(this->CreateShaderModule(&module,
pShaderBytecode, BytecodeLength, pClassLinkage,
@ -751,6 +762,7 @@ namespace dxvk {
DxbcModuleInfo moduleInfo;
moduleInfo.options = m_dxbcOptions;
moduleInfo.tess = nullptr;
if (FAILED(this->CreateShaderModule(&module,
pShaderBytecode, BytecodeLength, pClassLinkage,

View File

@ -7,6 +7,7 @@ namespace dxvk {
D3D11Options::D3D11Options(const Config& config) {
this->allowMapFlagNoWait = config.getOption<bool>("d3d11.allowMapFlagNoWait", false);
this->fakeStreamOutSupport = config.getOption<bool>("d3d11.fakeStreamOutSupport", false);
this->maxTessFactor = config.getOption<int32_t>("d3d11.maxTessFactor", 0);
}
}

View File

@ -23,6 +23,13 @@ namespace dxvk {
/// well enough without it. Will be removed once
/// Stream Output is properly supported in DXVK.
bool fakeStreamOutSupport;
/// Maximum tessellation factor.
///
/// Limits tessellation factors in tessellation
/// control shaders. Values from 8 to 64 are
/// supported, other values will be ignored.
int32_t maxTessFactor;
};
}

View File

@ -5631,10 +5631,17 @@ namespace dxvk {
= m_module.constu32(tessFactor.index);
// Apply global tess factor limit
float maxTessFactor = m_hs.maxTessFactor;
if (m_moduleInfo.tess != nullptr) {
if (m_moduleInfo.tess->maxTessFactor < maxTessFactor)
maxTessFactor = m_moduleInfo.tess->maxTessFactor;
}
DxbcRegisterValue tessValue = emitRegisterExtract(value, mask);
tessValue.id = m_module.opFClamp(getVectorTypeId(tessValue.type),
tessValue.id, m_module.constf32(0.0f),
m_module.constf32(m_hs.maxTessFactor));
m_module.constf32(maxTessFactor));
DxbcRegisterPointer ptr;
ptr.type.ctype = DxbcScalarType::Float32;

View File

@ -4,6 +4,17 @@
namespace dxvk {
/**
* \brief Tessellation info
*
* Stores the maximum tessellation factor
* to export from tessellation shaders.
*/
struct DxbcTessInfo {
float maxTessFactor;
};
/**
* \brief Shader module info
*
@ -11,7 +22,8 @@ namespace dxvk {
* This data can be supplied by the client API implementation.
*/
struct DxbcModuleInfo {
DxbcOptions options;
DxbcOptions options;
DxbcTessInfo* tess;
};
}