mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 06:44:14 +00:00
Make PresentMode configurable
Disable vsync Revert accidential hardcode of num_frames Make the PresentMode configurable Adapt examples + adjust style according to @kvrak Adher to @kvarks wishes for style. Examples build. Fix unnecessary ampersand.
This commit is contained in:
parent
8af0fa824b
commit
c5c7092d9c
@ -197,6 +197,7 @@ int main() {
|
||||
.format = WGPUTextureFormat_Bgra8Unorm,
|
||||
.width = prev_width,
|
||||
.height = prev_height,
|
||||
.present_mode = WGPUPresentMode_Vsync,
|
||||
});
|
||||
|
||||
while (!glfwWindowShouldClose(window)) {
|
||||
@ -213,6 +214,7 @@ int main() {
|
||||
.format = WGPUTextureFormat_Bgra8Unorm,
|
||||
.width = width,
|
||||
.height = height,
|
||||
.present_mode = WGPUPresentMode_Vsync,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#define WGPU_LOCAL
|
||||
|
||||
/* Generated with cbindgen:0.8.7 */
|
||||
/* Generated with cbindgen:0.9.0 */
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
@ -110,6 +110,11 @@ typedef enum {
|
||||
WGPUPowerPreference_HighPerformance = 2,
|
||||
} WGPUPowerPreference;
|
||||
|
||||
typedef enum {
|
||||
WGPUPresentMode_NoVsync = 0,
|
||||
WGPUPresentMode_Vsync = 1,
|
||||
} WGPUPresentMode;
|
||||
|
||||
typedef enum {
|
||||
WGPUPrimitiveTopology_PointList = 0,
|
||||
WGPUPrimitiveTopology_LineList = 1,
|
||||
@ -577,6 +582,7 @@ typedef struct {
|
||||
WGPUTextureFormat format;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
WGPUPresentMode present_mode;
|
||||
} WGPUSwapChainDescriptor;
|
||||
|
||||
typedef struct {
|
||||
|
@ -1734,6 +1734,10 @@ pub fn device_create_swap_chain(
|
||||
);
|
||||
//TODO: check for supported
|
||||
config.composite_alpha = hal::window::CompositeAlpha::OPAQUE;
|
||||
config.present_mode = match desc.present_mode {
|
||||
swap_chain::PresentMode::NoVsync => hal::PresentMode::Immediate,
|
||||
swap_chain::PresentMode::Vsync => hal::PresentMode::Fifo,
|
||||
};
|
||||
|
||||
if let Some(formats) = formats {
|
||||
assert!(
|
||||
|
@ -77,6 +77,13 @@ pub struct SwapChain<B: hal::Backend> {
|
||||
pub(crate) command_pool: hal::CommandPool<B, hal::General>,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub enum PresentMode {
|
||||
NoVsync = 0,
|
||||
Vsync = 1,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct SwapChainDescriptor {
|
||||
@ -84,6 +91,7 @@ pub struct SwapChainDescriptor {
|
||||
pub format: resource::TextureFormat,
|
||||
pub width: u32,
|
||||
pub height: u32,
|
||||
pub present_mode: PresentMode,
|
||||
}
|
||||
|
||||
impl SwapChainDescriptor {
|
||||
|
Loading…
Reference in New Issue
Block a user