Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Categories
- All Discussions1,524
- General534
- Graphics109
- GPU Computing419
- Mobile141
- Pro Graphics163
- Tools158
In this Discussion
- Detlef Roettger January 11
type cast when using double-precision vbo with vert_program(float4 position : POSITION)
-
So i have this big triangular mesh with double-precision vertex positions. i am trying to render it with a solid wireframe cgfx that is declared with float3 vertex position inputs. i am a bit unsure about the performance impact of the possible double-to-float cast here.
first, suppose i am using a non-quadro, gl 4.1 capable Fermi card. generally speaking, if i upload vertices via SceniX as a double vbo to my video card, and render it with a cg vertex program that is declared to take float4 position : POSITION:
1) is a type-cast/truncation incurred every time the vertex program accesses elements of the vbo? i mean does the gpu have to type-cast double to float on-the-fly when rendering such a double vbo using a float vp? does the gpu, by any chance, intelligently cache the truncated float for the next frame?
2) is such on-the-fly type-cast (double to float) expensive? am i better off offload the conversion from double to single to the CPU before uploading the vertices to the video card?
then, alternatively, if i am using a good-old quadro fx 880m (gl 3.3), with the same double vbo, and the same float vp,
3) would the lack of double-precision support trigger a software-based rendering code path that dooms me tremendously? or would it trigger a one-time cast at the time of vbo creation that truncates doubles into floats for storage on the video card? -
1 Comment sorted by
-
I have avoided double vertex data where I can and have no recent performance comparison. You would need to benchmark your use case.
You will most likely not hit the most performant paths inside the hardware or driver when using double vertex attributes.
1.) Yes, reading double, casting to floats. No cache.
2.) Yes, expect lower performance than the maximum possible when using double vertex attributes in any case, even when the shader could use double arithmetic. Alone the bandwidth requirement is two-fold.
Yes, the recommendation is to use 32-bit floating point vertex attribute data for maximum performance. There are a few other attribute and data type combinations which are fast, but OpenGL implementations are optimized for floats since a long time.
3.) Lack of double precision vertex attributes in some older HW?
I'm not sure right now how that is handled with input data coming directly as VBO data. In the past using any of the immediate mode double entry-points was first converting the data to floats. With direct access to buffer object memory, that case gets harder if there weren't native support for double data.