mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-16 23:17:29 +00:00
D3D12/Vulkan : swizzle texture format G8B8 (#1931)
* D3D12: swizzle texture format G8B8 * Vulkan: swizzle texture format G8B8
This commit is contained in:
parent
2e5b01faca
commit
7ac9d3b679
@ -286,12 +286,51 @@ void D3D12GSRender::upload_textures(ID3D12GraphicsCommandList *command_list, siz
|
||||
break;
|
||||
|
||||
case CELL_GCM_TEXTURE_G8B8:
|
||||
shared_resource_view_desc.Shader4ComponentMapping = D3D12_ENCODE_SHADER_4_COMPONENT_MAPPING(
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_1,
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_2,
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_1,
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_2);
|
||||
{
|
||||
u8 remap_a = rsx::method_registers.fragment_textures[i].remap() & 0x3;
|
||||
u8 remap_r = (rsx::method_registers.fragment_textures[i].remap() >> 2) & 0x3;
|
||||
u8 remap_g = (rsx::method_registers.fragment_textures[i].remap() >> 4) & 0x3;
|
||||
u8 remap_b = (rsx::method_registers.fragment_textures[i].remap() >> 6) & 0x3;
|
||||
|
||||
if (is_render_target)
|
||||
{
|
||||
// ARGB format
|
||||
// Data comes from RTT, stored as RGBA already
|
||||
const int RemapValue[4] =
|
||||
{
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_1,
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_2,
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_1,
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_2
|
||||
};
|
||||
|
||||
shared_resource_view_desc.Shader4ComponentMapping = D3D12_ENCODE_SHADER_4_COMPONENT_MAPPING(
|
||||
RemapValue[remap_r],
|
||||
RemapValue[remap_g],
|
||||
RemapValue[remap_b],
|
||||
RemapValue[remap_a]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// ARGB format
|
||||
// Data comes from RSX mem, stored as ARGB already
|
||||
const int RemapValue[4] =
|
||||
{
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_2,
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_1,
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_2,
|
||||
D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_1
|
||||
};
|
||||
|
||||
shared_resource_view_desc.Shader4ComponentMapping = D3D12_ENCODE_SHADER_4_COMPONENT_MAPPING(
|
||||
RemapValue[remap_r],
|
||||
RemapValue[remap_g],
|
||||
RemapValue[remap_b],
|
||||
RemapValue[remap_a]);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case CELL_GCM_TEXTURE_R6G5B5: // TODO: Remap it to another format here, so it's not glitched out
|
||||
shared_resource_view_desc.Shader4ComponentMapping = D3D12_ENCODE_SHADER_4_COMPONENT_MAPPING(
|
||||
@ -338,8 +377,6 @@ void D3D12GSRender::upload_textures(ID3D12GraphicsCommandList *command_list, siz
|
||||
case CELL_GCM_TEXTURE_A8R8G8B8:
|
||||
case CELL_GCM_TEXTURE_D8R8G8B8:
|
||||
{
|
||||
|
||||
|
||||
u8 remap_a = rsx::method_registers.fragment_textures[i].remap() & 0x3;
|
||||
u8 remap_r = (rsx::method_registers.fragment_textures[i].remap() >> 2) & 0x3;
|
||||
u8 remap_g = (rsx::method_registers.fragment_textures[i].remap() >> 4) & 0x3;
|
||||
|
@ -138,7 +138,10 @@ VkComponentMapping get_component_mapping(u32 format, u8 swizzle_mask)
|
||||
return { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_R };
|
||||
|
||||
case CELL_GCM_TEXTURE_G8B8:
|
||||
return { VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G };
|
||||
{
|
||||
VkComponentSwizzle map_table[] = { VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_R };
|
||||
return{ map_table[remap_r], map_table[remap_g], map_table[remap_b], map_table[remap_a] };
|
||||
}
|
||||
|
||||
case CELL_GCM_TEXTURE_X16:
|
||||
return { VK_COMPONENT_SWIZZLE_ONE, VK_COMPONENT_SWIZZLE_R, VK_COMPONENT_SWIZZLE_ONE, VK_COMPONENT_SWIZZLE_R };
|
||||
|
Loading…
Reference in New Issue
Block a user