On Mon, 14 Jun 2021 at 05:27, Conor McCarthy <cmccarthy(a)codeweavers.com> wrote:
libs/vkd3d-shader/spirv.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-)
There's an existing usage of vkd3d_dxbc_compiler_get_constant_float_vector() in vkd3d_dxbc_compiler_emit_rcp() as well. The neg/abs/sat changes are three separate changes.
static uint32_t vkd3d_dxbc_compiler_get_constant_float_vector(struct vkd3d_dxbc_compiler *compiler, - float value, unsigned int component_count) + float value, unsigned int component_count, enum vkd3d_data_type data_type) { - const float values[] = {value, value, value, value}; - return vkd3d_dxbc_compiler_get_constant(compiler, VKD3D_SHADER_COMPONENT_FLOAT, - component_count, (const uint32_t *)values); + if (data_type == VKD3D_DATA_DOUBLE) + { + const double values[] = {value, value}; + return vkd3d_dxbc_compiler_get_constant(compiler, VKD3D_SHADER_COMPONENT_DOUBLE, + component_count, (const uint32_t *)values); + } + else + { + const float values[] = {value, value, value, value}; + return vkd3d_dxbc_compiler_get_constant(compiler, VKD3D_SHADER_COMPONENT_FLOAT, + component_count, (const uint32_t *)values); + } }
I think it would be preferable to just introduce vkd3d_dxbc_compiler_get_constant_double_vector(), instead of hacking double support into vkd3d_dxbc_compiler_get_constant_float_vector().