2016-03-13 03:11:22 +00:00
|
|
|
//
|
2017-01-06 19:34:14 +00:00
|
|
|
// Copyright (C) 2016 Google, Inc.
|
|
|
|
// Copyright (C) 2016 LunarG, Inc.
|
2016-03-13 03:11:22 +00:00
|
|
|
//
|
2017-01-06 19:34:14 +00:00
|
|
|
// All rights reserved.
|
2016-03-13 03:11:22 +00:00
|
|
|
//
|
2017-01-06 19:34:14 +00:00
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions
|
|
|
|
// are met:
|
2016-03-13 03:11:22 +00:00
|
|
|
//
|
|
|
|
// Redistributions of source code must retain the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer.
|
|
|
|
//
|
|
|
|
// Redistributions in binary form must reproduce the above
|
|
|
|
// copyright notice, this list of conditions and the following
|
|
|
|
// disclaimer in the documentation and/or other materials provided
|
|
|
|
// with the distribution.
|
|
|
|
//
|
|
|
|
// Neither the name of Google, Inc., nor the names of its
|
|
|
|
// contributors may be used to endorse or promote products derived
|
|
|
|
// from this software without specific prior written permission.
|
|
|
|
//
|
2017-01-06 19:34:14 +00:00
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
|
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
|
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
|
|
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
|
|
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
// POSSIBILITY OF SUCH DAMAGE.
|
2016-03-13 03:11:22 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef EHLSLTOKENS_H_
|
|
|
|
#define EHLSLTOKENS_H_
|
|
|
|
|
|
|
|
namespace glslang {
|
|
|
|
|
|
|
|
enum EHlslTokenClass {
|
|
|
|
EHTokNone = 0,
|
|
|
|
|
|
|
|
// qualifiers
|
|
|
|
EHTokStatic,
|
|
|
|
EHTokConst,
|
|
|
|
EHTokSNorm,
|
|
|
|
EHTokUnorm,
|
|
|
|
EHTokExtern,
|
|
|
|
EHTokUniform,
|
|
|
|
EHTokVolatile,
|
2016-06-13 05:52:12 +00:00
|
|
|
EHTokPrecise,
|
2016-03-13 03:11:22 +00:00
|
|
|
EHTokShared,
|
|
|
|
EHTokGroupShared,
|
|
|
|
EHTokLinear,
|
|
|
|
EHTokCentroid,
|
|
|
|
EHTokNointerpolation,
|
|
|
|
EHTokNoperspective,
|
|
|
|
EHTokSample,
|
|
|
|
EHTokRowMajor,
|
|
|
|
EHTokColumnMajor,
|
|
|
|
EHTokPackOffset,
|
2016-07-13 02:44:32 +00:00
|
|
|
EHTokIn,
|
|
|
|
EHTokOut,
|
|
|
|
EHTokInOut,
|
2016-08-17 16:22:08 +00:00
|
|
|
EHTokLayout,
|
2017-02-13 00:50:28 +00:00
|
|
|
EHTokGloballyCoherent,
|
2017-03-15 15:05:14 +00:00
|
|
|
EHTokInline,
|
2016-03-13 03:11:22 +00:00
|
|
|
|
2016-11-17 22:04:20 +00:00
|
|
|
// primitive types
|
|
|
|
EHTokPoint,
|
|
|
|
EHTokLine,
|
|
|
|
EHTokTriangle,
|
|
|
|
EHTokLineAdj,
|
|
|
|
EHTokTriangleAdj,
|
|
|
|
|
|
|
|
// stream out types
|
|
|
|
EHTokPointStream,
|
|
|
|
EHTokLineStream,
|
|
|
|
EHTokTriangleStream,
|
|
|
|
|
Add basic HS/DS implementation.
This obsoletes WIP PR #704, which was built on the pre entry point wrapping master. New version
here uses entry point wrapping.
This is a limited implementation of tessellation shaders. In particular, the following are not functional,
and will be added as separate stages to reduce the size of each PR.
* patchconstantfunctions accepting per-control-point input values, such as
const OutputPatch <hs_out_t, 3> cpv are not implemented.
* patchconstantfunctions whose signature requires an aggregate input type such as
a structure containing builtin variables. Code to synthesize such calls is not
yet present.
These restrictions will be relaxed as soon as possible. Simple cases can compile now: see for example
Test/hulsl.hull.1.tesc - e.g, writing to inner and outer tessellation factors.
PCF invocation is synthesized as an entry point epilogue protected behind a barrier and a test on
invocation ID == 0. If there is an existing invocation ID variable it will be used, otherwise one is
added to the linkage. The PCF and the shader EP interfaces are unioned and builtins appearing in
the PCF but not the EP are also added to the linkage and synthesized as shader inputs.
Parameter matching to (eventually arbitrary) PCF signatures is by builtin variable type. Any user
variables in the PCF signature will result in an error. Overloaded PCF functions will also result in
an error.
[domain()], [partitioning()], [outputtopology()], [outputcontrolpoints()], and [patchconstantfunction()]
attributes to the shader entry point are in place, with the exception of the Pow2 partitioning mode.
2017-01-07 15:54:10 +00:00
|
|
|
// Tessellation patches
|
|
|
|
EHTokInputPatch,
|
|
|
|
EHTokOutputPatch,
|
|
|
|
|
2016-03-13 03:11:22 +00:00
|
|
|
// template types
|
|
|
|
EHTokBuffer,
|
|
|
|
EHTokVector,
|
|
|
|
EHTokMatrix,
|
|
|
|
|
|
|
|
// scalar types
|
|
|
|
EHTokVoid,
|
2016-09-20 19:22:58 +00:00
|
|
|
EHTokString,
|
2016-03-13 03:11:22 +00:00
|
|
|
EHTokBool,
|
|
|
|
EHTokInt,
|
|
|
|
EHTokUint,
|
|
|
|
EHTokDword,
|
|
|
|
EHTokHalf,
|
|
|
|
EHTokFloat,
|
|
|
|
EHTokDouble,
|
|
|
|
EHTokMin16float,
|
|
|
|
EHTokMin10float,
|
|
|
|
EHTokMin16int,
|
|
|
|
EHTokMin12int,
|
|
|
|
EHTokMin16uint,
|
|
|
|
|
|
|
|
// vector types
|
|
|
|
EHTokBool1,
|
|
|
|
EHTokBool2,
|
|
|
|
EHTokBool3,
|
|
|
|
EHTokBool4,
|
|
|
|
EHTokFloat1,
|
|
|
|
EHTokFloat2,
|
|
|
|
EHTokFloat3,
|
|
|
|
EHTokFloat4,
|
|
|
|
EHTokInt1,
|
|
|
|
EHTokInt2,
|
|
|
|
EHTokInt3,
|
|
|
|
EHTokInt4,
|
|
|
|
EHTokDouble1,
|
|
|
|
EHTokDouble2,
|
|
|
|
EHTokDouble3,
|
|
|
|
EHTokDouble4,
|
|
|
|
EHTokUint1,
|
|
|
|
EHTokUint2,
|
|
|
|
EHTokUint3,
|
|
|
|
EHTokUint4,
|
HLSL: allow scalar type keywords as identifiers, and add half type support.
HLSL allows type keywords to also be identifiers, so a sequence such as "float half = 3" is
valid, or more bizzarely, something like "float.float = int.uint + bool;"
There are places this is not supported. E.g, it's permitted for struct members, but not struct
names or functions. Also, vector or matrix types such as "float3" are not permitted as
identifiers.
This PR adds that support, as well as support for the "half" type. In production shaders,
this was seen with variables named "half". The PR attempts to support this without breaking
useful grammar errors such as "; expected" at the end of unterminated statements, so it errs
on that side at the possible expense of failing to accept valid constructs containing a type
keyword identifier. If others are discovered, they can be added.
Also, half is now accepted as a valid type, alongside the min*float types.
2016-12-27 01:45:52 +00:00
|
|
|
EHTokHalf1,
|
|
|
|
EHTokHalf2,
|
|
|
|
EHTokHalf3,
|
|
|
|
EHTokHalf4,
|
2016-10-27 01:18:55 +00:00
|
|
|
EHTokMin16float1,
|
|
|
|
EHTokMin16float2,
|
|
|
|
EHTokMin16float3,
|
|
|
|
EHTokMin16float4,
|
|
|
|
EHTokMin10float1,
|
|
|
|
EHTokMin10float2,
|
|
|
|
EHTokMin10float3,
|
|
|
|
EHTokMin10float4,
|
|
|
|
EHTokMin16int1,
|
|
|
|
EHTokMin16int2,
|
|
|
|
EHTokMin16int3,
|
|
|
|
EHTokMin16int4,
|
|
|
|
EHTokMin12int1,
|
|
|
|
EHTokMin12int2,
|
|
|
|
EHTokMin12int3,
|
|
|
|
EHTokMin12int4,
|
|
|
|
EHTokMin16uint1,
|
|
|
|
EHTokMin16uint2,
|
|
|
|
EHTokMin16uint3,
|
|
|
|
EHTokMin16uint4,
|
2016-03-13 03:11:22 +00:00
|
|
|
|
|
|
|
// matrix types
|
|
|
|
EHTokInt1x1,
|
|
|
|
EHTokInt1x2,
|
|
|
|
EHTokInt1x3,
|
|
|
|
EHTokInt1x4,
|
|
|
|
EHTokInt2x1,
|
|
|
|
EHTokInt2x2,
|
|
|
|
EHTokInt2x3,
|
|
|
|
EHTokInt2x4,
|
|
|
|
EHTokInt3x1,
|
|
|
|
EHTokInt3x2,
|
|
|
|
EHTokInt3x3,
|
|
|
|
EHTokInt3x4,
|
|
|
|
EHTokInt4x1,
|
|
|
|
EHTokInt4x2,
|
|
|
|
EHTokInt4x3,
|
|
|
|
EHTokInt4x4,
|
2016-06-08 18:50:56 +00:00
|
|
|
EHTokUint1x1,
|
|
|
|
EHTokUint1x2,
|
|
|
|
EHTokUint1x3,
|
|
|
|
EHTokUint1x4,
|
|
|
|
EHTokUint2x1,
|
|
|
|
EHTokUint2x2,
|
|
|
|
EHTokUint2x3,
|
|
|
|
EHTokUint2x4,
|
|
|
|
EHTokUint3x1,
|
|
|
|
EHTokUint3x2,
|
|
|
|
EHTokUint3x3,
|
|
|
|
EHTokUint3x4,
|
|
|
|
EHTokUint4x1,
|
|
|
|
EHTokUint4x2,
|
|
|
|
EHTokUint4x3,
|
|
|
|
EHTokUint4x4,
|
|
|
|
EHTokBool1x1,
|
|
|
|
EHTokBool1x2,
|
|
|
|
EHTokBool1x3,
|
|
|
|
EHTokBool1x4,
|
|
|
|
EHTokBool2x1,
|
|
|
|
EHTokBool2x2,
|
|
|
|
EHTokBool2x3,
|
|
|
|
EHTokBool2x4,
|
|
|
|
EHTokBool3x1,
|
|
|
|
EHTokBool3x2,
|
|
|
|
EHTokBool3x3,
|
|
|
|
EHTokBool3x4,
|
|
|
|
EHTokBool4x1,
|
|
|
|
EHTokBool4x2,
|
|
|
|
EHTokBool4x3,
|
|
|
|
EHTokBool4x4,
|
2016-03-13 03:11:22 +00:00
|
|
|
EHTokFloat1x1,
|
|
|
|
EHTokFloat1x2,
|
|
|
|
EHTokFloat1x3,
|
|
|
|
EHTokFloat1x4,
|
|
|
|
EHTokFloat2x1,
|
|
|
|
EHTokFloat2x2,
|
|
|
|
EHTokFloat2x3,
|
|
|
|
EHTokFloat2x4,
|
|
|
|
EHTokFloat3x1,
|
|
|
|
EHTokFloat3x2,
|
|
|
|
EHTokFloat3x3,
|
|
|
|
EHTokFloat3x4,
|
|
|
|
EHTokFloat4x1,
|
|
|
|
EHTokFloat4x2,
|
|
|
|
EHTokFloat4x3,
|
|
|
|
EHTokFloat4x4,
|
|
|
|
EHTokDouble1x1,
|
|
|
|
EHTokDouble1x2,
|
|
|
|
EHTokDouble1x3,
|
|
|
|
EHTokDouble1x4,
|
|
|
|
EHTokDouble2x1,
|
|
|
|
EHTokDouble2x2,
|
|
|
|
EHTokDouble2x3,
|
|
|
|
EHTokDouble2x4,
|
|
|
|
EHTokDouble3x1,
|
|
|
|
EHTokDouble3x2,
|
|
|
|
EHTokDouble3x3,
|
|
|
|
EHTokDouble3x4,
|
|
|
|
EHTokDouble4x1,
|
|
|
|
EHTokDouble4x2,
|
|
|
|
EHTokDouble4x3,
|
|
|
|
EHTokDouble4x4,
|
|
|
|
|
|
|
|
// texturing types
|
|
|
|
EHTokSampler,
|
|
|
|
EHTokSampler1d,
|
|
|
|
EHTokSampler2d,
|
|
|
|
EHTokSampler3d,
|
|
|
|
EHTokSamplerCube,
|
|
|
|
EHTokSamplerState,
|
|
|
|
EHTokSamplerComparisonState,
|
|
|
|
EHTokTexture,
|
|
|
|
EHTokTexture1d,
|
|
|
|
EHTokTexture1darray,
|
|
|
|
EHTokTexture2d,
|
|
|
|
EHTokTexture2darray,
|
|
|
|
EHTokTexture3d,
|
|
|
|
EHTokTextureCube,
|
2016-06-29 16:58:58 +00:00
|
|
|
EHTokTextureCubearray,
|
|
|
|
EHTokTexture2DMS,
|
|
|
|
EHTokTexture2DMSarray,
|
2016-10-04 22:58:14 +00:00
|
|
|
EHTokRWTexture1d,
|
|
|
|
EHTokRWTexture1darray,
|
|
|
|
EHTokRWTexture2d,
|
|
|
|
EHTokRWTexture2darray,
|
|
|
|
EHTokRWTexture3d,
|
|
|
|
EHTokRWBuffer,
|
2016-03-13 03:11:22 +00:00
|
|
|
|
2017-02-13 00:50:28 +00:00
|
|
|
// Structure buffer variants
|
|
|
|
EHTokAppendStructuredBuffer,
|
|
|
|
EHTokByteAddressBuffer,
|
|
|
|
EHTokConsumeStructuredBuffer,
|
|
|
|
EHTokRWByteAddressBuffer,
|
|
|
|
EHTokRWStructuredBuffer,
|
|
|
|
EHTokStructuredBuffer,
|
|
|
|
|
2016-03-13 03:11:22 +00:00
|
|
|
// variable, user type, ...
|
|
|
|
EHTokIdentifier,
|
2017-03-04 00:01:01 +00:00
|
|
|
EHTokClass,
|
2016-03-13 03:11:22 +00:00
|
|
|
EHTokStruct,
|
2016-07-25 22:05:33 +00:00
|
|
|
EHTokCBuffer,
|
|
|
|
EHTokTBuffer,
|
2016-03-13 03:11:22 +00:00
|
|
|
EHTokTypedef,
|
2017-03-22 17:38:22 +00:00
|
|
|
EHTokThis,
|
2017-03-30 22:22:26 +00:00
|
|
|
EHTokNamespace,
|
2017-04-25 15:30:28 +00:00
|
|
|
EHTokConstantBuffer,
|
2016-03-13 03:11:22 +00:00
|
|
|
|
|
|
|
// constant
|
|
|
|
EHTokFloatConstant,
|
|
|
|
EHTokDoubleConstant,
|
|
|
|
EHTokIntConstant,
|
|
|
|
EHTokUintConstant,
|
|
|
|
EHTokBoolConstant,
|
2016-08-22 22:13:47 +00:00
|
|
|
EHTokStringConstant,
|
2016-03-13 03:11:22 +00:00
|
|
|
|
|
|
|
// control flow
|
|
|
|
EHTokFor,
|
|
|
|
EHTokDo,
|
|
|
|
EHTokWhile,
|
|
|
|
EHTokBreak,
|
|
|
|
EHTokContinue,
|
|
|
|
EHTokIf,
|
|
|
|
EHTokElse,
|
|
|
|
EHTokDiscard,
|
|
|
|
EHTokReturn,
|
|
|
|
EHTokSwitch,
|
|
|
|
EHTokCase,
|
|
|
|
EHTokDefault,
|
|
|
|
|
|
|
|
// expressions
|
|
|
|
EHTokLeftOp,
|
|
|
|
EHTokRightOp,
|
|
|
|
EHTokIncOp,
|
|
|
|
EHTokDecOp,
|
|
|
|
EHTokLeOp,
|
|
|
|
EHTokGeOp,
|
|
|
|
EHTokEqOp,
|
|
|
|
EHTokNeOp,
|
|
|
|
EHTokAndOp,
|
|
|
|
EHTokOrOp,
|
|
|
|
EHTokXorOp,
|
2016-05-04 05:17:20 +00:00
|
|
|
EHTokAssign,
|
2016-03-13 03:11:22 +00:00
|
|
|
EHTokMulAssign,
|
|
|
|
EHTokDivAssign,
|
|
|
|
EHTokAddAssign,
|
|
|
|
EHTokModAssign,
|
|
|
|
EHTokLeftAssign,
|
|
|
|
EHTokRightAssign,
|
|
|
|
EHTokAndAssign,
|
|
|
|
EHTokXorAssign,
|
|
|
|
EHTokOrAssign,
|
|
|
|
EHTokSubAssign,
|
|
|
|
EHTokLeftParen,
|
|
|
|
EHTokRightParen,
|
|
|
|
EHTokLeftBracket,
|
|
|
|
EHTokRightBracket,
|
|
|
|
EHTokLeftBrace,
|
|
|
|
EHTokRightBrace,
|
|
|
|
EHTokDot,
|
|
|
|
EHTokComma,
|
|
|
|
EHTokColon,
|
2017-03-11 01:03:43 +00:00
|
|
|
EHTokColonColon,
|
2016-03-13 03:11:22 +00:00
|
|
|
EHTokSemicolon,
|
|
|
|
EHTokBang,
|
|
|
|
EHTokDash,
|
|
|
|
EHTokTilde,
|
|
|
|
EHTokPlus,
|
|
|
|
EHTokStar,
|
|
|
|
EHTokSlash,
|
|
|
|
EHTokPercent,
|
|
|
|
EHTokLeftAngle,
|
|
|
|
EHTokRightAngle,
|
|
|
|
EHTokVerticalBar,
|
|
|
|
EHTokCaret,
|
|
|
|
EHTokAmpersand,
|
|
|
|
EHTokQuestion,
|
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace glslang
|
|
|
|
|
2016-06-29 16:58:58 +00:00
|
|
|
#endif // EHLSLTOKENS_H_
|