<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Reviewed-by: Tim Rowley <<a href="mailto:timothy.o.rowley@intel.com" class="">timothy.o.rowley@intel.com</a>>
<div class=""><br class="">
<div>
<blockquote type="cite" class="">
<div class="">On Nov 7, 2016, at 6:18 PM, Ilia Mirkin <<a href="mailto:imirkin@alum.mit.edu" class="">imirkin@alum.mit.edu</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="">Most logic op usage is probably going to end up with normalized<br class="">
textures. Scale the floating point values and convert to integer before<br class="">
performing the logic operations.<br class="">
<br class="">
Signed-off-by: Ilia Mirkin <<a href="mailto:imirkin@alum.mit.edu" class="">imirkin@alum.mit.edu</a>><br class="">
---<br class="">
<br class="">
The gl-1.1-xor-copypixels test still fails. The image stays the same. I'm<br class="">
suspecting it's for reasons outside of this patch.<br class="">
<br class="">
I'm not too familiar with the whole swr infrastructure, perhaps there was<br class="">
an eaiser way to do all this. I looked for conversion helper functions but<br class="">
couldn't find anything that would fit nicely here. Feel free to point me<br class="">
in the right direction.<br class="">
<br class="">
.../drivers/swr/rasterizer/jitter/blend_jit.cpp | 81 +++++++++++++++++-----<br class="">
1 file changed, 64 insertions(+), 17 deletions(-)<br class="">
<br class="">
diff --git a/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp b/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp<br class="">
index 1452d27..d69d503 100644<br class="">
--- a/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp<br class="">
+++ b/src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp<br class="">
@@ -649,29 +649,54 @@ struct BlendJit : public Builder<br class="">
if(state.blendState.logicOpEnable)<br class="">
{<br class="">
const SWR_FORMAT_INFO& info = GetFormatInfo(state.format);<br class="">
- SWR_ASSERT(info.type[0] == SWR_TYPE_UINT);<br class="">
Value* vMask[4];<br class="">
+ float scale[4];<br class="">
+<br class="">
+ if (!state.blendState.blendEnable) {<br class="">
+ Clamp(state.format, src);<br class="">
+ Clamp(state.format, dst);<br class="">
+ }<br class="">
+<br class="">
for(uint32_t i = 0; i < 4; i++)<br class="">
{<br class="">
- switch(info.bpc[i])<br class="">
+ if (info.type[i] == SWR_TYPE_UNUSED)<br class="">
{<br class="">
- case 0: vMask[i] = VIMMED1(0x00000000); break;<br class="">
- case 2: vMask[i] = VIMMED1(0x00000003); break;<br class="">
- case 5: vMask[i] = VIMMED1(0x0000001F); break;<br class="">
- case 6: vMask[i] = VIMMED1(0x0000003F); break;<br class="">
- case 8: vMask[i] = VIMMED1(0x000000FF); break;<br class="">
- case 10: vMask[i] = VIMMED1(0x000003FF); break;<br class="">
- case 11: vMask[i] = VIMMED1(0x000007FF); break;<br class="">
- case 16: vMask[i] = VIMMED1(0x0000FFFF); break;<br class="">
- case 24: vMask[i] = VIMMED1(0x00FFFFFF); break;<br class="">
- case 32: vMask[i] = VIMMED1(0xFFFFFFFF); break;<br class="">
+ continue;<br class="">
+ }<br class="">
+<br class="">
+ if (info.bpc[i] >= 32) {<br class="">
+ vMask[i] = VIMMED1(0xFFFFFFFF);<br class="">
+ scale[i] = 0xFFFFFFFF;<br class="">
+ } else {<br class="">
+ vMask[i] = VIMMED1((1 << info.bpc[i]) - 1);<br class="">
+ if (info.type[i] == SWR_TYPE_SNORM)<br class="">
+ scale[i] = (1 << (info.bpc[i] - 1)) - 1;<br class="">
+ else<br class="">
+ scale[i] = (1 << info.bpc[i]) - 1;<br class="">
+ }<br class="">
+<br class="">
+ switch (info.type[i]) {<br class="">
default:<br class="">
- vMask[i] = VIMMED1(0x0);<br class="">
- SWR_ASSERT(0, "Unsupported bpc for logic op\n");<br class="">
+ SWR_ASSERT(0, "Unsupported type for logic op\n");<br class="">
+ /* fallthrough */<br class="">
+ case SWR_TYPE_UINT:<br class="">
+ case SWR_TYPE_SINT:<br class="">
+ src[i] = BITCAST(src[i], mSimdInt32Ty);<br class="">
+ dst[i] = BITCAST(dst[i], mSimdInt32Ty);<br class="">
+ break;<br class="">
+ case SWR_TYPE_SNORM:<br class="">
+ src[i] = FADD(src[i], VIMMED1(0.5f));<br class="">
+ dst[i] = FADD(dst[i], VIMMED1(0.5f));<br class="">
+ /* fallthrough */<br class="">
+ case SWR_TYPE_UNORM:<br class="">
+ src[i] = FP_TO_UI(<br class="">
+ FMUL(src[i], VIMMED1(scale[i])),<br class="">
+ mSimdInt32Ty);<br class="">
+ dst[i] = FP_TO_UI(<br class="">
+ FMUL(dst[i], VIMMED1(scale[i])),<br class="">
+ mSimdInt32Ty);<br class="">
break;<br class="">
}<br class="">
- src[i] = BITCAST(src[i], mSimdInt32Ty);//, vMask[i]);<br class="">
- dst[i] = BITCAST(dst[i], mSimdInt32Ty);<br class="">
}<br class="">
<br class="">
LogicOpFunc(state.blendState.logicOpFunc, src, dst, result);<br class="">
@@ -679,10 +704,32 @@ struct BlendJit : public Builder<br class="">
// store results out<br class="">
for(uint32_t i = 0; i < 4; ++i)<br class="">
{<br class="">
+ if (info.type[i] == SWR_TYPE_UNUSED)<br class="">
+ {<br class="">
+ continue;<br class="">
+ }<br class="">
+<br class="">
// clear upper bits from PS output not in RT format after doing logic op<br class="">
result[i] = AND(result[i], vMask[i]);<br class="">
<br class="">
- STORE(BITCAST(result[i], mSimdFP32Ty), pResult, {i});<br class="">
+ switch (info.type[i]) {<br class="">
+ default:<br class="">
+ SWR_ASSERT(0, "Unsupported type for logic op\n");<br class="">
+ /* fallthrough */<br class="">
+ case SWR_TYPE_UINT:<br class="">
+ case SWR_TYPE_SINT:<br class="">
+ result[i] = BITCAST(result[i], mSimdFP32Ty);<br class="">
+ break;<br class="">
+ case SWR_TYPE_SNORM:<br class="">
+ case SWR_TYPE_UNORM:<br class="">
+ result[i] = FMUL(UI_TO_FP(result[i], mSimdFP32Ty),<br class="">
+ VIMMED1(1.0f / scale[i]));<br class="">
+ if (info.type[i] == SWR_TYPE_SNORM)<br class="">
+ result[i] = FADD(result[i], VIMMED1(-0.5f));<br class="">
+ break;<br class="">
+ }<br class="">
+<br class="">
+ STORE(result[i], pResult, {i});<br class="">
}<br class="">
}<br class="">
<br class="">
-- <br class="">
2.7.3<br class="">
<br class="">
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>