Skip to content

Commit

Permalink
Merge branch 'next' of github.com:LuisaGroup/LuisaCompute into dev-fa…
Browse files Browse the repository at this point in the history
…llback-backend
  • Loading branch information
Mike-Leo-Smith committed Jan 7, 2025
2 parents 251d64e + 5675868 commit 11875a1
Show file tree
Hide file tree
Showing 11 changed files with 100 additions and 27 deletions.
19 changes: 19 additions & 0 deletions include/luisa/backends/ext/dx_hdr_ext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,23 @@ namespace luisa::compute {
Swapchain DXHDRExt::create_swapchain(const Stream &stream, const DXSwapchainOption &option) noexcept {
return Swapchain{stream.device(), create_swapchain(option, stream.handle())};
}
void DXHDRExt::set_color_space(
Swapchain const &swapchain,
ColorSpace const &color_space) const noexcept {
set_color_space(swapchain.handle(), color_space);
}
auto DXHDRExt::set_hdr_meta_data(
Swapchain const &swapchain,
float max_output_nits,
float min_output_nits,
float max_cll,
float max_fall,
const DisplayChromaticities *custom_chroma) noexcept -> Meta {
return set_hdr_meta_data(
swapchain.handle(),
max_output_nits,
min_output_nits,
max_cll,
max_fall);
}
}// namespace luisa::compute
17 changes: 14 additions & 3 deletions include/luisa/backends/ext/dx_hdr_ext_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ class DXHDRExt : public DeviceExtension {
};

struct Meta {
ColorSpace color_space;
DisplayChromaticities chromaticities;
};

Expand All @@ -80,8 +79,20 @@ class DXHDRExt : public DeviceExtension {
const DisplayChromaticities *custom_chroma = nullptr) noexcept = 0;
static constexpr luisa::string_view name = "DXHDRExt";
[[nodiscard]] Swapchain create_swapchain(const Stream &stream, const DXSwapchainOption &option) noexcept;
[[nodiscard]] virtual bool device_support_hdr() const = 0;

