FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

glBindBufferRange(EXT/NV) and GL_UNIFORM_BUFFER_EXT

 
Post new topic   Reply to topic     Forum Index -> Derelict
View previous topic :: View next topic  
Author Message
ParticlePeter



Joined: 19 Nov 2011
Posts: 49
Location: Germany

PostPosted: Sun Dec 18, 2011 3:23 pm    Post subject: glBindBufferRange(EXT/NV) and GL_UNIFORM_BUFFER_EXT Reply with quote

Hi,

has anybody managed to make Shared Uniform Buffer Object with glBindBufferRange(EXT/NV) and GL_UNIFORM_BUFFER_EXT work on Derelict2, Windows 7 and DMD2 ?

With
glBindBufferRangeNV( GL_UNIFORM_BUFFER_EXT , index , UBO , 0 , mat4.sizeof + vec4.sizeof ) ;
I am getting an GL_INVALID_ENUM directly after the call ( mat4 and vec4 are from gl3n, and sizeof returns 64 and 16, which seems correct )

and with
glBindBufferRangeEXT( GL_UNIFORM_BUFFER_EXT , index , UBO , 0 , mat4.sizeof + vec4.sizeof ) ;
I get an access violation.

I checked the validity of the program, index, UBO, everything seems O.K.

I was following directly this article:
http://arcsynthesis.org/gltut/Positioning/Tut07%20Shared%20Uniforms.html
_________________
Cheers, searching for the Pivot of my Soul, PP
Back to top
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Sun Dec 18, 2011 10:55 pm    Post subject: Re: glBindBufferRange(EXT/NV) and GL_UNIFORM_BUFFER_EXT Reply with quote

ParticlePeter wrote:
Hi,

has anybody managed to make Shared Uniform Buffer Object with glBindBufferRange(EXT/NV) and GL_UNIFORM_BUFFER_EXT work on Derelict2, Windows 7 and DMD2 ?

With
glBindBufferRangeNV( GL_UNIFORM_BUFFER_EXT , index , UBO , 0 , mat4.sizeof + vec4.sizeof ) ;
I am getting an GL_INVALID_ENUM directly after the call ( mat4 and vec4 are from gl3n, and sizeof returns 64 and 16, which seems correct )


GL_UNIFORM_BUFFER_EXT is not a valid target for glBindBufferRangeNV. That function is part of the GL_NV_transform_feedback extension. The only valid target that it accepts, as per the OpenGL extension registry, is TRANSFORM_FEEDBACK_BUFFER_NV. This enum has a different value than GL_UNIFORM_BUFFER_EXT, hence the error.

Quote:

and with
glBindBufferRangeEXT( GL_UNIFORM_BUFFER_EXT , index , UBO , 0 , mat4.sizeof + vec4.sizeof ) ;
I get an access violation.


An access violation generally means a null pointer is getting dereferenced somewhere. My first guess is that glBindBufferRangeExt is null. It's a function pointer, not a function. So before calling it, you need to make sure that the GL_EXT_bindable_uniform extension is actually loaded. You should do this for all extensions that your app requires if you aren't already.

Code:

// Load the shared library and OpenGL version 1.1.
DerelictGL.load();

// Load versions 1.2 - 2.1.
DerelictGL.loadClassicVersions();

// Load versions 3.0+ if needed
DerelictGL.loadModernVersions();

// Now load extensions. No exceptions are thrown on failure.
DerelictGL.loadExtensions();

// Test if any extensions you require are available.
if(!DerelictGL.isExtensionLoaded("GL_EXT_bindable_uniform"))
{
   ...
}


I wouldn't call this in a render loop. If you need to execute different code paths based on extension availability, you should store the return value of isExtensionLoaded and test that instead.

Also, if isExtensionLoaded returns false, you can call DerelictGL.isExtensionSupported. If it returns false, you'll know the problem is that the driver doesn't support the extension. If it returns true, you'll know that one or more function pointers failed to load, which could mean corrupt drivers.

Anyway, if that's not your problem then I suggest you make use of a debugger.
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
ParticlePeter



Joined: 19 Nov 2011
Posts: 49
Location: Germany

PostPosted: Tue Dec 20, 2011 2:38 pm    Post subject: Reply with quote

Hi, thanks for you reply.

I took some time to post, as wanted to dig deeper into this case. Unfortunately its not totally clear to me.

O.K., I tried your advice, but without success. Usually I set up DerelictGL with:
DerelictGL.loadExtendedVersions( GLVersion.GL33 ) ;
DerelictGL.loadExtensions() ;
As I wish a pure forward compatible core 3.3 context. I think this is not possible due to SDL 1.2 ( DerelictSDL which I use ), but everything was working fine so far. Anyway I also tried the code you posted, with no difference.

I checked for the extensions EXT_bindable_uniform and ARB_uniform_buffer_object ( more on that bellow ) but both were lodaded, and no error was reported.
With a debugger ( in VisualD ) I found out the function which gave me the access violation in the first place, but I am not sure what I might do additionally.

I made a mistake in my first post, I was not searching for EXT_bindable_uniform but rather ARB_uniform_buffer_object. In gl3.h the Buffer Target is defined as GL_UNIFORM_BUFFER ( defines 0x8A11 ), but derelict defines it as UNIFORM_BUFFER_ARB. Btw, why is it called differently ?

I was searching the derelict sources for the token GL_UNIFORM_BUFFER, found only GL_UNIFORM_BUFFER_EXT and assumed that this is the right one.
I found the functions ( like glBindBufferBaseEXT ) to manipulate this buffer in extloader.d inside the GLExtensionState load_GL_EXT_transform_feedback() scope block at line 2788, which confuses me. So even this functions seem to be related to a transform feedback buffer ( according to scope ), same as glBindBufferBaseNV.

