Commit 9d9dae0c authored by Matteo Bruni's avatar Matteo Bruni Committed by Alexandre Julliard

d3dcompiler: Distinguish between scalars, vectors and matrices.

parent a8839cd1
...@@ -614,6 +614,17 @@ void SlDeleteShader(struct bwriter_shader *shader) DECLSPEC_HIDDEN; ...@@ -614,6 +614,17 @@ void SlDeleteShader(struct bwriter_shader *shader) DECLSPEC_HIDDEN;
* DEALINGS IN THE SOFTWARE. * DEALINGS IN THE SOFTWARE.
*/ */
enum hlsl_type_class
{
HLSL_CLASS_SCALAR,
HLSL_CLASS_VECTOR,
HLSL_CLASS_MATRIX,
HLSL_CLASS_LAST_NUMERIC = HLSL_CLASS_MATRIX,
HLSL_CLASS_STRUCT,
HLSL_CLASS_ARRAY,
HLSL_CLASS_OBJECT,
};
enum hlsl_base_type enum hlsl_base_type
{ {
HLSL_TYPE_FLOAT, HLSL_TYPE_FLOAT,
...@@ -628,8 +639,6 @@ enum hlsl_base_type ...@@ -628,8 +639,6 @@ enum hlsl_base_type
HLSL_TYPE_PIXELSHADER, HLSL_TYPE_PIXELSHADER,
HLSL_TYPE_VERTEXSHADER, HLSL_TYPE_VERTEXSHADER,
HLSL_TYPE_STRING, HLSL_TYPE_STRING,
HLSL_TYPE_STRUCT,
HLSL_TYPE_ARRAY,
HLSL_TYPE_VOID, HLSL_TYPE_VOID,
}; };
...@@ -643,6 +652,7 @@ struct hlsl_type ...@@ -643,6 +652,7 @@ struct hlsl_type
{ {
struct list entry; struct list entry;
struct list scope_entry; struct list scope_entry;
enum hlsl_type_class type;
enum hlsl_base_type base_type; enum hlsl_base_type base_type;
const char *name; const char *name;
unsigned int modifiers; unsigned int modifiers;
...@@ -737,7 +747,8 @@ void hlsl_message(const char *fmt, ...) PRINTF_ATTR(1,2) DECLSPEC_HIDDEN; ...@@ -737,7 +747,8 @@ void hlsl_message(const char *fmt, ...) PRINTF_ATTR(1,2) DECLSPEC_HIDDEN;
BOOL add_declaration(struct hlsl_scope *scope, struct hlsl_ir_var *decl, BOOL local_var) DECLSPEC_HIDDEN; BOOL add_declaration(struct hlsl_scope *scope, struct hlsl_ir_var *decl, BOOL local_var) DECLSPEC_HIDDEN;
struct hlsl_ir_var *get_variable(struct hlsl_scope *scope, const char *name) DECLSPEC_HIDDEN; struct hlsl_ir_var *get_variable(struct hlsl_scope *scope, const char *name) DECLSPEC_HIDDEN;
void free_declaration(struct hlsl_ir_var *decl) DECLSPEC_HIDDEN; void free_declaration(struct hlsl_ir_var *decl) DECLSPEC_HIDDEN;
struct hlsl_type *new_hlsl_type(const char *name, enum hlsl_base_type base_type, unsigned dimx, unsigned dimy) DECLSPEC_HIDDEN; struct hlsl_type *new_hlsl_type(const char *name, enum hlsl_type_class type_class,
enum hlsl_base_type base_type, unsigned dimx, unsigned dimy) DECLSPEC_HIDDEN;
struct hlsl_type *new_array_type(struct hlsl_type *basic_type, unsigned int array_size) DECLSPEC_HIDDEN; struct hlsl_type *new_array_type(struct hlsl_type *basic_type, unsigned int array_size) DECLSPEC_HIDDEN;
struct hlsl_type *get_type(struct hlsl_scope *scope, const char *name, BOOL recursive) DECLSPEC_HIDDEN; struct hlsl_type *get_type(struct hlsl_scope *scope, const char *name, BOOL recursive) DECLSPEC_HIDDEN;
BOOL find_function(const char *name) DECLSPEC_HIDDEN; BOOL find_function(const char *name) DECLSPEC_HIDDEN;
......
...@@ -240,7 +240,7 @@ type: base_type ...@@ -240,7 +240,7 @@ type: base_type
base_type: KW_VOID base_type: KW_VOID
{ {
$$ = new_hlsl_type("void", HLSL_TYPE_VOID, 1, 1); $$ = new_hlsl_type("void", HLSL_CLASS_SCALAR, HLSL_TYPE_VOID, 1, 1);
} }
| TYPE_IDENTIFIER | TYPE_IDENTIFIER
{ {
...@@ -257,9 +257,9 @@ base_type: KW_VOID ...@@ -257,9 +257,9 @@ base_type: KW_VOID
TRACE("Struct type %s.\n", $2); TRACE("Struct type %s.\n", $2);
type = get_type(hlsl_ctx.cur_scope, $2, TRUE); type = get_type(hlsl_ctx.cur_scope, $2, TRUE);
if (type->base_type != HLSL_TYPE_STRUCT) if (type->type != HLSL_CLASS_STRUCT)
{ {
hlsl_message("Line %u: Redefining %s as a structure.\n", hlsl_message("Line %u: redefining %s as a structure.\n",
hlsl_ctx.line_no, $2); hlsl_ctx.line_no, $2);
set_parse_status(&hlsl_ctx.status, PARSE_ERR); set_parse_status(&hlsl_ctx.status, PARSE_ERR);
} }
......
...@@ -804,7 +804,8 @@ void free_declaration(struct hlsl_ir_var *decl) ...@@ -804,7 +804,8 @@ void free_declaration(struct hlsl_ir_var *decl)
d3dcompiler_free(decl); d3dcompiler_free(decl);
} }
struct hlsl_type *new_hlsl_type(const char *name, enum hlsl_base_type base_type, unsigned dimx, unsigned dimy) struct hlsl_type *new_hlsl_type(const char *name, enum hlsl_type_class type_class,
enum hlsl_base_type base_type, unsigned dimx, unsigned dimy)
{ {
struct hlsl_type *type; struct hlsl_type *type;
...@@ -815,6 +816,7 @@ struct hlsl_type *new_hlsl_type(const char *name, enum hlsl_base_type base_type, ...@@ -815,6 +816,7 @@ struct hlsl_type *new_hlsl_type(const char *name, enum hlsl_base_type base_type,
return NULL; return NULL;
} }
type->name = name; type->name = name;
type->type = type_class;
type->base_type = base_type; type->base_type = base_type;
type->dimx = dimx; type->dimx = dimx;
type->dimy = dimy; type->dimy = dimy;
...@@ -879,8 +881,6 @@ const char *debug_base_type(const struct hlsl_type *type) ...@@ -879,8 +881,6 @@ const char *debug_base_type(const struct hlsl_type *type)
case HLSL_TYPE_INT: name = "int"; break; case HLSL_TYPE_INT: name = "int"; break;
case HLSL_TYPE_UINT: name = "uint"; break; case HLSL_TYPE_UINT: name = "uint"; break;
case HLSL_TYPE_BOOL: name = "bool"; break; case HLSL_TYPE_BOOL: name = "bool"; break;
case HLSL_TYPE_STRUCT: name = "struct"; break;
case HLSL_TYPE_ARRAY: name = "array"; break;
default: default:
FIXME("Unhandled case %u\n", type->base_type); FIXME("Unhandled case %u\n", type->base_type);
} }
...@@ -894,15 +894,18 @@ const char *debug_hlsl_type(const struct hlsl_type *type) ...@@ -894,15 +894,18 @@ const char *debug_hlsl_type(const struct hlsl_type *type)
if (type->name) if (type->name)
return debugstr_a(type->name); return debugstr_a(type->name);
if (type->base_type == HLSL_TYPE_STRUCT) if (type->type == HLSL_CLASS_STRUCT)
name = "<anonymous struct>"; name = "<anonymous struct>";
else else
name = debug_base_type(type); name = debug_base_type(type);
if (type->dimx == 1 && type->dimy == 1)
if (type->type == HLSL_CLASS_SCALAR)
return wine_dbg_sprintf("%s", name); return wine_dbg_sprintf("%s", name);
if (type->dimy == 1) if (type->type == HLSL_CLASS_VECTOR)
return wine_dbg_sprintf("vector<%s, %u>", name, type->dimx); return wine_dbg_sprintf("vector<%s, %u>", name, type->dimx);
return wine_dbg_sprintf("matrix<%s, %u, %u>", name, type->dimx, type->dimy); if (type->type == HLSL_CLASS_MATRIX)
return wine_dbg_sprintf("matrix<%s, %u, %u>", name, type->dimx, type->dimy);
return "unexpected_type";
} }
const char *debug_node_type(enum hlsl_ir_node_type type) const char *debug_node_type(enum hlsl_ir_node_type type)
...@@ -924,7 +927,7 @@ void free_hlsl_type(struct hlsl_type *type) ...@@ -924,7 +927,7 @@ void free_hlsl_type(struct hlsl_type *type)
struct hlsl_struct_field *field, *next_field; struct hlsl_struct_field *field, *next_field;
d3dcompiler_free((void *)type->name); d3dcompiler_free((void *)type->name);
if (type->base_type == HLSL_TYPE_STRUCT) if (type->type == HLSL_CLASS_STRUCT)
{ {
LIST_FOR_EACH_ENTRY_SAFE(field, next_field, type->e.elements, struct hlsl_struct_field, entry) LIST_FOR_EACH_ENTRY_SAFE(field, next_field, type->e.elements, struct hlsl_struct_field, entry)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment