d3dcompiler: Parse modifiers.
This commit is contained in:
parent
9d9dae0cdb
commit
3275cca970
|
@ -694,6 +694,20 @@ struct hlsl_ir_node
|
|||
unsigned int column;
|
||||
};
|
||||
|
||||
#define HLSL_STORAGE_EXTERN 0x00000001
|
||||
#define HLSL_STORAGE_NOINTERPOLATION 0x00000002
|
||||
#define HLSL_MODIFIER_PRECISE 0x00000004
|
||||
#define HLSL_STORAGE_SHARED 0x00000008
|
||||
#define HLSL_STORAGE_GROUPSHARED 0x00000010
|
||||
#define HLSL_STORAGE_STATIC 0x00000020
|
||||
#define HLSL_STORAGE_UNIFORM 0x00000040
|
||||
#define HLSL_STORAGE_VOLATILE 0x00000080
|
||||
#define HLSL_MODIFIER_CONST 0x00000100
|
||||
#define HLSL_MODIFIER_ROW_MAJOR 0x00000200
|
||||
#define HLSL_MODIFIER_COLUMN_MAJOR 0x00000400
|
||||
#define HLSL_MODIFIER_IN 0x00000800
|
||||
#define HLSL_MODIFIER_OUT 0x00001000
|
||||
|
||||
struct hlsl_ir_var
|
||||
{
|
||||
struct hlsl_ir_node node;
|
||||
|
|
|
@ -50,6 +50,8 @@ static void hlsl_error(const char *s)
|
|||
static void debug_dump_decl(struct hlsl_type *type, DWORD modifiers, const char *declname, unsigned int line_no)
|
||||
{
|
||||
TRACE("Line %u: ", line_no);
|
||||
if (modifiers)
|
||||
TRACE("%s ", debug_modifiers(modifiers));
|
||||
TRACE("%s %s;\n", debug_hlsl_type(type), declname);
|
||||
}
|
||||
|
||||
|
@ -58,6 +60,25 @@ static BOOL declare_variable(struct hlsl_ir_var *decl, BOOL local)
|
|||
BOOL ret;
|
||||
|
||||
TRACE("Declaring variable %s.\n", decl->name);
|
||||
if (decl->node.data_type->type == HLSL_CLASS_MATRIX)
|
||||
{
|
||||
if (!(decl->modifiers & (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR)))
|
||||
{
|
||||
decl->modifiers |= hlsl_ctx.matrix_majority == HLSL_ROW_MAJOR
|
||||
? HLSL_MODIFIER_ROW_MAJOR : HLSL_MODIFIER_COLUMN_MAJOR;
|
||||
}
|
||||
}
|
||||
if (local)
|
||||
{
|
||||
DWORD invalid = decl->modifiers & (HLSL_STORAGE_EXTERN | HLSL_STORAGE_SHARED
|
||||
| HLSL_STORAGE_GROUPSHARED | HLSL_STORAGE_UNIFORM);
|
||||
if (invalid)
|
||||
{
|
||||
hlsl_message("Line %u: modifier '%s' invalid for local variables.\n",
|
||||
hlsl_ctx.line_no, debug_modifiers(invalid));
|
||||
set_parse_status(&hlsl_ctx.status, PARSE_ERR);
|
||||
}
|
||||
}
|
||||
ret = add_declaration(hlsl_ctx.cur_scope, decl, local);
|
||||
if (ret == FALSE)
|
||||
{
|
||||
|
@ -71,6 +92,26 @@ static BOOL declare_variable(struct hlsl_ir_var *decl, BOOL local)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
static DWORD add_modifier(DWORD modifiers, DWORD mod)
|
||||
{
|
||||
if (modifiers & mod)
|
||||
{
|
||||
hlsl_message("Line %u: modifier '%s' already specified.\n",
|
||||
hlsl_ctx.line_no, debug_modifiers(mod));
|
||||
set_parse_status(&hlsl_ctx.status, PARSE_ERR);
|
||||
return modifiers;
|
||||
}
|
||||
if (mod & (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR)
|
||||
&& modifiers & (HLSL_MODIFIER_ROW_MAJOR | HLSL_MODIFIER_COLUMN_MAJOR))
|
||||
{
|
||||
hlsl_message("Line %u: more than one matrix majority keyword.\n",
|
||||
hlsl_ctx.line_no);
|
||||
set_parse_status(&hlsl_ctx.status, PARSE_ERR);
|
||||
return modifiers;
|
||||
}
|
||||
return modifiers | mod;
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%error-verbose
|
||||
|
@ -298,6 +339,12 @@ declaration: var_modifiers type variables_def ';'
|
|||
FIXME("Variable with an initializer.\n");
|
||||
}
|
||||
|
||||
if (hlsl_ctx.cur_scope == hlsl_ctx.globals)
|
||||
{
|
||||
var->modifiers |= HLSL_STORAGE_UNIFORM;
|
||||
local = FALSE;
|
||||
}
|
||||
|
||||
ret = declare_variable(var, local);
|
||||
if (ret == FALSE)
|
||||
free_declaration(var);
|
||||
|
@ -338,6 +385,50 @@ var_modifiers: /* Empty */
|
|||
{
|
||||
$$ = 0;
|
||||
}
|
||||
| KW_EXTERN var_modifiers
|
||||
{
|
||||
$$ = add_modifier($2, HLSL_STORAGE_EXTERN);
|
||||
}
|
||||
| KW_NOINTERPOLATION var_modifiers
|
||||
{
|
||||
$$ = add_modifier($2, HLSL_STORAGE_NOINTERPOLATION);
|
||||
}
|
||||
| KW_PRECISE var_modifiers
|
||||
{
|
||||
$$ = add_modifier($2, HLSL_MODIFIER_PRECISE);
|
||||
}
|
||||
| KW_SHARED var_modifiers
|
||||
{
|
||||
$$ = add_modifier($2, HLSL_STORAGE_SHARED);
|
||||
}
|
||||
| KW_GROUPSHARED var_modifiers
|
||||
{
|
||||
$$ = add_modifier($2, HLSL_STORAGE_GROUPSHARED);
|
||||
}
|
||||
| KW_STATIC var_modifiers
|
||||
{
|
||||
$$ = add_modifier($2, HLSL_STORAGE_STATIC);
|
||||
}
|
||||
| KW_UNIFORM var_modifiers
|
||||
{
|
||||
$$ = add_modifier($2, HLSL_STORAGE_UNIFORM);
|
||||
}
|
||||
| KW_VOLATILE var_modifiers
|
||||
{
|
||||
$$ = add_modifier($2, HLSL_STORAGE_VOLATILE);
|
||||
}
|
||||
| KW_CONST var_modifiers
|
||||
{
|
||||
$$ = add_modifier($2, HLSL_MODIFIER_CONST);
|
||||
}
|
||||
| KW_ROW_MAJOR var_modifiers
|
||||
{
|
||||
$$ = add_modifier($2, HLSL_MODIFIER_ROW_MAJOR);
|
||||
}
|
||||
| KW_COLUMN_MAJOR var_modifiers
|
||||
{
|
||||
$$ = add_modifier($2, HLSL_MODIFIER_COLUMN_MAJOR);
|
||||
}
|
||||
|
||||
%%
|
||||
|
||||
|
|
|
@ -908,6 +908,43 @@ const char *debug_hlsl_type(const struct hlsl_type *type)
|
|||
return "unexpected_type";
|
||||
}
|
||||
|
||||
const char *debug_modifiers(DWORD modifiers)
|
||||
{
|
||||
char string[110];
|
||||
|
||||
string[0] = 0;
|
||||
if (modifiers & HLSL_STORAGE_EXTERN)
|
||||
strcat(string, " extern"); /* 7 */
|
||||
if (modifiers & HLSL_STORAGE_NOINTERPOLATION)
|
||||
strcat(string, " nointerpolation"); /* 16 */
|
||||
if (modifiers & HLSL_MODIFIER_PRECISE)
|
||||
strcat(string, " precise"); /* 8 */
|
||||
if (modifiers & HLSL_STORAGE_SHARED)
|
||||
strcat(string, " shared"); /* 7 */
|
||||
if (modifiers & HLSL_STORAGE_GROUPSHARED)
|
||||
strcat(string, " groupshared"); /* 12 */
|
||||
if (modifiers & HLSL_STORAGE_STATIC)
|
||||
strcat(string, " static"); /* 7 */
|
||||
if (modifiers & HLSL_STORAGE_UNIFORM)
|
||||
strcat(string, " uniform"); /* 8 */
|
||||
if (modifiers & HLSL_STORAGE_VOLATILE)
|
||||
strcat(string, " volatile"); /* 9 */
|
||||
if (modifiers & HLSL_MODIFIER_CONST)
|
||||
strcat(string, " const"); /* 6 */
|
||||
if (modifiers & HLSL_MODIFIER_ROW_MAJOR)
|
||||
strcat(string, " row_major"); /* 10 */
|
||||
if (modifiers & HLSL_MODIFIER_COLUMN_MAJOR)
|
||||
strcat(string, " column_major"); /* 13 */
|
||||
if ((modifiers & (HLSL_MODIFIER_IN | HLSL_MODIFIER_OUT)) == (HLSL_MODIFIER_IN | HLSL_MODIFIER_OUT))
|
||||
strcat(string, " inout"); /* 6 */
|
||||
else if (modifiers & HLSL_MODIFIER_IN)
|
||||
strcat(string, " in"); /* 3 */
|
||||
else if (modifiers & HLSL_MODIFIER_OUT)
|
||||
strcat(string, " out"); /* 4 */
|
||||
|
||||
return wine_dbg_sprintf("%s", string[0] ? string + 1 : "");
|
||||
}
|
||||
|
||||
const char *debug_node_type(enum hlsl_ir_node_type type)
|
||||
{
|
||||
const char *names[] =
|
||||
|
|
Loading…
Reference in New Issue