Commit c75d6dc8 by James Dong Committed by Commit Bot

Vulkan: Add support for gl_VertexID/gl_InstanceID

Adds support for GLES 3.0 feature which adds gl_VertexID and gl_InstanceID built-in variables to vertex shader. Bug: angleproject:3221 Change-Id: I372d7ac34bed376b506e327725f0eca2513852fa Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1646735 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 6064e6ab
...@@ -179,4 +179,36 @@ void TOutputVulkanGLSL::writeStructType(const TStructure *structure) ...@@ -179,4 +179,36 @@ void TOutputVulkanGLSL::writeStructType(const TStructure *structure)
objSink() << ";\n"; objSink() << ";\n";
} }
} }
void TOutputVulkanGLSL::visitSymbol(TIntermSymbol *node)
{
TInfoSinkBase &out = objSink();
// All the special cases are built-ins, so if it's not a built-in we can return early.
if (node->variable().symbolType() != SymbolType::BuiltIn)
{
TOutputGLSL::visitSymbol(node);
return;
}
// Some built-ins get a special translation.
const ImmutableString &name = node->getName();
if (name == "gl_VertexID")
{
// gl_VertexIndex in Vulkan GLSL has the same semantics as gl_VertexID.
out << "gl_VertexIndex";
}
else if (name == "gl_InstanceID")
{
// gl_InstanceIndex in Vulkan GLSL is equal to
// gl_InstanceID + baseInstance, but in OpenGL ES,
// baseInstance is always zero.
// (OpenGL ES 3.2 spec page 278 footnote 3)
out << "gl_InstanceIndex";
}
else
{
TOutputGLSL::visitSymbol(node);
}
}
} // namespace sh } // namespace sh
...@@ -33,6 +33,7 @@ class TOutputVulkanGLSL : public TOutputGLSL ...@@ -33,6 +33,7 @@ class TOutputVulkanGLSL : public TOutputGLSL
void writeLayoutQualifier(TIntermTyped *variable) override; void writeLayoutQualifier(TIntermTyped *variable) override;
void writeQualifier(TQualifier qualifier, const TType &type, const TSymbol *symbol) override; void writeQualifier(TQualifier qualifier, const TType &type, const TSymbol *symbol) override;
void writeVariableType(const TType &type, const TSymbol *symbol) override; void writeVariableType(const TType &type, const TSymbol *symbol) override;
void visitSymbol(TIntermSymbol *node) override;
}; };
} // namespace sh } // namespace sh
...@@ -599,8 +599,6 @@ ...@@ -599,8 +599,6 @@
3193 VULKAN : dEQP-GLES3.functional.vertex_arrays.single_attribute.offset.int2_10_10_10* = SKIP 3193 VULKAN : dEQP-GLES3.functional.vertex_arrays.single_attribute.offset.int2_10_10_10* = SKIP
3193 VULKAN : dEQP-GLES3.functional.vertex_array_objects.all_attributes = SKIP 3193 VULKAN : dEQP-GLES3.functional.vertex_array_objects.all_attributes = SKIP
// Vertex ID, Index ID
3221 VULKAN : dEQP-GLES3.functional.shaders.builtin_variable.vertex_id = FAIL
3221 VULKAN : dEQP-GLES3.functional.instanced.* = SKIP 3221 VULKAN : dEQP-GLES3.functional.instanced.* = SKIP
// Polygon offset: // Polygon offset:
......
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