[Mesa-dev,v5,00/29] add fp64 support to mesa and glsl compiler

Submitted by Ilia Mirkin on Feb. 10, 2015, 11:58 a.m.

Details

Message ID 1423569549-13866-1-git-send-email-imirkin@alum.mit.edu
State New, archived
Headers show

Not browsing as part of any series.

Commit Message

Ilia Mirkin Feb. 10, 2015, 11:58 a.m.
I spent a lot of quality time with Ian's random_ubo.py script, and I'm
happy to report that with the current iteration, it doesn't spot any
problems (after ~1000 shaders). I only had to make the following
change to it:


As well as apply the shader_runner patches from the list. I had to
remove version 130 because it causes a non-core context to be created,
which means that there's no fp64 support.

Also all of the current piglit fp64 tests pass both on softpipe and
nvc0. Dave has them all passing on r600 without sb, and getting close
with it.

Tapani's "glsl: validate output types for shader stages" patch is
necessary for the piglit that its description references to pass. If
you have a better suggestion of where to put that code, let me know.

Hopefully this is getting closer to pushable... Patch series also
available at https://github.com/imirkin/mesa/commits/fp64-6 .

Dave Airlie (24):
  glapi: add ARB_gpu_shader_fp64 (v2)
  mesa: add ARB_gpu_shader_fp64 extension info (v2)
  mesa: add double uniform support. (v5)
  glsl: add ARB_gpu_shader_fp64 to the glsl extensions. (v2)
  glsl: Add double builtin type generation
  glsl: Uniform linking support for doubles
  glsl/ir: Add builtin function support for doubles
  glsl/ir: Add printing support for doubles
  glsl/ir: Add cloning support for doubles
  glsl/ir: Add builtin constant function support for doubles
  glsl/ir: Add builder support for functions with double floats
  glsl: Add support doubles in optimization passes
  glsl: Add ubo lowering support for doubles
  glsl/ast: Support double floats
  glsl/parser: Support double floats
  glsl/lexer: Support double floats
  glsl: Support double inouts
  glsl: Support double loop control
  glsl: Linking support for doubles
  glsl: add double support to lower_mat_op_to_vec
  glsl: enable/disable certain lowering passes for doubles
  glsl/lower_instructions: add double lowering passes
  glsl: implement double builtin functions
  glsl: lower double optional passes (v2)

Ilia Mirkin (4):
  glsl: Add double builtin type
  glsl: fix uniform linking logic in the presence of structs
  glsl: add a lowering pass for frexp/ldexp with double arguments
  glsl/tests: add DOUBLE/IMAGE types

