linux: switch to srgb color space output (#7666)

Dzmitry Malyshau created

This matches the behavior of the existing Metal backend.

Picks up https://github.com/kvark/blade/pull/76

Release Notes:
- N/A

Change summary

Cargo.lock                                       |  4 +-
crates/gpui/Cargo.toml                           |  4 +-
crates/gpui/src/platform/linux/blade_renderer.rs | 23 ++++++++++-------
3 files changed, 17 insertions(+), 14 deletions(-)

Detailed changes

Cargo.lock 🔗

@@ -937,7 +937,7 @@ dependencies = [
 [[package]]
 name = "blade-graphics"
 version = "0.3.0"
-source = "git+https://github.com/kvark/blade?rev=26bc5e8b9ef67b4f2970eb95888db733eace98f3#26bc5e8b9ef67b4f2970eb95888db733eace98f3"
+source = "git+https://github.com/kvark/blade?rev=c4f951a88b345724cb952e920ad30e39851f7760#c4f951a88b345724cb952e920ad30e39851f7760"
 dependencies = [
  "ash",
  "ash-window",
@@ -967,7 +967,7 @@ dependencies = [
 [[package]]
 name = "blade-macros"
 version = "0.2.1"
-source = "git+https://github.com/kvark/blade?rev=26bc5e8b9ef67b4f2970eb95888db733eace98f3#26bc5e8b9ef67b4f2970eb95888db733eace98f3"
+source = "git+https://github.com/kvark/blade?rev=c4f951a88b345724cb952e920ad30e39851f7760#c4f951a88b345724cb952e920ad30e39851f7760"
 dependencies = [
  "proc-macro2",
  "quote",

crates/gpui/Cargo.toml 🔗

@@ -99,7 +99,7 @@ flume = "0.11"
 xcb = { version = "1.3", features = ["as-raw-xcb-connection"] }
 as-raw-xcb-connection = "1"
 #TODO: use these on all platforms
-blade-graphics = { git = "https://github.com/kvark/blade", rev = "26bc5e8b9ef67b4f2970eb95888db733eace98f3" }
-blade-macros = { git = "https://github.com/kvark/blade", rev = "26bc5e8b9ef67b4f2970eb95888db733eace98f3" }
+blade-graphics = { git = "https://github.com/kvark/blade", rev = "c4f951a88b345724cb952e920ad30e39851f7760" }
+blade-macros = { git = "https://github.com/kvark/blade", rev = "c4f951a88b345724cb952e920ad30e39851f7760" }
 bytemuck = "1"
 cosmic-text = "0.10.0"

crates/gpui/src/platform/linux/blade_renderer.rs 🔗

@@ -237,12 +237,19 @@ pub struct BladeRenderer {
 }
 
 impl BladeRenderer {
-    pub fn new(gpu: Arc<gpu::Context>, size: gpu::Extent) -> Self {
-        let surface_format = gpu.resize(gpu::SurfaceConfig {
+    fn make_surface_config(size: gpu::Extent) -> gpu::SurfaceConfig {
+        gpu::SurfaceConfig {
             size,
             usage: gpu::TextureUsage::TARGET,
             frame_count: SURFACE_FRAME_COUNT,
-        });
+            //Note: this matches the original logic of the Metal backend,
+            // but ultimaterly we need to switch to `Linear`.
+            color_space: gpu::ColorSpace::Srgb,
+        }
+    }
+
+    pub fn new(gpu: Arc<gpu::Context>, size: gpu::Extent) -> Self {
+        let surface_format = gpu.resize(Self::make_surface_config(size));
         let command_encoder = gpu.create_command_encoder(gpu::CommandEncoderDesc {
             name: "main",
             buffer_count: 2,
@@ -291,11 +298,7 @@ impl BladeRenderer {
 
     pub fn resize(&mut self, size: gpu::Extent) {
         self.wait_for_gpu();
-        self.gpu.resize(gpu::SurfaceConfig {
-            size,
-            usage: gpu::TextureUsage::TARGET,
-            frame_count: SURFACE_FRAME_COUNT,
-        });
+        self.gpu.resize(Self::make_surface_config(size));
         self.viewport_size = size;
     }
 
@@ -455,7 +458,7 @@ impl BladeRenderer {
                         sprites,
                     } => {
                         let tex_info = self.atlas.get_texture_info(texture_id);
-                        let instance_buf = self.instance_belt.alloc_data(sprites, &self.gpu);
+                        let instance_buf = self.instance_belt.alloc_data(&sprites, &self.gpu);
                         let mut encoder = pass.with(&self.pipelines.mono_sprites);
                         encoder.bind(
                             0,
@@ -473,7 +476,7 @@ impl BladeRenderer {
                         sprites,
                     } => {
                         let tex_info = self.atlas.get_texture_info(texture_id);
-                        let instance_buf = self.instance_belt.alloc_data(sprites, &self.gpu);
+                        let instance_buf = self.instance_belt.alloc_data(&sprites, &self.gpu);
                         let mut encoder = pass.with(&self.pipelines.poly_sprites);
                         encoder.bind(
                             0,