mirror of
https://github.com/KhronosGroup/glslang
synced 2024-11-09 12:00:05 +00:00
Add Float16/Int8/Int16 capabilities for private variables and function parameters
This commit is contained in:
parent
9f538c7207
commit
2b2316d3fa
17
SPIRV/GlslangToSpv.cpp
Executable file → Normal file
17
SPIRV/GlslangToSpv.cpp
Executable file → Normal file
@ -2878,6 +2878,11 @@ spv::Id TGlslangToSpvTraverser::createSpvVariable(const glslang::TIntermSymbol*
|
||||
builder.addCapability(spv::CapabilityStorageUniformBufferBlock16);
|
||||
break;
|
||||
default:
|
||||
if (node->getType().containsBasicType(glslang::EbtFloat16))
|
||||
builder.addCapability(spv::CapabilityFloat16);
|
||||
if (node->getType().containsBasicType(glslang::EbtInt16) ||
|
||||
node->getType().containsBasicType(glslang::EbtUint16))
|
||||
builder.addCapability(spv::CapabilityInt16);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -2894,6 +2899,8 @@ spv::Id TGlslangToSpvTraverser::createSpvVariable(const glslang::TIntermSymbol*
|
||||
} else if (storageClass == spv::StorageClassStorageBuffer) {
|
||||
builder.addExtension(spv::E_SPV_KHR_8bit_storage);
|
||||
builder.addCapability(spv::CapabilityStorageBuffer8BitAccess);
|
||||
} else {
|
||||
builder.addCapability(spv::CapabilityInt8);
|
||||
}
|
||||
}
|
||||
|
||||
@ -3799,6 +3806,16 @@ void TGlslangToSpvTraverser::makeFunctions(const glslang::TIntermSequence& glslF
|
||||
symbolValues[parameters[p]->getAsSymbolNode()->getId()] = function->getParamId(p);
|
||||
// give a name too
|
||||
builder.addName(function->getParamId(p), parameters[p]->getAsSymbolNode()->getName().c_str());
|
||||
|
||||
const glslang::TType& paramType = parameters[p]->getAsTyped()->getType();
|
||||
if (paramType.containsBasicType(glslang::EbtInt8) ||
|
||||
paramType.containsBasicType(glslang::EbtUint8))
|
||||
builder.addCapability(spv::CapabilityInt8);
|
||||
if (paramType.containsBasicType(glslang::EbtInt16) ||
|
||||
paramType.containsBasicType(glslang::EbtUint16))
|
||||
builder.addCapability(spv::CapabilityInt16);
|
||||
if (paramType.containsBasicType(glslang::EbtFloat16))
|
||||
builder.addCapability(spv::CapabilityFloat16);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
62
Test/baseResults/spv.functionParameterTypes.frag.out
Normal file
62
Test/baseResults/spv.functionParameterTypes.frag.out
Normal file
@ -0,0 +1,62 @@
|
||||
spv.functionParameterTypes.frag
|
||||
// Module Version 10000
|
||||
// Generated by (magic number): 80007
|
||||
// Id's are bound by 34
|
||||
|
||||
Capability Shader
|
||||
Capability Float16
|
||||
Capability Int64
|
||||
Capability Int16
|
||||
Capability Int8
|
||||
1: ExtInstImport "GLSL.std.450"
|
||||
MemoryModel Logical GLSL450
|
||||
EntryPoint Fragment 4 "main"
|
||||
ExecutionMode 4 OriginUpperLeft
|
||||
Source GLSL 460
|
||||
SourceExtension "GL_EXT_shader_explicit_arithmetic_types_float16"
|
||||
SourceExtension "GL_EXT_shader_explicit_arithmetic_types_int16"
|
||||
SourceExtension "GL_EXT_shader_explicit_arithmetic_types_int64"
|
||||
SourceExtension "GL_EXT_shader_explicit_arithmetic_types_int8"
|
||||
Name 4 "main"
|
||||
Name 29 "f(i81;u81;i161;u161;i641;u641;f161;"
|
||||
Name 22 "i8"
|
||||
Name 23 "u8"
|
||||
Name 24 "i16"
|
||||
Name 25 "u16"
|
||||
Name 26 "i64"
|
||||
Name 27 "u64"
|
||||
Name 28 "f16"
|
||||
2: TypeVoid
|
||||
3: TypeFunction 2
|
||||
6: TypeInt 8 1
|
||||
7: TypePointer Function 6(int8_t)
|
||||
8: TypeInt 8 0
|
||||
9: TypePointer Function 8(int8_t)
|
||||
10: TypeInt 16 1
|
||||
11: TypePointer Function 10(int16_t)
|
||||
12: TypeInt 16 0
|
||||
13: TypePointer Function 12(int16_t)
|
||||
14: TypeInt 64 1
|
||||
15: TypePointer Function 14(int64_t)
|
||||
16: TypeInt 64 0
|
||||
17: TypePointer Function 16(int64_t)
|
||||
18: TypeFloat 16
|
||||
19: TypePointer Function 18(float16_t)
|
||||
20: TypeInt 32 1
|
||||
21: TypeFunction 20(int) 7(ptr) 9(ptr) 11(ptr) 13(ptr) 15(ptr) 17(ptr) 19(ptr)
|
||||
31: 20(int) Constant 0
|
||||
4(main): 2 Function None 3
|
||||
5: Label
|
||||
Return
|
||||
FunctionEnd
|
||||
29(f(i81;u81;i161;u161;i641;u641;f161;): 20(int) Function None 21
|
||||
22(i8): 7(ptr) FunctionParameter
|
||||
23(u8): 9(ptr) FunctionParameter
|
||||
24(i16): 11(ptr) FunctionParameter
|
||||
25(u16): 13(ptr) FunctionParameter
|
||||
26(i64): 15(ptr) FunctionParameter
|
||||
27(u64): 17(ptr) FunctionParameter
|
||||
28(f16): 19(ptr) FunctionParameter
|
||||
30: Label
|
||||
ReturnValue 31
|
||||
FunctionEnd
|
54
Test/baseResults/spv.privateVariableTypes.frag.out
Normal file
54
Test/baseResults/spv.privateVariableTypes.frag.out
Normal file
@ -0,0 +1,54 @@
|
||||
spv.privateVariableTypes.frag
|
||||
// Module Version 10000
|
||||
// Generated by (magic number): 80007
|
||||
// Id's are bound by 27
|
||||
|
||||
Capability Shader
|
||||
Capability Float16
|
||||
Capability Int64
|
||||
Capability Int16
|
||||
Capability Int8
|
||||
1: ExtInstImport "GLSL.std.450"
|
||||
MemoryModel Logical GLSL450
|
||||
EntryPoint Fragment 4 "main"
|
||||
ExecutionMode 4 OriginUpperLeft
|
||||
Source GLSL 460
|
||||
SourceExtension "GL_EXT_shader_explicit_arithmetic_types_float16"
|
||||
SourceExtension "GL_EXT_shader_explicit_arithmetic_types_int16"
|
||||
SourceExtension "GL_EXT_shader_explicit_arithmetic_types_int64"
|
||||
SourceExtension "GL_EXT_shader_explicit_arithmetic_types_int8"
|
||||
Name 4 "main"
|
||||
Name 8 "i8"
|
||||
Name 11 "u8"
|
||||
Name 14 "i16"
|
||||
Name 17 "u16"
|
||||
Name 20 "i64"
|
||||
Name 23 "u64"
|
||||
Name 26 "f16"
|
||||
2: TypeVoid
|
||||
3: TypeFunction 2
|
||||
6: TypeInt 8 1
|
||||
7: TypePointer Private 6(int8_t)
|
||||
8(i8): 7(ptr) Variable Private
|
||||
9: TypeInt 8 0
|
||||
10: TypePointer Private 9(int8_t)
|
||||
11(u8): 10(ptr) Variable Private
|
||||
12: TypeInt 16 1
|
||||
13: TypePointer Private 12(int16_t)
|
||||
14(i16): 13(ptr) Variable Private
|
||||
15: TypeInt 16 0
|
||||
16: TypePointer Private 15(int16_t)
|
||||
17(u16): 16(ptr) Variable Private
|
||||
18: TypeInt 64 1
|
||||
19: TypePointer Private 18(int64_t)
|
||||
20(i64): 19(ptr) Variable Private
|
||||
21: TypeInt 64 0
|
||||
22: TypePointer Private 21(int64_t)
|
||||
23(u64): 22(ptr) Variable Private
|
||||
24: TypeFloat 16
|
||||
25: TypePointer Private 24(float16_t)
|
||||
26(f16): 25(ptr) Variable Private
|
||||
4(main): 2 Function None 3
|
||||
5: Label
|
||||
Return
|
||||
FunctionEnd
|
20
Test/spv.functionParameterTypes.frag
Normal file
20
Test/spv.functionParameterTypes.frag
Normal file
@ -0,0 +1,20 @@
|
||||
#version 460 core
|
||||
#extension GL_EXT_shader_explicit_arithmetic_types_int64 : enable
|
||||
#extension GL_EXT_shader_explicit_arithmetic_types_int8 : enable
|
||||
#extension GL_EXT_shader_explicit_arithmetic_types_int16 : enable
|
||||
#extension GL_EXT_shader_explicit_arithmetic_types_float16 : enable
|
||||
|
||||
int f(int8_t i8,
|
||||
uint8_t u8,
|
||||
int16_t i16,
|
||||
uint16_t u16,
|
||||
int64_t i64,
|
||||
uint64_t u64,
|
||||
float16_t f16)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
}
|
17
Test/spv.privateVariableTypes.frag
Normal file
17
Test/spv.privateVariableTypes.frag
Normal file
@ -0,0 +1,17 @@
|
||||
#version 460 core
|
||||
#extension GL_EXT_shader_explicit_arithmetic_types_int64 : enable
|
||||
#extension GL_EXT_shader_explicit_arithmetic_types_int8 : enable
|
||||
#extension GL_EXT_shader_explicit_arithmetic_types_int16 : enable
|
||||
#extension GL_EXT_shader_explicit_arithmetic_types_float16 : enable
|
||||
|
||||
int8_t i8;
|
||||
uint8_t u8;
|
||||
int16_t i16;
|
||||
uint16_t u16;
|
||||
int64_t i64;
|
||||
uint64_t u64;
|
||||
float16_t f16;
|
||||
|
||||
void main()
|
||||
{
|
||||
}
|
@ -307,6 +307,7 @@ INSTANTIATE_TEST_CASE_P(
|
||||
"spv.functionCall.frag",
|
||||
"spv.functionNestedOpaque.vert",
|
||||
"spv.functionSemantics.frag",
|
||||
"spv.functionParameterTypes.frag",
|
||||
"spv.GeometryShaderPassthrough.geom",
|
||||
"spv.interpOps.frag",
|
||||
"spv.int64.frag",
|
||||
@ -334,6 +335,7 @@ INSTANTIATE_TEST_CASE_P(
|
||||
"spv.precision.frag",
|
||||
"spv.precisionNonESSamp.frag",
|
||||
"spv.prepost.frag",
|
||||
"spv.privateVariableTypes.frag",
|
||||
"spv.qualifiers.vert",
|
||||
"spv.sample.frag",
|
||||
"spv.sampleId.frag",
|
||||
|
Loading…
Reference in New Issue
Block a user