[Mesa-dev] [PATCH 50/50] st/glsl: enable fp64 lowering support

Dave Airlie airlied at gmail.com
Tue Mar 13 04:25:15 UTC 2018


From: Dave Airlie <airlied at redhat.com>

This enables fp64 emulation if the driver requests it
with PIPE_CAP_DOUBLES set to PIPE_DOUBLES_EMULATE.

It moves the mat->vec lowering earlier as we don't
want to hit any matrix operation in double lowering,
and if we lower div->rcp we end up getting the wrong
type of matrix mult, so just avoid that problem.

Otherwise it just enables all the fp64 lowering.
---
 src/mesa/state_tracker/st_extensions.c     |  2 +-
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 13 ++++++++++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 3b8e226..524b021 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -1254,7 +1254,7 @@ void st_init_extensions(struct pipe_screen *screen,
    }
 #endif
 
-   if (screen->get_param(screen, PIPE_CAP_DOUBLES)) {
+   if (screen->get_param(screen, PIPE_CAP_DOUBLES) != PIPE_DOUBLES_NONE) {
       extensions->ARB_gpu_shader_fp64 = GL_TRUE;
       extensions->ARB_vertex_attrib_64bit = GL_TRUE;
    }
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index b608635..abcadd0 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -7028,9 +7028,21 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
                                              options->EmitNoIndirectUniform);
       }
 
+      do_mat_op_to_vec(ir);
+
       if (!pscreen->get_param(pscreen, PIPE_CAP_INT64_DIVMOD))
          lower_64bit_instructions(ir, DIV64 | MOD64);
 
+      /* Enable double lowering if the hardware doesn't support doubles.
+       * The lowering requires GLSL >= 130.
+       */
+      if ((pscreen->get_param(pscreen, PIPE_CAP_DOUBLES) == PIPE_DOUBLES_EMULATE) &&
+          ctx->Const.GLSLVersion >= 130) {
+         lower_instructions(ir, DDIV_TO_MUL_RCP | DMIN_DMAX_TO_LESS | DOPS_TO_DTRUNC | DRSQ_TO_DRCP | DFMA_TO_DMULADD |
+                            DMOD_TO_FLOOR | (have_dfrexp ? 0 : DFREXP_DLDEXP_TO_ARITH));
+         lower_64bit_instructions(ir, LOWER_ALL_DOUBLE_OPS);
+      }
+
       if (ctx->Extensions.ARB_shading_language_packing) {
          unsigned lower_inst = LOWER_PACK_SNORM_2x16 |
                                LOWER_UNPACK_SNORM_2x16 |
@@ -7053,7 +7065,6 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
 
       if (!pscreen->get_param(pscreen, PIPE_CAP_TEXTURE_GATHER_OFFSETS))
          lower_offset_arrays(ir);
-      do_mat_op_to_vec(ir);
 
       if (stage == MESA_SHADER_FRAGMENT)
          lower_blend_equation_advanced(
-- 
2.9.5



More information about the mesa-dev mailing list