vkd3d-shader: Get rid of hlsl_base_type_to_string().

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Matteo Bruni <mbruni@codeweavers.com>
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2021-02-16 23:52:05 -06:00 committed by Alexandre Julliard
parent 60f7735b20
commit 124069907d
3 changed files with 16 additions and 35 deletions

View File

@ -639,55 +639,37 @@ static int compare_function_decl_rb(const void *key, const struct rb_entry *entr
return 0; return 0;
} }
const char *hlsl_base_type_to_string(const struct hlsl_type *type)
{
const char *name = "(unknown)";
switch (type->base_type)
{
case HLSL_TYPE_FLOAT: name = "float"; break;
case HLSL_TYPE_HALF: name = "half"; break;
case HLSL_TYPE_DOUBLE: name = "double"; break;
case HLSL_TYPE_INT: name = "int"; break;
case HLSL_TYPE_UINT: name = "uint"; break;
case HLSL_TYPE_BOOL: name = "bool"; break;
case HLSL_TYPE_SAMPLER:
switch (type->sampler_dim)
{
case HLSL_SAMPLER_DIM_GENERIC: name = "sampler"; break;
case HLSL_SAMPLER_DIM_1D: name = "sampler1D"; break;
case HLSL_SAMPLER_DIM_2D: name = "sampler2D"; break;
case HLSL_SAMPLER_DIM_3D: name = "sampler3D"; break;
case HLSL_SAMPLER_DIM_CUBE: name = "samplerCUBE"; break;
}
break;
default:
FIXME("Unhandled case %u.\n", type->base_type);
}
return name;
}
char *hlsl_type_to_string(const struct hlsl_type *type) char *hlsl_type_to_string(const struct hlsl_type *type)
{ {
const char *name; const char *name;
char *string; char *string;
static const char base_types[HLSL_TYPE_LAST_SCALAR + 1][7] =
{
"float",
"half",
"double",
"int",
"uint",
"bool",
};
if (type->name) if (type->name)
return vkd3d_strdup(type->name); return vkd3d_strdup(type->name);
switch (type->type) switch (type->type)
{ {
case HLSL_CLASS_SCALAR: case HLSL_CLASS_SCALAR:
return vkd3d_strdup(hlsl_base_type_to_string(type)); return vkd3d_strdup(base_types[type->base_type]);
case HLSL_CLASS_VECTOR: case HLSL_CLASS_VECTOR:
name = hlsl_base_type_to_string(type); name = base_types[type->base_type];
if ((string = malloc(strlen(name) + 2))) if ((string = malloc(strlen(name) + 2)))
sprintf(string, "%s%u", name, type->dimx); sprintf(string, "%s%u", name, type->dimx);
return string; return string;
case HLSL_CLASS_MATRIX: case HLSL_CLASS_MATRIX:
name = hlsl_base_type_to_string(type); name = base_types[type->base_type];
if ((string = malloc(strlen(name) + 4))) if ((string = malloc(strlen(name) + 4)))
sprintf(string, "%s%ux%u", name, type->dimx, type->dimy); sprintf(string, "%s%ux%u", name, type->dimx, type->dimy);
return string; return string;
@ -907,8 +889,7 @@ static void dump_ir_constant(struct vkd3d_string_buffer *buffer, const struct hl
break; break;
default: default:
vkd3d_string_buffer_printf(buffer, "Constants of type %s not supported\n", assert(0);
hlsl_base_type_to_string(type));
} }
} }
if (type->dimx != 1) if (type->dimx != 1)

View File

@ -496,7 +496,6 @@ static inline void hlsl_src_remove(struct hlsl_src *src)
const char *debug_hlsl_type(const struct hlsl_type *type) DECLSPEC_HIDDEN; const char *debug_hlsl_type(const struct hlsl_type *type) DECLSPEC_HIDDEN;
const char *hlsl_base_type_to_string(const struct hlsl_type *type) DECLSPEC_HIDDEN;
char *hlsl_type_to_string(const struct hlsl_type *type) DECLSPEC_HIDDEN; char *hlsl_type_to_string(const struct hlsl_type *type) DECLSPEC_HIDDEN;
char *hlsl_modifiers_to_string(unsigned int modifiers) DECLSPEC_HIDDEN; char *hlsl_modifiers_to_string(unsigned int modifiers) DECLSPEC_HIDDEN;
const char *hlsl_node_type_to_string(enum hlsl_ir_node_type type) DECLSPEC_HIDDEN; const char *hlsl_node_type_to_string(enum hlsl_ir_node_type type) DECLSPEC_HIDDEN;

View File

@ -909,13 +909,14 @@ static unsigned int evaluate_array_dimension(struct hlsl_ir_node *node)
case HLSL_TYPE_INT: case HLSL_TYPE_INT:
return constant->value.i[0]; return constant->value.i[0];
case HLSL_TYPE_FLOAT: case HLSL_TYPE_FLOAT:
case HLSL_TYPE_HALF:
return constant->value.f[0]; return constant->value.f[0];
case HLSL_TYPE_DOUBLE: case HLSL_TYPE_DOUBLE:
return constant->value.d[0]; return constant->value.d[0];
case HLSL_TYPE_BOOL: case HLSL_TYPE_BOOL:
return constant->value.b[0]; return constant->value.b[0];
default: default:
WARN("Invalid type %s.\n", hlsl_base_type_to_string(constant->node.data_type)); assert(0);
return 0; return 0;
} }
} }