[dxvk] Remove remaining built-in specialization constants

This commit is contained in:
Philip Rebohle 2022-07-17 14:08:47 +02:00
parent 0f16a8f70d
commit f15466a2c5
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
7 changed files with 18 additions and 47 deletions

View File

@ -45,16 +45,16 @@ namespace dxvk {
if (!fogCtx.IsPixel) {
spvModule.setDebugName(fogMode, "vertex_fog_mode");
spvModule.decorateSpecId(fogMode, getSpecId(D3D9SpecConstantId::VertexFogMode));
spvModule.decorateSpecId(fogMode, D3D9SpecConstantId::VertexFogMode);
}
else {
spvModule.setDebugName(fogMode, "pixel_fog_mode");
spvModule.decorateSpecId(fogMode, getSpecId(D3D9SpecConstantId::PixelFogMode));
spvModule.decorateSpecId(fogMode, D3D9SpecConstantId::PixelFogMode);
}
uint32_t fogEnabled = spvModule.specConstBool(false);
spvModule.setDebugName(fogEnabled, "fog_enabled");
spvModule.decorateSpecId(fogEnabled, getSpecId(D3D9SpecConstantId::FogEnabled));
spvModule.decorateSpecId(fogEnabled, D3D9SpecConstantId::FogEnabled);
uint32_t doFog = spvModule.allocateId();
uint32_t skipFog = spvModule.allocateId();
@ -272,7 +272,7 @@ namespace dxvk {
if (isFixedFunction) {
uint32_t pointMode = spvModule.specConst32(uint32Type, 0);
spvModule.setDebugName(pointMode, "point_mode");
spvModule.decorateSpecId(pointMode, getSpecId(D3D9SpecConstantId::PointMode));
spvModule.decorateSpecId(pointMode, D3D9SpecConstantId::PointMode);
uint32_t scaleBit = spvModule.opBitFieldUExtract(uint32Type, pointMode, spvModule.consti32(0), spvModule.consti32(1));
uint32_t isScale = spvModule.opIEqual(boolType, scaleBit, spvModule.constu32(1));
@ -325,7 +325,7 @@ namespace dxvk {
uint32_t pointMode = spvModule.specConst32(uint32Type, 0);
spvModule.setDebugName(pointMode, "point_mode");
spvModule.decorateSpecId(pointMode, getSpecId(D3D9SpecConstantId::PointMode));
spvModule.decorateSpecId(pointMode, D3D9SpecConstantId::PointMode);
uint32_t spriteBit = spvModule.opBitFieldUExtract(uint32Type, pointMode, spvModule.consti32(1), spvModule.consti32(1));
uint32_t isSprite = spvModule.opIEqual(boolType, spriteBit, spvModule.constu32(1));
@ -2190,7 +2190,7 @@ namespace dxvk {
// Declare spec constants for render states
uint32_t alphaFuncId = m_module.specConst32(m_module.defIntType(32, 0), 0);
m_module.setDebugName(alphaFuncId, "alpha_func");
m_module.decorateSpecId(alphaFuncId, getSpecId(D3D9SpecConstantId::AlphaCompareOp));
m_module.decorateSpecId(alphaFuncId, D3D9SpecConstantId::AlphaCompareOp);
// Implement alpha test
auto oC0 = m_ps.out.COLOR;

View File

@ -270,11 +270,11 @@ namespace dxvk {
}
m_nullSpecConstant = m_module.specConst32(m_module.defIntType(32, 0), 0);
m_module.decorateSpecId(m_nullSpecConstant, getSpecId(D3D9SpecConstantId::SamplerNull));
m_module.decorateSpecId(m_nullSpecConstant, D3D9SpecConstantId::SamplerNull);
m_module.setDebugName(m_nullSpecConstant, "nullSamplers");
m_depthSpecConstant = m_module.specConst32(m_module.defIntType(32, 0), 0);
m_module.decorateSpecId(m_depthSpecConstant, getSpecId(D3D9SpecConstantId::SamplerDepthMode));
m_module.decorateSpecId(m_depthSpecConstant, D3D9SpecConstantId::SamplerDepthMode);
m_module.setDebugName(m_depthSpecConstant, "depthSamplers");
this->emitDclInputArray();
@ -339,10 +339,10 @@ namespace dxvk {
m_bindings.push_back(binding);
m_boolSpecConstant = m_module.specConst32(m_module.defIntType(32, 0), 0);
m_module.decorateSpecId(m_boolSpecConstant, getSpecId(
m_module.decorateSpecId(m_boolSpecConstant,
m_programInfo.type() == DxsoProgramType::VertexShader
? D3D9SpecConstantId::VertexShaderBools
: D3D9SpecConstantId::PixelShaderBools));
: D3D9SpecConstantId::PixelShaderBools);
m_module.setDebugName(m_boolSpecConstant, "boolConstants");
}
@ -534,18 +534,18 @@ namespace dxvk {
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.decorateSpecId(m_ps.samplerTypeSpec, D3D9SpecConstantId::SamplerType);
m_module.setDebugName(m_ps.samplerTypeSpec, "s_sampler_types");
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.decorateSpecId(m_ps.projectionSpec, D3D9SpecConstantId::ProjectionType);
m_module.setDebugName(m_ps.projectionSpec, "s_projections");
}
}
m_ps.fetch4Spec = m_module.specConst32(m_module.defIntType(32, 0), 0);
m_module.decorateSpecId(m_ps.fetch4Spec, getSpecId(D3D9SpecConstantId::Fetch4));
m_module.decorateSpecId(m_ps.fetch4Spec, D3D9SpecConstantId::Fetch4);
m_module.setDebugName(m_ps.fetch4Spec, "s_fetch4");
this->setupRenderStateInfo();
@ -3759,7 +3759,7 @@ void DxsoCompiler::emitControlFlowGenericLoop(
uint32_t alphaFuncId = m_module.specConst32(m_module.defIntType(32, 0), 0);
m_module.setDebugName (alphaFuncId, "alpha_func");
m_module.decorateSpecId (alphaFuncId, getSpecId(D3D9SpecConstantId::AlphaCompareOp));
m_module.decorateSpecId (alphaFuncId, D3D9SpecConstantId::AlphaCompareOp);
// Implement alpha test and fog
DxsoRegister color0;

View File

@ -109,7 +109,7 @@ namespace dxvk {
DxvkSpecConstants specData;
for (uint32_t i = 0; i < MaxNumSpecConstants; i++)
specData.set(getSpecId(i), state.sc.specConstants[i], 0u);
specData.set(i, state.sc.specConstants[i], 0u);
VkSpecializationInfo specInfo = specData.getSpecInfo();

View File

@ -1024,9 +1024,8 @@ namespace dxvk {
/**
* \brief Sets specialization constants
*
* Replaces current specialization constants with
* the given list of constant entries. The specId
* in the shader can be computed with \c getSpecId.
* Replaces current specialization constants
* with the given list of constant entries.
* \param [in] pipeline Graphics or Compute pipeline
* \param [in] index Constant index
* \param [in] value Constant value

View File

@ -805,7 +805,7 @@ namespace dxvk {
DxvkSpecConstants specData;
for (uint32_t i = 0; i < MaxNumSpecConstants; i++)
specData.set(getSpecId(i), state.sc.specConstants[i], 0u);
specData.set(i, state.sc.specConstants[i], 0u);
VkSpecializationInfo specInfo = specData.getSpecInfo();

View File

@ -18,21 +18,6 @@ namespace dxvk {
class DxvkPipelineManager;
struct DxvkPipelineStats;
/**
* \brief Built-in specialization constants
*
* These specialization constants allow the SPIR-V
* shaders to access some pipeline state like D3D
* shaders do. They need to be filled in by the
* implementation at pipeline compilation time.
*/
enum class DxvkSpecConstantId : uint32_t {
FirstPipelineConstant = 0,
/// Special constant ranges that do not count
/// towards the spec constant min/max values
ColorComponentMappings = DxvkLimits::MaxNumSpecConstants,
};
/**
* \brief Shader flags
*

View File

@ -74,18 +74,5 @@ namespace dxvk {
void setAsUint32(uint32_t specId, uint32_t value);
};
/**
* \brief Computes specialization constant ID
*
* Computest the specId to use within shaders
* for a given pipeline specialization constant.
* \param [in] index Spec constant index
* \returns Specialization constant ID
*/
inline uint32_t getSpecId(uint32_t index) {
return uint32_t(DxvkSpecConstantId::FirstPipelineConstant) + index;
}
}