Skip to content

Commit

Permalink
Merge pull request #169 from pattakosn/more-fixes
Browse files Browse the repository at this point in the history
more linux fixes
  • Loading branch information
PanosK92 authored Feb 13, 2025
2 parents 47f102f + 644f61d commit 2bbb038
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 18 deletions.
2 changes: 1 addition & 1 deletion runtime/Core/ThreadPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ namespace spartan
future<void> ThreadPool::AddTask(Task&& task)
{
// create a packaged task that will give us a future
auto packaged_task = make_shared<std::packaged_task<void()>>(forward<Task>(task));
auto packaged_task = make_shared<std::packaged_task<void()>>(std::forward<Task>(task));

// get the future before we move the packaged_task into the lambda
future<void> future = packaged_task->get_future();
Expand Down
1 change: 0 additions & 1 deletion runtime/Logging/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

//= INCLUDES =================
#include "pch.h"
#include "ILogger.h"
#include "../World/Entity.h"
#include "../Core/Debugging.h"
//============================
Expand Down
1 change: 1 addition & 0 deletions runtime/Logging/Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//= INCLUDES ===================
#include <string>
#include <memory>
#include "ILogger.h"
//==============================

namespace spartan
Expand Down
1 change: 1 addition & 0 deletions runtime/Math/Helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

//= INCLUDES ====
#include <random>
#include <algorithm>
//===============

namespace spartan::math
Expand Down
12 changes: 6 additions & 6 deletions runtime/Math/Matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,13 +256,13 @@ namespace spartan::math
zs * sqrt(_mm_cvtss_f32(square2))
);
#else
const int xs = (Sign(m00 * m01 * m02 * m03) < 0) ? -1 : 1;
const int ys = (Sign(m10 * m11 * m12 * m13) < 0) ? -1 : 1;
const int zs = (Sign(m20 * m21 * m22 * m23) < 0) ? -1 : 1;
const int xs = (sign(m00 * m01 * m02 * m03) < 0) ? -1 : 1;
const int ys = (sign(m10 * m11 * m12 * m13) < 0) ? -1 : 1;
const int zs = (sign(m20 * m21 * m22 * m23) < 0) ? -1 : 1;
return Vector3(
static_cast<float>(xs) * Sqrt(m00 * m00 + m01 * m01 + m02 * m02),
static_cast<float>(ys) * Sqrt(m10 * m10 + m11 * m11 + m12 * m12),
static_cast<float>(zs) * Sqrt(m20 * m20 + m21 * m21 + m22 * m22)
static_cast<float>(xs) * sqrt(m00 * m00 + m01 * m01 + m02 * m02),
static_cast<float>(ys) * sqrt(m10 * m10 + m11 * m11 + m12 * m12),
static_cast<float>(zs) * sqrt(m20 * m20 + m21 * m21 + m22 * m22)
);
#endif
}
Expand Down
4 changes: 2 additions & 2 deletions runtime/Math/Vector3.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ namespace spartan::math
z = _mm_cvtss_f32(_mm_shuffle_ps(vec, vec, _MM_SHUFFLE(2, 2, 2, 2)));
#else
// fallback to scalar path
const auto length_inverted = 1.0f / Sqrt(length_squared);
const auto length_inverted = 1.0f / sqrt(length_squared);
x *= length_inverted;
y *= length_inverted;
z *= length_inverted;
Expand Down Expand Up @@ -155,7 +155,7 @@ namespace spartan::math
return _mm_cvtss_f32(length);
#else
// Fallback to scalar path
return Sqrt(x * x + y * y + z * z);
return sqrt(x * x + y * y + z * z);
#endif
}

Expand Down
1 change: 1 addition & 0 deletions runtime/RHI/RHI_Shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#pragma once

//= INCLUDES =====================
#include <atomic>
#include <memory>
#include <string>
#include <unordered_map>
Expand Down
2 changes: 1 addition & 1 deletion runtime/RHI/RHI_Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ namespace spartan
// move the target mip to the top
if (target_mip > 0)
{
m_slices[0].mips[0] = move(m_slices[0].mips[target_mip]);
m_slices[0].mips[0] = std::move(m_slices[0].mips[target_mip]);
m_width = max(1u, m_width >> target_mip);
m_height = max(1u, m_height >> target_mip);
}
Expand Down
16 changes: 16 additions & 0 deletions runtime/RHI/Vulkan/Vulkan_FidelityFX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,7 @@ namespace spartan

