mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Add env vars to set wgpu backend and wgpu api trace save dir (api trace still needs feature to be set ofc)
This commit is contained in:
parent
349ff53c3c
commit
91b6cd7106
11
Cargo.toml
11
Cargo.toml
@ -108,7 +108,16 @@ key = "veloren-nix.cachix.org-1:zokfKJqVsNV6kI/oJdLF6TYBdNPYGSb+diMVQPn/5Rc="
|
||||
winit = { git = "https://gitlab.com/veloren/winit.git", branch = "macos-test-spiffed" }
|
||||
vek = { git = "https://gitlab.com/veloren/vek.git", branch = "fix_intrinsics2" }
|
||||
# patch wgpu so we can use wgpu-profiler crate
|
||||
wgpu = { git = "https://github.com/gfx-rs/wgpu-rs.git", rev = "c5ee9cd98310aee66fb49bc98f4f65590304e4aa" }
|
||||
wgpu = { git = "https://github.com/gfx-rs/wgpu-rs.git", rev = "d44fc6ff855faf37b63fd711a9f9a916256cedc2" }
|
||||
# patch gfx-hal for the dx12 backend patch for cube sampling
|
||||
[patch."https://github.com/gfx-rs/gfx"]
|
||||
gfx-hal = { path = "../gfx/src/hal" }
|
||||
gfx-backend-empty = { path = "../gfx/src/backend/empty" }
|
||||
gfx-backend-vulkan = { path = "../gfx/src/backend/vulkan" }
|
||||
gfx-backend-gl = { path = "../gfx/src/backend/gl" }
|
||||
gfx-backend-dx12 = { path = "../gfx/src/backend/dx12" }
|
||||
gfx-backend-dx11 = { path = "../gfx/src/backend/dx11" }
|
||||
gfx-backend-metal = { path = "../gfx/src/backend/metal" }
|
||||
|
||||
# # Uncomment this to use a local fork of wgpu (for testing purposes)
|
||||
# [patch.'https://github.com/gfx-rs/wgpu']
|
||||
|
@ -141,15 +141,23 @@ impl Renderer {
|
||||
|
||||
// TODO: fix panic on wayland with opengl?
|
||||
// TODO: fix backend defaulting to opengl on wayland.
|
||||
let only_vulkan = std::env::var("ONLY_VULKAN")
|
||||
let backend_bit = std::env::var("WGPU_BACKEND")
|
||||
.ok()
|
||||
.map_or(false, |s| &s == "1" || &s == "true");
|
||||
let backend_bit = if only_vulkan {
|
||||
info!("Only requesting Vulkan backend due to ONLY_VULKAN env var being set");
|
||||
wgpu::BackendBit::VULKAN
|
||||
} else {
|
||||
wgpu::BackendBit::PRIMARY /* | wgpu::BackendBit::SECONDARY */
|
||||
};
|
||||
.and_then(|backend| match backend.to_lowercase().as_str() {
|
||||
"vulkan" => Some(wgpu::BackendBit::VULKAN),
|
||||
"metal" => Some(wgpu::BackendBit::METAL),
|
||||
"dx12" => Some(wgpu::BackendBit::DX12),
|
||||
"primary" => Some(wgpu::BackendBit::PRIMARY),
|
||||
"opengl" | "gl" => Some(wgpu::BackendBit::GL),
|
||||
"dx11" => Some(wgpu::BackendBit::DX11),
|
||||
"secondary" => Some(wgpu::BackendBit::SECONDARY),
|
||||
"all" => Some(wgpu::BackendBit::all()),
|
||||
_ => None,
|
||||
})
|
||||
.unwrap_or(
|
||||
wgpu::BackendBit::PRIMARY, /* | wgpu::BackendBit::SECONDARY */
|
||||
);
|
||||
|
||||
let instance = wgpu::Instance::new(backend_bit);
|
||||
|
||||
let dims = window.inner_size();
|
||||
@ -172,21 +180,26 @@ impl Renderer {
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let (device, queue) = futures::executor::block_on(adapter.request_device(
|
||||
&wgpu::DeviceDescriptor {
|
||||
// TODO
|
||||
label: None,
|
||||
features: wgpu::Features::DEPTH_CLAMPING
|
||||
let (device, queue) = futures::executor::block_on(
|
||||
adapter.request_device(
|
||||
&wgpu::DeviceDescriptor {
|
||||
// TODO
|
||||
label: None,
|
||||
features: wgpu::Features::DEPTH_CLAMPING
|
||||
| wgpu::Features::ADDRESS_MODE_CLAMP_TO_BORDER
|
||||
| wgpu::Features::PUSH_CONSTANTS
|
||||
// TODO: make optional based on enabling profiling
|
||||
// NOTE: requires recreating the device/queue is this setting changes
|
||||
// alternatively it could be a compile time feature toggle
|
||||
| (adapter.features() & wgpu_profiler::GpuProfiler::REQUIRED_WGPU_FEATURES),
|
||||
limits,
|
||||
},
|
||||
None,
|
||||
))?;
|
||||
limits,
|
||||
},
|
||||
std::env::var_os("WGPU_TRACE_DIR")
|
||||
.as_ref()
|
||||
.map(|v| std::path::Path::new(v))
|
||||
.or(Some("./wgpu-trace".as_ref())),
|
||||
),
|
||||
)?;
|
||||
|
||||
let profiler_features_enabled = device
|
||||
.features()
|
||||
|
Loading…
Reference in New Issue
Block a user