[PATCH vkd3d v4 3/5] vkd3d: Introduce a vkd3d_bound_range() helper.
Zebediah Figura (she/her)
zfigura at codeweavers.com
Thu Jul 22 12:02:13 CDT 2021
On 7/22/21 4:15 AM, Henri Verbeet wrote:
> On Fri, 9 Jul 2021 at 04:14, Zebediah Figura <zfigura at codeweavers.com> wrote:
>> +static inline bool vkd3d_bound_range(size_t start, size_t count, size_t limit)
>> +{
>> +#ifdef HAVE_BUILTIN_ADD_OVERFLOW
>> + size_t sum;
>> +
>> + return !__builtin_add_overflow(start, count, &sum) && sum <= limit;
>> +#else
>> + return start <= limit && count <= limit - start;
>> +#endif
>> +}
> [...]
>> @@ -1925,7 +1925,7 @@ static D3D12_GPU_VIRTUAL_ADDRESS vkd3d_gpu_va_allocator_allocate_fallback(struct
>> base = allocator->fallback_floor;
>> ceiling = ~(D3D12_GPU_VIRTUAL_ADDRESS)0;
>> ceiling -= alignment - 1;
>> - if (aligned_size > ceiling || ceiling - aligned_size < base)
>> + if (!vkd3d_bound_range(base, aligned_size, ceiling))
>> return 0;
>>
> Actually, you can't necessarily do that. D3D12_GPU_VIRTUAL_ADDRESS is
> always a 64-bit type, but size_t may not be.
>
Oops, I thought I checked all of my types :-(
More information about the wine-devel
mailing list