From 5714f18d1571f763dab7a2b3013e5e59ed348bb6 Mon Sep 17 00:00:00 2001 From: Philip Rebohle Date: Wed, 1 May 2019 00:34:51 +0200 Subject: [PATCH] [dxvk] Use new specialization constant code for graphics pipelines --- src/dxvk/dxvk_graphics.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/dxvk/dxvk_graphics.cpp b/src/dxvk/dxvk_graphics.cpp index ed45b6374..78dea7f18 100644 --- a/src/dxvk/dxvk_graphics.cpp +++ b/src/dxvk/dxvk_graphics.cpp @@ -184,22 +184,26 @@ namespace dxvk { sampleCount = VkSampleCountFlagBits(state.rsSampleCount); // Set up some specialization constants - DxvkSpecConstantData specData = { }; - specData.rasterizerSampleCount = uint32_t(sampleCount); - specData.alphaTestEnable = state.xsAlphaCompareOp != VK_COMPARE_OP_ALWAYS; - specData.alphaCompareOp = state.xsAlphaCompareOp; + DxvkSpecConstants specData; + specData.set(uint32_t(DxvkSpecConstantId::RasterizerSampleCount), sampleCount, VK_SAMPLE_COUNT_1_BIT); + specData.set(uint32_t(DxvkSpecConstantId::AlphaTestEnable), state.xsAlphaCompareOp != VK_COMPARE_OP_ALWAYS, false); + specData.set(uint32_t(DxvkSpecConstantId::AlphaCompareOp), state.xsAlphaCompareOp, VK_COMPARE_OP_ALWAYS); - for (uint32_t i = 0; i < MaxNumActiveBindings; i++) - specData.activeBindings[i] = state.bsBindingMask.isBound(i) ? VK_TRUE : VK_FALSE; + for (uint32_t i = 0; i < m_layout->bindingCount(); i++) + specData.set(i, state.bsBindingMask.isBound(i), true); - VkSpecializationInfo specInfo; - specInfo.mapEntryCount = g_specConstantMap.mapEntryCount(); - specInfo.pMapEntries = g_specConstantMap.mapEntryData(); - specInfo.dataSize = sizeof(specData); - specInfo.pData = &specData; + for (uint32_t i = 0; i < MaxNumRenderTargets; i++) { + if ((m_fsOut & (1 << i)) != 0) { + uint32_t specId = uint32_t(DxvkSpecConstantId::ColorComponentMappings) + 4 * i; + specData.set(specId + 0, util::getComponentIndex(state.omComponentMapping[i].r, 0), 0u); + 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 stages; - DxvkShaderModuleCreateInfo moduleInfo; moduleInfo.fsDualSrcBlend = state.omBlendAttachments[0].blendEnable && ( util::isDualSourceBlendFactor(state.omBlendAttachments[0].srcColorBlendFactor) || @@ -213,6 +217,7 @@ namespace dxvk { auto tesm = createShaderModule(m_tes, moduleInfo); auto fsm = createShaderModule(m_fs, moduleInfo); + std::vector stages; if (vsm) stages.push_back(vsm.stageInfo(&specInfo)); if (tcsm) stages.push_back(tcsm.stageInfo(&specInfo)); if (tesm) stages.push_back(tesm.stageInfo(&specInfo)); @@ -230,11 +235,6 @@ namespace dxvk { if ((m_fsOut & (1 << i)) == 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