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