Initial work on parsing sampler declarations.
authorRyan C. Gordon <icculus@icculus.org>
Fri, 06 Mar 2009 22:58:21 -0500
changeset 724 e96f140736f0
parent 723 6d58b504cc6e
child 725 5e3c35b63abd
Initial work on parsing sampler declarations.
mojoshader_compiler.c
mojoshader_parser_hlsl.lemon
--- a/mojoshader_compiler.c	Fri Mar 06 22:56:44 2009 -0500
+++ b/mojoshader_compiler.c	Fri Mar 06 22:58:21 2009 -0500
@@ -245,6 +245,15 @@
             if (tokencmp("call")) return TOKEN_HLSL_CALL;
             if (tokencmp("case")) return TOKEN_HLSL_CASE;
             if (tokencmp("default")) return TOKEN_HLSL_DEFAULT;
+            if (tokencmp("sampler")) return TOKEN_HLSL_SAMPLER;
+            if (tokencmp("sampler1D")) return TOKEN_HLSL_SAMPLER1D;
+            if (tokencmp("sampler2D")) return TOKEN_HLSL_SAMPLER2D;
+            if (tokencmp("sampler3D")) return TOKEN_HLSL_SAMPLER3D;
+            if (tokencmp("samplerCUBE")) return TOKEN_HLSL_SAMPLERCUBE;
+            if (tokencmp("sampler_state")) return TOKEN_HLSL_SAMPLER_STATE;
+            if (tokencmp("SamplerState")) return TOKEN_HLSL_SAMPLERSTATE;
+            if (tokencmp("SamplerComparisonState")) return TOKEN_HLSL_SAMPLERCOMPARISONSTATE;
+
             #undef tokencmp
             return TOKEN_HLSL_IDENTIFIER;
 
--- a/mojoshader_parser_hlsl.lemon	Fri Mar 06 22:56:44 2009 -0500
+++ b/mojoshader_parser_hlsl.lemon	Fri Mar 06 22:58:21 2009 -0500
@@ -170,6 +170,8 @@
 variable_declaration ::= datatype scalar_or_array SEMICOLON.
 variable_declaration ::= struct_declaration scalar_or_array SEMICOLON.
 
+// !!! FIXME: we don't handle full sampler declarations at the moment.
+
 struct_declaration ::= STRUCT identifier LBRACE struct_member_list RBRACE.
 
 struct_member_list ::= struct_member.
@@ -220,10 +222,20 @@
 intrinsic_datatype ::= datatype_vector.
 intrinsic_datatype ::= datatype_matrix.
 intrinsic_datatype ::= datatype_scalar.
+intrinsic_datatype ::= datatype_sampler.
 
 datatype ::= intrinsic_datatype.
 datatype ::= USERTYPE.
 
+datatype_sampler ::= SAMPLER.
+datatype_sampler ::= SAMPLER1D.
+datatype_sampler ::= SAMPLER2D.
+datatype_sampler ::= SAMPLER3D.
+datatype_sampler ::= SAMPLERCUBE.
+datatype_sampler ::= SAMPLER_STATE.
+datatype_sampler ::= SAMPLERSTATE.
+datatype_sampler ::= SAMPLERCOMPARISONSTATE.
+
 datatype_scalar ::= BOOL.
 datatype_scalar ::= INT.
 datatype_scalar ::= UINT.