NV_command_list bindings

Started by sumwise, March 21, 2021, 13:39:32

Previous topic - Next topic

sumwise

Aloha dear community,

I started playing around with nv_command_list and was wondering about the methods that lwjgl exposes.
My questions are:

1) if the DrawCommandsStatesNV takes (uint buffer, const intptr* indirects, ...)
why does the lwjgl version take (int buffer, PointerBuffer indirects, ...) instead of (int buffer, IntBuffer indirects, ...)
am I supposed to provide a PointerBuffer that contains as many IntBuffers as needed where each of those
IntBuffers only contains a single offset or did I misunderstand how to provide the offsets?

2) ListDrawCommandsStatesClientNV expects (..., const sizei* sizes, ...) and the lwjgl version expects a PointerBuffer here, too
Again I am wondering how to setup the PointerBuffer to contain the sizes

Specifically it is about these commands from the extension:

void ListDrawCommandsStatesClientNV(uint list, uint segment, const void** indirects, 
                                              const sizei* sizes, const uint* states, const uint* fbos,
                                              uint count);

and the lwjgl method is
public static void glListDrawCommandsStatesClientNV(int list, int segment, PointerBuffer indirects, 
                                        PointerBuffer sizes, IntBuffer states, IntBuffer fbos)

while the spec of the extension says about this command:

Quote
    A list has multiple segments and each segment enqueues an ordered list of
    command sequences. This command enqueues the equivalent of the DrawCommandsStatesNV
    commands into the list indicated by <list> on the segment indicated by <segment>
    except that the sequence data is copied from the sequences pointed to by the <indirects>
    pointer. The <indirects> pointer should point to a list of size <count> of pointers,
    each of which should point to a command sequence.

    [...]
   
    ListDrawCommandsStatesClientNV performs a by-value copy of the
    indirect data based on the provided client-side pointers. In this case
    the content is fully immutable, while the buffer-based versions can
    change the content of the buffers at any later time.

now the mentioned DrawCommandsStatesNV has the following signature:
void DrawCommandsStatesNV(uint buffer, const intptr* indirects, const sizei* sizes, 
                                       const uint* states, const uint* fbos, uint count);
as well as a version taking addresses:
void DrawCommandsStatesAddressNV(const uint64* indirects, const sizei* sizes, 
                                              const uint* states, const uint* fbos, uint count);

and the spec states:
Quote
    These commands accept arrays of buffer addresses (either an array of
    offsets <indirects> into a buffer named by <buffer>, or an array of GPU
    addresses <indirects>), an array of sequence lengths in <sizes>, and an
    array of state object names in <states>, of which all names must be non-zero.
    Frame buffer object names are stored in <fbos> and can
    be either zero or non-zero. All arrays have <count> entries.
the lwjgl methods for those are:
public static void glDrawCommandsStatesNV(int buffer, PointerBuffer indirects, IntBuffer sizes, 
                                              IntBuffer states, IntBuffer fbos)
and the version taking addresses:
public static void glDrawCommandsStatesAddressNV(LongBuffer indirects, IntBuffer sizes, 
                                              IntBuffer states, IntBuffer fbos)


Thanks a lot in advance and many greetings from the shire,
sumwise


spasi

Quote from: sumwise on March 21, 2021, 13:39:32
1) if the DrawCommandsStatesNV takes (uint buffer, const intptr* indirects, ...)
why does the lwjgl version take (int buffer, PointerBuffer indirects, ...) instead of (int buffer, IntBuffer indirects, ...)
am I supposed to provide a PointerBuffer that contains as many IntBuffers as needed where each of those
IntBuffers only contains a single offset or did I misunderstand how to provide the offsets?

No, it's just an array of offsets. GLintptr is a 32-bit integer on 32-bit systems and a 64-bit integer on 64-bit systems. This is exactly what PointerBuffer is used for, to hide that difference. When interacting with a PointerBuffer in your application, you're working with Java longs (64-bit integers) and LWJGL automatically maps them to 32-bit integers when running on a 32-bit system.

Quote from: sumwise on March 21, 2021, 13:39:32
2) ListDrawCommandsStatesClientNV expects (..., const sizei* sizes, ...) and the lwjgl version expects a PointerBuffer here, too
Again I am wondering how to setup the PointerBuffer to contain the sizes

Thanks, this was a bug in the bindings, it will be fixed in the next 3.3.0 snapshot (sizes will be an IntBuffer).

sumwise

The responsiveness in this forum is awesome, really, thanks a lot!