On Fri Mar 22 21:20:30 2024 +0000, Francisco Casas wrote:
well, first we have to find out if native does some compilation passes such as copy-propagation and constant folding to lower complicated expressions into constants, and apply those passes. For instance, are rhs expressions such as `ANISOTROPIC + 1` marked as a of the _constant load_ type in the effects metadata? After applying the passes we have to check the type of the last instruction of the block (or args[0], in case ths is not a complex initializer with braces) which represents the whole expression, and see if it is HLSL_IR_CONSTANT, HLSL_IR_INDEX (in which case we have to check if the index part is constant) or HLSL_IR_EXPR. We should also probably introduce a pass exclusive to fx.c to lower known HLSL_IR_UNDECLARED_LOAD into constants, so constant folding (if required) can work. I don't know yet how complex initializers with braces work in this case, if at all, but they parse.
They are evaluated, yes. Destination index is not evaluated, it has to be an integer literal. So full format would be like this:
property_name[<literal index>] = ( literal_constant | variable[literal_constant] | variable[index_variable] | <expression-for-anything-more-complicated> )
Expression case does not map directly to our internal opcodes, it does not follow the same conventions as d3dbc/tpf binaries do. But we can leave that out for now.
Another case that does not fit into "args" array is examples like "compile ps_2_0, main(var)", or asm {} blocks, or asm{} blocks with leading decl{} part. Those will have to be handled separately.