mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader: Keep track of the buffer in which a variable was defined.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
4695690ac8
commit
dbfe63d6a1
@ -1599,8 +1599,14 @@ static bool hlsl_ctx_init(struct hlsl_ctx *ctx, const struct hlsl_profile_info *
|
||||
|
||||
list_init(&ctx->static_initializers);
|
||||
list_init(&ctx->extern_vars);
|
||||
|
||||
list_init(&ctx->buffers);
|
||||
|
||||
if (!(ctx->globals_buffer = hlsl_new_buffer(ctx, HLSL_BUFFER_CONSTANT,
|
||||
hlsl_strdup(ctx, "$Globals"), NULL, ctx->location)))
|
||||
return false;
|
||||
ctx->cur_buffer = ctx->globals_buffer;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -222,6 +222,7 @@ struct hlsl_ir_var
|
||||
struct vkd3d_shader_location loc;
|
||||
const char *name;
|
||||
struct hlsl_semantic semantic;
|
||||
struct hlsl_buffer *buffer;
|
||||
unsigned int modifiers;
|
||||
struct hlsl_reg_reservation reg_reservation;
|
||||
struct list scope_entry, param_entry, extern_entry;
|
||||
@ -451,6 +452,7 @@ struct hlsl_ctx
|
||||
struct list extern_vars;
|
||||
|
||||
struct list buffers;
|
||||
struct hlsl_buffer *cur_buffer, *globals_buffer;
|
||||
struct list types;
|
||||
struct rb_tree functions;
|
||||
const struct hlsl_ir_function_decl *cur_function;
|
||||
|
@ -1393,6 +1393,8 @@ static struct list *declare_vars(struct hlsl_ctx *ctx, struct hlsl_type *basic_t
|
||||
continue;
|
||||
}
|
||||
|
||||
var->buffer = ctx->cur_buffer;
|
||||
|
||||
if (ctx->cur_scope == ctx->globals)
|
||||
{
|
||||
local = false;
|
||||
@ -1779,7 +1781,7 @@ hlsl_prog:
|
||||
|
||||
hlsl_add_function(ctx, $2.name, $2.decl, false);
|
||||
}
|
||||
| hlsl_prog buffer_declaration
|
||||
| hlsl_prog buffer_declaration buffer_body
|
||||
| hlsl_prog declaration_statement
|
||||
{
|
||||
if (!list_empty($2))
|
||||
@ -1790,17 +1792,21 @@ hlsl_prog:
|
||||
| hlsl_prog ';'
|
||||
|
||||
buffer_declaration:
|
||||
buffer_type any_identifier colon_attribute '{' declaration_statement_list '}'
|
||||
buffer_type any_identifier colon_attribute
|
||||
{
|
||||
struct hlsl_buffer *buffer;
|
||||
|
||||
if ($3.semantic.name)
|
||||
hlsl_error(ctx, @3, VKD3D_SHADER_ERROR_HLSL_INVALID_SEMANTIC, "Semantics are not allowed on buffers.");
|
||||
|
||||
if (!(buffer = hlsl_new_buffer(ctx, $1, $2, &$3.reg_reservation, @2)))
|
||||
if (!(ctx->cur_buffer = hlsl_new_buffer(ctx, $1, $2, &$3.reg_reservation, @2)))
|
||||
YYABORT;
|
||||
}
|
||||
|
||||
buffer_body:
|
||||
'{' declaration_statement_list '}'
|
||||
{
|
||||
ctx->cur_buffer = ctx->globals_buffer;
|
||||
}
|
||||
|
||||
buffer_type:
|
||||
KW_CBUFFER
|
||||
{
|
||||
|
@ -41,6 +41,7 @@ static void prepend_uniform_copy(struct hlsl_ctx *ctx, struct list *instrs, stru
|
||||
list_add_tail(&ctx->extern_vars, &uniform->extern_entry);
|
||||
uniform->is_uniform = 1;
|
||||
uniform->is_param = temp->is_param;
|
||||
uniform->buffer = temp->buffer;
|
||||
|
||||
if (!(name = hlsl_get_string_buffer(ctx)))
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user