On 04/22/2016 05:15 PM, Matteo Bruni wrote:
- float *v;
- unsigned int op_pos, op_step, result_index;
- D3DXHANDLE param;
- if (args_count == 1)
- {
op_pos = TEST_EFFECT_PRESHADER_OP0_POS;
op_step = TEST_EFFECT_PRESHADER_OP0_INS_SIZE;
result_index = 0;
- }
- else if (args_count == 2)
- {
op_pos = TEST_EFFECT_PRESHADER_OPMUL_POS;
op_step = TEST_EFFECT_PRESHADER_OPMUL_INS_SIZE;
result_index = 2;
- }
- else
- {
return;
- }
That doesn't seem particularly nice, especially WRT extending this test later on. It seems better to have the "original" bytecode and these variables you compute here passed in from the caller (maybe stored in a struct together with the opcode parameters).
I am not sure I understand how do you see this original bytecode: is it a pointer inside the effect blob to the code to be altered, the whole effect blob pointer or something else?
test_effect_preshader_ops() should probably be table-based. At that point the *_POS and *_SIZE defines might become unnecessary; if they stay they should probably be named after the argument count (which is the actually interesting part, the original operation is going to change for the test and can be figured out from the light index) instead.
I can put it in the array but do we need to make this too generic? I. e. support other argument counts besides 1 and 2? I know just one opcode which has more opcodes and we are unlikely to encounter much more. I was planning to test d3dts_dotswiz separately outside of this infrastructure. I can get rid of _SIZE define (as actually it can be computed from arguments count), but how do you see getting rid of _POS?