Skip to content

Commit

Permalink
refactor: refactor rendering scopes and command encoding
Browse files Browse the repository at this point in the history
- update default required features to include `target_os = "linux"`
- update mask scope to be of type `&mut commandencoder` instead of `encode`
- update `mask_scope` in `renderer` for `context_scope` in different parts of the code
- update `begin_render_pass` scope for `mask_scope` and `content_scope` to have `renderpassdescriptor` parameters
  • Loading branch information
falcucci committed Sep 19, 2024
1 parent bf10625 commit e951a50
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ impl Renderer {
}

pub fn add_default_required_features() -> Features {
#[cfg(target_os = "macos")]
#[cfg(any(target_os = "macos", target_os = "linux"))]
{
Features::PUSH_CONSTANTS
| Features::VERTEX_WRITABLE_STORAGE
Expand Down Expand Up @@ -399,7 +399,7 @@ impl Renderer {
#[cfg(not(any(target_os = "macos", target_os = "linux")))]
let mut mask_scope = self.profiler.scope("mask", encoder, &self.device);

#[cfg(target_os = "macos")]
#[cfg(any(target_os = "macos", target_os = "linux"))]
let mask_scope: &mut CommandEncoder = encoder;

if let Some(mask_contents) = mask_contents {
Expand All @@ -424,7 +424,7 @@ impl Renderer {
},
);

#[cfg(target_os = "macos")]
#[cfg(any(target_os = "macos", target_os = "linux"))]
let render_pass = mask_scope.begin_render_pass(&RenderPassDescriptor {
label: Some("Render Pass"),
color_attachments: &[Some(RenderPassColorAttachment {
Expand All @@ -448,7 +448,7 @@ impl Renderer {
#[cfg(not(any(target_os = "macos", target_os = "linux")))]
let mut drawable_scope = render_pass.scope(&drawable.name, &self.device);

#[cfg(target_os = "macos")]
#[cfg(any(target_os = "macos", target_os = "linux"))]
let mut drawable_scope = render_pass;

if !drawable.ready() {
Expand Down Expand Up @@ -502,7 +502,7 @@ impl Renderer {
},
);

#[cfg(target_os = "macos")]
#[cfg(any(target_os = "macos", target_os = "linux"))]
mask_scope.begin_render_pass(&RenderPassDescriptor {
label: Some("Clear Mask Texture"),
color_attachments: &[Some(RenderPassColorAttachment {
Expand Down Expand Up @@ -536,7 +536,7 @@ impl Renderer {
.profiler
.scope("content", context.encoder, &self.device);

#[cfg(target_os = "macos")]
#[cfg(any(target_os = "macos", target_os = "linux"))]
let content_scope = context.encoder;

if *context.first {
Expand All @@ -560,7 +560,7 @@ impl Renderer {
},
);

#[cfg(target_os = "macos")]
#[cfg(any(target_os = "macos", target_os = "linux"))]
content_scope.begin_render_pass(&RenderPassDescriptor {
label: Some("Clear Offscreen Texture"),
color_attachments: &[Some(RenderPassColorAttachment {
Expand All @@ -583,7 +583,7 @@ impl Renderer {
let mut copy_scope =
content_scope.scope("Copy Frame to Offscreen", &self.device);

#[cfg(target_os = "macos")]
#[cfg(any(target_os = "macos", target_os = "linux"))]
let copy_scope = &mut *content_scope;

copy_scope.copy_texture_to_texture(
Expand Down Expand Up @@ -646,7 +646,7 @@ impl Renderer {
},
);

#[cfg(target_os = "macos")]
#[cfg(any(target_os = "macos", target_os = "linux"))]
let render_pass = content_scope.begin_render_pass(&RenderPassDescriptor {
label: Some("Render Pass"),
color_attachments: &[Some(RenderPassColorAttachment {
Expand All @@ -663,7 +663,7 @@ impl Renderer {
#[cfg(not(any(target_os = "macos", target_os = "linux")))]
let mut drawable_scope = render_pass.scope(&drawable.name, &self.device);

#[cfg(target_os = "macos")]
#[cfg(any(target_os = "macos", target_os = "linux"))]
let mut drawable_scope = render_pass;

if !drawable.ready() {
Expand Down

0 comments on commit e951a50

Please sign in to comment.