vk: Check for allowed texbuffer range instead of assuming 64M

This commit is contained in:
kd-11 2018-08-24 10:52:31 +03:00 committed by kd-11
parent b095a0be90
commit 76f102e865
4 changed files with 24 additions and 2 deletions

View File

@ -594,6 +594,15 @@ VKGSRender::VKGSRender() : GSRender()
m_index_buffer_ring_info.create(VK_BUFFER_USAGE_INDEX_BUFFER_BIT, VK_INDEX_RING_BUFFER_SIZE_M * 0x100000, "index buffer");
m_texture_upload_buffer_ring_info.create(VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VK_TEXTURE_UPLOAD_RING_BUFFER_SIZE_M * 0x100000, "texture upload buffer", 32 * 0x100000);
const auto limits = m_device->gpu().get_limits();
m_texbuffer_view_size = std::min(limits.maxTexelBufferElements, 0x4000000u);
if (m_texbuffer_view_size < 0x800000)
{
// Warn, only possibly expected on macOS
LOG_WARNING(RSX, "Current driver may crash due to memory limitations (%uk)", m_texbuffer_view_size / 1024);
}
for (auto &ctx : frame_context_storage)
{
vkCreateSemaphore((*m_device), &semaphore_info, nullptr, &ctx.present_semaphore);

View File

@ -327,6 +327,8 @@ private:
bool renderer_unavailable = false;
u64 m_last_heap_sync_time = 0;
u32 m_texbuffer_view_size = 0;
vk::vk_data_heap m_attrib_ring_info;
vk::vk_data_heap m_uniform_buffer_ring_info;
vk::vk_data_heap m_transform_constants_ring_info;

View File

@ -398,6 +398,8 @@ namespace vk
dev = pdev;
vkGetPhysicalDeviceProperties(pdev, &props);
vkGetPhysicalDeviceMemoryProperties(pdev, &memory_properties);
LOG_NOTICE(RSX, "Physical device intialized. GPU=%s, driver=%u", props.deviceName, props.driverVersion);
}
std::string name() const
@ -436,6 +438,11 @@ namespace vk
return memory_properties;
}
VkPhysicalDeviceLimits get_limits() const
{
return props.limits;
}
operator VkPhysicalDevice() const
{
return dev;

View File

@ -322,11 +322,13 @@ vk::vertex_upload_info VKGSRender::upload_vertex_data()
{
if (!m_persistent_attribute_storage || !m_persistent_attribute_storage->in_range(persistent_range_base, required.first, persistent_range_base))
{
verify("Incompatible driver (MacOS?)" HERE), m_texbuffer_view_size >= required.first;
if (m_persistent_attribute_storage)
m_current_frame->buffer_views_to_clean.push_back(std::move(m_persistent_attribute_storage));
//View 64M blocks at a time (different drivers will only allow a fixed viewable heap size, 64M should be safe)
const size_t view_size = (persistent_range_base + 0x4000000) > m_attrib_ring_info.size() ? m_attrib_ring_info.size() - persistent_range_base : 0x4000000;
const size_t view_size = (persistent_range_base + m_texbuffer_view_size) > m_attrib_ring_info.size() ? m_attrib_ring_info.size() - persistent_range_base : m_texbuffer_view_size;
m_persistent_attribute_storage = std::make_unique<vk::buffer_view>(*m_device, m_attrib_ring_info.heap->value, VK_FORMAT_R8_UINT, persistent_range_base, view_size);
persistent_range_base = 0;
}
@ -336,10 +338,12 @@ vk::vertex_upload_info VKGSRender::upload_vertex_data()
{
if (!m_volatile_attribute_storage || !m_volatile_attribute_storage->in_range(volatile_range_base, required.second, volatile_range_base))
{
verify("Incompatible driver (MacOS?)" HERE), m_texbuffer_view_size >= required.second;
if (m_volatile_attribute_storage)
m_current_frame->buffer_views_to_clean.push_back(std::move(m_volatile_attribute_storage));
const size_t view_size = (volatile_range_base + 0x4000000) > m_attrib_ring_info.size() ? m_attrib_ring_info.size() - volatile_range_base : 0x4000000;
const size_t view_size = (volatile_range_base + m_texbuffer_view_size) > m_attrib_ring_info.size() ? m_attrib_ring_info.size() - volatile_range_base : m_texbuffer_view_size;
m_volatile_attribute_storage = std::make_unique<vk::buffer_view>(*m_device, m_attrib_ring_info.heap->value, VK_FORMAT_R8_UINT, volatile_range_base, view_size);
volatile_range_base = 0;
}