Shocker's picture

TransformFeedback problem

Now I am trying for TransformFeedback .
I made a simple TF sample .
But this program causes an error at GL.LinkProgram probably because of "TransformFeedbackVaryings".

GL.TransformFeedbackVaryings(program, 1, new string[] { "feedback" }, TransformFeedbackMode.SeparateAttribs);
GL.GetProgramInfoLog(program, out info);
GL.GetProgram(program, ProgramParameter.LinkStatus, out status_code);
if (status_code != 1)
    Link info
    error: Varying (named edback) specified but not present in the program object.
    throw new ApplicationException(info);

Try changing 2nd argument of TransformFeedback to '0', the error disappers .
But, in rendering step , result of queries was zero .
This means the program couldn't write vertices into buffer object .

Could anyone tell me what is wrong in my code or show me a correct sample ?
Thanks .

I write down my PC's environments below . This may lead the problem to solving early .
OS : Windows Vista Home Premium SP2
CPU : Core 2 Duo T7500 2.2GHz
Mem : PC2-5300 2GB
GPU : Geforce 8600M GT (GDDR3 256MB)
ForceWare 186.81 (supports OpenGL 3.0)

Everytime, sorry for my english .

Form1.cs7.74 KB


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
kvark's picture

It looks correct. Though, you don't need fragment shader as you disable the rasterizer.

This can be easily a driver bug.
ATI fixed their Catalyst to support TF properly only 1-2 months ago.
Try latest NV drivers (even beta ones).

zahirtezcan's picture

I have got an Nvidia card and tried this code . And got the same error with some encoding problem:

error: Varying (named ë edback) specified but not present in the program object.

the Fiddler's picture

Which version of OpenTK are you using and what is your OS language settings for non-Unicode applications? (You can find this in "Control Panel" -> "Regional and Language Options", it should be the last tab).

Shocker's picture

Thanks for replies .
I use OpenTK and OS language settings for non-unicode applications is Japanese .

Fortunately, today NVIDIA released new Beta version driver 195.55 for Notebooks .
I install it and test problem again .
Unfortunately, I got same error .

the Fiddler's picture

Thanks. I've tested this on my Linux laptop (Quadro NVS135M, 190.42 drivers, Mono 2.4.3 / english codepage) and the code does not fail at that point. Instead, it fails with an "InvalidOperation" OpenGL error in the first GL.DrawArrays call. Unfortunately, I don't have access to a windows machine with transform-feedback-capable drivers right now, so I cannot test in a configuration more similar to yours.

This looks like a marshaling issue but the cause is not immediately obvious (it could be similar to #1332: 2byte character may causes a bug with GL.ShaderSource .).

Suggestion: try importing the function manually.

// Code was wrong, see below for corrected code.

We need to find out what works, so we can add this to OpenTK.

Edit: Corrected code here,

kvark's picture

I have to add what is obvious for me but might not be the same for you:
TransformFeedback + OpenTK works correctly in my engine (the 'dude' demo uses it), at least on ATI Catalyst 9.9+.
So the problem is not with OpenTK, but with Nv drivers most probably.

the Fiddler's picture

Indeed, but you have to take into account that string-related functions are affected by your regional settings. I'm not saying that this is the problem here (it could be, but that's for from certain at this point - hence the code in my previous post), but it has caused problems before so it's something to keep an eye out for.

Shocker's picture

I'm sorry for reply is late .
Where should I add code which manually calls TF ?

I tried inserting declares of delegate and it's instance into class members .
I got an error "static qualifier is improper" .
So I removed static qualifier .
then I got another error which notices wrong in argument type .
I swap 1st and 2nd argument of "Marshal.GetDelegateForFunctionPointer" .

finally error disappered , but program crashed .

Would you mind my asking you to tell me where is correct place ?

Thank you .

the Fiddler's picture

Ugh, that's what you get for writing code directly in the browser. :)

Corrected code below:

using System.Runtime.InteropServices;
// Note: this code assumes you are using GameWindow. The same code can be used with
// GLControl - the only limitation is that you need a valid GraphicsContext prior to calling
// GraphicsContext.CurrentContext.
class Game : GameWindow
    // Edit, this should be IntPtr[] varyings
    delegate void glTransformFeedbackVaryings(int program, int count, IntPtr varyings, TransformFeedbackMode bufferMode);
    static glTransformFeedbackVaryings TransformFeedbackVaryings;
    protected override void OnLoad(object sender, EventArgs e)
        base.OnLoad(sender, e);
        TransformFeedbackVaryings = (glTransformFeedbackVaryings)Marshal.GetDelegateForFunctionPointer(
            (GraphicsContext.CurrentContext as IGraphicsContextInternal).GetAddress("glTransformFeedbackVaryings"),,

Afterwards, simply use TransformFeedbackVaryings instead of GL.TransformFeedbackVaryings.

If it still crashes, please post the exception message, this could be useful.

Edit: this code also has an error, see below.

Shocker's picture

Thank you .
I added manual TransformFeedback into code .
But program still crashed or threw error that is similar to before .
A name of varying variable mentioned by the error message is strange . (What is "stemBrushesKey" ??)

TFTest_GLControl.cs8.62 KB