Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

With the DX11 pipeline, would it be much quicker for the vertex buffer to pass one single UINT with one byte per channel to the input assembler, as opposed to three floats? Then the vertex shader would convert the four bytes to four floats, which I guess is the required colour format for the pipeline. In this instance, colour accuracy isn't an issue.

The vertex buffer would need to be updated many times per frame, so using a single UINT and saving 12 bytes for every vertex could well be worth it: quicker uploads to vram and also less memory used. But the cost is the extra shader work for every vertex to convert each 8 bits of the input UNIT into a float.

Anyone have an idea if it might be worth doing?

Or, is it possible for the pipeline to be set to just internally use a four-byte colour format? The swap chain buffer has been initialised as DXGI_FORMAT_R8G8B8A8_UNORM, so ultimately that's how the colour will be written.

Thanks!

share|improve this question
    
Hey Paul, what were your findings (performance wise)? I'm doing something similar and need to rapidly update & resize vertex buffers: –  Dr. ABT Jan 4 '13 at 14:57
add comment

1 Answer

up vote 3 down vote accepted

The pipeline will always be floating point internally, and the hardware does the int/float conversions for you, so that part of it should be very fast. If your app is vertex-bound, either on the CPU side updating the buffer or on the GPU side reading it, then the thinner UINT format could make a difference. You'll have to measure and compare the performance to see which is faster.

share|improve this answer
    
Thanks Nathan. Looks like I'll need to do some profiling. –  Paul Apr 15 '12 at 7:29
    
Speed -- unpacking the four bytes from one uint into four bytes will take a few lines of code, as it'll involve using bit shifts and masking the results with bitwise ANDs, then multiplying the result to get it into the range 0.0f to 1.0f. Using a union would be quick, but HLSL doesn't have unions. –  Paul Apr 15 '12 at 7:35
1  
@Paul In sounds like you're loading the value as a single uint and unpacking it yourself in HLSL? Why? You should just use DXGI_FORMAT_R8G8B8A8_UNORM in your input layout, so the API will do the unpacking for you. –  Nathan Reed Apr 15 '12 at 18:22
    
Wow Nathan, thanks a huge amount. Had no idea that it would be done by the API. –  Paul Apr 16 '12 at 8:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.