<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<br class="">
<div>
<blockquote type="cite" class="">
<div class="">On Nov 27, 2016, at 11:13 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=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">On
Thu, Nov 24, 2016 at 6:11 PM, Ilia Mirkin <</span><a href="mailto:imirkin@alum.mit.edu" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">imirkin@alum.mit.edu</a><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">>
wrote:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">
Instead of (incorrectly) biasing the snorm value to make it look like a<br class="">
unorm, just use signed integer math.<br class="">
<br class="">
This fixes arb_color_buffer_float-render GL_RGBA8_SNORM<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="">
src/gallium/drivers/swr/rasterizer/jitter/blend_jit.cpp | 17 ++++++++++++-----<br class="">
1 file changed, 12 insertions(+), 5 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 ad809c4..339ca52 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="">
@@ -692,9 +692,13 @@ struct BlendJit : public Builder<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="">
+ src[i] = FP_TO_SI(<br class="">
+ FMUL(src[i], VIMMED1(scale[i])),<br class="">
+ mSimdInt32Ty);<br class="">
+ dst[i] = FP_TO_SI(<br class="">
+ FMUL(dst[i], VIMMED1(scale[i])),<br class="">
+ mSimdInt32Ty);<br class="">
+ break;<br class="">
case SWR_TYPE_UNORM:<br class="">
src[i] = FP_TO_UI(<br class="">
FMUL(src[i], VIMMED1(scale[i])),<br class="">
@@ -728,11 +732,14 @@ struct BlendJit : public Builder<br class="">
result[i] = BITCAST(result[i], mSimdFP32Ty);<br class="">
break;<br class="">
case SWR_TYPE_SNORM:<br class="">
+ result[i] = SHL(result[i], 32 - info.bpc[i]);<br class="">
+ result[i] = ASHR(result[i], 32 - info.bpc[i]);<br class="">
</blockquote>
<br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">These
two immediate arguments should probably have a C() around them.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">I've
fixed that up in my tree. Hopefully these will emit as VPSLLD and</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">VPSRAD.
Not sure how to check that.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
</div>
</blockquote>
<div><br class="">
</div>
<div>With the version of the patch from your tree, I’m seeing this IR:</div>
<div><br class="">
</div>
<div>
<div> %24 = ashr exact <8 x i32> %23, i32 24</div>
<div> %25 = sitofp <8 x i32> %24 to <8 x float></div>
<div> %26 = fmul <8 x float> %25, <float 0x3F80204080000000, float 0x3F80204080000000, float 0x3F80204080000000, float 0x3F80204080000000, float 0x3F80204080000000, float 0x3F80204080000000, float 0x3F80204080000000, float 0x3F80204080000000></div>
<div> store <8 x float> %26, <8 x float>* %result, align 32</div>
<div class=""><br class="">
</div>
<div class="">Turn into this x86 code:</div>
<div class=""><br class="">
</div>
<div class="">
<div class=""> 9a: vpslld ymm1,ymm3,0x18</div>
<div class=""> 9f: vpsrad ymm1,ymm1,0x18</div>
<div class=""> a4: vcvtdq2ps ymm1,ymm1</div>
<div class=""> a8: vmulps ymm1,ymm1,ymm2</div>
<div class=""> ac: vmovaps YMMWORD PTR [rax+0x20],ymm1</div>
</div>
<div class=""><br class="">
</div>
<div class="">So llvm does what you expected.</div>
<div class=""><br class="">
</div>
<div class="">Version of this patch from your tree Reviewed-by: Tim Rowley <<a href="mailto:timothy.o.rowley@intel.com" class="">timothy.o.rowley@intel.com</a>></div>
</div>
<div><br class="">
</div>
<br class="">
<blockquote type="cite" class="">
<div class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">
<blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">
+ result[i] = FMUL(SI_TO_FP(result[i], mSimdFP32Ty),<br class="">
+ VIMMED1(1.0f / scale[i]));<br class="">
+ break;<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="">
--<br class="">
2.7.3</blockquote>
</div>
</blockquote>
</div>
<br class="">
</body>
</html>