mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
vkd3d-shader/hlsl: Allow failure in hlsl_offset_from_deref.
Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com> Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Matteo Bruni <mbruni@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
f257004caf
commit
b266133a8c
@ -751,8 +751,10 @@ unsigned int hlsl_combine_writemasks(unsigned int first, unsigned int second);
|
||||
unsigned int hlsl_map_swizzle(unsigned int swizzle, unsigned int writemask);
|
||||
unsigned int hlsl_swizzle_from_writemask(unsigned int writemask);
|
||||
|
||||
unsigned int hlsl_offset_from_deref(const struct hlsl_deref *deref);
|
||||
struct hlsl_reg hlsl_reg_from_deref(const struct hlsl_deref *deref, const struct hlsl_type *type);
|
||||
bool hlsl_offset_from_deref(const struct hlsl_deref *deref, unsigned int *offset);
|
||||
unsigned int hlsl_offset_from_deref_safe(struct hlsl_ctx *ctx, const struct hlsl_deref *deref);
|
||||
struct hlsl_reg hlsl_reg_from_deref(struct hlsl_ctx *ctx, const struct hlsl_deref *deref,
|
||||
const struct hlsl_type *type);
|
||||
|
||||
bool hlsl_sm1_register_from_semantic(struct hlsl_ctx *ctx, const struct hlsl_semantic *semantic,
|
||||
bool output, D3DSHADER_PARAM_REGISTER_TYPE *type, unsigned int *reg);
|
||||
|
@ -1286,31 +1286,46 @@ static bool type_is_single_reg(const struct hlsl_type *type)
|
||||
return type->type == HLSL_CLASS_SCALAR || type->type == HLSL_CLASS_VECTOR;
|
||||
}
|
||||
|
||||
unsigned int hlsl_offset_from_deref(const struct hlsl_deref *deref)
|
||||
bool hlsl_offset_from_deref(const struct hlsl_deref *deref, unsigned int *offset)
|
||||
{
|
||||
struct hlsl_ir_node *offset_node = deref->offset.node;
|
||||
|
||||
if (!offset_node)
|
||||
return 0;
|
||||
{
|
||||
*offset = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* We should always have generated a cast to UINT. */
|
||||
assert(offset_node->data_type->type == HLSL_CLASS_SCALAR
|
||||
&& offset_node->data_type->base_type == HLSL_TYPE_UINT);
|
||||
|
||||
if (offset_node->type != HLSL_IR_CONSTANT)
|
||||
return false;
|
||||
|
||||
*offset = hlsl_ir_constant(offset_node)->value[0].u;
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned int hlsl_offset_from_deref_safe(struct hlsl_ctx *ctx, const struct hlsl_deref *deref)
|
||||
{
|
||||
FIXME("Dereference with non-constant offset of type %s.\n", hlsl_node_type_to_string(offset_node->type));
|
||||
unsigned int offset;
|
||||
|
||||
if (hlsl_offset_from_deref(deref, &offset))
|
||||
return offset;
|
||||
|
||||
hlsl_fixme(ctx, deref->offset.node->loc, "Dereference with non-constant offset of type %s.",
|
||||
hlsl_node_type_to_string(deref->offset.node->type));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return hlsl_ir_constant(offset_node)->value[0].u;
|
||||
}
|
||||
|
||||
struct hlsl_reg hlsl_reg_from_deref(const struct hlsl_deref *deref, const struct hlsl_type *type)
|
||||
struct hlsl_reg hlsl_reg_from_deref(struct hlsl_ctx *ctx, const struct hlsl_deref *deref,
|
||||
const struct hlsl_type *type)
|
||||
{
|
||||
const struct hlsl_ir_var *var = deref->var;
|
||||
struct hlsl_reg ret = var->reg;
|
||||
unsigned int offset = hlsl_offset_from_deref(deref);
|
||||
unsigned int offset = hlsl_offset_from_deref_safe(ctx, deref);
|
||||
|
||||
ret.id += offset / 4;
|
||||
|
||||
|
@ -663,7 +663,7 @@ static void write_sm1_expr(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *b
|
||||
static void write_sm1_load(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *buffer, const struct hlsl_ir_node *instr)
|
||||
{
|
||||
const struct hlsl_ir_load *load = hlsl_ir_load(instr);
|
||||
const struct hlsl_reg reg = hlsl_reg_from_deref(&load->src, instr->data_type);
|
||||
const struct hlsl_reg reg = hlsl_reg_from_deref(ctx, &load->src, instr->data_type);
|
||||
struct sm1_instruction sm1_instr =
|
||||
{
|
||||
.opcode = D3DSIO_MOV,
|
||||
@ -707,7 +707,7 @@ static void write_sm1_store(struct hlsl_ctx *ctx, struct vkd3d_bytecode_buffer *
|
||||
{
|
||||
const struct hlsl_ir_store *store = hlsl_ir_store(instr);
|
||||
const struct hlsl_ir_node *rhs = store->rhs.node;
|
||||
const struct hlsl_reg reg = hlsl_reg_from_deref(&store->lhs, rhs->data_type);
|
||||
const struct hlsl_reg reg = hlsl_reg_from_deref(ctx, &store->lhs, rhs->data_type);
|
||||
struct sm1_instruction sm1_instr =
|
||||
{
|
||||
.opcode = D3DSIO_MOV,
|
||||
|
@ -792,7 +792,7 @@ static void sm4_register_from_deref(struct hlsl_ctx *ctx, struct sm4_register *r
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned int offset = hlsl_offset_from_deref(deref) + var->buffer_offset;
|
||||
unsigned int offset = hlsl_offset_from_deref_safe(ctx, deref) + var->buffer_offset;
|
||||
|
||||
assert(data_type->type <= HLSL_CLASS_VECTOR);
|
||||
reg->type = VKD3D_SM4_RT_CONSTBUFFER;
|
||||
@ -820,7 +820,7 @@ static void sm4_register_from_deref(struct hlsl_ctx *ctx, struct sm4_register *r
|
||||
}
|
||||
else
|
||||
{
|
||||
struct hlsl_reg hlsl_reg = hlsl_reg_from_deref(deref, data_type);
|
||||
struct hlsl_reg hlsl_reg = hlsl_reg_from_deref(ctx, deref, data_type);
|
||||
|
||||
assert(hlsl_reg.allocated);
|
||||
reg->type = VKD3D_SM4_RT_INPUT;
|
||||
@ -850,7 +850,7 @@ static void sm4_register_from_deref(struct hlsl_ctx *ctx, struct sm4_register *r
|
||||
}
|
||||
else
|
||||
{
|
||||
struct hlsl_reg hlsl_reg = hlsl_reg_from_deref(deref, data_type);
|
||||
struct hlsl_reg hlsl_reg = hlsl_reg_from_deref(ctx, deref, data_type);
|
||||
|
||||
assert(hlsl_reg.allocated);
|
||||
reg->type = VKD3D_SM4_RT_OUTPUT;
|
||||
@ -862,7 +862,7 @@ static void sm4_register_from_deref(struct hlsl_ctx *ctx, struct sm4_register *r
|
||||
}
|
||||
else
|
||||
{
|
||||
struct hlsl_reg hlsl_reg = hlsl_reg_from_deref(deref, data_type);
|
||||
struct hlsl_reg hlsl_reg = hlsl_reg_from_deref(ctx, deref, data_type);
|
||||
|
||||
assert(hlsl_reg.allocated);
|
||||
reg->type = VKD3D_SM4_RT_TEMP;
|
||||
|
Loading…
x
Reference in New Issue
Block a user