Commit e2b43f00 by Alexis Hetu Committed by Alexis Hétu

Transform feedback varyings gather operation

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/3621Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent a734c0f3
......@@ -96,9 +96,8 @@ namespace es2
{
}
LinkedVarying::LinkedVarying(const std::string &name, GLenum type, GLsizei size, const std::string &semanticName,
unsigned int semanticIndex, unsigned int semanticIndexCount)
: name(name), type(type), size(size), semanticName(semanticName), semanticIndex(semanticIndex), semanticIndexCount(semanticIndexCount)
LinkedVarying::LinkedVarying(const std::string &name, GLenum type, GLsizei sizet)
: name(name), type(type), size(size)
{
}
......@@ -111,6 +110,8 @@ namespace es2
pixelBinary = 0;
vertexBinary = 0;
transformFeedbackBufferMode = GL_INTERLEAVED_ATTRIBS;
infoLog = 0;
validated = false;
......@@ -1084,11 +1085,11 @@ namespace es2
bool Program::linkVaryings()
{
for(glsl::VaryingList::iterator input = fragmentShader->varyings.begin(); input != fragmentShader->varyings.end(); input++)
for(glsl::VaryingList::iterator input = fragmentShader->varyings.begin(); input != fragmentShader->varyings.end(); ++input)
{
bool matched = false;
for(glsl::VaryingList::iterator output = vertexShader->varyings.begin(); output != vertexShader->varyings.end(); output++)
for(glsl::VaryingList::iterator output = vertexShader->varyings.begin(); output != vertexShader->varyings.end(); ++output)
{
if(output->name == input->name)
{
......@@ -1115,9 +1116,9 @@ namespace es2
glsl::VaryingList &psVaryings = fragmentShader->varyings;
glsl::VaryingList &vsVaryings = vertexShader->varyings;
for(glsl::VaryingList::iterator output = vsVaryings.begin(); output != vsVaryings.end(); output++)
for(glsl::VaryingList::iterator output = vsVaryings.begin(); output != vsVaryings.end(); ++output)
{
for(glsl::VaryingList::iterator input = psVaryings.begin(); input != psVaryings.end(); input++)
for(glsl::VaryingList::iterator input = psVaryings.begin(); input != psVaryings.end(); ++input)
{
if(output->name == input->name)
{
......@@ -1169,6 +1170,33 @@ namespace es2
return true;
}
bool Program::gatherTransformFeedbackLinkedVaryings()
{
// Varyings have already been validated in linkVaryings()
glsl::VaryingList &vsVaryings = vertexShader->varyings;
for(std::vector<std::string>::iterator trVar = transformFeedbackVaryings.begin(); trVar != transformFeedbackVaryings.end(); ++trVar)
{
bool found = false;
for(glsl::VaryingList::iterator var = vsVaryings.begin(); var != vsVaryings.end(); ++var)
{
if(var->name == (*trVar))
{
transformFeedbackLinkedVaryings.push_back(LinkedVarying(var->name, var->type, var->size()));
found = true;
break;
}
}
if(!found)
{
return false;
}
}
return true;
}
// Links the code of the vertex and pixel shader by matching up their varyings,
// compiling them into binaries, determining the attribute mappings, and collecting
// a list of uniforms
......@@ -1211,6 +1239,11 @@ namespace es2
return;
}
if(!gatherTransformFeedbackLinkedVaryings())
{
return;
}
linked = true; // Success
}
......@@ -1220,7 +1253,7 @@ namespace es2
unsigned int usedLocations = 0;
// Link attributes that have a binding location
for(glsl::ActiveAttributes::iterator attribute = vertexShader->activeAttributes.begin(); attribute != vertexShader->activeAttributes.end(); attribute++)
for(glsl::ActiveAttributes::iterator attribute = vertexShader->activeAttributes.begin(); attribute != vertexShader->activeAttributes.end(); ++attribute)
{
int location = getAttributeBinding(attribute->name);
......@@ -1249,7 +1282,7 @@ namespace es2
}
// Link attributes that don't have a binding location
for(glsl::ActiveAttributes::iterator attribute = vertexShader->activeAttributes.begin(); attribute != vertexShader->activeAttributes.end(); attribute++)
for(glsl::ActiveAttributes::iterator attribute = vertexShader->activeAttributes.begin(); attribute != vertexShader->activeAttributes.end(); ++attribute)
{
int location = getAttributeBinding(attribute->name);
......@@ -2283,6 +2316,7 @@ namespace es2
}
uniformIndex.clear();
transformFeedbackLinkedVaryings.clear();
delete[] infoLog;
infoLog = 0;
......
......@@ -107,19 +107,13 @@ namespace es2
struct LinkedVarying
{
LinkedVarying();
LinkedVarying(const std::string &name, GLenum type, GLsizei size, const std::string &semanticName,
unsigned int semanticIndex, unsigned int semanticIndexCount);
LinkedVarying(const std::string &name, GLenum type, GLsizei size);
// Original GL name
std::string name;
GLenum type;
GLsizei size;
// DirectX semantic information
std::string semanticName;
unsigned int semanticIndex;
unsigned int semanticIndexCount;
};
class Program
......@@ -223,6 +217,7 @@ namespace es2
void resetUniformBlockBindings();
bool linkVaryings();
bool gatherTransformFeedbackLinkedVaryings();
bool linkAttributes();
int getAttributeBinding(const std::string &name);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment