diff --git a/.idea/vcs.xml b/.idea/vcs.xml index d362b1b..23335e3 100644 --- a/.idea/vcs.xml +++ b/.idea/vcs.xml @@ -2,6 +2,6 @@ - + \ No newline at end of file diff --git a/spirv-to-dxil-sys/Cargo.toml b/spirv-to-dxil-sys/Cargo.toml index 20c1d2c..a9f8432 100644 --- a/spirv-to-dxil-sys/Cargo.toml +++ b/spirv-to-dxil-sys/Cargo.toml @@ -6,7 +6,6 @@ edition = "2021" [lib] crate-type = ["cdylib"] -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [build-dependencies] bindgen = "0.63.0" diff --git a/spirv-to-dxil-sys/build.rs b/spirv-to-dxil-sys/build.rs index 77ee3b7..83e360f 100644 --- a/spirv-to-dxil-sys/build.rs +++ b/spirv-to-dxil-sys/build.rs @@ -15,11 +15,18 @@ fn main() { let object_dst = cmake_dst.join("build/mesa/lib"); + // let vulkan_util_dst = cmake_dst.join("build/mesa/src/mesa/src/vulkan/util"); let header_dst = cmake_dst.join("build/mesa/src/mesa/src/microsoft/spirv_to_dxil"); let header_compiler_dst = cmake_dst.join("build/mesa/src/mesa/src/microsoft/compiler"); + if cfg!(target_os = "windows") { + println!("cargo:rustc-link-lib=Version"); + println!("cargo:rustc-link-lib=synchronization"); + } + println!("cargo:rustc-link-search=native={}", object_dst.display()); println!("cargo:rustc-link-lib=static=spirv_to_dxil"); + println!("cargo:rustc-link-lib=static=vulkan_util"); eprintln!("{:?}", cmake_dst); let bindings = bindgen::Builder::default() diff --git a/spirv-to-dxil-sys/native/CMakeLists.txt b/spirv-to-dxil-sys/native/CMakeLists.txt index d7efc96..4901d64 100644 --- a/spirv-to-dxil-sys/native/CMakeLists.txt +++ b/spirv-to-dxil-sys/native/CMakeLists.txt @@ -2,7 +2,6 @@ cmake_minimum_required(VERSION 3.6) project(native-spirv-to-dxil) include(ExternalProject) - # need python find_package(Python COMPONENTS Interpreter REQUIRED) if(DEFINED ENV{VIRTUAL_ENV} OR DEFINED ENV{CONDA_PREFIX}) @@ -11,33 +10,34 @@ else() set(_pip_args "--user") endif() +find_program(PIP_EXE pip) +if(PIP_EXE STREQUAL "PIP_EXE-NOTFOUND") + message(FATAL_ERROR "pip required") +endif(PIP_EXE STREQUAL "PIP_EXE-NOTFOUND") + execute_process(COMMAND ${Python_EXECUTABLE} -m pip install mako) -find_program(LEX_EXE - flex - ) -if(LEX_EXE STREQUAL "LEX_EXE-NOTFOUND") - message(FATAL_ERROR "flex (lex) required to build NIR and GLSL compiler") -endif(LEX_EXE STREQUAL "LEX_EXE-NOTFOUND") - -find_program(YACC_EXE - bison - ) -if(YACC_EXE STREQUAL "YACC_EXE-NOTFOUND") - message(FATAL_ERROR "bison (yacc) required to build NIR and GLSL compiler") -endif(YACC_EXE STREQUAL "YACC_EXE-NOTFOUND") +string(TOLOWER ${CMAKE_BUILD_TYPE} MESON_BUILD_TYPE) set(MESA_EXTRA_FLAGS - -Dbuildtype=release - -Dgallium-drivers= + -Dbuildtype=${MESON_BUILD_TYPE} + # force zink because we want libvulkan_util + -Dgallium-drivers=zink + -Dvulkan-drivers= + -Dopengl=false -Dglx=disabled + -Dmicrosoft-clc=disabled + -Dgallium-d3d12-video=disabled + -Dmin-windows-version=10 -Dgbm=disabled -Degl=disabled -Dgles1=disabled -Dgles2=disabled + -Dllvm=disabled -Dshared-llvm=disabled -Dspirv-to-dxil=true -Dplatforms=auto + -Dzlib=disabled ) @@ -45,8 +45,8 @@ ExternalProject_Add(mesa URL file://${CMAKE_CURRENT_LIST_DIR}/mesa PREFIX ${CMAKE_BINARY_DIR}/mesa CONFIGURE_COMMAND cd ${CMAKE_BINARY_DIR}/mesa/src/mesa && meson setup ${CMAKE_BINARY_DIR}/mesa/src/mesa-build ${MESA_EXTRA_FLAGS} - BUILD_COMMAND cd ${CMAKE_BINARY_DIR}/mesa/src/mesa-build && ninja src/microsoft/spirv_to_dxil/libspirv_to_dxil.a + BUILD_COMMAND cd ${CMAKE_BINARY_DIR}/mesa/src/mesa-build && ninja src/vulkan/util/libvulkan_util.a && ninja src/microsoft/spirv_to_dxil/libspirv_to_dxil.a INSTALL_COMMAND cmake -DOUT_DIR=${CMAKE_BINARY_DIR}/mesa -DMESA_BUILD=${CMAKE_BINARY_DIR}/mesa/src/mesa-build -P ${CMAKE_CURRENT_LIST_DIR}/install_spirv_to_dxil.cmake - BUILD_BYPRODUCTS ${CMAKE_BINARY_DIR}/mesa/lib/spirv_to_dxil.lib ${CMAKE_BINARY_DIR}/mesa/lib/libspirv_to_dxil.a + BUILD_BYPRODUCTS ${CMAKE_BINARY_DIR}/mesa/lib/spirv_to_dxil.lib ${CMAKE_BINARY_DIR}/mesa/lib/libspirv_to_dxil.a ${CMAKE_BINARY_DIR}/mesa/lib/vulkan_util.lib ${CMAKE_BINARY_DIR}/mesa/lib/libvulkan_util.a ) diff --git a/spirv-to-dxil-sys/native/install_spirv_to_dxil.cmake b/spirv-to-dxil-sys/native/install_spirv_to_dxil.cmake index 391f7da..f829931 100644 --- a/spirv-to-dxil-sys/native/install_spirv_to_dxil.cmake +++ b/spirv-to-dxil-sys/native/install_spirv_to_dxil.cmake @@ -1,5 +1,7 @@ file(INSTALL ${MESA_BUILD}/src/microsoft/spirv_to_dxil/libspirv_to_dxil.a DESTINATION ${OUT_DIR}/lib) +file(INSTALL ${MESA_BUILD}/src/vulkan/util/libvulkan_util.a DESTINATION ${OUT_DIR}/lib) if (WIN32) + file(RENAME ${OUT_DIR}/lib/libvulkan_util.a ${OUT_DIR}/lib/vulkan_util.lib) file(RENAME ${OUT_DIR}/lib/libspirv_to_dxil.a ${OUT_DIR}/lib/spirv_to_dxil.lib) endif() \ No newline at end of file diff --git a/spirv-to-dxil-sys/native/wrapper.h b/spirv-to-dxil-sys/native/wrapper.h index e9c4734..88cb379 100644 --- a/spirv-to-dxil-sys/native/wrapper.h +++ b/spirv-to-dxil-sys/native/wrapper.h @@ -1,2 +1 @@ #include "spirv_to_dxil.h" - diff --git a/spirv-to-dxil-sys/src/lib.rs b/spirv-to-dxil-sys/src/lib.rs index 365c7c2..5518aac 100644 --- a/spirv-to-dxil-sys/src/lib.rs +++ b/spirv-to-dxil-sys/src/lib.rs @@ -16,7 +16,8 @@ mod tests { #[test] fn it_works() { - let result = add(2, 2); - assert_eq!(result, 4); + unsafe { + eprintln!("{:x?}", spirv_to_dxil_get_version()); + } } }