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