LuisaCompute icon indicating copy to clipboard operation
LuisaCompute copied to clipboard

当采用xmake构建,启用cpu后端来运行时,会出现 'swapchain context is not initialized' 错误

Open hanasaki666 opened this issue 1 year ago • 1 comments

Describe the bug

报错信息:

panic occurred: 'swapchain context is not initialized' in file 'luisa_compute_backend_impl\src\cpu\mod.rs' at line 190

我尝试过以clang-cl和llvm作为toolchain,都会出现这个panic,而使用cmake构建是能正常运行的,我怀疑可能是xmake构建时一些构建配置没能正确传递给rust那边

为了能成功构建,我改了scripts\xmake_func.lua里对 “Windows SDK”的要求:

if #vers > 2 then
    --if tonumber(vers[3]) >= 22000 then 这行是原代码,被我注释掉了
    if tonumber(vers[3]) >= 20348 then
        legal_sdk = true
    end
end

构建时使用的scripts\options.lua

lc_toolchain = {
	toolchain = "clang-cl",
}
function get_options()
	return {
		cpu_backend = true,
		enable_api = true,
		-- enable_clangcxx = true,
		enable_custom_malloc = true,
		enable_ir = true,
	}
end

生成的.xmake\windows\x64\xmake.conf

{
    __toolchains_windows_x64 = {
        "clang-cl"
    },
    _lc_bin_dir = [[bin\release]],
    _lc_check_env = true,
    _lc_enable_py = false,
    _lc_enable_rust = true,
    arch = "x64",
    bin_dir = "bin",
    buildir = "build",
    ccache = true,
    clean = true,
    cpu_backend = true,
    cuda = [[D:\cuda]],
    cuda_backend = true,
    cuda_ext_lcub = false,
    dx_backend = true,
    enable_api = true,
    enable_clangcxx = false,
    enable_custom_malloc = true,
    enable_dsl = true,
    enable_gui = true,
    enable_ir = true,
    enable_mimalloc = true,
    enable_osl = true,
    enable_simd = true,
    enable_tests = true,
    enable_unity_build = true,
    external_marl = false,
    host = "windows",
    kind = "static",
    metal_backend = false,
    mode = "release",
    ndk_stdcxx = true,
    network = "public",
    plat = "windows",
    proxy_pac = "pac.lua",
    py_include = false,
    py_libs = false,
    py_linkdir = false,
    sdk_dir = false,
    theme = "default",
    toolchain = "clang-cl",
    vk_backend = false,
    vs = "2022"
}

Expected behavior 可以成功以cpu作为后端来运行需要swapchain的tests(比如test_path_tracing)

Desktop (please complete the following information):

  • OS: Windows 10
  • Version 22H2

hanasaki666 avatar May 05 '24 05:05 hanasaki666

@MaxwellGengYF 请帮忙检查

Mike-Leo-Smith avatar May 14 '24 06:05 Mike-Leo-Smith

Fixed in next branch.

MaxwellGengYF avatar May 21 '24 04:05 MaxwellGengYF