mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Handle NULL constants.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
This commit is contained in:
parent
d945d5e78c
commit
b4d957f848
Notes:
Henri Verbeet
2024-08-13 21:26:02 +02:00
Approved-by: Elizabeth Figura (@zfigura) Approved-by: Henri Verbeet (@hverbeet) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/980
@ -1524,6 +1524,7 @@ D3DXPARAMETER_CLASS hlsl_sm1_class(const struct hlsl_type *type)
|
|||||||
case HLSL_CLASS_HULL_SHADER:
|
case HLSL_CLASS_HULL_SHADER:
|
||||||
case HLSL_CLASS_GEOMETRY_SHADER:
|
case HLSL_CLASS_GEOMETRY_SHADER:
|
||||||
case HLSL_CLASS_BLEND_STATE:
|
case HLSL_CLASS_BLEND_STATE:
|
||||||
|
case HLSL_CLASS_NULL:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1628,6 +1629,7 @@ D3DXPARAMETER_TYPE hlsl_sm1_base_type(const struct hlsl_type *type)
|
|||||||
case HLSL_CLASS_HULL_SHADER:
|
case HLSL_CLASS_HULL_SHADER:
|
||||||
case HLSL_CLASS_GEOMETRY_SHADER:
|
case HLSL_CLASS_GEOMETRY_SHADER:
|
||||||
case HLSL_CLASS_BLEND_STATE:
|
case HLSL_CLASS_BLEND_STATE:
|
||||||
|
case HLSL_CLASS_NULL:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -650,6 +650,7 @@ static uint32_t write_fx_4_type(const struct hlsl_type *type, struct fx_write_co
|
|||||||
case HLSL_CLASS_PASS:
|
case HLSL_CLASS_PASS:
|
||||||
case HLSL_CLASS_TECHNIQUE:
|
case HLSL_CLASS_TECHNIQUE:
|
||||||
case HLSL_CLASS_CONSTANT_BUFFER:
|
case HLSL_CLASS_CONSTANT_BUFFER:
|
||||||
|
case HLSL_CLASS_NULL:
|
||||||
vkd3d_unreachable();
|
vkd3d_unreachable();
|
||||||
|
|
||||||
case HLSL_CLASS_STRING:
|
case HLSL_CLASS_STRING:
|
||||||
@ -1091,6 +1092,7 @@ static bool is_type_supported_fx_2(struct hlsl_ctx *ctx, const struct hlsl_type
|
|||||||
case HLSL_CLASS_PASS:
|
case HLSL_CLASS_PASS:
|
||||||
case HLSL_CLASS_TECHNIQUE:
|
case HLSL_CLASS_TECHNIQUE:
|
||||||
case HLSL_CLASS_CONSTANT_BUFFER:
|
case HLSL_CLASS_CONSTANT_BUFFER:
|
||||||
|
case HLSL_CLASS_NULL:
|
||||||
/* This cannot appear as an extern variable. */
|
/* This cannot appear as an extern variable. */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -386,6 +386,7 @@ static void hlsl_type_calculate_reg_size(struct hlsl_ctx *ctx, struct hlsl_type
|
|||||||
case HLSL_CLASS_HULL_SHADER:
|
case HLSL_CLASS_HULL_SHADER:
|
||||||
case HLSL_CLASS_GEOMETRY_SHADER:
|
case HLSL_CLASS_GEOMETRY_SHADER:
|
||||||
case HLSL_CLASS_BLEND_STATE:
|
case HLSL_CLASS_BLEND_STATE:
|
||||||
|
case HLSL_CLASS_NULL:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -461,6 +462,7 @@ static bool type_is_single_component(const struct hlsl_type *type)
|
|||||||
case HLSL_CLASS_HULL_SHADER:
|
case HLSL_CLASS_HULL_SHADER:
|
||||||
case HLSL_CLASS_GEOMETRY_SHADER:
|
case HLSL_CLASS_GEOMETRY_SHADER:
|
||||||
case HLSL_CLASS_BLEND_STATE:
|
case HLSL_CLASS_BLEND_STATE:
|
||||||
|
case HLSL_CLASS_NULL:
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
case HLSL_CLASS_VECTOR:
|
case HLSL_CLASS_VECTOR:
|
||||||
@ -627,6 +629,7 @@ unsigned int hlsl_type_get_component_offset(struct hlsl_ctx *ctx, struct hlsl_ty
|
|||||||
case HLSL_CLASS_VOID:
|
case HLSL_CLASS_VOID:
|
||||||
case HLSL_CLASS_SCALAR:
|
case HLSL_CLASS_SCALAR:
|
||||||
case HLSL_CLASS_CONSTANT_BUFFER:
|
case HLSL_CLASS_CONSTANT_BUFFER:
|
||||||
|
case HLSL_CLASS_NULL:
|
||||||
vkd3d_unreachable();
|
vkd3d_unreachable();
|
||||||
}
|
}
|
||||||
type = next_type;
|
type = next_type;
|
||||||
@ -1023,6 +1026,7 @@ unsigned int hlsl_type_component_count(const struct hlsl_type *type)
|
|||||||
case HLSL_CLASS_HULL_SHADER:
|
case HLSL_CLASS_HULL_SHADER:
|
||||||
case HLSL_CLASS_GEOMETRY_SHADER:
|
case HLSL_CLASS_GEOMETRY_SHADER:
|
||||||
case HLSL_CLASS_BLEND_STATE:
|
case HLSL_CLASS_BLEND_STATE:
|
||||||
|
case HLSL_CLASS_NULL:
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
case HLSL_CLASS_EFFECT_GROUP:
|
case HLSL_CLASS_EFFECT_GROUP:
|
||||||
@ -1115,6 +1119,7 @@ bool hlsl_types_are_equal(const struct hlsl_type *t1, const struct hlsl_type *t2
|
|||||||
case HLSL_CLASS_HULL_SHADER:
|
case HLSL_CLASS_HULL_SHADER:
|
||||||
case HLSL_CLASS_GEOMETRY_SHADER:
|
case HLSL_CLASS_GEOMETRY_SHADER:
|
||||||
case HLSL_CLASS_BLEND_STATE:
|
case HLSL_CLASS_BLEND_STATE:
|
||||||
|
case HLSL_CLASS_NULL:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1464,7 +1469,7 @@ struct hlsl_ir_node *hlsl_new_constant(struct hlsl_ctx *ctx, struct hlsl_type *t
|
|||||||
{
|
{
|
||||||
struct hlsl_ir_constant *c;
|
struct hlsl_ir_constant *c;
|
||||||
|
|
||||||
VKD3D_ASSERT(type->class <= HLSL_CLASS_VECTOR);
|
VKD3D_ASSERT(type->class <= HLSL_CLASS_VECTOR || type->class == HLSL_CLASS_NULL);
|
||||||
|
|
||||||
if (!(c = hlsl_alloc(ctx, sizeof(*c))))
|
if (!(c = hlsl_alloc(ctx, sizeof(*c))))
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1527,6 +1532,12 @@ struct hlsl_ir_node *hlsl_new_string_constant(struct hlsl_ctx *ctx, const char *
|
|||||||
return &s->node;
|
return &s->node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct hlsl_ir_node *hlsl_new_null_constant(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc)
|
||||||
|
{
|
||||||
|
struct hlsl_constant_value value = { 0 };
|
||||||
|
return hlsl_new_constant(ctx, ctx->builtin_types.null, &value, loc);
|
||||||
|
}
|
||||||
|
|
||||||
struct hlsl_ir_node *hlsl_new_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op,
|
struct hlsl_ir_node *hlsl_new_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op,
|
||||||
struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS],
|
struct hlsl_ir_node *operands[HLSL_MAX_OPERANDS],
|
||||||
struct hlsl_type *data_type, const struct vkd3d_shader_location *loc)
|
struct hlsl_type *data_type, const struct vkd3d_shader_location *loc)
|
||||||
@ -2568,6 +2579,7 @@ struct vkd3d_string_buffer *hlsl_type_to_string(struct hlsl_ctx *ctx, const stru
|
|||||||
case HLSL_CLASS_HULL_SHADER:
|
case HLSL_CLASS_HULL_SHADER:
|
||||||
case HLSL_CLASS_GEOMETRY_SHADER:
|
case HLSL_CLASS_GEOMETRY_SHADER:
|
||||||
case HLSL_CLASS_BLEND_STATE:
|
case HLSL_CLASS_BLEND_STATE:
|
||||||
|
case HLSL_CLASS_NULL:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3930,6 +3942,7 @@ static void declare_predefined_types(struct hlsl_ctx *ctx)
|
|||||||
|
|
||||||
ctx->builtin_types.string = hlsl_new_simple_type(ctx, "STRING", HLSL_CLASS_STRING);
|
ctx->builtin_types.string = hlsl_new_simple_type(ctx, "STRING", HLSL_CLASS_STRING);
|
||||||
ctx->builtin_types.Void = hlsl_new_simple_type(ctx, "void", HLSL_CLASS_VOID);
|
ctx->builtin_types.Void = hlsl_new_simple_type(ctx, "void", HLSL_CLASS_VOID);
|
||||||
|
ctx->builtin_types.null = hlsl_new_simple_type(ctx, "NULL", HLSL_CLASS_NULL);
|
||||||
hlsl_scope_add_type(ctx->globals, hlsl_new_simple_type(ctx, "DepthStencilView", HLSL_CLASS_DEPTH_STENCIL_VIEW));
|
hlsl_scope_add_type(ctx->globals, hlsl_new_simple_type(ctx, "DepthStencilView", HLSL_CLASS_DEPTH_STENCIL_VIEW));
|
||||||
hlsl_scope_add_type(ctx->globals, hlsl_new_simple_type(ctx, "DepthStencilState", HLSL_CLASS_DEPTH_STENCIL_STATE));
|
hlsl_scope_add_type(ctx->globals, hlsl_new_simple_type(ctx, "DepthStencilState", HLSL_CLASS_DEPTH_STENCIL_STATE));
|
||||||
hlsl_scope_add_type(ctx->globals, hlsl_new_simple_type(ctx, "fxgroup", HLSL_CLASS_EFFECT_GROUP));
|
hlsl_scope_add_type(ctx->globals, hlsl_new_simple_type(ctx, "fxgroup", HLSL_CLASS_EFFECT_GROUP));
|
||||||
|
@ -98,6 +98,7 @@ enum hlsl_type_class
|
|||||||
HLSL_CLASS_CONSTANT_BUFFER,
|
HLSL_CLASS_CONSTANT_BUFFER,
|
||||||
HLSL_CLASS_BLEND_STATE,
|
HLSL_CLASS_BLEND_STATE,
|
||||||
HLSL_CLASS_VOID,
|
HLSL_CLASS_VOID,
|
||||||
|
HLSL_CLASS_NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum hlsl_base_type
|
enum hlsl_base_type
|
||||||
@ -999,6 +1000,7 @@ struct hlsl_ctx
|
|||||||
struct hlsl_type *sampler[HLSL_SAMPLER_DIM_LAST_SAMPLER + 1];
|
struct hlsl_type *sampler[HLSL_SAMPLER_DIM_LAST_SAMPLER + 1];
|
||||||
struct hlsl_type *string;
|
struct hlsl_type *string;
|
||||||
struct hlsl_type *Void;
|
struct hlsl_type *Void;
|
||||||
|
struct hlsl_type *null;
|
||||||
} builtin_types;
|
} builtin_types;
|
||||||
|
|
||||||
/* List of the instruction nodes for initializing static variables. */
|
/* List of the instruction nodes for initializing static variables. */
|
||||||
@ -1451,6 +1453,7 @@ struct hlsl_type *hlsl_new_uav_type(struct hlsl_ctx *ctx, enum hlsl_sampler_dim
|
|||||||
struct hlsl_type *hlsl_new_cb_type(struct hlsl_ctx *ctx, struct hlsl_type *format);
|
struct hlsl_type *hlsl_new_cb_type(struct hlsl_ctx *ctx, struct hlsl_type *format);
|
||||||
struct hlsl_ir_node *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n,
|
struct hlsl_ir_node *hlsl_new_uint_constant(struct hlsl_ctx *ctx, unsigned int n,
|
||||||
const struct vkd3d_shader_location *loc);
|
const struct vkd3d_shader_location *loc);
|
||||||
|
struct hlsl_ir_node *hlsl_new_null_constant(struct hlsl_ctx *ctx, const struct vkd3d_shader_location *loc);
|
||||||
struct hlsl_ir_node *hlsl_new_unary_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg,
|
struct hlsl_ir_node *hlsl_new_unary_expr(struct hlsl_ctx *ctx, enum hlsl_ir_expr_op op, struct hlsl_ir_node *arg,
|
||||||
const struct vkd3d_shader_location *loc);
|
const struct vkd3d_shader_location *loc);
|
||||||
struct hlsl_ir_var *hlsl_new_var(struct hlsl_ctx *ctx, const char *name, struct hlsl_type *type,
|
struct hlsl_ir_var *hlsl_new_var(struct hlsl_ctx *ctx, const char *name, struct hlsl_type *type,
|
||||||
|
@ -107,6 +107,7 @@ matrix {return KW_MATRIX; }
|
|||||||
namespace {return KW_NAMESPACE; }
|
namespace {return KW_NAMESPACE; }
|
||||||
nointerpolation {return KW_NOINTERPOLATION; }
|
nointerpolation {return KW_NOINTERPOLATION; }
|
||||||
noperspective {return KW_NOPERSPECTIVE; }
|
noperspective {return KW_NOPERSPECTIVE; }
|
||||||
|
NULL {return KW_NULL; }
|
||||||
out {return KW_OUT; }
|
out {return KW_OUT; }
|
||||||
packoffset {return KW_PACKOFFSET; }
|
packoffset {return KW_PACKOFFSET; }
|
||||||
pass {return KW_PASS; }
|
pass {return KW_PASS; }
|
||||||
|
@ -304,6 +304,26 @@ static bool implicit_compatible_data_types(struct hlsl_ctx *ctx, struct hlsl_typ
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (src->class == HLSL_CLASS_NULL)
|
||||||
|
{
|
||||||
|
switch (dst->class)
|
||||||
|
{
|
||||||
|
case HLSL_CLASS_DEPTH_STENCIL_STATE:
|
||||||
|
case HLSL_CLASS_DEPTH_STENCIL_VIEW:
|
||||||
|
case HLSL_CLASS_PIXEL_SHADER:
|
||||||
|
case HLSL_CLASS_RASTERIZER_STATE:
|
||||||
|
case HLSL_CLASS_RENDER_TARGET_VIEW:
|
||||||
|
case HLSL_CLASS_SAMPLER:
|
||||||
|
case HLSL_CLASS_STRING:
|
||||||
|
case HLSL_CLASS_TEXTURE:
|
||||||
|
case HLSL_CLASS_UAV:
|
||||||
|
case HLSL_CLASS_VERTEX_SHADER:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return hlsl_types_are_componentwise_equal(ctx, src, dst);
|
return hlsl_types_are_componentwise_equal(ctx, src, dst);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,6 +351,9 @@ static struct hlsl_ir_node *add_cast(struct hlsl_ctx *ctx, struct hlsl_block *bl
|
|||||||
if (hlsl_types_are_equal(src_type, dst_type))
|
if (hlsl_types_are_equal(src_type, dst_type))
|
||||||
return node;
|
return node;
|
||||||
|
|
||||||
|
if (src_type->class == HLSL_CLASS_NULL)
|
||||||
|
return node;
|
||||||
|
|
||||||
if (src_type->class > HLSL_CLASS_VECTOR || dst_type->class > HLSL_CLASS_VECTOR)
|
if (src_type->class > HLSL_CLASS_VECTOR || dst_type->class > HLSL_CLASS_VECTOR)
|
||||||
{
|
{
|
||||||
unsigned int src_comp_count = hlsl_type_component_count(src_type);
|
unsigned int src_comp_count = hlsl_type_component_count(src_type);
|
||||||
@ -6050,6 +6073,7 @@ static bool state_block_add_entry(struct hlsl_state_block *state_block, struct h
|
|||||||
%token KW_NAMESPACE
|
%token KW_NAMESPACE
|
||||||
%token KW_NOINTERPOLATION
|
%token KW_NOINTERPOLATION
|
||||||
%token KW_NOPERSPECTIVE
|
%token KW_NOPERSPECTIVE
|
||||||
|
%token KW_NULL
|
||||||
%token KW_OUT
|
%token KW_OUT
|
||||||
%token KW_PACKOFFSET
|
%token KW_PACKOFFSET
|
||||||
%token KW_PASS
|
%token KW_PASS
|
||||||
@ -8321,6 +8345,18 @@ primary_expr:
|
|||||||
YYABORT;
|
YYABORT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
| KW_NULL
|
||||||
|
{
|
||||||
|
struct hlsl_ir_node *c;
|
||||||
|
|
||||||
|
if (!(c = hlsl_new_null_constant(ctx, &@1)))
|
||||||
|
YYABORT;
|
||||||
|
if (!($$ = make_block(ctx, c)))
|
||||||
|
{
|
||||||
|
hlsl_free_instr(c);
|
||||||
|
YYABORT;
|
||||||
|
}
|
||||||
|
}
|
||||||
| VAR_IDENTIFIER
|
| VAR_IDENTIFIER
|
||||||
{
|
{
|
||||||
struct hlsl_ir_load *load;
|
struct hlsl_ir_load *load;
|
||||||
|
@ -1649,6 +1649,7 @@ static bool copy_propagation_transform_load(struct hlsl_ctx *ctx,
|
|||||||
case HLSL_CLASS_DEPTH_STENCIL_VIEW:
|
case HLSL_CLASS_DEPTH_STENCIL_VIEW:
|
||||||
case HLSL_CLASS_GEOMETRY_SHADER:
|
case HLSL_CLASS_GEOMETRY_SHADER:
|
||||||
case HLSL_CLASS_BLEND_STATE:
|
case HLSL_CLASS_BLEND_STATE:
|
||||||
|
case HLSL_CLASS_NULL:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case HLSL_CLASS_MATRIX:
|
case HLSL_CLASS_MATRIX:
|
||||||
|
@ -3007,6 +3007,7 @@ static D3D_SHADER_VARIABLE_CLASS sm4_class(const struct hlsl_type *type)
|
|||||||
case HLSL_CLASS_HULL_SHADER:
|
case HLSL_CLASS_HULL_SHADER:
|
||||||
case HLSL_CLASS_GEOMETRY_SHADER:
|
case HLSL_CLASS_GEOMETRY_SHADER:
|
||||||
case HLSL_CLASS_BLEND_STATE:
|
case HLSL_CLASS_BLEND_STATE:
|
||||||
|
case HLSL_CLASS_NULL:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
vkd3d_unreachable();
|
vkd3d_unreachable();
|
||||||
|
@ -34,7 +34,7 @@ float4 main() : sv_target
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
[pixel shader todo]
|
[pixel shader]
|
||||||
SamplerState s
|
SamplerState s
|
||||||
{
|
{
|
||||||
UnknownField = NULL;
|
UnknownField = NULL;
|
||||||
@ -52,7 +52,7 @@ float4 main() : sv_target
|
|||||||
[require]
|
[require]
|
||||||
shader model >= 4.0
|
shader model >= 4.0
|
||||||
|
|
||||||
[pixel shader fail(sm>=6) todo]
|
[pixel shader fail(sm>=6)]
|
||||||
Texture2DMS<float4> t = NULL;
|
Texture2DMS<float4> t = NULL;
|
||||||
|
|
||||||
RWTexture1D<float4> u1 = NULL;
|
RWTexture1D<float4> u1 = NULL;
|
||||||
@ -72,7 +72,7 @@ float4 main() : sv_target
|
|||||||
[require]
|
[require]
|
||||||
shader model >= 5.0
|
shader model >= 5.0
|
||||||
|
|
||||||
[pixel shader fail(sm>=6) todo]
|
[pixel shader fail(sm>=6)]
|
||||||
RasterizerOrderedTexture2D<uint4> t1 = NULL;
|
RasterizerOrderedTexture2D<uint4> t1 = NULL;
|
||||||
|
|
||||||
float4 main() : sv_target
|
float4 main() : sv_target
|
||||||
|
Loading…
Reference in New Issue
Block a user