Basically the function which I am looking for is glBindBufferBase, or glBindBufferRange to upload Data to the GL_UNIFORM_BUFFER ( Derelict UNIFORM_BUFFER_ARB ), but I cannot find it in the Dereleict source. Both were introduced in OpenGL 3.0. If this function is not available, with which function can I get Data into an Uniform Buffer Object ?

Btw, EXT_bindable_uniform seems to be an old outdated version of ARB_uniform_buffer_object.
_________________
Cheers, searching for the Pivot of my Soul, PP
Back to top
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Tue Dec 20, 2011 11:53 pm    Post subject: Reply with quote

ParticlePeter wrote:
Hi, thanks for you reply.

I took some time to post, as wanted to dig deeper into this case. Unfortunately its not totally clear to me.

O.K., I tried your advice, but without success. Usually I set up DerelictGL with:
DerelictGL.loadExtendedVersions( GLVersion.GL33 ) ;
DerelictGL.loadExtensions() ;
As I wish a pure forward compatible core 3.3 context. I think this is not possible due to SDL 1.2 ( DerelictSDL which I use ), but everything was working fine so far. Anyway I also tried the code you posted, with no difference.


DerelictGL.loadExtendedVersions (which is now an alias for loadClassicVersions) will not load anything higher than 2.1. So that means any 3.0+ functions will all be null. To load those, you have to call loadModernVersions. I assume it only worked for you because you weren't calling any of the newer functions.

Also, you aren't getting a core 3.3 context with SDL 1.2. If you want that, you'll have to create it yourself. In the near future, I will upload a preliminary 1.3 binding which will make this possible.

Quote:

I checked for the extensions EXT_bindable_uniform and ARB_uniform_buffer_object ( more on that bellow ) but both were lodaded, and no error was reported.
With a debugger ( in VisualD ) I found out the function which gave me the access violation in the first place, but I am not sure what I might do additionally.

I made a mistake in my first post, I was not searching for EXT_bindable_uniform but rather ARB_uniform_buffer_object. In gl3.h the Buffer Target is defined as GL_UNIFORM_BUFFER ( defines 0x8A11 ), but derelict defines it as UNIFORM_BUFFER_ARB. Btw, why is it called differently ?


No idea. All of the enums for that extension were misnamed, and half of them were missing. I've just now corrected it and committed the fix.
Quote:

I was searching the derelict sources for the token GL_UNIFORM_BUFFER, found only GL_UNIFORM_BUFFER_EXT and assumed that this is the right one.
I found the functions ( like glBindBufferBaseEXT ) to manipulate this buffer in extloader.d inside the GLExtensionState load_GL_EXT_transform_feedback() scope block at line 2788, which confuses me. So even this functions seem to be related to a transform feedback buffer ( according to scope ), same as glBindBufferBaseNV.

Basically the function which I am looking for is glBindBufferBase, or glBindBufferRange to upload Data to the GL_UNIFORM_BUFFER ( Derelict UNIFORM_BUFFER_ARB ), but I cannot find it in the Dereleict source. Both were introduced in OpenGL 3.0. If this function is not available, with which function can I get Data into an Uniform Buffer Object ?


If it's part of OpenGL 3.0, it absolutely should be there. I'll go through and see what else is missing. DerelictGL is a 1-to-1 binding, so it should always be identical to the C side. If any of the names are different or anything is missing, that's a bug.
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Wed Dec 21, 2011 12:20 am    Post subject: Reply with quote

There were a handful of 3.0 functions that were missing. I think I've got them all. Hopefully that fixes your problems. If not, please be sure to let me know.
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
ParticlePeter



Joined: 19 Nov 2011
Posts: 49
Location: Germany

PostPosted: Wed Dec 21, 2011 9:45 am    Post subject: Reply with quote

Hi,

wow, that was fast, thank you. It solved the problem with the access violation, but unfortunately the UniformBufferObject is still not working. No GL Error, GLintersect shows the right per frame GL calls, the buffer does update properly ( according to glGetBufferSubData ). But the shader does not use the updated value. This time I am pretty sure that the mistake is on my side, but can't find it.

Have you tried using an UBO by any chance ?
_________________
Cheers, searching for the Pivot of my Soul, PP
Back to top
View user's profile Send private message
ParticlePeter



Joined: 19 Nov 2011
Posts: 49
Location: Germany

PostPosted: Wed Dec 21, 2011 9:57 am    Post subject: Reply with quote

Oh, I meant GLIntercept of course http://code.google.com/p/glintercept/
_________________
Cheers, searching for the Pivot of my Soul, PP
Back to top
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Thu Dec 22, 2011 5:33 am    Post subject: Reply with quote

ParticlePeter wrote:
Have you tried using an UBO by any chance ?


Sorry, no. I know nothing about them.
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
ParticlePeter



Joined: 19 Nov 2011
Posts: 49
Location: Germany

PostPosted: Thu Dec 22, 2011 1:23 pm    Post subject: Reply with quote

Hi,

Finally I managed to make it work, thank you very much for all your help and this beautiful library Smile
_________________
Cheers, searching for the Pivot of my Soul, PP
Back to top
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Fri Dec 23, 2011 10:26 am    Post subject: Reply with quote

Thanks for your thanks! Glad things are working for you now.
_________________
The One With D | The One With Aldacron | D Bits
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Derelict All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group