mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Make HLSL_TYPE_VOID into a separate class.
This commit is contained in:
parent
e17e481130
commit
cdcf2da2eb
Notes:
Alexandre Julliard
2024-04-19 22:26:17 +02:00
Approved-by: Giovanni Mascellani (@giomasce) Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/781
@ -1514,10 +1514,11 @@ D3DXPARAMETER_CLASS hlsl_sm1_class(const struct hlsl_type *type)
|
||||
return D3DXPC_STRUCT;
|
||||
case HLSL_CLASS_VECTOR:
|
||||
return D3DXPC_VECTOR;
|
||||
default:
|
||||
ERR("Invalid class %#x.\n", type->class);
|
||||
vkd3d_unreachable();
|
||||
case HLSL_CLASS_VOID:
|
||||
break;
|
||||
}
|
||||
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
|
||||
D3DXPARAMETER_TYPE hlsl_sm1_base_type(const struct hlsl_type *type)
|
||||
@ -1595,8 +1596,6 @@ D3DXPARAMETER_TYPE hlsl_sm1_base_type(const struct hlsl_type *type)
|
||||
break;
|
||||
case HLSL_TYPE_VERTEXSHADER:
|
||||
return D3DXPT_VERTEXSHADER;
|
||||
case HLSL_TYPE_VOID:
|
||||
return D3DXPT_VOID;
|
||||
default:
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
@ -1607,6 +1606,9 @@ D3DXPARAMETER_TYPE hlsl_sm1_base_type(const struct hlsl_type *type)
|
||||
|
||||
case HLSL_CLASS_STRUCT:
|
||||
return D3DXPT_VOID;
|
||||
|
||||
case HLSL_CLASS_VOID:
|
||||
break;
|
||||
}
|
||||
|
||||
vkd3d_unreachable();
|
||||
|
@ -436,6 +436,11 @@ static uint32_t write_fx_4_type(const struct hlsl_type *type, struct fx_write_co
|
||||
|
||||
case HLSL_CLASS_ARRAY:
|
||||
vkd3d_unreachable();
|
||||
|
||||
case HLSL_CLASS_VOID:
|
||||
FIXME("Writing type class %u is not implemented.\n", type->class);
|
||||
set_status(fx, VKD3D_ERROR_NOT_IMPLEMENTED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
size = stride = type->reg_size[HLSL_REGSET_NUMERIC] * sizeof(float);
|
||||
@ -814,6 +819,9 @@ static bool is_type_supported_fx_2(struct hlsl_ctx *ctx, const struct hlsl_type
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
||||
case HLSL_CLASS_VOID:
|
||||
return false;
|
||||
}
|
||||
|
||||
vkd3d_unreachable();
|
||||
|
@ -365,6 +365,9 @@ static void hlsl_type_calculate_reg_size(struct hlsl_ctx *ctx, struct hlsl_type
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case HLSL_CLASS_VOID:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -377,6 +380,25 @@ unsigned int hlsl_type_get_array_element_reg_size(const struct hlsl_type *type,
|
||||
return type->reg_size[regset];
|
||||
}
|
||||
|
||||
static struct hlsl_type *hlsl_new_simple_type(struct hlsl_ctx *ctx, const char *name, enum hlsl_type_class class)
|
||||
{
|
||||
struct hlsl_type *type;
|
||||
|
||||
if (!(type = hlsl_alloc(ctx, sizeof(*type))))
|
||||
return NULL;
|
||||
if (!(type->name = hlsl_strdup(ctx, name)))
|
||||
{
|
||||
vkd3d_free(type);
|
||||
return NULL;
|
||||
}
|
||||
type->class = class;
|
||||
hlsl_type_calculate_reg_size(ctx, type);
|
||||
|
||||
list_add_tail(&ctx->types, &type->entry);
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
static struct hlsl_type *hlsl_new_type(struct hlsl_ctx *ctx, const char *name, enum hlsl_type_class type_class,
|
||||
enum hlsl_base_type base_type, unsigned dimx, unsigned dimy)
|
||||
{
|
||||
@ -402,7 +424,22 @@ static struct hlsl_type *hlsl_new_type(struct hlsl_ctx *ctx, const char *name, e
|
||||
|
||||
static bool type_is_single_component(const struct hlsl_type *type)
|
||||
{
|
||||
return type->class == HLSL_CLASS_SCALAR || type->class == HLSL_CLASS_OBJECT;
|
||||
switch (type->class)
|
||||
{
|
||||
case HLSL_CLASS_SCALAR:
|
||||
case HLSL_CLASS_OBJECT:
|
||||
return true;
|
||||
|
||||
case HLSL_CLASS_VECTOR:
|
||||
case HLSL_CLASS_MATRIX:
|
||||
case HLSL_CLASS_STRUCT:
|
||||
case HLSL_CLASS_ARRAY:
|
||||
return false;
|
||||
|
||||
case HLSL_CLASS_VOID:
|
||||
break;
|
||||
}
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
|
||||
/* Given a type and a component index, this function moves one step through the path required to
|
||||
@ -525,7 +562,7 @@ unsigned int hlsl_type_get_component_offset(struct hlsl_ctx *ctx, struct hlsl_ty
|
||||
assert(idx == 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
case HLSL_CLASS_VOID:
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
type = next_type;
|
||||
@ -752,7 +789,6 @@ struct hlsl_type *hlsl_new_struct_type(struct hlsl_ctx *ctx, const char *name,
|
||||
if (!(type = hlsl_alloc(ctx, sizeof(*type))))
|
||||
return NULL;
|
||||
type->class = HLSL_CLASS_STRUCT;
|
||||
type->base_type = HLSL_TYPE_VOID;
|
||||
type->name = name;
|
||||
type->dimy = 1;
|
||||
type->e.record.fields = fields;
|
||||
@ -896,9 +932,11 @@ unsigned int hlsl_type_component_count(const struct hlsl_type *type)
|
||||
case HLSL_CLASS_OBJECT:
|
||||
return 1;
|
||||
|
||||
default:
|
||||
vkd3d_unreachable();
|
||||
case HLSL_CLASS_VOID:
|
||||
break;
|
||||
}
|
||||
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
|
||||
bool hlsl_types_are_equal(const struct hlsl_type *t1, const struct hlsl_type *t2)
|
||||
@ -2313,16 +2351,17 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const stru
|
||||
return string;
|
||||
|
||||
default:
|
||||
vkd3d_string_buffer_printf(string, "<unexpected type>");
|
||||
return string;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
default:
|
||||
case HLSL_CLASS_VOID:
|
||||
break;
|
||||
}
|
||||
|
||||
vkd3d_string_buffer_printf(string, "<unexpected type>");
|
||||
return string;
|
||||
}
|
||||
}
|
||||
|
||||
struct vkd3d_string_buffer *hlsl_component_to_string(struct hlsl_ctx *ctx, const struct hlsl_ir_var *var,
|
||||
unsigned int index)
|
||||
@ -3609,7 +3648,7 @@ static void declare_predefined_types(struct hlsl_ctx *ctx)
|
||||
ctx->builtin_types.sampler[bt] = type;
|
||||
}
|
||||
|
||||
ctx->builtin_types.Void = hlsl_new_type(ctx, "void", HLSL_CLASS_OBJECT, HLSL_TYPE_VOID, 1, 1);
|
||||
ctx->builtin_types.Void = hlsl_new_simple_type(ctx, "void", HLSL_CLASS_VOID);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(effect_types); ++i)
|
||||
{
|
||||
|
@ -79,6 +79,7 @@ enum hlsl_type_class
|
||||
HLSL_CLASS_STRUCT,
|
||||
HLSL_CLASS_ARRAY,
|
||||
HLSL_CLASS_OBJECT,
|
||||
HLSL_CLASS_VOID,
|
||||
};
|
||||
|
||||
enum hlsl_base_type
|
||||
@ -101,7 +102,6 @@ enum hlsl_base_type
|
||||
HLSL_TYPE_TECHNIQUE,
|
||||
HLSL_TYPE_EFFECT_GROUP,
|
||||
HLSL_TYPE_STRING,
|
||||
HLSL_TYPE_VOID,
|
||||
};
|
||||
|
||||
enum hlsl_sampler_dim
|
||||
@ -175,7 +175,7 @@ struct hlsl_type
|
||||
* If base_type is HLSL_TYPE_SAMPLER, then both dimx = 1 and dimy = 1.
|
||||
* If base_type is HLSL_TYPE_TEXTURE, then dimx = 4 and dimy = 1.
|
||||
* If base_type is HLSL_TYPE_UAV, then dimx is the dimx of e.resource_format, and dimy = 1.
|
||||
* Otherwise both dimx = 1 and dimy = 1. */
|
||||
*/
|
||||
unsigned int dimx;
|
||||
unsigned int dimy;
|
||||
/* Sample count for HLSL_SAMPLER_DIM_2DMS or HLSL_SAMPLER_DIM_2DMSARRAY. */
|
||||
|
@ -1634,6 +1634,9 @@ static bool copy_propagation_transform_load(struct hlsl_ctx *ctx,
|
||||
/* FIXME: Actually we shouldn't even get here, but we don't split
|
||||
* matrices yet. */
|
||||
return false;
|
||||
|
||||
case HLSL_CLASS_VOID:
|
||||
vkd3d_unreachable();
|
||||
}
|
||||
|
||||
if (copy_propagation_replace_with_constant_vector(ctx, state, load, HLSL_SWIZZLE(X, Y, Z, W), &load->node))
|
||||
|
@ -3008,6 +3008,7 @@ static D3D_SHADER_VARIABLE_CLASS sm4_class(const struct hlsl_type *type)
|
||||
case HLSL_CLASS_ARRAY:
|
||||
case HLSL_CLASS_STRUCT:
|
||||
case HLSL_CLASS_OBJECT:
|
||||
case HLSL_CLASS_VOID:
|
||||
break;
|
||||
}
|
||||
vkd3d_unreachable();
|
||||
|
Loading…
Reference in New Issue
Block a user