[PATCH vkd3d v3 3/6] vkd3d-shader/hlsl: Allow failure in hlsl_offset_from_deref.
Zebediah Figura (she/her)
zfigura at codeweavers.com
Fri Nov 12 10:45:13 CST 2021
On 11/12/21 04:29, Giovanni Mascellani wrote:
> 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.
Well,like I said I don't hate it. On the other hand, since the
duplicated code amounts to a single hlsl_fixme line, I don't really hate
that either. So, <shrug>.
More information about the wine-devel
mailing list