From bca8443a53a78f69477e7c4842ecb863bc9135b7 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Tue, 25 Aug 2009 23:20:02 -0400 Subject: [PATCH] Added statement block attributes to the HLSL grammar. These are supposedly only available to Shader Model 4 and Xbox 360 targets. --- mojoshader_compiler.c | 5 +++++ mojoshader_parser_hlsl.lemon | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/mojoshader_compiler.c b/mojoshader_compiler.c index aae9f474..a48d6c96 100644 --- a/mojoshader_compiler.c +++ b/mojoshader_compiler.c @@ -326,6 +326,11 @@ static int convert_to_lemon_token(const Context *ctx) if (tokencmp("sampler_state")) return TOKEN_HLSL_SAMPLER_STATE; if (tokencmp("SamplerState")) return TOKEN_HLSL_SAMPLERSTATE; if (tokencmp("SamplerComparisonState")) return TOKEN_HLSL_SAMPLERCOMPARISONSTATE; + if (tokencmp("isolate")) return TOKEN_HLSL_ISOLATE; + if (tokencmp("maxInstructionCount")) return TOKEN_HLSL_MAXINSTRUCTIONCOUNT; + if (tokencmp("noExpressionOptimizations")) return TOKEN_HLSL_NOEXPRESSIONOPTIMIZATIONS; + if (tokencmp("unused")) return TOKEN_HLSL_UNUSED; + if (tokencmp("xps")) return TOKEN_HLSL_XPS; #undef tokencmp diff --git a/mojoshader_parser_hlsl.lemon b/mojoshader_parser_hlsl.lemon index 1c67ab85..a6a70909 100644 --- a/mojoshader_parser_hlsl.lemon +++ b/mojoshader_parser_hlsl.lemon @@ -19,6 +19,10 @@ %name ParseHLSL +// Some shift-reduce conflicts are basically unavoidable, but if the final +// conflict count matches this value, we consider it known and acceptable. +%expect 1 + %start_symbol shader %token_prefix TOKEN_HLSL_ %token_type { TokenData } @@ -385,10 +389,21 @@ statement_block ::= LBRACE statement_list RBRACE. statement_list ::= statement. statement_list ::= statement_list statement. +// These are for Shader Model 4 and Xbox 360 only, apparently. +statement_attribute_details ::= ISOLATE. +statement_attribute_details ::= MAXINSTRUCTIONCOUNT LPAREN INT_CONSTANT RPAREN. +statement_attribute_details ::= NOEXPRESSIONOPTIMIZATIONS. +statement_attribute_details ::= REMOVEUNUSEDINPUTS. +statement_attribute_details ::= UNUSED. +statement_attribute_details ::= XPS. + +statement_attribute ::= LBRACKET statement_attribute_details RBRACKET. + statement ::= return_statement. statement ::= BREAK SEMICOLON. statement ::= CONTINUE SEMICOLON. statement ::= DISCARD SEMICOLON. +statement ::= statement_attribute statement_block. statement ::= statement_block. statement ::= for_statement. statement ::= do_statement.