Skip to content

Commit

Permalink
Merge branch 'll' of github.com:gfx-rs/gfx into ll
Browse files Browse the repository at this point in the history
  • Loading branch information
Bastacyclop committed Oct 4, 2017
2 parents 09eb82e + 5495511 commit 7ba2a04
Show file tree
Hide file tree
Showing 56 changed files with 1,954 additions and 1,172 deletions.
23 changes: 17 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ os:
- linux
- osx
branches:
only:
- staging
- trying
- master
except:
- staging.tmp


notifications:
webhooks:
Expand All @@ -26,7 +25,15 @@ notifications:
on_start: false

before_install:
- bash scripts/travis-before_install.sh
# 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 export DISPLAY=:99.0 && sh -e /etc/init.d/xvfb start && make travis-sdl2; fi
- if [[ $TRAVIS_OS_NAME == osx ]]; then brew update && brew install sdl2 && brew upgrade cmake; fi

addons:
apt:
Expand All @@ -48,4 +55,8 @@ addons:
- libxrandr-dev

script:
- bash scripts/travis-script.sh
- if [[ $TRAVIS_RUST_VERSION == "nightly" && $TRAVIS_BRANCH == "staging" ]]; then exit; fi
- export PATH=$PATH:$HOME/deps/bin
- export LIBRARY_PATH=$HOME/deps/usr/lib/x86_64-linux-gnu
- export LD_LIBRARY_PATH=$LIBRARY_PATH
- make all
66 changes: 4 additions & 62 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,6 @@
## Change Log

