2017-08-04 15:56:24 +00:00
|
|
|
// Copyright 2017 Dolphin Emulator Project
|
2021-07-05 01:22:19 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2017-08-04 15:56:24 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2021-12-09 22:00:08 +00:00
|
|
|
#include <fmt/format.h>
|
|
|
|
#include <string>
|
|
|
|
|
2017-08-04 15:56:24 +00:00
|
|
|
#include "Common/CommonTypes.h"
|
2021-12-09 22:00:08 +00:00
|
|
|
|
2017-08-04 15:56:24 +00:00
|
|
|
#include "VideoCommon/ShaderGenCommon.h"
|
|
|
|
#include "VideoCommon/TextureDecoder.h"
|
|
|
|
|
|
|
|
enum class APIType;
|
|
|
|
|
2017-11-25 10:07:14 +00:00
|
|
|
namespace TextureConversionShaderGen
|
|
|
|
{
|
2017-08-04 15:56:24 +00:00
|
|
|
#pragma pack(1)
|
2017-11-25 10:07:14 +00:00
|
|
|
struct UidData
|
2017-08-04 15:56:24 +00:00
|
|
|
{
|
2017-11-25 10:07:14 +00:00
|
|
|
u32 NumValues() const { return sizeof(UidData); }
|
2017-08-04 15:56:24 +00:00
|
|
|
EFBCopyFormat dst_format;
|
|
|
|
|
|
|
|
u32 efb_has_alpha : 1;
|
|
|
|
u32 is_depth_copy : 1;
|
|
|
|
u32 is_intensity : 1;
|
|
|
|
u32 scale_by_half : 1;
|
2022-02-07 21:37:28 +00:00
|
|
|
u32 all_copy_filter_coefs_needed : 1;
|
|
|
|
u32 copy_filter_can_overflow : 1;
|
|
|
|
u32 apply_gamma : 1;
|
2017-08-04 15:56:24 +00:00
|
|
|
};
|
|
|
|
#pragma pack()
|
|
|
|
|
2017-11-25 10:07:14 +00:00
|
|
|
using TCShaderUid = ShaderUid<UidData>;
|
|
|
|
|
2019-02-15 01:59:50 +00:00
|
|
|
ShaderCode GenerateVertexShader(APIType api_type);
|
|
|
|
ShaderCode GeneratePixelShader(APIType api_type, const UidData* uid_data);
|
2017-08-04 15:56:24 +00:00
|
|
|
|
2017-11-25 10:07:14 +00:00
|
|
|
TCShaderUid GetShaderUid(EFBCopyFormat dst_format, bool is_depth_copy, bool is_intensity,
|
2022-02-07 21:37:28 +00:00
|
|
|
bool scale_by_half, float gamma_rcp,
|
|
|
|
const std::array<u32, 3>& filter_coefficients);
|
2017-08-04 15:56:24 +00:00
|
|
|
|
2017-11-25 10:07:14 +00:00
|
|
|
} // namespace TextureConversionShaderGen
|
2021-12-09 22:00:08 +00:00
|
|
|
|
|
|
|
template <>
|
|
|
|
struct fmt::formatter<TextureConversionShaderGen::UidData>
|
|
|
|
{
|
|
|
|
constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
|
|
|
|
template <typename FormatContext>
|
2022-01-13 01:16:29 +00:00
|
|
|
auto format(const TextureConversionShaderGen::UidData& uid, FormatContext& ctx) const
|
2021-12-09 22:00:08 +00:00
|
|
|
{
|
|
|
|
std::string dst_format;
|
|
|
|
if (uid.dst_format == EFBCopyFormat::XFB)
|
|
|
|
dst_format = "XFB";
|
|
|
|
else
|
|
|
|
dst_format = fmt::to_string(uid.dst_format);
|
2022-01-13 06:52:21 +00:00
|
|
|
return fmt::format_to(ctx.out(),
|
|
|
|
"dst_format: {}, efb_has_alpha: {}, is_depth_copy: {}, is_intensity: {}, "
|
2022-02-07 21:37:28 +00:00
|
|
|
"scale_by_half: {}, all_copy_filter_coefs_needed: {}, "
|
|
|
|
"copy_filter_can_overflow: {}, apply_gamma: {}",
|
2022-01-13 06:52:21 +00:00
|
|
|
dst_format, uid.efb_has_alpha, uid.is_depth_copy, uid.is_intensity,
|
2022-02-07 21:37:28 +00:00
|
|
|
uid.scale_by_half, uid.all_copy_filter_coefs_needed,
|
|
|
|
uid.copy_filter_can_overflow, uid.apply_gamma);
|
2021-12-09 22:00:08 +00:00
|
|
|
}
|
|
|
|
};
|