[PATCH 8/9] d3dx9: Add test for 'cmp' preshader opcode.
Paul Gofman
gofmanp at gmail.com
Thu May 11 10:08:31 CDT 2017
T
On 05/11/2017 05:43 PM, Matteo Bruni wrote:
> DWORD *test_effect_blob;
>> HRESULT hr;
>> @@ -4506,8 +4507,30 @@ static void test_preshader_op(IDirect3DDevice9 *device, const DWORD *sample_effe
>>
>> test_effect_blob = HeapAlloc(GetProcessHeap(), 0, sample_effect_blob_size);
>> memcpy(test_effect_blob, sample_effect_blob, sample_effect_blob_size);
>> - for (i = 0; i < blob_position[test->args_count].ins_count; ++i)
>> - test_effect_blob[op_pos + i * op_step] = test->opcode;
>> +
>> + if (test->args_count == 3)
>> + {
>> + DWORD *pos;
>> +
>> + pos = &test_effect_blob[op_pos - 1];
>> + *pos++ = 1;
>> + *pos++ = test->opcode;
>> + *pos++ = test->args_count;
>> + for (i = 0; i < 3; ++i)
>> + {
>> + *pos++ = 0;
>> + *pos++ = 2;
>> + *pos++ = i == 2 ? 4 : 0;
>> + }
>> + *pos++ = 0;
>> + *pos++ = 4;
>> + *pos++ = 0;
>> + }
>> + else
>> + {
>> + for (i = 0; i < blob_position[test->args_count].ins_count; ++i)
>> + test_effect_blob[op_pos + i * op_step] = test->opcode;
>> + }
> I think this is getting more and more ugly. What about writing an
> effect with those 3 preshaders by hand instead? You could start with
> those edited effect fragments, fixing them up and putting them
> together in a new effect blob. Sprinkle over some comments as
> necessary.
>
> I'm not going to block the patch for this reason but I think it's
> something worth exploring.
>
>
The problem is I met this opcode in the wild and thus added it in the
first version of preshader implementation (and can "model" and test it
by manually editing preshader code), but could not make native d3dx
compiler to generate it so far. Whatever I tried in HLSL which would be
a straightforward use of 'cmp' resulted in different opcode sequences.
It was either generated by some earlier versions of compiler or I just
could not find the conditions under which it will be used. As for adding
some other 3-parameter opcode to effect blob, while scanning all the
opcodes in the 3 hex digit opcode range I have found just one other 3
parameter opcode 'movc', but it seem to always return 0 and I cannot
generate it in effect blob from source either. So by now I didn't find
any other way to test this opcode rather than manually code it in the
effect blob.
Maybe I would rather generate the code for all the other cases too?
It won't make this part less evident but it will be a uniform approach.
More information about the wine-devel
mailing list