-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove d3dx dependency, severely improve memory usage but loading takes a long time initially #19
Conversation
doesn't work yet, fails to create textures from dds memory
fails when using std::launch::async though, maybe something in the directxtex library is not thread safe
modules/TextureClient.ixx
Outdated
} | ||
std::vector<std::future<unsigned>> futures; | ||
for (const auto modfile : modfiles) { | ||
futures.emplace_back(std::async(std::launch::deferred, ProcessModfile, std::ref(*this), modfile, files_size > 400'000'000)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think 400'000'000 bytes is a sensible value. 450mb load to roughly 850mb of non-compressed memory and around 250mb of compressed memory. With 850mb of texmod data, worst case, we still have 1gb free for gw itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
launching this deferred instead of async because some part of the directxtex library doesn't seem work when using its functions asynchronously
if (image.GetMetadata().format == DXGI_FORMAT_B8G8R8X8_UNORM) { | ||
// todo: this is undefined behaviour, but we must force them to be interpreted as BGRA instead of BGRX | ||
const_cast<DXGI_FORMAT&>(image.GetMetadata().format) = DXGI_FORMAT_B8G8R8A8_UNORM; | ||
const auto images = image.GetImages(); | ||
for (int i = 0; i < image.GetImageCount(); ++i) { | ||
const_cast<DXGI_FORMAT&>(images[i].format) = DXGI_FORMAT_B8G8R8A8_UNORM; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't see any way around undefined behaviour here. unfortunately, we're forced to do this.
const static std::regex re(R"(0x[0-9a-f]{8})", std::regex::optimize | std::regex::icase); | ||
std::smatch match; | ||
if (!std::regex_search(name, match, re)) { | ||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
texmod/umod always saved them padded to 8 chars, right?
DirectX::ScratchImage ImageConvertToBGRA(DirectX::ScratchImage& image, const TexEntry& entry) | ||
{ | ||
if (image.GetMetadata().format == DXGI_FORMAT_B8G8R8A8_UNORM || image.GetMetadata().format == DXGI_FORMAT_BC3_UNORM) { | ||
return std::move(image); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ye, I know... unfortunately not much of a choice, it would be better to not call the function if it wasn't necessary, but the check is more appropriate here
No description provided.