[Bug 76861] New: mid3 generates slow code for constant arguments
bugzilla-daemon at freedesktop.org
bugzilla-daemon at freedesktop.org
Mon Mar 31 14:34:52 PDT 2014
https://bugs.freedesktop.org/show_bug.cgi?id=76861
Priority: medium
Bug ID: 76861
Assignee: idr at freedesktop.org
Summary: mid3 generates slow code for constant arguments
QA Contact: intel-3d-bugs at lists.freedesktop.org
Severity: enhancement
Classification: Unclassified
OS: All
Reporter: idr at freedesktop.org
Hardware: Other
Status: NEW
Version: git
Component: glsl-compiler
Product: Mesa
mid3 (from GL_AMD_shader_trinary_minmax) generate slow code if two of the
arguments are constants. The code
a = mid3(b, 1, 3);
should generate the same code as
a = clamp(b, 1, 3);
Instead it generates
(assign (xyzw) (var_ref a) (expression vec4 max (expression vec4 min
(var_ref b) (constant vec4 (1.0 1.0 1.0 1.0)) ) (expression vec4 max
(expression vec4 min (var_ref b0) (constant vec4 (3.0 3.0 3.0 3.0)) ) (constant
vec4 (1.0 1.0 1.0 1.0)) ) ) )
I think the correct fix for this is to add an ir_triop_mid opcode and a
lowering pass (in lower_instructions.cpp). The lowering pass would then need
to be smart enough to do the right thing when some of the operands are
constants.
min3 and max3 may have similar problems.
The mid3 issue is likely to become a bigger problem in the future. Emil
Persson (aka Humus) suggested that PS3 / Xbox1 developers use mid3 as a general
purpose clamp during his GDC2014 presentation. See
https://www.youtube.com/watch?v=UJq96XZURHw
--
You are receiving this mail because:
You are the QA Contact for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/intel-3d-bugs/attachments/20140331/3be337a6/attachment.html>
More information about the intel-3d-bugs
mailing list