If a shader's only use of float16 is for FConvert, add the Float16 capability.

When visiting instructions, check that there are no 16-bit storage capabilities
and add the Float16 capability. Same for int8/int16.
This commit is contained in:
Jeff Bolz
2019-05-01 11:45:36 -05:00
parent 86c72c9486
commit faac86e5d6
6 changed files with 157 additions and 18 deletions

View File

@@ -0,0 +1,39 @@
spv.float16convertonlyarith.comp
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 22
Capability Shader
Capability Float16
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint GLCompute 4 "main"
ExecutionMode 4 LocalSize 16 16 1
Source GLSL 450
SourceExtension "GL_EXT_shader_explicit_arithmetic_types_float16"
Name 4 "main"
Name 9 "v"
Decorate 21 BuiltIn WorkgroupSize
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypePointer Function 7(fvec4)
10: 6(float) Constant 0
11: 7(fvec4) ConstantComposite 10 10 10 10
13: TypeFloat 16
14: TypeVector 13(float16_t) 4
17: TypeInt 32 0
18: TypeVector 17(int) 3
19: 17(int) Constant 16
20: 17(int) Constant 1
21: 18(ivec3) ConstantComposite 19 19 20
4(main): 2 Function None 3
5: Label
9(v): 8(ptr) Variable Function
Store 9(v) 11
12: 7(fvec4) Load 9(v)
15: 14(f16vec4) FConvert 12
16: 7(fvec4) FConvert 15
Return
FunctionEnd

View File

@@ -0,0 +1,39 @@
spv.float16convertonlystorage.comp
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 22
Capability Shader
Capability Float16
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint GLCompute 4 "main"
ExecutionMode 4 LocalSize 16 16 1
Source GLSL 450
SourceExtension "GL_EXT_shader_16bit_storage"
Name 4 "main"
Name 9 "v"
Decorate 21 BuiltIn WorkgroupSize
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypePointer Function 7(fvec4)
10: 6(float) Constant 0
11: 7(fvec4) ConstantComposite 10 10 10 10
13: TypeFloat 16
14: TypeVector 13(float16_t) 4
17: TypeInt 32 0
18: TypeVector 17(int) 3
19: 17(int) Constant 16
20: 17(int) Constant 1
21: 18(ivec3) ConstantComposite 19 19 20
4(main): 2 Function None 3
5: Label
9(v): 8(ptr) Variable Function
Store 9(v) 11
12: 7(fvec4) Load 9(v)
15: 14(f16vec4) FConvert 12
16: 7(fvec4) FConvert 15
Return
FunctionEnd

View File

@@ -0,0 +1,11 @@
#version 450 core
#extension GL_EXT_shader_explicit_arithmetic_types_float16 : require
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
void main()
{
vec4 v = vec4(0.0);
vec4(f16vec4(v));
}

View File

@@ -0,0 +1,11 @@
#version 450 core
#extension GL_EXT_shader_16bit_storage : require
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
void main()
{
vec4 v = vec4(0.0);
vec4(f16vec4(v));
}