vkd3d-shader/hlsl: Handle effect group statement.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
Nikolay Sivov 2023-11-05 19:27:00 +01:00 committed by Alexandre Julliard
parent f7a02a5da2
commit e527d7c1e7
Notes: Alexandre Julliard 2024-01-11 23:13:27 +01:00
Approved-by: Giovanni Mascellani (@giomasce)
Approved-by: Zebediah Figura (@zfigura)
Approved-by: Henri Verbeet (@hverbeet)
Approved-by: Alexandre Julliard (@julliard)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/443
6 changed files with 53 additions and 6 deletions

View File

@ -3366,6 +3366,7 @@ static void declare_predefined_types(struct hlsl_ctx *ctx)
{"float", HLSL_CLASS_SCALAR, HLSL_TYPE_FLOAT, 1, 1},
{"vector", HLSL_CLASS_VECTOR, HLSL_TYPE_FLOAT, 4, 1},
{"matrix", HLSL_CLASS_MATRIX, HLSL_TYPE_FLOAT, 4, 4},
{"fxgroup", HLSL_CLASS_OBJECT, HLSL_TYPE_EFFECT_GROUP, 1, 1},
{"STRING", HLSL_CLASS_OBJECT, HLSL_TYPE_STRING, 1, 1},
{"TEXTURE", HLSL_CLASS_OBJECT, HLSL_TYPE_TEXTURE, 1, 1},
{"PIXELSHADER", HLSL_CLASS_OBJECT, HLSL_TYPE_PIXELSHADER, 1, 1},

View File

@ -96,6 +96,7 @@ enum hlsl_base_type
HLSL_TYPE_PIXELSHADER,
HLSL_TYPE_VERTEXSHADER,
HLSL_TYPE_TECHNIQUE,
HLSL_TYPE_EFFECT_GROUP,
HLSL_TYPE_STRING,
HLSL_TYPE_VOID,
};
@ -405,6 +406,8 @@ struct hlsl_ir_var
struct list scope_entry;
/* Item entry in hlsl_ctx.extern_vars, if the variable is extern. */
struct list extern_entry;
/* Scope that variable itself defines, used to provide a container for techniques and passes. */
struct hlsl_scope *scope;
/* Indexes of the IR instructions where the variable is first written and last read (liveness
* range). The IR instructions are numerated starting from 2, because 0 means unused, and 1

View File

@ -1120,6 +1120,31 @@ static bool add_technique(struct hlsl_ctx *ctx, const char *name, const char *ty
return true;
}
static bool add_effect_group(struct hlsl_ctx *ctx, const char *name, struct hlsl_scope *scope,
const struct vkd3d_shader_location *loc)
{
struct hlsl_ir_var *var;
struct hlsl_type *type;
type = hlsl_get_type(ctx->globals, "fxgroup", false, false);
if (!(var = hlsl_new_var(ctx, name, type, loc, NULL, 0, NULL)))
return false;
var->scope = scope;
if (!hlsl_add_var(ctx, var, false))
{
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 struct hlsl_reg_reservation parse_reg_reservation(const char *reg_string)
{
struct hlsl_reg_reservation reservation = {0};
@ -5120,6 +5145,7 @@ hlsl_prog:
}
| hlsl_prog preproc_directive
| hlsl_prog global_technique
| hlsl_prog effect_group
| hlsl_prog ';'
technique_name:
@ -5166,6 +5192,23 @@ global_technique:
| technique10
| technique11
group_technique:
technique10
| technique11
group_techniques:
group_technique
| group_techniques group_technique
effect_group:
KW_FXGROUP any_identifier '{' scope_start group_techniques '}'
{
struct hlsl_scope *scope = ctx->cur_scope;
hlsl_pop_scope(ctx);
if (!(add_effect_group(ctx, $2, scope, &@2)))
YYABORT;
}
buffer_declaration:
buffer_type any_identifier colon_attribute
{

View File

@ -124,7 +124,7 @@ fxgroup group
}
% Regular shaders with technique blocks
[vertex shader todo]
[vertex shader]
float4 main() : sv_position
{
return 0;
@ -147,7 +147,7 @@ fxgroup group
technique10 {}
}
[pixel shader todo]
[pixel shader]
float4 main() : sv_target
{
return 0;

View File

@ -97,7 +97,7 @@ float4 technIque10;
float4 technIque11;
% Regular shaders with technique blocks
[vertex shader todo]
[vertex shader]
float4 main() : sv_position
{
return 0;
@ -120,7 +120,7 @@ fxgroup group
technique10 {}
}
[pixel shader todo]
[pixel shader]
float4 main() : sv_target
{
return 0;

View File

@ -97,7 +97,7 @@ float4 technIque10;
float4 technIque11;
% Regular shaders with technique blocks
[vertex shader todo]
[vertex shader]
float4 main() : sv_position
{
return 0;
@ -120,7 +120,7 @@ fxgroup group
technique10 {}
}
[pixel shader todo]
[pixel shader]
float4 main() : sv_target
{
return 0;