Jump to content
  • Advertisement
Sign in to follow this  

Packing VS structs

This topic is 3908 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!