On 03/24/2017 05:10 PM, Matteo Bruni wrote:
2017-03-24 2:16 GMT+01:00 Paul Gofman gofmanp@gmail.com:
Sorry, I messed up things actually, base register actually can come from temporary (register) table also, which happens in the test. So I will introduce extra structure for registers.
So I had a look at my stuff. As you know it has got very little and specific testing and is most likely missing some cases but I see that:
- for relative addressing I accept any register type as base but
expect only temporary registers as index (i.e. I look for "flags" == 1 and then for the "base" fields only when parsing TEMP registers)
- for CONST registers the "flags" != 0 field has a different meaning.
In that case it is an offset in the IMMED table and there is no additional "base" register type + index in the effect bytecode, so it's indexed like imm["flags" + cidx].
What is seen from my tests for relative addressing (all these cases below are present in the test currently there in the last patch I sent, though I will add another test in the updated patch which covers more cases, and also has a non-zero absolute offset, which helped me to discovered and fix the bug): 1. Temporary register or constant float (e. g. c0) register can be used as base register in relative addressing. Temporary register is used by compiler when it needs to do some precompute for the index value, like rounding, multiplying by stride for structure or any other arithmetic with indexes, otherwise cX registers are used directly.
2. If the value being indexed is 4x vectors aligned, the main register being indexed is cX, it is directly indexed by base register;
3. If the value we are indexing into is some vector, or matrix, or anything not 4x aligned, compiler generates a code doing the indexing through a 'dot' instructions with base register indexing immediate constants to dot with.
This is basically present in the test I sent (doing a trace with +d3dx will show preshaders with these relative addressing types, the string to easily find the code in the output is 'imm['). in the next update I will include another test which is a bit more complicated in terms of this 'dot' arithmetic.
So unless I am missing something I don't see yet how flags have a different meaning for const or immed registers, it looks very straightforward and matches the test.