Sign in to follow this  
HeroOfSpielburg

Packing VS structs

Recommended Posts

Hello, This topic has been skirted around several times before in other threads, but unfortunately I haven't been able to construct a solution yet, so I'll present my particular challenge here. I am trying to build a singular instancing solution that will work on any sort of hardware. I do not want to incur the CPU overhead of vertex buffer locking so I am using an extremely simplistic vertex stream and loading the vertex shader constant registers with a series of "instance" structures. Currently, I handle one instance's attributes per five register lines (20 floats), but I'd like to get that down to three lines. A lot of the data for the instance is quite simple and a waste at a full float (for example one attribute is a bias to apply to the vertex position that is either 0, 0.5, or -0.5). One big win I thought of trying is using HALF values for things like matrices and texture UVs. However, I've read that this is not supported on all hardware, and in the case it is not it is "emulated as a float". What does this emulation produce, exactly? Can I still upload a 16-bit floating value in the struct and have the shader reference it correctly? I tried something similar by cramming an RGBA value into a single 32-bit int and pulling out the component values via recursive division, but when I looked at the results in PIX, it seemed that the shader program wouldn't correctly utilize the contents of the register, the values weren't listed in the debugger. If there is a better way to go about uploading compact limited precision data to a vertex shader, I would be much obliged to hear some ideas. Thank you for the time!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this