PDA

View Full Version : problem with glBufferAddressRangeNV



Sylvain Rochette
08-12-2013, 05:28 PM
I have one big VBO & IBO, this VBO store 3 kinds of attributes.

I use glGenVertexArrays / glBindVertexArray to record all my attributes for my 3 kind of attributes.

XYZ + NORMAL + UV + UV2 + COLOR
XYX + UV for ENV MAP
XYZ + NORMAL + UV

When I use glBindVertexArray, I need to call glBufferAddressRangeNV for each attributes
even if that was done during my vertex array creation...

Creation code:


glGenVertexArrays(1, &m_id);
glBindVertexArray(m_id);
...
glVertexAttribFormatNV(attrib, size, GL_FLOAT, GL_FALSE, stride);
..
for each attrib...
glEnableVertexAttribArray(i);
glBufferAddressRangeNV(GL_VERTEX_ATTRIB_ARRAY_ADDR ESS_NV, i, vb->m_address + offset, vb->size() - offset);
..
glBufferAddressRangeNV(GL_ELEMENT_ARRAY_ADDRESS_NV , 0, ib->m_address, ib->size());
glEnableClientState(GL_ELEMENT_ARRAY_UNIFIED_NV);
glEnableClientState(GL_VERTEX_ATTRIB_ARRAY_UNIFIED _NV);
glBindVertexArray(0);


This is not the full code since i have a class that handle attributes, so it can be anything... its not hardcoded...

Anyway, Why glBufferAddressRangeNV need to be called each time glBindVertexArray is used? If I dont call that nothing is rendered, maybe its related because I have multiple vertex array in one VBO. but its not an issue if I dont use unified memory...

Dark Photon
08-13-2013, 06:52 AM
Anyway, Why glBufferAddressRangeNV need to be called each time glBindVertexArray is used? If I dont call that nothing is rendered...
Doesn't make sense to me. NV_vertex_buffer_unified_memory clearly states that {VERTEX_ATTRIB,ELEMENT}_ARRAY_{ADDRESS,LENGTH}_NV and the associated enables are VAO state. That said, I don't use VAOs with bindless as I saw worse performance when I tried this. I just store this data in my batch state objects. Less cache misses with that I suspect.

Are you sure your start addresses and sizes are static?

Sylvain Rochette
08-13-2013, 09:14 AM
Doesn't make sense to me. NV_vertex_buffer_unified_memory clearly states that {VERTEX_ATTRIB,ELEMENT}_ARRAY_{ADDRESS,LENGTH}_NV and the associated enables are VAO state. That said, I don't use VAOs with bindless as I saw worse performance when I tried this. I just store this data in my batch state objects. Less cache misses with that I suspect.

Are you sure your start addresses and sizes are static?

The address is ok, I used a sample you pasted on another thread, the address is get just after the creation of the VBO / IBO.

The IBO state seam to work, but for my static VBO, it seam to not work so far, but I have 3 VAO to that VBO, I did not try just one, because i need to deactivate lot of crap to test this, so right now , the same code used to create the VAO after i bind a VAO to setup the address...

Maybe I need to setup something that I am not aware, but all samples I saw from the forum and net just use VBO without VAO, and VAO is working quite fine without NV (on my side)

I think I got an increase of about 10% in FPS with NV but since I set the address each time, I bet I can do better if VAO do his job. You say it will be worse maybe :) but I cannot verify this right now :(