On 12/22/21 03:37, Giovanni Mascellani wrote:
Hi,
On 22/12/21 00:08, Zebediah Figura wrote:
This patch is something of an argument for storing the resource and sampler variables as hlsl_src rather than hlsl_deref. I'm still inclined to avoid this, because that would require the variable to be unchanged between the load and resource load, and that feels like a tricky and dangerous invariant to preserve.
I have no opinion of whether using a hlsl_src or a hlsl_deref (not yet, at least :-P ), but I don't understand your second sentence. Is it possible to mutate a texture or sampler variable?
Sure, it's possible to mutate any variable.
To expand, what I mean is that the alternative—where we use hlsl_src—means we'd need to have a separate HLSL_IR_LOAD instruction, and then at codegen time we reach through it and retrieve the variable from that. That works—objects can only be returned by LOAD instructions—but the problem is that you can get something like:
Texture2D | 2: t1 | 3: t1 = t2 float4 | 4: sample(@2, ...)
I guess we could validate at codegen time that t1 isn't written to (after all, if it is, we have a problem anyway)...