allocation removals and fixes

This commit is contained in:
Turánszki János
2024-06-04 07:32:26 +02:00
parent 8f03af5065
commit 00a72a7b30
10 changed files with 68 additions and 38 deletions
+1 -1
View File
@@ -229,7 +229,7 @@ public:
void Initialize() override;
~Editor()
~Editor() override
{
config.Commit();
}
-4
View File
@@ -279,7 +279,6 @@ void GeneralWindow::Create(EditorComponent* _editor)
{
editor->SetLocalization(editor->default_localization);
editor->main->config.GetSection("options").Set("language", "English");
editor->main->config.Commit();
return;
}
@@ -289,7 +288,6 @@ void GeneralWindow::Create(EditorComponent* _editor)
{
editor->SetLocalization(editor->current_localization);
editor->main->config.GetSection("options").Set("language", language);
editor->main->config.Commit();
}
else
{
@@ -376,8 +374,6 @@ void GeneralWindow::Create(EditorComponent* _editor)
theme.font.shadow_color = wi::Color::Shadow();
break;
}
editor->main->config.Commit();
theme.tooltipImage = theme.image;
theme.tooltipImage.color = theme_color_idle;
+1 -1
View File
@@ -1525,7 +1525,7 @@ void GraphicsWindow::Update()
resolutionScaleSlider.SetValue(editor->resolutionScale);
streamingSlider.SetValue(wi::resourcemanager::GetStreamingMemoryThreshold());
MSAAComboBox.SetSelectedByUserdataWithoutCallback(editor->renderPath->getMSAASampleCount());
tonemapCombo.SetSelected((int)editor->renderPath->getTonemap());
tonemapCombo.SetSelectedByUserdataWithoutCallback((int)editor->renderPath->getTonemap());
exposureSlider.SetValue(editor->renderPath->getExposure());
brightnessSlider.SetValue(editor->renderPath->getBrightness());
contrastSlider.SetValue(editor->renderPath->getContrast());
+19 -14
View File
@@ -278,20 +278,25 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
editor.is_window_active = true;
if (wi::shadercompiler::GetRegisteredShaderCount() > 0)
{
std::thread([] {
wi::backlog::post("[Shader check] Started checking " + std::to_string(wi::shadercompiler::GetRegisteredShaderCount()) + " registered shaders for changes...");
if (wi::shadercompiler::CheckRegisteredShadersOutdated())
{
wi::backlog::post("[Shader check] Changes detected, initiating reload...");
wi::eventhandler::Subscribe_Once(wi::eventhandler::EVENT_THREAD_SAFE_POINT, [](uint64_t userdata) {
wi::renderer::ReloadShaders();
});
}
else
{
wi::backlog::post("[Shader check] All up to date");
}
}).detach();
static wi::jobsystem::context shader_check_ctx;
if (!wi::jobsystem::IsBusy(shader_check_ctx))
{
shader_check_ctx.priority = wi::jobsystem::Priority::Low;
wi::jobsystem::Execute(shader_check_ctx, [](wi::jobsystem::JobArgs args) {
wi::backlog::post("[Shader check] Started checking " + std::to_string(wi::shadercompiler::GetRegisteredShaderCount()) + " registered shaders for changes...");
if (wi::shadercompiler::CheckRegisteredShadersOutdated())
{
wi::backlog::post("[Shader check] Changes detected, initiating reload...");
wi::eventhandler::Subscribe_Once(wi::eventhandler::EVENT_THREAD_SAFE_POINT, [](uint64_t userdata) {
wi::renderer::ReloadShaders();
});
}
else
{
wi::backlog::post("[Shader check] All up to date");
}
});
}
}
editor.renderComponent.ReloadLanguage();
break;
+3 -1
View File
@@ -50,6 +50,8 @@ namespace wi
initialized = true;
wi::initializer::InitializeComponentsAsync();
alwaysactive = wi::arguments::HasArgument("alwaysactive");
}
void Application::ActivatePath(RenderPath* component, float fadeSeconds, wi::Color fadeColor)
@@ -132,7 +134,7 @@ namespace wi
}
}
if (!is_window_active && !wi::arguments::HasArgument("alwaysactive"))
if (!is_window_active && !alwaysactive)
{
// If the application is not active, disable Update loops:
deltaTimeAccumulator = 0;
+1
View File
@@ -29,6 +29,7 @@ namespace wi
bool frameskip = true;
bool framerate_lock = false;
bool initialized = false;
bool alwaysactive = false;
wi::FadeManager fadeManager;
+2 -1
View File
@@ -1022,7 +1022,7 @@ namespace wi::helper
#endif // PLATFORM_LINUX || PLATFORM_PS5
if (file.is_open())
{
size_t dataSize = (size_t)file.tellg();
size_t dataSize = (size_t)file.tellg() - offset;
dataSize = std::min(dataSize, max_read);
file.seekg((std::streampos)offset);
data.resize(dataSize);
@@ -1169,6 +1169,7 @@ namespace wi::helper
}
#endif // PLATFORM_UWP
wi::backlog::post("File couln't be written: " + fileName, wi::backlog::LogLevel::Error);
return false;
}
+29 -14
View File
@@ -762,19 +762,6 @@ namespace wi
desc.swizzle.a = ComponentSwizzle::ONE;
}
wi::vector<SubresourceData> initdata;
initdata.reserve(desc.array_size * desc.mip_levels);
for (uint32_t slice = 0; slice < desc.array_size; ++slice)
{
for (uint32_t mip = 0; mip < desc.mip_levels; ++mip)
{
SubresourceData& subresourceData = initdata.emplace_back();
subresourceData.data_ptr = filedata + header.mip_offset(mip, slice);
subresourceData.row_pitch = header.row_pitch(mip);
subresourceData.slice_pitch = header.slice_pitch(mip);
}
}
if (header.is_1d())
{
desc.type = TextureDesc::Type::TEXTURE_1D;
@@ -790,6 +777,33 @@ namespace wi
desc.height = AlignTo(desc.height, GetFormatBlockSize(desc.format));
}
wi::vector<SubresourceData> initdata_heap;
SubresourceData initdata_stack[16] = {};
SubresourceData* initdata = nullptr;
// Determine if we need heap allocation for initdata, or it is small enough for stack:
if (desc.array_size * desc.mip_levels < arraysize(initdata_stack))
{
initdata = initdata_stack;
}
else
{
initdata_heap.resize(desc.array_size * desc.mip_levels);
initdata = initdata_heap.data();
}
uint32_t subresource_index = 0;
for (uint32_t slice = 0; slice < desc.array_size; ++slice)
{
for (uint32_t mip = 0; mip < desc.mip_levels; ++mip)
{
SubresourceData& subresourceData = initdata_stack[subresource_index++];
subresourceData.data_ptr = filedata + header.mip_offset(mip, slice);
subresourceData.row_pitch = header.row_pitch(mip);
subresourceData.slice_pitch = header.slice_pitch(mip);
}
}
int mip_offset = 0;
if (has_flag(flags, Flags::STREAMING))
{
@@ -806,6 +820,7 @@ namespace wi
streaming_data.slice_pitch = header.slice_pitch(mip);
}
}
// Reduce mip map count that will be uploaded to GPU:
while (desc.mip_levels > 1 && desc.depth == 1 && desc.array_size == 1 && ComputeTextureMemorySizeInBytes(desc) > streaming_texture_min_size)
{
desc.width >>= 1;
@@ -816,7 +831,7 @@ namespace wi
resource->streaming_texture.min_lod_clamp_absolute = (float)mip_offset;
}
success = device->CreateTexture(&desc, initdata.data() + mip_offset, &resource->texture);
success = device->CreateTexture(&desc, initdata + mip_offset, &resource->texture);
device->SetName(&resource->texture, name.c_str());
Format srgb_format = GetFormatSRGB(desc.format);
+10
View File
@@ -5021,6 +5021,8 @@ namespace wi::scene
if ((filterMask & FILTER_COLLIDER) && collider_bvh.IsValid())
{
collider_bvh.Intersects(ray, 0, [&](uint32_t collider_index) {
if (colliders.GetCount() <= collider_index)
return;
const ColliderComponent& collider = colliders_cpu[collider_index];
if ((collider.layerMask & layerMask) == 0)
@@ -5246,6 +5248,8 @@ namespace wi::scene
if ((filterMask & FILTER_COLLIDER) && collider_bvh.IsValid())
{
collider_bvh.IntersectsFirst(ray, [&](uint32_t collider_index) {
if (colliders.GetCount() <= collider_index)
return false;
const ColliderComponent& collider = colliders_cpu[collider_index];
if ((collider.layerMask & layerMask) == 0)
@@ -5413,6 +5417,8 @@ namespace wi::scene
if ((filterMask & FILTER_COLLIDER) && collider_bvh.IsValid())
{
collider_bvh.Intersects(sphere, 0, [&](uint32_t collider_index) {
if (colliders.GetCount() <= collider_index)
return;
const ColliderComponent& collider = colliders_cpu[collider_index];
if ((collider.layerMask & layerMask) == 0)
@@ -5694,6 +5700,8 @@ namespace wi::scene
if ((filterMask & FILTER_COLLIDER) && collider_bvh.IsValid())
{
collider_bvh.Intersects(capsule_aabb, 0, [&](uint32_t collider_index) {
if (colliders.GetCount() <= collider_index)
return;
const ColliderComponent& collider = colliders_cpu[collider_index];
if ((collider.layerMask & layerMask) == 0)
@@ -6877,6 +6885,8 @@ namespace wi::scene
if (colliders_cpu != nullptr)
{
collider_bvh.Intersects(tail_sphere, 0, [&](uint32_t collider_index) {
if (colliders.GetCount() <= collider_index)
return;
const ColliderComponent& collider = colliders_cpu[collider_index];
float dist = 0;
+2 -2
View File
@@ -9,7 +9,7 @@ namespace wi::version
// minor features, major updates, breaking compatibility changes
const int minor = 71;
// minor bug fixes, alterations, refactors, updates
const int revision = 475;
const int revision = 476;
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);
@@ -50,7 +50,7 @@ All contributors: https://github.com/turanszkij/WickedEngine/graphs/contributors
Patreon supporters
---------------------------
Nemerle, James Webb, Quifeng Jin, TheGameCreators, Joseph Goldin, Yuri, Sergey K, Yukawa Kanta, Dragon Josh, John, LurkingNinja, Bernardo Del Castillo, Invictus, Scott Hunt, Yazan Altaki, Tuan NV, Robert MacGregor, cybernescence, Alexander Dahlin, blueapples, Delhills, NI NI, Sherief, ktopoet, Justin Macklin, Cédric Fabre, TogetherTeam, Bartosz Boczula, Arne Koenig, Ivan Trajchev, nathants, Fahd Ahmed, Gabriel Jadderson, SAS_Controller, Dominik Madarász, Segfault, Mike amanfo, Dennis Brakhane, rookie, Peter Moore, therealjtgill, Nicolas Embleton, Desuuc, radino1977, Anthony Curtis, manni heck, Matthias Hölzl, Phyffer, Lucas Pinheiro, Tapkaara, gpman, Anthony Python, Gnowos, Klaus, slaughternaut, Paul Brain, Connor Greaves, Alexandr, Lee Bamber, MCAlarm MC2, Titoutan, Willow, Aldo, lokimx, K. Osterman, Nomad, ykl, Alex Krokos, Timmy, Avaflow, mat, Hexegonel Samael Michael, Joe Spataro, soru
Nemerle, James Webb, Quifeng Jin, TheGameCreators, Joseph Goldin, Yuri, Sergey K, Yukawa Kanta, Dragon Josh, John, LurkingNinja, Bernardo Del Castillo, Invictus, Scott Hunt, Yazan Altaki, Tuan NV, Robert MacGregor, cybernescence, Alexander Dahlin, blueapples, Delhills, NI NI, Sherief, ktopoet, Justin Macklin, Cédric Fabre, TogetherTeam, Bartosz Boczula, Arne Koenig, Ivan Trajchev, nathants, Fahd Ahmed, Gabriel Jadderson, SAS_Controller, Dominik Madarász, Segfault, Mike amanfo, Dennis Brakhane, rookie, Peter Moore, therealjtgill, Nicolas Embleton, Desuuc, radino1977, Anthony Curtis, manni heck, Matthias Hölzl, Phyffer, Lucas Pinheiro, Tapkaara, gpman, Anthony Python, Gnowos, Klaus, slaughternaut, Paul Brain, Connor Greaves, Alexandr, Lee Bamber, MCAlarm MC2, Titoutan, Willow, Aldo, lokimx, K. Osterman, Nomad, ykl, Alex Krokos, Timmy, Avaflow, mat, Hexegonel Samael Michael, Joe Spataro, soru, GeniokV, Mammoth
)";
return credits;