Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

render: fix vulkan formats for pre-multiplied alpha #88

Merged
merged 1 commit into from
Feb 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ pub static ARGB8888: &Format = &Format {
bpp: 4,
gl_format: GL_BGRA_EXT,
gl_type: GL_UNSIGNED_BYTE,
vk_format: vk::Format::B8G8R8A8_SRGB,
vk_format: vk::Format::B8G8R8A8_UNORM,
drm: ARGB8888_DRM,
wl_id: Some(ARGB8888_ID),
external_only_guess: false,
Expand All @@ -107,7 +107,7 @@ pub static XRGB8888: &Format = &Format {
bpp: 4,
gl_format: GL_BGRA_EXT,
gl_type: GL_UNSIGNED_BYTE,
vk_format: vk::Format::B8G8R8A8_SRGB,
vk_format: vk::Format::B8G8R8A8_UNORM,
drm: XRGB8888_DRM,
wl_id: Some(XRGB8888_ID),
external_only_guess: false,
Expand All @@ -125,7 +125,7 @@ pub static FORMATS: &[Format] = &[
bpp: 4,
gl_format: GL_RGBA,
gl_type: GL_UNSIGNED_BYTE,
vk_format: vk::Format::R8G8B8A8_SRGB,
vk_format: vk::Format::R8G8B8A8_UNORM,
drm: fourcc_code('A', 'B', '2', '4'),
wl_id: None,
external_only_guess: false,
Expand All @@ -138,7 +138,7 @@ pub static FORMATS: &[Format] = &[
bpp: 4,
gl_format: GL_RGBA,
gl_type: GL_UNSIGNED_BYTE,
vk_format: vk::Format::R8G8B8A8_SRGB,
vk_format: vk::Format::R8G8B8A8_UNORM,
drm: fourcc_code('X', 'B', '2', '4'),
wl_id: None,
external_only_guess: false,
Expand Down
4 changes: 2 additions & 2 deletions src/gfx_apis/vulkan/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ impl VulkanRenderer {
rai = rai
.clear_value(ClearValue {
color: ClearColorValue {
float32: clear.to_array_linear(),
float32: clear.to_array_srgb(),
},
})
.load_op(AttachmentLoadOp::CLEAR);
Expand Down Expand Up @@ -413,7 +413,7 @@ impl VulkanRenderer {
pos: r.rect.to_vk(width, height),
};
let frag = FillFragPushConstants {
color: r.color.to_array_linear(),
color: r.color.to_array_srgb(),
};
unsafe {
dev.cmd_push_constants(
Expand Down
2 changes: 1 addition & 1 deletion src/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,11 @@ impl Color {
[to_u8(self.r), to_u8(self.g), to_u8(self.b), to_u8(self.a)]
}

#[allow(dead_code)]
pub fn to_array_srgb(self) -> [f32; 4] {
[self.r, self.g, self.b, self.a]
}

#[allow(dead_code)]
pub fn to_array_linear(self) -> [f32; 4] {
fn to_linear(srgb: f32) -> f32 {
if srgb <= 0.04045 {
Expand Down
Loading