PDA

View Full Version : When do double precision VBOs convert to float



Ternary
02-14-2011, 03:54 PM
Assuming a graphics card which does not support double precision values (i.e. pre OpenGL 4)

When does the the following code convert doubles to floats.



// code snippet
const GLdouble vts[] = {0.0, 0.0, 0.0,
1.0, 0.0, 0.0,
0.2, 1.0, 0.0};
glGenBuffers(1, &name);
glBindBuffer(GL_ARRAY_BUFFER, name);
glBufferData(GL_ARRAY_BUFFER, sizeof(vts), vts, GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_DOUBLE, GL_FALSE, 0, 0);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);


It seems to me that the conversion from double to float would be between reading the double from the gpu VBO and handing it off to the vertex shader. Is this correct?

If so I am storing double precision in the VBO which is a poor use of memory as I'm storing doubles but using floats, correct?

Also I'm taking a speed hit in the conversion from double to float EVERY time the VBO is used, correct?

Thanks

Dark Photon
02-14-2011, 06:04 PM
Assuming a graphics card which does not support double precision values (i.e. pre OpenGL 4) When does the the following code convert doubles to floats.



glVertexAttribPointer(0, 3, GL_DOUBLE, GL_FALSE, 0, 0);


I haven't used it, but my read is that to specify double values for double vertex attributes, you need to use glVertexAttribLPointer. But I confess to have never tried this yet... So I think your code will result in the GPU converting the double[3]'s to float regardless whether the GPU supports 64-bit vtx attribs.

As far as when the conversion occurs, you don't type it when it goes into the buffer, so would seem the GPU needs to convert it on-the-fly as it's read into the shader.

mhagain
02-15-2011, 07:13 AM
Based on your assumption that the GPU doesn't natively support doubles, I would expect that it would have to happen in software, and your VBO is actually software emulated.