OSDN Git Service

Transform feedback varyings gather operation
authorAlexis Hetu <sugoi@google.com>
Thu, 2 Jul 2015 14:59:51 +0000 (10:59 -0400)
committerAlexis Hétu <sugoi@google.com>
Tue, 7 Jul 2015 13:54:47 +0000 (13:54 +0000)
A few small things were missing to get the transform
feedback varyings gather operation to work properly:
- A basic implementation of
  Program::gatherTransformFeedbackLinkedVaryings()
  has been made as a first step.
- transformFeedbackBufferMode is now initialized in
  the constructor
- transformFeedbackLinkedVaryings are now properly
  reset

Also:
- Removed useless DirectX semantic information from
  the LinkedVarying class
- ++it is more efficient than it++ in a loop, because
  it++ create a temporary object to return the
  original state of the iterator, so I made the
  changes where applicable in Program.cpp.

Change-Id: I78513f185ef5ef1a17448606b5c598c22d0d217e
Reviewed-on: https://swiftshader-review.googlesource.com/3621
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
src/OpenGL/libGLESv2/Program.cpp
src/OpenGL/libGLESv2/Program.h

index 2e78c2c..636a073 100644 (file)
@@ -96,9 +96,8 @@ namespace es2
        {\r
        }\r
 \r
-       LinkedVarying::LinkedVarying(const std::string &name, GLenum type, GLsizei size, const std::string &semanticName,\r
-                                    unsigned int semanticIndex, unsigned int semanticIndexCount)\r
-        : name(name), type(type), size(size), semanticName(semanticName), semanticIndex(semanticIndex), semanticIndexCount(semanticIndexCount)\r
+       LinkedVarying::LinkedVarying(const std::string &name, GLenum type, GLsizei sizet)\r
+        : name(name), type(type), size(size)\r
        {\r
        }\r
 \r
@@ -111,6 +110,8 @@ namespace es2
                pixelBinary = 0;\r
                vertexBinary = 0;\r
 \r
+               transformFeedbackBufferMode = GL_INTERLEAVED_ATTRIBS;\r
+\r
                infoLog = 0;\r
                validated = false;\r
 \r
