mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-08 07:51:28 +12:00
Make render-targets GPU resident
Fix minor regressions that occured during merge
This commit is contained in:
parent
d910d2c572
commit
b018c91135
4 changed files with 29 additions and 10 deletions
|
@ -240,12 +240,13 @@ namespace vk
|
||||||
VkDeviceMemory vram = nullptr;
|
VkDeviceMemory vram = nullptr;
|
||||||
vk::render_device *owner = nullptr;
|
vk::render_device *owner = nullptr;
|
||||||
u64 vram_block_sz = 0;
|
u64 vram_block_sz = 0;
|
||||||
|
bool mappable = false;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
memory_block() {}
|
memory_block() {}
|
||||||
~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)
|
if (vram)
|
||||||
destroy();
|
destroy();
|
||||||
|
@ -255,7 +256,12 @@ namespace vk
|
||||||
owner = (vk::render_device*)&device;
|
owner = (vk::render_device*)&device;
|
||||||
VkDevice dev = (VkDevice)(*owner);
|
VkDevice dev = (VkDevice)(*owner);
|
||||||
|
|
||||||
if (!owner->get_compatible_memory_type(typeBits, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, &typeIndex))
|
u32 access_mask = 0;
|
||||||
|
|
||||||
|
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!");
|
throw EXCEPTION("Could not find suitable memory type!");
|
||||||
|
|
||||||
VkMemoryAllocateInfo infos;
|
VkMemoryAllocateInfo infos;
|
||||||
|
@ -266,6 +272,12 @@ namespace vk
|
||||||
|
|
||||||
CHECK_RESULT(vkAllocateMemory(dev, &infos, nullptr, &vram));
|
CHECK_RESULT(vkAllocateMemory(dev, &infos, nullptr, &vram));
|
||||||
vram_block_sz = block_sz;
|
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()
|
void destroy()
|
||||||
|
@ -278,6 +290,11 @@ namespace vk
|
||||||
vram_block_sz = 0;
|
vram_block_sz = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_mappable()
|
||||||
|
{
|
||||||
|
return mappable;
|
||||||
|
}
|
||||||
|
|
||||||
vk::render_device& get_owner()
|
vk::render_device& get_owner()
|
||||||
{
|
{
|
||||||
return (*owner);
|
return (*owner);
|
||||||
|
@ -419,7 +436,10 @@ namespace vk
|
||||||
|
|
||||||
void *map(u32 offset, u64 size)
|
void *map(u32 offset, u64 size)
|
||||||
{
|
{
|
||||||
|
if (!vram.is_mappable()) return nullptr;
|
||||||
|
|
||||||
void *data = nullptr;
|
void *data = nullptr;
|
||||||
|
|
||||||
if (size == VK_WHOLE_SIZE)
|
if (size == VK_WHOLE_SIZE)
|
||||||
size = m_memory_layout.size;
|
size = m_memory_layout.size;
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace rsx
|
||||||
VkFormat requested_format = vk::get_compatible_surface_format(format);
|
VkFormat requested_format = vk::get_compatible_surface_format(format);
|
||||||
|
|
||||||
vk::texture rtt;
|
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);
|
rtt.change_layout(*cmd, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL);
|
||||||
|
|
||||||
return rtt;
|
return rtt;
|
||||||
|
@ -30,7 +30,7 @@ namespace rsx
|
||||||
VkFormat requested_format = vk::get_compatible_depth_surface_format(format);
|
VkFormat requested_format = vk::get_compatible_depth_surface_format(format);
|
||||||
|
|
||||||
vk::texture rtt;
|
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);
|
rtt.change_layout(*cmd, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
||||||
|
|
||||||
return rtt;
|
return rtt;
|
||||||
|
|
|
@ -162,7 +162,7 @@ namespace vk
|
||||||
CHECK_RESULT(vkCreateImage(device, &image_info, nullptr, &m_image_contents));
|
CHECK_RESULT(vkCreateImage(device, &image_info, nullptr, &m_image_contents));
|
||||||
|
|
||||||
vkGetImageMemoryRequirements(device, m_image_contents, &m_memory_layout);
|
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));
|
CHECK_RESULT(vkBindImageMemory(device, m_image_contents, vram_allocation, 0));
|
||||||
|
|
||||||
|
|
|
@ -289,7 +289,6 @@ VKGSRender::upload_vertex_data()
|
||||||
continue;
|
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 element_size = vk::get_suitable_vk_size(vertex_info.type, vertex_info.size);
|
||||||
const u32 data_size = element_size * vertex_draw_count;
|
const u32 data_size = element_size * vertex_draw_count;
|
||||||
const VkFormat format = vk::get_suitable_vk_format(vertex_info.type, vertex_info.size);
|
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)
|
switch (vertex_info.type)
|
||||||
{
|
{
|
||||||
case rsx::vertex_base_type::f:
|
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;
|
break;
|
||||||
case rsx::vertex_base_type::sf:
|
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;
|
break;
|
||||||
case rsx::vertex_base_type::s1:
|
case rsx::vertex_base_type::s1:
|
||||||
case rsx::vertex_base_type::ub:
|
case rsx::vertex_base_type::ub:
|
||||||
case rsx::vertex_base_type::ub256:
|
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;
|
break;
|
||||||
case rsx::vertex_base_type::s32k:
|
case rsx::vertex_base_type::s32k:
|
||||||
case rsx::vertex_base_type::cmp:
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
throw EXCEPTION("Unknown base type %d", vertex_info.type);
|
throw EXCEPTION("Unknown base type %d", vertex_info.type);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue