UberShaderPixel.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright 2015 Dolphin Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <functional>
  5. #include "Common/CommonTypes.h"
  6. #include "VideoCommon/ShaderGenCommon.h"
  7. enum class APIType;
  8. namespace UberShader
  9. {
  10. #pragma pack(1)
  11. struct pixel_ubershader_uid_data
  12. {
  13. u32 num_texgens : 4;
  14. u32 early_depth : 1;
  15. u32 per_pixel_depth : 1;
  16. u32 uint_output : 1;
  17. u32 no_dual_src : 1;
  18. u32 NumValues() const { return sizeof(pixel_ubershader_uid_data); }
  19. };
  20. #pragma pack()
  21. using PixelShaderUid = ShaderUid<pixel_ubershader_uid_data>;
  22. PixelShaderUid GetPixelShaderUid();
  23. ShaderCode GenPixelShader(APIType api_type, const ShaderHostConfig& host_config,
  24. const pixel_ubershader_uid_data* uid_data,
  25. const CustomPixelShaderContents& custom_details);
  26. void EnumeratePixelShaderUids(const std::function<void(const PixelShaderUid&)>& callback);
  27. void ClearUnusedPixelShaderUidBits(APIType api_type, const ShaderHostConfig& host_config,
  28. PixelShaderUid* uid);
  29. } // namespace UberShader
  30. template <>
  31. struct fmt::formatter<UberShader::pixel_ubershader_uid_data>
  32. {
  33. constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); }
  34. template <typename FormatContext>
  35. auto format(const UberShader::pixel_ubershader_uid_data& uid, FormatContext& ctx) const
  36. {
  37. return fmt::format_to(
  38. ctx.out(), "Pixel UberShader for {} texgens{}{}{}{}", uid.num_texgens,
  39. uid.early_depth ? ", early-depth" : "", uid.per_pixel_depth ? ", per-pixel depth" : "",
  40. uid.uint_output ? ", uint output" : "", uid.no_dual_src ? ", no dual-source blending" : "");
  41. }
  42. };