[[nodiscard]] virtual bool device_support_hdr() const noexcept = 0;
virtual void set_color_space(
uint64_t handle,
ColorSpace const &color_space) const noexcept = 0;
void set_color_space(
Swapchain const& swapchain,
ColorSpace const &color_space) const noexcept;
Meta set_hdr_meta_data(
Swapchain const& swapchain,
float max_output_nits = 1000.0f,
float min_output_nits = 0.001f,
float max_cll = 2000.0f,
float max_fall = 500.0f,
const DisplayChromaticities *custom_chroma = nullptr) noexcept;
protected:
~DXHDRExt() = default;
};
Expand Down
15 changes: 11 additions & 4 deletions src/backends/dx/DXApi/dx_hdr_ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ DXHDRExt::DisplayCurve EnsureSwapChainColorSpace(
IDXGISwapChain4 *swapChain,
DXGI_COLOR_SPACE_TYPE &currentSwapChainColorSpace,
DXHDRExt::SwapChainBitDepth swapChainBitDepth,
bool enableST2084) {
bool enableST2084) noexcept {
DXHDRExt::DisplayCurve result{DXHDRExt::DisplayCurve::None};
DXGI_COLOR_SPACE_TYPE colorSpace = DXGI_COLOR_SPACE_RGB_FULL_G22_NONE_P709;
switch (swapChainBitDepth) {
Expand Down Expand Up @@ -50,7 +50,7 @@ DXHDRExt::DisplayChromaticities SetHDRMetaData(
float MinOutputNits /*=0.001f*/,
float MaxCLL /*=2000.0f*/,
float MaxFALL /*=500.0f*/,
const DXHDRExt::DisplayChromaticities *Chroma) {
const DXHDRExt::DisplayChromaticities *Chroma) noexcept {
if (!swapchain) {
return {};
}
Expand Down Expand Up @@ -186,10 +186,17 @@ auto DXHDRExtImpl::set_hdr_meta_data(
max_fall,
custom_chroma);
return {
static_cast<ColorSpace>(color_space),
chroma};
}
bool DXHDRExtImpl::device_support_hdr() const {
void DXHDRExtImpl::set_color_space(
uint64_t handle,
ColorSpace const &color_space) const noexcept {
auto swapChain = reinterpret_cast<LCSwapChain *>(handle);
ComPtr<IDXGISwapChain3> swapChain3;
ThrowIfFailed(swapChain->swapChain->QueryInterface(IID_PPV_ARGS(&swapChain3)));
swapChain3->SetColorSpace1(static_cast<DXGI_COLOR_SPACE_TYPE>(color_space));
}
bool DXHDRExtImpl::device_support_hdr() const noexcept {
return _device_support_hdr;
}
}// namespace lc::dx
6 changes: 5 additions & 1 deletion src/backends/dx/DXApi/dx_hdr_ext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
#include <luisa/backends/ext/dx_hdr_ext_interface.h>
#include <DXApi/LCDevice.h>
namespace lc::dx {

class DXHDRExtImpl : public luisa::compute::DXHDRExt {
LCDevice *_lc_device;
bool _device_support_hdr = false;
bool device_support_hdr() const override;
bool device_support_hdr() const noexcept override;
public:
DXHDRExtImpl(LCDevice *lc_device);
~DXHDRExtImpl();
Expand All @@ -19,5 +20,8 @@ class DXHDRExtImpl : public luisa::compute::DXHDRExt {
float max_cll = 2000.0f,
float max_fall = 500.0f,
const DXHDRExt::DisplayChromaticities *custom_chroma = nullptr) noexcept override;
void set_color_space(
uint64_t handle,
ColorSpace const &color_space) const noexcept override;
};
}// namespace lc::dx
9 changes: 7 additions & 2 deletions src/backends/validation/dx_hdr_ext_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ using namespace luisa::compute;
class DXHDRExtImpl : public DXHDRExt, public vstd::IOperatorNewBase {
public:
DXHDRExt *ptr;
DXHDRExtImpl(DXHDRExt *ptr) : ptr(ptr) {}
DXHDRExtImpl(DXHDRExt *ptr) noexcept : ptr(ptr) {}
SwapchainCreationInfo create_swapchain(
const DXSwapchainOption &option,
uint64_t stream_handle) noexcept override;
Expand All @@ -21,9 +21,14 @@ class DXHDRExtImpl : public DXHDRExt, public vstd::IOperatorNewBase {
float max_cll = 2000.0f,
float max_fall = 500.0f,
const DisplayChromaticities *custom_chroma = nullptr) noexcept override;
bool device_support_hdr() const override {
bool device_support_hdr() const noexcept override {
return ptr->device_support_hdr();
}
void set_color_space(
uint64_t handle,
ColorSpace const &color_space) const noexcept {
ptr->set_color_space(handle, color_space);
}
};

}// namespace lc::validation
31 changes: 24 additions & 7 deletions src/backends/validation/stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,30 @@ void Stream::check_compete() {
detail::usage_name(iter.second.usage),
get_name());
} else {
LUISA_WARNING(
"Simultaneous-accessible resource {} is used to be {} by {} and {} by {} simultaneously.",
res->get_name(),
detail::usage_name(stream_iter.second.usage),
other_stream->get_name(),
detail::usage_name(iter.second.usage),
get_name());
switch (res->tag()) {
case Resource::Tag::BUFFER:
case Resource::Tag::TEXTURE:
case Resource::Tag::BINDLESS_ARRAY:
case Resource::Tag::MESH:
case Resource::Tag::CURVE:
case Resource::Tag::PROCEDURAL_PRIMITIVE:
case Resource::Tag::MOTION_INSTANCE:
case Resource::Tag::ACCEL:
case Resource::Tag::SWAP_CHAIN:
case Resource::Tag::DEPTH_BUFFER:
case Resource::Tag::SPARSE_BUFFER:
case Resource::Tag::SPARSE_TEXTURE:
case Resource::Tag::SPARSE_BUFFER_HEAP:
case Resource::Tag::SPARSE_TEXTURE_HEAP:
LUISA_WARNING(
"Simultaneous-accessible resource {} is used to be {} by {} and {} by {} simultaneously.",
res->get_name(),
detail::usage_name(stream_iter.second.usage),
other_stream->get_name(),
detail::usage_name(iter.second.usage),
get_name());
break;
}
}
}
}
Expand Down
18 changes: 13 additions & 5 deletions src/core/platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,18 @@ namespace detail {
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)&buffer,
0, nullptr);
#if UNICODE == 1
auto value = static_cast<wchar_t *>(buffer);
luisa::wstring_view err_msg_view{value};
luisa::string err_msg{reinterpret_cast<char const *>(err_msg_view.data()), err_msg_view.size() * sizeof(wchar_t)};
LocalFree(buffer);
return err_msg;
#else
auto value = static_cast<wchar_t *>(buffer);
luisa::string err_msg{fmt::format("{} (code = 0x{:x}).", static_cast<char *>(buffer), err_code)};
LocalFree(buffer);
return err_msg;
#endif
}

}// namespace detail
Expand Down Expand Up @@ -103,7 +112,7 @@ void *dynamic_module_find_symbol(void *handle, luisa::string_view name_view) noe
auto symbol = GetProcAddress(reinterpret_cast<HMODULE>(handle), name.c_str());
if (symbol == nullptr) [[unlikely]] {
LUISA_WARNING("Failed to load symbol '{}', reason: {}.",
name, detail::win32_last_error_message());
name, detail::win32_last_error_message());
}
return reinterpret_cast<void *>(symbol);
}
Expand Down Expand Up @@ -217,7 +226,7 @@ void *dynamic_module_load(const luisa::filesystem::path &path) noexcept {
auto p = path;
for (auto ext :
#ifdef LUISA_PLATFORM_APPLE
{ ".so", ".dylib" }
{".so", ".dylib"}
#else
{".so"}
#endif
Expand All @@ -228,8 +237,7 @@ void *dynamic_module_load(const luisa::filesystem::path &path) noexcept {
}
LUISA_WARNING_WITH_LOCATION(
"Failed to load dynamic module '{}', reason: {}.",
luisa::to_string(p), dlerror()
);
luisa::to_string(p), dlerror());
}

