Skip to content

Commit

Permalink
fixed pgd3d tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hakasapl committed Dec 6, 2024
1 parent 49f98c5 commit bab3624
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ParallaxGenLib/include/ParallaxGenDirectory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,7 @@ class ParallaxGenDirectory : public BethesdaDirectory {

[[nodiscard]] auto getPGJSONs() const -> const std::vector<std::filesystem::path> &;

void setTextureType(const std::filesystem::path &Path, const NIFUtil::TextureType &Type);

auto getTextureType(const std::filesystem::path &Path) -> NIFUtil::TextureType;
};
11 changes: 11 additions & 0 deletions ParallaxGenLib/src/ParallaxGenD3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ ParallaxGenD3D::ParallaxGenD3D(ParallaxGenDirectory *PGD, filesystem::path Outpu
: PGD(PGD), OutputDir(std::move(OutputDir)), ExePath(std::move(ExePath)), UseGPU(UseGPU) {}

auto ParallaxGenD3D::findCMMaps(const std::vector<std::wstring> &BSAExcludes) -> ParallaxGenTask::PGResult {
if (UseGPU && (!PtrDevice || !PtrContext)) {
throw runtime_error("GPU not initialized");
}

auto &EnvMasks = PGD->getTextureMap(NIFUtil::TextureSlots::ENVMASK);

ParallaxGenTask::PGResult PGResult = ParallaxGenTask::PGResult::SUCCESS;
Expand Down Expand Up @@ -88,6 +92,7 @@ auto ParallaxGenD3D::findCMMaps(const std::vector<std::wstring> &BSAExcludes) ->
for (const auto &CMMap : CMMaps) {
EnvSlot.second.erase(CMMap);
EnvSlot.second.insert({CMMap.Path, NIFUtil::TextureType::COMPLEXMATERIAL});
PGD->setTextureType(CMMap.Path, NIFUtil::TextureType::COMPLEXMATERIAL);
}
}

Expand Down Expand Up @@ -442,6 +447,7 @@ auto ParallaxGenD3D::upgradeToComplexMaterial(const std::filesystem::path &Paral
{
throw runtime_error("GPU was not initialized");
}

lock_guard<mutex> Lock(UpgradeCMMutex);

ParallaxGenTask::PGResult PGResult{};
Expand All @@ -454,6 +460,11 @@ auto ParallaxGenD3D::upgradeToComplexMaterial(const std::filesystem::path &Paral
return {};
}

if (EnvExists && PGD->getTextureType(EnvMap) == NIFUtil::TextureType::COMPLEXMATERIAL) {
spdlog::trace(L"Skipping shader upgrade for {} as it is already a complex material", EnvMap.wstring());
return {};
}

// get parallax map
DirectX::ScratchImage ParallaxMapDDS;
if (ParallaxExists && getDDS(ParallaxMap, ParallaxMapDDS) != ParallaxGenTask::PGResult::SUCCESS) {
Expand Down
6 changes: 6 additions & 0 deletions ParallaxGenLib/src/ParallaxGenDirectory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,12 @@ auto ParallaxGenDirectory::getPBRJSONs() const -> const vector<filesystem::path>

auto ParallaxGenDirectory::getPGJSONs() const -> const vector<filesystem::path> & { return PGJSONs; }

void ParallaxGenDirectory::setTextureType(const filesystem::path &Path, const NIFUtil::TextureType &Type) {
lock_guard<mutex> Lock(TextureTypesMutex);

TextureTypes[Path] = Type;
}

auto ParallaxGenDirectory::getTextureType(const filesystem::path &Path) -> NIFUtil::TextureType {
lock_guard<mutex> Lock(TextureTypesMutex);

Expand Down

0 comments on commit bab3624

Please sign in to comment.