@@ -81,6 +81,18 @@ pub type SharedGraphicsServer = Rc<dyn GraphicsServer>;
8181
8282define_as_any_trait ! ( GraphicsServerAsAny => GraphicsServer ) ;
8383
84+ pub struct RenderingScope {
85+ server : Weak < dyn GraphicsServer > ,
86+ }
87+
88+ impl Drop for RenderingScope {
89+ fn drop ( & mut self ) {
90+ if let Some ( server) = self . server . upgrade ( ) {
91+ server. pop_debug_group ( ) ;
92+ }
93+ }
94+ }
95+
8496/// Graphics server is an abstraction layer over various graphics APIs used on different platforms
8597/// supported by the engine. Such abstraction layer tries to provide more or less high-level and
8698/// unified interface, that can be used to build graphics pipelines quickly and more or less efficiently.
@@ -168,7 +180,7 @@ pub trait GraphicsServer: GraphicsServerAsAny {
168180 ) -> Result < GpuGeometryBuffer , FrameworkError > ;
169181
170182 /// Creates a weak reference to the shared graphics server.
171- fn weak ( self : Rc < Self > ) -> Weak < dyn GraphicsServer > ;
183+ fn weak ( & self ) -> Weak < dyn GraphicsServer > ;
172184
173185 /// Sends all scheduled GPU command buffers for execution on GPU without waiting for a certain
174186 /// threshold.
@@ -216,6 +228,14 @@ pub trait GraphicsServer: GraphicsServerAsAny {
216228 /// Ends the current debug group.
217229 fn pop_debug_group ( & self ) ;
218230
231+ fn begin_scope ( & self , name : & str ) -> RenderingScope {
232+ self . push_debug_group ( name) ;
233+
234+ RenderingScope {
235+ server : self . weak ( ) ,
236+ }
237+ }
238+
219239 /// A shortcut for [`Self::create_texture`], that creates a rectangular texture with the given
220240 /// size and pixel kind.
221241 fn create_2d_render_target (
0 commit comments