Tapani Pälli (1):
  glsl: validate output types for shader stages

 src/glsl/ast.h                                     |   2 +
 src/glsl/ast_function.cpp                          |  66 +-
 src/glsl/ast_to_hir.cpp                            |  78 ++-
 src/glsl/builtin_functions.cpp                     | 751 ++++++++++++++-------
 src/glsl/builtin_type_macros.h                     |  16 +
 src/glsl/builtin_types.cpp                         |  30 +
 src/glsl/glcpp/glcpp-parse.y                       |   3 +
 src/glsl/glsl_lexer.ll                             |  31 +-
 src/glsl/glsl_parser.yy                            |  33 +-
 src/glsl/glsl_parser_extras.cpp                    |   5 +
 src/glsl/glsl_parser_extras.h                      |   7 +
 src/glsl/glsl_types.cpp                            | 112 ++-
 src/glsl/glsl_types.h                              |  20 +-
 src/glsl/ir.cpp                                    | 111 ++-
 src/glsl/ir.h                                      |  22 +
 src/glsl/ir_builder.cpp                            |  23 +
 src/glsl/ir_builder.h                              |   5 +
 src/glsl/ir_clone.cpp                              |   1 +
 src/glsl/ir_constant_expression.cpp                | 247 ++++++-
 src/glsl/ir_optimization.h                         |   2 +
 src/glsl/ir_print_visitor.cpp                      |  11 +
 src/glsl/ir_set_program_inouts.cpp                 |  28 +-
 src/glsl/ir_validate.cpp                           |  72 +-
 src/glsl/link_uniform_blocks.cpp                   |  45 +-
 src/glsl/link_uniform_initializers.cpp             |   8 +-
 src/glsl/link_uniforms.cpp                         |  44 +-
 src/glsl/linker.h                                  |   6 +
 src/glsl/loop_controls.cpp                         |   8 +-
 src/glsl/lower_instructions.cpp                    | 525 +++++++++++++-
 src/glsl/lower_mat_op_to_vec.cpp                   |   2 +
 src/glsl/lower_ubo_reference.cpp                   |  57 +-
 src/glsl/opt_algebraic.cpp                         |  26 +-
 src/glsl/opt_constant_propagation.cpp              |   3 +
 src/glsl/opt_minmax.cpp                            |  13 +
 src/glsl/standalone_scaffolding.cpp                |   1 +
 src/glsl/tests/uniform_initializer_utils.cpp       |  12 +
 src/mapi/glapi/gen/ARB_gpu_shader_fp64.xml         | 143 ++++
 src/mapi/glapi/gen/ARB_separate_shader_objects.xml |   2 -
 src/mapi/glapi/gen/Makefile.am                     |   1 +
 src/mapi/glapi/gen/gl_API.xml                      |   2 +
 src/mesa/main/extensions.c                         |   1 +
 src/mesa/main/mtypes.h                             |   1 +
 src/mesa/main/tests/dispatch_sanity.cpp            |  70 +-
 src/mesa/main/uniform_query.cpp                    |  46 +-
 src/mesa/main/uniforms.c                           | 380 ++++++++++-
 src/mesa/main/uniforms.h                           |  92 ++-
 src/mesa/program/ir_to_mesa.cpp                    |  37 +-
 47 files changed, 2714 insertions(+), 487 deletions(-)
 create mode 100644 src/mapi/glapi/gen/ARB_gpu_shader_fp64.xml

Patch hide | download patch | download mbox

diff --git a/generated_tests/random_ubo.py b/generated_tests/random_ubo.py
index 33359f6..e3f999e 100644
--- a/generated_tests/random_ubo.py
+++ b/generated_tests/random_ubo.py
@@ -763,8 +763,8 @@  def scalar_derp(type, name, offset, data):
         # 0xHHHHHHHHLLLLLLLL
         # 012345678901234567
 
-        hi = "0x" + bits[2:9]
-        lo = "0x" + bits[10:17]
+        hi = "0x" + bits[2:10]
+        lo = "0x" + bits[10:18]
 
         return "!double_match({}, uvec2({}, {}))".format(name, lo, hi)
     else:
@@ -1734,7 +1734,7 @@  if __name__ == "__main__":
         extensions = []
 
     # Pick a random GLSL version from the available set of possible versions.
