Skip to content

Build Metal shaders in Makefile instead of build.rs #3047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,8 @@ before_install:
# Do not run bors builds against the nightly compiler.
# We want to find out about nightly bugs, so they're done in master, but we don't block on them.
- if [[ $TRAVIS_RUST_VERSION == "nightly" && $TRAVIS_BRANCH == "staging" ]]; then exit; fi
# Extract SDL2 .deb into a cached directory (see cache section above and LIBRARY_PATH exports below)
# Will no longer be needed when Trusty build environment goes out of beta at Travis CI
# (assuming it will have libsdl2-dev and Rust by then)
# see https://docs.travis-ci.com/user/trusty-ci-environment/
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then make travis-sdl2 && export CXX=g++-5; fi
- if [[ $TRAVIS_OS_NAME == "osx" ]]; then brew update && brew install sdl2; fi
- if [[ $TRAVIS_OS_NAME == "linux" ]]; then export CXX=g++-5; fi
- if [[ $TRAVIS_OS_NAME == "osx" ]]; then brew update; fi
- if [[ $TRAVIS_OS_NAME == "windows" ]]; then choco install make; fi
- rustup self update
- rustup target add $TARGET; true
Expand Down
26 changes: 9 additions & 17 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
RUST_BACKTRACE:=1
EXCLUDES:=
FEATURES_EXTRA:=mint serialize
FEATURES_HAL:=
FEATURES_HAL2:=
FEATURES_HAL3:=

SDL2_DEST=$(HOME)/deps
SDL2_CONFIG=$(SDL2_DEST)/usr/bin/sdl2-config
SDL2_PPA=http://ppa.launchpad.net/zoogie/sdl2-snapshots/ubuntu/pool/main/libs/libsdl2

ifeq (,$(TARGET))
CHECK_TARGET_FLAG=
else
Expand Down Expand Up @@ -44,7 +39,7 @@ else
endif


.PHONY: all check quad quad-wasm test doc reftests benches travis-sdl2
.PHONY: all check quad quad-wasm test doc reftests benches shader-binaries

all: check test

Expand All @@ -69,6 +64,7 @@ doc:

reftests:
cd src/warden && cargo run --bin reftest --features "$(FEATURES_HAL) $(FEATURES_HAL2)" -- local #TODO: gl

benches:
cd src/warden && cargo run --release --bin bench --features "$(FEATURES_HAL) $(FEATURES_HAL2)" -- blit

Expand All @@ -82,14 +78,10 @@ quad:
quad-wasm:
cd examples && cargo +nightly build --target wasm32-unknown-unknown --features gl --bin quad && wasm-bindgen ../target/wasm32-unknown-unknown/debug/quad.wasm --out-dir ../examples/generated-wasm --web

travis-sdl2:
#TODO
#if [ -e $(SDL2_CONFIG) ]; then exit 1; fi
#mkdir -p $(SDL2_DEST)
#test -f $(SDL2_DEST)/dev.deb || curl -sLo $(SDL2_DEST)/dev.deb $(SDL2_PPA)/libsdl2-dev_2.0.3+z4~20140315-8621-1ppa1precise1_amd64.deb
#test -f $(SDL2_DEST)/bin.deb || curl -sLo $(SDL2_DEST)/bin.deb $(SDL2_PPA)/libsdl2_2.0.3+z4~20140315-8621-1ppa1precise1_amd64.deb
#dpkg-deb -x $(SDL2_DEST)/bin.deb .
#dpkg-deb -x $(SDL2_DEST)/dev.deb .
#sed -e s,/usr,$(SDL2_DEST),g $(SDL2_CONFIG) > $(SDL2_CONFIG).new
#mv $(SDL2_CONFIG).new $(SDL2_CONFIG)
#chmod a+x $(SDL2_CONFIG)
shader-binaries:
ifeq ($(UNAME_S),Darwin)
cd ./src/backend/metal/shaders && \
xcrun -sdk macosx metal -c *.metal -mmacosx-version-min=10.11 && \
xcrun -sdk macosx metallib *.air -o gfx_shaders.metallib && \
rm *.air
endif
87 changes: 0 additions & 87 deletions src/backend/metal/build.rs

This file was deleted.

Binary file added src/backend/metal/shaders/gfx_shaders.metallib
Binary file not shown.
2 changes: 1 addition & 1 deletion src/backend/metal/src/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ pub struct ServicePipes {

impl ServicePipes {
pub fn new(device: &metal::DeviceRef) -> Self {
let data = include_bytes!(concat!(env!("OUT_DIR"), "/gfx_shaders.metallib"));
let data = include_bytes!("./../shaders/gfx_shaders.metallib");
let library = device.new_library_with_data(data).unwrap();

let copy_buffer = Self::create_copy_buffer(&library, device);
Expand Down