Hi,
On 12/11/21 05:16, Zebediah Figura (she/her) wrote:
On 11/11/21 05:06, Giovanni Mascellani wrote:
+unsigned int hlsl_offset_from_deref_safe(struct hlsl_ctx *ctx, const struct hlsl_deref *deref) +{ + 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; }
I don't hate this, but ultimately we're going to need to handle non-constant offsets in the callers anyway. I'd just pass the buck all the way down to sm4_register_from_deref() and write_sm1_{load,store}().
Sure, but wouldn't it make sense to do this once the caller is able to handle the error condition? Otherwise we have to repeat the same code in five different places. Just think hlsl_offset_from_deref_safe as a helper, nothing more. Once we'll have another helper that does a better job, hlsl_offset_from_deref_safe will be kissed bye bye.
But if you really insist, I can copy it in every caller.
Giovanni.