vkd3d-shader/hlsl: Allow annotations on constant buffers.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
Nikolay Sivov 2024-03-28 02:22:15 +01:00 committed by Alexandre Julliard
parent 64418dd290
commit c509c85f63
Notes: Alexandre Julliard 2024-04-03 00:23:27 +02: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/742
5 changed files with 31 additions and 7 deletions

View File

@ -1038,7 +1038,8 @@ static void write_fx_4_buffer(struct hlsl_buffer *b, struct fx_write_context *fx
put_u32(buffer, bind_point); /* Bind point */
put_u32(buffer, 0); /* Annotations count */
/* FIXME: write annotations */
if (b->annotations)
hlsl_fixme(ctx, &b->loc, "Writing annotations for buffers is not implemented.");
count = 0;
size = 0;

View File

@ -2031,7 +2031,8 @@ struct hlsl_ir_function_decl *hlsl_new_func_decl(struct hlsl_ctx *ctx,
}
struct hlsl_buffer *hlsl_new_buffer(struct hlsl_ctx *ctx, enum hlsl_buffer_type type, const char *name,
uint32_t modifiers, const struct hlsl_reg_reservation *reservation, const struct vkd3d_shader_location *loc)
uint32_t modifiers, const struct hlsl_reg_reservation *reservation, struct hlsl_scope *annotations,
const struct vkd3d_shader_location *loc)
{
struct hlsl_buffer *buffer;
@ -2042,6 +2043,7 @@ struct hlsl_buffer *hlsl_new_buffer(struct hlsl_ctx *ctx, enum hlsl_buffer_type
buffer->modifiers = modifiers;
if (reservation)
buffer->reservation = *reservation;
buffer->annotations = annotations;
buffer->loc = *loc;
list_add_tail(&ctx->buffers, &buffer->entry);
return buffer;
@ -3586,10 +3588,10 @@ static bool hlsl_ctx_init(struct hlsl_ctx *ctx, const struct vkd3d_shader_compil
list_init(&ctx->buffers);
if (!(ctx->globals_buffer = hlsl_new_buffer(ctx, HLSL_BUFFER_CONSTANT,
hlsl_strdup(ctx, "$Globals"), 0, NULL, &ctx->location)))
hlsl_strdup(ctx, "$Globals"), 0, NULL, NULL, &ctx->location)))
return false;
if (!(ctx->params_buffer = hlsl_new_buffer(ctx, HLSL_BUFFER_CONSTANT,
hlsl_strdup(ctx, "$Params"), 0, NULL, &ctx->location)))
hlsl_strdup(ctx, "$Params"), 0, NULL, NULL, &ctx->location)))
return false;
ctx->cur_buffer = ctx->globals_buffer;

View File

@ -806,6 +806,8 @@ struct hlsl_buffer
* If provided, it should be of type 'b' if type is HLSL_BUFFER_CONSTANT and 't' if type is
* HLSL_BUFFER_TEXTURE. */
struct hlsl_reg_reservation reservation;
/* Scope that contains annotations for this buffer. */
struct hlsl_scope *annotations;
/* Item entry for hlsl_ctx.buffers */
struct list entry;
@ -1228,7 +1230,8 @@ struct hlsl_ir_node *hlsl_new_binary_expr(struct hlsl_ctx *ctx, enum hlsl_ir_exp
struct hlsl_ir_node *arg2);
struct hlsl_ir_node *hlsl_new_bool_constant(struct hlsl_ctx *ctx, bool b, const struct vkd3d_shader_location *loc);
struct hlsl_buffer *hlsl_new_buffer(struct hlsl_ctx *ctx, enum hlsl_buffer_type type, const char *name,
uint32_t modifiers, const struct hlsl_reg_reservation *reservation, const struct vkd3d_shader_location *loc);
uint32_t modifiers, const struct hlsl_reg_reservation *reservation, struct hlsl_scope *annotations,
const struct vkd3d_shader_location *loc);
struct hlsl_ir_node *hlsl_new_call(struct hlsl_ctx *ctx, struct hlsl_ir_function_decl *decl,
const struct vkd3d_shader_location *loc);
struct hlsl_ir_node *hlsl_new_cast(struct hlsl_ctx *ctx, struct hlsl_ir_node *node, struct hlsl_type *type,

View File

@ -5665,12 +5665,12 @@ effect_group:
}
buffer_declaration:
var_modifiers buffer_type any_identifier colon_attribute
var_modifiers buffer_type any_identifier colon_attribute annotations_opt
{
if ($4.semantic.name)
hlsl_error(ctx, &@4, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC, "Semantics are not allowed on buffers.");
if (!(ctx->cur_buffer = hlsl_new_buffer(ctx, $2, $3, $1, &$4.reg_reservation, &@3)))
if (!(ctx->cur_buffer = hlsl_new_buffer(ctx, $2, $3, $1, &$4.reg_reservation, $5, &@3)))
YYABORT;
}

View File

@ -16,6 +16,24 @@ uniform 0 float4 1.0 2.0 3.0 4.0
todo(glsl) draw quad
probe all rgba (1.0, 2.0, 3.0, 4.0)
[pixel shader fail(sm>=6)]
// Annotations
cbuffer cb : register(b1) < int i = 1; >
{
float4 m1;
};
cbuffer cb < int i = 2; >
{
float4 m2;
};
float4 main() : sv_target
{
return m1 + m2;
}
[pixel shader]
// Test empty constant buffer.
cbuffer Constants : register(b1)