glsl: Add 16-bit types

Graphics / Mesa 3D Graphics Library / Mesa - Eduardo Lima Mitev [] - 6 December 2017 07:57 EST

Adds new INT16, UINT16 and FLOAT16 base types.

The corresponding GL types for half floats were reused from the AMD_gpu_shader_half_float extension. The int16 and uint16 types come from NV_gpu_shader_5 extension.

This adds the builtins and the lexer support.

To avoid a bunch of warnings due to cases not handled in switch, the new types have been added to a few places using same behavior as their 32-bit counterparts, except for a few trivial cases where they are already handled properly. Subsequent patches in this set will provide correct 16-bit implementations when needed.

v2: * Use FLOAT16 instead of HALF_FLOAT as name of the base type.
- Removed float16_t from builtin types.
- Don't copy 16-bit types as if they were 32-bit values in copy_constant_to_storage().
- Use get_scalar_type() instead of adding a new custom switch statement. (Jason Ekstrand)
v3: Use GL_FLOAT16_NV instead of GL_HALF_FLOAT for consistency (Ilia Mirkin)
v4: Add missing 16-bit base types support in glsl_to_nir (Eduardo Lima).
v5: Fix coding style (Topi Poholainen).

59f458cd87 glsl: Add 16-bit types
src/compiler/builtin_type_macros.h | 26 +++++++
src/compiler/glsl/ast_to_hir.cpp | 3 +
src/compiler/glsl/glsl_to_nir.cpp | 6 +-
src/compiler/glsl/ir_clone.cpp | 3 +
src/compiler/glsl/link_uniform_initializers.cpp | 3 +
src/compiler/glsl/lower_buffer_access.cpp | 3 +-
src/compiler/glsl_types.cpp | 93 ++++++++++++++++++++++++-
src/compiler/glsl_types.h | 10 ++-
src/mesa/program/ir_to_mesa.cpp | 6 ++
9 files changed, 145 insertions(+), 8 deletions(-)


  • Share