wgpu: Hook up wgpu renderer, and wgpu's profiling, to tracy
This commit is contained in:
parent
f606735720
commit
4d85b6a75b
|
@ -3227,6 +3227,20 @@ name = "profiling"
|
||||||
version = "1.0.7"
|
version = "1.0.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "74605f360ce573babfe43964cbe520294dcb081afbf8c108fc6e23036b4da2df"
|
checksum = "74605f360ce573babfe43964cbe520294dcb081afbf8c108fc6e23036b4da2df"
|
||||||
|
dependencies = [
|
||||||
|
"profiling-procmacros",
|
||||||
|
"tracy-client",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "profiling-procmacros"
|
||||||
|
version = "1.0.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7a1e2417ef905b8ad94215f8a607bd2d0f5d13d416d18dca4a530811e8a0674c"
|
||||||
|
dependencies = [
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quick-xml"
|
name = "quick-xml"
|
||||||
|
@ -3586,13 +3600,14 @@ dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"gc-arena",
|
"gc-arena",
|
||||||
"image",
|
"image",
|
||||||
"log",
|
|
||||||
"naga-agal",
|
"naga-agal",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"ouroboros",
|
"ouroboros",
|
||||||
|
"profiling",
|
||||||
"raw-window-handle 0.5.0",
|
"raw-window-handle 0.5.0",
|
||||||
"ruffle_render",
|
"ruffle_render",
|
||||||
"swf",
|
"swf",
|
||||||
|
"tracing",
|
||||||
"typed-arena",
|
"typed-arena",
|
||||||
"web-sys",
|
"web-sys",
|
||||||
"wgpu",
|
"wgpu",
|
||||||
|
@ -4505,9 +4520,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracing-tracy"
|
name = "tracing-tracy"
|
||||||
version = "0.10.1"
|
version = "0.10.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "74513033e242c0109c2ba9cb6d94117a53dbd6511eb135f5512143136eeba311"
|
checksum = "ed3ebef1f9f0d00aaa29239537effef65b82c56040c680f540fc6cedfac7b230"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"tracing-core",
|
"tracing-core",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
|
@ -4527,9 +4542,9 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tracy-client"
|
name = "tracy-client"
|
||||||
version = "0.15.0"
|
version = "0.14.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c615e58172e788a208faee61b74988cd9c4778bc782384bed540b3fa4e5d4436"
|
checksum = "8b3b9ab635a5b91dd66b7a1591a89f7d52423e6a9143b230bb4c503f41296c0c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"loom",
|
"loom",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
|
|
|
@ -25,7 +25,9 @@ isahc = "1.7.2"
|
||||||
rfd = "0.10.0"
|
rfd = "0.10.0"
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
bytemuck = "1.12.3"
|
bytemuck = "1.12.3"
|
||||||
tracing-tracy = { version = "0.10.1", optional = true }
|
|
||||||
|
# Deliberately held back to match tracy client used by profiling crate
|
||||||
|
tracing-tracy = { version = "=0.10.0", optional = true }
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
winapi = "0.3.9"
|
winapi = "0.3.9"
|
||||||
|
@ -40,7 +42,7 @@ default = ["software_video"]
|
||||||
avm_debug = ["ruffle_core/avm_debug"]
|
avm_debug = ["ruffle_core/avm_debug"]
|
||||||
lzma = ["ruffle_core/lzma"]
|
lzma = ["ruffle_core/lzma"]
|
||||||
software_video = ["ruffle_video_software"]
|
software_video = ["ruffle_video_software"]
|
||||||
tracy = ["tracing-tracy"]
|
tracy = ["tracing-tracy", "ruffle_render_wgpu/profile-with-tracy"]
|
||||||
|
|
||||||
# wgpu features
|
# wgpu features
|
||||||
render_debug_labels = ["ruffle_render_wgpu/render_debug_labels"]
|
render_debug_labels = ["ruffle_render_wgpu/render_debug_labels"]
|
||||||
|
|
|
@ -9,7 +9,7 @@ version.workspace = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
wgpu = { git = "https://github.com/gfx-rs/wgpu", rev = "630c12fe47a7bc0dc9ec6217f3903ec6fd6e3fac", features = ["naga"] }
|
wgpu = { git = "https://github.com/gfx-rs/wgpu", rev = "630c12fe47a7bc0dc9ec6217f3903ec6fd6e3fac", features = ["naga"] }
|
||||||
log = "0.4"
|
tracing = "0.1.37"
|
||||||
ruffle_render = { path = "..", features = ["tessellator"] }
|
ruffle_render = { path = "..", features = ["tessellator"] }
|
||||||
bytemuck = { version = "1.12.3", features = ["derive"] }
|
bytemuck = { version = "1.12.3", features = ["derive"] }
|
||||||
raw-window-handle = "0.5"
|
raw-window-handle = "0.5"
|
||||||
|
@ -24,6 +24,7 @@ once_cell = "1.17.0"
|
||||||
gc-arena = { workspace = true }
|
gc-arena = { workspace = true }
|
||||||
naga-agal = { path = "../naga-agal" }
|
naga-agal = { path = "../naga-agal" }
|
||||||
downcast-rs = "1.2.0"
|
downcast-rs = "1.2.0"
|
||||||
|
profiling = { version = "1.0", default-features = false, optional = true }
|
||||||
|
|
||||||
# desktop
|
# desktop
|
||||||
[target.'cfg(not(target_family = "wasm"))'.dependencies.futures]
|
[target.'cfg(not(target_family = "wasm"))'.dependencies.futures]
|
||||||
|
@ -38,3 +39,4 @@ features = ["HtmlCanvasElement"]
|
||||||
render_debug_labels = []
|
render_debug_labels = []
|
||||||
render_trace = ["wgpu/trace"]
|
render_trace = ["wgpu/trace"]
|
||||||
webgl = ["wgpu/webgl"]
|
webgl = ["wgpu/webgl"]
|
||||||
|
profile-with-tracy = ["profiling", "profiling/profile-with-tracy"]
|
||||||
|
|
|
@ -22,6 +22,7 @@ use std::num::NonZeroU32;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use swf::Color;
|
use swf::Color;
|
||||||
|
use tracing::instrument;
|
||||||
use wgpu::Extent3d;
|
use wgpu::Extent3d;
|
||||||
|
|
||||||
pub struct WgpuRenderBackend<T: RenderTarget> {
|
pub struct WgpuRenderBackend<T: RenderTarget> {
|
||||||
|
@ -72,7 +73,7 @@ impl WgpuRenderBackend<SwapChainTarget> {
|
||||||
trace_path: Option<&Path>,
|
trace_path: Option<&Path>,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
if wgpu::Backends::SECONDARY.contains(backend) {
|
if wgpu::Backends::SECONDARY.contains(backend) {
|
||||||
log::warn!(
|
tracing::warn!(
|
||||||
"{} graphics backend support may not be fully supported.",
|
"{} graphics backend support may not be fully supported.",
|
||||||
format_list(&get_backend_names(backend), "and")
|
format_list(&get_backend_names(backend), "and")
|
||||||
);
|
);
|
||||||
|
@ -100,7 +101,7 @@ impl WgpuRenderBackend<crate::target::TextureTarget> {
|
||||||
trace_path: Option<&Path>,
|
trace_path: Option<&Path>,
|
||||||
) -> Result<Self, Error> {
|
) -> Result<Self, Error> {
|
||||||
if wgpu::Backends::SECONDARY.contains(backend) {
|
if wgpu::Backends::SECONDARY.contains(backend) {
|
||||||
log::warn!(
|
tracing::warn!(
|
||||||
"{} graphics backend support may not be fully supported.",
|
"{} graphics backend support may not be fully supported.",
|
||||||
format_list(&get_backend_names(backend), "and")
|
format_list(&get_backend_names(backend), "and")
|
||||||
);
|
);
|
||||||
|
@ -298,6 +299,7 @@ impl<T: RenderTarget + 'static> RenderBackend for WgpuRenderBackend<T> {
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(level = "debug", skip_all)]
|
||||||
fn context3d_present<'gc>(
|
fn context3d_present<'gc>(
|
||||||
&mut self,
|
&mut self,
|
||||||
context: &mut dyn Context3D,
|
context: &mut dyn Context3D,
|
||||||
|
@ -346,6 +348,7 @@ impl<T: RenderTarget + 'static> RenderBackend for WgpuRenderBackend<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(level = "debug", skip_all)]
|
||||||
fn register_shape(
|
fn register_shape(
|
||||||
&mut self,
|
&mut self,
|
||||||
shape: DistilledShape,
|
shape: DistilledShape,
|
||||||
|
@ -357,6 +360,7 @@ impl<T: RenderTarget + 'static> RenderBackend for WgpuRenderBackend<T> {
|
||||||
handle
|
handle
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(level = "debug", skip_all)]
|
||||||
fn replace_shape(
|
fn replace_shape(
|
||||||
&mut self,
|
&mut self,
|
||||||
shape: DistilledShape,
|
shape: DistilledShape,
|
||||||
|
@ -367,6 +371,7 @@ impl<T: RenderTarget + 'static> RenderBackend for WgpuRenderBackend<T> {
|
||||||
self.meshes[handle.0] = mesh;
|
self.meshes[handle.0] = mesh;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(level = "debug", skip_all)]
|
||||||
fn register_glyph_shape(&mut self, glyph: &swf::Glyph) -> ShapeHandle {
|
fn register_glyph_shape(&mut self, glyph: &swf::Glyph) -> ShapeHandle {
|
||||||
let shape = ruffle_render::shape_utils::swf_glyph_to_shape(glyph);
|
let shape = ruffle_render::shape_utils::swf_glyph_to_shape(glyph);
|
||||||
let handle = ShapeHandle(self.meshes.len());
|
let handle = ShapeHandle(self.meshes.len());
|
||||||
|
@ -378,11 +383,12 @@ impl<T: RenderTarget + 'static> RenderBackend for WgpuRenderBackend<T> {
|
||||||
handle
|
handle
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(level = "debug", skip_all)]
|
||||||
fn submit_frame(&mut self, clear: Color, commands: CommandList) {
|
fn submit_frame(&mut self, clear: Color, commands: CommandList) {
|
||||||
let frame_output = match self.target.get_next_texture() {
|
let frame_output = match self.target.get_next_texture() {
|
||||||
Ok(frame) => frame,
|
Ok(frame) => frame,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::warn!("Couldn't begin new render frame: {}", e);
|
tracing::warn!("Couldn't begin new render frame: {}", e);
|
||||||
// Attempt to recreate the swap chain in this case.
|
// Attempt to recreate the swap chain in this case.
|
||||||
self.target.resize(
|
self.target.resize(
|
||||||
&self.descriptors.device,
|
&self.descriptors.device,
|
||||||
|
@ -420,6 +426,7 @@ impl<T: RenderTarget + 'static> RenderBackend for WgpuRenderBackend<T> {
|
||||||
self.offscreen_texture_pool = TexturePool::new();
|
self.offscreen_texture_pool = TexturePool::new();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(level = "debug", skip_all)]
|
||||||
fn register_bitmap(&mut self, bitmap: Bitmap) -> Result<BitmapHandle, BitmapError> {
|
fn register_bitmap(&mut self, bitmap: Bitmap) -> Result<BitmapHandle, BitmapError> {
|
||||||
if bitmap.width() > self.descriptors.limits.max_texture_dimension_2d
|
if bitmap.width() > self.descriptors.limits.max_texture_dimension_2d
|
||||||
|| bitmap.height() > self.descriptors.limits.max_texture_dimension_2d
|
|| bitmap.height() > self.descriptors.limits.max_texture_dimension_2d
|
||||||
|
@ -479,6 +486,7 @@ impl<T: RenderTarget + 'static> RenderBackend for WgpuRenderBackend<T> {
|
||||||
Ok(handle)
|
Ok(handle)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(level = "debug", skip_all)]
|
||||||
fn update_texture(
|
fn update_texture(
|
||||||
&mut self,
|
&mut self,
|
||||||
handle: &BitmapHandle,
|
handle: &BitmapHandle,
|
||||||
|
@ -513,6 +521,7 @@ impl<T: RenderTarget + 'static> RenderBackend for WgpuRenderBackend<T> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(level = "debug", skip_all)]
|
||||||
fn render_offscreen(
|
fn render_offscreen(
|
||||||
&mut self,
|
&mut self,
|
||||||
handle: BitmapHandle,
|
handle: BitmapHandle,
|
||||||
|
|
|
@ -174,7 +174,7 @@ impl CurrentPipeline {
|
||||||
Context3DTriangleFace::Back => Some(wgpu::Face::Back),
|
Context3DTriangleFace::Back => Some(wgpu::Face::Back),
|
||||||
Context3DTriangleFace::Front => Some(wgpu::Face::Front),
|
Context3DTriangleFace::Front => Some(wgpu::Face::Front),
|
||||||
Context3DTriangleFace::FrontAndBack => {
|
Context3DTriangleFace::FrontAndBack => {
|
||||||
log::error!("FrontAndBack culling not supported!");
|
tracing::error!("FrontAndBack culling not supported!");
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
Context3DTriangleFace::None => None,
|
Context3DTriangleFace::None => None,
|
||||||
|
|
|
@ -225,7 +225,7 @@ impl WgpuContext3D {
|
||||||
mask,
|
mask,
|
||||||
} => {
|
} => {
|
||||||
if *mask != COLOR_MASK | DEPTH_MASK | STENCIL_MASK {
|
if *mask != COLOR_MASK | DEPTH_MASK | STENCIL_MASK {
|
||||||
log::warn!(
|
tracing::warn!(
|
||||||
"Context3D::present: Clear command with mask {:x} not implemeneted",
|
"Context3D::present: Clear command with mask {:x} not implemeneted",
|
||||||
mask
|
mask
|
||||||
);
|
);
|
||||||
|
@ -253,12 +253,14 @@ impl WgpuContext3D {
|
||||||
wants_best_resolution_on_browser_zoom: _,
|
wants_best_resolution_on_browser_zoom: _,
|
||||||
} => {
|
} => {
|
||||||
if *anti_alias != 1 {
|
if *anti_alias != 1 {
|
||||||
log::warn!(
|
tracing::warn!(
|
||||||
"configureBackBuffer: anti_alias={anti_alias} is not yet implemented"
|
"configureBackBuffer: anti_alias={anti_alias} is not yet implemented"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if *depth_and_stencil {
|
if *depth_and_stencil {
|
||||||
log::warn!("configureBackBuffer: depth_and_stencil is not yet implemented");
|
tracing::warn!(
|
||||||
|
"configureBackBuffer: depth_and_stencil is not yet implemented"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let texture_label = create_debug_label!("Render target texture");
|
let texture_label = create_debug_label!("Render target texture");
|
||||||
|
@ -358,7 +360,7 @@ impl WgpuContext3D {
|
||||||
);
|
);
|
||||||
|
|
||||||
if !seen_clear_command {
|
if !seen_clear_command {
|
||||||
log::warn!("Context3D::present: drawTriangles called without first calling clear()");
|
tracing::warn!("Context3D::present: drawTriangles called without first calling clear()");
|
||||||
}
|
}
|
||||||
|
|
||||||
if new_pipeline.is_some() || render_pass.is_none() {
|
if new_pipeline.is_some() || render_pass.is_none() {
|
||||||
|
|
|
@ -11,6 +11,7 @@ use crate::{ColorAdjustments, Descriptors, MaskState, Pipelines, Transforms, Uni
|
||||||
use ruffle_render::commands::CommandList;
|
use ruffle_render::commands::CommandList;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use target::CommandTarget;
|
use target::CommandTarget;
|
||||||
|
use tracing::instrument;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Surface {
|
pub struct Surface {
|
||||||
|
@ -47,6 +48,7 @@ impl Surface {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[instrument(level = "debug", skip_all)]
|
||||||
pub fn draw_commands_to(
|
pub fn draw_commands_to(
|
||||||
&mut self,
|
&mut self,
|
||||||
frame_view: &wgpu::TextureView,
|
frame_view: &wgpu::TextureView,
|
||||||
|
@ -165,6 +167,7 @@ impl Surface {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
#[instrument(level = "debug", skip_all)]
|
||||||
pub fn draw_commands<'frame, 'global: 'frame>(
|
pub fn draw_commands<'frame, 'global: 'frame>(
|
||||||
&mut self,
|
&mut self,
|
||||||
clear_color: wgpu::Color,
|
clear_color: wgpu::Color,
|
||||||
|
|
|
@ -3,6 +3,7 @@ use crate::Error;
|
||||||
use ruffle_render::utils::unmultiply_alpha_rgba;
|
use ruffle_render::utils::unmultiply_alpha_rgba;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
use tracing::instrument;
|
||||||
|
|
||||||
pub trait RenderTargetFrame: Debug {
|
pub trait RenderTargetFrame: Debug {
|
||||||
fn into_view(self) -> wgpu::TextureView;
|
fn into_view(self) -> wgpu::TextureView;
|
||||||
|
@ -123,6 +124,7 @@ impl RenderTarget for SwapChainTarget {
|
||||||
Ok(SwapChainTargetFrame { texture, view })
|
Ok(SwapChainTargetFrame { texture, view })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(level = "debug", skip_all)]
|
||||||
fn submit<I: IntoIterator<Item = wgpu::CommandBuffer>>(
|
fn submit<I: IntoIterator<Item = wgpu::CommandBuffer>>(
|
||||||
&self,
|
&self,
|
||||||
_device: &wgpu::Device,
|
_device: &wgpu::Device,
|
||||||
|
@ -209,6 +211,7 @@ impl TextureTarget {
|
||||||
|
|
||||||
/// Captures the current contents of our texture buffer
|
/// Captures the current contents of our texture buffer
|
||||||
/// as an `RgbaImage`
|
/// as an `RgbaImage`
|
||||||
|
#[instrument(level = "debug", skip_all)]
|
||||||
pub fn capture(
|
pub fn capture(
|
||||||
&self,
|
&self,
|
||||||
device: &wgpu::Device,
|
device: &wgpu::Device,
|
||||||
|
@ -251,7 +254,7 @@ impl TextureTarget {
|
||||||
image
|
image
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!("Unknown error reading capture buffer: {:?}", e);
|
tracing::error!("Unknown error reading capture buffer: {:?}", e);
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -284,6 +287,7 @@ impl RenderTarget for TextureTarget {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[instrument(level = "debug", skip_all)]
|
||||||
fn submit<I: IntoIterator<Item = wgpu::CommandBuffer>>(
|
fn submit<I: IntoIterator<Item = wgpu::CommandBuffer>>(
|
||||||
&self,
|
&self,
|
||||||
device: &wgpu::Device,
|
device: &wgpu::Device,
|
||||||
|
|
Loading…
Reference in New Issue