Commit 638e2ae4 by Alexis Hetu Committed by Alexis Hétu

Transform feedback varyings API

Implemented the API functions to set and get the varyings used for transform feedback. Change-Id: I0d6451cfbd4a4b1b96dd9c064bb9b310b46764c4 Reviewed-on: https://swiftshader-review.googlesource.com/3462Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent e09941af
...@@ -92,6 +92,16 @@ namespace es2 ...@@ -92,6 +92,16 @@ namespace es2
{ {
} }
LinkedVarying::LinkedVarying()
{
}
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)
{
}
Program::Program(ResourceManager *manager, GLuint handle) : resourceManager(manager), handle(handle), serial(issueSerial()) Program::Program(ResourceManager *manager, GLuint handle) : resourceManager(manager), handle(handle), serial(issueSerial())
{ {
device = getDevice(); device = getDevice();
...@@ -2579,6 +2589,80 @@ namespace es2 ...@@ -2579,6 +2589,80 @@ namespace es2
return maxLength; return maxLength;
} }
void Program::setTransformFeedbackVaryings(GLsizei count, const GLchar *const *varyings, GLenum bufferMode)
{
transformFeedbackVaryings.resize(count);
for(GLsizei i = 0; i < count; i++)
{
transformFeedbackVaryings[i] = varyings[i];
}
transformFeedbackBufferMode = bufferMode;
}
void Program::getTransformFeedbackVarying(GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name) const
{
if(linked)
{
ASSERT(index < transformFeedbackLinkedVaryings.size());
const LinkedVarying &varying = transformFeedbackLinkedVaryings[index];
GLsizei lastNameIdx = std::min(bufSize - 1, static_cast<GLsizei>(varying.name.length()));
if(length)
{
*length = lastNameIdx;
}
if(size)
{
*size = varying.size;
}
if(type)
{
*type = varying.type;
}
if(name)
{
memcpy(name, varying.name.c_str(), lastNameIdx);
name[lastNameIdx] = '\0';
}
}
}
GLsizei Program::getTransformFeedbackVaryingCount() const
{
if(linked)
{
return static_cast<GLsizei>(transformFeedbackLinkedVaryings.size());
}
else
{
return 0;
}
}
GLsizei Program::getTransformFeedbackVaryingMaxLength() const
{
if(linked)
{
GLsizei maxSize = 0;
for(size_t i = 0; i < transformFeedbackLinkedVaryings.size(); i++)
{
const LinkedVarying &varying = transformFeedbackLinkedVaryings[i];
maxSize = std::max(maxSize, static_cast<GLsizei>(varying.name.length() + 1));
}
return maxSize;
}
else
{
return 0;
}
}
GLenum Program::getTransformFeedbackBufferMode() const
{
return transformFeedbackBufferMode;
}
void Program::flagForDeletion() void Program::flagForDeletion()
{ {
orphaned = true; orphaned = true;
......
...@@ -104,6 +104,24 @@ namespace es2 ...@@ -104,6 +104,24 @@ namespace es2
unsigned int index; unsigned int index;
}; };
struct LinkedVarying
{
LinkedVarying();
LinkedVarying(const std::string &name, GLenum type, GLsizei size, const std::string &semanticName,
unsigned int semanticIndex, unsigned int semanticIndexCount);
// Original GL name
std::string name;
GLenum type;
GLsizei size;
// DirectX semantic information
std::string semanticName;
unsigned int semanticIndex;
unsigned int semanticIndexCount;
};
class Program class Program
{ {
public: public:
...@@ -180,6 +198,12 @@ namespace es2 ...@@ -180,6 +198,12 @@ namespace es2
GLint getActiveUniformBlockCount() const; GLint getActiveUniformBlockCount() const;
GLint getActiveUniformBlockMaxLength() const; GLint getActiveUniformBlockMaxLength() const;
void setTransformFeedbackVaryings(GLsizei count, const GLchar *const *varyings, GLenum bufferMode);
void getTransformFeedbackVarying(GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name) const;
GLsizei getTransformFeedbackVaryingCount() const;
GLsizei getTransformFeedbackVaryingMaxLength() const;
GLenum getTransformFeedbackBufferMode() const;
void addRef(); void addRef();
void release(); void release();
unsigned int getRefCount() const; unsigned int getRefCount() const;
...@@ -253,6 +277,9 @@ namespace es2 ...@@ -253,6 +277,9 @@ namespace es2
GLuint uniformBlockBindings[MAX_UNIFORM_BUFFER_BINDINGS]; GLuint uniformBlockBindings[MAX_UNIFORM_BUFFER_BINDINGS];
std::vector<std::string> transformFeedbackVaryings;
GLenum transformFeedbackBufferMode;
struct Sampler struct Sampler
{ {
bool active; bool active;
...@@ -269,6 +296,8 @@ namespace es2 ...@@ -269,6 +296,8 @@ namespace es2
UniformIndex uniformIndex; UniformIndex uniformIndex;
typedef std::vector<UniformBlock*> UniformBlockArray; typedef std::vector<UniformBlock*> UniformBlockArray;
UniformBlockArray uniformBlocks; UniformBlockArray uniformBlocks;
typedef std::vector<LinkedVarying> LinkedVaryingArray;
LinkedVaryingArray transformFeedbackLinkedVaryings;
bool linked; bool linked;
bool orphaned; // Flag to indicate that the program can be deleted when no longer in use bool orphaned; // Flag to indicate that the program can be deleted when no longer in use
......
...@@ -3196,6 +3196,33 @@ void GetProgramiv(GLuint program, GLenum pname, GLint* params) ...@@ -3196,6 +3196,33 @@ void GetProgramiv(GLuint program, GLenum pname, GLint* params)
return; return;
} }
else return error(GL_INVALID_ENUM); else return error(GL_INVALID_ENUM);
case GL_TRANSFORM_FEEDBACK_BUFFER_MODE:
if(clientVersion >= 3)
{
*params = programObject->getTransformFeedbackBufferMode();
return;
}
else return error(GL_INVALID_ENUM);
case GL_TRANSFORM_FEEDBACK_VARYINGS:
if(clientVersion >= 3)
{
*params = programObject->getTransformFeedbackVaryingCount();
return;
}
else return error(GL_INVALID_ENUM);
case GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH:
if(clientVersion >= 3)
{
*params = programObject->getTransformFeedbackVaryingMaxLength();
return;
}
else return error(GL_INVALID_ENUM);
case GL_PROGRAM_BINARY_RETRIEVABLE_HINT:
if(clientVersion >= 3)
{
UNIMPLEMENTED();
}
else return error(GL_INVALID_ENUM);
default: default:
return error(GL_INVALID_ENUM); return error(GL_INVALID_ENUM);
} }
......
...@@ -1971,9 +1971,9 @@ GL_APICALL void GL_APIENTRY glTransformFeedbackVaryings(GLuint program, GLsizei ...@@ -1971,9 +1971,9 @@ GL_APICALL void GL_APIENTRY glTransformFeedbackVaryings(GLuint program, GLsizei
{ {
return error(GL_INVALID_VALUE); return error(GL_INVALID_VALUE);
} }
}
UNIMPLEMENTED(); programObject->setTransformFeedbackVaryings(count, varyings, bufferMode);
}
} }
GL_APICALL void GL_APIENTRY glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name) GL_APICALL void GL_APIENTRY glGetTransformFeedbackVarying(GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name)
...@@ -1981,6 +1981,11 @@ GL_APICALL void GL_APIENTRY glGetTransformFeedbackVarying(GLuint program, GLuint ...@@ -1981,6 +1981,11 @@ GL_APICALL void GL_APIENTRY glGetTransformFeedbackVarying(GLuint program, GLuint
TRACE("(GLuint program = %d, GLuint index = %d, GLsizei bufSize = %d, GLsizei *length = %p, GLsizei *size = %p, GLenum *type = %p, GLchar *name = %p)", TRACE("(GLuint program = %d, GLuint index = %d, GLsizei bufSize = %d, GLsizei *length = %p, GLsizei *size = %p, GLenum *type = %p, GLchar *name = %p)",
program, index, bufSize, length, size, type, name); program, index, bufSize, length, size, type, name);
if(bufSize < 0)
{
return error(GL_INVALID_VALUE);
}
es2::Context *context = es2::getContext(); es2::Context *context = es2::getContext();
if(context) if(context)
...@@ -1991,9 +1996,14 @@ GL_APICALL void GL_APIENTRY glGetTransformFeedbackVarying(GLuint program, GLuint ...@@ -1991,9 +1996,14 @@ GL_APICALL void GL_APIENTRY glGetTransformFeedbackVarying(GLuint program, GLuint
{ {
return error(GL_INVALID_VALUE); return error(GL_INVALID_VALUE);
} }
}
UNIMPLEMENTED(); if(index >= static_cast<GLuint>(programObject->getTransformFeedbackVaryingCount()))
{
return error(GL_INVALID_VALUE);
}
programObject->getTransformFeedbackVarying(index, bufSize, length, size, type, name);
}
} }
GL_APICALL void GL_APIENTRY glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer) GL_APICALL void GL_APIENTRY glVertexAttribIPointer(GLuint index, GLint size, GLenum type, GLsizei stride, const void *pointer)
......
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