Fix sparse cubemap array tests issues
authorJeannot Breton <jbreton@nvidia.com>
Thu, 25 May 2017 20:48:20 +0000 (15:48 -0500)
committerAlexander Galazin <Alexander.Galazin@arm.com>
Fri, 26 May 2017 18:57:40 +0000 (14:57 -0400)
Add cubeMapArrayRefZDef, a new shader token used as <compare>
parameters on some shadow cube map array texture instructions

Add <CUBE_REFZ_DEF> to some FunctionToken argument list definitions.
It will be replaced by the value of cubeMapArrayRefZDef.

Copy the depth reference value to s.cubeMapArrayRefZDef when we
generate the shader tokens

Change the way cube map array texture coordinate are computed in
the shader to support array with more than 6 layers

Specify that textureGradClampARB on shadow cubemap array is not
supported

Generate cube map array texture coordinate attributes as a vec4
with different coordinate for each layer

Affects:

KHR-GL45.sparse_texture2_tests.*
KHR-GL45.sparse_texture_clamp_tests.*

Components: OpenGL

VK-GL-CTS issue: 445

Change-Id: Ia9fb2240396ab4a34dd697d0b96985da35dfe802

external/openglcts/modules/gl/gl4cSparseTexture2Tests.cpp
external/openglcts/modules/gl/gl4cSparseTexture2Tests.hpp
external/openglcts/modules/gl/gl4cSparseTextureClampTests.cpp

index 4b7944e..a987829 100644 (file)
@@ -2178,7 +2178,7 @@ void SparseTexture2LookupTestCase::init()
        mSupportedInternalFormats.push_back(GL_DEPTH_COMPONENT16);
 
        FunctionToken f;
-       f = FunctionToken("sparseTextureARB", "");
+       f = FunctionToken("sparseTextureARB", "<CUBE_REFZ_DEF>");
        f.allowedTargets.insert(GL_TEXTURE_2D);
        f.allowedTargets.insert(GL_TEXTURE_2D_ARRAY);
        f.allowedTargets.insert(GL_TEXTURE_CUBE_MAP);
@@ -2449,12 +2449,13 @@ SparseTexture2LookupTestCase::TokenStringsExt SparseTexture2LookupTestCase::crea
        if ((target == GL_TEXTURE_CUBE_MAP || target == GL_TEXTURE_CUBE_MAP_ARRAY) &&
                funcName.find("Fetch", 0) == std::string::npos)
        {
-               s.cubeMapCoordDef = "    if (point.z == 0) coord.xyz = vec3(1, coord.y * 2 - 1, -coord.x * 2 + 1);\n"
-                                                       "    if (point.z == 1) coord.xyz = vec3(-1, coord.y * 2 - 1, coord.x * 2 - 1);\n"
-                                                       "    if (point.z == 2) coord.xyz = vec3(coord.x * 2 - 1, 1, coord.y * 2 - 1);\n"
-                                                       "    if (point.z == 3) coord.xyz = vec3(coord.x * 2 - 1, -1, -coord.y * 2 + 1);\n"
-                                                       "    if (point.z == 4) coord.xyz = vec3(coord.x * 2 - 1, coord.y * 2 - 1, 1);\n"
-                                                       "    if (point.z == 5) coord.xyz = vec3(-coord.x * 2 + 1, coord.y * 2 - 1, -1);\n";
+               s.cubeMapCoordDef = "    int face = point.z % 6;\n"
+                                                       "    if (face == 0) coord.xyz = vec3(1, coord.y * 2 - 1, -coord.x * 2 + 1);\n"
+                                                       "    if (face == 1) coord.xyz = vec3(-1, coord.y * 2 - 1, coord.x * 2 - 1);\n"
+                                                       "    if (face == 2) coord.xyz = vec3(coord.x * 2 - 1, 1, coord.y * 2 - 1);\n"
+                                                       "    if (face == 3) coord.xyz = vec3(coord.x * 2 - 1, -1, -coord.y * 2 + 1);\n"
+                                                       "    if (face == 4) coord.xyz = vec3(coord.x * 2 - 1, coord.y * 2 - 1, 1);\n"
+                                                       "    if (face == 5) coord.xyz = vec3(-coord.x * 2 + 1, coord.y * 2 - 1, -1);\n";
        }
 
        if (s.coordDef.empty())
@@ -2491,7 +2492,7 @@ SparseTexture2LookupTestCase::TokenStringsExt SparseTexture2LookupTestCase::crea
                        s.coordDef += s.refZDef;
                }
                else
-                       funcToken.arguments += s.refZDef;
+                       s.cubeMapArrayRefZDef = s.refZDef;
 
                s.componentDef = ".r";
        }
