TextureConverterShaderGen.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // Copyright 2017 Dolphin Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <fmt/format.h>
  5. #include <string>
  6. #include "Common/CommonTypes.h"
  7. #include "VideoCommon/ShaderGenCommon.h"
  8. #include "VideoCommon/TextureDecoder.h"
  9. enum class APIType;
  10. namespace TextureConversionShaderGen
  11. {
  12. #pragma pack(1)
  13. struct UidData
  14. {
  15. u32 NumValues() const { return sizeof(UidData); }
  16. EFBCopyFormat dst_format;
  17. u32 efb_has_alpha : 1;
  18. u32 is_depth_copy : 1;
  19. u32 is_intensity : 1;
  20. u32 scale_by_half : 1;
  21. u32 all_copy_filter_coefs_needed : 1;
  22. u32 copy_filter_can_overflow : 1;
  23. u32 apply_gamma : 1;
  24. };
  25. #pragma pack()
  26. using TCShaderUid = ShaderUid<UidData>;
  27. ShaderCode GenerateVertexShader(APIType api_type);
  28. ShaderCode GeneratePixelShader(APIType api_type, const UidData* uid_data);
  29. TCShaderUid GetShaderUid(EFBCopyFormat dst_format, bool is_depth_copy, bool is_intensity,
  30. bool scale_by_half, float gamma_rcp,
  31. const std::array<u32, 3>& filter_coefficients);
  32. } // namespace TextureConversionShaderGen
  33. template <>
  34. struct fmt::formatter<TextureConversionShaderGen::UidData>
  35. {
  36. constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
  37. template <typename FormatContext>
  38. auto format(const TextureConversionShaderGen::UidData& uid, FormatContext& ctx) const
  39. {
  40. std::string dst_format;
  41. if (uid.dst_format == EFBCopyFormat::XFB)
  42. dst_format = "XFB";
  43. else
  44. dst_format = fmt::to_string(uid.dst_format);
  45. return fmt::format_to(ctx.out(),
  46. "dst_format: {}, efb_has_alpha: {}, is_depth_copy: {}, is_intensity: {}, "
  47. "scale_by_half: {}, all_copy_filter_coefs_needed: {}, "
  48. "copy_filter_can_overflow: {}, apply_gamma: {}",
  49. dst_format, uid.efb_has_alpha, uid.is_depth_copy, uid.is_intensity,
  50. uid.scale_by_half, uid.all_copy_filter_coefs_needed,
  51. uid.copy_filter_can_overflow, uid.apply_gamma);
  52. }
  53. };