// // Copyright 2017 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. // // GeometryShader_test.cpp: // tests for compiling a Geometry Shader // #include "GLSLANG/ShaderLang.h" #include "angle_gl.h" #include "compiler/translator/BaseTypes.h" #include "gtest/gtest.h" #include "tests/test_utils/ShaderCompileTreeTest.h" #include "tests/test_utils/compiler_test.h" usingnamespacesh; class GeometryShaderTest : public ShaderCompileTreeTest { … }; class GeometryShaderOutputCodeTest : public MatchOutputCodeTest { … }; // Geometry Shaders are not supported in GLSL ES shaders version lower than 310. TEST_F(GeometryShaderTest, Version300) { … } // Geometry Shaders are not supported in GLSL ES shaders version 310 without extension // EXT_geometry_shader enabled. TEST_F(GeometryShaderTest, Version310WithoutExtension) { … } // Geometry Shaders are not supported in GLSL ES shaders version 310 with extension // EXT_geometry_shader disabled. TEST_F(GeometryShaderTest, Version310ExtensionDisabled) { … } // Geometry Shaders are supported in GLSL ES shaders version 310 with EXT_geometry_shader enabled. TEST_F(GeometryShaderTest, Version310WithEXTExtension) { … } // Missing the declaration of input primitive in a geometry shader should be a link error instead of // a compile error. TEST_F(GeometryShaderTest, NoInputPrimitives) { … } // Geometry Shaders can only support 5 kinds of input primitives, which cannot be used as output // primitives except 'points'. // Skip testing "points" as it can be used as both input and output primitives. TEST_F(GeometryShaderTest, ValidInputPrimitives) { … } // Geometry Shaders allow duplicated declaration of input primitive, but all of them must be same. TEST_F(GeometryShaderTest, RedeclareInputPrimitives) { … } // Geometry Shaders don't allow declaring different input primitives in one layout. TEST_F(GeometryShaderTest, DeclareDifferentInputPrimitivesInOneLayout) { … } // Geometry Shaders don't allow 'invocations' < 1. TEST_F(GeometryShaderTest, InvocationsLessThanOne) { … } // Geometry Shaders allow declaring 'invocations' == 1 together with input primitive declaration in // one layout. TEST_F(GeometryShaderTest, InvocationsEqualsOne) { … } // Geometry Shaders allow declaring 'invocations' == 1 in an individual layout. TEST_F(GeometryShaderTest, InvocationsEqualsOneInSeparatedLayout) { … } // Geometry Shaders don't allow 'invocations' larger than the implementation-dependent maximum value // (32 in this test). TEST_F(GeometryShaderTest, TooLargeInvocations) { … } // Geometry Shaders allow 'invocations' declared together with input primitives in one layout. TEST_F(GeometryShaderTest, InvocationsDeclaredWithInputPrimitives) { … } // Geometry Shaders allow 'invocations' declared before input primitives in one input layout. TEST_F(GeometryShaderTest, InvocationsBeforeInputPrimitives) { … } // Geometry Shaders allow 'invocations' declared in an individual input layout. TEST_F(GeometryShaderTest, InvocationsInIndividualLayout) { … } // Geometry Shaders allow duplicated 'invocations' declarations. TEST_F(GeometryShaderTest, DuplicatedInvocations) { … } // Geometry Shaders don't allow multiple different 'invocations' declarations in different // layouts. TEST_F(GeometryShaderTest, RedeclareDifferentInvocations) { … } // Geometry Shaders don't allow multiple different 'invocations' declarations in different // layouts. TEST_F(GeometryShaderTest, RedeclareDifferentInvocationsAfterInvocationEqualsOne) { … } // Geometry Shaders don't allow multiple different 'invocations' declarations in one layout. TEST_F(GeometryShaderTest, RedeclareDifferentInvocationsInOneLayout) { … } // Geometry Shaders don't allow 'invocations' in out layouts. TEST_F(GeometryShaderTest, DeclareInvocationsInOutLayout) { … } // Geometry Shaders don't allow 'invocations' in layouts without 'in' qualifier. TEST_F(GeometryShaderTest, DeclareInvocationsInLayoutNoQualifier) { … } // Geometry Shaders allow declaring output primitive before input primitive declaration. TEST_F(GeometryShaderTest, DeclareOutputPrimitiveBeforeInputPrimitiveDeclare) { … } // Geometry Shaders allow declaring 'max_vertices' before output primitive in one output layout. TEST_F(GeometryShaderTest, DeclareMaxVerticesBeforeOutputPrimitive) { … } // Missing the declaration of output primitive should be a link error instead of a compile error in // a geometry shader. TEST_F(GeometryShaderTest, NoOutputPrimitives) { … } // Geometry Shaders can only support 3 kinds of output primitives, which cannot be used as input // primitives except 'points'. // Skip testing "points" as it can be used as both input and output primitives. TEST_F(GeometryShaderTest, ValidateOutputPrimitives) { … } // Geometry Shaders allow duplicated output primitive declarations, but all of them must be same. TEST_F(GeometryShaderTest, RedeclareOutputPrimitives) { … } // Geometry Shaders don't allow declaring different output primitives in one layout. TEST_F(GeometryShaderTest, RedeclareDifferentOutputPrimitivesInOneLayout) { … } // Missing the declarations of output primitives and 'max_vertices' in a geometry shader should // be a link error instead of a compile error. TEST_F(GeometryShaderTest, NoOutLayouts) { … } // Missing the declarations of 'max_vertices' in a geometry shader should be a link error // instead of a compile error. TEST_F(GeometryShaderTest, NoMaxVertices) { … } // Geometry Shaders cannot declare a negative 'max_vertices'. TEST_F(GeometryShaderTest, NegativeMaxVertices) { … } // Geometry Shaders allow max_vertices == 0. TEST_F(GeometryShaderTest, ZeroMaxVertices) { … } // Geometry Shaders cannot declare a 'max_vertices' that is greater than // MAX_GEOMETRY_OUTPUT_VERTICES_EXT (256 in this test). TEST_F(GeometryShaderTest, TooLargeMaxVertices) { … } // Geometry Shaders can declare 'max_vertices' in an individual out layout. TEST_F(GeometryShaderTest, MaxVerticesInIndividualLayout) { … } // Geometry Shaders allow duplicated 'max_vertices' declarations. TEST_F(GeometryShaderTest, DuplicatedMaxVertices) { … } // Geometry Shaders don't allow declaring different 'max_vertices'. TEST_F(GeometryShaderTest, RedeclareDifferentMaxVertices) { … } // Geometry Shaders don't allow declaring different 'max_vertices'. TEST_F(GeometryShaderTest, RedeclareDifferentMaxVerticesInOneLayout) { … } // Geometry Shaders don't allow 'location' declared with input/output primitives in one layout. TEST_F(GeometryShaderTest, InvalidLocation) { … } // Geometry Shaders don't allow invalid layout qualifier declarations. TEST_F(GeometryShaderTest, InvalidLayoutQualifiers) { … } // Verify that indexing an array with a constant integer on gl_in is legal. TEST_F(GeometryShaderTest, IndexGLInByConstantInteger) { … } // Verify that indexing an array with an integer variable on gl_in is legal. TEST_F(GeometryShaderTest, IndexGLInByVariable) { … } // Verify that indexing an array on gl_in without input primitive declaration causes a compile // error. TEST_F(GeometryShaderTest, IndexGLInWithoutInputPrimitive) { … } // Verify that using gl_in.length() without input primitive declaration causes a compile error. TEST_F(GeometryShaderTest, UseGLInLengthWithoutInputPrimitive) { … } // Verify that using gl_in.length() with input primitive declaration can compile. TEST_F(GeometryShaderTest, UseGLInLengthWithInputPrimitive) { … } // Verify that gl_in[].gl_Position cannot be l-value. TEST_F(GeometryShaderTest, AssignValueToGLIn) { … } // Verify Geometry Shader supports all required built-in variables. TEST_F(GeometryShaderTest, BuiltInVariables) { … } // Verify that gl_PrimitiveIDIn cannot be l-value. TEST_F(GeometryShaderTest, AssignValueToGLPrimitiveIn) { … } // Verify that gl_InvocationID cannot be l-value. TEST_F(GeometryShaderTest, AssignValueToGLInvocations) { … } // Verify that both EmitVertex() and EndPrimitive() are supported in Geometry Shader. TEST_F(GeometryShaderTest, GeometryShaderBuiltInFunctions) { … } // Verify that using EmitVertex() or EndPrimitive() without GL_EXT_geometry_shader declared causes a // compile error. TEST_F(GeometryShaderTest, GeometryShaderBuiltInFunctionsWithoutExtension) { … } // Verify that all required built-in constant values are supported in Geometry Shaders TEST_F(GeometryShaderTest, GeometryShaderBuiltInConstants) { … } // Verify that using any Geometry Shader built-in constant values without GL_EXT_geometry_shader // declared causes a compile error. TEST_F(GeometryShaderTest, GeometryShaderBuiltInConstantsWithoutExtension) { … } // Verify that Geometry Shaders cannot accept non-array inputs. TEST_F(GeometryShaderTest, NonArrayInput) { … } // Verify that compilation errors do not occur even if declaring an unsized Geometry Shader input // before a valid input primitive declaration. TEST_F(GeometryShaderTest, DeclareUnsizedInputBeforeInputPrimitive) { … } // Verify that it is a compile error to declare an unsized Geometry Shader input without a valid // input primitive declaration. TEST_F(GeometryShaderTest, DeclareUnsizedInputWithoutInputPrimitive) { … } // Verify that indexing an unsized Geometry Shader input which is declared after a // valid input primitive declaration can compile. TEST_F(GeometryShaderTest, IndexingUnsizedInputDeclaredAfterInputPrimitive) { … } // Verify that calling length() function on an unsized Geometry Shader input which // is declared before a valid input primitive declaration can compile. TEST_F(GeometryShaderTest, CallingLengthOnUnsizedInputDeclaredAfterInputPrimitive) { … } // Verify that assigning a value to the input of a geometry shader causes a compile error. TEST_F(GeometryShaderTest, AssignValueToInput) { … } // Geometry Shaders allow inputs with location qualifier. TEST_F(GeometryShaderTest, InputWithLocations) { … } // Geometry Shaders allow inputs with explicit size declared before the declaration of the // input primitive, but they should have same size and match the declaration of the // following input primitive declarations. TEST_F(GeometryShaderTest, InputWithSizeBeforeInputPrimitive) { … } // Geometry shaders allow inputs with explicit size declared after the declaration of the // input primitive, but their sizes should match the previous input primitive declaration. TEST_F(GeometryShaderTest, InputWithSizeAfterInputPrimitive) { … } // Verify that Geometry Shaders accept non-array outputs. TEST_F(GeometryShaderTest, NonArrayOutputs) { … } // Verify that Geometry Shaders allow declaring outputs with 'location' layout qualifier. TEST_F(GeometryShaderTest, OutputsWithLocation) { … } // Geometry Shaders allow declaring sized array outputs. TEST_F(GeometryShaderTest, SizedArrayOutputs) { … } // Verify that Geometry Shader outputs cannot be declared as an unsized array. TEST_F(GeometryShaderTest, UnsizedArrayOutputs) { … } // Verify that Geometry Shader inputs can use interpolation qualifiers. TEST_F(GeometryShaderTest, InputWithInterpolationQualifiers) { … } // Verify that Geometry Shader outputs can use interpolation qualifiers. TEST_F(GeometryShaderTest, OutputWithInterpolationQualifiers) { … } // Verify that Geometry Shader outputs can use 'invariant' qualifier. TEST_F(GeometryShaderTest, InvariantOutput) { … } // Verify that the member of gl_in won't be incorrectly changed in the output shader string. TEST_F(GeometryShaderOutputCodeTest, ValidateGLInMembersInOutputShaderString) { … } // Verify that geometry shader inputs can be declared as struct arrays. TEST_F(GeometryShaderTest, StructArrayInput) { … } // Verify that geometry shader outputs cannot be declared as struct arrays. TEST_F(GeometryShaderTest, StructArrayOutput) { … }