Don't do updatePrecision on float16_t operations

float16_t does not take GLSL precisions and SPIR-V does not
support RelaxedPrecision on float16_t.

Fixes #2894
This commit is contained in:
Greg Fischer 2022-02-24 13:50:41 -07:00
parent ac7f6a293e
commit 79a35ace7c
4 changed files with 93 additions and 4 deletions

View File

@ -0,0 +1,72 @@
spv.float16NoRelaxed.vert
// Module Version 10300
// Generated by (magic number): 8000a
// Id's are bound by 35
Capability Shader
Capability Float16
Capability GroupNonUniform
Capability GroupNonUniformVote
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 11 30
Source GLSL 450
SourceExtension "GL_EXT_shader_explicit_arithmetic_types_float16"
SourceExtension "GL_EXT_shader_subgroup_extended_types_float16"
SourceExtension "GL_KHR_shader_subgroup_basic"
SourceExtension "GL_KHR_shader_subgroup_vote"
Name 4 "main"
Name 8 "valueNoEqual"
Name 11 "gl_SubgroupInvocationID"
Name 15 "tempRes"
Name 26 "Buffer1"
MemberName 26(Buffer1) 0 "result"
Name 28 ""
Name 30 "gl_VertexIndex"
Decorate 11(gl_SubgroupInvocationID) RelaxedPrecision
Decorate 11(gl_SubgroupInvocationID) BuiltIn SubgroupLocalInvocationId
Decorate 12 RelaxedPrecision
Decorate 25 ArrayStride 4
MemberDecorate 26(Buffer1) 0 Offset 0
Decorate 26(Buffer1) Block
Decorate 28 DescriptorSet 0
Decorate 28 Binding 0
Decorate 30(gl_VertexIndex) BuiltIn VertexIndex
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 16
7: TypePointer Function 6(float16_t)
9: TypeInt 32 0
10: TypePointer Input 9(int)
11(gl_SubgroupInvocationID): 10(ptr) Variable Input
14: TypePointer Function 9(int)
17: TypeBool
18: 9(int) Constant 3
20: TypeInt 32 1
21: 20(int) Constant 0
22: 20(int) Constant 16
25: TypeRuntimeArray 9(int)
26(Buffer1): TypeStruct 25
27: TypePointer StorageBuffer 26(Buffer1)
28: 27(ptr) Variable StorageBuffer
29: TypePointer Input 20(int)
30(gl_VertexIndex): 29(ptr) Variable Input
33: TypePointer StorageBuffer 9(int)
4(main): 2 Function None 3
5: Label
8(valueNoEqual): 7(ptr) Variable Function
15(tempRes): 14(ptr) Variable Function
12: 9(int) Load 11(gl_SubgroupInvocationID)
13:6(float16_t) ConvertUToF 12
Store 8(valueNoEqual) 13
16:6(float16_t) Load 8(valueNoEqual)
19: 17(bool) GroupNonUniformAllEqual 18 16
23: 20(int) Select 19 21 22
24: 9(int) Bitcast 23
Store 15(tempRes) 24
31: 20(int) Load 30(gl_VertexIndex)
32: 9(int) Load 15(tempRes)
34: 33(ptr) AccessChain 28 21 31
Store 34 32
Return
FunctionEnd

View File

@ -0,0 +1,16 @@
#version 450
#extension GL_KHR_shader_subgroup_vote: enable
#extension GL_EXT_shader_subgroup_extended_types_float16 : enable
layout(set = 0, binding = 0, std430) buffer Buffer1
{
uint result[];
};
void main (void)
{
uint tempRes;
float16_t valueNoEqual = float16_t(gl_SubgroupInvocationID);
tempRes = subgroupAllEqual(valueNoEqual) ? 0x0 : 0x10;
result[gl_VertexIndex] = tempRes;
}

View File

@ -2766,7 +2766,7 @@ void TIntermBranch::updatePrecision(TPrecisionQualifier parentPrecision)
return;
if (exp->getBasicType() == EbtInt || exp->getBasicType() == EbtUint ||
exp->getBasicType() == EbtFloat || exp->getBasicType() == EbtFloat16) {
exp->getBasicType() == EbtFloat) {
if (parentPrecision != EpqNone && exp->getQualifier().precision == EpqNone) {
exp->propagatePrecision(parentPrecision);
}
@ -3284,7 +3284,7 @@ bool TIntermediate::promoteUnary(TIntermUnary& node)
void TIntermUnary::updatePrecision()
{
if (getBasicType() == EbtInt || getBasicType() == EbtUint ||
getBasicType() == EbtFloat || getBasicType() == EbtFloat16) {
getBasicType() == EbtFloat) {
if (operand->getQualifier().precision > getQualifier().precision)
getQualifier().precision = operand->getQualifier().precision;
}
@ -3785,7 +3785,7 @@ bool TIntermediate::promoteAggregate(TIntermAggregate& node)
void TIntermAggregate::updatePrecision()
{
if (getBasicType() == EbtInt || getBasicType() == EbtUint ||
getBasicType() == EbtFloat || getBasicType() == EbtFloat16) {
getBasicType() == EbtFloat) {
TPrecisionQualifier maxPrecision = EpqNone;
TIntermSequence operands = getSequence();
for (unsigned int i = 0; i < operands.size(); ++i) {
@ -3807,7 +3807,7 @@ void TIntermAggregate::updatePrecision()
void TIntermBinary::updatePrecision()
{
if (getBasicType() == EbtInt || getBasicType() == EbtUint ||
getBasicType() == EbtFloat || getBasicType() == EbtFloat16) {
getBasicType() == EbtFloat) {
if (op == EOpRightShift || op == EOpLeftShift) {
// For shifts get precision from left side only and thus no need to propagate
getQualifier().precision = left->getQualifier().precision;

View File

@ -528,6 +528,7 @@ INSTANTIATE_TEST_SUITE_P(
"spv.vulkan110.int16.frag",
"spv.int32.frag",
"spv.explicittypes.frag",
"spv.float16NoRelaxed.vert",
"spv.float32.frag",
"spv.float64.frag",
"spv.memoryScopeSemantics.comp",