1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2025-01-31 14:52:11 +01:00

[dxso] Implement d3d9.forceSamplerTypeSpecConstants

This option makes us always use a spec constant to determine sampler type (instead of just in PS 1.x)
which works around a game bug in Halo CE where it gives cube textures to 2d/volume samplers
This commit is contained in:
Joshua Ashton 2020-01-01 20:53:20 +00:00
parent 694d6c7f77
commit c024b89171
6 changed files with 20 additions and 7 deletions

View File

@ -5403,7 +5403,7 @@ namespace dxvk {
UploadConstants<DxsoProgramTypes::PixelShader>();
if (GetCommonShader(m_state.pixelShader)->GetInfo().majorVersion() >= 2)
UpdateSamplerTypes(0u, 0u);
UpdateSamplerTypes(m_d3d9Options.forceSamplerTypeSpecConstants ? m_samplerTypeBitfield : 0u, 0u);
else
UpdateSamplerTypes(m_samplerTypeBitfield, m_projectionBitfield); // For implicit samplers...
}

View File

@ -61,6 +61,7 @@ namespace dxvk {
this->memoryTrackTest = config.getOption<bool> ("d3d9.memoryTrackTest", false);
this->supportVCache = config.getOption<bool> ("d3d9.supportVCache", vendorId == 0x10de);
this->enableDialogMode = config.getOption<bool> ("d3d9.enableDialogMode", false);
this->forceSamplerTypeSpecConstants = config.getOption<bool> ("d3d9.forceSamplerTypeSpecConstants", false);
this->forceAspectRatio = config.getOption<std::string>("d3d9.forceAspectRatio", "");

View File

@ -112,6 +112,10 @@ namespace dxvk {
/// Enable dialog mode (ie. no exclusive fullscreen)
bool enableDialogMode;
/// Always use a spec constant to determine sampler type (instead of just in PS 1.x)
/// Works around a game bug in Halo CE where it gives cube textures to 2d/volume samplers
bool forceSamplerTypeSpecConstants;
};
}

View File

@ -438,14 +438,16 @@ namespace dxvk {
m_ps.functionId = m_module.allocateId();
m_module.setDebugName(m_ps.functionId, "ps_main");
if (m_programInfo.majorVersion() < 2) {
if (m_programInfo.majorVersion() < 2 || m_moduleInfo.options.forceSamplerTypeSpecConstants) {
m_ps.samplerTypeSpec = m_module.specConst32(m_module.defIntType(32, 0), 0);
m_module.decorateSpecId(m_ps.samplerTypeSpec, getSpecId(D3D9SpecConstantId::SamplerType));
m_module.setDebugName(m_ps.samplerTypeSpec, "s_sampler_types");
m_ps.projectionSpec = m_module.specConst32(m_module.defIntType(32, 0), 0);
m_module.decorateSpecId(m_ps.projectionSpec, getSpecId(D3D9SpecConstantId::ProjectionType));
m_module.setDebugName(m_ps.projectionSpec, "s_projections");
if (m_programInfo.majorVersion() < 2) {
m_ps.projectionSpec = m_module.specConst32(m_module.defIntType(32, 0), 0);
m_module.decorateSpecId(m_ps.projectionSpec, getSpecId(D3D9SpecConstantId::ProjectionType));
m_module.setDebugName(m_ps.projectionSpec, "s_projections");
}
}
this->setupRenderStateInfo();
@ -723,7 +725,7 @@ namespace dxvk {
m_resourceSlots.push_back(resource);
};
if (m_programInfo.majorVersion() >= 2) {
if (m_programInfo.majorVersion() >= 2 && !m_moduleInfo.options.forceSamplerTypeSpecConstants) {
DxsoSamplerType samplerType =
SamplerTypeFromTextureType(type);
@ -2772,7 +2774,7 @@ void DxsoCompiler::emitControlFlowGenericLoop(
SampleImage(texcoordVar, sampler.color[samplerType], false, samplerType);
};
if (m_programInfo.majorVersion() >= 2) {
if (m_programInfo.majorVersion() >= 2 && !m_moduleInfo.options.forceSamplerTypeSpecConstants) {
DxsoSamplerType samplerType =
SamplerTypeFromTextureType(sampler.type);

View File

@ -37,6 +37,8 @@ namespace dxvk {
shaderModel = options.shaderModel;
invariantPosition = options.invariantPosition;
forceSamplerTypeSpecConstants = options.forceSamplerTypeSpecConstants;
}
}

View File

@ -37,6 +37,10 @@ namespace dxvk {
/// Work around a NV driver quirk
/// Fixes flickering/z-fighting in some games.
bool invariantPosition;
/// Always use a spec constant to determine sampler type (instead of just in PS 1.x)
/// Works around a game bug in Halo CE where it gives cube textures to 2d/volume samplers
bool forceSamplerTypeSpecConstants;
};
}