layout(location = 0) out vec4 out_color;
+out gl_PerVertex {
+ vec4 gl_Position;
+};
+
void main() {
gl_Position = in_position;
out_color = in_color;
layout(location = 0) out vec4 out_color;
+out gl_PerVertex {
+ vec4 gl_Position;
+};
+
void main() {
vec2 perVertex = vec2(in_position.x, in_position.y);
vec2 perInstance[6] = vec2[6](vec2(0.0, 0.0), vec2(0.3, 0.0), vec2(0.0, -0.3),vec2(0.3, -0.3), vec2(0.7, -0.7), vec2(-0.75, 0.8));
layout(location = 0) out vec4 out_color;
+out gl_PerVertex {
+ vec4 gl_Position;
+};
+
void main() {
vec2 perVertex = vec2(in_position.x, in_position.y);
vec2 perInstance[6] = vec2[6](vec2(0.7, -0.7), vec2(-0.75, 0.8), vec2(0.0, 0.0), vec2(0.3, 0.0), vec2(0.0, -0.3),vec2(0.3, -0.3) );
-#version 310 es
+#version 450
precision highp float;
layout(location = 0) in vec4 in_position;
layout(location = 1) in vec4 in_color;
layout(location = 0) out vec4 out_color;
+out gl_PerVertex { vec4 gl_Position; };
void main() {
gl_Position = in_position;
-#version 430
+#version 450
layout(triangles) in;
layout(triangle_strip, max_vertices = 3) out;
+in gl_PerVertex { vec4 gl_Position; } gl_in[];
+out gl_PerVertex { vec4 gl_Position; };
layout(location = 0) in vec4 in_color[];
layout(location = 0) out vec4 out_color;
" quadrant_id = gl_VertexIndex / 6;\n"
" result_position = vec4(float(quadOriginX + quadXcoord - 1), float(quadOriginY + quadYcoord - 1), 0.0, 1.0);\n";
+std::string genPerVertexBlock (const vk::VkShaderStageFlagBits stage, const glu::GLSLVersion version)
+{
+ static const char* const block = "gl_PerVertex {\n"
+ " vec4 gl_Position;\n"
+ " float gl_PointSize;\n" // not used, but for compatibility with how implicit block is declared in ES
+ "}";
+ std::ostringstream str;
+
+ if (!glu::glslVersionIsES(version))
+ switch (stage)
+ {
+ case vk::VK_SHADER_STAGE_VERTEX_BIT:
+ str << "out " << block << ";\n";
+ break;
+
+ case vk::VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT:
+ str << "in " << block << " gl_in[gl_MaxPatchVertices];\n"
+ << "out " << block << " gl_out[];\n";
+ break;
+
+ case vk::VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT:
+ str << "in " << block << " gl_in[gl_MaxPatchVertices];\n"
+ << "out " << block << ";\n";
+ break;
+
+ case vk::VK_SHADER_STAGE_GEOMETRY_BIT:
+ str << "in " << block << " gl_in[];\n"
+ << "out " << block << ";\n";
+ break;
+
+ default:
+ break;
+ }
+
+ return str.str();
+}
+
bool isUniformDescriptorType (vk::VkDescriptorType type)
{
return type == vk::VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER ||
<< genResourceDeclarations(vk::VK_SHADER_STAGE_VERTEX_BIT, 0)
<< "layout(location = 0) out highp vec4 " << nextStageName << "_color;\n"
<< (onlyVS ? "" : "layout(location = 1) flat out highp int " + de::toString(nextStageName) + "_quadrant_id;\n")
+ << genPerVertexBlock(vk::VK_SHADER_STAGE_VERTEX_BIT, m_glslVersion)
<< "void main (void)\n"
<< "{\n"
<< " highp vec4 result_position;\n"
buf << versionDecl << "\n"
<< genExtensionDeclarations(vk::VK_SHADER_STAGE_VERTEX_BIT)
<< "layout(location = 1) flat out highp int " << nextStageName << "_quadrant_id;\n"
+ << genPerVertexBlock(vk::VK_SHADER_STAGE_VERTEX_BIT, m_glslVersion)
<< "void main (void)\n"
<< "{\n"
<< " highp vec4 result_position;\n"
<< genResourceDeclarations(vk::VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, 0)
<< "layout(location = 1) flat in highp int tsc_quadrant_id[];\n"
<< "layout(location = 0) out highp vec4 tes_color[];\n"
+ << genPerVertexBlock(vk::VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, m_glslVersion)
<< "void main (void)\n"
<< "{\n"
<< " highp vec4 result_color;\n"
<< "layout(vertices=3) out;\n"
<< "layout(location = 1) flat in highp int tsc_quadrant_id[];\n"
<< "layout(location = 1) flat out highp int tes_quadrant_id[];\n"
+ << genPerVertexBlock(vk::VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT, m_glslVersion)
<< "void main (void)\n"
<< "{\n"
<< " tes_quadrant_id[gl_InvocationID] = tsc_quadrant_id[0];\n"
<< genResourceDeclarations(vk::VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, 0)
<< "layout(location = 1) flat in highp int tes_quadrant_id[];\n"
<< "layout(location = 0) out highp vec4 frag_color;\n"
+ << genPerVertexBlock(vk::VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, m_glslVersion)
<< "void main (void)\n"
<< "{\n"
<< " highp vec4 result_color;\n"
<< "layout(triangles) in;\n"
<< "layout(location = 0) in highp vec4 tes_color[];\n"
<< "layout(location = 0) out highp vec4 frag_color;\n"
+ << genPerVertexBlock(vk::VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT, m_glslVersion)
<< "void main (void)\n"
<< "{\n"
<< " frag_color = tes_color[0];\n"
<< genResourceDeclarations(vk::VK_SHADER_STAGE_GEOMETRY_BIT, 0)
<< "layout(location = 1) flat in highp int geo_quadrant_id[];\n"
<< "layout(location = 0) out highp vec4 frag_color;\n"
+ << genPerVertexBlock(vk::VK_SHADER_STAGE_GEOMETRY_BIT, m_glslVersion)
<< "void main (void)\n"
<< "{\n"
<< " highp int quadrant_id;\n"
<< "\n"
<< "layout(location = 0) in highp vec4 position;\n"
<< "\n"
+ << "out gl_PerVertex {\n"
+ << " vec4 gl_Position;\n"
+ << "};\n"
+ << "\n"
<< "void main (void)\n"
<< "{\n"
<< " gl_Position = position;\n"
<< "layout(location = 0) in highp vec4 position;\n"
<< "layout(location = 1) in highp vec4 color;\n"
<< "layout(location = 0) out highp vec4 vtxColor;\n"
+ << "out gl_PerVertex { vec4 gl_Position; };\n"
<< "layout(push_constant) uniform Material {\n";
switch (getRangeSizeCase(m_pushConstantRange[rangeNdx].range.size))
<< "} tessLevel;\n"
<< "layout(location = 0) in highp vec4 color[];\n"
<< "layout(location = 0) out highp vec4 vtxColor[];\n"
+ << "in gl_PerVertex { vec4 gl_Position; } gl_in[gl_MaxPatchVertices];\n"
+ << "out gl_PerVertex { vec4 gl_Position; } gl_out[];\n"
<< "void main()\n"
<< "{\n"
<< " gl_TessLevelInner[0] = tessLevel.level;\n"
<< "} matInst;\n"
<< "layout(location = 0) in highp vec4 color[];\n"
<< "layout(location = 0) out highp vec4 vtxColor;\n"
+ << "in gl_PerVertex { vec4 gl_Position; } gl_in[gl_MaxPatchVertices];\n"
+ << "out gl_PerVertex { vec4 gl_Position; };\n"
<< "void main()\n"
<< "{\n"
<< " gl_Position = gl_TessCoord.x * gl_in[0].gl_Position + gl_TessCoord.y * gl_in[1].gl_Position + gl_TessCoord.z * gl_in[2].gl_Position;\n"
<< "} matInst;\n"
<< "layout(location = 0) in highp vec4 color[];\n"
<< "layout(location = 0) out highp vec4 vtxColor;\n"
+ << "in gl_PerVertex { vec4 gl_Position; } gl_in[];\n"
+ << "out gl_PerVertex { vec4 gl_Position; };\n"
<< "void main()\n"
<< "{\n"
<< " for(int i=0; i<3; i++)\n"
BasicGraphicsTest::initPrograms(programCollection);
programCollection.glslSources.add("dummy_geo") << glu::GeometrySource(
- "#version 450 \n"
+ "#version 310 es\n"
+ "#extension GL_EXT_geometry_shader : enable\n"
"layout(triangles) in;\n"
"layout(triangle_strip, max_vertices = 3) out;\n"
"layout(location = 0) in highp vec4 in_vtxColor[];\n"
"}\n");
programCollection.glslSources.add("basic_tcs") << glu::TessellationControlSource(
- "#version 450 \n"
+ "#version 310 es\n"
+ "#extension GL_EXT_tessellation_shader : enable\n"
"layout(vertices = 3) out;\n"
"layout(location = 0) in highp vec4 color[];\n"
"layout(location = 0) out highp vec4 vtxColor[];\n"
"}\n");
programCollection.glslSources.add("basic_tes") << glu::TessellationEvaluationSource(
- "#version 450 \n"
+ "#version 310 es\n"
+ "#extension GL_EXT_tessellation_shader : enable\n"
"layout(triangles, fractional_even_spacing, ccw) in;\n"
"layout(location = 0) in highp vec4 colors[];\n"
"layout(location = 0) out highp vec4 vtxColor;\n"
"}\n");
programCollection.glslSources.add("vert") << glu::VertexSource("#version 430\n"
- "layout(location = 0) in vec4 in_Postion;\n"
+ "layout(location = 0) in vec4 in_Position;\n"
+ "out gl_PerVertex { vec4 gl_Position; float gl_PointSize; };\n"
"void main() {\n"
- " gl_Position = in_Postion;\n"
+ " gl_Position = in_Position;\n"
" gl_PointSize = 1.0;\n"
"}\n");
}
{
std::ostringstream src;
- src << "#version 450\n";
+ src << "#version 310 es\n";
src << "layout(local_size_x = 1) in;\n";
src << "\n";
std::string generateVertexShader (const ShaderInterface& interface, const UniformLayout& layout, const std::map<int, void*>& blockPointers)
{
std::ostringstream src;
- src << "#version 450\n";
+ src << "#version 310 es\n";
src << "layout(location = 0) in highp vec4 a_position;\n";
src << "layout(location = 0) out mediump float v_vtxResult;\n";
std::string generateFragmentShader (const ShaderInterface& interface, const UniformLayout& layout, const std::map<int, void*>& blockPointers)
{
std::ostringstream src;
- src << "#version 450\n";
+ src << "#version 310 es\n";
src << "layout(location = 0) in mediump float v_vtxResult;\n";
src << "layout(location = 0) out mediump vec4 dEQP_FragColor;\n";