summaryrefslogtreecommitdiffstats
path: root/src/video_core/texture_cache/image_view_info.h
blob: 921f889883acb0d1ce881f02dd0c43cf2b69e537 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <array>
#include <type_traits>

#include "video_core/surface.h"
#include "video_core/texture_cache/types.h"
#include "video_core/textures/texture.h"

namespace VideoCommon {

using Tegra::Texture::SwizzleSource;
using Tegra::Texture::TICEntry;
using VideoCore::Surface::PixelFormat;

/// Properties used to determine a image view
struct ImageViewInfo {
    explicit ImageViewInfo() noexcept = default;
    explicit ImageViewInfo(const TICEntry& config, s32 base_layer) noexcept;
    explicit ImageViewInfo(ImageViewType type, PixelFormat format,
                           SubresourceRange range = {}) noexcept;

    auto operator<=>(const ImageViewInfo&) const noexcept = default;

    [[nodiscard]] bool IsRenderTarget() const noexcept;

    [[nodiscard]] std::array<SwizzleSource, 4> Swizzle() const noexcept {
        return std::array{
            static_cast<SwizzleSource>(x_source),
            static_cast<SwizzleSource>(y_source),
            static_cast<SwizzleSource>(z_source),
            static_cast<SwizzleSource>(w_source),
        };
    }

    ImageViewType type{};
    PixelFormat format{};
    SubresourceRange range;
    u8 x_source = static_cast<u8>(SwizzleSource::R);
    u8 y_source = static_cast<u8>(SwizzleSource::G);
    u8 z_source = static_cast<u8>(SwizzleSource::B);
    u8 w_source = static_cast<u8>(SwizzleSource::A);
};
static_assert(std::has_unique_object_representations_v<ImageViewInfo>);

} // namespace VideoCommon