Mesa (master): glsl: Enable derivative builtins for NV_compute_shader_derivatives

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Apr 9 03:29:09 UTC 2019


Module: Mesa
Branch: master
Commit: 09a3273fe7b66078e9ebce74b38eb5353548d7cb
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=09a3273fe7b66078e9ebce74b38eb5353548d7cb

Author: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Date:   Tue Mar 26 00:04:01 2019 -0700

glsl: Enable derivative builtins for NV_compute_shader_derivatives

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

---

 src/compiler/glsl/builtin_functions.cpp | 34 ++++++++++++++++++++++++---------
 1 file changed, 25 insertions(+), 9 deletions(-)

diff --git a/src/compiler/glsl/builtin_functions.cpp b/src/compiler/glsl/builtin_functions.cpp
index 386cbc0ccd7..873572efa44 100644
--- a/src/compiler/glsl/builtin_functions.cpp
+++ b/src/compiler/glsl/builtin_functions.cpp
@@ -458,6 +458,14 @@ fs_oes_derivatives(const _mesa_glsl_parse_state *state)
 }
 
 static bool
+derivatives(const _mesa_glsl_parse_state *state)
+{
+   return fs_oes_derivatives(state) ||
+          (state->stage == MESA_SHADER_COMPUTE &&
+           state->NV_compute_shader_derivatives_enable);
+}
+
+static bool
 fs_derivative_control(const _mesa_glsl_parse_state *state)
 {
    return state->stage == MESA_SHADER_FRAGMENT &&
@@ -466,6 +474,14 @@ fs_derivative_control(const _mesa_glsl_parse_state *state)
 }
 
 static bool
+derivative_control(const _mesa_glsl_parse_state *state)
+{
+   return fs_derivative_control(state) ||
+      (state->stage == MESA_SHADER_COMPUTE &&
+       state->NV_compute_shader_derivatives_enable);
+}
+
+static bool
 tex1d_lod(const _mesa_glsl_parse_state *state)
 {
    return !state->es_shader && lod_exists_in_stage(state);
@@ -5542,18 +5558,18 @@ builtin_builder::_textureSamplesIdentical(builtin_available_predicate avail,
    return sig;
 }
 
-UNOP(dFdx, ir_unop_dFdx, fs_oes_derivatives)
-UNOP(dFdxCoarse, ir_unop_dFdx_coarse, fs_derivative_control)
-UNOP(dFdxFine, ir_unop_dFdx_fine, fs_derivative_control)
-UNOP(dFdy, ir_unop_dFdy, fs_oes_derivatives)
-UNOP(dFdyCoarse, ir_unop_dFdy_coarse, fs_derivative_control)
-UNOP(dFdyFine, ir_unop_dFdy_fine, fs_derivative_control)
+UNOP(dFdx, ir_unop_dFdx, derivatives)
+UNOP(dFdxCoarse, ir_unop_dFdx_coarse, derivative_control)
+UNOP(dFdxFine, ir_unop_dFdx_fine, derivative_control)
+UNOP(dFdy, ir_unop_dFdy, derivatives)
+UNOP(dFdyCoarse, ir_unop_dFdy_coarse, derivative_control)
+UNOP(dFdyFine, ir_unop_dFdy_fine, derivative_control)
 
 ir_function_signature *
 builtin_builder::_fwidth(const glsl_type *type)
 {
    ir_variable *p = in_var(type, "p");
-   MAKE_SIG(type, fs_oes_derivatives, 1, p);
+   MAKE_SIG(type, derivatives, 1, p);
 
    body.emit(ret(add(abs(expr(ir_unop_dFdx, p)), abs(expr(ir_unop_dFdy, p)))));
 
@@ -5564,7 +5580,7 @@ ir_function_signature *
 builtin_builder::_fwidthCoarse(const glsl_type *type)
 {
    ir_variable *p = in_var(type, "p");
-   MAKE_SIG(type, fs_derivative_control, 1, p);
+   MAKE_SIG(type, derivative_control, 1, p);
 
    body.emit(ret(add(abs(expr(ir_unop_dFdx_coarse, p)),
                      abs(expr(ir_unop_dFdy_coarse, p)))));
@@ -5576,7 +5592,7 @@ ir_function_signature *
 builtin_builder::_fwidthFine(const glsl_type *type)
 {
    ir_variable *p = in_var(type, "p");
-   MAKE_SIG(type, fs_derivative_control, 1, p);
+   MAKE_SIG(type, derivative_control, 1, p);
 
    body.emit(ret(add(abs(expr(ir_unop_dFdx_fine, p)),
                      abs(expr(ir_unop_dFdy_fine, p)))));




More information about the mesa-commit mailing list