Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
416: Makefile package command and travis github releases r=kvark a=Korijn

Closes gfx-rs#414

Approach mostly mimicked from [gfx-portability](https://github.com/gfx-rs/portability) as recommended to me by @kvark. I needed a number of commits to iron out some kinks for the Windows builds, so I would recommend using squash merge when accepting this PR.

Note that the Windows rust=nightly build fails, but it's also broken on master, so it's unrelated to the changes in this PR.

/cc @almarklein

# Questions

- [x] Would it make sense to also regenerate the `ffi/wgpu.h` and `wgpu-remote.h` header files and include them in the zip archive?

# Todo for maintainers

- [x] Configure encrypted `api_key`
As in [gfx-portability](https://github.com/gfx-rs/portability/blob/master/.travis.yml#L61) you will need to create an API key and commit it to the `.travis.yml` file. I've checked "allow edits from maintainers" so you should be able to commit to this branch directly. You may want to reference the [Travis instructions](https://docs.travis-ci.com/user/deployment/releases/#authenticating-with-an-oauth-token) as well.

- [ ] Tag revisions
Previous versions (`v0.1` - `v0.4`) have not been tagged on the master branch, you will want to do so retroactively. Also, when releasing in the future, make sure to tag the commit before pushing. Alternatively, you can schedule a travis build manually after applying the tag retroactively.

420: Make Origin3d::{x,y,z} all have type u32 r=kvark a=fintelia

Fixes gfx-rs#419 

424: swapchain creation: check if selected present mode is supported r=kvark a=Veykril

Implements a simple check as talked about in gfx-rs#350 to fallback to `FIFO` should the selected present mode not be available on the system.

Co-authored-by: Korijn van Golen <[email protected]>
Co-authored-by: Korijn van Golen <[email protected]>
Co-authored-by: Jonathan Behrens <[email protected]>
Co-authored-by: Veykril <[email protected]>
  • Loading branch information
5 people committed Dec 30, 2019
4 parents 7d8a1d5 + 52de829 + 461f114 + 9eab6fc commit 890bbcf
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 26 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
.vs
build
ffi/dawn*.h
dist
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,17 @@ script:
make example-compute example-triangle VERBOSE=1;
fi
- if [[ $TRAVIS_RUST_VERSION == "nightly" ]] && [[ $TRAVIS_OS_NAME != "windows" ]]; then make VERBOSE=1; fi
- if [[ $TRAVIS_RUST_VERSION == "stable" ]]; then make package; fi

deploy:
provider: releases
api_key:
secure: kS8vjHOnLEknb2qxf2dPxMW8S5KcpjSkSgoi23WXiX3DZ2v8DIJMxVLanJhD3mbr1oI1NGXQHrTeeA/HBEEJcOVzlQo38MgNo/Jyt1k4jLRyCEDL0LjO+M1zAQGoEDWlyyjeu+Alw3SFKqGoZeuYDZ/mxUpEapFMD++8w4IjON2fI6iNumcIMeAg3Ns6Y4wHYQPzfIQQf5svI9dh1lf7PhlFB/btONBPi6rXxU/UwCnHBoOPydl5OwjggaUAjCJSf8i/FDLWt5XpvA2UsML2AbcFNuwFhNGhf6ArwEsqgcMCGL6jACetvI/l3ZL96h5dsgzRLW0ruvnvpEm3y3aw9wCjEAcnQMZCBPlIfOpj5MH/guh526QWCVQ3rwRUJOhua9T2yvwda3ICYspyVShzlbwscA9yLwvsuO+6Hl+upuE2IPfLvS6QpnXVlIWHe/3HqOoQggDdsWvnZhhGNKASKsi9vNgTvec/1iX846/KGcV3nYeHIWFrvP0IgWtEqQrgcWj9w6X7LDdaTFmrkKwKnNn4ClLQYPnlWQS71iX0gwRhONGaSAEfFca6vwVTa8AGSQUEHphe5lT7LtAy6UhlbjZNuKvUR+pn+l0EoWlZzm+uxKMtGR+mG9h6My+GA3hCWWtX/Xc94TvuJ1cg+uRu48+rD21vv3cr2fEVDRq7pGg=
file_glob: true
file: dist/wgpu-*.zip
skip_cleanup: true
overwrite: true
on:
tags: true
condition: $TRAVIS_RUST_VERSION == "stable" && $TRAVIS_BRANCH == $TRAVIS_TAG
skip_cleanup: true
44 changes: 42 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ CREATE_BUILD_DIR:=
WILDCARD_WGPU_NATIVE:=$(wildcard wgpu-native/**/*.rs wgpu-core/**/*.rs)
WILDCARD_WGPU_REMOTE:=$(wildcard wgpu-remote/**/*.rs wgpu-core/**/*.rs)

GIT_TAG=$(shell git describe --abbrev=0 --tags)
GIT_TAG_FULL=$(shell git describe --tags)
OS_NAME=

ifeq (,$(TARGET))
CHECK_TARGET_FLAG=
else
Expand All @@ -26,13 +30,46 @@ else
CREATE_BUILD_DIR=mkdir -p $(BUILD_DIR)
endif

.PHONY: all check test doc clear lib-native lib-remote \
ifeq ($(OS),Windows_NT)
LIB_EXTENSION=dll
OS_NAME=windows
ZIP_TOOL=7z
else
UNAME_S:=$(shell uname -s)
ZIP_TOOL=zip
ifeq ($(UNAME_S),Linux)
LIB_EXTENSION=so
OS_NAME=linux
endif
ifeq ($(UNAME_S),Darwin)
LIB_EXTENSION=dylib
OS_NAME=macos
endif
endif


.PHONY: all check test doc clear \
example-compute example-triangle example-remote \
run-example-compute run-example-triangle run-example-remote
run-example-compute run-example-triangle run-example-remote \
lib-native lib-native-release \
lib-remote

#TODO: example-remote
all: example-compute example-triangle lib-remote

package: lib-native lib-native-release
mkdir -p dist
echo "$(GIT_TAG_FULL)" > dist/commit-sha
for RELEASE in debug release; do \
ARCHIVE=wgpu-$$RELEASE-$(OS_NAME)-$(GIT_TAG).zip; \
rm -f dist/$$ARCHIVE; \
if [ $(ZIP_TOOL) = zip ]; then \
zip -j dist/$$ARCHIVE target/$$RELEASE/libwgpu_*.$(LIB_EXTENSION) ffi/*.h dist/commit-sha; \
else \
7z a -tzip dist/$$ARCHIVE ./target/$$RELEASE/wgpu_*.$(LIB_EXTENSION) ./ffi/*.h ./dist/commit-sha; \
fi; \
done

check:
cargo check --all

Expand All @@ -49,6 +86,9 @@ clear:
lib-native: Cargo.lock wgpu-native/Cargo.toml $(WILDCARD_WGPU_NATIVE)
cargo build --manifest-path wgpu-native/Cargo.toml

lib-native-release: Cargo.lock wgpu-native/Cargo.toml $(WILDCARD_WGPU_NATIVE)
cargo build --manifest-path wgpu-native/Cargo.toml --release

lib-remote: Cargo.lock wgpu-remote/Cargo.toml $(WILDCARD_WGPU_REMOTE)
cargo build --manifest-path wgpu-remote/Cargo.toml

Expand Down
8 changes: 4 additions & 4 deletions ffi/wgpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,11 @@ typedef uint64_t WGPUId_Texture_Dummy;
typedef WGPUId_Texture_Dummy WGPUTextureId;

typedef struct {
float x;
float y;
float z;
uint32_t x;
uint32_t y;
uint32_t z;
} WGPUOrigin3d;
#define WGPUOrigin3d_ZERO (WGPUOrigin3d){ .x = 0.0, .y = 0.0, .z = 0.0 }
#define WGPUOrigin3d_ZERO (WGPUOrigin3d){ .x = 0, .y = 0, .z = 0 }

typedef struct {
WGPUTextureId texture;
Expand Down
44 changes: 30 additions & 14 deletions wgpu-core/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2015,6 +2015,34 @@ impl<F: IdentityFilter<ComputePipelineId>> Global<F> {
}
}

fn validate_swap_chain_descriptor(
config: &mut hal::window::SwapchainConfig,
caps: &hal::window::SurfaceCapabilities,
) {
let width = config.extent.width;
let height = config.extent.height;
if width < caps.extents.start().width
|| width > caps.extents.end().width
|| height < caps.extents.start().height
|| height > caps.extents.end().height
{
log::warn!(
"Requested size {}x{} is outside of the supported range: {:?}",
width,
height,
caps.extents
);
}
if !caps.present_modes.contains(config.present_mode) {
log::warn!(
"Surface does not support present mode: {:?}, falling back to {:?}",
config.present_mode,
hal::window::PresentMode::FIFO
);
config.present_mode = hal::window::PresentMode::FIFO;
}
}

impl<F: IdentityFilter<SwapChainId>> Global<F> {
pub fn device_create_swap_chain<B: GfxBackend>(
&self,
Expand Down Expand Up @@ -2044,8 +2072,7 @@ impl<F: IdentityFilter<SwapChainId>> Global<F> {
let num_frames = swap_chain::DESIRED_NUM_FRAMES
.max(*caps.image_count.start())
.min(*caps.image_count.end());
let config = desc.to_hal(num_frames, &device.features);

let mut config = desc.to_hal(num_frames, &device.features);
if let Some(formats) = formats {
assert!(
formats.contains(&config.format),
Expand All @@ -2054,18 +2081,7 @@ impl<F: IdentityFilter<SwapChainId>> Global<F> {
formats
);
}
if desc.width < caps.extents.start().width
|| desc.width > caps.extents.end().width
|| desc.height < caps.extents.start().height
|| desc.height > caps.extents.end().height
{
log::warn!(
"Requested size {}x{} is outside of the supported range: {:?}",
desc.width,
desc.height,
caps.extents
);
}
validate_swap_chain_descriptor(&mut config, &caps);

unsafe {
B::get_surface_mut(surface)
Expand Down
12 changes: 6 additions & 6 deletions wgpu-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,16 @@ impl Color {
#[repr(C)]
#[derive(Clone, Copy, Debug)]
pub struct Origin3d {
pub x: f32,
pub y: f32,
pub z: f32,
pub x: u32,
pub y: u32,
pub z: u32,
}

impl Origin3d {
pub const ZERO: Self = Origin3d {
x: 0.0,
y: 0.0,
z: 0.0,
x: 0,
y: 0,
z: 0,
};
}

Expand Down

0 comments on commit 890bbcf

Please sign in to comment.