From e608cf4719edf97113df6a974d8a2676d406f906 Mon Sep 17 00:00:00 2001 From: devil-ira Date: Tue, 21 Mar 2023 17:33:13 +0100 Subject: [PATCH] Specialize on hdr --- crates/bevy_gizmos/src/pipeline_2d.rs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/crates/bevy_gizmos/src/pipeline_2d.rs b/crates/bevy_gizmos/src/pipeline_2d.rs index dd959182b5290..f3ab5be25cba8 100644 --- a/crates/bevy_gizmos/src/pipeline_2d.rs +++ b/crates/bevy_gizmos/src/pipeline_2d.rs @@ -12,7 +12,7 @@ use bevy_render::{ render_phase::{DrawFunctions, RenderPhase, SetItemPipeline}, render_resource::*, texture::BevyDefault, - view::Msaa, + view::{ExtractedView, Msaa, ViewTarget}, }; use bevy_sprite::*; use bevy_utils::FloatOrd; @@ -47,6 +47,12 @@ impl SpecializedMeshPipeline for GizmoLinePipeline { Mesh::ATTRIBUTE_COLOR.at_shader_location(1), ])?; + let format = if key.contains(Mesh2dPipelineKey::HDR) { + ViewTarget::TEXTURE_FORMAT_HDR + } else { + TextureFormat::bevy_default() + }; + Ok(RenderPipelineDescriptor { vertex: VertexState { shader: self.shader.clone_weak(), @@ -59,7 +65,7 @@ impl SpecializedMeshPipeline for GizmoLinePipeline { shader_defs: vec![], entry_point: "fragment".into(), targets: vec![Some(ColorTargetState { - format: TextureFormat::bevy_default(), + format, blend: Some(BlendState::ALPHA_BLENDING), write_mask: ColorWrites::ALL, })], @@ -97,11 +103,12 @@ pub(crate) fn queue_gizmos_2d( gpu_meshes: Res>, msaa: Res, mesh_handles: Query<(Entity, &Mesh2dHandle), With>, - mut views: Query<&mut RenderPhase>, + mut views: Query<(&ExtractedView, &mut RenderPhase)>, ) { let draw_function = draw_functions.read().get_id::().unwrap(); let key = Mesh2dPipelineKey::from_msaa_samples(msaa.samples()); - for mut phase in &mut views { + for (view, mut phase) in &mut views { + let key = key | Mesh2dPipelineKey::from_hdr(view.hdr); for (entity, mesh_handle) in &mesh_handles { let Some(mesh) = gpu_meshes.get(&mesh_handle.0) else { continue; };