### v0.16 (2017-05-11)
- `RawGlobal` PSO component ([#1262](https://github.com/gfx-rs/gfx/pull/1262))
- run-time configurable instance rate ([#1256](https://github.com/gfx-rs/gfx/pull/1256))
- more convenience traits are derived ([#1249](https://github.com/gfx-rs/gfx/pull/1249))
- optional cgmath support ([#1242](https://github.com/gfx-rs/gfx/pull/1242))

### v0.15 (2017-04-22)
- optional serialization support ([#1234](https://github.com/gfx-rs/gfx/pull/1234))
- better GL state caching ([#1221](https://github.com/gfx-rs/gfx/pull/1221))
- GL texture staging ([#1202](https://github.com/gfx-rs/gfx/pull/1202))
- primitives with adjacency ([#1154](https://github.com/gfx-rs/gfx/pull/1154))
- metal backend improvements ([#1165](https://github.com/gfx-rs/gfx/pull/1165), [#1175](https://github.com/gfx-rs/gfx/pull/1175))
- resource mapping improvements

### v0.14 (2017-01-16)
- fixed `Fence` and `Sync` bounds ([#1095](https://github.com/gfx-rs/gfx/pull/1095))
- dx11 buffer mapping support ([#1099](https://github.com/gfx-rs/gfx/pull/1099), [#1105](https://github.com/gfx-rs/gfx/pull/1105))
- redesigned resource usage model for next-gen compatibility ([#1123](https://github.com/gfx-rs/gfx/pull/1123))
- buffer copy support ([#1129](https://github.com/gfx-rs/gfx/pull/1129))
- fixed and improved some errors ([#1137](https://github.com/gfx-rs/gfx/pull/1137), [#1138](https://github.com/gfx-rs/gfx/pull/1138))
- application launcher revamp and resize support ([#1121](https://github.com/gfx-rs/gfx/pull/1121))

### v0.13 (2016-12-18)
- experimental Metal backend ([#969](https://github.com/gfx-rs/gfx/pull/969), [#1049](https://github.com/gfx-rs/gfx/pull/1049), [#1050](https://github.com/gfx-rs/gfx/pull/1050))
- persistent mapping ([#1026](https://github.com/gfx-rs/gfx/pull/1026))
- tessellation support ([#1027](https://github.com/gfx-rs/gfx/pull/1027), [#1088](https://github.com/gfx-rs/gfx/pull/1088))
- new examples: gamma, particle, terrain_tessellated
- better PSO error messages, constant offset checks ([#1004](https://github.com/gfx-rs/gfx/pull/1004))
- unified scissor: now Y-reversed on GL ([#1092](https://github.com/gfx-rs/gfx/pull/1092))
- `const` resources are now called `immutable`
- faster handle clones and cleaner core API ([#1031](https://github.com/gfx-rs/gfx/pull/1031))

### v0.12 (2016-06-23)
- Android / GLES support ([#993](https://github.com/gfx-rs/gfx/pull/993))
- GL unsigned int samplers ([#991](https://github.com/gfx-rs/gfx/pull/991))
- better errors ([#976](https://github.com/gfx-rs/gfx/pull/976))
- better GLSL pre core reflection

### v0.11 (2016-04-30)
- modified `Slice` API ([#955](https://github.com/gfx-rs/gfx/pull/955))
- fixed GL blending where it's not in the core ([#953](https://github.com/gfx-rs/gfx/pull/953))
- raw PSO components for vertex buffers and render targets

### v0.10.2 (2016-04-15)
- fixed get_texel_count ([#937](https://github.com/gfx-rs/gfx/pull/937))

### v0.10.1 (2016-03-26)
- fixed update_texture ([#912](https://github.com/gfx-rs/gfx/pull/912))

### v0.10 (2016-03-21)
- Direct3D 11 backend ([#861](https://github.com/gfx-rs/gfx/pull/861))

### v0.9.2 (2016-02-24)
- fixed universal format views ([#886](https://github.com/gfx-rs/gfx/pull/886))
- fixed constant buffer binding ([#828](https://github.com/gfx-rs/gfx/pull/828))

### v0.9.1 (2016-02-19)
- window resize support ([#879](https://github.com/gfx-rs/gfx/pull/879))
- deriving windows attributes from target formats ([#874](https://github.com/gfx-rs/gfx/pull/874))

### v0.9 (2016-01-22)
- Pipepeline State Object revolution ([#828](https://github.com/gfx-rs/gfx/pull/828))
### v0.1 (TBD)
- `gfx_hal`: graphics hardware abstraction layer
- `gfx_backend_*`: Vulkan, D3D12, Metal
- `gfx_render`: safer wrapper at a higher level
75 changes: 75 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
RUST_BACKTRACE:=1
EXCLUDES:=
FEATURES_RENDER:=
FEATURES_RENDER_ADD:= mint serialize
FEATURES_QUAD:=
FEATURES_QUAD_ADD:=
FEATURES_QUAD2:=
CMD_QUAD_RENDER:=cargo check

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 ($(OS),Windows_NT)
EXCLUDES+= --exclude gfx_backend_metal
FEATURES_QUAD=vulkan
ifeq ($(TARGET),x86_64-pc-windows-gnu)
# No d3d12 support on GNU windows ATM
# context: https://github.com/gfx-rs/gfx/pull/1417
EXCLUDES+= --exclude gfx_backend_dx12
else
FEATURES_QUAD2=dx12
endif
else
UNAME_S:=$(shell uname -s)
EXCLUDES+= --exclude gfx_device_dx11
EXCLUDES+= --exclude gfx_backend_dx12
GLUTIN_HEADLESS_FEATURE="--features headless" #TODO?
ifeq ($(UNAME_S),Linux)
EXCLUDES+= --exclude gfx_backend_metal
FEATURES_QUAD=vulkan
endif
ifeq ($(UNAME_S),Darwin)
EXCLUDES+= --exclude gfx_backend_vulkan
EXCLUDES+= --exclude quad_render
FEATURES_QUAD=metal
FEATURES_QUAD_ADD=metal_argument_buffer
CMD_QUAD_RENDER=pwd
endif
endif


.PHONY: all check render ex-quad travis-sdl2

all: check render ex-quad ex-quad-render

check:
cargo check --all $(EXCLUDES)
cargo test --all $(EXCLUDES)

render:
cd src/render && cargo test --features "$(FEATURES_RENDER)"
cd src/render && cargo test --features "$(FEATURES_RENDER) $(FEATURES_RENDER_ADD)"

ex-quad:
cd examples/core/quad && cargo check --features "gl"
cd examples/core/quad && cargo check --features "$(FEATURES_QUAD2)"
cd examples/core/quad && cargo check --features "$(FEATURES_QUAD)"
cd examples/core/quad && cargo check --features "$(FEATURES_QUAD) $(FEATURES_QUAD_ADD)"

ex-quad-render:
cd examples/render/quad_render && $(CMD_QUAD_RENDER)

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)
110 changes: 8 additions & 102 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,110 +22,16 @@
</p>

## gfx-rs
`gfx` is a high-performance, bindless graphics API for the Rust programming language. It aims to be the default API for Rust graphics: for one-off applications, or higher level libraries or engines.

### Under Construction
gfx-rs is a graphics abstraction library in Rust. It consists of the following layers/components:
- `gfx_hal`: hardware abstraction layer - a Vulkan-ic mostly unsafe API translating to native graphics backends
- `gfx_backend_*`: graphics backends for various platforms, include the windowing logic.
- `gfx_render`: higher level wrapper around HAL, providing resources lifetime tracking, synchronization, and more

gfx-rs is undergoing severe changes now with transition to the new [low-level core](http://gfx-rs.github.io/2017/07/24/low-level.html). All the following sections apply to the `pre-ll` branch and will be outdated soon. The new development focus is on zero-cost low-level abstraction of current-gen graphics APIs, such as Vulkan, D3D12, and Metal.
### Features

---
TODO

## Motivation
### Usage

- Graphics APIs are mostly designed with C and C++ in mind, and hence are dangerous and error prone, with little static safety guarantees.
- Providing type safe wrappers around platform-specific APIs is feasible, but only pushes the problem of platform independence to a higher level of abstraction, often to the game or rendering engine.
- Modern graphics APIs, whilst providing a great degree of flexibility and a high level of performance, often have a much higher barrier to entry than traditional [fixed-function](https://en.wikipedia.org/wiki/Fixed-function) APIs.
- Graphics APIs like OpenGL still [require the developer to 'bind' and 'unbind' objects](https://www.khronos.org/opengl/wiki/Buffer_Object) in order to perform operations on them. This results in a large amount of boiler plate code, and brings with it the usual problems associated with global state.

## Features

Graphics backends:
- [OpenGL 2.1+](src/backend/gl)
- [OpenGL ES2+](src/backend/gl) ([works](https://github.com/gfx-rs/gfx/pull/993) on Android)
- [Direct3D 11](src/backend/dx11)
- [Metal](src/backend/metal) (WIP 75%)
- [Vulkan](src/backend/vulkan) (WIP 40%)

Hardware features:
- [x] off-screen render targets
- [x] multisampling
- [x] instancing
- [x] geometry shaders
- [x] tessellation
- [ ] computing
- [x] persistent mapping

## Who's using it?

Biggest open-source projects are:
- [Amethyst](https://github.com/amethyst/amethyst) engine
- [ggez](https://github.com/ggez/ggez) engine
- Piston engine - [2d graphics](https://github.com/PistonDevelopers/gfx_graphics)
- [LazyBox](https://github.com/lazybox/lazybox) engine
- [Vange-rs](https://github.com/kvark/vange-rs) game
- [Zemeroth](https://github.com/ozkriff/zemeroth) game
- [Rust-quake](https://github.com/Thinkofname/rust-quake) level viewer
- [Rust-oids](https://github.com/itadinanta/rust-oids) game

Shiny screens, including some older projects:
<p align="center">
<!--img src="https://raw.githubusercontent.com/csherratt/snowmew/master/.screenshot.jpg" height="160" alt="Snowmew"/-->
<img src="https://github.com/PistonDevelopers/hematite/blob/master/screenshot.png" height="160" alt="Hematite"/>
<img src="http://image.prntscr.com/image/2f1ec5d477e042dda2c29323c9f49ab4.png" height="160" alt="LazyBox"/>
<img src="https://github.com/kvark/vange-rs/blob/master/etc/shots/Road10-debug-shape.png" height="160" alt="Vange-rs"/>
<img src="https://github.com/kvark/claymore/raw/master/etc/screens/7-forest.jpg" height="160" alt="Claymore"/>
<img src="https://camo.githubusercontent.com/fb8c95650fba27061e58e76f17ff8460a41b3312/687474703a2f2f692e696d6775722e636f6d2f504f68534c77682e706e67" height="160" alt="ZoC"/>
<img src="https://camo.githubusercontent.com/0038d5e3c73b280cfa5d01b26ccef12be7237af5/687474703a2f2f692e696d6775722e636f6d2f703163654954352e706e67" height="160" alt="Rust-Quake">
<img src="https://github.com/itadinanta/rust-oids/raw/master/img/screenshot_007.png" height="160" alt="Rust-oids">
<!--img src="https://raw.githubusercontent.com/csherratt/petri/master/petri.png" height="160" alt="Petri"/-->
</p>

## Getting started

If you want to build your own stand-alone gfx program, add the following to your new `Cargo.toml`:

[dependencies]
gfx = "0.16"

or, if you want the absolute latest commits to master, you can instead add.

[dependencies]
gfx = { git = "https://github.com/gfx-rs/gfx.git" }

For gfx to work, it needs access to the graphics system of the OS. This is typically provided through some window initialization API.
gfx can use a couple of those to acquire graphical contexts.
For example; [glfw](https://github.com/PistonDevelopers/glfw-rs) or [glutin](https://github.com/tomaka/glutin/).

To see how the graphic context is acquired, see the [cube example](https://github.com/gfx-rs/gfx/tree/master/support/examples/cube) or the [triangle example](https://github.com/gfx-rs/gfx/tree/master/render/examples/triangle).

To use `glutin`, for example, your `Cargo.toml` must be extended with the following dependencies:

[dependencies]
...
glutin ="*"
gfx_window_glutin = "*"

Alternatively, an excellent introduction into gfx and its related crates can be found [here](https://wiki.alopex.li/LearningGfx).

## Running the Examples

The [examples directory](./examples) contains all the examples for GFX, as well as the
[accompanying documentation](./examples/README.md) for understanding and running those examples.


## Structure and current versions
`gfx` consist of several crates. You can find all of them in this repository.

| Core functionality: | Graphic backends: | Window backends: |
| :---: | :---: | :---: |
| [![gfx on crates.io](http://img.shields.io/crates/v/gfx.svg?label=gfx)](http://crates.io/crates/gfx) | [![gfx_device_gl on crates.io](http://img.shields.io/crates/v/gfx_device_gl.svg?label=gfx_device_gl)](http://crates.io/crates/gfx_device_gl) | [![gfx_window_sdl on crates.io](http://img.shields.io/crates/v/gfx_window_sdl.svg?label=gfx_window_sdl)](http://crates.io/crates/gfx_window_sdl) |
| | [![gfx_device_dx11 on crates.io](http://img.shields.io/crates/v/gfx_device_dx11.svg?label=gfx_device_dx11)](http://crates.io/crates/gfx_device_dx11) | [![gfx_window_dxgi on crates.io](http://img.shields.io/crates/v/gfx_window_dxgi.svg?label=gfx_window_dxgi)](http://crates.io/crates/gfx_window_dxgi) |
| [![gfx_core on crates.io](http://img.shields.io/crates/v/gfx_core.svg?label=gfx_core)](http://crates.io/crates/gfx_core) | [![gfx_device_metal on crates.io](http://img.shields.io/crates/v/gfx_device_metal.svg?label=gfx_device_metal)](http://crates.io/crates/gfx_device_metal) | [![gfx_window_glfw on crates.io](http://img.shields.io/crates/v/gfx_window_glfw.svg?label=gfx_window_glfw)](http://crates.io/crates/gfx_window_glfw) |
| [![gfx_macros on crates.io](http://img.shields.io/crates/v/gfx_macros.svg?label=gfx_macros)](http://crates.io/crates/gfx_macros) | [![gfx_device_vulkan on crates.io](http://img.shields.io/crates/v/gfx_device_vulkan.svg?label=gfx_device_vulkan)](http://crates.io/crates/gfx_device_vulkan) | [![gfx_window_metal on crates.io](http://img.shields.io/crates/v/gfx_window_metal.svg?label=gfx_window_metal)](http://crates.io/crates/gfx_window_metal) |
| | | [![gfx_window_glutin on crates.io](http://img.shields.io/crates/v/gfx_window_glutin.svg?label=gfx_window_glutin)](http://crates.io/crates/gfx_window_glutin) |
| | | [![gfx_window_vulkan on crates.io](http://img.shields.io/crates/v/gfx_window_vulkan.svg?label=gfx_window_vulkan)](http://crates.io/crates/gfx_window_vulkan) |

## Note

`gfx` is still in development. API may change with new backends/features to be implemented.
If you are interested in helping out, checkout [contrib.md](info/contrib.md) and do not hesitate to contact the developers on [Gitter](https://gitter.im/gfx-rs/gfx).
TODO
60 changes: 20 additions & 40 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,46 +1,26 @@
skip_branch_with_pr: true
branches:
except:
- staging.tmp
environment:
global:
PATH: '%PATH%;C:\msys64\mingw64\bin;C:\msys64\usr\bin;%USERPROFILE%\.cargo\bin'
RUST_BACKTRACE: full
matrix:
- TARGET: 1.20.0-x86_64-pc-windows
COMPILER: gnu
- TARGET: 1.20.0-x86_64-pc-windows
COMPILER: msvc
- TARGET: nightly-x86_64-pc-windows
COMPILER: msvc
- CHANNEL: stable
TARGET: x86_64-pc-windows-msvc
- CHANNEL: stable
TARGET: x86_64-pc-windows-gnu
- CHANNEL: nightly
TARGET: x86_64-pc-windows-msvc

install:
- if %COMPILER%==gnu choco install -y mingw
- ps: Start-FileDownload "https://static.rust-lang.org/dist/rust-${env:TARGET}-${env:COMPILER}.exe" -FileName "rust-install.exe"
- ps: .\rust-install.exe /VERYSILENT /NORESTART /DIR="C:\rust" | Out-Null
- ps: $env:PATH="$env:PATH;C:\rust\bin;C:\tools\mingw64\bin"
- if %COMPILER%==gnu gcc -v
- curl -sSf -o rustup-init.exe https://win.rustup.rs
- rustup-init -yv --default-toolchain %CHANNEL% --default-host %TARGET%
#- bash -lc "pacman -S --noconfirm mingw-w64-x86_64-cmake"
- rustc -vV
- cargo -vV
build_script:
# No d3d12 support on GNU windows ATM
# context: https://github.com/gfx-rs/gfx/pull/1417
- if %COMPILER%==gnu (
cargo build --all
--exclude gfx_window_glfw
--exclude gfx_window_sdl
--exclude gfx_backend_metal
--exclude gfx_backend_dx12
--exclude gfx_window_dxgi
) else (
cargo build --all
--exclude gfx_window_glfw
--exclude gfx_window_sdl
--exclude gfx_backend_metal
)

build: false
test_script:
- if %COMPILER%==gnu (
cargo test --all
--exclude gfx_window_glfw
--exclude gfx_window_sdl
--exclude gfx_backend_metal
--exclude gfx_backend_dx12
--exclude gfx_window_dxgi
) else (
cargo test --all
--exclude gfx_window_glfw
--exclude gfx_window_sdl
--exclude gfx_backend_metal
)
- C:\MinGW\bin\mingw32-make.exe all
Loading

0 comments on commit 7ba2a04

Please sign in to comment.