Because of the change introduced in f21693b2, SM1 scalars and vectors were not longer getting the correct writemask when they are allocated, so this is fixed.
Also, the mapping of sm1 src register swizzles is moved outside `write_sm1_instruction()` since there are some instructions that don't do this, remarkably dp2add. This is fixed.
Before the last patch we are writing the operation as:
```
dp2add r0.x, r1.x, r0.x, r2.x
```
and now it is:
```
dp2add r0.x, r1.xyxx, r0.xyxx, r2.x
```
dp2add now has its own function, `write_sm1_dp2add()`, since it seems to
be the only instruction with this structure.
Ideally we would be using the default swizzles for the first two src arguments:
```
dp2add r0.x, r1, r0, r2.x
```
since, according to native's documentation, these are supported for all sm < 4.
But using default swizzles whenever is possible -- along with following the conversion of repeating the
last component of the swizzle when fewer than 4 components are to be
specified -- has a higher scope. Probably would involve modifying
`hlsl_swizzle_from_writemask()` and `hlsl_map_swizzle()`.
--
v3: vkd3d-shader/hlsl: Fix SM1 dp2add swizzles.
vkd3d-shader/hlsl: Map SM1 src swizzles outside write_sm1_instruction().
vkd3d-shader/hlsl: Set writemasks correctly for SM1 scalar and vector types.
vkd3d-shader/hlsl: Expect component count in allocate_register().
vkd3d-shader/hlsl: Rename 'component_count' arguments to 'reg_size'.
https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/81
While running in XCode's profiler, I noticed a memory leak in `Global_Split`.
When the strings are being copied into the SafeArray, the `BSTR` is not freed after `VariantCopyInd`.
--
v4: vbscript: Fix memory leak in Split()
https://gitlab.winehq.org/wine/wine/-/merge_requests/2131
QueryInterface should set *out to NULL on failure, as it seems to do in many different places.
This seems to be a regression from !888.
One old game started to crash on startup with this merge request.
I bisected it and it pointed to the commit 131ada052a2dbec66df695ce536ca048a2bd9174.
--
v3: wmvcore/tests: check out value for NULL in check_interface
https://gitlab.winehq.org/wine/wine/-/merge_requests/2130
While running in XCode's profiler, I noticed a memory leak in `Global_Split`.
When the strings are being copied into the SafeArray, the `BSTR` is not freed after `VariantCopyInd`.
--
v3: vbscript: Fix memory leak in Split()
https://gitlab.winehq.org/wine/wine/-/merge_requests/2131
While running in XCode's profiler, I noticed a memory leak in `Global_Split`.
When the strings are being copied into the SafeArray, the `BSTR` is not freed after `VariantCopyInd`.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/2131
While running in XCode's profiler, I noticed two memory leaks in `interp_redim_preserve`.
After looking at `interp_redim`, the `bounds` structure is freed.
I've updated `interp_redim_preserve` to free `bounds` when the array is NULL and not NULL.
--
v3: vbscript: Fix memory leak in interp_redim_preserve
https://gitlab.winehq.org/wine/wine/-/merge_requests/2132
Jinoh Kang (@iamahuman) commented about dlls/ntdll/rtl.c:
> + * the 32-bit addition above to handle.
> + *
> + * This produces an integer in the range [0x7fffffe2, 0xfffffffe].
> + */
> + result = 0x7fffffffu * 2 - result;
> +
> + /* Perform the 2nd round of the modulus calculation.
> + * This produces an integer in the range [0, 0x7fffffff].
> + */
> + result = (result & 0x7fffffffu) + (result >> 31);
> +
> + /* If result is 0x7fffffff, set it to 0. We avoid branching here so that
> + * RtlUniform runs in near-constant time. This also avoids unexpected
> + * performance hit due to polluted branch target buffer.
> + */
> + result &= -((0x7fffffffu * 2 - result) >> 31);
If we assume that the right shift operator is always defined as arithmetic shift, we can optimize it further:
```suggestion:-0+0
result &= (LONG)(0x7fffffffu * 2 - result) >> 31;
```
That said, GCC (https://godbolt.org/z/65od5ErMo) does this optimization already. Meanwhile clang (https://godbolt.org/z/46x8a8r9v) seems to recognize the trick and replace it with `inc + cmovns` (since `0x7fffffff + 1` is `0x80000000` which sets SF).
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/821#note_23433
QueryInterface should set *out to NULL on failure, as it seems to do in many different places.
This seems to be a regression from !888.
One old game started to crash on startup with this merge request.
I bisected it and it pointed to the commit 131ada052a2dbec66df695ce536ca048a2bd9174.
--
v2: wmvcore/tests: check out value in check_interface
https://gitlab.winehq.org/wine/wine/-/merge_requests/2130
While running in XCode's profiler, I noticed two memory leaks in `interp_redim_preserve`.
After looking at `interp_redim`, the `bounds` structure is freed.
I've updated `interp_redim_preserve` to free `bounds` when the array is NULL and not NULL.
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/2132