Commit b076adde by Corentin Wallez Committed by Jamie Madill

Implement gl_VertexID

BUG=angleproject:1217 Change-Id: Ibb9423d7de4966bce231734925a804b6340b5059 Reviewed-on: https://chromium-review.googlesource.com/321420Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 37477918
......@@ -311,6 +311,7 @@ enum TQualifier
// built-ins read by vertex shader
EvqInstanceID,
EvqVertexID,
// built-ins written by vertex shader
EvqPosition,
......@@ -411,6 +412,7 @@ inline const char* getQualifierString(TQualifier q)
case EvqInOut: return "inout";
case EvqConstReadOnly: return "const";
case EvqInstanceID: return "InstanceID";
case EvqVertexID: return "VertexID";
case EvqPosition: return "Position";
case EvqPointSize: return "PointSize";
case EvqFragCoord: return "FragCoord";
......
......@@ -578,6 +578,8 @@ void IdentifyBuiltIns(sh::GLenum type, ShShaderSpec spec,
TType(EbtFloat, EbpMedium, EvqPointSize, 1)));
symbolTable.insert(ESSL3_BUILTINS, new TVariable(NewPoolTString("gl_InstanceID"),
TType(EbtInt, EbpHigh, EvqInstanceID, 1)));
symbolTable.insert(ESSL3_BUILTINS, new TVariable(NewPoolTString("gl_VertexID"),
TType(EbtInt, EbpHigh, EvqVertexID, 1)));
break;
default:
......
......@@ -158,6 +158,7 @@ OutputHLSL::OutputHLSL(sh::GLenum shaderType, int shaderVersion,
mUsesFrontFacing = false;
mUsesPointSize = false;
mUsesInstanceID = false;
mUsesVertexID = false;
mUsesFragDepth = false;
mUsesXor = false;
mUsesDiscardRewriting = false;
......@@ -585,6 +586,11 @@ void OutputHLSL::header(TInfoSinkBase &out, const BuiltInFunctionEmulator *built
out << "static int gl_InstanceID;";
}
if (mUsesVertexID)
{
out << "static int gl_VertexID;";
}
out << "\n"
"// Varyings\n";
out << varyings;
......@@ -1510,6 +1516,11 @@ void OutputHLSL::visitSymbol(TIntermSymbol *node)
mUsesInstanceID = true;
out << name;
}
else if (qualifier == EvqVertexID)
{
mUsesVertexID = true;
out << name;
}
else if (name == "gl_FragDepthEXT" || name == "gl_FragDepth")
{
mUsesFragDepth = true;
......
......@@ -177,6 +177,7 @@ class OutputHLSL : public TIntermTraverser
bool mUsesFrontFacing;
bool mUsesPointSize;
bool mUsesInstanceID;
bool mUsesVertexID;
bool mUsesFragDepth;
bool mUsesXor;
bool mUsesDiscardRewriting;
......
......@@ -134,6 +134,7 @@ CollectVariables::CollectVariables(std::vector<sh::Attribute> *attribs,
mFrontFacingAdded(false),
mFragCoordAdded(false),
mInstanceIDAdded(false),
mVertexIDAdded(false),
mPositionAdded(false),
mPointSizeAdded(false),
mLastFragDataAdded(false),
......@@ -313,6 +314,22 @@ void CollectVariables::visitSymbol(TIntermSymbol *symbol)
mInstanceIDAdded = true;
}
return;
case EvqVertexID:
if (!mVertexIDAdded)
{
Attribute info;
const char kName[] = "gl_VertexID";
info.name = kName;
info.mappedName = kName;
info.type = GL_INT;
info.arraySize = 0;
info.precision = GL_HIGH_INT; // Defined by spec.
info.staticUse = true;
info.location = -1;
mAttribs->push_back(info);
mVertexIDAdded = true;
}
return;
case EvqPosition:
if (!mPositionAdded)
{
......
......@@ -53,6 +53,7 @@ class CollectVariables : public TIntermTraverser
bool mFragCoordAdded;
bool mInstanceIDAdded;
bool mVertexIDAdded;
bool mPositionAdded;
bool mPointSizeAdded;
bool mLastFragDataAdded;
......
......@@ -231,10 +231,11 @@ std::string DynamicHLSL::generateVertexShaderForInputLayout(
{
GLenum componentType = mRenderer->getVertexComponentType(vertexFormatType);
if (shaderAttribute.name == "gl_InstanceID")
if (shaderAttribute.name == "gl_InstanceID" ||
shaderAttribute.name == "gl_VertexID")
{
// The input type of the instance ID in HLSL (uint) differs from the one in ESSL
// (int).
// The input types of the instance ID and vertex ID in HLSL (uint) differs from
// the ones in ESSL (int).
structStream << " uint";
}
else
......@@ -251,6 +252,10 @@ std::string DynamicHLSL::generateVertexShaderForInputLayout(
{
structStream << "SV_InstanceID";
}
else if (shaderAttribute.name == "gl_VertexID")
{
structStream << "SV_VertexID";
}
else
{
structStream << "TEXCOORD" << semanticIndex;
......
......@@ -68,7 +68,6 @@
1093 WIN LINUX : dEQP-GLES3.functional.shaders.builtin_functions.precision.tanh.highp_fragment.vec2 = FAIL
1093 WIN LINUX : dEQP-GLES3.functional.shaders.builtin_functions.precision.tanh.highp_fragment.vec3 = FAIL
1093 WIN LINUX : dEQP-GLES3.functional.shaders.builtin_functions.precision.tanh.highp_fragment.vec4 = FAIL
1094 WIN LINUX : dEQP-GLES3.functional.shaders.builtin_variable.vertex_id = FAIL
1095 WIN LINUX : dEQP-GLES3.functional.texture.mipmap.2d.projected.nearest_nearest_clamp = FAIL
1095 WIN LINUX : dEQP-GLES3.functional.texture.mipmap.2d.projected.nearest_nearest_repeat = FAIL
1095 WIN LINUX : dEQP-GLES3.functional.texture.mipmap.2d.projected.nearest_nearest_mirror = FAIL
......
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