Matteo Bruni : d3dcompiler: Parse sampler declarations.

Alexandre Julliard julliard at winehq.org
Tue Jun 12 13:36:31 CDT 2012


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

Author: Matteo Bruni <mbruni at codeweavers.com>
Date:   Mon Jun 11 19:18:32 2012 +0200

d3dcompiler: Parse sampler declarations.

---

 dlls/d3dcompiler_43/d3dcompiler_private.h |   10 ++++++++++
 dlls/d3dcompiler_43/hlsl.y                |   25 +++++++++++++++++++++++++
 dlls/d3dcompiler_43/utils.c               |   10 ++++++++++
 3 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/dlls/d3dcompiler_43/d3dcompiler_private.h b/dlls/d3dcompiler_43/d3dcompiler_private.h
index 5e5f1d3..1c4b776 100644
--- a/dlls/d3dcompiler_43/d3dcompiler_private.h
+++ b/dlls/d3dcompiler_43/d3dcompiler_private.h
@@ -644,6 +644,15 @@ enum hlsl_base_type
     HLSL_TYPE_VOID,
 };
 
+enum hlsl_sampler_dim
+{
+   HLSL_SAMPLER_DIM_GENERIC,
+   HLSL_SAMPLER_DIM_1D,
+   HLSL_SAMPLER_DIM_2D,
+   HLSL_SAMPLER_DIM_3D,
+   HLSL_SAMPLER_DIM_CUBE,
+};
+
 enum hlsl_matrix_majority
 {
     HLSL_COLUMN_MAJOR,
@@ -656,6 +665,7 @@ struct hlsl_type
     struct list scope_entry;
     enum hlsl_type_class type;
     enum hlsl_base_type base_type;
+    enum hlsl_sampler_dim sampler_dim;
     const char *name;
     unsigned int modifiers;
     unsigned int dimx;
diff --git a/dlls/d3dcompiler_43/hlsl.y b/dlls/d3dcompiler_43/hlsl.y
index cc13e25..7384e88 100644
--- a/dlls/d3dcompiler_43/hlsl.y
+++ b/dlls/d3dcompiler_43/hlsl.y
@@ -343,6 +343,31 @@ base_type:                KW_VOID
                             {
                                 $$ = new_hlsl_type("void", HLSL_CLASS_SCALAR, HLSL_TYPE_VOID, 1, 1);
                             }
+                        | KW_SAMPLER
+                            {
+                                $$ = new_hlsl_type("sampler", HLSL_CLASS_OBJECT, HLSL_TYPE_SAMPLER, 1, 1);
+                                $$->sampler_dim = HLSL_SAMPLER_DIM_GENERIC;
+                            }
+                        | KW_SAMPLER1D
+                            {
+                                $$ = new_hlsl_type("sampler1D", HLSL_CLASS_OBJECT, HLSL_TYPE_SAMPLER, 1, 1);
+                                $$->sampler_dim = HLSL_SAMPLER_DIM_1D;
+                            }
+                        | KW_SAMPLER2D
+                            {
+                                $$ = new_hlsl_type("sampler2D", HLSL_CLASS_OBJECT, HLSL_TYPE_SAMPLER, 1, 1);
+                                $$->sampler_dim = HLSL_SAMPLER_DIM_2D;
+                            }
+                        | KW_SAMPLER3D
+                            {
+                                $$ = new_hlsl_type("sampler3D", HLSL_CLASS_OBJECT, HLSL_TYPE_SAMPLER, 1, 1);
+                                $$->sampler_dim = HLSL_SAMPLER_DIM_3D;
+                            }
+                        | KW_SAMPLERCUBE
+                            {
+                                $$ = new_hlsl_type("samplerCUBE", HLSL_CLASS_OBJECT, HLSL_TYPE_SAMPLER, 1, 1);
+                                $$->sampler_dim = HLSL_SAMPLER_DIM_CUBE;
+                            }
                         | TYPE_IDENTIFIER
                             {
                                 struct hlsl_type *type;
diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c
index 304f70c..6f8b013 100644
--- a/dlls/d3dcompiler_43/utils.c
+++ b/dlls/d3dcompiler_43/utils.c
@@ -897,6 +897,16 @@ static 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_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);
     }




More information about the wine-cvs mailing list