Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • wine/vkd3d
  • stefan/vkd3d
  • cmccarthy/vkd3d
  • giomasce/vkd3d
  • fcasas/vkd3d
  • jactry/vkd3d
  • ReDress/vkd3d
  • mstorsjo/vkd3d
  • huw/vkd3d
  • julliard/vkd3d
  • bshanks/vkd3d
  • zfigura/vkd3d
  • hverbeet/vkd3d
  • DarkShadow44/vkd3d
  • nsivov/vkd3d
  • dhary686/vkd3d
  • Mystral/vkd3d
  • maljaf/vkd3d
  • smcv/vkd3d
  • flibitijibibo/vkd3d
  • q4a/vkd3d
  • jsikorski/vkd3d
  • alesliehughes/vkd3d-alesliehughes
  • vitorhnn/vkd3d
  • agusev/vkd3d
  • etang-cw/vkd3d
  • petrathekat/vkd3d
  • simon.mr995/vkd3d
  • sgwaki/vkd3d
  • jacek/vkd3d
  • fweimer/vkd3d
  • Clara/vkd3d
  • disini/vkd3d
  • antenabr2/vkd3d
  • gilvbp/vkd3d
  • yshui/vkd3d
  • shaunren/vkd3d
  • jennetsaryyewa96/vkd3d
  • Jamesattay/vkd3d
  • zacemmneeto77/vkd3d
  • GermanAizek/vkd3d
  • opespinach/vkd3d
  • ruslanboyka201/vkd3d
  • navi/vkd3d
  • Feifan/vkd3d
  • yashmhmdly172/vkd3d
  • Sec32fun32/vkd3d
  • ritalat/vkd3d
  • ivyl/vkd3d
  • baikaishiuc/vkd3d
  • austin987/vkd3d
  • TornadoCookie/vkd3d
