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",
|
||||
"png",
|
||||
"pollster",
|
||||
"profiling",
|
||||
"raw-window-handle 0.6.0",
|
||||
"serde",
|
||||
"serde_json",
|
||||
|
||||
@ -38,10 +38,11 @@ log.workspace = true
|
||||
parking_lot.workspace = true
|
||||
png.workspace = true
|
||||
pollster.workspace = true
|
||||
profiling.workspace = true
|
||||
serde_json.workspace = true
|
||||
serde.workspace = true
|
||||
wgpu.workspace = true
|
||||
wgpu-macros.workspace = true
|
||||
wgpu.workspace = true
|
||||
wgt = { workspace = true, features = ["replay"] }
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
|
||||
@ -77,9 +77,11 @@ pub fn main() -> MainResult {
|
||||
|
||||
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")))
|
||||
.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 mut test_guard = TEST_LIST.lock();
|
||||
@ -98,7 +100,10 @@ pub fn main() -> MainResult {
|
||||
|
||||
fn execute_native(tests: impl IntoIterator<Item = NativeTest>) {
|
||||
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();
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@ pub(crate) struct GpuReport {
|
||||
impl GpuReport {
|
||||
#[cfg_attr(target_arch = "wasm32", allow(unused))]
|
||||
pub(crate) fn from_json(file: &str) -> serde_json::Result<Self> {
|
||||
profiling::scope!("Parsing .gpuconfig");
|
||||
serde_json::from_str(file)
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,6 +2,8 @@ use crate::auxil;
|
||||
|
||||
impl crate::Instance<super::Api> for super::Instance {
|
||||
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") {
|
||||
Ok(string) => string == "1" || string == "true",
|
||||
Err(_) => false,
|
||||
|
||||
@ -12,6 +12,7 @@ impl Drop for super::Instance {
|
||||
|
||||
impl crate::Instance<super::Api> for super::Instance {
|
||||
unsafe fn init(desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
|
||||
profiling::scope!("Init DX12 Backend");
|
||||
let lib_main = d3d12::D3D12Lib::new().map_err(|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 {
|
||||
unsafe fn init(desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
|
||||
profiling::scope!("Init OpenGL (EGL) Backend");
|
||||
#[cfg(target_os = "emscripten")]
|
||||
let egl_result: Result<EglInstance, khronos_egl::Error> =
|
||||
Ok(khronos_egl::Instance::new(khronos_egl::Static));
|
||||
|
||||
@ -124,6 +124,7 @@ unsafe impl Send for Instance {}
|
||||
|
||||
impl crate::Instance<super::Api> for Instance {
|
||||
unsafe fn init(_desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
|
||||
profiling::scope!("Init OpenGL (WebGL) Backend");
|
||||
Ok(Instance {
|
||||
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 {
|
||||
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 _) };
|
||||
if opengl_module.is_null() {
|
||||
return Err(crate::InstanceError::with_source(
|
||||
|
||||
@ -80,6 +80,7 @@ impl Instance {
|
||||
|
||||
impl crate::Instance<Api> for Instance {
|
||||
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
|
||||
// process. Instead, we enable the validation inside the test harness itself in tests/src/native.rs.
|
||||
Ok(Instance {
|
||||
|
||||
@ -209,14 +209,16 @@ impl super::Instance {
|
||||
_instance_api_version: u32,
|
||||
flags: wgt::InstanceFlags,
|
||||
) -> Result<Vec<&'static CStr>, crate::InstanceError> {
|
||||
let instance_extensions = entry
|
||||
.enumerate_instance_extension_properties(None)
|
||||
.map_err(|e| {
|
||||
crate::InstanceError::with_source(
|
||||
String::from("enumerate_instance_extension_properties() failed"),
|
||||
e,
|
||||
)
|
||||
})?;
|
||||
let instance_extensions = {
|
||||
profiling::scope!("vkEnumerateInstanceExtensionProperties");
|
||||
entry.enumerate_instance_extension_properties(None)
|
||||
};
|
||||
let instance_extensions = instance_extensions.map_err(|e| {
|
||||
crate::InstanceError::with_source(
|
||||
String::from("enumerate_instance_extension_properties() failed"),
|
||||
e,
|
||||
)
|
||||
})?;
|
||||
|
||||
// Check our extensions against the available extensions
|
||||
let mut extensions: Vec<&'static CStr> = Vec::new();
|
||||
@ -570,12 +572,21 @@ impl Drop for super::InstanceShared {
|
||||
|
||||
impl crate::Instance<super::Api> for super::Instance {
|
||||
unsafe fn init(desc: &crate::InstanceDescriptor) -> Result<Self, crate::InstanceError> {
|
||||
profiling::scope!("Init Vulkan Backend");
|
||||
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)
|
||||
})?;
|
||||
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+
|
||||
Ok(Some(version)) => version,
|
||||
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 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);
|
||||
crate::InstanceError::with_source(
|
||||
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_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(
|
||||
String::from("Entry::create_instance() failed"),
|
||||
e,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user