const std::string missHitDiff = (shaderOp == SHADERS_CACHE_OP_HIT ? "" : " + 0.1");
const std::string missSuffix = (shaderOp == SHADERS_CACHE_OP_HIT ? "" : "_miss");
- for (deUint32 shaderNdx = 0; shaderNdx < m_param.getShaderCount(); shaderNdx++)
+ programCollection.glslSources.add("color_vert" + missSuffix) << glu::VertexSource(
- "#version 310 es\n"
++ "#version 450\n"
+ "layout(location = 0) in vec4 position;\n"
+ "layout(location = 1) in vec4 color;\n"
+ "layout(location = 0) out highp vec4 vtxColor;\n"
++ "out gl_PerVertex { vec4 gl_Position; };\n"
+ "void main (void)\n"
+ "{\n"
+ " gl_Position = position;\n"
+ " vtxColor = color" + missHitDiff + ";\n"
+ "}\n");
+
+ programCollection.glslSources.add("color_frag" + missSuffix) << glu::FragmentSource(
+ "#version 310 es\n"
+ "layout(location = 0) in highp vec4 vtxColor;\n"
+ "layout(location = 0) out highp vec4 fragColor;\n"
+ "void main (void)\n"
+ "{\n"
+ " fragColor = vtxColor" + missHitDiff + ";\n"
+ "}\n");
+
+ VkShaderStageFlags shaderFlag = m_param.getShaderFlags();
+ if (shaderFlag & VK_SHADER_STAGE_GEOMETRY_BIT)
{
- switch(m_param.getShaderFlag(shaderNdx))
- {
- case VK_SHADER_STAGE_VERTEX_BIT:
- programCollection.glslSources.add("color_vert" + missSuffix) << glu::VertexSource(
- "#version 450\n"
- "layout(location = 0) in vec4 position;\n"
- "layout(location = 1) in vec4 color;\n"
- "layout(location = 0) out highp vec4 vtxColor;\n"
- "out gl_PerVertex { vec4 gl_Position; };\n"
- "void main (void)\n"
- "{\n"
- " gl_Position = position;\n"
- " vtxColor = color" + missHitDiff + ";\n"
- "}\n");
- break;
-
- case VK_SHADER_STAGE_FRAGMENT_BIT:
- programCollection.glslSources.add("color_frag" + missSuffix) << glu::FragmentSource(
- "#version 310 es\n"
- "layout(location = 0) in highp vec4 vtxColor;\n"
- "layout(location = 0) out highp vec4 fragColor;\n"
- "void main (void)\n"
- "{\n"
- " fragColor = vtxColor" + missHitDiff + ";\n"
- "}\n");
- break;
-
- case VK_SHADER_STAGE_GEOMETRY_BIT:
- programCollection.glslSources.add("unused_geo" + missSuffix) << glu::GeometrySource(
- "#version 450 \n"
- "layout(triangles) in;\n"
- "layout(triangle_strip, max_vertices = 3) out;\n"
- "layout(location = 0) in highp vec4 in_vtxColor[];\n"
- "layout(location = 0) out highp vec4 vtxColor;\n"
- "out gl_PerVertex { vec4 gl_Position; };\n"
- "in gl_PerVertex { vec4 gl_Position; } gl_in[];\n"
- "void main (void)\n"
- "{\n"
- " for(int ndx=0; ndx<3; ndx++)\n"
- " {\n"
- " gl_Position = gl_in[ndx].gl_Position;\n"
- " vtxColor = in_vtxColor[ndx]" + missHitDiff + ";\n"
- " EmitVertex();\n"
- " }\n"
- " EndPrimitive();\n"
- "}\n");
- break;
-
- case VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT:
- programCollection.glslSources.add("basic_tcs" + missSuffix) << glu::TessellationControlSource(
- "#version 450 \n"
- "layout(vertices = 3) out;\n"
- "layout(location = 0) in highp vec4 color[];\n"
- "layout(location = 0) out highp vec4 vtxColor[];\n"
- "out gl_PerVertex { vec4 gl_Position; } gl_out[3];\n"
- "in gl_PerVertex { vec4 gl_Position; } gl_in[gl_MaxPatchVertices];\n"
- "void main()\n"
- "{\n"
- " gl_TessLevelOuter[0] = 4.0;\n"
- " gl_TessLevelOuter[1] = 4.0;\n"
- " gl_TessLevelOuter[2] = 4.0;\n"
- " gl_TessLevelInner[0] = 4.0;\n"
- " gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;\n"
- " vtxColor[gl_InvocationID] = color[gl_InvocationID]" + missHitDiff + ";\n"
- "}\n");
- break;
-
- case VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT:
- programCollection.glslSources.add("basic_tes" + missSuffix) << glu::TessellationEvaluationSource(
- "#version 450 \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"
- "out gl_PerVertex { vec4 gl_Position; };\n"
- "in gl_PerVertex { vec4 gl_Position; } gl_in[gl_MaxPatchVertices];\n"
- "void main() \n"
- "{\n"
- " float u = gl_TessCoord.x;\n"
- " float v = gl_TessCoord.y;\n"
- " float w = gl_TessCoord.z;\n"
- " vec4 pos = vec4(0);\n"
- " vec4 color = vec4(0)" + missHitDiff + ";\n"
- " pos.xyz += u * gl_in[0].gl_Position.xyz;\n"
- " color.xyz += u * colors[0].xyz;\n"
- " pos.xyz += v * gl_in[1].gl_Position.xyz;\n"
- " color.xyz += v * colors[1].xyz;\n"
- " pos.xyz += w * gl_in[2].gl_Position.xyz;\n"
- " color.xyz += w * colors[2].xyz;\n"
- " pos.w = 1.0;\n"
- " color.w = 1.0;\n"
- " gl_Position = pos;\n"
- " vtxColor = color;\n"
- "}\n");
- break;
-
- default:
- DE_FATAL("Unknown Shader Stage!");
- break;
- }
+ programCollection.glslSources.add("unused_geo" + missSuffix) << glu::GeometrySource(
+ "#version 450 \n"
+ "layout(triangles) in;\n"
+ "layout(triangle_strip, max_vertices = 3) out;\n"
+ "layout(location = 0) in highp vec4 in_vtxColor[];\n"
+ "layout(location = 0) out highp vec4 vtxColor;\n"
+ "out gl_PerVertex { vec4 gl_Position; };\n"
+ "in gl_PerVertex { vec4 gl_Position; } gl_in[];\n"
+ "void main (void)\n"
+ "{\n"
+ " for(int ndx=0; ndx<3; ndx++)\n"
+ " {\n"
+ " gl_Position = gl_in[ndx].gl_Position;\n"
+ " vtxColor = in_vtxColor[ndx]" + missHitDiff + ";\n"
+ " EmitVertex();\n"
+ " }\n"
+ " EndPrimitive();\n"
+ "}\n");
+ }
+ if (shaderFlag & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT)
+ {
+ programCollection.glslSources.add("basic_tcs" + missSuffix) << glu::TessellationControlSource(
+ "#version 450 \n"
+ "layout(vertices = 3) out;\n"
+ "layout(location = 0) in highp vec4 color[];\n"
+ "layout(location = 0) out highp vec4 vtxColor[];\n"
+ "out gl_PerVertex { vec4 gl_Position; } gl_out[3];\n"
+ "in gl_PerVertex { vec4 gl_Position; } gl_in[gl_MaxPatchVertices];\n"
+ "void main()\n"
+ "{\n"
+ " gl_TessLevelOuter[0] = 4.0;\n"
+ " gl_TessLevelOuter[1] = 4.0;\n"
+ " gl_TessLevelOuter[2] = 4.0;\n"
+ " gl_TessLevelInner[0] = 4.0;\n"
+ " gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;\n"
+ " vtxColor[gl_InvocationID] = color[gl_InvocationID]" + missHitDiff + ";\n"
+ "}\n");
+ }
+ if (shaderFlag & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT)
+ {
+ programCollection.glslSources.add("basic_tes" + missSuffix) << glu::TessellationEvaluationSource(
+ "#version 450 \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"
+ "out gl_PerVertex { vec4 gl_Position; };\n"
+ "in gl_PerVertex { vec4 gl_Position; } gl_in[gl_MaxPatchVertices];\n"
+ "void main() \n"
+ "{\n"
+ " float u = gl_TessCoord.x;\n"
+ " float v = gl_TessCoord.y;\n"
+ " float w = gl_TessCoord.z;\n"
+ " vec4 pos = vec4(0);\n"
+ " vec4 color = vec4(0)" + missHitDiff + ";\n"
+ " pos.xyz += u * gl_in[0].gl_Position.xyz;\n"
+ " color.xyz += u * colors[0].xyz;\n"
+ " pos.xyz += v * gl_in[1].gl_Position.xyz;\n"
+ " color.xyz += v * colors[1].xyz;\n"
+ " pos.xyz += w * gl_in[2].gl_Position.xyz;\n"
+ " color.xyz += w * colors[2].xyz;\n"
+ " pos.w = 1.0;\n"
+ " color.w = 1.0;\n"
+ " gl_Position = pos;\n"
+ " vtxColor = color;\n"
+ "}\n");
}
}
}