52 results
Show changes
Commits on Source (5)
...@@ -224,6 +224,7 @@ vkd3d_shader_tests = \ ...@@ -224,6 +224,7 @@ vkd3d_shader_tests = \
tests/hlsl/sampler-state.shader_test \ tests/hlsl/sampler-state.shader_test \
tests/hlsl/sampler.shader_test \ tests/hlsl/sampler.shader_test \
tests/hlsl/saturate.shader_test \ tests/hlsl/saturate.shader_test \
tests/hlsl/scope.shader_test \
tests/hlsl/shade-mode.shader_test \ tests/hlsl/shade-mode.shader_test \
tests/hlsl/shader-interstage-interface.shader_test \ tests/hlsl/shader-interstage-interface.shader_test \
tests/hlsl/shader-point-size.shader_test \ tests/hlsl/shader-point-size.shader_test \
......
...@@ -93,7 +93,7 @@ char *hlsl_sprintf_alloc(struct hlsl_ctx *ctx, const char *fmt, ...) ...@@ -93,7 +93,7 @@ char *hlsl_sprintf_alloc(struct hlsl_ctx *ctx, const char *fmt, ...)
return ret; return ret;
} }
bool hlsl_add_var(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, bool local_var) void hlsl_add_var(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl)
{ {
struct hlsl_scope *scope = ctx->cur_scope; struct hlsl_scope *scope = ctx->cur_scope;
struct hlsl_ir_var *var; struct hlsl_ir_var *var;
...@@ -103,21 +103,16 @@ bool hlsl_add_var(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, bool local_var ...@@ -103,21 +103,16 @@ bool hlsl_add_var(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, bool local_var
LIST_FOR_EACH_ENTRY(var, &scope->vars, struct hlsl_ir_var, scope_entry) LIST_FOR_EACH_ENTRY(var, &scope->vars, struct hlsl_ir_var, scope_entry)
{ {
if (var->name && !strcmp(decl->name, var->name)) if (var->name && !strcmp(decl->name, var->name))
return false;
}
if (local_var && scope->upper->upper == ctx->globals)
{
/* Check whether the variable redefines a function parameter. */
LIST_FOR_EACH_ENTRY(var, &scope->upper->vars, struct hlsl_ir_var, scope_entry)
{ {
if (var->name && !strcmp(decl->name, var->name)) hlsl_error(ctx, &decl->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
return false; "Identifier \"%s\" was already declared in this scope.", var->name);
hlsl_note(ctx, &var->loc, VKD3D_SHADER_LOG_ERROR, "\"%s\" was previously declared here.", var->name);
break;
} }
} }
} }
list_add_tail(&scope->vars, &decl->scope_entry); list_add_tail(&scope->vars, &decl->scope_entry);
return true;
} }
struct hlsl_ir_var *hlsl_get_var(struct hlsl_scope *scope, const char *name) struct hlsl_ir_var *hlsl_get_var(struct hlsl_scope *scope, const char *name)
......
...@@ -1496,7 +1496,7 @@ const char *hlsl_node_type_to_string(enum hlsl_ir_node_type type); ...@@ -1496,7 +1496,7 @@ const char *hlsl_node_type_to_string(enum hlsl_ir_node_type type);
struct hlsl_ir_node *hlsl_add_conditional(struct hlsl_ctx *ctx, struct hlsl_block *block, struct hlsl_ir_node *hlsl_add_conditional(struct hlsl_ctx *ctx, struct hlsl_block *block,
struct hlsl_ir_node *condition, struct hlsl_ir_node *if_true, struct hlsl_ir_node *if_false); struct hlsl_ir_node *condition, struct hlsl_ir_node *if_true, struct hlsl_ir_node *if_false);
void hlsl_add_function(struct hlsl_ctx *ctx, char *name, struct hlsl_ir_function_decl *decl); void hlsl_add_function(struct hlsl_ctx *ctx, char *name, struct hlsl_ir_function_decl *decl);
bool hlsl_add_var(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl, bool local_var); void hlsl_add_var(struct hlsl_ctx *ctx, struct hlsl_ir_var *decl);
void hlsl_block_cleanup(struct hlsl_block *block); void hlsl_block_cleanup(struct hlsl_block *block);
bool hlsl_clone_block(struct hlsl_ctx *ctx, struct hlsl_block *dst_block, const struct hlsl_block *src_block); bool hlsl_clone_block(struct hlsl_ctx *ctx, struct hlsl_block *dst_block, const struct hlsl_block *src_block);
......
...@@ -1311,11 +1311,7 @@ static bool add_func_parameter(struct hlsl_ctx *ctx, struct hlsl_func_parameters ...@@ -1311,11 +1311,7 @@ static bool add_func_parameter(struct hlsl_ctx *ctx, struct hlsl_func_parameters
free_parse_initializer(&param->initializer); free_parse_initializer(&param->initializer);
} }
if (!hlsl_add_var(ctx, var, false)) hlsl_add_var(ctx, var);
{
hlsl_free_var(var);
return false;
}
if (!hlsl_array_reserve(ctx, (void **)&parameters->vars, &parameters->capacity, if (!hlsl_array_reserve(ctx, (void **)&parameters->vars, &parameters->capacity,
parameters->count + 1, sizeof(*parameters->vars))) parameters->count + 1, sizeof(*parameters->vars)))
...@@ -1324,7 +1320,7 @@ static bool add_func_parameter(struct hlsl_ctx *ctx, struct hlsl_func_parameters ...@@ -1324,7 +1320,7 @@ static bool add_func_parameter(struct hlsl_ctx *ctx, struct hlsl_func_parameters
return true; return true;
} }
static bool add_pass(struct hlsl_ctx *ctx, const char *name, struct hlsl_scope *annotations, static void add_pass(struct hlsl_ctx *ctx, const char *name, struct hlsl_scope *annotations,
struct hlsl_state_block *state_block, const struct vkd3d_shader_location *loc) struct hlsl_state_block *state_block, const struct vkd3d_shader_location *loc)
{ {
struct hlsl_ir_var *var; struct hlsl_ir_var *var;
...@@ -1332,7 +1328,7 @@ static bool add_pass(struct hlsl_ctx *ctx, const char *name, struct hlsl_scope * ...@@ -1332,7 +1328,7 @@ static bool add_pass(struct hlsl_ctx *ctx, const char *name, struct hlsl_scope *
type = hlsl_get_type(ctx->globals, "pass", false, false); type = hlsl_get_type(ctx->globals, "pass", false, false);
if (!(var = hlsl_new_var(ctx, name, type, loc, NULL, 0, NULL))) if (!(var = hlsl_new_var(ctx, name, type, loc, NULL, 0, NULL)))
return false; return;
var->annotations = annotations; var->annotations = annotations;
var->state_blocks = hlsl_alloc(ctx, sizeof(*var->state_blocks)); var->state_blocks = hlsl_alloc(ctx, sizeof(*var->state_blocks));
...@@ -1340,21 +1336,10 @@ static bool add_pass(struct hlsl_ctx *ctx, const char *name, struct hlsl_scope * ...@@ -1340,21 +1336,10 @@ static bool add_pass(struct hlsl_ctx *ctx, const char *name, struct hlsl_scope *
var->state_block_count = 1; var->state_block_count = 1;
var->state_block_capacity = 1; var->state_block_capacity = 1;
if (!hlsl_add_var(ctx, var, false)) hlsl_add_var(ctx, var);
{
struct hlsl_ir_var *old = hlsl_get_var(ctx->cur_scope, var->name);
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
"Identifier \"%s\" was already declared in this scope.", var->name);
hlsl_note(ctx, &old->loc, VKD3D_SHADER_LOG_ERROR, "\"%s\" was previously declared here.", old->name);
hlsl_free_var(var);
return false;
}
return true;
} }
static bool add_technique(struct hlsl_ctx *ctx, const char *name, struct hlsl_scope *scope, static void add_technique(struct hlsl_ctx *ctx, const char *name, struct hlsl_scope *scope,
struct hlsl_scope *annotations, const char *typename, const struct vkd3d_shader_location *loc) struct hlsl_scope *annotations, const char *typename, const struct vkd3d_shader_location *loc)
{ {
struct hlsl_ir_var *var; struct hlsl_ir_var *var;
...@@ -1362,25 +1347,14 @@ static bool add_technique(struct hlsl_ctx *ctx, const char *name, struct hlsl_sc ...@@ -1362,25 +1347,14 @@ static bool add_technique(struct hlsl_ctx *ctx, const char *name, struct hlsl_sc
type = hlsl_get_type(ctx->globals, typename, false, false); type = hlsl_get_type(ctx->globals, typename, false, false);
if (!(var = hlsl_new_var(ctx, name, type, loc, NULL, 0, NULL))) if (!(var = hlsl_new_var(ctx, name, type, loc, NULL, 0, NULL)))
return false; return;
var->scope = scope; var->scope = scope;
var->annotations = annotations; var->annotations = annotations;
if (!hlsl_add_var(ctx, var, false)) hlsl_add_var(ctx, var);
{
struct hlsl_ir_var *old = hlsl_get_var(ctx->cur_scope, var->name);
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
"Identifier \"%s\" was already declared in this scope.", var->name);
hlsl_note(ctx, &old->loc, VKD3D_SHADER_LOG_ERROR, "\"%s\" was previously declared here.", old->name);
hlsl_free_var(var);
return false;
}
return true;
} }
static bool add_effect_group(struct hlsl_ctx *ctx, const char *name, struct hlsl_scope *scope, static void add_effect_group(struct hlsl_ctx *ctx, const char *name, struct hlsl_scope *scope,
struct hlsl_scope *annotations, const struct vkd3d_shader_location *loc) struct hlsl_scope *annotations, const struct vkd3d_shader_location *loc)
{ {
struct hlsl_ir_var *var; struct hlsl_ir_var *var;
...@@ -1388,22 +1362,11 @@ static bool add_effect_group(struct hlsl_ctx *ctx, const char *name, struct hlsl ...@@ -1388,22 +1362,11 @@ static bool add_effect_group(struct hlsl_ctx *ctx, const char *name, struct hlsl
type = hlsl_get_type(ctx->globals, "fxgroup", false, false); type = hlsl_get_type(ctx->globals, "fxgroup", false, false);
if (!(var = hlsl_new_var(ctx, name, type, loc, NULL, 0, NULL))) if (!(var = hlsl_new_var(ctx, name, type, loc, NULL, 0, NULL)))
return false; return;
var->scope = scope; var->scope = scope;
var->annotations = annotations; var->annotations = annotations;
if (!hlsl_add_var(ctx, var, false)) hlsl_add_var(ctx, var);
{
struct hlsl_ir_var *old = hlsl_get_var(ctx->cur_scope, var->name);
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
"Identifier \"%s\" was already declared in this scope.", var->name);
hlsl_note(ctx, &old->loc, VKD3D_SHADER_LOG_ERROR, "\"%s\" was previously declared here.", old->name);
hlsl_free_var(var);
return false;
}
return true;
} }
static bool parse_reservation_index(struct hlsl_ctx *ctx, const char *string, unsigned int bracket_offset, static bool parse_reservation_index(struct hlsl_ctx *ctx, const char *string, unsigned int bracket_offset,
...@@ -2590,7 +2553,6 @@ static void declare_var(struct hlsl_ctx *ctx, struct parse_variable_def *v) ...@@ -2590,7 +2553,6 @@ static void declare_var(struct hlsl_ctx *ctx, struct parse_variable_def *v)
bool constant_buffer = false; bool constant_buffer = false;
struct hlsl_ir_var *var; struct hlsl_ir_var *var;
struct hlsl_type *type; struct hlsl_type *type;
bool local = true;
char *var_name; char *var_name;
unsigned int i; unsigned int i;
...@@ -2726,8 +2688,6 @@ static void declare_var(struct hlsl_ctx *ctx, struct parse_variable_def *v) ...@@ -2726,8 +2688,6 @@ static void declare_var(struct hlsl_ctx *ctx, struct parse_variable_def *v)
if (ctx->cur_scope == ctx->globals) if (ctx->cur_scope == ctx->globals)
{ {
local = false;
if ((modifiers & HLSL_STORAGE_UNIFORM) && (modifiers & HLSL_STORAGE_STATIC)) if ((modifiers & HLSL_STORAGE_UNIFORM) && (modifiers & HLSL_STORAGE_STATIC))
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER, hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_INVALID_MODIFIER,
"Variable '%s' is declared as both \"uniform\" and \"static\".", var->name); "Variable '%s' is declared as both \"uniform\" and \"static\".", var->name);
...@@ -2790,16 +2750,7 @@ static void declare_var(struct hlsl_ctx *ctx, struct parse_variable_def *v) ...@@ -2790,16 +2750,7 @@ static void declare_var(struct hlsl_ctx *ctx, struct parse_variable_def *v)
"Static variables cannot have both numeric and resource components."); "Static variables cannot have both numeric and resource components.");
} }
if (!hlsl_add_var(ctx, var, local)) hlsl_add_var(ctx, var);
{
struct hlsl_ir_var *old = hlsl_get_var(ctx->cur_scope, var->name);
hlsl_error(ctx, &var->loc, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
"Variable \"%s\" was already declared in this scope.", var->name);
hlsl_note(ctx, &old->loc, VKD3D_SHADER_LOG_ERROR, "\"%s\" was previously declared here.", old->name);
hlsl_free_var(var);
return;
}
} }
static struct hlsl_block *initialize_vars(struct hlsl_ctx *ctx, struct list *var_list) static struct hlsl_block *initialize_vars(struct hlsl_ctx *ctx, struct list *var_list)
...@@ -5748,6 +5699,16 @@ static struct hlsl_block *add_shader_compilation(struct hlsl_ctx *ctx, const cha ...@@ -5748,6 +5699,16 @@ static struct hlsl_block *add_shader_compilation(struct hlsl_ctx *ctx, const cha
return NULL; return NULL;
} }
for (unsigned int i = 0; i < args->args_count; ++i)
{
if (args->args[i]->data_type->class == HLSL_CLASS_ERROR)
{
args->instrs->value = ctx->error_instr;
free(args->args);
return args->instrs;
}
}
if (!(call_to_compile = add_user_call(ctx, decl, args, true, loc))) if (!(call_to_compile = add_user_call(ctx, decl, args, true, loc)))
{ {
free_parse_initializer(args); free_parse_initializer(args);
...@@ -7295,8 +7256,7 @@ name_opt: ...@@ -7295,8 +7256,7 @@ name_opt:
pass: pass:
KW_PASS name_opt annotations_opt '{' state_block_start state_block '}' KW_PASS name_opt annotations_opt '{' state_block_start state_block '}'
{ {
if (!add_pass(ctx, $2, $3, $6, &@1)) add_pass(ctx, $2, $3, $6, &@1);
YYABORT;
} }
annotations_list: annotations_list:
...@@ -7347,8 +7307,7 @@ technique9: ...@@ -7347,8 +7307,7 @@ technique9:
struct hlsl_scope *scope = ctx->cur_scope; struct hlsl_scope *scope = ctx->cur_scope;
hlsl_pop_scope(ctx); hlsl_pop_scope(ctx);
if (!add_technique(ctx, $2, scope, $3, "technique", &@1)) add_technique(ctx, $2, scope, $3, "technique", &@1);
YYABORT;
} }
technique10: technique10:
...@@ -7357,8 +7316,7 @@ technique10: ...@@ -7357,8 +7316,7 @@ technique10:
struct hlsl_scope *scope = ctx->cur_scope; struct hlsl_scope *scope = ctx->cur_scope;
hlsl_pop_scope(ctx); hlsl_pop_scope(ctx);
if (!add_technique(ctx, $2, scope, $3, "technique10", &@1)) add_technique(ctx, $2, scope, $3, "technique10", &@1);
YYABORT;
} }
technique11: technique11:
...@@ -7371,8 +7329,7 @@ technique11: ...@@ -7371,8 +7329,7 @@ technique11:
hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX, hlsl_error(ctx, &@1, VKD3D_SHADER_ERROR_HLSL_INVALID_SYNTAX,
"The 'technique11' keyword is invalid for this profile."); "The 'technique11' keyword is invalid for this profile.");
if (!add_technique(ctx, $2, scope, $3, "technique11", &@1)) add_technique(ctx, $2, scope, $3, "technique11", &@1);
YYABORT;
} }
global_technique: global_technique:
...@@ -7393,8 +7350,7 @@ effect_group: ...@@ -7393,8 +7350,7 @@ effect_group:
{ {
struct hlsl_scope *scope = ctx->cur_scope; struct hlsl_scope *scope = ctx->cur_scope;
hlsl_pop_scope(ctx); hlsl_pop_scope(ctx);
if (!(add_effect_group(ctx, $2, scope, $3, &@2))) add_effect_group(ctx, $2, scope, $3, &@2);
YYABORT;
} }
buffer_declaration: buffer_declaration:
...@@ -7863,10 +7819,9 @@ compound_statement: ...@@ -7863,10 +7819,9 @@ compound_statement:
if (!($$ = make_empty_block(ctx))) if (!($$ = make_empty_block(ctx)))
YYABORT; YYABORT;
} }
| '{' scope_start statement_list '}' | '{' statement_list '}'
{ {
hlsl_pop_scope(ctx); $$ = $2;
$$ = $3;
} }
scope_start: scope_start:
...@@ -8112,11 +8067,7 @@ param_list: ...@@ -8112,11 +8067,7 @@ param_list:
{ {
$$ = $1; $$ = $1;
if (!add_func_parameter(ctx, &$$, &$3, &@3)) if (!add_func_parameter(ctx, &$$, &$3, &@3))
{
hlsl_error(ctx, &@3, VKD3D_SHADER_ERROR_HLSL_REDEFINED,
"Parameter \"%s\" is already declared.", $3.name);
YYABORT; YYABORT;
}
} }
parameter: parameter:
...@@ -9126,7 +9077,11 @@ statement_list: ...@@ -9126,7 +9077,11 @@ statement_list:
statement: statement:
declaration_statement declaration_statement
| expr_statement | expr_statement
| compound_statement | scope_start compound_statement
{
hlsl_pop_scope(ctx);
$$ = $2;
}
| jump_statement | jump_statement
| selection_statement | selection_statement
| loop_statement | loop_statement
......
[pixel shader fail]
float4 main() : sv_target
{
float4 x, x;
return 0;
}
[pixel shader fail]
float4 main() : sv_target
{
float4 x;
float4 x;
return 0;
}
[pixel shader fail]
float4 x;
float4 x;
float4 main() : sv_target
{
return 0;
}
[pixel shader]
float4 x;
float4 main() : sv_target
{
float4 x;
return 0;
}
[pixel shader]
float4 x;
float4 main(float4 x : TEXCOORD) : sv_target
{
return x;
}
[pixel shader fail]
float4 main(float4 x : TEXCOORD) : sv_target
{
float4 x;
return 0;
}
[pixel shader fail]
float4 main(float4 x : TEXCOORD, float4 x : TEXCOORD) : sv_target
{
return 0;
}
[pixel shader]
float4 main() : sv_target
{
float4 x = 1;
{
return x;
}
}
[pixel shader]
float4 main(float4 x : TEXCOORD) : sv_target
{
{
float4 x = 1;
return x;
}
}
[pixel shader fail]
float4 main() : sv_target
{
{
float4 x = 1;
}
return x;
}
[pixel shader]
float4 main() : sv_target
{
float4 x = 1;
if (1)
{
return x;
}
}
[pixel shader]
float4 main(float4 x : TEXCOORD) : sv_target
{
if (1)
{
float4 x = 1;
return x;
}
}
[pixel shader fail]
float4 main() : sv_target
{
if (1)
{
float4 x = 1;
}
return x;
}
[pixel shader fail]
{
float4 x = 1;
}
float4 main() : sv_target
{
return 0;
}
[pixel shader fail]
float4 main() : sv_target
{
return x;
float4 x = 1;
}
[pixel shader fail]
float4 main() : sv_target
{
return x;
}
float4 x;