Checkpoint: Get basic workspace rendering

Nathan Sobo created

Change summary

crates/gpui3/src/platform/mac/metal_renderer.rs | 47 -------------
crates/storybook2/src/storybook2.rs             |  9 -
crates/storybook2/src/workspace.rs              | 64 +++++++-----------
3 files changed, 29 insertions(+), 91 deletions(-)

Detailed changes

crates/gpui3/src/platform/mac/metal_renderer.rs 🔗

@@ -1,37 +1,3 @@
-// How can I fix this?
-// -[MTLDebugRenderCommandEncoder setRenderPipelineState:]:1580: failed assertion `Set Render Pipeline State Validation
-// For depth attachment, the render pipeline's pixelFormat (MTLPixelFormatInvalid) does not match the framebuffer's pixelFormat (MTLPixelFormatDepth32Float).
-// '
-// -[MTLDebugRenderCommandEncoder setRenderPipelineState:]:1580: failed assertion `Set Render Pipeline State Validation
-// For depth attachment, the render pipeline's pixelFormat (MTLPixelFormatInvalid) does not match the framebuffer's pixelFormat (MTLPixelFormatDepth32Float).
-// // It seems like the error you're facing has to do with the difference between the
-// pixel format of the render pipeline and the framebuffer. If the pixel format of
-// those two doesn't match, Metal throws an error. To resolve this issue, you need
-// to set the pixel format of your depth attachment and your render pipeline state
-// to the same value.
-
-// In this code:
-// ---
-/*
-descriptor.set_depth_attachment_pixel_format(MTLPixelFormat::Depth32Float);
-*/
-// ---
-// you've commented out the line where you set the depth attachment pixel format
-// to MTLPixelFormat::Depth32Float. If you uncomment this line, it should resolve
-// the error as your depth attachment's pixel format will then match your framebuffer's.
-
-// If you still encounter the same problem, you might be configuring another render
-// pipeline state elsewhere in your code with a different depth pixel format. Make
-// sure all configurations have matching pixel formats.
-
-// Additionally, be aware of the limitations of certain pixel formats. For example,
-// not all pixel formats support depth stencil attachments, and some are only
-// compatible with certain types of GPU hardware. Implementation of pixel formats
-// can vary between different versions of iOS, so ensure that your choice of pixel
-// format is compatible with your minimum target version.
-//
-// I want it to be UANorm
-
 use crate::{
     point, size, AtlasTextureId, DevicePixels, GlyphRasterParams, MetalAtlas, MonochromeSprite,
     Quad, Scene, Size,
@@ -182,19 +148,6 @@ impl MetalRenderer {
         let command_buffer = command_queue.new_command_buffer();
 
         let render_pass_descriptor = metal::RenderPassDescriptor::new();
-
-        // let depth_texture_desc = metal::TextureDescriptor::new();
-        // depth_texture_desc.set_pixel_format(metal::MTLPixelFormat::Depth32Float);
-        // depth_texture_desc.set_storage_mode(metal::MTLStorageMode::Private);
-        // depth_texture_desc.set_usage(metal::MTLTextureUsage::RenderTarget);
-        // depth_texture_desc.set_width(i32::from(viewport_size.width) as u64);
-        // depth_texture_desc.set_height(i32::from(viewport_size.height) as u64);
-        // let depth_texture = self.device.new_texture(&depth_texture_desc);
-        // let depth_attachment = render_pass_descriptor.depth_attachment().unwrap();
-        // depth_attachment.set_texture(Some(&depth_texture));
-        // depth_attachment.set_clear_depth(1.);
-        // depth_attachment.set_store_action(metal::MTLStoreAction::Store);
-
         let color_attachment = render_pass_descriptor
             .color_attachments()
             .object_at(0)

crates/storybook2/src/storybook2.rs 🔗

@@ -1,6 +1,6 @@
 #![allow(dead_code, unused_variables)]
 
-use gpui3::{Bounds, WindowBounds, WindowOptions};
+use gpui3::{px, size, Bounds, WindowBounds, WindowOptions};
 use log::LevelFilter;
 use simplelog::SimpleLogger;
 
@@ -23,11 +23,8 @@ fn main() {
         let window = cx.open_window(
             WindowOptions {
                 bounds: WindowBounds::Fixed(Bounds {
-                    size: gpui3::Size {
-                        width: 800_f32.into(),
-                        height: 600_f32.into(),
-                    },
-                    ..Default::default()
+                    origin: Default::default(),
+                    size: size(px(800.), px(600.)),
                 }),
                 ..Default::default()
             },

crates/storybook2/src/workspace.rs 🔗

@@ -1,6 +1,6 @@
 use crate::{
     collab_panel::{collab_panel, CollabPanel},
-    theme::theme,
+    theme::{theme, themed},
     themes::rose_pine_dawn,
 };
 use gpui3::{
@@ -27,43 +27,31 @@ impl Workspace {
 
     fn render(&mut self, cx: &mut ViewContext<Self>) -> impl Element<State = Self> {
         let theme = rose_pine_dawn();
-        div()
-            .size_full()
-            .font("Helvetica")
-            .text_base()
-            .fill(white())
-            .text_color(black())
-            .child("The quick brown fox ran over the lazy dog.")
-
-        // TODO: Implement style.
-        //.size_full().fill(gpui3::hsla(0.83, 1., 0.5, 1.))
-
-        // themed(rose_pine_dawn(), cx, |cx| {
-        //     div()
-        //         .size_full()
-        //         .flex()
-        //         .flex_col()
-        //         .font("Zed Sans Extended")
-        //         .gap_0()
-        //         .justify_start()
-        //         .items_start()
-        //         .text_color(theme.lowest.base.default.foreground)
-        //         // .fill(theme.middle.base.default.background)
-        //         .fill(gpui3::hsla(0.83, 1., 0.5, 1.))
-        //         .child(titlebar(cx))
-        //         .child(
-        //             div()
-        //                 .flex_1()
-        //                 .w_full()
-        //                 .flex()
-        //                 .flex_row()
-        //                 .overflow_hidden()
-        //                 .child(self.left_panel.clone())
-        //                 .child(div().h_full().flex_1())
-        //                 .child(self.right_panel.clone()),
-        //         )
-        //         .child(statusbar::statusbar(cx))
-        // })
+        themed(rose_pine_dawn(), cx, |cx| {
+            div()
+                .size_full()
+                .flex()
+                .flex_col()
+                .font("Zed Sans Extended")
+                .gap_0()
+                .justify_start()
+                .items_start()
+                .text_color(theme.lowest.base.default.foreground)
+                .fill(theme.middle.base.default.background)
+                .child(titlebar(cx))
+                .child(
+                    div()
+                        .flex_1()
+                        .w_full()
+                        .flex()
+                        .flex_row()
+                        .overflow_hidden()
+                        .child(self.left_panel.clone())
+                        .child(div().h_full().flex_1())
+                        .child(self.right_panel.clone()),
+                )
+                .child(statusbar::statusbar(cx))
+        })
     }
 }