July 28, 2025
8:11 p.m.
Matteo Bruni (@Mystral) commented about dlls/d3dx9_36/d3dx_helpers.h:
> unsigned short float_32_to_16(const float in);
> float float_16_to_32(const unsigned short in);
>
> +struct d3dx_buffer;
> +struct d3dx_buffer_ops
> +{
> + HRESULT (*d3dx_buffer_create)(struct d3dx_buffer *d3dx_buffer, unsigned int size);
> + void (*d3dx_buffer_destroy)(struct d3dx_buffer *d3dx_buffer);
> +};
> +
> +struct d3dx_buffer
> +{
> + const struct d3dx_buffer_ops *ops;
> + void *buffer_iface;
> + void *buffer_data;
> +};
This is a bit confusing since `struct d3dx_buffer` is doing two things at the same time:
- offer functions to create and destroy a version-specific d3dx buffer
- hold data for a specific instance of the version-specific d3dx buffer
This won't be much of a problem for now, given the use cases we expect, and it could be improved somewhat with naming tweaks, but I think it would be better if we simply split up the two uses of the struct right away.
What about this:
- rename `struct d3dx_buffer_ops` to `struct d3dx_buffer_wrapper`
- add an output `struct d3dx_buffer *` parameter to `d3dx_buffer_create()`
- get rid of the ops pointer in `struct d3dx_buffer`
- pass both a `struct d3dx_buffer_wrapper *` (input, const) and a `struct d3dx_buffer *` (output) parameters to `d3dx_save_pixels_to_memory()`
It might be a bit more verbose but it seems cleaner to me. Unless I'm missing some kind of complication...
--
https://gitlab.winehq.org/wine/wine/-/merge_requests/8490#note_111237