1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-02 01:24:11 +01:00

[dxvk] Use only one spec constant for fragment shader output component mapping

Let's trust the driver to be able to constant-fold bitfieldExtract operations.
This commit is contained in:
Philip Rebohle 2021-01-29 16:17:07 +01:00
parent 307f43ff1e
commit 3a993d0c5c
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
3 changed files with 11 additions and 14 deletions

View File

@ -5904,16 +5904,15 @@ namespace dxvk {
uint32_t specTypeId = getScalarTypeId(DxbcScalarType::Uint32); uint32_t specTypeId = getScalarTypeId(DxbcScalarType::Uint32);
uint32_t compTypeId = getScalarTypeId(vector.type.ctype); uint32_t compTypeId = getScalarTypeId(vector.type.ctype);
uint32_t specId = m_module.specConst32(specTypeId, 0x3210);
m_module.decorateSpecId(specId, uint32_t(DxvkSpecConstantId::ColorComponentMappings) + i);
m_module.setDebugName(specId, str::format("omap", i).c_str());
std::array<uint32_t, 4> scalars; std::array<uint32_t, 4> scalars;
for (uint32_t c = 0; c < vector.type.ccount; c++) { for (uint32_t c = 0; c < vector.type.ccount; c++) {
const char* components = "rgba"; scalars[c] = m_module.opVectorExtractDynamic(compTypeId, vector.id,
m_module.opBitFieldUExtract(specTypeId, specId,
uint32_t specId = m_module.specConst32(specTypeId, c); m_module.constu32(4 * c), m_module.constu32(4)));
m_module.decorateSpecId(specId, uint32_t(DxvkSpecConstantId::ColorComponentMappings) + 4 * i + c);
m_module.setDebugName(specId, str::format("omap", i, ".", components[c]).c_str());
scalars[c] = m_module.opVectorExtractDynamic(compTypeId, vector.id, specId);
} }
uint32_t typeId = getVectorTypeId(vector.type); uint32_t typeId = getVectorTypeId(vector.type);

View File

@ -167,11 +167,9 @@ namespace dxvk {
for (uint32_t i = 0; i < MaxNumRenderTargets; i++) { for (uint32_t i = 0; i < MaxNumRenderTargets; i++) {
if ((m_fsOut & (1 << i)) != 0) { if ((m_fsOut & (1 << i)) != 0) {
uint32_t specId = uint32_t(DxvkSpecConstantId::ColorComponentMappings) + 4 * i; specData.set(uint32_t(DxvkSpecConstantId::ColorComponentMappings) + i,
specData.set(specId + 0, state.omSwizzle[i].rIndex(), 0u); state.omSwizzle[i].rIndex() << 0 | state.omSwizzle[i].gIndex() << 4 |
specData.set(specId + 1, state.omSwizzle[i].gIndex(), 1u); state.omSwizzle[i].bIndex() << 8 | state.omSwizzle[i].aIndex() << 12, 0x3210u);
specData.set(specId + 2, state.omSwizzle[i].bIndex(), 2u);
specData.set(specId + 3, state.omSwizzle[i].aIndex(), 3u);
} }
} }

View File

@ -29,7 +29,7 @@ namespace dxvk {
ColorComponentMappings = MaxNumResourceSlots, ColorComponentMappings = MaxNumResourceSlots,
// Specialization constants for pipeline state // Specialization constants for pipeline state
SpecConstantRangeStart = ColorComponentMappings + MaxNumRenderTargets * 4, SpecConstantRangeStart = ColorComponentMappings + MaxNumRenderTargets,
RasterizerSampleCount = SpecConstantRangeStart + 0, RasterizerSampleCount = SpecConstantRangeStart + 0,
FirstPipelineConstant FirstPipelineConstant
}; };