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

[dxvk] Use new specialization constant code for graphics pipelines

This commit is contained in:
Philip Rebohle 2019-05-01 00:34:51 +02:00
parent c3f7dfd197
commit 5714f18d15
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99

View File

@ -184,22 +184,26 @@ namespace dxvk {
sampleCount = VkSampleCountFlagBits(state.rsSampleCount); sampleCount = VkSampleCountFlagBits(state.rsSampleCount);
// Set up some specialization constants // Set up some specialization constants
DxvkSpecConstantData specData = { }; DxvkSpecConstants specData;
specData.rasterizerSampleCount = uint32_t(sampleCount); specData.set(uint32_t(DxvkSpecConstantId::RasterizerSampleCount), sampleCount, VK_SAMPLE_COUNT_1_BIT);
specData.alphaTestEnable = state.xsAlphaCompareOp != VK_COMPARE_OP_ALWAYS; specData.set(uint32_t(DxvkSpecConstantId::AlphaTestEnable), state.xsAlphaCompareOp != VK_COMPARE_OP_ALWAYS, false);
specData.alphaCompareOp = state.xsAlphaCompareOp; specData.set(uint32_t(DxvkSpecConstantId::AlphaCompareOp), state.xsAlphaCompareOp, VK_COMPARE_OP_ALWAYS);
for (uint32_t i = 0; i < MaxNumActiveBindings; i++) for (uint32_t i = 0; i < m_layout->bindingCount(); i++)
specData.activeBindings[i] = state.bsBindingMask.isBound(i) ? VK_TRUE : VK_FALSE; specData.set(i, state.bsBindingMask.isBound(i), true);
VkSpecializationInfo specInfo; for (uint32_t i = 0; i < MaxNumRenderTargets; i++) {
specInfo.mapEntryCount = g_specConstantMap.mapEntryCount(); if ((m_fsOut & (1 << i)) != 0) {
specInfo.pMapEntries = g_specConstantMap.mapEntryData(); uint32_t specId = uint32_t(DxvkSpecConstantId::ColorComponentMappings) + 4 * i;
specInfo.dataSize = sizeof(specData); specData.set(specId + 0, util::getComponentIndex(state.omComponentMapping[i].r, 0), 0u);
specInfo.pData = &specData; specData.set(specId + 1, util::getComponentIndex(state.omComponentMapping[i].g, 1), 1u);
specData.set(specId + 2, util::getComponentIndex(state.omComponentMapping[i].b, 2), 2u);
specData.set(specId + 3, util::getComponentIndex(state.omComponentMapping[i].a, 3), 3u);
}
}
VkSpecializationInfo specInfo = specData.getSpecInfo();
std::vector<VkPipelineShaderStageCreateInfo> stages;
DxvkShaderModuleCreateInfo moduleInfo; DxvkShaderModuleCreateInfo moduleInfo;
moduleInfo.fsDualSrcBlend = state.omBlendAttachments[0].blendEnable && ( moduleInfo.fsDualSrcBlend = state.omBlendAttachments[0].blendEnable && (
util::isDualSourceBlendFactor(state.omBlendAttachments[0].srcColorBlendFactor) || util::isDualSourceBlendFactor(state.omBlendAttachments[0].srcColorBlendFactor) ||
@ -213,6 +217,7 @@ namespace dxvk {
auto tesm = createShaderModule(m_tes, moduleInfo); auto tesm = createShaderModule(m_tes, moduleInfo);
auto fsm = createShaderModule(m_fs, moduleInfo); auto fsm = createShaderModule(m_fs, moduleInfo);
std::vector<VkPipelineShaderStageCreateInfo> stages;
if (vsm) stages.push_back(vsm.stageInfo(&specInfo)); if (vsm) stages.push_back(vsm.stageInfo(&specInfo));
if (tcsm) stages.push_back(tcsm.stageInfo(&specInfo)); if (tcsm) stages.push_back(tcsm.stageInfo(&specInfo));
if (tesm) stages.push_back(tesm.stageInfo(&specInfo)); if (tesm) stages.push_back(tesm.stageInfo(&specInfo));
@ -230,11 +235,6 @@ namespace dxvk {
if ((m_fsOut & (1 << i)) == 0) if ((m_fsOut & (1 << i)) == 0)
omBlendAttachments[i].colorWriteMask = 0; omBlendAttachments[i].colorWriteMask = 0;
specData.outputMappings[4 * i + 0] = util::getComponentIndex(state.omComponentMapping[i].r, 0);
specData.outputMappings[4 * i + 1] = util::getComponentIndex(state.omComponentMapping[i].g, 1);
specData.outputMappings[4 * i + 2] = util::getComponentIndex(state.omComponentMapping[i].b, 2);
specData.outputMappings[4 * i + 3] = util::getComponentIndex(state.omComponentMapping[i].a, 3);
} }
// Generate per-instance attribute divisors // Generate per-instance attribute divisors