OSDN Git Service

glGetFragDataLocation implementation
authorAlexis Hetu <sugoi@google.com>
Wed, 16 Aug 2017 20:37:19 +0000 (16:37 -0400)
committerAlexis Hétu <sugoi@google.com>
Thu, 17 Aug 2017 16:55:17 +0000 (16:55 +0000)
Implemented glGetFragDataLocation. There's very little coverage for
this function in dEQP, but the one test that uses it passes.

Change-Id: I6cfc93d7eaad54f23c922e45dafee9cba3401c83
Note: Chromium's ES3 path requires this function to be implemented.
Reviewed-on: https://swiftshader-review.googlesource.com/11728
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
src/OpenGL/libGLESv2/Program.cpp
src/OpenGL/libGLESv2/Program.h
src/OpenGL/libGLESv2/libGLESv3.cpp

index 24d1f3c..7eda6f5 100644 (file)
@@ -254,6 +254,27 @@ namespace es2
                return vertexBinary;
        }
 
+       GLint Program::getFragDataLocation(const GLchar *name)
+       {
+               if(name && linked)
+               {
+                       std::string baseName(name);
+                       unsigned int subscript = GL_INVALID_INDEX;
+                       baseName = ParseUniformName(baseName, &subscript);
+                       for(glsl::VaryingList::iterator input = fragmentShader->varyings.begin(); input != fragmentShader->varyings.end(); ++input)
+                       {
+                               if(input->name == baseName)
+                               {
+                                       int rowCount = VariableRowCount(input->type);
+                                       int colCount = VariableColumnCount(input->type);
+                                       return (subscript == GL_INVALID_INDEX) ? input->reg : input->reg + (rowCount > 1 ? colCount * subscript : subscript);
+                               }
+                       }
+               }
+
+               return -1;
+       }
+
        void Program::bindAttributeLocation(GLuint index, const char *name)
        {
                if(index < MAX_VERTEX_ATTRIBS)
index 56f7df7..9d4621e 100644 (file)
@@ -182,6 +182,8 @@ namespace es2
                void getInfoLog(GLsizei bufSize, GLsizei *length, char *infoLog);
                void getAttachedShaders(GLsizei maxCount, GLsizei *count, GLuint *shaders);
 
+               GLint getFragDataLocation(const GLchar *name);
+
                void getActiveAttribute(GLuint index, GLsizei bufsize, GLsizei *length, GLint *size, GLenum *type, GLchar *name) const;
                size_t getActiveAttributeCount() const;
                GLint getActiveAttributeMaxLength() const;
index 642e5bb..f995d2d 100644 (file)
@@ -2280,11 +2280,6 @@ GL_APICALL GLint GL_APIENTRY glGetFragDataLocation(GLuint program, const GLchar
 
        es2::Context *context = es2::getContext();
 
-       if(strstr(name, "gl_") == name)
-       {
-               return -1;
-       }
-
        if(context)
        {
                es2::Program *programObject = context->getProgram(program);
@@ -2305,9 +2300,10 @@ GL_APICALL GLint GL_APIENTRY glGetFragDataLocation(GLuint program, const GLchar
                {
                        return error(GL_INVALID_OPERATION, -1);
                }
+
+               return programObject->getFragDataLocation(name);
        }
 
-       UNIMPLEMENTED();
        return -1;
 }