HLSL: Correct some mistakes for min16 types
- Add missing constructor ops to support float16/int16/uint16 types - Allow half float literals - Correct two errors of double literal parse in HLSL: extension check and postfix
This commit is contained in:
		
							parent
							
								
									845860d565
								
							
						
					
					
						commit
						a00e51b5b2
					
				@ -174,16 +174,22 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
 | 
				
			|||||||
    // Suffix:
 | 
					    // Suffix:
 | 
				
			||||||
    bool isFloat16 = false;
 | 
					    bool isFloat16 = false;
 | 
				
			||||||
    if (ch == 'l' || ch == 'L') {
 | 
					    if (ch == 'l' || ch == 'L') {
 | 
				
			||||||
        parseContext.doubleCheck(ppToken->loc, "double floating-point suffix");
 | 
					        if (parseContext.intermediate.getSource() == EShSourceGlsl)
 | 
				
			||||||
 | 
					            parseContext.doubleCheck(ppToken->loc, "double floating-point suffix");
 | 
				
			||||||
        if (! HasDecimalOrExponent)
 | 
					        if (! HasDecimalOrExponent)
 | 
				
			||||||
            parseContext.ppError(ppToken->loc, "float literal needs a decimal point or exponent", "", "");
 | 
					            parseContext.ppError(ppToken->loc, "float literal needs a decimal point or exponent", "", "");
 | 
				
			||||||
        int ch2 = getChar();
 | 
					        if (parseContext.intermediate.getSource() == EShSourceGlsl) {
 | 
				
			||||||
        if (ch2 != 'f' && ch2 != 'F') {
 | 
					            int ch2 = getChar();
 | 
				
			||||||
            ungetChar();
 | 
					            if (ch2 != 'f' && ch2 != 'F') {
 | 
				
			||||||
            ungetChar();
 | 
					                ungetChar();
 | 
				
			||||||
        } else {
 | 
					                ungetChar();
 | 
				
			||||||
 | 
					            } else {
 | 
				
			||||||
 | 
					                saveName(ch);
 | 
				
			||||||
 | 
					                saveName(ch2);
 | 
				
			||||||
 | 
					                isDouble = 1;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        } else if (parseContext.intermediate.getSource() == EShSourceHlsl) {
 | 
				
			||||||
            saveName(ch);
 | 
					            saveName(ch);
 | 
				
			||||||
            saveName(ch2);
 | 
					 | 
				
			||||||
            isDouble = 1;
 | 
					            isDouble = 1;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    } else if (ch == 'h' || ch == 'H') {
 | 
					    } else if (ch == 'h' || ch == 'H') {
 | 
				
			||||||
@ -201,9 +207,9 @@ int TPpContext::lFloatConst(int len, int ch, TPpToken* ppToken)
 | 
				
			|||||||
                saveName(ch2);
 | 
					                saveName(ch2);
 | 
				
			||||||
                isFloat16 = true;
 | 
					                isFloat16 = true;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else {
 | 
					        } else if (parseContext.intermediate.getSource() == EShSourceHlsl) {
 | 
				
			||||||
            saveName(ch);
 | 
					            saveName(ch);
 | 
				
			||||||
            isFloat16 = false;
 | 
					            isFloat16 = true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    } else if (ch == 'f' || ch == 'F') {
 | 
					    } else if (ch == 'f' || ch == 'F') {
 | 
				
			||||||
        parseContext.profileRequires(ppToken->loc,  EEsProfile, 300, nullptr, "floating-point suffix");
 | 
					        parseContext.profileRequires(ppToken->loc,  EEsProfile, 300, nullptr, "floating-point suffix");
 | 
				
			||||||
 | 
				
			|||||||
@ -3283,6 +3283,9 @@ bool HlslGrammar::acceptLiteral(TIntermTyped*& node)
 | 
				
			|||||||
    case EHTokUintConstant:
 | 
					    case EHTokUintConstant:
 | 
				
			||||||
        node = intermediate.addConstantUnion(token.u, token.loc, true);
 | 
					        node = intermediate.addConstantUnion(token.u, token.loc, true);
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
 | 
					    case EHTokFloat16Constant:
 | 
				
			||||||
 | 
					        node = intermediate.addConstantUnion(token.d, EbtFloat16, token.loc, true);
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
    case EHTokFloatConstant:
 | 
					    case EHTokFloatConstant:
 | 
				
			||||||
        node = intermediate.addConstantUnion(token.d, EbtFloat, token.loc, true);
 | 
					        node = intermediate.addConstantUnion(token.d, EbtFloat, token.loc, true);
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
 | 
				
			|||||||
@ -8320,6 +8320,22 @@ TIntermTyped* HlslParseContext::constructBuiltIn(const TType& type, TOperator op
 | 
				
			|||||||
    // First, convert types as needed.
 | 
					    // First, convert types as needed.
 | 
				
			||||||
    //
 | 
					    //
 | 
				
			||||||
    switch (op) {
 | 
					    switch (op) {
 | 
				
			||||||
 | 
					    case EOpConstructF16Vec2:
 | 
				
			||||||
 | 
					    case EOpConstructF16Vec3:
 | 
				
			||||||
 | 
					    case EOpConstructF16Vec4:
 | 
				
			||||||
 | 
					    case EOpConstructF16Mat2x2:
 | 
				
			||||||
 | 
					    case EOpConstructF16Mat2x3:
 | 
				
			||||||
 | 
					    case EOpConstructF16Mat2x4:
 | 
				
			||||||
 | 
					    case EOpConstructF16Mat3x2:
 | 
				
			||||||
 | 
					    case EOpConstructF16Mat3x3:
 | 
				
			||||||
 | 
					    case EOpConstructF16Mat3x4:
 | 
				
			||||||
 | 
					    case EOpConstructF16Mat4x2:
 | 
				
			||||||
 | 
					    case EOpConstructF16Mat4x3:
 | 
				
			||||||
 | 
					    case EOpConstructF16Mat4x4:
 | 
				
			||||||
 | 
					    case EOpConstructFloat16:
 | 
				
			||||||
 | 
					        basicOp = EOpConstructFloat16;
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    case EOpConstructVec2:
 | 
					    case EOpConstructVec2:
 | 
				
			||||||
    case EOpConstructVec3:
 | 
					    case EOpConstructVec3:
 | 
				
			||||||
    case EOpConstructVec4:
 | 
					    case EOpConstructVec4:
 | 
				
			||||||
@ -8352,6 +8368,13 @@ TIntermTyped* HlslParseContext::constructBuiltIn(const TType& type, TOperator op
 | 
				
			|||||||
        basicOp = EOpConstructDouble;
 | 
					        basicOp = EOpConstructDouble;
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    case EOpConstructI16Vec2:
 | 
				
			||||||
 | 
					    case EOpConstructI16Vec3:
 | 
				
			||||||
 | 
					    case EOpConstructI16Vec4:
 | 
				
			||||||
 | 
					    case EOpConstructInt16:
 | 
				
			||||||
 | 
					        basicOp = EOpConstructInt16;
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    case EOpConstructIVec2:
 | 
					    case EOpConstructIVec2:
 | 
				
			||||||
    case EOpConstructIVec3:
 | 
					    case EOpConstructIVec3:
 | 
				
			||||||
    case EOpConstructIVec4:
 | 
					    case EOpConstructIVec4:
 | 
				
			||||||
@ -8368,6 +8391,13 @@ TIntermTyped* HlslParseContext::constructBuiltIn(const TType& type, TOperator op
 | 
				
			|||||||
        basicOp = EOpConstructInt;
 | 
					        basicOp = EOpConstructInt;
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    case EOpConstructU16Vec2:
 | 
				
			||||||
 | 
					    case EOpConstructU16Vec3:
 | 
				
			||||||
 | 
					    case EOpConstructU16Vec4:
 | 
				
			||||||
 | 
					    case EOpConstructUint16:
 | 
				
			||||||
 | 
					        basicOp = EOpConstructUint16;
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    case EOpConstructUVec2:
 | 
					    case EOpConstructUVec2:
 | 
				
			||||||
    case EOpConstructUVec3:
 | 
					    case EOpConstructUVec3:
 | 
				
			||||||
    case EOpConstructUVec4:
 | 
					    case EOpConstructUVec4:
 | 
				
			||||||
 | 
				
			|||||||
@ -550,6 +550,7 @@ EHlslTokenClass HlslScanContext::tokenizeClass(HlslToken& token)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        case PpAtomConstInt:           parserToken->i = ppToken.ival;       return EHTokIntConstant;
 | 
					        case PpAtomConstInt:           parserToken->i = ppToken.ival;       return EHTokIntConstant;
 | 
				
			||||||
        case PpAtomConstUint:          parserToken->i = ppToken.ival;       return EHTokUintConstant;
 | 
					        case PpAtomConstUint:          parserToken->i = ppToken.ival;       return EHTokUintConstant;
 | 
				
			||||||
 | 
					        case PpAtomConstFloat16:       parserToken->d = ppToken.dval;       return EHTokFloat16Constant;
 | 
				
			||||||
        case PpAtomConstFloat:         parserToken->d = ppToken.dval;       return EHTokFloatConstant;
 | 
					        case PpAtomConstFloat:         parserToken->d = ppToken.dval;       return EHTokFloatConstant;
 | 
				
			||||||
        case PpAtomConstDouble:        parserToken->d = ppToken.dval;       return EHTokDoubleConstant;
 | 
					        case PpAtomConstDouble:        parserToken->d = ppToken.dval;       return EHTokDoubleConstant;
 | 
				
			||||||
        case PpAtomIdentifier:
 | 
					        case PpAtomIdentifier:
 | 
				
			||||||
 | 
				
			|||||||
@ -298,6 +298,7 @@ enum EHlslTokenClass {
 | 
				
			|||||||
    EHTokConstantBuffer,
 | 
					    EHTokConstantBuffer,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // constant
 | 
					    // constant
 | 
				
			||||||
 | 
					    EHTokFloat16Constant,
 | 
				
			||||||
    EHTokFloatConstant,
 | 
					    EHTokFloatConstant,
 | 
				
			||||||
    EHTokDoubleConstant,
 | 
					    EHTokDoubleConstant,
 | 
				
			||||||
    EHTokIntConstant,
 | 
					    EHTokIntConstant,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user