Commit 58d2843c by John Kessenich Committed by GitHub

Merge pull request #498 from amdrexu/bugfix

Parser: Add 64-bit type conversion for specialization constant.
parents 7d01bd6f 64bcfdb6
......@@ -3761,8 +3761,8 @@ spv::Id TGlslangToSpvTraverser::createConversion(glslang::TOperator op, spv::Dec
case glslang::EOpConvInt64ToUint64:
if (builder.isInSpecConstCodeGenMode()) {
// Build zero scalar or vector for OpIAdd.
zero = (op == glslang::EOpConvUintToInt64 ||
op == glslang::EOpConvIntToUint64) ? builder.makeUint64Constant(0) : builder.makeUintConstant(0);
zero = (op == glslang::EOpConvUint64ToInt64 ||
op == glslang::EOpConvInt64ToUint64) ? builder.makeUint64Constant(0) : builder.makeUintConstant(0);
zero = makeSmearedConstant(zero, vectorSize);
// Use OpIAdd, instead of OpBitcast to do the conversion when
// generating for OpSpecConstantOp instruction.
......
......@@ -8,7 +8,7 @@ Linked fragment stage:
Missing functionality: shader int64
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 455
// Id's are bound by 478
Capability Shader
Capability Float64
......@@ -64,6 +64,11 @@ Missing functionality: shader int64
Decorate 452(Block) Block
Decorate 454(block) DescriptorSet 0
Decorate 454(block) Binding 1
Decorate 455 SpecId 100
Decorate 456 SpecId 101
Decorate 457 SpecId 102
Decorate 458 SpecId 103
Decorate 459 SpecId 104
2: TypeVoid
3: TypeFunction 2
14: TypeInt 64 1
......@@ -145,6 +150,29 @@ Missing functionality: shader int64
452(Block): TypeStruct 134(ivec3) 36(int)
453: TypePointer Uniform 452(Block)
454(block): 453(ptr) Variable Uniform
455: 14(int) SpecConstant 4294967286 4294967295
456: 36(int) SpecConstant 20 0
457: 27(int) SpecConstant 4294967291
458: 17(int) SpecConstant 4
459: 53(bool) SpecConstantTrue
460: 53(bool) SpecConstantOp 171 455 67
461: 53(bool) SpecConstantOp 171 456 67
462: 14(int) SpecConstantOp 169 459 59 58
463: 36(int) SpecConstantOp 169 459 68 67
464: 27(int) SpecConstantOp 114 455
465: 14(int) SpecConstantOp 114 457
466: 17(int) SpecConstantOp 113 456
467: 36(int) SpecConstantOp 113 458
468: 14(int) SpecConstantOp 128 456 67
469: 36(int) SpecConstantOp 128 455 67
470: 17(int) SpecConstantOp 113 456
471: 27(int) SpecConstantOp 128 470 217
472: 14(int) SpecConstantOp 114 457
473: 36(int) SpecConstantOp 128 472 67
474: 27(int) SpecConstantOp 114 455
475: 17(int) SpecConstantOp 128 474 217
476: 36(int) SpecConstantOp 113 458
477: 14(int) SpecConstantOp 128 476 67
4(main): 2 Function None 3
5: Label
Return
......
......@@ -61,6 +61,7 @@ Linked vertex stage:
38: TypeFloat 64
39: 38(float) SpecConstant 1413754136 1074340347
40: 6(float) SpecConstant 1078523331
41: 38(float) SpecConstantOp 115 40
50: 8(int) SpecConstant 12
51: TypeArray 7(fvec4) 50
52: TypePointer Input 51
......@@ -69,6 +70,7 @@ Linked vertex stage:
63: 33(int) SpecConstant 2
67: 38(float) SpecConstant 1413754136 1074340347
68: 6(float) SpecConstant 1078523331
69: 38(float) SpecConstantOp 115 68
75: TypePointer Function 8(int)
77: 8(int) SpecConstant 8
4(main): 2 Function None 3
......@@ -87,7 +89,6 @@ Linked vertex stage:
Store 20(color) 37
Branch 32
32: Label
41: 38(float) FConvert 40
42: 38(float) FDiv 39 41
43: 6(float) FConvert 42
44: 7(fvec4) Load 20(color)
......@@ -119,7 +120,6 @@ Linked vertex stage:
Store 20(color) 66
Branch 62
62: Label
69: 38(float) FConvert 68
70: 38(float) FDiv 67 69
71: 6(float) FConvert 70
72: 7(fvec4) Load 20(color)
......
......@@ -225,4 +225,37 @@ void builtinFuncs()
// notEqual()
bv = notEqual(u64v, u64vec3(u64));
bv.xy = notEqual(i64v, i64vec2(i64));
}
\ No newline at end of file
}
// Type conversion for specialization constant
layout(constant_id = 100) const int64_t si64 = -10L;
layout(constant_id = 101) const uint64_t su64 = 20UL;
layout(constant_id = 102) const int si = -5;
layout(constant_id = 103) const uint su = 4;
layout(constant_id = 104) const bool sb = true;
// bool <-> int64/uint64
const bool i64_to_b = bool(si64);
const bool u64_to_b = bool(su64);
const int64_t b_to_i64 = int64_t(sb);
const uint64_t b_to_u64 = uint64_t(sb);
// int <-> int64
const int i64_to_i = int(si64);
const int64_t i_to_i64 = int64_t(si);
// uint <-> uint64
const uint u64_to_u = uint(su64);
const uint64_t u_to_u64 = uint64_t(su);
// int64 <-> uint64
const int64_t u64_to_i64 = int64_t(su64);
const uint64_t i64_to_u64 = uint64_t(si64);
// int <-> uint64
const int u64_to_i = int(su64);
const uint64_t i_to_u64 = uint64_t(si);
// uint <-> int64
const uint i64_to_u = uint(si64);
const int64_t u_to_i64 = int64_t(su);
\ No newline at end of file
......@@ -4,12 +4,16 @@ layout(constant_id = 200) const float sp_float = 3.1415926;
layout(constant_id = 201) const int sp_int = 10;
layout(constant_id = 202) const uint sp_uint = 100;
layout(constant_id = 203) const int sp_sint = -10;
layout(constant_id = 204) const double sp_double = 2.718281828459;
//
// Scalars
//
// float <-> double conversion
const float float_from_double = float(sp_double);
const double double_from_float = double(sp_float);
// uint/int <-> bool conversion
const bool bool_from_int = bool(sp_int);
const bool bool_from_uint = bool(sp_uint);
......
......@@ -1444,6 +1444,8 @@ bool TIntermediate::isSpecializationOperation(const TIntermOperator& node) const
case EOpIndexIndirect:
case EOpIndexDirectStruct:
case EOpVectorSwizzle:
case EOpConvFloatToDouble:
case EOpConvDoubleToFloat:
return true;
default:
return false;
......@@ -1474,6 +1476,20 @@ bool TIntermediate::isSpecializationOperation(const TIntermOperator& node) const
case EOpConvBoolToInt:
case EOpConvIntToUint:
case EOpConvBoolToUint:
case EOpConvInt64ToBool:
case EOpConvBoolToInt64:
case EOpConvUint64ToBool:
case EOpConvBoolToUint64:
case EOpConvInt64ToInt:
case EOpConvIntToInt64:
case EOpConvUint64ToUint:
case EOpConvUintToUint64:
case EOpConvInt64ToUint64:
case EOpConvUint64ToInt64:
case EOpConvInt64ToUint:
case EOpConvUintToInt64:
case EOpConvUint64ToInt:
case EOpConvIntToUint64:
// unary operations
case EOpNegative:
......
......@@ -4942,7 +4942,7 @@ const TFunction* TParseContext::findFunction120(const TSourceLoc& loc, const TFu
// "When function calls are resolved, an exact type match for all the arguments
// is sought. If an exact match is found, all other functions are ignored, and
// the exact match is used. If no exact match is found, then the implicit
// conversions in section 4.1.10 Implicit Conversions will be applied to find
// conversions in section 4.1.10 Implicit Conversions will be applied to find
// a match. Mismatched types on input parameters (in or inout or default) must
// have a conversion from the calling argument type to the formal parameter type.
// Mismatched types on output parameters (out or inout) must have a conversion
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment