Conversation
Many games support own archive formats and implement own sort of a virtual file system. In that case, LoadFromDDSFile() doesn't fit, while LoadFromDDSMemory() requires 2x filesize: one buffer to read the file and another one to load the texture, since ScratchImage is always owning. Add a simple InputStream class and LoadDDSFromStream() to avoid this memory overhead and allow games and apps to use their own functionality to operate with files or memory. More formats could support this in future, as well as writing to an OutputStream if/when needed. Signed-off-by: Alexander Lobakin <alobakin@mailbox.org>
|
@microsoft-github-policy-service agree |
|
For loading DDS content at runtime in a game, I'd suggest not using DirectXTex or at least not the library. It's designed to load and convert all kinds of legacy content to modern formats, so it brings a lot of code to bear. The DDSTextureLoader module is intended to be more light-weight and focused on the needs of runtime. That may be a good place to look at adding the Stream version instead. |
|
We considered using DDSTextureLoader, but unfortunately it's a poor fit for our engine, probably not only ours. We don't want our texture loader to require a Dx context or to create SRVs/UAVs/whatever for us. Once we have a list of textures to load, we load them and create |
|
For scenarios where you are just wanting to load content, DirectXTex is going to be overkill unless your dataset includes lots of legacy formats (24bpp, etc.) you have to fix-up at load-time. For most titles/engines, DirectXTex is an excellent library to use for a 'content cooking/packing' step that produces a 'WAD-style' file-system-in-a-file' data file that your application can efficiently load with ASYNC I/O. Loading them as individual DDS files generally gets dominated by the overhead of Open/Close and AV scans. Is there a particular design requirement here that your engine consume 'loose' files? |
|
The textures are stored in game archives (either legacy custom format or squashfs) and are read using the corresponding APIs. There are no individual opens/closes; the archives are indexed, opened, and reading a file from them is very cheap. |
|
And to verify for your scenario, you DO NOT expect the loader at runtime to do legacy conversions/expansions (24bpp, 3:2:2, etc.)? |
|
Nope, we only use DXT1 (it's not under the 24bpp category I guess?), DXT5, and BC7 (+ BC6H in some future probably). But we only expect a Here's all what we need, load + create: (that fallback part after (I mean, we'd still need DxTex, but only for screenshot capturing) |
|
Did you look at ScreenGrab for screenshots? |
|
We only use |
Many games support own archive formats and implement own sort of a virtual file system. In that case,
LoadFromDDSFile()doesn't fit, whileLoadFromDDSMemory()requires 2x filesize: one buffer to read the file and another one to load the texture, sinceScratchImageis always owning.Add a simple
InputStreamclass andLoadDDSFromStream()to avoid this memory overhead and allow games and apps to use their own functionality to operate with files or memory.More formats could support this in future, as well as writing to an
OutputStreamif/when needed.