From 201d508626d56f702eff63ff425423239e330c1e Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Wed, 29 Jan 2020 17:22:38 +0000 Subject: [PATCH] [dxso] Handle writemask in TexKill op Turns out this actually applies to what is tested, despite docs saying otherwise and never ever seeing this before! Fixes some broken ENB shaders which I assume have some manual hand edits because I can't get FXC to generate this code at all. --- src/dxso/dxso_compiler.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/dxso/dxso_compiler.cpp b/src/dxso/dxso_compiler.cpp index 306e9a38..2a10a04b 100644 --- a/src/dxso/dxso_compiler.cpp +++ b/src/dxso/dxso_compiler.cpp @@ -2860,6 +2860,11 @@ void DxsoCompiler::emitControlFlowGenericLoop( texReg.id, texReg.id, texReg.type.ccount, indices.data()); } + else { + // The writemask actually applies and works here... + // (FXC doesn't generate this but it fixes broken ENB shaders) + texReg = emitRegisterSwizzle(texReg, IdentitySwizzle, ctx.dst.mask); + } const uint32_t boolVecTypeId = getVectorTypeId({ DxsoScalarType::Bool, texReg.type.ccount }); @@ -2868,7 +2873,8 @@ void DxsoCompiler::emitControlFlowGenericLoop( boolVecTypeId, texReg.id, m_module.constfReplicant(0.0f, texReg.type.ccount)); - result = m_module.opAny(m_module.defBoolType(), result); + if (texReg.type.ccount != 1) + result = m_module.opAny(m_module.defBoolType(), result); if (m_ps.killState == 0) { uint32_t labelIf = m_module.allocateId();