void RHI_FidelityFX::Shutdown(const FidelityFX fx)
{
#ifdef _MSC_VER
if (fx == FidelityFX::Sssr)
{
sssr::context_destroy();
Expand All @@ -942,6 +943,7 @@ namespace spartan
{
fsr3::context_destroy();
}
#endif
}

void RHI_FidelityFX::Tick(Cb_Frame* cb_frame)
Expand Down Expand Up @@ -1464,6 +1466,7 @@ namespace spartan

void RHI_FidelityFX::BrixelizerGI_SetResolutionPercentage(const float resolution_percentage)
{
#ifdef _MSC_VER
if (resolution_percentage == 0.25f)
{
brixelizer_gi::internal_resolution = FFX_BRIXELIZER_GI_INTERNAL_RESOLUTION_25_PERCENT;
Expand All @@ -1486,10 +1489,12 @@ namespace spartan
}

brixelizer_gi::context_create();
#endif
}

void RHI_FidelityFX::Breadcrumbs_RegisterCommandList(RHI_CommandList* cmd_list, const RHI_Queue* queue, const char* name)
{
#ifdef _MSC_VER
// note: command lists need to register per frame
SP_ASSERT(Debugging::IsBreadcrumbsEnabled());

Expand All @@ -1501,10 +1506,12 @@ namespace spartan
description.submissionIndex = 0;

SP_ASSERT(ffxBreadcrumbsRegisterCommandList(&breadcrumbs::context, &description) == FFX_OK);
#endif
}

void RHI_FidelityFX::Breadcrumbs_RegisterPipeline(RHI_Pipeline* pipeline)
{
#ifdef _MSC_VER
// note: pipelines need to register only once

SP_ASSERT(Debugging::IsBreadcrumbsEnabled());
Expand Down Expand Up @@ -1541,31 +1548,39 @@ namespace spartan
}

SP_ASSERT(ffxBreadcrumbsRegisterPipeline(&breadcrumbs::context, &description) == FFX_OK);
#endif
}

void RHI_FidelityFX::Breadcrumbs_SetPipelineState(RHI_CommandList* cmd_list, RHI_Pipeline* pipeline)
{
#ifdef _MSC_VER
SP_ASSERT(Debugging::IsBreadcrumbsEnabled());
SP_ASSERT(ffxBreadcrumbsSetPipeline(&breadcrumbs::context, to_ffx_cmd_list(cmd_list), to_ffx_pipeline(pipeline)) == FFX_OK);
#endif
}

void RHI_FidelityFX::Breadcrumbs_MarkerBegin(RHI_CommandList* cmd_list, const char* name)
{
#ifdef _MSC_VER
lock_guard<mutex> lock(breadcrumbs::mutex_marker_start); // without a mutex, after loading a world, a gpu crash can occur
SP_ASSERT(Debugging::IsBreadcrumbsEnabled());
const FfxBreadcrumbsNameTag name_tag = { name, true };
SP_ASSERT(ffxBreadcrumbsBeginMarker(&breadcrumbs::context, to_ffx_cmd_list(cmd_list), FFX_BREADCRUMBS_MARKER_PASS, &name_tag) == FFX_OK);
#endif
}

void RHI_FidelityFX::Breadcrumbs_MarkerEnd(RHI_CommandList* cmd_list)
{
#ifdef _MSC_VER
lock_guard<mutex> lock(breadcrumbs::mutex_marker_end); // without a mutex, after loading a world, a gpu crash can occur
SP_ASSERT(Debugging::IsBreadcrumbsEnabled());
SP_ASSERT(ffxBreadcrumbsEndMarker(&breadcrumbs::context, to_ffx_cmd_list(cmd_list)) == FFX_OK);
#endif
}

void RHI_FidelityFX::Breadcrumbs_OnDeviceRemoved()
{
#ifdef _MSC_VER
FfxBreadcrumbsMarkersStatus marker_status = {};
SP_ASSERT(ffxBreadcrumbsPrintStatus(&breadcrumbs::context, &marker_status) == FFX_OK);

Expand All @@ -1579,5 +1594,6 @@ namespace spartan
}

FFX_SAFE_FREE(marker_status.pBuffer, free);
#endif
}
}
4 changes: 2 additions & 2 deletions runtime/RHI/Vulkan/Vulkan_SwapChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ namespace spartan
SP_ASSERT(m_sdl_window != nullptr);

