mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
Extra Profiling Scopes (#4610)
This commit is contained in:
parent
e0341c52cf
commit
2aa7c29068
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -4441,6 +4441,7 @@ dependencies = [
|
|||||||
"parking_lot",
|
"parking_lot",
|
||||||
"png",
|
"png",
|
||||||
"pollster",
|
"pollster",
|
||||||
|
"profiling",
|
||||||
"raw-window-handle 0.6.0",
|
"raw-window-handle 0.6.0",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
|||||||
@ -38,10 +38,11 @@ log.workspace = true
|
|||||||
parking_lot.workspace = true
|
parking_lot.workspace = true
|
||||||
png.workspace = true
|
png.workspace = true
|
||||||
pollster.workspace = true
|
pollster.workspace = true
|
||||||
|
profiling.workspace = true
|
||||||
serde_json.workspace = true
|
serde_json.workspace = true
|
||||||
serde.workspace = true
|
serde.workspace = true
|
||||||
wgpu.workspace = true
|
|
||||||
wgpu-macros.workspace = true
|
wgpu-macros.workspace = true
|
||||||
|
wgpu.workspace = true
|
||||||
wgt = { workspace = true, features = ["replay"] }
|
wgt = { workspace = true, features = ["replay"] }
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
|
|||||||
@ -77,9 +77,11 @@ pub fn main() -> MainResult {
|
|||||||
|
|
||||||
use crate::report::GpuReport;
|
use crate::report::GpuReport;
|
||||||
|
|
||||||
let config_text =
|
let config_text = {
|
||||||
|
profiling::scope!("Reading .gpuconfig");
|
||||||
&std::fs::read_to_string(format!("{}/../.gpuconfig", env!("CARGO_MANIFEST_DIR")))
|
&std::fs::read_to_string(format!("{}/../.gpuconfig", env!("CARGO_MANIFEST_DIR")))
|
||||||
.context("Failed to read .gpuconfig, did you run the tests via `cargo xtask test`?")?;
|
.context("Failed to read .gpuconfig, did you run the tests via `cargo xtask test`?")?
|
||||||
|
};
|
||||||
let report = GpuReport::from_json(config_text).context("Could not pare .gpuconfig JSON")?;
|
let report = GpuReport::from_json(config_text).context("Could not pare .gpuconfig JSON")?;
|
||||||
|
|
||||||
let mut test_guard = TEST_LIST.lock();
|
let mut test_guard = TEST_LIST.lock();
|
||||||
@ -98,7 +100,10 @@ pub fn main() -> MainResult {
|
|||||||
|
|
||||||
fn execute_native(tests: impl IntoIterator<Item = NativeTest>) {
|
fn execute_native(tests: impl IntoIterator<Item = NativeTest>) {
|
||||||
let args = libtest_mimic::Arguments::from_args();
|
let args = libtest_mimic::Arguments::from_args();
|
||||||
let trials = tests.into_iter().map(NativeTest::into_trial).collect();
|
let trials = {
|
||||||
|
profiling::scope!("collecting tests");
|
||||||
|
tests.into_iter().map(NativeTest::into_trial).collect()
|
||||||
|
};
|
||||||
|
|
||||||
libtest_mimic::run(&args, trials).exit_if_failed();
|
libtest_mimic::run(&args, trials).exit_if_failed();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,6 +17,7 @@ pub(crate) struct GpuReport {
|
|||||||
impl GpuReport {
|
impl GpuReport {
|
||||||
#[cfg_attr(target_arch = "wasm32", allow(unused))]
|
#[cfg_attr(target_arch = "wasm32", allow(unused))]
|
||||||
pub(crate) fn from_json(file: &str) -> serde_json::Result<Self> {
|
pub(crate) fn from_json(file: &str) -> serde_json::Result<Self> {
|
||||||
|
profiling::scope!("Parsing .gpuconfig");
|
||||||
serde_json::from_str(file)
|
serde_json::from_str(file)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,8 @@ use crate::auxil;
|
|||||||
|
|
||||||
impl crate::Instance<super::Api> for super::Instance {
|
impl crate::Instance<super::Api> for super::Instance {
|
||||||
unsafe fn init(desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
|
unsafe fn init(desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
|
||||||
|
profiling::scope!("Init DX11 Backend");
|
||||||
|
|
||||||
let enable_dx11 = match std::env::var("WGPU_UNSTABLE_DX11_BACKEND") {
|
let enable_dx11 = match std::env::var("WGPU_UNSTABLE_DX11_BACKEND") {
|
||||||
Ok(string) => string == "1" || string == "true",
|
Ok(string) => string == "1" || string == "true",
|
||||||
Err(_) => false,
|
Err(_) => false,
|
||||||
|
|||||||
@ -12,6 +12,7 @@ impl Drop for super::Instance {
|
|||||||
|
|
||||||
impl crate::Instance<super::Api> for super::Instance {
|
impl crate::Instance<super::Api> for super::Instance {
|
||||||
unsafe fn init(desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
|
unsafe fn init(desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
|
||||||
|
profiling::scope!("Init DX12 Backend");
|
||||||
let lib_main = d3d12::D3D12Lib::new().map_err(|e| {
|
let lib_main = d3d12::D3D12Lib::new().map_err(|e| {
|
||||||
crate::InstanceError::with_source(String::from("failed to load d3d12.dll"), e)
|
crate::InstanceError::with_source(String::from("failed to load d3d12.dll"), e)
|
||||||
})?;
|
})?;
|
||||||
|
|||||||
@ -674,6 +674,7 @@ unsafe impl Sync for Instance {}
|
|||||||
|
|
||||||
impl crate::Instance<super::Api> for Instance {
|
impl crate::Instance<super::Api> for Instance {
|
||||||
unsafe fn init(desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
|
unsafe fn init(desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
|
||||||
|
profiling::scope!("Init OpenGL (EGL) Backend");
|
||||||
#[cfg(target_os = "emscripten")]
|
#[cfg(target_os = "emscripten")]
|
||||||
let egl_result: Result<EglInstance, khronos_egl::Error> =
|
let egl_result: Result<EglInstance, khronos_egl::Error> =
|
||||||
Ok(khronos_egl::Instance::new(khronos_egl::Static));
|
Ok(khronos_egl::Instance::new(khronos_egl::Static));
|
||||||
|
|||||||
@ -124,6 +124,7 @@ unsafe impl Send for Instance {}
|
|||||||
|
|
||||||
impl crate::Instance<super::Api> for Instance {
|
impl crate::Instance<super::Api> for Instance {
|
||||||
unsafe fn init(_desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
|
unsafe fn init(_desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
|
||||||
|
profiling::scope!("Init OpenGL (WebGL) Backend");
|
||||||
Ok(Instance {
|
Ok(Instance {
|
||||||
webgl2_context: Mutex::new(None),
|
webgl2_context: Mutex::new(None),
|
||||||
})
|
})
|
||||||
|
|||||||
@ -321,6 +321,7 @@ fn get_global_device_context() -> Result<HDC, crate::InstanceError> {
|
|||||||
|
|
||||||
impl crate::Instance<super::Api> for Instance {
|
impl crate::Instance<super::Api> for Instance {
|
||||||
unsafe fn init(desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
|
unsafe fn init(desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
|
||||||
|
profiling::scope!("Init OpenGL (WGL) Backend");
|
||||||
let opengl_module = unsafe { LoadLibraryA("opengl32.dll\0".as_ptr() as *const _) };
|
let opengl_module = unsafe { LoadLibraryA("opengl32.dll\0".as_ptr() as *const _) };
|
||||||
if opengl_module.is_null() {
|
if opengl_module.is_null() {
|
||||||
return Err(crate::InstanceError::with_source(
|
return Err(crate::InstanceError::with_source(
|
||||||
|
|||||||
@ -80,6 +80,7 @@ impl Instance {
|
|||||||
|
|
||||||
impl crate::Instance<Api> for Instance {
|
impl crate::Instance<Api> for Instance {
|
||||||
unsafe fn init(_desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
|
unsafe fn init(_desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
|
||||||
|
profiling::scope!("Init Metal Backend");
|
||||||
// We do not enable metal validation based on the validation flags as it affects the entire
|
// We do not enable metal validation based on the validation flags as it affects the entire
|
||||||
// process. Instead, we enable the validation inside the test harness itself in tests/src/native.rs.
|
// process. Instead, we enable the validation inside the test harness itself in tests/src/native.rs.
|
||||||
Ok(Instance {
|
Ok(Instance {
|
||||||
|
|||||||
@ -209,9 +209,11 @@ impl super::Instance {
|
|||||||
_instance_api_version: u32,
|
_instance_api_version: u32,
|
||||||
flags: wgt::InstanceFlags,
|
flags: wgt::InstanceFlags,
|
||||||
) -> Result<Vec<&'static CStr>, crate::InstanceError> {
|
) -> Result<Vec<&'static CStr>, crate::InstanceError> {
|
||||||
let instance_extensions = entry
|
let instance_extensions = {
|
||||||
.enumerate_instance_extension_properties(None)
|
profiling::scope!("vkEnumerateInstanceExtensionProperties");
|
||||||
.map_err(|e| {
|
entry.enumerate_instance_extension_properties(None)
|
||||||
|
};
|
||||||
|
let instance_extensions = instance_extensions.map_err(|e| {
|
||||||
crate::InstanceError::with_source(
|
crate::InstanceError::with_source(
|
||||||
String::from("enumerate_instance_extension_properties() failed"),
|
String::from("enumerate_instance_extension_properties() failed"),
|
||||||
e,
|
e,
|
||||||
@ -570,12 +572,21 @@ impl Drop for super::InstanceShared {
|
|||||||
|
|
||||||
impl crate::Instance<super::Api> for super::Instance {
|
impl crate::Instance<super::Api> for super::Instance {
|
||||||
unsafe fn init(desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
|
unsafe fn init(desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
|
||||||
|
profiling::scope!("Init Vulkan Backend");
|
||||||
use crate::auxil::cstr_from_bytes_until_nul;
|
use crate::auxil::cstr_from_bytes_until_nul;
|
||||||
|
|
||||||
let entry = unsafe { ash::Entry::load() }.map_err(|err| {
|
let entry = unsafe {
|
||||||
|
profiling::scope!("Load vk library");
|
||||||
|
ash::Entry::load()
|
||||||
|
}
|
||||||
|
.map_err(|err| {
|
||||||
crate::InstanceError::with_source(String::from("missing Vulkan entry points"), err)
|
crate::InstanceError::with_source(String::from("missing Vulkan entry points"), err)
|
||||||
})?;
|
})?;
|
||||||
let instance_api_version = match entry.try_enumerate_instance_version() {
|
let version = {
|
||||||
|
profiling::scope!("vkEnumerateInstanceVersion");
|
||||||
|
entry.try_enumerate_instance_version()
|
||||||
|
};
|
||||||
|
let instance_api_version = match version {
|
||||||
// Vulkan 1.1+
|
// Vulkan 1.1+
|
||||||
Ok(Some(version)) => version,
|
Ok(Some(version)) => version,
|
||||||
Ok(None) => vk::API_VERSION_1_0,
|
Ok(None) => vk::API_VERSION_1_0,
|
||||||
@ -612,7 +623,11 @@ impl crate::Instance<super::Api> for super::Instance {
|
|||||||
|
|
||||||
let extensions = Self::desired_extensions(&entry, instance_api_version, desc.flags)?;
|
let extensions = Self::desired_extensions(&entry, instance_api_version, desc.flags)?;
|
||||||
|
|
||||||
let instance_layers = entry.enumerate_instance_layer_properties().map_err(|e| {
|
let instance_layers = {
|
||||||
|
profiling::scope!("vkEnumerateInstanceLayerProperties");
|
||||||
|
entry.enumerate_instance_layer_properties()
|
||||||
|
};
|
||||||
|
let instance_layers = instance_layers.map_err(|e| {
|
||||||
log::info!("enumerate_instance_layer_properties: {:?}", e);
|
log::info!("enumerate_instance_layer_properties: {:?}", e);
|
||||||
crate::InstanceError::with_source(
|
crate::InstanceError::with_source(
|
||||||
String::from("enumerate_instance_layer_properties() failed"),
|
String::from("enumerate_instance_layer_properties() failed"),
|
||||||
@ -708,7 +723,11 @@ impl crate::Instance<super::Api> for super::Instance {
|
|||||||
.enabled_layer_names(&str_pointers[..layers.len()])
|
.enabled_layer_names(&str_pointers[..layers.len()])
|
||||||
.enabled_extension_names(&str_pointers[layers.len()..]);
|
.enabled_extension_names(&str_pointers[layers.len()..]);
|
||||||
|
|
||||||
unsafe { entry.create_instance(&create_info, None) }.map_err(|e| {
|
unsafe {
|
||||||
|
profiling::scope!("vkCreateInstance");
|
||||||
|
entry.create_instance(&create_info, None)
|
||||||
|
}
|
||||||
|
.map_err(|e| {
|
||||||
crate::InstanceError::with_source(
|
crate::InstanceError::with_source(
|
||||||
String::from("Entry::create_instance() failed"),
|
String::from("Entry::create_instance() failed"),
|
||||||
e,
|
e,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user