On Tue Mar 12 16:21:47 2024 +0000, Francisco Casas wrote:
Still, I think that hlsl_block covers _expression_ and all the other cases. Using node_from_block(), it can be checked if the resulting node is an HLSL_IR_LOAD for the other cases. Even if the "instruction set" is different, it is probably a restrictive subset of the instruction set handled by the hlsl, right?
The problem is that it shouldn't cover all cases, because effect binary contains specific markers, telling which kind of value assignment that is. E.g 0 - constant, 1 - variable, 2 - constant index array access, etc. This is encoded as effect metadata.
Regarding instruction set, it certainly does intersect, but it's not the same. See preshader_ops[] in d3d10/effect.c for known ops. Also there is special way to encode number of used components, and as you can see some instructions do not exist in normal shader language. One option is to have a superset, and then convert them at some point, but to me it seems unfortunate to pollute main compiler logic with marginally used functionality. I don't know what would be the best option.
Also for constant values you can have special predefined constant names like "inv_src_alpha" that are meaningful in context of a state object. We can certainly have all that logic implemented as helpers in fx.c as a number of helpers that would return numeric value for given state object type and constant name.