Matteo Bruni : d3dcompiler: Distinguish between scalars, vectors and matrices.

Alexandre Julliard julliard at winehq.org
Thu Jun 7 13:39:16 CDT 2012


Module: wine
Branch: master
Commit: 9d9dae0cdb79fb30c13c0a20690730fc2cd17ef0
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=9d9dae0cdb79fb30c13c0a20690730fc2cd17ef0

Author: Matteo Bruni <mbruni at codeweavers.com>
Date:   Thu Jun  7 00:19:02 2012 +0200

d3dcompiler: Distinguish between scalars, vectors and matrices.

---

 dlls/d3dcompiler_43/d3dcompiler_private.h |   17 ++++++++++++++---
 dlls/d3dcompiler_43/hlsl.y                |    6 +++---
 dlls/d3dcompiler_43/utils.c               |   19 +++++++++++--------
 3 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h
index 3ee0ed5..74d2662 100644
--- a/dlls/d3dcompiler_43/d3dcompiler_private.h
+++ b/dlls/d3dcompiler_43/d3dcompiler_private.h
@@ -614,6 +614,17 @@ void SlDeleteShader(struct bwriter_shader *shader) DECLSPEC_HIDDEN;
  * 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
 {
     HLSL_TYPE_FLOAT,
@@ -628,8 +639,6 @@ enum hlsl_base_type
     HLSL_TYPE_PIXELSHADER,
     HLSL_TYPE_VERTEXSHADER,
     HLSL_TYPE_STRING,
-    HLSL_TYPE_STRUCT,
-    HLSL_TYPE_ARRAY,
     HLSL_TYPE_VOID,
 };
 
@@ -643,6 +652,7 @@ struct hlsl_type
 {
     struct list entry;
     struct list scope_entry;
+    enum hlsl_type_class type;
     enum hlsl_base_type base_type;
     const char *name;
     unsigned int modifiers;
@@ -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;
 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;
-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 *get_type(struct hlsl_scope *scope, const char *name, BOOL recursive) DECLSPEC_HIDDEN;
 BOOL find_function(const char *name) DECLSPEC_HIDDEN;
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y
index d967bce..e5a2a48 100644
--- a/dlls/d3dcompiler_43/hlsl.y
+++ b/dlls/d3dcompiler_43/hlsl.y
@@ -240,7 +240,7 @@ type:                     base_type
 
 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
                             {
@@ -257,9 +257,9 @@ base_type:                KW_VOID
 
                                 TRACE("Struct type %s.\n", $2);
                                 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);
                                     set_parse_status(&hlsl_ctx.status, PARSE_ERR);
                                 }
diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c
index eaf2566..ef22823 100644
--- a/dlls/d3dcompiler_43/utils.c
+++ b/dlls/d3dcompiler_43/utils.c
@@ -804,7 +804,8 @@ void free_declaration(struct hlsl_ir_var *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;
 
@@ -815,6 +816,7 @@ struct hlsl_type *new_hlsl_type(const char *name, enum hlsl_base_type base_type,
         return NULL;
     }
     type->name = name;
+    type->type = type_class;
     type->base_type = base_type;
     type->dimx = dimx;
     type->dimy = dimy;
@@ -879,8 +881,6 @@ const char *debug_base_type(const struct hlsl_type *type)
         case HLSL_TYPE_INT:          name = "int";           break;
         case HLSL_TYPE_UINT:         name = "uint";          break;
         case HLSL_TYPE_BOOL:         name = "bool";          break;
-        case HLSL_TYPE_STRUCT:       name = "struct";        break;
-        case HLSL_TYPE_ARRAY:        name = "array";         break;
         default:
             FIXME("Unhandled case %u\n", type->base_type);
     }
@@ -894,15 +894,18 @@ const char *debug_hlsl_type(const struct hlsl_type *type)
     if (type->name)
         return debugstr_a(type->name);
 
-    if (type->base_type == HLSL_TYPE_STRUCT)
+    if (type->type == HLSL_CLASS_STRUCT)
         name = "<anonymous struct>";
     else
         name = debug_base_type(type);
-    if (type->dimx == 1 && type->dimy == 1)
+
+    if (type->type == HLSL_CLASS_SCALAR)
         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("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)
@@ -924,7 +927,7 @@ void free_hlsl_type(struct hlsl_type *type)
     struct hlsl_struct_field *field, *next_field;
 
     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)
         {




More information about the wine-cvs mailing list