[Bug 76862] clamp with bounds inside [0, 1] generates slow code

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Tue Jun 3 19:32:26 PDT 2014


https://bugs.freedesktop.org/show_bug.cgi?id=76862

Matt Turner <mattst88 at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
           Assignee|idr at freedesktop.org         |xynopsis at gmail.com

--- Comment #3 from Matt Turner <mattst88 at gmail.com> ---
I think the project will look like this:

== Add saturate(x) to the GLSL IR ==

 1) Add a new GLSL IR instruction, "ir_unop_saturate". See commit 499d7a7f as
an example.

 2) Implement constant evaluation of saturate. See commit 9c04b8c2 as an
example.

 3) Implement a lowering pass to lower saturate(a) to min(max(a, b), c) (to be
used for old ARB vertex programs that cannot do saturate). See commit dafd0508
as an example.

 4) Update the backend visitors (ir_to_mesa.cpp, st_glsl_to_tgsi.cpp,
brw_fs_visitor.cpp, brw_vec4_visitor.cpp) to handle ir_unop_saturate. All of
these emit instructions that have a saturate flag that can be set, so emit a
MOV with the saturate flag. See 84772629 as an example (for the i965 backends).

Note the small difficulty of not being able to use the saturate flag in certain
ARB vertex program versions in ir_to_mesa and st_glsl_to_tgsi, noted in their
try_emit_sat functions. For those, modify the call to lower_instructions() to
include your new flag according to the condition at the top of try_emit_sat().

 5) Update src/glsl/ir_builder.cpp's saturate() function to use the new
operation.

 6) Delete the try_emit_sat functions, since they'll no longer be useful.

This should be one patch series. Send it as soon as it's done.

== Use saturate to optimize code ==

 1) Write some piglit tests for the last two cases below. Submit them as soon
as they're ready.

 2) Extend opt_algebraic.cpp to recognize min(max(a, 0.0), 1.0) as saturate.
Make sure tests/spec/glsl-1.10/execution/?s-saturate-*.shader_test pass.

 3) Extend opt_algebraic.cpp to recognize min(max(a, b), c) where (b == 0.0 and
c < 1.0) and turn it into saturate(min(a, c)).

 4) Extend opt_algebraic.cpp to recognize min(max(a, b), c) where (b > 0.0 and
c == 1.0) and turn it into saturate(max(a, b))

With these two optimizations on top of the previously laid infrastructure, your
piglit tests should generate fewer instructions.

-- 
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/20140604/84e1ba7f/attachment.html>


More information about the intel-3d-bugs mailing list