-    glsl_version = random.choice([v for v in [130, 140, 150, 400, 430]
+    glsl_version = random.choice([v for v in [140, 150, 400, 430]
                                   if v <= max_glsl_version])
 
     # Use the GLSL version filter out some extensions that are redundant.

Comments

On 02/10/2015 01:58 PM, Ilia Mirkin wrote:
> I spent a lot of quality time with Ian's random_ubo.py script, and I'm
> happy to report that with the current iteration, it doesn't spot any
> problems (after ~1000 shaders). I only had to make the following
> change to it:
>
> diff --git a/generated_tests/random_ubo.py b/generated_tests/random_ubo.py
> index 33359f6..e3f999e 100644
> --- a/generated_tests/random_ubo.py
> +++ b/generated_tests/random_ubo.py
> @@ -763,8 +763,8 @@ def scalar_derp(type, name, offset, data):
>           # 0xHHHHHHHHLLLLLLLL
>           # 012345678901234567
>
> -        hi = "0x" + bits[2:9]
> -        lo = "0x" + bits[10:17]
> +        hi = "0x" + bits[2:10]
> +        lo = "0x" + bits[10:18]
>
>           return "!double_match({}, uvec2({}, {}))".format(name, lo, hi)
>       else:
> @@ -1734,7 +1734,7 @@ if __name__ == "__main__":
>           extensions = []
>
>       # Pick a random GLSL version from the available set of possible versions.
> -    glsl_version = random.choice([v for v in [130, 140, 150, 400, 430]
> +    glsl_version = random.choice([v for v in [140, 150, 400, 430]
>                                     if v <= max_glsl_version])
>
>       # Use the GLSL version filter out some extensions that are redundant.
>
> As well as apply the shader_runner patches from the list. I had to
> remove version 130 because it causes a non-core context to be created,
> which means that there's no fp64 support.
>
> Also all of the current piglit fp64 tests pass both on softpipe and
> nvc0. Dave has them all passing on r600 without sb, and getting close
> with it.
>
> Tapani's "glsl: validate output types for shader stages" patch is
> necessary for the piglit that its description references to pass. If
> you have a better suggestion of where to put that code, let me know.

I've taken more look in to this. If the output does not have a 
interpolation qualifier then we incorrectly allow wrong types. My patch 
validates the output type independent of the interpolation qualifier so 
that's why it works. I can add more tests if wanted.

> Hopefully this is getting closer to pushable... Patch series also
> available at https://github.com/imirkin/mesa/commits/fp64-6 .
>
> Dave Airlie (24):
>    glapi: add ARB_gpu_shader_fp64 (v2)
>    mesa: add ARB_gpu_shader_fp64 extension info (v2)
>    mesa: add double uniform support. (v5)
>    glsl: add ARB_gpu_shader_fp64 to the glsl extensions. (v2)
>    glsl: Add double builtin type generation
>    glsl: Uniform linking support for doubles
>    glsl/ir: Add builtin function support for doubles
>    glsl/ir: Add printing support for doubles
>    glsl/ir: Add cloning support for doubles
>    glsl/ir: Add builtin constant function support for doubles
>    glsl/ir: Add builder support for functions with double floats
>    glsl: Add support doubles in optimization passes
>    glsl: Add ubo lowering support for doubles
>    glsl/ast: Support double floats
>    glsl/parser: Support double floats
>    glsl/lexer: Support double floats
>    glsl: Support double inouts
>    glsl: Support double loop control
>    glsl: Linking support for doubles
>    glsl: add double support to lower_mat_op_to_vec
>    glsl: enable/disable certain lowering passes for doubles
>    glsl/lower_instructions: add double lowering passes
>    glsl: implement double builtin functions
>    glsl: lower double optional passes (v2)
>
> Ilia Mirkin (4):
>    glsl: Add double builtin type
>    glsl: fix uniform linking logic in the presence of structs
>    glsl: add a lowering pass for frexp/ldexp with double arguments
>    glsl/tests: add DOUBLE/IMAGE types
>
> Tapani Pälli (1):
>    glsl: validate output types for shader stages
>
>   src/glsl/ast.h                                     |   2 +
>   src/glsl/ast_function.cpp                          |  66 +-
>   src/glsl/ast_to_hir.cpp                            |  78 ++-
>   src/glsl/builtin_functions.cpp                     | 751 ++++++++++++++-------
>   src/glsl/builtin_type_macros.h                     |  16 +
>   src/glsl/builtin_types.cpp                         |  30 +
>   src/glsl/glcpp/glcpp-parse.y                       |   3 +
>   src/glsl/glsl_lexer.ll                             |  31 +-
>   src/glsl/glsl_parser.yy                            |  33 +-
>   src/glsl/glsl_parser_extras.cpp                    |   5 +
>   src/glsl/glsl_parser_extras.h                      |   7 +
>   src/glsl/glsl_types.cpp                            | 112 ++-
>   src/glsl/glsl_types.h                              |  20 +-
>   src/glsl/ir.cpp                                    | 111 ++-
>   src/glsl/ir.h                                      |  22 +
>   src/glsl/ir_builder.cpp                            |  23 +
>   src/glsl/ir_builder.h                              |   5 +
>   src/glsl/ir_clone.cpp                              |   1 +
>   src/glsl/ir_constant_expression.cpp                | 247 ++++++-
>   src/glsl/ir_optimization.h                         |   2 +
>   src/glsl/ir_print_visitor.cpp                      |  11 +
>   src/glsl/ir_set_program_inouts.cpp                 |  28 +-
>   src/glsl/ir_validate.cpp                           |  72 +-
>   src/glsl/link_uniform_blocks.cpp                   |  45 +-
>   src/glsl/link_uniform_initializers.cpp             |   8 +-
>   src/glsl/link_uniforms.cpp                         |  44 +-
>   src/glsl/linker.h                                  |   6 +
>   src/glsl/loop_controls.cpp                         |   8 +-
>   src/glsl/lower_instructions.cpp                    | 525 +++++++++++++-
>   src/glsl/lower_mat_op_to_vec.cpp                   |   2 +
>   src/glsl/lower_ubo_reference.cpp                   |  57 +-
>   src/glsl/opt_algebraic.cpp                         |  26 +-
>   src/glsl/opt_constant_propagation.cpp              |   3 +
>   src/glsl/opt_minmax.cpp                            |  13 +
>   src/glsl/standalone_scaffolding.cpp                |   1 +
>   src/glsl/tests/uniform_initializer_utils.cpp       |  12 +
>   src/mapi/glapi/gen/ARB_gpu_shader_fp64.xml         | 143 ++++
>   src/mapi/glapi/gen/ARB_separate_shader_objects.xml |   2 -
>   src/mapi/glapi/gen/Makefile.am                     |   1 +
>   src/mapi/glapi/gen/gl_API.xml                      |   2 +
>   src/mesa/main/extensions.c                         |   1 +
>   src/mesa/main/mtypes.h                             |   1 +
>   src/mesa/main/tests/dispatch_sanity.cpp            |  70 +-
>   src/mesa/main/uniform_query.cpp                    |  46 +-
>   src/mesa/main/uniforms.c                           | 380 ++++++++++-
>   src/mesa/main/uniforms.h                           |  92 ++-
>   src/mesa/program/ir_to_mesa.cpp                    |  37 +-
>   47 files changed, 2714 insertions(+), 487 deletions(-)
>   create mode 100644 src/mapi/glapi/gen/ARB_gpu_shader_fp64.xml
>
Matt and Ian -- thanks a lot for doing the reviews you already have
done! Matt mentioned that it'd be helpful to have a list of the
patches that have yet to be reviewed, so here it is:

$ grep -L Reviewed-by *.patch | xargs grep -h 'PATCH v5' | sed 's/Subject: //'
[PATCH v5 04/29] mesa: add double uniform support. (v5)
[PATCH v5 07/29] glsl: Uniform linking support for doubles
[PATCH v5 08/29] glsl: fix uniform linking logic in the presence of
[PATCH v5 09/29] glsl/ir: Add builtin function support for doubles
[PATCH v5 12/29] glsl/ir: Add builtin constant function support for
[PATCH v5 15/29] glsl: Add ubo lowering support for doubles
[PATCH v5 16/29] glsl/ast: Support double floats
[PATCH v5 19/29] glsl: Support double inouts
[PATCH v5 20/29] glsl: Support double loop control
[PATCH v5 23/29] glsl: validate output types for shader stages
[PATCH v5 24/29] glsl: enable/disable certain lowering passes for
[PATCH v5 25/29] glsl/lower_instructions: add double lowering passes
[PATCH v5 26/29] glsl: implement double builtin functions
[PATCH v5 27/29] glsl: lower double optional passes (v2)
[PATCH v5 28/29] glsl: add a lowering pass for frexp/ldexp with
[PATCH v5 29/29] glsl/tests: add DOUBLE/IMAGE types

On Tue, Feb 10, 2015 at 6:58 AM, Ilia Mirkin <imirkin@alum.mit.edu> wrote:
> I spent a lot of quality time with Ian's random_ubo.py script, and I'm
> happy to report that with the current iteration, it doesn't spot any
> problems (after ~1000 shaders). I only had to make the following
> change to it:
>
> diff --git a/generated_tests/random_ubo.py b/generated_tests/random_ubo.py
> index 33359f6..e3f999e 100644
> --- a/generated_tests/random_ubo.py
> +++ b/generated_tests/random_ubo.py
> @@ -763,8 +763,8 @@ def scalar_derp(type, name, offset, data):
>          # 0xHHHHHHHHLLLLLLLL
>          # 012345678901234567
>
> -        hi = "0x" + bits[2:9]
> -        lo = "0x" + bits[10:17]
> +        hi = "0x" + bits[2:10]
> +        lo = "0x" + bits[10:18]
>
>          return "!double_match({}, uvec2({}, {}))".format(name, lo, hi)
>      else:
> @@ -1734,7 +1734,7 @@ if __name__ == "__main__":
>          extensions = []
>
>      # Pick a random GLSL version from the available set of possible versions.
> -    glsl_version = random.choice([v for v in [130, 140, 150, 400, 430]
> +    glsl_version = random.choice([v for v in [140, 150, 400, 430]
>                                    if v <= max_glsl_version])
>
>      # Use the GLSL version filter out some extensions that are redundant.
>
> As well as apply the shader_runner patches from the list. I had to
> remove version 130 because it causes a non-core context to be created,
> which means that there's no fp64 support.
>
> Also all of the current piglit fp64 tests pass both on softpipe and
> nvc0. Dave has them all passing on r600 without sb, and getting close
> with it.
>
> Tapani's "glsl: validate output types for shader stages" patch is
> necessary for the piglit that its description references to pass. If
> you have a better suggestion of where to put that code, let me know.
>
> Hopefully this is getting closer to pushable... Patch series also
> available at https://github.com/imirkin/mesa/commits/fp64-6 .
>
> Dave Airlie (24):
>   glapi: add ARB_gpu_shader_fp64 (v2)
>   mesa: add ARB_gpu_shader_fp64 extension info (v2)
>   mesa: add double uniform support. (v5)
>   glsl: add ARB_gpu_shader_fp64 to the glsl extensions. (v2)
>   glsl: Add double builtin type generation
>   glsl: Uniform linking support for doubles
>   glsl/ir: Add builtin function support for doubles
>   glsl/ir: Add printing support for doubles
>   glsl/ir: Add cloning support for doubles
>   glsl/ir: Add builtin constant function support for doubles
>   glsl/ir: Add builder support for functions with double floats
>   glsl: Add support doubles in optimization passes
>   glsl: Add ubo lowering support for doubles
>   glsl/ast: Support double floats
>   glsl/parser: Support double floats
>   glsl/lexer: Support double floats
>   glsl: Support double inouts
>   glsl: Support double loop control
>   glsl: Linking support for doubles
>   glsl: add double support to lower_mat_op_to_vec
>   glsl: enable/disable certain lowering passes for doubles
>   glsl/lower_instructions: add double lowering passes
>   glsl: implement double builtin functions
>   glsl: lower double optional passes (v2)
>
> Ilia Mirkin (4):
>   glsl: Add double builtin type
>   glsl: fix uniform linking logic in the presence of structs
>   glsl: add a lowering pass for frexp/ldexp with double arguments
>   glsl/tests: add DOUBLE/IMAGE types
>
> Tapani Pälli (1):
>   glsl: validate output types for shader stages
>
>  src/glsl/ast.h                                     |   2 +
>  src/glsl/ast_function.cpp                          |  66 +-
>  src/glsl/ast_to_hir.cpp                            |  78 ++-
>  src/glsl/builtin_functions.cpp                     | 751 ++++++++++++++-------
>  src/glsl/builtin_type_macros.h                     |  16 +
>  src/glsl/builtin_types.cpp                         |  30 +
>  src/glsl/glcpp/glcpp-parse.y                       |   3 +
>  src/glsl/glsl_lexer.ll                             |  31 +-
>  src/glsl/glsl_parser.yy                            |  33 +-
>  src/glsl/glsl_parser_extras.cpp                    |   5 +
>  src/glsl/glsl_parser_extras.h                      |   7 +
>  src/glsl/glsl_types.cpp                            | 112 ++-
>  src/glsl/glsl_types.h                              |  20 +-
>  src/glsl/ir.cpp                                    | 111 ++-
>  src/glsl/ir.h                                      |  22 +
>  src/glsl/ir_builder.cpp                            |  23 +
>  src/glsl/ir_builder.h                              |   5 +
>  src/glsl/ir_clone.cpp                              |   1 +
>  src/glsl/ir_constant_expression.cpp                | 247 ++++++-
>  src/glsl/ir_optimization.h                         |   2 +
>  src/glsl/ir_print_visitor.cpp                      |  11 +
>  src/glsl/ir_set_program_inouts.cpp                 |  28 +-
>  src/glsl/ir_validate.cpp                           |  72 +-
>  src/glsl/link_uniform_blocks.cpp                   |  45 +-
>  src/glsl/link_uniform_initializers.cpp             |   8 +-
>  src/glsl/link_uniforms.cpp                         |  44 +-
>  src/glsl/linker.h                                  |   6 +
>  src/glsl/loop_controls.cpp                         |   8 +-
>  src/glsl/lower_instructions.cpp                    | 525 +++++++++++++-
>  src/glsl/lower_mat_op_to_vec.cpp                   |   2 +
>  src/glsl/lower_ubo_reference.cpp                   |  57 +-
>  src/glsl/opt_algebraic.cpp                         |  26 +-
>  src/glsl/opt_constant_propagation.cpp              |   3 +
>  src/glsl/opt_minmax.cpp                            |  13 +
>  src/glsl/standalone_scaffolding.cpp                |   1 +
>  src/glsl/tests/uniform_initializer_utils.cpp       |  12 +
>  src/mapi/glapi/gen/ARB_gpu_shader_fp64.xml         | 143 ++++
>  src/mapi/glapi/gen/ARB_separate_shader_objects.xml |   2 -
>  src/mapi/glapi/gen/Makefile.am                     |   1 +
>  src/mapi/glapi/gen/gl_API.xml                      |   2 +
>  src/mesa/main/extensions.c                         |   1 +
>  src/mesa/main/mtypes.h                             |   1 +
>  src/mesa/main/tests/dispatch_sanity.cpp            |  70 +-
>  src/mesa/main/uniform_query.cpp                    |  46 +-
>  src/mesa/main/uniforms.c                           | 380 ++++++++++-
>  src/mesa/main/uniforms.h                           |  92 ++-
>  src/mesa/program/ir_to_mesa.cpp                    |  37 +-
>  47 files changed, 2714 insertions(+), 487 deletions(-)
>  create mode 100644 src/mapi/glapi/gen/ARB_gpu_shader_fp64.xml
>
> --
> 2.0.5
>
On 02/11/2015 09:13 AM, Tapani Pälli wrote:
>
>
> On 02/10/2015 01:58 PM, Ilia Mirkin wrote:
>>
>> Tapani's "glsl: validate output types for shader stages" patch is
>> necessary for the piglit that its description references to pass. If
>> you have a better suggestion of where to put that code, let me know.
>
> I've taken more look in to this. If the output does not have a
> interpolation qualifier then we incorrectly allow wrong types. My patch
> validates the output type independent of the interpolation qualifier so
> that's why it works. I can add more tests if wanted.

Sorry, this was not correct conclusion, the involved tests made me think 
so. The actual reason why patch works is that we validate the output 
variable types only if they are "valid varying variables" (see 
is_varying_var function), and output from fragment shader is not "valid 
varying". So we allow any type of output from fragment shader declared 
with 'out', this patch fixes that. It has some extra checks as it 
validates also outputs from other stages but to me it seems legit to do 
in that place.

// Tapani