TextureConversionShader.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright 2008 Dolphin Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <optional>
  5. #include <string>
  6. #include <utility>
  7. #include "Common/CommonTypes.h"
  8. enum class APIType;
  9. enum class TextureFormat;
  10. enum class EFBCopyFormat;
  11. enum class TLUTFormat;
  12. enum TexelBufferFormat : u32;
  13. struct EFBCopyParams;
  14. namespace TextureConversionShaderTiled
  15. {
  16. u16 GetEncodedSampleCount(EFBCopyFormat format);
  17. std::string GenerateEncodingShader(const EFBCopyParams& params, APIType api_type);
  18. // Information required to compile and dispatch a texture decoding shader.
  19. struct DecodingShaderInfo
  20. {
  21. TexelBufferFormat buffer_format;
  22. u32 palette_size;
  23. u32 group_size_x;
  24. u32 group_size_y;
  25. bool group_flatten;
  26. const char* shader_body;
  27. };
  28. // Obtain shader information for the specified texture format.
  29. // If this format does not have a shader written for it, returns nullptr.
  30. const DecodingShaderInfo* GetDecodingShaderInfo(TextureFormat format);
  31. // Determine how many thread groups should be dispatched for an image of the specified width/height.
  32. // First is the number of X groups, second is the number of Y groups, Z is always one.
  33. std::pair<u32, u32> GetDispatchCount(const DecodingShaderInfo* info, u32 width, u32 height);
  34. // Returns the GLSL string containing the texture decoding shader for the specified format.
  35. std::string GenerateDecodingShader(TextureFormat format, std::optional<TLUTFormat> palette_format,
  36. APIType api_type);
  37. // Returns the GLSL string containing the palette conversion shader for the specified format.
  38. std::string GeneratePaletteConversionShader(TLUTFormat palette_format, APIType api_type);
  39. } // namespace TextureConversionShaderTiled