From f3f4f88b4b006d6187041bb8b65d7c42de718d9c Mon Sep 17 00:00:00 2001 From: Zephyron Date: Fri, 2 Jan 2026 17:51:22 +1000 Subject: [PATCH] feat(shader): add SamplerComponentType enum and infrastructure Add SamplerComponentType enum to classify texture component types (float, signed int, unsigned int, depth, stencil) and add ReadTextureComponentType method to Environment interface. - Add SamplerComponentType enum with constexpr helper functions - Add component_type field to TextureDescriptor struct - Add ReadTextureComponentType virtual method to Environment base class Co-Authored-By: ForrestMarkX Signed-off-by: Zephyron --- src/shader_recompiler/environment.h | 6 ++++++ src/shader_recompiler/shader_info.h | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/shader_recompiler/environment.h b/src/shader_recompiler/environment.h index 5dbbc7e61..217f0d404 100644 --- a/src/shader_recompiler/environment.h +++ b/src/shader_recompiler/environment.h @@ -1,4 +1,5 @@ // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 citron Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once @@ -22,6 +23,11 @@ public: [[nodiscard]] virtual TextureType ReadTextureType(u32 raw_handle) = 0; + /// Read the component type of a texture from its raw handle + /// @param raw_handle The raw texture handle to query + /// @return The component type of the texture (float, signed int, unsigned int, depth, or stencil) + [[nodiscard]] virtual SamplerComponentType ReadTextureComponentType(u32 raw_handle) = 0; + [[nodiscard]] virtual TexturePixelFormat ReadTexturePixelFormat(u32 raw_handle) = 0; [[nodiscard]] virtual bool IsTexturePixelFormatInteger(u32 raw_handle) = 0; diff --git a/src/shader_recompiler/shader_info.h b/src/shader_recompiler/shader_info.h index 74c402632..78cc285c4 100644 --- a/src/shader_recompiler/shader_info.h +++ b/src/shader_recompiler/shader_info.h @@ -158,6 +158,25 @@ enum class ImageFormat : u32 { R32G32B32A32_SFLOAT, }; +/// Texture sampler component type classification +enum class SamplerComponentType : u8 { + Float, ///< Floating-point texture components + Sint, ///< Signed integer texture components + Uint, ///< Unsigned integer texture components + Depth, ///< Depth texture components + Stencil, ///< Stencil texture components +}; + +/// Check if a component type represents an integer type +[[nodiscard]] constexpr bool IsInteger(SamplerComponentType type) noexcept { + return type == SamplerComponentType::Sint || type == SamplerComponentType::Uint; +} + +/// Check if a component type represents a depth or stencil type +[[nodiscard]] constexpr bool IsDepthStencil(SamplerComponentType type) noexcept { + return type == SamplerComponentType::Depth || type == SamplerComponentType::Stencil; +} + enum class Interpolation { Smooth, Flat, @@ -211,6 +230,7 @@ using ImageBufferDescriptors = boost::container::small_vector