libs/vkd3d-shader: Pass buffer size to vkd3d_dxbc_compiler_get_register_name().

This commit is contained in:
Józef Kucia 2017-07-10 15:33:34 +02:00
parent 649a814b23
commit 2e6f80e24c

View File

@ -1156,26 +1156,27 @@ static uint32_t vkd3d_dxbc_compiler_get_constant_float(struct vkd3d_dxbc_compile
return vkd3d_dxbc_compiler_get_constant(compiler, VKD3D_TYPE_FLOAT, 1, (uint32_t *)&value); return vkd3d_dxbc_compiler_get_constant(compiler, VKD3D_TYPE_FLOAT, 1, (uint32_t *)&value);
} }
static bool vkd3d_dxbc_compiler_get_register_name(char *buffer,const struct vkd3d_shader_register *reg) static bool vkd3d_dxbc_compiler_get_register_name(char *buffer, unsigned int buffer_size,
const struct vkd3d_shader_register *reg)
{ {
switch (reg->type) switch (reg->type)
{ {
case VKD3DSPR_CONSTBUFFER: case VKD3DSPR_CONSTBUFFER:
sprintf(buffer, "cb%u_%u", reg->idx[0].offset, reg->idx[1].offset); snprintf(buffer, buffer_size, "cb%u_%u", reg->idx[0].offset, reg->idx[1].offset);
break; break;
case VKD3DSPR_INPUT: case VKD3DSPR_INPUT:
sprintf(buffer, "v%u", reg->idx[0].offset); snprintf(buffer, buffer_size, "v%u", reg->idx[0].offset);
break; break;
case VKD3DSPR_OUTPUT: case VKD3DSPR_OUTPUT:
case VKD3DSPR_COLOROUT: case VKD3DSPR_COLOROUT:
sprintf(buffer, "o%u", reg->idx[0].offset); snprintf(buffer, buffer_size, "o%u", reg->idx[0].offset);
break; break;
case VKD3DSPR_THREADID: case VKD3DSPR_THREADID:
sprintf(buffer, "vThreadID"); snprintf(buffer, buffer_size, "vThreadID");
break; break;
default: default:
FIXME("Unhandled register %#x.\n", reg->type); FIXME("Unhandled register %#x.\n", reg->type);
sprintf(buffer, "unrecognized_%#x", reg->type); snprintf(buffer, buffer_size, "unrecognized_%#x", reg->type);
return false; return false;
} }
@ -1186,7 +1187,7 @@ static void vkd3d_dxbc_compiler_emit_register_debug_name(struct vkd3d_spirv_buil
uint32_t id, const struct vkd3d_shader_register *reg) uint32_t id, const struct vkd3d_shader_register *reg)
{ {
char debug_name[256]; char debug_name[256];
if (vkd3d_dxbc_compiler_get_register_name(debug_name, reg)) if (vkd3d_dxbc_compiler_get_register_name(debug_name, ARRAY_SIZE(debug_name), reg))
vkd3d_spirv_build_op_name(builder, id, debug_name); vkd3d_spirv_build_op_name(builder, id, debug_name);
} }