return nullptr;
Expand All @@ -246,7 +254,7 @@ void *dynamic_module_find_symbol(void *handle, luisa::string_view name_view) noe
auto symbol = dlsym(handle, name.c_str());
if (symbol == nullptr) [[unlikely]] {
LUISA_WARNING("Failed to load symbol '{}', reason: {}.",
name, dlerror());
name, dlerror());
}
LUISA_VERBOSE_WITH_LOCATION(
"Loading dynamic symbol '{}' in {} ms.",
Expand Down
6 changes: 4 additions & 2 deletions src/core/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ on_load(function(target)
if is_mode("debug") then
target:add("syslinks", "Dbghelp")
end
target:add("defines", "NOMINMAX", "LUISA_PLATFORM_WINDOWS", {
target:add("defines", "NOMINMAX", "LUISA_PLATFORM_WINDOWS", "_DISABLE_CONSTEXPR_MUTEX_CONSTRUCTOR", {
public = true
})
elseif is_plat("linux") then
Expand All @@ -39,7 +39,9 @@ on_load(function(target)
target:add("deps", "eastl", "spdlog", "lc-check-winsdk")
local marl_path = path.join(os.scriptdir(), "../ext/marl")
if (not get_config("external_marl")) and (os.exists(marl_path)) then
target:add("defines", "MARL_DLL", {public = true})
target:add("defines", "MARL_DLL", {
public = true
})
target:add("defines", "MARL_BUILDING_DLL")
target:add("files", path.join(marl_path, "src/*.c"), path.join(marl_path, "src/build.marl.cpp"))
if not is_plat("windows") then
Expand Down
2 changes: 1 addition & 1 deletion src/ext/EASTL
Submodule EASTL updated 2 files
+1 −1 packages/mimalloc
+0 −1 xmake.lua
2 changes: 1 addition & 1 deletion src/ext/xxHash

0 comments on commit 11875a1

Please sign in to comment.