mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-28 11:49:06 +00:00
VideoCommon: Reduce duplicates of non-palette-requiring texture decode shaders
This commit is contained in:
parent
70bf89fa59
commit
23c1721fbd
5 changed files with 34 additions and 20 deletions
|
@ -950,6 +950,7 @@ uint GetTiledTexelOffset(uint2 block_size, uint2 coords)
|
|||
return buffer_pos;
|
||||
}
|
||||
|
||||
#if defined(HAS_PALETTE)
|
||||
uint4 GetPaletteColor(uint index)
|
||||
{
|
||||
// Fetch and swap BE to LE.
|
||||
|
@ -994,6 +995,7 @@ float4 GetPaletteColorNormalized(uint index)
|
|||
uint4 color = GetPaletteColor(index);
|
||||
return float4(color) / 255.0;
|
||||
}
|
||||
#endif // defined(HAS_PALETTE)
|
||||
|
||||
)";
|
||||
|
||||
|
@ -1385,7 +1387,7 @@ std::pair<u32, u32> GetDispatchCount(const DecodingShaderInfo* info, u32 width,
|
|||
(height + (info->group_size_y - 1)) / info->group_size_y};
|
||||
}
|
||||
|
||||
std::string GenerateDecodingShader(TextureFormat format, TLUTFormat palette_format,
|
||||
std::string GenerateDecodingShader(TextureFormat format, std::optional<TLUTFormat> palette_format,
|
||||
APIType api_type)
|
||||
{
|
||||
const DecodingShaderInfo* info = GetDecodingShaderInfo(format);
|
||||
|
@ -1393,17 +1395,20 @@ std::string GenerateDecodingShader(TextureFormat format, TLUTFormat palette_form
|
|||
return "";
|
||||
|
||||
std::ostringstream ss;
|
||||
switch (palette_format)
|
||||
if (palette_format.has_value())
|
||||
{
|
||||
case TLUTFormat::IA8:
|
||||
ss << "#define PALETTE_FORMAT_IA8 1\n";
|
||||
break;
|
||||
case TLUTFormat::RGB565:
|
||||
ss << "#define PALETTE_FORMAT_RGB565 1\n";
|
||||
break;
|
||||
case TLUTFormat::RGB5A3:
|
||||
ss << "#define PALETTE_FORMAT_RGB5A3 1\n";
|
||||
break;
|
||||
switch (*palette_format)
|
||||
{
|
||||
case TLUTFormat::IA8:
|
||||
ss << "#define PALETTE_FORMAT_IA8 1\n";
|
||||
break;
|
||||
case TLUTFormat::RGB565:
|
||||
ss << "#define PALETTE_FORMAT_RGB565 1\n";
|
||||
break;
|
||||
case TLUTFormat::RGB5A3:
|
||||
ss << "#define PALETTE_FORMAT_RGB5A3 1\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ss << decoding_shader_header;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue