Skip to content

Commit 890bbcf

Browse files
bors[bot]KorijnfinteliaVeykril
authored
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]>
4 parents 7d8a1d5 + 52de829 + 461f114 + 9eab6fc commit 890bbcf

File tree

6 files changed

+97
-26
lines changed

6 files changed

+97
-26
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
.vs
77
build
88
ffi/dawn*.h
9+
dist

.travis.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,3 +77,17 @@ script:
7777
make example-compute example-triangle VERBOSE=1;
7878
fi
7979
- if [[ $TRAVIS_RUST_VERSION == "nightly" ]] && [[ $TRAVIS_OS_NAME != "windows" ]]; then make VERBOSE=1; fi
80+
- if [[ $TRAVIS_RUST_VERSION == "stable" ]]; then make package; fi
81+
82+
deploy:
83+
provider: releases
84+
api_key:
85+
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=
86+
file_glob: true
87+
file: dist/wgpu-*.zip
88+
skip_cleanup: true
89+
overwrite: true
90+
on:
91+
tags: true
92+
condition: $TRAVIS_RUST_VERSION == "stable" && $TRAVIS_BRANCH == $TRAVIS_TAG
93+
skip_cleanup: true

Makefile

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ CREATE_BUILD_DIR:=
1111
WILDCARD_WGPU_NATIVE:=$(wildcard wgpu-native/**/*.rs wgpu-core/**/*.rs)
1212
WILDCARD_WGPU_REMOTE:=$(wildcard wgpu-remote/**/*.rs wgpu-core/**/*.rs)
1313

14+
GIT_TAG=$(shell git describe --abbrev=0 --tags)
15+
GIT_TAG_FULL=$(shell git describe --tags)
16+
OS_NAME=
17+
1418
ifeq (,$(TARGET))
1519
CHECK_TARGET_FLAG=
1620
else
@@ -26,13 +30,46 @@ else
2630
CREATE_BUILD_DIR=mkdir -p $(BUILD_DIR)
2731
endif
2832

29-
.PHONY: all check test doc clear lib-native lib-remote \
33+
ifeq ($(OS),Windows_NT)
34+
LIB_EXTENSION=dll
35+
OS_NAME=windows
36+
ZIP_TOOL=7z
37+
else
38+
UNAME_S:=$(shell uname -s)
39+
ZIP_TOOL=zip
40+
ifeq ($(UNAME_S),Linux)
41+
LIB_EXTENSION=so
42+
OS_NAME=linux
43+
endif
44+
ifeq ($(UNAME_S),Darwin)
45+
LIB_EXTENSION=dylib
46+
OS_NAME=macos
47+
endif
48+
endif
49+
50+
51+
.PHONY: all check test doc clear \
3052
example-compute example-triangle example-remote \
31-
run-example-compute run-example-triangle run-example-remote
53+
run-example-compute run-example-triangle run-example-remote \
54+
lib-native lib-native-release \
55+
lib-remote
3256

3357
#TODO: example-remote
3458
all: example-compute example-triangle lib-remote
3559

60+
package: lib-native lib-native-release
61+
mkdir -p dist
62+
echo "$(GIT_TAG_FULL)" > dist/commit-sha
63+
for RELEASE in debug release; do \
64+
ARCHIVE=wgpu-$$RELEASE-$(OS_NAME)-$(GIT_TAG).zip; \
65+
rm -f dist/$$ARCHIVE; \
66+
if [ $(ZIP_TOOL) = zip ]; then \
67+
zip -j dist/$$ARCHIVE target/$$RELEASE/libwgpu_*.$(LIB_EXTENSION) ffi/*.h dist/commit-sha; \
68+
else \
69+
7z a -tzip dist/$$ARCHIVE ./target/$$RELEASE/wgpu_*.$(LIB_EXTENSION) ./ffi/*.h ./dist/commit-sha; \
70+
fi; \
71+
done
72+
3673
check:
3774
cargo check --all
3875

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

89+
lib-native-release: Cargo.lock wgpu-native/Cargo.toml $(WILDCARD_WGPU_NATIVE)
90+
cargo build --manifest-path wgpu-native/Cargo.toml --release
91+
5292
lib-remote: Cargo.lock wgpu-remote/Cargo.toml $(WILDCARD_WGPU_REMOTE)
5393
cargo build --manifest-path wgpu-remote/Cargo.toml
5494

ffi/wgpu.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -349,11 +349,11 @@ typedef uint64_t WGPUId_Texture_Dummy;
349349
typedef WGPUId_Texture_Dummy WGPUTextureId;
350350

351351
typedef struct {
352-
float x;
353-
float y;
354-
float z;
352+
uint32_t x;
353+
uint32_t y;
354+
uint32_t z;
355355
} WGPUOrigin3d;
356-
#define WGPUOrigin3d_ZERO (WGPUOrigin3d){ .x = 0.0, .y = 0.0, .z = 0.0 }
356+
#define WGPUOrigin3d_ZERO (WGPUOrigin3d){ .x = 0, .y = 0, .z = 0 }
357357

358358
typedef struct {
359359
WGPUTextureId texture;

wgpu-core/src/device.rs

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,6 +2015,34 @@ impl<F: IdentityFilter<ComputePipelineId>> Global<F> {
20152015
}
20162016
}
20172017

2018+
fn validate_swap_chain_descriptor(
2019+
config: &mut hal::window::SwapchainConfig,
2020+
caps: &hal::window::SurfaceCapabilities,
2021+
) {
2022+
let width = config.extent.width;
2023+
let height = config.extent.height;
2024+
if width < caps.extents.start().width
2025+
|| width > caps.extents.end().width
2026+
|| height < caps.extents.start().height
2027+
|| height > caps.extents.end().height
2028+
{
2029+
log::warn!(
2030+
"Requested size {}x{} is outside of the supported range: {:?}",
2031+
width,
2032+
height,
2033+
caps.extents
2034+
);
2035+
}
2036+
if !caps.present_modes.contains(config.present_mode) {
2037+
log::warn!(
2038+
"Surface does not support present mode: {:?}, falling back to {:?}",
2039+
config.present_mode,
2040+
hal::window::PresentMode::FIFO
2041+
);
2042+
config.present_mode = hal::window::PresentMode::FIFO;
2043+
}
2044+
}
2045+
20182046
impl<F: IdentityFilter<SwapChainId>> Global<F> {
20192047
pub fn device_create_swap_chain<B: GfxBackend>(
20202048
&self,
@@ -2044,8 +2072,7 @@ impl<F: IdentityFilter<SwapChainId>> Global<F> {
20442072
let num_frames = swap_chain::DESIRED_NUM_FRAMES
20452073
.max(*caps.image_count.start())
20462074
.min(*caps.image_count.end());
2047-
let config = desc.to_hal(num_frames, &device.features);
2048-
2075+
let mut config = desc.to_hal(num_frames, &device.features);
20492076
if let Some(formats) = formats {
20502077
assert!(
20512078
formats.contains(&config.format),
@@ -2054,18 +2081,7 @@ impl<F: IdentityFilter<SwapChainId>> Global<F> {
20542081
formats
20552082
);
20562083
}
2057-
if desc.width < caps.extents.start().width
2058-
|| desc.width > caps.extents.end().width
2059-
|| desc.height < caps.extents.start().height
2060-
|| desc.height > caps.extents.end().height
2061-
{
2062-
log::warn!(
2063-
"Requested size {}x{} is outside of the supported range: {:?}",
2064-
desc.width,
2065-
desc.height,
2066-
caps.extents
2067-
);
2068-
}
2084+
validate_swap_chain_descriptor(&mut config, &caps);
20692085

20702086
unsafe {
20712087
B::get_surface_mut(surface)

wgpu-core/src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -159,16 +159,16 @@ impl Color {
159159
#[repr(C)]
160160
#[derive(Clone, Copy, Debug)]
161161
pub struct Origin3d {
162-
pub x: f32,
163-
pub y: f32,
164-
pub z: f32,
162+
pub x: u32,
163+
pub y: u32,
164+
pub z: u32,
165165
}
166166

167167
impl Origin3d {
168168
pub const ZERO: Self = Origin3d {
169-
x: 0.0,
170-
y: 0.0,
171-
z: 0.0,
169+
x: 0,
170+
y: 0,
171+
z: 0,
172172
};
173173
}
174174

0 commit comments

Comments
 (0)