mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-03-01 16:13:23 +00:00
Make render-targets GPU resident
Fix minor regressions that occured during merge
This commit is contained in:
parent
d910d2c572
commit
b018c91135
@ -240,12 +240,13 @@ namespace vk
|
||||
VkDeviceMemory vram = nullptr;
|
||||
vk::render_device *owner = nullptr;
|
||||
u64 vram_block_sz = 0;
|
||||
bool mappable = false;
|
||||
|
||||
public:
|
||||
memory_block() {}
|
||||
~memory_block() {}
|
||||
|
||||
void allocate_from_pool(vk::render_device &device, u64 block_sz, u32 typeBits)
|
||||
void allocate_from_pool(vk::render_device &device, u64 block_sz, bool host_visible, u32 typeBits)
|
||||
{
|
||||
if (vram)
|
||||
destroy();
|
||||
@ -254,8 +255,13 @@ namespace vk
|
||||
|
||||
owner = (vk::render_device*)&device;
|
||||
VkDevice dev = (VkDevice)(*owner);
|
||||
|
||||
u32 access_mask = 0;
|
||||
|
||||
if (!owner->get_compatible_memory_type(typeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, &typeIndex))
|
||||
if (host_visible)
|
||||
access_mask |= VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
|
||||
|
||||
if (!owner->get_compatible_memory_type(typeBits, access_mask, &typeIndex))
|
||||
throw EXCEPTION("Could not find suitable memory type!");
|
||||
|
||||
VkMemoryAllocateInfo infos;
|
||||
@ -266,6 +272,12 @@ namespace vk
|
||||
|
||||
CHECK_RESULT(vkAllocateMemory(dev, &infos, nullptr, &vram));
|
||||
vram_block_sz = block_sz;
|
||||
mappable = host_visible;
|
||||
}
|
||||
|
||||
void allocate_from_pool(vk::render_device &device, u64 block_sz, u32 typeBits)
|
||||
{
|
||||
allocate_from_pool(device, block_sz, true, typeBits);
|
||||
}
|
||||
|
||||
void destroy()
|
||||
@ -278,6 +290,11 @@ namespace vk
|
||||
vram_block_sz = 0;
|
||||
}
|
||||
|
||||
bool is_mappable()
|
||||
{
|
||||
return mappable;
|
||||
}
|
||||
|
||||
vk::render_device& get_owner()
|
||||
{
|
||||
return (*owner);
|
||||
@ -419,7 +436,10 @@ namespace vk
|
||||
|
||||
void *map(u32 offset, u64 size)
|
||||
{
|
||||
if (!vram.is_mappable()) return nullptr;
|
||||
|
||||
void *data = nullptr;
|
||||
|
||||
if (size == VK_WHOLE_SIZE)
|
||||
size = m_memory_layout.size;
|
||||
|
||||
|
@ -19,7 +19,7 @@ namespace rsx
|
||||
VkFormat requested_format = vk::get_compatible_surface_format(format);
|
||||
|
||||
vk::texture rtt;
|
||||
rtt.create(device, requested_format, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_SAMPLED_BIT, width, height);
|
||||
rtt.create(device, requested_format, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT|VK_IMAGE_USAGE_TRANSFER_SRC_BIT|VK_IMAGE_USAGE_SAMPLED_BIT, width, height, 1, true);
|
||||
rtt.change_layout(*cmd, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
||||
|
||||
return rtt;
|
||||
@ -30,7 +30,7 @@ namespace rsx
|
||||
VkFormat requested_format = vk::get_compatible_depth_surface_format(format);
|
||||
|
||||
vk::texture rtt;
|
||||
rtt.create(device, requested_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT|VK_IMAGE_USAGE_SAMPLED_BIT, width, height);
|
||||
rtt.create(device, requested_format, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT|VK_IMAGE_USAGE_SAMPLED_BIT, width, height, 1, true);
|
||||
rtt.change_layout(*cmd, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
||||
|
||||
return rtt;
|
||||
|
@ -162,7 +162,7 @@ namespace vk
|
||||
CHECK_RESULT(vkCreateImage(device, &image_info, nullptr, &m_image_contents));
|
||||
|
||||
vkGetImageMemoryRequirements(device, m_image_contents, &m_memory_layout);
|
||||
vram_allocation.allocate_from_pool(device, m_memory_layout.size, m_memory_layout.memoryTypeBits);
|
||||
vram_allocation.allocate_from_pool(device, m_memory_layout.size, !gpu_only, m_memory_layout.memoryTypeBits);
|
||||
|
||||
CHECK_RESULT(vkBindImageMemory(device, m_image_contents, vram_allocation, 0));
|
||||
|
||||
|
@ -289,7 +289,6 @@ VKGSRender::upload_vertex_data()
|
||||
continue;
|
||||
}
|
||||
|
||||
const u32 host_element_size = rsx::get_vertex_type_size_on_host(vertex_info.type, vertex_info.size);
|
||||
const u32 element_size = vk::get_suitable_vk_size(vertex_info.type, vertex_info.size);
|
||||
const u32 data_size = element_size * vertex_draw_count;
|
||||
const VkFormat format = vk::get_suitable_vk_format(vertex_info.type, vertex_info.size);
|
||||
@ -311,19 +310,19 @@ VKGSRender::upload_vertex_data()
|
||||
switch (vertex_info.type)
|
||||
{
|
||||
case rsx::vertex_base_type::f:
|
||||
vk::copy_inlined_data_to_buffer<float, 1>(src, dst, vertex_draw_count, vertex_info.type, vertex_info.size, opt_size, host_element_size, stride);
|
||||
vk::copy_inlined_data_to_buffer<float, 1>(src, dst, vertex_draw_count, vertex_info.type, vertex_info.size, opt_size, element_size, stride);
|
||||
break;
|
||||
case rsx::vertex_base_type::sf:
|
||||
vk::copy_inlined_data_to_buffer<u16, 0x3c00>(src, dst, vertex_draw_count, vertex_info.type, vertex_info.size, opt_size, host_element_size, stride);
|
||||
vk::copy_inlined_data_to_buffer<u16, 0x3c00>(src, dst, vertex_draw_count, vertex_info.type, vertex_info.size, opt_size, element_size, stride);
|
||||
break;
|
||||
case rsx::vertex_base_type::s1:
|
||||
case rsx::vertex_base_type::ub:
|
||||
case rsx::vertex_base_type::ub256:
|
||||
vk::copy_inlined_data_to_buffer<u8, 1>(src, dst, vertex_draw_count, vertex_info.type, vertex_info.size, opt_size, host_element_size, stride);
|
||||
vk::copy_inlined_data_to_buffer<u8, 1>(src, dst, vertex_draw_count, vertex_info.type, vertex_info.size, opt_size, element_size, stride);
|
||||
break;
|
||||
case rsx::vertex_base_type::s32k:
|
||||
case rsx::vertex_base_type::cmp:
|
||||
vk::copy_inlined_data_to_buffer<u16, 1>(src, dst, vertex_draw_count, vertex_info.type, vertex_info.size, opt_size, host_element_size, stride);
|
||||
vk::copy_inlined_data_to_buffer<u16, 1>(src, dst, vertex_draw_count, vertex_info.type, vertex_info.size, opt_size, element_size, stride);
|
||||
break;
|
||||
default:
|
||||
throw EXCEPTION("Unknown base type %d", vertex_info.type);
|
||||
|
Loading…
x
Reference in New Issue
Block a user