// create surface
VkSurfaceKHR surface = nullptr;
VkSurfaceKHR surface = VK_NULL_HANDLE;
{
SP_ASSERT_MSG(
SDL_Vulkan_CreateSurface(static_cast<SDL_Window*>(m_sdl_window), RHI_Context::instance, nullptr, &surface),
Expand Down Expand Up @@ -244,7 +244,7 @@ namespace spartan
m_height = clamp(m_height, capabilities.minImageExtent.height, capabilities.maxImageExtent.height);

// swap chain
VkSwapchainKHR swap_chain = nullptr;
VkSwapchainKHR swap_chain = VK_NULL_HANDLE;
{
VkSwapchainCreateInfoKHR create_info = {};
create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
Expand Down
12 changes: 8 additions & 4 deletions runtime/Rendering/Renderer_Passes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -946,6 +946,7 @@ namespace spartan
{
cmd_list->BeginTimeblock("ssr");

#ifdef _MSC_VER
RHI_FidelityFX::SSSR_Dispatch(
cmd_list,
GetOption<float>(Renderer_Option::ResolutionScale),
Expand All @@ -957,7 +958,7 @@ namespace spartan
GetRenderTarget(Renderer_RenderTarget::brdf_specular_lut),
GetRenderTarget(Renderer_RenderTarget::ssr)
);

#endif
cleared = false;

cmd_list->EndTimeblock();
Expand Down Expand Up @@ -1179,7 +1180,7 @@ namespace spartan
if (GetOption<float>(Renderer_Option::GlobalIllumination) != 0.0f && m_initialized_third_party)
{
cmd_list->BeginTimeblock("light_global_illumination");

#ifdef _MSC_VER
// update
{
vector<shared_ptr<Entity>>& entities = m_renderables[Renderer_Entity::Mesh];
Expand All @@ -1196,7 +1197,7 @@ namespace spartan
GetRenderTarget(Renderer_RenderTarget::light_diffuse_gi) // use as debug output (if needed)
);
}

#endif
// dispatch
{
static array<RHI_Texture*, 8> noise_textures =
Expand All @@ -1210,7 +1211,7 @@ namespace spartan
GetStandardTexture(Renderer_StandardTexture::Noise_blue_6),
GetStandardTexture(Renderer_StandardTexture::Noise_blue_7)
};

#ifdef _MSC_VER
RHI_FidelityFX::BrixelizerGI_Dispatch(
cmd_list,
&m_cb_frame_cpu,
Expand All @@ -1224,6 +1225,7 @@ namespace spartan
GetRenderTarget(Renderer_RenderTarget::light_specular_gi),
GetRenderTarget(Renderer_RenderTarget::light_diffuse_gi) // use as debug output (if needed)
);
#endif
}

cleared = false;
Expand Down Expand Up @@ -1769,6 +1771,7 @@ namespace spartan

if (GetOption<Renderer_Upsampling>(Renderer_Option::Upsampling) == Renderer_Upsampling::Fsr3 && m_initialized_third_party)
{
#ifdef _MSC_VER
RHI_FidelityFX::FSR3_Dispatch(
cmd_list,
GetCamera().get(),
Expand All @@ -1781,6 +1784,7 @@ namespace spartan
GetRenderTarget(Renderer_RenderTarget::gbuffer_velocity),
tex_out
);
#endif
}
else // no upscale or linear upscale
{
Expand Down
2 changes: 2 additions & 0 deletions runtime/Rendering/Renderer_Resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ namespace spartan
render_target(Renderer_RenderTarget::skysphere) = make_shared<RHI_Texture>(RHI_Texture_Type::Type2D, 4096, 4096, 1, mip_count, RHI_Format::R11G11B10_Float, flags | RHI_Texture_PerMipViews, "skysphere");
}

#ifdef _MSC_VER
RHI_FidelityFX::Resize(GetResolutionRender(), GetResolutionOutput());
#endif
}

void Renderer::CreateShaders()
Expand Down
2 changes: 1 addition & 1 deletion runtime/Resource/IResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ namespace spartan
ResourceType GetResourceType() const { return m_resource_type; }
const char* GetResourceTypeCstr() const { return typeid(*this).name(); }
const std::string& GetResourceFilePath() const { return m_resource_file_path; }
const std::string& GetResourceDirectory() const { return FileSystem::GetDirectoryFromFilePath(m_resource_file_path); }
const std::string GetResourceDirectory() const { return FileSystem::GetDirectoryFromFilePath(m_resource_file_path); }

// flags
void SetFlag(const uint32_t flag, bool enabled = true)
Expand Down
1 change: 1 addition & 0 deletions runtime/Resource/ResourceCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "../Logging/Log.h"
#include <mutex>
#include "../Rendering/Material.h"
#include <algorithm>
//================================

namespace spartan
Expand Down

0 comments on commit 2bbb038

Please sign in to comment.