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 <forrestmarkx@outlook.com>
Signed-off-by: Zephyron <zephyron@citron-emu.org>
This commit is contained in:
Zephyron
2026-01-02 17:51:22 +10:00
parent f8de99641f
commit f3f4f88b4b
2 changed files with 26 additions and 0 deletions

View File

@@ -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;

View File

@@ -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<ImageBufferDescrip
struct TextureDescriptor {
TextureType type;
SamplerComponentType component_type;
bool is_depth;
bool is_multisample;
bool is_integer;