PDA

View Full Version : testing nv command list



Antonio
06-14-2016, 04:14 PM
Hi All,

I've posted this on Nvidia forums, but maybe someone here can help me too :-)

I'm beginning to play with this extension and tried to run the following code:


UniformAddressCommandNV u;
u.header = glGetCommandHeaderNV(GL_UNIFORM_ADDRESS_COMMAND_NV , sizeof UniformAddressCommandNV);
u.index = (unsigned short)materialUniLoc;
u.stage = glGetStageIndexNV(GL_FRAGMENT_SHADER);
u.addressLo = getAddressLo(myMeshes[n].uniformGPUAddr[MATERIAL_BUFFER]);
u.addressHi = getAddressHi(myMeshes[n].uniformGPUAddr[MATERIAL_BUFFER]);
glBindBuffer(GL_ARRAY_BUFFER, commandBuffer);
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof UniformAddressCommandNV, &u);
glBindBuffer(GL_ARRAY_BUFFER, 0);

GLintptr indirects[1];
GLsizei sizes[1];
indirects[0] = 0;
sizes[0] = sizeof UniformAddressCommandNV;

glDrawCommandsNV(GL_TRIANGLES, commandBuffer, indirects, sizes, 1);


The above code gives me an error, using the debug extension, in the glDrawCommandsNV line:
Type: Error; Source: API; ID: 1282; Severity: High
GL_INVALID_OPERATION error generated. Array object is not active.

However, if doing the line below instead it works OK.


glBufferAddressRangeNV(GL_UNIFORM_BUFFER_ADDRESS_N V, materialUniLoc,
myMeshes[n].uniformGPUAddr[MATERIAL_BUFFER], 0x10000/*sizeof(struct MyMaterial)*/);


From the spec these seem identical. Cn anyone help me with this?

Best regards,

António

Dark Photon
06-14-2016, 08:05 PM
The above code gives me an error, using the debug extension, in the glDrawCommandsNV line:
Type: Error; Source: API; ID: 1282; Severity: High
GL_INVALID_OPERATION error generated. Array object is not active.

Sounds like you might be running with a core context in GL 3.0+ which requires a non-zero VAO to be bound for some GL commands (a netsearch indicates the above error refers to the bound VAO. Might try a compatibility context or just create a dummy VAO and leave it bound if you're not using VAOs (bindless perf beats VAOs anyway in my experience).

Failing that, ensure that neither of these conditions listed in the NV_command_list extension for this call are true:



INVALID_OPERATION is generated if a geometry shader is active and <mode> is
incompatible with the input primitive type of the geometry shader in the currently
installed program object.
INVALID_OPERATION is generated if a non-zero buffer object name is bound to an
enabled array or the element array and the buffer object's data store is currently mapped.

Antonio
06-16-2016, 03:55 PM
Thanks Dark Photon


Sounds like you might be running with a core context in GL 3.0+ which requires a non-zero VAO to be bound for some GL commands (a netsearch indicates the above error refers to the bound VAO. Might try a compatibility context or just create a dummy VAO and leave it bound if you're not using VAOs (bindless perf beats VAOs anyway in my experience).

Spot on! No more error. I knew he was complaining about a VAO, but it didn't (and still doesn't) make sense to me why a VAO should be bound for glDrawCommandsNV.

Thanks a lot.

Still not getting the same behaviour though. Using glBindBufferRange produces the right colors, but the token alone seems to have no effect.


Best Regards,

António

Antonio
06-18-2016, 10:07 AM
Still not getting the same behaviour though. Using glBindBufferRange produces the right colors, but the token alone seems to have no effect.


I got it working as long as I do the actual drawing with the list. It seems that the binds performed in the list are gone once the command is done. Is that the case?

Best Regards,

António

Alfonse Reinheart
06-18-2016, 10:26 AM
NV_command_list does not work with glBindBufferRange. Or buffer binding of any sort. It only works with bindless stuff. You must use bindless vertex arrays, bindless textures, and bindless uniform buffers (https://www.opengl.org/registry/specs/NV/uniform_buffer_unified_memory.txt).

If you're using NV_command_list, you should never be calling `glBindBufferRange` (or Base).