Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- libs/vkd3d-shader/hlsl_sm4.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index fa845dc4..af5c777f 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1468,7 +1468,7 @@ static void write_sm4_cast(struct hlsl_ctx *ctx, break;
default: - break; + assert(0); } break;
@@ -1494,7 +1494,7 @@ static void write_sm4_cast(struct hlsl_ctx *ctx, break;
default: - break; + assert(0); } break;
@@ -1520,7 +1520,7 @@ static void write_sm4_cast(struct hlsl_ctx *ctx, break;
default: - break; + assert(0); } break;
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- libs/vkd3d-shader/hlsl.c | 8 ++++---- libs/vkd3d-shader/hlsl.h | 4 ++-- libs/vkd3d-shader/hlsl.y | 8 ++++---- libs/vkd3d-shader/hlsl_codegen.c | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index d88b0b6d..36cc3a91 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -564,25 +564,25 @@ struct hlsl_ir_store *hlsl_new_simple_store(struct hlsl_ctx *ctx, struct hlsl_ir }
struct hlsl_ir_constant *hlsl_new_int_constant(struct hlsl_ctx *ctx, int n, - const struct vkd3d_shader_location loc) + const struct vkd3d_shader_location *loc) { struct hlsl_ir_constant *c;
if (!(c = hlsl_alloc(ctx, sizeof(*c)))) return NULL; - init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_INT), loc); + init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_INT), *loc); c->value[0].i = n; return c; }
struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n, - const struct vkd3d_shader_location loc) + const struct vkd3d_shader_location *loc) { struct hlsl_ir_constant *c;
if (!(c = hlsl_alloc(ctx, sizeof(*c)))) return NULL; - init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_UINT), loc); + init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_UINT), *loc); c->value[0].u = n; return c; } diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 0543e144..c9abbd4a 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -738,7 +738,7 @@ struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx, struct hl struct list *parameters, const struct hlsl_semantic *semantic, struct vkd3d_shader_location loc); struct hlsl_ir_if *hlsl_new_if(struct hlsl_ctx *ctx, struct hlsl_ir_node *condition, struct vkd3d_shader_location loc); struct hlsl_ir_constant *hlsl_new_int_constant(struct hlsl_ctx *ctx, int n, - const struct vkd3d_shader_location loc); + const struct vkd3d_shader_location *loc); struct hlsl_ir_jump *hlsl_new_jump(struct hlsl_ctx *ctx, enum hlsl_ir_jump_type type, struct vkd3d_shader_location loc); struct hlsl_ir_load *hlsl_new_load(struct hlsl_ctx *ctx, struct hlsl_ir_var *var, struct hlsl_ir_node *offset, struct hlsl_type *type, struct vkd3d_shader_location loc); @@ -757,7 +757,7 @@ struct hlsl_ir_var *hlsl_new_synthetic_var(struct hlsl_ctx *ctx, const char *nam const struct vkd3d_shader_location loc); struct hlsl_type *hlsl_new_texture_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim, struct hlsl_type *format); struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n, - const struct vkd3d_shader_location loc); + const struct vkd3d_shader_location *loc); struct hlsl_ir_node *hlsl_new_unary_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg, struct vkd3d_shader_location loc); struct hlsl_ir_var *hlsl_new_var(struct hlsl_ctx *ctx, const char *name, struct hlsl_type *type, diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 1ab56fba..41fa7df4 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -573,7 +573,7 @@ static struct hlsl_ir_load *add_record_load(struct hlsl_ctx *ctx, struct list *i { struct hlsl_ir_constant *c;
- if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset, loc))) + if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset, &loc))) return NULL; list_add_tail(instrs, &c->node.entry);
@@ -607,7 +607,7 @@ static struct hlsl_ir_load *add_array_load(struct hlsl_ctx *ctx, struct list *in return NULL; }
- if (!(c = hlsl_new_uint_constant(ctx, hlsl_type_get_array_element_reg_size(data_type), loc))) + if (!(c = hlsl_new_uint_constant(ctx, hlsl_type_get_array_element_reg_size(data_type), &loc))) return NULL; list_add_tail(instrs, &c->node.entry); if (!(mul = hlsl_new_binary_expr(ctx, HLSL_OP2_MUL, index, &c->node))) @@ -1399,7 +1399,7 @@ static bool add_increment(struct hlsl_ctx *ctx, struct list *instrs, bool decrem hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST, "Argument to %s%screment operator is const.", post ? "post" : "pre", decrement ? "de" : "in");
- if (!(one = hlsl_new_int_constant(ctx, 1, loc))) + if (!(one = hlsl_new_int_constant(ctx, 1, &loc))) return false; list_add_tail(instrs, &one->node.entry);
@@ -1452,7 +1452,7 @@ static void struct_var_initializer(struct hlsl_ctx *ctx, struct list *list, stru
if (hlsl_type_component_count(field->type) == hlsl_type_component_count(node->data_type)) { - if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset, node->loc))) + if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset, &node->loc))) break; list_add_tail(list, &c->node.entry);
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 98be3aeb..3d0f9e41 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -92,7 +92,7 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct list *instrs, struct return; list_add_head(instrs, &load->node.entry);
- if (!(offset = hlsl_new_uint_constant(ctx, field_offset, var->loc))) + if (!(offset = hlsl_new_uint_constant(ctx, field_offset, &var->loc))) return; list_add_after(&load->node.entry, &offset->node.entry);
@@ -159,7 +159,7 @@ static void append_output_copy(struct hlsl_ctx *ctx, struct list *instrs, struct list_add_before(&var->scope_entry, &output->scope_entry); list_add_tail(&ctx->extern_vars, &output->extern_entry);
- if (!(offset = hlsl_new_uint_constant(ctx, field_offset, var->loc))) + if (!(offset = hlsl_new_uint_constant(ctx, field_offset, &var->loc))) return; list_add_tail(instrs, &offset->node.entry);
@@ -572,7 +572,7 @@ static bool split_copy(struct hlsl_ctx *ctx, struct hlsl_ir_store *store, struct hlsl_ir_load *split_load; struct hlsl_ir_constant *c;
- if (!(c = hlsl_new_uint_constant(ctx, offset, store->node.loc))) + if (!(c = hlsl_new_uint_constant(ctx, offset, &store->node.loc))) return false; list_add_before(&store->node.entry, &c->node.entry);
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
Signed-off-by: Francisco Casas fcasas@codeweavers.com
March 23, 2022 11:28 AM, "Giovanni Mascellani" gmascellani@codeweavers.com wrote:
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
libs/vkd3d-shader/hlsl.c | 8 ++++---- libs/vkd3d-shader/hlsl.h | 4 ++-- libs/vkd3d-shader/hlsl.y | 8 ++++---- libs/vkd3d-shader/hlsl_codegen.c | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index d88b0b6d..36cc3a91 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -564,25 +564,25 @@ struct hlsl_ir_store *hlsl_new_simple_store(struct hlsl_ctx *ctx, struct hlsl_ir }
struct hlsl_ir_constant *hlsl_new_int_constant(struct hlsl_ctx *ctx, int n,
- const struct vkd3d_shader_location loc)
- const struct vkd3d_shader_location *loc)
{ struct hlsl_ir_constant *c;
if (!(c = hlsl_alloc(ctx, sizeof(*c)))) return NULL;
- init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_INT), loc);
- init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_INT), *loc);
c->value[0].i = n; return c; }
struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n,
- const struct vkd3d_shader_location loc)
- const struct vkd3d_shader_location *loc)
{ struct hlsl_ir_constant *c;
if (!(c = hlsl_alloc(ctx, sizeof(*c)))) return NULL;
- init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_UINT), loc);
- init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_UINT), *loc);
c->value[0].u = n; return c; } diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 0543e144..c9abbd4a 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -738,7 +738,7 @@ struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx, struct hl struct list *parameters, const struct hlsl_semantic *semantic, struct vkd3d_shader_location loc); struct hlsl_ir_if *hlsl_new_if(struct hlsl_ctx *ctx, struct hlsl_ir_node *condition, struct vkd3d_shader_location loc); struct hlsl_ir_constant *hlsl_new_int_constant(struct hlsl_ctx *ctx, int n,
- const struct vkd3d_shader_location loc);
- const struct vkd3d_shader_location *loc);
struct hlsl_ir_jump *hlsl_new_jump(struct hlsl_ctx *ctx, enum hlsl_ir_jump_type type, struct vkd3d_shader_location loc); struct hlsl_ir_load *hlsl_new_load(struct hlsl_ctx *ctx, struct hlsl_ir_var *var, struct hlsl_ir_node *offset, struct hlsl_type *type, struct vkd3d_shader_location loc); @@ -757,7 +757,7 @@ struct hlsl_ir_var *hlsl_new_synthetic_var(struct hlsl_ctx *ctx, const char *nam const struct vkd3d_shader_location loc); struct hlsl_type *hlsl_new_texture_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim, struct hlsl_type *format); struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n,
- const struct vkd3d_shader_location loc);
- const struct vkd3d_shader_location *loc);
struct hlsl_ir_node *hlsl_new_unary_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg, struct vkd3d_shader_location loc); struct hlsl_ir_var *hlsl_new_var(struct hlsl_ctx *ctx, const char *name, struct hlsl_type *type, diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 1ab56fba..41fa7df4 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -573,7 +573,7 @@ static struct hlsl_ir_load *add_record_load(struct hlsl_ctx *ctx, struct list *i { struct hlsl_ir_constant *c;
- if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset, loc)))
- if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset, &loc)))
return NULL; list_add_tail(instrs, &c->node.entry);
@@ -607,7 +607,7 @@ static struct hlsl_ir_load *add_array_load(struct hlsl_ctx *ctx, struct list *in return NULL; }
- if (!(c = hlsl_new_uint_constant(ctx, hlsl_type_get_array_element_reg_size(data_type), loc)))
- if (!(c = hlsl_new_uint_constant(ctx, hlsl_type_get_array_element_reg_size(data_type), &loc)))
return NULL; list_add_tail(instrs, &c->node.entry); if (!(mul = hlsl_new_binary_expr(ctx, HLSL_OP2_MUL, index, &c->node))) @@ -1399,7 +1399,7 @@ static bool add_increment(struct hlsl_ctx *ctx, struct list *instrs, bool decrem hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST, "Argument to %s%screment operator is const.", post ? "post" : "pre", decrement ? "de" : "in");
- if (!(one = hlsl_new_int_constant(ctx, 1, loc)))
- if (!(one = hlsl_new_int_constant(ctx, 1, &loc)))
return false; list_add_tail(instrs, &one->node.entry);
@@ -1452,7 +1452,7 @@ static void struct_var_initializer(struct hlsl_ctx *ctx, struct list *list, stru
if (hlsl_type_component_count(field->type) == hlsl_type_component_count(node->data_type)) {
- if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset, node->loc)))
- if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset, &node->loc)))
break; list_add_tail(list, &c->node.entry);
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 98be3aeb..3d0f9e41 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -92,7 +92,7 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct list *instrs, struct return; list_add_head(instrs, &load->node.entry);
- if (!(offset = hlsl_new_uint_constant(ctx, field_offset, var->loc)))
- if (!(offset = hlsl_new_uint_constant(ctx, field_offset, &var->loc)))
return; list_add_after(&load->node.entry, &offset->node.entry);
@@ -159,7 +159,7 @@ static void append_output_copy(struct hlsl_ctx *ctx, struct list *instrs, struct list_add_before(&var->scope_entry, &output->scope_entry); list_add_tail(&ctx->extern_vars, &output->extern_entry);
- if (!(offset = hlsl_new_uint_constant(ctx, field_offset, var->loc)))
- if (!(offset = hlsl_new_uint_constant(ctx, field_offset, &var->loc)))
return; list_add_tail(instrs, &offset->node.entry);
@@ -572,7 +572,7 @@ static bool split_copy(struct hlsl_ctx *ctx, struct hlsl_ir_store *store, struct hlsl_ir_load *split_load; struct hlsl_ir_constant *c;
- if (!(c = hlsl_new_uint_constant(ctx, offset, store->node.loc)))
- if (!(c = hlsl_new_uint_constant(ctx, offset, &store->node.loc)))
return false; list_add_before(&store->node.entry, &c->node.entry);
-- 2.35.1
Signed-off-by: Francisco Casas fcasas@codeweavers.com --- It may be good to assert that type->type is HLSL_IR_SCALAR or HLSL_IR_VECTOR.
March 23, 2022 11:28 AM, "Giovanni Mascellani" gmascellani@codeweavers.com wrote:
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
libs/vkd3d-shader/hlsl.c | 8 ++++---- libs/vkd3d-shader/hlsl.h | 4 ++-- libs/vkd3d-shader/hlsl.y | 8 ++++---- libs/vkd3d-shader/hlsl_codegen.c | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index d88b0b6d..36cc3a91 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -564,25 +564,25 @@ struct hlsl_ir_store *hlsl_new_simple_store(struct hlsl_ctx *ctx, struct hlsl_ir }
struct hlsl_ir_constant *hlsl_new_int_constant(struct hlsl_ctx *ctx, int n,
- const struct vkd3d_shader_location loc)
- const struct vkd3d_shader_location *loc)
{ struct hlsl_ir_constant *c;
if (!(c = hlsl_alloc(ctx, sizeof(*c)))) return NULL;
- init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_INT), loc);
- init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_INT), *loc);
c->value[0].i = n; return c; }
struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n,
- const struct vkd3d_shader_location loc)
- const struct vkd3d_shader_location *loc)
{ struct hlsl_ir_constant *c;
if (!(c = hlsl_alloc(ctx, sizeof(*c)))) return NULL;
- init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_UINT), loc);
- init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_UINT), *loc);
c->value[0].u = n; return c; } diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 0543e144..c9abbd4a 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -738,7 +738,7 @@ struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx, struct hl struct list *parameters, const struct hlsl_semantic *semantic, struct vkd3d_shader_location loc); struct hlsl_ir_if *hlsl_new_if(struct hlsl_ctx *ctx, struct hlsl_ir_node *condition, struct vkd3d_shader_location loc); struct hlsl_ir_constant *hlsl_new_int_constant(struct hlsl_ctx *ctx, int n,
- const struct vkd3d_shader_location loc);
- const struct vkd3d_shader_location *loc);
struct hlsl_ir_jump *hlsl_new_jump(struct hlsl_ctx *ctx, enum hlsl_ir_jump_type type, struct vkd3d_shader_location loc); struct hlsl_ir_load *hlsl_new_load(struct hlsl_ctx *ctx, struct hlsl_ir_var *var, struct hlsl_ir_node *offset, struct hlsl_type *type, struct vkd3d_shader_location loc); @@ -757,7 +757,7 @@ struct hlsl_ir_var *hlsl_new_synthetic_var(struct hlsl_ctx *ctx, const char *nam const struct vkd3d_shader_location loc); struct hlsl_type *hlsl_new_texture_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim, struct hlsl_type *format); struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n,
- const struct vkd3d_shader_location loc);
- const struct vkd3d_shader_location *loc);
struct hlsl_ir_node *hlsl_new_unary_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg, struct vkd3d_shader_location loc); struct hlsl_ir_var *hlsl_new_var(struct hlsl_ctx *ctx, const char *name, struct hlsl_type *type, diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 1ab56fba..41fa7df4 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -573,7 +573,7 @@ static struct hlsl_ir_load *add_record_load(struct hlsl_ctx *ctx, struct list *i { struct hlsl_ir_constant *c;
- if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset, loc)))
- if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset, &loc)))
return NULL; list_add_tail(instrs, &c->node.entry);
@@ -607,7 +607,7 @@ static struct hlsl_ir_load *add_array_load(struct hlsl_ctx *ctx, struct list *in return NULL; }
- if (!(c = hlsl_new_uint_constant(ctx, hlsl_type_get_array_element_reg_size(data_type), loc)))
- if (!(c = hlsl_new_uint_constant(ctx, hlsl_type_get_array_element_reg_size(data_type), &loc)))
return NULL; list_add_tail(instrs, &c->node.entry); if (!(mul = hlsl_new_binary_expr(ctx, HLSL_OP2_MUL, index, &c->node))) @@ -1399,7 +1399,7 @@ static bool add_increment(struct hlsl_ctx *ctx, struct list *instrs, bool decrem hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST, "Argument to %s%screment operator is const.", post ? "post" : "pre", decrement ? "de" : "in");
- if (!(one = hlsl_new_int_constant(ctx, 1, loc)))
- if (!(one = hlsl_new_int_constant(ctx, 1, &loc)))
return false; list_add_tail(instrs, &one->node.entry);
@@ -1452,7 +1452,7 @@ static void struct_var_initializer(struct hlsl_ctx *ctx, struct list *list, stru
if (hlsl_type_component_count(field->type) == hlsl_type_component_count(node->data_type)) {
- if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset, node->loc)))
- if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset, &node->loc)))
break; list_add_tail(list, &c->node.entry);
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 98be3aeb..3d0f9e41 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -92,7 +92,7 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct list *instrs, struct return; list_add_head(instrs, &load->node.entry);
- if (!(offset = hlsl_new_uint_constant(ctx, field_offset, var->loc)))
- if (!(offset = hlsl_new_uint_constant(ctx, field_offset, &var->loc)))
return; list_add_after(&load->node.entry, &offset->node.entry);
@@ -159,7 +159,7 @@ static void append_output_copy(struct hlsl_ctx *ctx, struct list *instrs, struct list_add_before(&var->scope_entry, &output->scope_entry); list_add_tail(&ctx->extern_vars, &output->extern_entry);
- if (!(offset = hlsl_new_uint_constant(ctx, field_offset, var->loc)))
- if (!(offset = hlsl_new_uint_constant(ctx, field_offset, &var->loc)))
return; list_add_tail(instrs, &offset->node.entry);
@@ -572,7 +572,7 @@ static bool split_copy(struct hlsl_ctx *ctx, struct hlsl_ir_store *store, struct hlsl_ir_load *split_load; struct hlsl_ir_constant *c;
- if (!(c = hlsl_new_uint_constant(ctx, offset, store->node.loc)))
- if (!(c = hlsl_new_uint_constant(ctx, offset, &store->node.loc)))
return false; list_add_before(&store->node.entry, &c->node.entry);
-- 2.35.1
Sorry, this reply was intended for the next patch in the series (3/6).
March 24, 2022 4:02 PM, "Francisco Casas" fcasas@codeweavers.com wrote:
Signed-off-by: Francisco Casas fcasas@codeweavers.com
It may be good to assert that type->type is HLSL_IR_SCALAR or HLSL_IR_VECTOR.
March 23, 2022 11:28 AM, "Giovanni Mascellani" gmascellani@codeweavers.com wrote:
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
libs/vkd3d-shader/hlsl.c | 8 ++++---- libs/vkd3d-shader/hlsl.h | 4 ++-- libs/vkd3d-shader/hlsl.y | 8 ++++---- libs/vkd3d-shader/hlsl_codegen.c | 6 +++--- 4 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index d88b0b6d..36cc3a91 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -564,25 +564,25 @@ struct hlsl_ir_store *hlsl_new_simple_store(struct hlsl_ctx *ctx, struct hlsl_ir }
struct hlsl_ir_constant *hlsl_new_int_constant(struct hlsl_ctx *ctx, int n,
- const struct vkd3d_shader_location loc)
- const struct vkd3d_shader_location *loc)
{ struct hlsl_ir_constant *c;
if (!(c = hlsl_alloc(ctx, sizeof(*c)))) return NULL;
- init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_INT), loc);
- init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_INT), *loc);
c->value[0].i = n; return c; }
struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n,
- const struct vkd3d_shader_location loc)
- const struct vkd3d_shader_location *loc)
{ struct hlsl_ir_constant *c;
if (!(c = hlsl_alloc(ctx, sizeof(*c)))) return NULL;
- init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_UINT), loc);
- init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_UINT), *loc);
c->value[0].u = n; return c; } diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index 0543e144..c9abbd4a 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -738,7 +738,7 @@ struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx, struct hl struct list *parameters, const struct hlsl_semantic *semantic, struct vkd3d_shader_location loc); struct hlsl_ir_if *hlsl_new_if(struct hlsl_ctx *ctx, struct hlsl_ir_node *condition, struct vkd3d_shader_location loc); struct hlsl_ir_constant *hlsl_new_int_constant(struct hlsl_ctx *ctx, int n,
- const struct vkd3d_shader_location loc);
- const struct vkd3d_shader_location *loc);
struct hlsl_ir_jump *hlsl_new_jump(struct hlsl_ctx *ctx, enum hlsl_ir_jump_type type, struct vkd3d_shader_location loc); struct hlsl_ir_load *hlsl_new_load(struct hlsl_ctx *ctx, struct hlsl_ir_var *var, struct hlsl_ir_node *offset, struct hlsl_type *type, struct vkd3d_shader_location loc); @@ -757,7 +757,7 @@ struct hlsl_ir_var *hlsl_new_synthetic_var(struct hlsl_ctx *ctx, const char *nam const struct vkd3d_shader_location loc); struct hlsl_type *hlsl_new_texture_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim dim, struct hlsl_type *format); struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n,
- const struct vkd3d_shader_location loc);
- const struct vkd3d_shader_location *loc);
struct hlsl_ir_node *hlsl_new_unary_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg, struct vkd3d_shader_location loc); struct hlsl_ir_var *hlsl_new_var(struct hlsl_ctx *ctx, const char *name, struct hlsl_type *type, diff --git a/libs/vkd3d-shader/hlsl.y b/libs/vkd3d-shader/hlsl.y index 1ab56fba..41fa7df4 100644 --- a/libs/vkd3d-shader/hlsl.y +++ b/libs/vkd3d-shader/hlsl.y @@ -573,7 +573,7 @@ static struct hlsl_ir_load *add_record_load(struct hlsl_ctx *ctx, struct list *i { struct hlsl_ir_constant *c;
- if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset, loc)))
- if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset, &loc)))
return NULL; list_add_tail(instrs, &c->node.entry);
@@ -607,7 +607,7 @@ static struct hlsl_ir_load *add_array_load(struct hlsl_ctx *ctx, struct list *in return NULL; }
- if (!(c = hlsl_new_uint_constant(ctx, hlsl_type_get_array_element_reg_size(data_type), loc)))
- if (!(c = hlsl_new_uint_constant(ctx, hlsl_type_get_array_element_reg_size(data_type), &loc)))
return NULL; list_add_tail(instrs, &c->node.entry); if (!(mul = hlsl_new_binary_expr(ctx, HLSL_OP2_MUL, index, &c->node))) @@ -1399,7 +1399,7 @@ static bool add_increment(struct hlsl_ctx *ctx, struct list *instrs, bool decrem hlsl_error(ctx, &loc, VKD3D_SHADER_ERROR_HLSL_MODIFIES_CONST, "Argument to %s%screment operator is const.", post ? "post" : "pre", decrement ? "de" : "in");
- if (!(one = hlsl_new_int_constant(ctx, 1, loc)))
- if (!(one = hlsl_new_int_constant(ctx, 1, &loc)))
return false; list_add_tail(instrs, &one->node.entry);
@@ -1452,7 +1452,7 @@ static void struct_var_initializer(struct hlsl_ctx *ctx, struct list *list, stru
if (hlsl_type_component_count(field->type) == hlsl_type_component_count(node->data_type)) {
- if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset, node->loc)))
- if (!(c = hlsl_new_uint_constant(ctx, field->reg_offset, &node->loc)))
break; list_add_tail(list, &c->node.entry);
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 98be3aeb..3d0f9e41 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -92,7 +92,7 @@ static void prepend_input_copy(struct hlsl_ctx *ctx, struct list *instrs, struct return; list_add_head(instrs, &load->node.entry);
- if (!(offset = hlsl_new_uint_constant(ctx, field_offset, var->loc)))
- if (!(offset = hlsl_new_uint_constant(ctx, field_offset, &var->loc)))
return; list_add_after(&load->node.entry, &offset->node.entry);
@@ -159,7 +159,7 @@ static void append_output_copy(struct hlsl_ctx *ctx, struct list *instrs, struct list_add_before(&var->scope_entry, &output->scope_entry); list_add_tail(&ctx->extern_vars, &output->extern_entry);
- if (!(offset = hlsl_new_uint_constant(ctx, field_offset, var->loc)))
- if (!(offset = hlsl_new_uint_constant(ctx, field_offset, &var->loc)))
return; list_add_tail(instrs, &offset->node.entry);
@@ -572,7 +572,7 @@ static bool split_copy(struct hlsl_ctx *ctx, struct hlsl_ir_store *store, struct hlsl_ir_load *split_load; struct hlsl_ir_constant *c;
- if (!(c = hlsl_new_uint_constant(ctx, offset, store->node.loc)))
- if (!(c = hlsl_new_uint_constant(ctx, offset, &store->node.loc)))
return false; list_add_before(&store->node.entry, &c->node.entry);
-- 2.35.1
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- libs/vkd3d-shader/hlsl.c | 29 ++++++++++++++++++++++------- libs/vkd3d-shader/hlsl.h | 2 ++ 2 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 36cc3a91..a8bfa6b2 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -563,15 +563,29 @@ struct hlsl_ir_store *hlsl_new_simple_store(struct hlsl_ctx *ctx, struct hlsl_ir return hlsl_new_store(ctx, lhs, NULL, rhs, 0, rhs->loc); }
-struct hlsl_ir_constant *hlsl_new_int_constant(struct hlsl_ctx *ctx, int n, +struct hlsl_ir_constant *hlsl_new_constant(struct hlsl_ctx *ctx, struct hlsl_type *type, const struct vkd3d_shader_location *loc) { struct hlsl_ir_constant *c;
if (!(c = hlsl_alloc(ctx, sizeof(*c)))) return NULL; - init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_INT), *loc); - c->value[0].i = n; + + init_node(&c->node, HLSL_IR_CONSTANT, type, *loc); + + return c; +} + +struct hlsl_ir_constant *hlsl_new_int_constant(struct hlsl_ctx *ctx, int n, + const struct vkd3d_shader_location *loc) +{ + struct hlsl_ir_constant *c; + + c = hlsl_new_constant(ctx, hlsl_get_scalar_type(ctx, HLSL_TYPE_INT), loc); + + if (c) + c->value[0].i = n; + return c; }
@@ -580,10 +594,11 @@ struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned i { struct hlsl_ir_constant *c;
- if (!(c = hlsl_alloc(ctx, sizeof(*c)))) - return NULL; - init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_UINT), *loc); - c->value[0].u = n; + c = hlsl_new_constant(ctx, hlsl_get_scalar_type(ctx, HLSL_TYPE_UINT), loc); + + if (c) + c->value[0].u = n; + return c; }
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index c9abbd4a..e4db386f 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -733,6 +733,8 @@ struct hlsl_buffer *hlsl_new_buffer(struct hlsl_ctx *ctx, enum hlsl_buffer_type const struct hlsl_reg_reservation *reservation, struct vkd3d_shader_location loc); struct hlsl_ir_expr *hlsl_new_cast(struct hlsl_ctx *ctx, struct hlsl_ir_node *node, struct hlsl_type *type, const struct vkd3d_shader_location *loc); +struct hlsl_ir_constant *hlsl_new_constant(struct hlsl_ctx *ctx, struct hlsl_type *type, + const struct vkd3d_shader_location *loc); struct hlsl_ir_expr *hlsl_new_copy(struct hlsl_ctx *ctx, struct hlsl_ir_node *node); struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx, struct hlsl_type *return_type, struct list *parameters, const struct hlsl_semantic *semantic, struct vkd3d_shader_location loc);
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
Signed-off-by: Francisco Casas fcasas@codeweavers.com --- It may be good to assert that type->type is HLSL_IR_SCALAR or HLSL_IR_VECTOR.
March 23, 2022 11:28 AM, "Giovanni Mascellani" gmascellani@codeweavers.com wrote:
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
libs/vkd3d-shader/hlsl.c | 29 ++++++++++++++++++++++------- libs/vkd3d-shader/hlsl.h | 2 ++ 2 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl.c b/libs/vkd3d-shader/hlsl.c index 36cc3a91..a8bfa6b2 100644 --- a/libs/vkd3d-shader/hlsl.c +++ b/libs/vkd3d-shader/hlsl.c @@ -563,15 +563,29 @@ struct hlsl_ir_store *hlsl_new_simple_store(struct hlsl_ctx *ctx, struct hlsl_ir return hlsl_new_store(ctx, lhs, NULL, rhs, 0, rhs->loc); }
-struct hlsl_ir_constant *hlsl_new_int_constant(struct hlsl_ctx *ctx, int n, +struct hlsl_ir_constant *hlsl_new_constant(struct hlsl_ctx *ctx, struct hlsl_type *type, const struct vkd3d_shader_location *loc) { struct hlsl_ir_constant *c;
if (!(c = hlsl_alloc(ctx, sizeof(*c)))) return NULL;
- init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_INT), *loc);
- c->value[0].i = n;
- init_node(&c->node, HLSL_IR_CONSTANT, type, *loc);
- return c;
+}
+struct hlsl_ir_constant *hlsl_new_int_constant(struct hlsl_ctx *ctx, int n,
- const struct vkd3d_shader_location *loc)
+{
- struct hlsl_ir_constant *c;
- c = hlsl_new_constant(ctx, hlsl_get_scalar_type(ctx, HLSL_TYPE_INT), loc);
- if (c)
- c->value[0].i = n;
return c; }
@@ -580,10 +594,11 @@ struct hlsl_ir_constant *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned i { struct hlsl_ir_constant *c;
- if (!(c = hlsl_alloc(ctx, sizeof(*c))))
- return NULL;
- init_node(&c->node, HLSL_IR_CONSTANT, hlsl_get_scalar_type(ctx, HLSL_TYPE_UINT), *loc);
- c->value[0].u = n;
- c = hlsl_new_constant(ctx, hlsl_get_scalar_type(ctx, HLSL_TYPE_UINT), loc);
- if (c)
- c->value[0].u = n;
return c; }
diff --git a/libs/vkd3d-shader/hlsl.h b/libs/vkd3d-shader/hlsl.h index c9abbd4a..e4db386f 100644 --- a/libs/vkd3d-shader/hlsl.h +++ b/libs/vkd3d-shader/hlsl.h @@ -733,6 +733,8 @@ struct hlsl_buffer *hlsl_new_buffer(struct hlsl_ctx *ctx, enum hlsl_buffer_type const struct hlsl_reg_reservation *reservation, struct vkd3d_shader_location loc); struct hlsl_ir_expr *hlsl_new_cast(struct hlsl_ctx *ctx, struct hlsl_ir_node *node, struct hlsl_type *type, const struct vkd3d_shader_location *loc); +struct hlsl_ir_constant *hlsl_new_constant(struct hlsl_ctx *ctx, struct hlsl_type *type,
- const struct vkd3d_shader_location *loc);
struct hlsl_ir_expr *hlsl_new_copy(struct hlsl_ctx *ctx, struct hlsl_ir_node *node); struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx, struct hlsl_type *return_type, struct list *parameters, const struct hlsl_semantic *semantic, struct vkd3d_shader_location loc); -- 2.35.1
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- libs/vkd3d-shader/hlsl_constant_ops.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_constant_ops.c b/libs/vkd3d-shader/hlsl_constant_ops.c index 51cee179..6c852ba1 100644 --- a/libs/vkd3d-shader/hlsl_constant_ops.c +++ b/libs/vkd3d-shader/hlsl_constant_ops.c @@ -75,11 +75,11 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct break;
case HLSL_TYPE_BOOL: - u = src->value[k].b; - i = src->value[k].b; - f = src->value[k].b; - d = src->value[k].b; - b = src->value[k].b; + u = !!src->value[k].b; + i = !!src->value[k].b; + f = !!src->value[k].b; + d = !!src->value[k].b; + b = !!src->value[k].b; break;
default:
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
Signed-off-by: Francisco Casas fcasas@codeweavers.com ---
But, if I am not mistaken, bool expands to _Bool (because we are including <stdbool.h>). And I don't see any point in the program were we may be assigning .b a value that's not 0 or 1. Given that in C, when an scalar is converted to _Bool, it automatically becomes 0 or 1.
March 23, 2022 11:27 AM, "Giovanni Mascellani" gmascellani@codeweavers.com wrote:
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
libs/vkd3d-shader/hlsl_constant_ops.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_constant_ops.c b/libs/vkd3d-shader/hlsl_constant_ops.c index 51cee179..6c852ba1 100644 --- a/libs/vkd3d-shader/hlsl_constant_ops.c +++ b/libs/vkd3d-shader/hlsl_constant_ops.c @@ -75,11 +75,11 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct break;
case HLSL_TYPE_BOOL:
- u = src->value[k].b;
- i = src->value[k].b;
- f = src->value[k].b;
- d = src->value[k].b;
- b = src->value[k].b;
- u = !!src->value[k].b;
- i = !!src->value[k].b;
- f = !!src->value[k].b;
- d = !!src->value[k].b;
- b = !!src->value[k].b;
break;
default:
2.35.1
On 3/24/22 14:59, Francisco Casas wrote:
Signed-off-by: Francisco Casas fcasas@codeweavers.com
But, if I am not mistaken, bool expands to _Bool (because we are including <stdbool.h>). And I don't see any point in the program were we may be assigning .b a value that's not 0 or 1. Given that in C, when an scalar is converted to _Bool, it automatically becomes 0 or 1.
Indeed. This patch is superfluous, then...
Hi,
Il 24/03/22 20:59, Francisco Casas ha scritto:
But, if I am not mistaken, bool expands to _Bool (because we are including <stdbool.h>). And I don't see any point in the program were we may be assigning .b a value that's not 0 or 1. Given that in C, when an scalar is converted to _Bool, it automatically becomes 0 or 1.
Yeah, it's pretty obvious I got a bit confused about patches 4-6/6. Part of the reason is that in the development branch we've got a patch which gets rid of .b and uses .i instead. This makes sense to me, because it allows us to represent true with 0xffffffff without tripping on the fact that sizeof(bool) == 1. Quite evidently my effort to port my patches from that convention to the one currently in master failed spectacularly.
So I'd retract patches 4-6/6 and resubmit them on top of that change (getting rid of .b), which I assume we wanted upstreamed as well (if not, please let me know).
Actually, it seem more appropriate to use .u instead of .i: first, because I find it more straight forward to think a bool as unsigned rather than signed; second, because if makes true > false, which I think is aligned with HLSL.
Thanks for the feedback, Giovanni.
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- libs/vkd3d-shader/hlsl_constant_ops.c | 41 +++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_constant_ops.c b/libs/vkd3d-shader/hlsl_constant_ops.c index 6c852ba1..2f090863 100644 --- a/libs/vkd3d-shader/hlsl_constant_ops.c +++ b/libs/vkd3d-shader/hlsl_constant_ops.c @@ -224,6 +224,43 @@ static bool fold_mul(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, return true; }
+static bool fold_nequal(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, + struct hlsl_ir_constant *src1, struct hlsl_ir_constant *src2) +{ + enum hlsl_base_type type = dst->node.data_type->base_type; + + assert(type == HLSL_TYPE_BOOL); + assert(src1->node.data_type->base_type == src2->node.data_type->base_type); + + for (int k = 0; k < 4; ++k) + { + switch (src1->node.data_type->base_type) + { + case HLSL_TYPE_FLOAT: + case HLSL_TYPE_HALF: + dst->value[k].b = src1->value[k].f != src2->value[k].f; + break; + + case HLSL_TYPE_DOUBLE: + dst->value[k].b = src1->value[k].d != src2->value[k].d; + break; + + case HLSL_TYPE_INT: + case HLSL_TYPE_UINT: + case HLSL_TYPE_BOOL: + dst->value[k].b = src1->value[k].u != src2->value[k].u; + break; + + default: + FIXME("Fold not-equal for type %s.\n", debug_hlsl_type(ctx, dst->node.data_type)); + return false; + } + + dst->value[k].b *= ~0u; + } + return true; +} + bool hlsl_fold_constants(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) { struct hlsl_ir_constant *arg1, *arg2 = NULL, *res; @@ -266,6 +303,10 @@ bool hlsl_fold_constants(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void success = fold_mul(ctx, res, arg1, arg2); break;
+ case HLSL_OP2_NEQUAL: + success = fold_nequal(ctx, res, arg1, arg2); + break; + default: FIXME("Fold "%s" expression.\n", debug_hlsl_expr_op(expr->op)); success = false;
On 3/23/22 09:27, Giovanni Mascellani wrote:
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
libs/vkd3d-shader/hlsl_constant_ops.c | 41 +++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_constant_ops.c b/libs/vkd3d-shader/hlsl_constant_ops.c index 6c852ba1..2f090863 100644 --- a/libs/vkd3d-shader/hlsl_constant_ops.c +++ b/libs/vkd3d-shader/hlsl_constant_ops.c @@ -224,6 +224,43 @@ static bool fold_mul(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, return true; }
+static bool fold_nequal(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst,
struct hlsl_ir_constant *src1, struct hlsl_ir_constant *src2)
+{
- enum hlsl_base_type type = dst->node.data_type->base_type;
- assert(type == HLSL_TYPE_BOOL);
Nitpick, but there doesn't seem much point in putting this in a separate variable.
- assert(src1->node.data_type->base_type == src2->node.data_type->base_type);
- for (int k = 0; k < 4; ++k)
"unsigned int"
- {
switch (src1->node.data_type->base_type)
{
case HLSL_TYPE_FLOAT:
case HLSL_TYPE_HALF:
dst->value[k].b = src1->value[k].f != src2->value[k].f;
break;
case HLSL_TYPE_DOUBLE:
dst->value[k].b = src1->value[k].d != src2->value[k].d;
break;
case HLSL_TYPE_INT:
case HLSL_TYPE_UINT:
case HLSL_TYPE_BOOL:
dst->value[k].b = src1->value[k].u != src2->value[k].u;
break;
default:
FIXME("Fold not-equal for type %s.\n", debug_hlsl_type(ctx, dst->node.data_type));
return false;
I don't think it's possible to get here, is it? We already check that the type is numeric when parsing.
(Also, we probably want to trace the source type here...)
}
dst->value[k].b *= ~0u;
- }
- return true;
+}
- bool hlsl_fold_constants(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) { struct hlsl_ir_constant *arg1, *arg2 = NULL, *res;
@@ -266,6 +303,10 @@ bool hlsl_fold_constants(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void success = fold_mul(ctx, res, arg1, arg2); break;
case HLSL_OP2_NEQUAL:
success = fold_nequal(ctx, res, arg1, arg2);
break;
default: FIXME("Fold \"%s\" expression.\n", debug_hlsl_expr_op(expr->op)); success = false;
Hello,
March 23, 2022 11:28 AM, "Giovanni Mascellani" gmascellani@codeweavers.com wrote:
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
libs/vkd3d-shader/hlsl_constant_ops.c | 41 +++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_constant_ops.c b/libs/vkd3d-shader/hlsl_constant_ops.c index 6c852ba1..2f090863 100644 --- a/libs/vkd3d-shader/hlsl_constant_ops.c +++ b/libs/vkd3d-shader/hlsl_constant_ops.c @@ -224,6 +224,43 @@ static bool fold_mul(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, return true; }
+static bool fold_nequal(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst,
- struct hlsl_ir_constant *src1, struct hlsl_ir_constant *src2)
+{
- enum hlsl_base_type type = dst->node.data_type->base_type;
- assert(type == HLSL_TYPE_BOOL);
- assert(src1->node.data_type->base_type == src2->node.data_type->base_type);
- for (int k = 0; k < 4; ++k)
- {
- switch (src1->node.data_type->base_type)
- {
- case HLSL_TYPE_FLOAT:
- case HLSL_TYPE_HALF:
- dst->value[k].b = src1->value[k].f != src2->value[k].f;
- break;
- case HLSL_TYPE_DOUBLE:
- dst->value[k].b = src1->value[k].d != src2->value[k].d;
- break;
- case HLSL_TYPE_INT:
- case HLSL_TYPE_UINT:
- case HLSL_TYPE_BOOL:
- dst->value[k].b = src1->value[k].u != src2->value[k].u;
I am not so sure we can compare bools using .u, since sizeof(bool) is 1. The next 3 bytes may not be initialized. (more probably now that we have hlsl_new_constant()).
- break;
- default:
- FIXME("Fold not-equal for type %s.\n", debug_hlsl_type(ctx, dst->node.data_type));
- return false;
- }
- dst->value[k].b *= ~0u;
- }
- return true;
+}
bool hlsl_fold_constants(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) { struct hlsl_ir_constant *arg1, *arg2 = NULL, *res; @@ -266,6 +303,10 @@ bool hlsl_fold_constants(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void success = fold_mul(ctx, res, arg1, arg2); break;
- case HLSL_OP2_NEQUAL:
- success = fold_nequal(ctx, res, arg1, arg2);
- break;
default: FIXME("Fold "%s" expression.\n", debug_hlsl_expr_op(expr->op)); success = false; -- 2.35.1
Best regards, Francisco.
Oh, never mind, I forgot that hlsl_alloc() does a calloc() and initializes the memory to 0.
I still think it may be safer to compare the .b-s separately. If say, we reuse a hlsl_ir_constant value somewhere and change its type from HLSL_TYPE_INT to HLSL_TYPE_BOOL.
Signed-off-by: Francisco Casas fcasas@codeweavers.com
March 24, 2022 5:07 PM, "Francisco Casas" fcasas@codeweavers.com wrote:
Hello,
March 23, 2022 11:28 AM, "Giovanni Mascellani" gmascellani@codeweavers.com wrote:
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
libs/vkd3d-shader/hlsl_constant_ops.c | 41 +++++++++++++++++++++++++++ 1 file changed, 41 insertions(+)
diff --git a/libs/vkd3d-shader/hlsl_constant_ops.c b/libs/vkd3d-shader/hlsl_constant_ops.c index 6c852ba1..2f090863 100644 --- a/libs/vkd3d-shader/hlsl_constant_ops.c +++ b/libs/vkd3d-shader/hlsl_constant_ops.c @@ -224,6 +224,43 @@ static bool fold_mul(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, return true; }
+static bool fold_nequal(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst,
- struct hlsl_ir_constant *src1, struct hlsl_ir_constant *src2)
+{
- enum hlsl_base_type type = dst->node.data_type->base_type;
- assert(type == HLSL_TYPE_BOOL);
- assert(src1->node.data_type->base_type == src2->node.data_type->base_type);
- for (int k = 0; k < 4; ++k)
- {
- switch (src1->node.data_type->base_type)
- {
- case HLSL_TYPE_FLOAT:
- case HLSL_TYPE_HALF:
- dst->value[k].b = src1->value[k].f != src2->value[k].f;
- break;
- case HLSL_TYPE_DOUBLE:
- dst->value[k].b = src1->value[k].d != src2->value[k].d;
- break;
- case HLSL_TYPE_INT:
- case HLSL_TYPE_UINT:
- case HLSL_TYPE_BOOL:
- dst->value[k].b = src1->value[k].u != src2->value[k].u;
I am not so sure we can compare bools using .u, since sizeof(bool) is 1. The next 3 bytes may not be initialized. (more probably now that we have hlsl_new_constant()).
- break;
- default:
- FIXME("Fold not-equal for type %s.\n", debug_hlsl_type(ctx, dst->node.data_type));
- return false;
- }
- dst->value[k].b *= ~0u;
- }
- return true;
+}
bool hlsl_fold_constants(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) { struct hlsl_ir_constant *arg1, *arg2 = NULL, *res; @@ -266,6 +303,10 @@ bool hlsl_fold_constants(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void success = fold_mul(ctx, res, arg1, arg2); break;
- case HLSL_OP2_NEQUAL:
- success = fold_nequal(ctx, res, arg1, arg2);
- break;
default: FIXME("Fold "%s" expression.\n", debug_hlsl_expr_op(expr->op)); success = false; -- 2.35.1
Best regards, Francisco.
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- libs/vkd3d-shader/hlsl_codegen.c | 32 +++++++++++++++++++++++++++ libs/vkd3d-shader/hlsl_constant_ops.c | 10 ++------- libs/vkd3d-shader/hlsl_sm4.c | 4 ++-- 3 files changed, 36 insertions(+), 10 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 3d0f9e41..7222ff8a 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -745,6 +745,37 @@ static bool lower_division(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, voi return true; }
+static bool lower_cast_to_bool(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) +{ + struct hlsl_type *type = instr->data_type, *arg_type; + struct hlsl_ir_constant *zero; + struct hlsl_ir_expr *expr; + + if (instr->type != HLSL_IR_EXPR) + return false; + expr = hlsl_ir_expr(instr); + if (expr->op != HLSL_OP1_CAST) + return false; + arg_type = expr->operands[0].node->data_type; + if (type->type > HLSL_CLASS_VECTOR || arg_type->type > HLSL_CLASS_VECTOR) + return false; + if (type->base_type != HLSL_TYPE_BOOL) + return false; + + /* Narrowing casts should already have been lowered. */ + assert(type->dimx == arg_type->dimx); + + zero = hlsl_new_constant(ctx, arg_type, &instr->loc); + if (!zero) + return false; + list_add_before(&instr->entry, &zero->node.entry); + + expr->op = HLSL_OP2_NEQUAL; + hlsl_src_from_node(&expr->operands[1], &zero->node); + + return true; +} + static bool dce(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) { switch (instr->type) @@ -1642,6 +1673,7 @@ int hlsl_emit_bytecode(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry }
transform_ir(ctx, lower_broadcasts, body, NULL); + transform_ir(ctx, lower_cast_to_bool, body, NULL); while (transform_ir(ctx, fold_redundant_casts, body, NULL)); do { diff --git a/libs/vkd3d-shader/hlsl_constant_ops.c b/libs/vkd3d-shader/hlsl_constant_ops.c index 2f090863..be06332e 100644 --- a/libs/vkd3d-shader/hlsl_constant_ops.c +++ b/libs/vkd3d-shader/hlsl_constant_ops.c @@ -27,7 +27,6 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct int32_t i; double d; float f; - bool b;
if (dst->node.data_type->dimx != src->node.data_type->dimx || dst->node.data_type->dimy != src->node.data_type->dimy) @@ -47,7 +46,6 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct i = src->value[k].f; f = src->value[k].f; d = src->value[k].f; - b = src->value[k].f; break;
case HLSL_TYPE_DOUBLE: @@ -55,7 +53,6 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct i = src->value[k].d; f = src->value[k].d; d = src->value[k].d; - b = src->value[k].d; break;
case HLSL_TYPE_INT: @@ -63,7 +60,6 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct i = src->value[k].i; f = src->value[k].i; d = src->value[k].i; - b = src->value[k].i; break;
case HLSL_TYPE_UINT: @@ -71,7 +67,6 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct i = src->value[k].u; f = src->value[k].u; d = src->value[k].u; - b = src->value[k].u; break;
case HLSL_TYPE_BOOL: @@ -79,7 +74,6 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct i = !!src->value[k].b; f = !!src->value[k].b; d = !!src->value[k].b; - b = !!src->value[k].b; break;
default: @@ -108,8 +102,8 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct break;
case HLSL_TYPE_BOOL: - dst->value[k].b = b; - break; + /* Casts to bool should have already been lowered. */ + assert(0);
default: FIXME("Cast from %s to %s.\n", debug_hlsl_type(ctx, src->node.data_type), diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index af5c777f..49ab1a21 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1533,8 +1533,8 @@ static void write_sm4_cast(struct hlsl_ctx *ctx, break;
case HLSL_TYPE_BOOL: - hlsl_fixme(ctx, &expr->node.loc, "SM4 cast to bool.\n"); - break; + /* Casts to bool should have already been lowered. */ + assert(0);
default: assert(0);
Signed-off-by: Zebediah Figura zfigura@codeweavers.com
Hello,
March 23, 2022 11:28 AM, "Giovanni Mascellani" gmascellani@codeweavers.com wrote:
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
libs/vkd3d-shader/hlsl_codegen.c | 32 +++++++++++++++++++++++++++ libs/vkd3d-shader/hlsl_constant_ops.c | 10 ++------- libs/vkd3d-shader/hlsl_sm4.c | 4 ++-- 3 files changed, 36 insertions(+), 10 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 3d0f9e41..7222ff8a 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -745,6 +745,37 @@ static bool lower_division(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, voi return true; }
+static bool lower_cast_to_bool(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) +{
- struct hlsl_type *type = instr->data_type, *arg_type;
- struct hlsl_ir_constant *zero;
- struct hlsl_ir_expr *expr;
- if (instr->type != HLSL_IR_EXPR)
- return false;
- expr = hlsl_ir_expr(instr);
- if (expr->op != HLSL_OP1_CAST)
- return false;
- arg_type = expr->operands[0].node->data_type;
- if (type->type > HLSL_CLASS_VECTOR || arg_type->type > HLSL_CLASS_VECTOR)
- return false;
- if (type->base_type != HLSL_TYPE_BOOL)
- return false;
- /* Narrowing casts should already have been lowered. */
- assert(type->dimx == arg_type->dimx);
But isn't lower_cast_to_bool being done before lower_narrowing_casts in hlsl_emit_bytecode() ?
- zero = hlsl_new_constant(ctx, arg_type, &instr->loc);
- if (!zero)
- return false;
- list_add_before(&instr->entry, &zero->node.entry);
- expr->op = HLSL_OP2_NEQUAL;
- hlsl_src_from_node(&expr->operands[1], &zero->node);
- return true;
+}
static bool dce(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) { switch (instr->type) @@ -1642,6 +1673,7 @@ int hlsl_emit_bytecode(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry }
transform_ir(ctx, lower_broadcasts, body, NULL);
- transform_ir(ctx, lower_cast_to_bool, body, NULL);
here.
while (transform_ir(ctx, fold_redundant_casts, body, NULL)); do { diff --git a/libs/vkd3d-shader/hlsl_constant_ops.c b/libs/vkd3d-shader/hlsl_constant_ops.c index 2f090863..be06332e 100644 --- a/libs/vkd3d-shader/hlsl_constant_ops.c +++ b/libs/vkd3d-shader/hlsl_constant_ops.c @@ -27,7 +27,6 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct int32_t i; double d; float f;
- bool b;
if (dst->node.data_type->dimx != src->node.data_type->dimx || dst->node.data_type->dimy != src->node.data_type->dimy) @@ -47,7 +46,6 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct i = src->value[k].f; f = src->value[k].f; d = src->value[k].f;
- b = src->value[k].f;
break;
case HLSL_TYPE_DOUBLE: @@ -55,7 +53,6 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct i = src->value[k].d; f = src->value[k].d; d = src->value[k].d;
- b = src->value[k].d;
break;
case HLSL_TYPE_INT: @@ -63,7 +60,6 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct i = src->value[k].i; f = src->value[k].i; d = src->value[k].i;
- b = src->value[k].i;
break;
case HLSL_TYPE_UINT: @@ -71,7 +67,6 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct i = src->value[k].u; f = src->value[k].u; d = src->value[k].u;
- b = src->value[k].u;
break;
case HLSL_TYPE_BOOL: @@ -79,7 +74,6 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct i = !!src->value[k].b; f = !!src->value[k].b; d = !!src->value[k].b;
- b = !!src->value[k].b;
break;
default: @@ -108,8 +102,8 @@ static bool fold_cast(struct hlsl_ctx *ctx, struct hlsl_ir_constant *dst, struct break;
case HLSL_TYPE_BOOL:
- dst->value[k].b = b;
- break;
- /* Casts to bool should have already been lowered. */
- assert(0);
default: FIXME("Cast from %s to %s.\n", debug_hlsl_type(ctx, src->node.data_type), diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index af5c777f..49ab1a21 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1533,8 +1533,8 @@ static void write_sm4_cast(struct hlsl_ctx *ctx, break;
case HLSL_TYPE_BOOL:
- hlsl_fixme(ctx, &expr->node.loc, "SM4 cast to bool.\n");
- break;
- /* Casts to bool should have already been lowered. */
- assert(0);
default: assert(0); -- 2.35.1
On Thu, Mar 24, 2022 at 10:32 PM Francisco Casas fcasas@codeweavers.com wrote:
Hello,
March 23, 2022 11:28 AM, "Giovanni Mascellani" gmascellani@codeweavers.com wrote:
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
libs/vkd3d-shader/hlsl_codegen.c | 32 +++++++++++++++++++++++++++ libs/vkd3d-shader/hlsl_constant_ops.c | 10 ++------- libs/vkd3d-shader/hlsl_sm4.c | 4 ++-- 3 files changed, 36 insertions(+), 10 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_codegen.c b/libs/vkd3d-shader/hlsl_codegen.c index 3d0f9e41..7222ff8a 100644 --- a/libs/vkd3d-shader/hlsl_codegen.c +++ b/libs/vkd3d-shader/hlsl_codegen.c @@ -745,6 +745,37 @@ static bool lower_division(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, voi return true; }
+static bool lower_cast_to_bool(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) +{
- struct hlsl_type *type = instr->data_type, *arg_type;
- struct hlsl_ir_constant *zero;
- struct hlsl_ir_expr *expr;
- if (instr->type != HLSL_IR_EXPR)
- return false;
- expr = hlsl_ir_expr(instr);
- if (expr->op != HLSL_OP1_CAST)
- return false;
- arg_type = expr->operands[0].node->data_type;
- if (type->type > HLSL_CLASS_VECTOR || arg_type->type > HLSL_CLASS_VECTOR)
- return false;
- if (type->base_type != HLSL_TYPE_BOOL)
- return false;
- /* Narrowing casts should already have been lowered. */
- assert(type->dimx == arg_type->dimx);
But isn't lower_cast_to_bool being done before lower_narrowing_casts in hlsl_emit_bytecode() ?
- zero = hlsl_new_constant(ctx, arg_type, &instr->loc);
- if (!zero)
- return false;
- list_add_before(&instr->entry, &zero->node.entry);
- expr->op = HLSL_OP2_NEQUAL;
- hlsl_src_from_node(&expr->operands[1], &zero->node);
- return true;
+}
static bool dce(struct hlsl_ctx *ctx, struct hlsl_ir_node *instr, void *context) { switch (instr->type) @@ -1642,6 +1673,7 @@ int hlsl_emit_bytecode(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *entry }
transform_ir(ctx, lower_broadcasts, body, NULL);
- transform_ir(ctx, lower_cast_to_bool, body, NULL);
here.
Yes, e.g. the following shader asserts:
uniform float4 val;
bool2 main() : sv_target { return (bool2)val; }
It's still an issue in v2.
On Wed, 23 Mar 2022 at 15:27, Giovanni Mascellani gmascellani@codeweavers.com wrote:
libs/vkd3d-shader/hlsl_sm4.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Would we be able to get here by providing either valid or invalid user input, or would the only way to get here be internal inconsistencies in the HLSL compiler? The latter would be fine, but I don't think we'd want to use assert() in the former case.
Hi,
Il 23/03/22 16:43, Henri Verbeet ha scritto:
Would we be able to get here by providing either valid or invalid user input, or would the only way to get here be internal inconsistencies in the HLSL compiler? The latter would be fine, but I don't think we'd want to use assert() in the former case.
I agree with the general principle that the user shouldn't ever be able to make an assert() fire.
In the specic case, for each processed instruction write_sm4_block() asserts that, if it has a return type, then it is either a scalar or vector type. Furthermore, the base type for scalars or vectors is only allowed to be in that list of six types (int, uint, bool, float, double, half). Therefore, if control reaches the lines that I am changing, it means that we have another bug up the pipeline, it shouldn't happen just a result of invalid user input.
Giovanni.
Signed-off-by: Francisco Casas fcasas@codeweavers.com
--- Maybe the commit message should specify that this is in write_sm4_cast().
March 23, 2022 11:28 AM, "Giovanni Mascellani" gmascellani@codeweavers.com wrote:
Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com
libs/vkd3d-shader/hlsl_sm4.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/libs/vkd3d-shader/hlsl_sm4.c b/libs/vkd3d-shader/hlsl_sm4.c index fa845dc4..af5c777f 100644 --- a/libs/vkd3d-shader/hlsl_sm4.c +++ b/libs/vkd3d-shader/hlsl_sm4.c @@ -1468,7 +1468,7 @@ static void write_sm4_cast(struct hlsl_ctx *ctx, break;
default:
- break;
- assert(0);
} break;
@@ -1494,7 +1494,7 @@ static void write_sm4_cast(struct hlsl_ctx *ctx, break;
default:
- break;
- assert(0);
} break;
@@ -1520,7 +1520,7 @@ static void write_sm4_cast(struct hlsl_ctx *ctx, break;
default:
- break;
- assert(0);
} break;
-- 2.35.1
Il 24/03/22 19:15, Francisco Casas ha scritto:
Maybe the commit message should specify that this is in write_sm4_cast().
I thought about that, but then decided that the subject would have become too long. And it is something that you can easily extract from the patch, it doesn't require too much explanation.
Giovanni.