PDA

View Full Version : Transform Feedback implementation



Shirakana
11-09-2010, 01:35 AM
Hi !
I'm trying to implement an algorithm using Transform Feedback feature but I'm having trouble reading the data back to process them. I may do something wrong but I really can't figure out what. Please help !

Here is the initialization stuff:

--------------------
// Data structure to store Eye space position and Screen Space position
struct ES_AND_SS {
float x,y,z;
int u,v;
};

// Buffer to store data
ES_AND_SS* tabData;

// Varying names to be recorded from vertex shader output
static const char* varyingNames[] = {
"ESPosition",
"ssCoord"
};

// Initializing data buffer
glTransformFeedbackVaryings(myProgramID,2,varyingN ames,GL_INTERLEAVED_ATTRIBS);

glGenBuffers(1,&bufferID);
size = 1000;

// Allocate space
tabData = new ES_AND_SS[size];
glBufferData(GL_TRANSFORM_FEEDBACK_BUFFER,size*siz eof(ES_AND_SS), NULL, GL_DYNAMIC_READ);

----------------

// When rendering:
myProgram->activate();
glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER,bufferID );
glBeginTransformFeedback(GL_POINTS);

//... draw some vertices ...

myProgram->deactivate();
glEndTransformFeedback();

// Reading back data
glGetBufferSubData(GL_TRANSFORM_FEEDBACK_BUFFER, 0, size*sizeof(ES_AND_SS), tabData);

// unbind
glBindBuffer(GL_TRANSFORM_FEEDBACK_BUFFER,0);

-----------------
But when parsing my data buffer I just get crappy values.
What the hell am I doing wrong ?

Thanks for your answers

randall
11-09-2010, 06:16 AM
You must re-link your program after glTransformFeedbackVaryings call.

Shirakana
11-09-2010, 06:59 AM
I tried this already and it fails in another way.
If I re-link my program I get no vertices transform !! I checked using a GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN query and it returns 0. Weird huh ?

randall
11-09-2010, 08:56 AM
Try to deactivate() your program after glEndTransformFeedback() not before.

Shirakana
11-10-2010, 03:06 AM
Done... but it doesn't solve the problem :(

Shirakana
11-10-2010, 06:20 AM
Ok I've got one of the answer: DO NOT FORGET TO BIND YOUR BUFFER BEFORE CALLING glBufferData(..)

So now the glGetBufferSubData(..) is ok but I still read 0.0 in all my data :(

Shirakana
11-12-2010, 07:27 AM
After many tests I realized that INTERLEAVED mode of transform feedback simply doesn't work, whereas SEPARATE mode works very well (driver bug ?). So much time lost for this :(

So don't use GL_INTERLEAVED_ATTRIBS but GL_SEPARATE_ATTRIBS instead !!