PDA

View Full Version : wglDXLockObjectsNV / wglDXUnlockObjectsNV Scope



henniman2
08-22-2015, 04:07 AM
Hi All,

i am a little bit unsure about the usage of this extension
https://www.opengl.org/registry/specs/NV/DX_interop.txt
especially when objects have to be locked using
wglDXLockObjectsNV.

Do they have to be locked

a) during binding


wglDXLockObjectsNV(...);
glBindTexture( target, tex );
wglDXUnlockObjectsNV(...)

b) until the next draw call


wglDXLockObjectsNV(...);
glBindTexture( target, tex );
glDrawArrays( ... )
wglDXUnlockObjectsNV(...)

c) until next finish/swapbuffers


wglDXLockObjectsNV(...);
glBindTexture( target, tex );
glDrawArrays( ... )
glFinish() // or SwapBuffers()
wglDXUnlockObjectsNV(...)

That is what the extension spec says



Before a GL object which is associated with a DirectX resource may
be used, it must be locked.

but what 'used' means in this context is unclear to me. Also, do i
have to issue a glFlush() call after the wglDXLockObjectsNV(...) to
ensure it is in the pipeline like when using fences?

Best
Henniman

Alfonse Reinheart
08-22-2015, 08:17 AM
"Used" means... used. OpenGL is pretty clear about when things are in use.

If you bind a texture, then you have used it. If you call a function that reads state from a bound texture, then you are using that texture. If you call a function that writes state to a bound texture, then you are using that texture. If you render with a texture bound, and the program fetches from that texture, then you are using that texture.

Now, OpenGL's memory model is, by default, synchronous (apparently) (https://www.opengl.org/wiki/Memory_Model). And Issue 2 of that extension makes it clear that it also deals with a synchronous memory model. So you don't need explicit synchronization before you unlock things.

The easiest way to think of it is like this: lock them before you bind them, and unlock them after you unbind them.