1
0
mirror of https://github.com/EduApps-CDG/OpenDX synced 2024-12-30 09:45:37 +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>(); UploadConstants<DxsoProgramTypes::PixelShader>();
if (GetCommonShader(m_state.pixelShader)->GetInfo().majorVersion() >= 2) if (GetCommonShader(m_state.pixelShader)->GetInfo().majorVersion() >= 2)
UpdateSamplerTypes(0u, 0u); UpdateSamplerTypes(m_d3d9Options.forceSamplerTypeSpecConstants ? m_samplerTypeBitfield : 0u, 0u);
else else
UpdateSamplerTypes(m_samplerTypeBitfield, m_projectionBitfield); // For implicit samplers... 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->memoryTrackTest = config.getOption<bool> ("d3d9.memoryTrackTest", false);
this->supportVCache = config.getOption<bool> ("d3d9.supportVCache", vendorId == 0x10de); this->supportVCache = config.getOption<bool> ("d3d9.supportVCache", vendorId == 0x10de);
this->enableDialogMode = config.getOption<bool> ("d3d9.enableDialogMode", false); this->enableDialogMode = config.getOption<bool> ("d3d9.enableDialogMode", false);
this->forceSamplerTypeSpecConstants = config.getOption<bool> ("d3d9.forceSamplerTypeSpecConstants", false);
this->forceAspectRatio = config.getOption<std::string>("d3d9.forceAspectRatio", ""); this->forceAspectRatio = config.getOption<std::string>("d3d9.forceAspectRatio", "");

View File

@ -112,6 +112,10 @@ namespace dxvk {
/// Enable dialog mode (ie. no exclusive fullscreen) /// Enable dialog mode (ie. no exclusive fullscreen)
bool enableDialogMode; 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_ps.functionId = m_module.allocateId();
m_module.setDebugName(m_ps.functionId, "ps_main"); 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_ps.samplerTypeSpec = m_module.specConst32(m_module.defIntType(32, 0), 0);
m_module.decorateSpecId(m_ps.samplerTypeSpec, getSpecId(D3D9SpecConstantId::SamplerType)); m_module.decorateSpecId(m_ps.samplerTypeSpec, getSpecId(D3D9SpecConstantId::SamplerType));
m_module.setDebugName(m_ps.samplerTypeSpec, "s_sampler_types"); m_module.setDebugName(m_ps.samplerTypeSpec, "s_sampler_types");
m_ps.projectionSpec = m_module.specConst32(m_module.defIntType(32, 0), 0); if (m_programInfo.majorVersion() < 2) {
m_module.decorateSpecId(m_ps.projectionSpec, getSpecId(D3D9SpecConstantId::ProjectionType)); m_ps.projectionSpec = m_module.specConst32(m_module.defIntType(32, 0), 0);
m_module.setDebugName(m_ps.projectionSpec, "s_projections"); m_module.decorateSpecId(m_ps.projectionSpec, getSpecId(D3D9SpecConstantId::ProjectionType));
m_module.setDebugName(m_ps.projectionSpec, "s_projections");
}
} }
this->setupRenderStateInfo(); this->setupRenderStateInfo();
@ -723,7 +725,7 @@ namespace dxvk {
m_resourceSlots.push_back(resource); m_resourceSlots.push_back(resource);
}; };
if (m_programInfo.majorVersion() >= 2) { if (m_programInfo.majorVersion() >= 2 && !m_moduleInfo.options.forceSamplerTypeSpecConstants) {
DxsoSamplerType samplerType = DxsoSamplerType samplerType =
SamplerTypeFromTextureType(type); SamplerTypeFromTextureType(type);
@ -2772,7 +2774,7 @@ void DxsoCompiler::emitControlFlowGenericLoop(
SampleImage(texcoordVar, sampler.color[samplerType], false, samplerType); SampleImage(texcoordVar, sampler.color[samplerType], false, samplerType);
}; };
if (m_programInfo.majorVersion() >= 2) { if (m_programInfo.majorVersion() >= 2 && !m_moduleInfo.options.forceSamplerTypeSpecConstants) {
DxsoSamplerType samplerType = DxsoSamplerType samplerType =
SamplerTypeFromTextureType(sampler.type); SamplerTypeFromTextureType(sampler.type);

View File

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

View File

@ -37,6 +37,10 @@ namespace dxvk {
/// Work around a NV driver quirk /// Work around a NV driver quirk
/// Fixes flickering/z-fighting in some games. /// Fixes flickering/z-fighting in some games.
bool invariantPosition; 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;
}; };
} }