@@ -2815,6 +2816,7 @@ bool SparseTexture2LookupTestCase::verifyLookupTextureData(const Functions& gl,
                replaceToken("<EPSILON>", s.epsilon.c_str(), shader);
                replaceToken("<SAMPLE_DEF>", s.sampleDef.c_str(), shader);
                replaceToken("<REFZ_DEF>", s.refZDef.c_str(), shader);
+               replaceToken("<CUBE_REFZ_DEF>", s.cubeMapArrayRefZDef.c_str(), shader);
                replaceToken("<POINT_COORD>", s.pointCoord.c_str(), shader);
                replaceToken("<COMPONENT_DEF>", s.componentDef.c_str(), shader);
                replaceToken("<CUBE_MAP_COORD_DEF>", s.cubeMapCoordDef.c_str(), shader);
index 55dc0b1..64cada9 100644 (file)
@@ -237,6 +237,7 @@ protected:
                std::string coordDef;
                std::string cubeMapCoordDef;
                std::string refZDef;
+               std::string cubeMapArrayRefZDef;
                std::string offsetDim;
                std::string offsetType;
                std::string nOffsetType;
index accf914..021a153 100644 (file)
@@ -199,7 +199,7 @@ void SparseTextureClampLookupResidencyTestCase::init()
        mSupportedInternalFormats.push_back(GL_DEPTH_COMPONENT16);
 
        FunctionToken f;
-       f = FunctionToken("sparseTextureClampARB", ", <LOD>");
+       f = FunctionToken("sparseTextureClampARB", "<CUBE_REFZ_DEF>, <LOD>");
        f.allowedTargets.insert(GL_TEXTURE_2D);
        f.allowedTargets.insert(GL_TEXTURE_2D_ARRAY);
        f.allowedTargets.insert(GL_TEXTURE_CUBE_MAP);
@@ -261,7 +261,8 @@ bool SparseTextureClampLookupResidencyTestCase::funcAllowed(GLint target, GLint
 
        if (format == GL_DEPTH_COMPONENT16)
        {
-               if (target == GL_TEXTURE_CUBE_MAP_ARRAY && funcToken.name == "sparseTextureGradClampARB")
+               if (target == GL_TEXTURE_CUBE_MAP_ARRAY &&
+                       (funcToken.name == "sparseTextureGradClampARB" || funcToken.name == "textureGradClampARB"))
                        return false;
        }
 
@@ -374,6 +375,7 @@ bool SparseTextureClampLookupResidencyTestCase::verifyLookupTextureData(const Fu
                        replaceToken("<EPSILON>", s.epsilon.c_str(), fragment);
                        replaceToken("<SAMPLE_DEF>", s.sampleDef.c_str(), fragment);
                        replaceToken("<REFZ_DEF>", s.refZDef.c_str(), fragment);
+                       replaceToken("<CUBE_REFZ_DEF>", s.cubeMapArrayRefZDef.c_str(), fragment);
                        replaceToken("<POINT_COORD>", s.pointCoord.c_str(), fragment);
                        replaceToken("<COMPONENT_DEF>", s.componentDef.c_str(), fragment);
                        replaceToken("<CUBE_MAP_COORD_DEF>", s.cubeMapCoordDef.c_str(), fragment);
@@ -480,6 +482,15 @@ void SparseTextureClampLookupResidencyTestCase::draw(GLint target, GLint layer,
                floatCoord = glu::va::Float("inCoord", 3, 4, 0, texCoord3D);
        else if (target == GL_TEXTURE_CUBE_MAP)
                floatCoord = glu::va::Float("inCoord", 3, 4, 0, texCoordCubeMap[layer]);
+       else if (target == GL_TEXTURE_CUBE_MAP_ARRAY)
+       {
+               GLfloat           layerCoord                       = GLfloat(layer) / 6.0f + 0.01f;
+               const GLfloat texCoordCubeMapArray[16] = { 0.0f, 0.0f, layerCoord, GLfloat(layer),
+                                                                                                  1.0f, 0.0f, layerCoord, GLfloat(layer),
+                                                                                                  0.0f, 1.0f, layerCoord, GLfloat(layer),
+                                                                                                  1.0f, 1.0f, layerCoord, GLfloat(layer) };
+               floatCoord = glu::va::Float("inCoord", 4, 4, 0, texCoordCubeMapArray);
+       }
        else
                floatCoord = glu::va::Float("inCoord", 2, 4, 0, texCoord2D);
 
@@ -510,7 +521,7 @@ void SparseTextureClampLookupColorTestCase::init()
        mSupportedInternalFormats.push_back(GL_DEPTH_COMPONENT16);
 
        FunctionToken f;
-       f = FunctionToken("sparseTextureClampARB", ", <LOD>");
+       f = FunctionToken("sparseTextureClampARB", "<CUBE_REFZ_DEF>, <LOD>");
        f.allowedTargets.insert(GL_TEXTURE_2D);
        f.allowedTargets.insert(GL_TEXTURE_2D_ARRAY);
        f.allowedTargets.insert(GL_TEXTURE_CUBE_MAP);
@@ -518,7 +529,7 @@ void SparseTextureClampLookupColorTestCase::init()
        f.allowedTargets.insert(GL_TEXTURE_3D);
        mFunctions.push_back(f);
 
-       f = FunctionToken("textureClampARB", ", <LOD>");
+       f = FunctionToken("textureClampARB", "<CUBE_REFZ_DEF>, <LOD>");
        f.allowedTargets.insert(GL_TEXTURE_1D);
        f.allowedTargets.insert(GL_TEXTURE_1D_ARRAY);
        f.allowedTargets.insert(GL_TEXTURE_2D);
@@ -866,6 +877,7 @@ bool SparseTextureClampLookupColorTestCase::verifyLookupTextureData(const Functi
                        replaceToken("<EPSILON>", s.epsilon.c_str(), fragment);
                        replaceToken("<SAMPLE_DEF>", s.sampleDef.c_str(), fragment);
                        replaceToken("<REFZ_DEF>", s.refZDef.c_str(), fragment);
+                       replaceToken("<CUBE_REFZ_DEF>", s.cubeMapArrayRefZDef.c_str(), fragment);
                        replaceToken("<POINT_COORD>", s.pointCoord.c_str(), fragment);
                        replaceToken("<COMPONENT_DEF>", s.componentDef.c_str(), fragment);
                        replaceToken("<CUBE_MAP_COORD_DEF>", s.cubeMapCoordDef.c_str(), fragment);