move more code to d3d_shared.h