On Tue Jul 8 22:53:13 2025 +0000, Matteo Bruni wrote:
I'm a bit torn on this... It would be nice if we could avoid including d3dx* headers from here. That way we're sure that we're not depending on anything version-specific in the generic code. It shouldn't usually make things more complicated, e.g. the `D3DX_FILTER_` defines could just be copied from the d3dx9 header and used unchanged instead of defining them to the `D3DX10_` (or `D3DX11_`) version. The one annoying bit with this is the `ID3DXBuffer` / `ID3D10Blob` / `ID3DBlob` mess. I haven't thought this through but it might make the whole thing not worth it. Maybe you already tried something like this and discarded it; let me know. Either way, I'd move the `#define COBJMACROS` out of the .h and into the .c files using it, otherwise it affects all the following includes which might come as a bit of a surprise.
The `ID3DXBuffer`/ `ID3D10Blob` / `ID3DBlob` was what ultimately led me to doing that. Originally I was just returning allocated memory/size from the saving to file function, creating the appropriate buffer interface, and copying it over. That feels a bit wasteful WRT memory.
In theory we're the ones implementing those interfaces in the first place, so we could add some way to do the equivalent of `D3DXCreateBuffer()` / `D3D10CreateBlob()` / `D3DCreateBlob()` with preallocated memory.
The other alternative is to do a kind of dry run to get the size first, then pass in the allocated memory on the second call. That ends up with extra code complexity that felt a bit messy to me at the time.