Skip to content

Commit

Permalink
vk: Reuse discarded memory whenever possible instead of recreating new
Browse files Browse the repository at this point in the history
objects
- Memory allocations are surprisingly expensive when spammed
  • Loading branch information
kd-11 committed Jul 2, 2019
1 parent 54ce5a2 commit 3857ae5
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 88 deletions.
14 changes: 14 additions & 0 deletions rpcs3/Emu/RSX/Common/TextureUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,3 +796,17 @@ size_t get_texture_size(const rsx::vertex_texture &texture)
return get_texture_size(texture.format(), texture.width(), texture.height(), texture.depth(),
texture.pitch(), texture.get_exact_mipmap_count(), texture.cubemap() ? 6 : 1);
}

u32 get_remap_encoding(const std::pair<std::array<u8, 4>, std::array<u8, 4>>& remap)
{
u32 encode = 0;
encode |= (remap.first[0] << 0);
encode |= (remap.first[1] << 2);
encode |= (remap.first[2] << 4);
encode |= (remap.first[3] << 6);
encode |= (remap.second[0] << 8);
encode |= (remap.second[1] << 10);
encode |= (remap.second[2] << 12);
encode |= (remap.second[3] << 14);
return encode;
}
5 changes: 5 additions & 0 deletions rpcs3/Emu/RSX/Common/TextureUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,3 +139,8 @@ size_t get_texture_size(const rsx::vertex_texture &texture);
* Get packed pitch
*/
u32 get_format_packed_pitch(u32 format, u16 width);

/**
* Reverse encoding
*/
u32 get_remap_encoding(const std::pair<std::array<u8, 4>, std::array<u8, 4>>& remap);
18 changes: 13 additions & 5 deletions rpcs3/Emu/RSX/VK/VKHelpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -1298,11 +1298,19 @@ namespace vk
}
}

VkComponentMapping real_mapping = vk::apply_swizzle_remap
(
{native_component_map.a, native_component_map.r, native_component_map.g, native_component_map.b },
remap
);
VkComponentMapping real_mapping;
if (remap_encoding == 0xAAE4)
{
real_mapping = native_component_map;
}
else
{
real_mapping = vk::apply_swizzle_remap
(
{ native_component_map.a, native_component_map.r, native_component_map.g, native_component_map.b },
remap
);
}

const auto range = vk::get_image_subresource_range(0, 0, info.arrayLayers, info.mipLevels, aspect() & mask);

Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/RSX/VK/VKOverlays.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ namespace vk
return fs_inputs;
}

virtual void get_dynamic_state_entries(VkDynamicState* state_descriptors, VkPipelineDynamicStateCreateInfo& info)
virtual void get_dynamic_state_entries(VkDynamicState* /*state_descriptors*/, VkPipelineDynamicStateCreateInfo& /*info*/)
{}

virtual std::vector<VkPushConstantRange> get_push_constants()
Expand Down

0 comments on commit 3857ae5

Please sign in to comment.