mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 06:44:14 +00:00
Force pipeline barriers between unordered usages
This commit is contained in:
parent
3504b7525e
commit
d37452ff27
10
Makefile
10
Makefile
@ -46,9 +46,9 @@ else
|
||||
endif
|
||||
endif
|
||||
|
||||
.PHONY: all check test doc clear lib-native lib-remote examples-native examples-remote
|
||||
.PHONY: all check test doc clear lib-native lib-remote examples-compute example-triangle example-remote
|
||||
|
||||
all: examples-native examples-remote
|
||||
all: examples-compute example-triangle example-remote
|
||||
|
||||
check:
|
||||
cargo check --all
|
||||
@ -69,10 +69,10 @@ lib-native: Cargo.lock wgpu-native/Cargo.toml $(WILDCARD_WGPU_NATIVE)
|
||||
lib-remote: Cargo.lock wgpu-remote/Cargo.toml $(WILDCARD_WGPU_NATIVE_AND_REMOTE)
|
||||
cargo build --manifest-path wgpu-remote/Cargo.toml --features $(FEATURE_RUST)
|
||||
|
||||
ffi/wgpu.h: wgpu-native/cbindgen.toml $(WILDCARD_WGPU_NATIVE)
|
||||
$(FFI_DIR)/wgpu.h: wgpu-native/cbindgen.toml $(WILDCARD_WGPU_NATIVE)
|
||||
rustup run nightly cbindgen wgpu-native > $(FFI_DIR)/wgpu.h
|
||||
|
||||
ffi/wgpu-remote.h: wgpu-remote/cbindgen.toml $(WILDCARD_WGPU_NATIVE_AND_REMOTE)
|
||||
$(FFI_DIR)/wgpu-remote.h: wgpu-remote/cbindgen.toml $(WILDCARD_WGPU_NATIVE_AND_REMOTE)
|
||||
rustup run nightly cbindgen wgpu-remote > $(FFI_DIR)/wgpu-remote.h
|
||||
|
||||
example-compute: lib-native $(FFI_DIR)/wgpu.h examples/compute/main.c
|
||||
@ -82,4 +82,4 @@ example-triangle: lib-native $(FFI_DIR)/wgpu.h examples/triangle/main.c
|
||||
cd examples/triangle && $(CREATE_BUILD_DIR) && cd build && cmake .. -DBACKEND=$(FEATURE_RUST) $(GENERATOR_PLATFORM) && cmake --build .
|
||||
|
||||
example-remote: lib-remote $(FFI_DIR)/wgpu-remote.h examples/remote/main.c
|
||||
cd examples/remote && $(CREATE_BUILD_DIR) && cd build && cmake .. && cmake --build .
|
||||
cd examples/remote && $(CREATE_BUILD_DIR) && cd build && cmake .. && cmake --build .
|
||||
|
@ -21,15 +21,16 @@ WGPUU32Array read_file(const char *name) {
|
||||
}
|
||||
|
||||
void read_buffer_map(
|
||||
WGPUBufferMapAsyncStatus status,
|
||||
const uint8_t *data,
|
||||
WGPUBufferMapAsyncStatus status,
|
||||
const uint8_t *data,
|
||||
uint8_t *userdata) {
|
||||
(void)userdata;
|
||||
if (status == WGPUBufferMapAsyncStatus_Success) {
|
||||
uint32_t *times = (uint32_t *) data;
|
||||
printf("Times: [%d, %d, %d, %d]",
|
||||
times[0],
|
||||
times[1],
|
||||
times[2],
|
||||
times[0],
|
||||
times[1],
|
||||
times[2],
|
||||
times[3]);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
/* Generated with cbindgen:0.8.7 */
|
||||
/* Generated with cbindgen:0.9.0 */
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
|
@ -431,7 +431,6 @@ typedef uint32_t WGPUBufferUsage;
|
||||
#define WGPUBufferUsage_STORAGE 128
|
||||
#define WGPUBufferUsage_INDIRECT 256
|
||||
#define WGPUBufferUsage_NONE 0
|
||||
#define WGPUBufferUsage_WRITE_ALL 2 + 8 + 128
|
||||
|
||||
typedef struct {
|
||||
WGPUBufferAddress size;
|
||||
@ -575,7 +574,6 @@ typedef uint32_t WGPUTextureUsage;
|
||||
#define WGPUTextureUsage_STORAGE 8
|
||||
#define WGPUTextureUsage_OUTPUT_ATTACHMENT 16
|
||||
#define WGPUTextureUsage_NONE 0
|
||||
#define WGPUTextureUsage_WRITE_ALL 2 + 8 + 16
|
||||
#define WGPUTextureUsage_UNINITIALIZED 65535
|
||||
|
||||
typedef struct {
|
||||
|
@ -31,7 +31,15 @@ bitflags! {
|
||||
const STORAGE = 128;
|
||||
const INDIRECT = 256;
|
||||
const NONE = 0;
|
||||
const WRITE_ALL = 2 + 8 + 128;
|
||||
/// The combination of all read-only usages.
|
||||
const READ_ALL = Self::MAP_READ.bits | Self::TRANSFER_SRC.bits |
|
||||
Self::INDEX.bits | Self::VERTEX.bits | Self::UNIFORM.bits | Self::INDIRECT.bits;
|
||||
/// The combination of all write-only and read-write usages.
|
||||
const WRITE_ALL = Self::MAP_WRITE.bits | Self::TRANSFER_DST.bits | Self::STORAGE.bits;
|
||||
/// The combination of all usages that the are guaranteed to be be ordered by the hardware.
|
||||
/// If a usage is not ordered, then even if it doesn't change between draw calls, there
|
||||
/// still need to be pipeline barriers inserted for synchronization.
|
||||
const ORDERED = Self::READ_ALL.bits;
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,7 +171,14 @@ bitflags! {
|
||||
const STORAGE = 8;
|
||||
const OUTPUT_ATTACHMENT = 16;
|
||||
const NONE = 0;
|
||||
const WRITE_ALL = 2 + 8 + 16;
|
||||
/// The combination of all read-only usages.
|
||||
const READ_ALL = Self::TRANSFER_SRC.bits | Self::SAMPLED.bits;
|
||||
/// The combination of all write-only and read-write usages.
|
||||
const WRITE_ALL = Self::TRANSFER_DST.bits | Self::STORAGE.bits | Self::OUTPUT_ATTACHMENT.bits;
|
||||
/// The combination of all usages that the are guaranteed to be be ordered by the hardware.
|
||||
/// If a usage is not ordered, then even if it doesn't change between draw calls, there
|
||||
/// still need to be pipeline barriers inserted for synchronization.
|
||||
const ORDERED = Self::READ_ALL.bits | Self::OUTPUT_ATTACHMENT.bits;
|
||||
const UNINITIALIZED = 0xFFFF;
|
||||
}
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ impl ResourceState for BufferState {
|
||||
output: Option<&mut Vec<PendingTransition<Self>>>,
|
||||
) -> Result<(), PendingTransition<Self>> {
|
||||
let old = self.last;
|
||||
if usage != old {
|
||||
if usage != old || !BufferUsage::ORDERED.contains(usage) {
|
||||
let pending = PendingTransition {
|
||||
id,
|
||||
selector: (),
|
||||
@ -77,7 +77,7 @@ impl ResourceState for BufferState {
|
||||
) -> Result<(), PendingTransition<Self>> {
|
||||
let old = self.last;
|
||||
let new = other.select(stitch);
|
||||
self.last = if old == new {
|
||||
self.last = if old == new && BufferUsage::ORDERED.contains(new) {
|
||||
other.last
|
||||
} else {
|
||||
let pending = PendingTransition {
|
||||
|
@ -123,7 +123,7 @@ impl ResourceState for TextureState {
|
||||
}
|
||||
let layers = plane_states.isolate(&selector.layers, Unit::new(usage));
|
||||
for &mut (ref range, ref mut unit) in layers {
|
||||
if unit.last == usage {
|
||||
if unit.last == usage && TextureUsage::ORDERED.contains(usage) {
|
||||
continue
|
||||
}
|
||||
let pending = PendingTransition {
|
||||
@ -175,7 +175,7 @@ impl ResourceState for TextureState {
|
||||
Range { start: None, end: Some(end) } => Unit::new(end.select(stitch)),
|
||||
Range { start: Some(start), end: Some(end) } => {
|
||||
let mut final_usage = end.select(stitch);
|
||||
if start.last != final_usage {
|
||||
if start.last != final_usage || !TextureUsage::ORDERED.contains(final_usage) {
|
||||
let pending = PendingTransition {
|
||||
id,
|
||||
selector: hal::image::SubresourceRange {
|
||||
|
Loading…
Reference in New Issue
Block a user