]> git.nega.tv - josh/narcissus/commitdiff
shark: Use command buffer debug markers
authorJosh Simmons <josh@nega.tv>
Tue, 4 Jun 2024 20:43:15 +0000 (22:43 +0200)
committerJosh Simmons <josh@nega.tv>
Tue, 4 Jun 2024 20:43:15 +0000 (22:43 +0200)
title/shark/src/main.rs
title/shark/src/microshades.rs [new file with mode: 0644]

index 0742a0cda7a8af5fea1fc03825d079b4995be67e..75fe96e3f9b19d5e9a23c86759cee91b92bf7808 100644 (file)
@@ -35,6 +35,7 @@ use crate::pipelines::primitive_2d::{PrimitiveUniforms, TILE_SIZE, TILE_STRIDE};
 
 mod fonts;
 mod helpers;
+pub mod microshades;
 mod pipelines;
 mod spring;
 
@@ -812,6 +813,8 @@ impl Images {
             {
                 let cmd_encoder = &mut cmd_encoder;
 
+                gpu.cmd_begin_marker(cmd_encoder, "image upload", microshades::BROWN_RGBA_F32[3]);
+
                 images = Images {
                     tony_mc_mapface_lut: load_dds(
                         gpu,
@@ -828,6 +831,8 @@ impl Images {
                         "title/shark/data/blĂ„haj.png",
                     ),
                 };
+
+                gpu.cmd_end_marker(cmd_encoder);
             }
 
             gpu.submit(frame, cmd_encoder);
@@ -1088,6 +1093,12 @@ impl<'gpu> DrawState<'gpu> {
 
             // If the atlas has been updated, we need to upload it to the GPU.
             if let Some(texture) = glyph_texture {
+                gpu.cmd_begin_marker(
+                    cmd_encoder,
+                    "upload glyph atlas",
+                    microshades::BROWN_RGBA_F32[3],
+                );
+
                 let buffer = gpu.request_transient_buffer_with_data(
                     frame,
                     thread_token,
@@ -1131,6 +1142,8 @@ impl<'gpu> DrawState<'gpu> {
                         ImageAspectFlags::COLOR,
                     )],
                 );
+
+                gpu.cmd_end_marker(cmd_encoder);
             }
 
             gpu.cmd_barrier(
@@ -1154,6 +1167,8 @@ impl<'gpu> DrawState<'gpu> {
                 ],
             );
 
+            gpu.cmd_begin_marker(cmd_encoder, "sharks", microshades::BLUE_RGBA_F32[3]);
+
             gpu.cmd_begin_rendering(
                 cmd_encoder,
                 &RenderingDesc {
@@ -1288,8 +1303,16 @@ impl<'gpu> DrawState<'gpu> {
 
             gpu.cmd_end_rendering(cmd_encoder);
 
+            gpu.cmd_end_marker(cmd_encoder);
+
             // Render UI
             {
+                gpu.cmd_begin_marker(
+                    cmd_encoder,
+                    "2d primitives",
+                    microshades::PURPLE_RGBA_F32[3],
+                );
+
                 let glyph_buffer = gpu.request_transient_buffer_with_data(
                     frame,
                     thread_token,
@@ -1409,10 +1432,18 @@ impl<'gpu> DrawState<'gpu> {
                 gpu.cmd_set_pipeline(cmd_encoder, self.primitive_2d_pipeline.rasterize_pipeline);
 
                 gpu.cmd_dispatch(cmd_encoder, (self.width + 7) / 8, (self.height + 7) / 8, 1);
+
+                gpu.cmd_end_marker(cmd_encoder);
             }
 
             // Display transform and composite
             {
+                gpu.cmd_begin_marker(
+                    cmd_encoder,
+                    "display transform",
+                    microshades::GREEN_RGBA_F32[3],
+                );
+
                 gpu.cmd_barrier(
                     cmd_encoder,
                     None,
@@ -1492,6 +1523,8 @@ impl<'gpu> DrawState<'gpu> {
                 );
 
                 gpu.cmd_dispatch(cmd_encoder, (self.width + 7) / 8, (self.height + 7) / 8, 1);
+
+                gpu.cmd_end_marker(cmd_encoder);
             }
         }
         gpu.submit(frame, cmd_encoder);
diff --git a/title/shark/src/microshades.rs b/title/shark/src/microshades.rs
new file mode 100644 (file)
index 0000000..dca00fd
--- /dev/null
@@ -0,0 +1,69 @@
+//! microshades
+//! ===
+//!
+//! The microshades package is designed to provide custom color shading palettes
+//! that improve accessibility and data organization. Approximately 300 million
+//! people in the world have Color Vision Deficiency (CVD), which is comparable
+//! to the most recent estimate of the US population. When creating figures and
+//! graphics that use color, it is important to consider that individuals with
+//! CVD will interact with this material, and may not perceive all of the
+//! information tied to the colors as intended. This package includes carefully
+//! crafted palettes that improve CVD accessibility and may be applied to any
+//! plot.
+//!
+//! https://karstenslab.github.io/project/microshades/
+
+pub const GRAY_RGBA8: [u32; 5] = [0xd9d9d9ff, 0xbdbdbdff, 0x969696ff, 0x737373ff, 0x525252ff];
+pub const BROWN_RGBA8: [u32; 5] = [0xD8C7BEff, 0xCAA995ff, 0xB78560ff, 0x9E5C00ff, 0x7D3200ff];
+pub const GREEN_RGBA8: [u32; 5] = [0xc7e9c0ff, 0xa1d99bff, 0x74c476ff, 0x41ab5dff, 0x238b45ff];
+pub const ORANGE_RGBA8: [u32; 5] = [0xfeeda0ff, 0xfec44fff, 0xfdae6bff, 0xfe9929ff, 0xff7f00ff];
+pub const BLUE_RGBA8: [u32; 5] = [0xeff3ffff, 0xc6dbefff, 0x9ecae1ff, 0x6baed6ff, 0x4292c6ff];
+pub const PURPLE_RGBA8: [u32; 5] = [0xdadaebff, 0xbcbddcff, 0x9e9ac8ff, 0x807dbaff, 0x6a51a3ff];
+
+pub const GRAY_RGBA_F32: [[f32; 4]; 5] = [
+    [0.8509804, 0.8509804, 0.8509804, 1.0],
+    [0.7411765, 0.7411765, 0.7411765, 1.0],
+    [0.5882353, 0.5882353, 0.5882353, 1.0],
+    [0.4509804, 0.4509804, 0.4509804, 1.0],
+    [0.32156864, 0.32156864, 0.32156864, 1.0],
+];
+
+pub const BROWN_RGBA_F32: [[f32; 4]; 5] = [
+    [0.84705883, 0.78039217, 0.74509805, 1.0],
+    [0.7921569, 0.6627451, 0.58431375, 1.0],
+    [0.7176471, 0.52156866, 0.3764706, 1.0],
+    [0.61960787, 0.36078432, 0.0, 1.0],
+    [0.49019608, 0.19607843, 0.0, 1.0],
+];
+
+pub const GREEN_RGBA_F32: [[f32; 4]; 5] = [
+    [0.78039217, 0.9137255, 0.7529412, 1.0],
+    [0.6313726, 0.8509804, 0.60784316, 1.0],
+    [0.45490196, 0.76862746, 0.4627451, 1.0],
+    [0.25490198, 0.67058825, 0.3647059, 1.0],
+    [0.13725491, 0.54509807, 0.27058825, 1.0],
+];
+
+pub const ORANGE_RGBA_F32: [[f32; 4]; 5] = [
+    [0.99607843, 0.92941177, 0.627451, 1.0],
+    [0.99607843, 0.76862746, 0.30980393, 1.0],
+    [0.99215686, 0.68235296, 0.41960785, 1.0],
+    [0.99607843, 0.6, 0.16078432, 1.0],
+    [1.0, 0.49803922, 0.0, 1.0],
+];
+
+pub const BLUE_RGBA_F32: [[f32; 4]; 5] = [
+    [0.9372549, 0.9529412, 1.0, 1.0],
+    [0.7764706, 0.85882354, 0.9372549, 1.0],
+    [0.61960787, 0.7921569, 0.88235295, 1.0],
+    [0.41960785, 0.68235296, 0.8392157, 1.0],
+    [0.25882354, 0.57254905, 0.7764706, 1.0],
+];
+
+pub const PURPLE_RGBA_F32: [[f32; 4]; 5] = [
+    [0.85490197, 0.85490197, 0.92156863, 1.0],
+    [0.7372549, 0.7411765, 0.8627451, 1.0],
+    [0.61960787, 0.6039216, 0.78431374, 1.0],
+    [0.5019608, 0.49019608, 0.7294118, 1.0],
+    [0.41568628, 0.31764707, 0.6392157, 1.0],
+];