@@ -1084,11 +1085,11 @@ namespace es2
 \r
        bool Program::linkVaryings()\r
        {\r
-               for(glsl::VaryingList::iterator input = fragmentShader->varyings.begin(); input != fragmentShader->varyings.end(); input++)\r
+               for(glsl::VaryingList::iterator input = fragmentShader->varyings.begin(); input != fragmentShader->varyings.end(); ++input)\r
                {\r
                        bool matched = false;\r
 \r
-                       for(glsl::VaryingList::iterator output = vertexShader->varyings.begin(); output != vertexShader->varyings.end(); output++)\r
+                       for(glsl::VaryingList::iterator output = vertexShader->varyings.begin(); output != vertexShader->varyings.end(); ++output)\r
                        {\r
                                if(output->name == input->name)\r
                                {\r
@@ -1115,9 +1116,9 @@ namespace es2
                glsl::VaryingList &psVaryings = fragmentShader->varyings;\r
                glsl::VaryingList &vsVaryings = vertexShader->varyings;\r
 \r
-               for(glsl::VaryingList::iterator output = vsVaryings.begin(); output != vsVaryings.end(); output++)\r
+               for(glsl::VaryingList::iterator output = vsVaryings.begin(); output != vsVaryings.end(); ++output)\r
                {\r
-                       for(glsl::VaryingList::iterator input = psVaryings.begin(); input != psVaryings.end(); input++)\r
+                       for(glsl::VaryingList::iterator input = psVaryings.begin(); input != psVaryings.end(); ++input)\r
                        {\r
                                if(output->name == input->name)\r
                                {\r
@@ -1169,6 +1170,33 @@ namespace es2
                return true;\r
        }\r
 \r
+       bool Program::gatherTransformFeedbackLinkedVaryings()\r
+       {\r
+               // Varyings have already been validated in linkVaryings()\r
+               glsl::VaryingList &vsVaryings = vertexShader->varyings;\r
+\r
+               for(std::vector<std::string>::iterator trVar = transformFeedbackVaryings.begin(); trVar != transformFeedbackVaryings.end(); ++trVar)\r
+               {\r
+                       bool found = false;\r
+                       for(glsl::VaryingList::iterator var = vsVaryings.begin(); var != vsVaryings.end(); ++var)\r
+                       {\r
+                               if(var->name == (*trVar))\r
+                               {\r
+                                       transformFeedbackLinkedVaryings.push_back(LinkedVarying(var->name, var->type, var->size()));\r
+                                       found = true;\r
+                                       break;\r
+                               }\r
+                       }\r
+\r
+                       if(!found)\r
+                       {\r
+                               return false;\r
+                       }\r
+               }\r
+\r
+               return true;\r
+       }\r
+\r
        // Links the code of the vertex and pixel shader by matching up their varyings,\r
        // compiling them into binaries, determining the attribute mappings, and collecting\r
        // a list of uniforms\r
@@ -1211,6 +1239,11 @@ namespace es2
                        return;\r
                }\r
 \r
+               if(!gatherTransformFeedbackLinkedVaryings())\r
+               {\r
+                       return;\r
+               }\r
+\r
                linked = true;   // Success\r
        }\r
 \r
@@ -1220,7 +1253,7 @@ namespace es2
                unsigned int usedLocations = 0;\r
 \r
                // Link attributes that have a binding location\r
-               for(glsl::ActiveAttributes::iterator attribute = vertexShader->activeAttributes.begin(); attribute != vertexShader->activeAttributes.end(); attribute++)\r
+               for(glsl::ActiveAttributes::iterator attribute = vertexShader->activeAttributes.begin(); attribute != vertexShader->activeAttributes.end(); ++attribute)\r
                {\r
                        int location = getAttributeBinding(attribute->name);\r
 \r
@@ -1249,7 +1282,7 @@ namespace es2
                }\r
 \r
                // Link attributes that don't have a binding location\r
-               for(glsl::ActiveAttributes::iterator attribute = vertexShader->activeAttributes.begin(); attribute != vertexShader->activeAttributes.end(); attribute++)\r
+               for(glsl::ActiveAttributes::iterator attribute = vertexShader->activeAttributes.begin(); attribute != vertexShader->activeAttributes.end(); ++attribute)\r
                {\r
                        int location = getAttributeBinding(attribute->name);\r
 \r
@@ -2283,6 +2316,7 @@ namespace es2
                }\r
 \r
                uniformIndex.clear();\r
+               transformFeedbackLinkedVaryings.clear();\r
 \r
                delete[] infoLog;\r
                infoLog = 0;\r
index 89f5e48..d6af502 100644 (file)
@@ -107,19 +107,13 @@ namespace es2
        struct LinkedVarying\r
        {\r
                LinkedVarying();\r
-               LinkedVarying(const std::string &name, GLenum type, GLsizei size, const std::string &semanticName,\r
-                             unsigned int semanticIndex, unsigned int semanticIndexCount);\r
+               LinkedVarying(const std::string &name, GLenum type, GLsizei size);\r
 \r
                // Original GL name\r
                std::string name;\r
 \r
                GLenum type;\r
                GLsizei size;\r
-\r
-               // DirectX semantic information\r
-               std::string semanticName;\r
-               unsigned int semanticIndex;\r
-               unsigned int semanticIndexCount;\r
        };\r
 \r
        class Program\r
@@ -223,6 +217,7 @@ namespace es2
                void resetUniformBlockBindings();\r
 \r
                bool linkVaryings();\r
+               bool gatherTransformFeedbackLinkedVaryings();\r
 \r
                bool linkAttributes();\r
                int getAttributeBinding(const std::string &name);\r