From c256c3848634b0f2fd9c26fdc25a6583a0e51da9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kurt=20K=C3=BChnert?= Date: Thu, 15 Sep 2022 15:57:04 +0000 Subject: [PATCH] Add TextureFormat::Rg16Unorm support for Image and derive Resource for SpecializedComputePipelines (#5991) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Objective Currently some TextureFormats are not supported by the Image type. The `TextureFormat::Rg16Unorm` format is useful for storing minmax heightmaps. Similar to #5249 I now additionally require image to support the dual channel variant. ## Solution Added `TextureFormat::Rg16Unorm` support to Image. Additionally this PR derives `Resource` for `SpecializedComputePipelines`, because for some reason this was missing. All other special pipelines do derive `Resource` already. Co-authored-by: Kurt Kühnert <51823519+Ku95@users.noreply.github.com> --- .../bevy_render/src/render_resource/pipeline_specializer.rs | 1 + crates/bevy_render/src/texture/image.rs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/bevy_render/src/render_resource/pipeline_specializer.rs b/crates/bevy_render/src/render_resource/pipeline_specializer.rs index c8faa95a7c..d685ca7f22 100644 --- a/crates/bevy_render/src/render_resource/pipeline_specializer.rs +++ b/crates/bevy_render/src/render_resource/pipeline_specializer.rs @@ -49,6 +49,7 @@ pub trait SpecializedComputePipeline { fn specialize(&self, key: Self::Key) -> ComputePipelineDescriptor; } +#[derive(Resource)] pub struct SpecializedComputePipelines { cache: HashMap, } diff --git a/crates/bevy_render/src/texture/image.rs b/crates/bevy_render/src/texture/image.rs index 132bcceea4..36a0708a99 100644 --- a/crates/bevy_render/src/texture/image.rs +++ b/crates/bevy_render/src/texture/image.rs @@ -539,9 +539,10 @@ impl TextureFormatPixelInfo for TextureFormat { TextureFormat::R16Uint | TextureFormat::R16Sint | TextureFormat::R16Float + | TextureFormat::R16Unorm | TextureFormat::Rg16Uint | TextureFormat::Rg16Sint - | TextureFormat::R16Unorm + | TextureFormat::Rg16Unorm | TextureFormat::Rg16Float | TextureFormat::Rgba16Uint | TextureFormat::Rgba16Sint @@ -587,6 +588,7 @@ impl TextureFormatPixelInfo for TextureFormat { | TextureFormat::Rg8Sint | TextureFormat::Rg16Uint | TextureFormat::Rg16Sint + | TextureFormat::Rg16Unorm | TextureFormat::Rg16Float | TextureFormat::Rg32Uint | TextureFormat::Rg32Sint