lavapipe: add support for KHR_buffer_device_address.

Adds the missing magic lowering pass, and stores the pmem
pointer for easier returning to user.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9616>
This commit is contained in:
Dave Airlie
2021-03-16 11:15:47 +10:00
committed by Marge Bot
parent 7b8d53afdd
commit a986d1ed63
5 changed files with 40 additions and 2 deletions

View File

@@ -448,7 +448,7 @@ Vulkan 1.1 -- all DONE: anv, radv
Vulkan 1.2 -- all DONE: anv Vulkan 1.2 -- all DONE: anv
VK_KHR_8bit_storage DONE (anv/gen8+, radv) VK_KHR_8bit_storage DONE (anv/gen8+, radv)
VK_KHR_buffer_device_address DONE (anv/gen8+, radv) VK_KHR_buffer_device_address DONE (anv/gen8+, lvp, radv)
VK_KHR_create_renderpass2 DONE (anv, lvp, radv, tu) VK_KHR_create_renderpass2 DONE (anv, lvp, radv, tu)
VK_KHR_depth_stencil_resolve DONE (anv, radv, tu) VK_KHR_depth_stencil_resolve DONE (anv, radv, tu)
VK_KHR_draw_indirect_count DONE (anv, lvp, radv, tu) VK_KHR_draw_indirect_count DONE (anv, lvp, radv, tu)

View File

@@ -90,6 +90,7 @@ static const struct vk_instance_extension_table lvp_instance_extensions_supporte
static const struct vk_device_extension_table lvp_device_extensions_supported = { static const struct vk_device_extension_table lvp_device_extensions_supported = {
.KHR_bind_memory2 = true, .KHR_bind_memory2 = true,
.KHR_buffer_device_address = true,
.KHR_create_renderpass2 = true, .KHR_create_renderpass2 = true,
.KHR_dedicated_allocation = true, .KHR_dedicated_allocation = true,
.KHR_descriptor_update_template = true, .KHR_descriptor_update_template = true,
@@ -525,6 +526,13 @@ VKAPI_ATTR void VKAPI_CALL lvp_GetPhysicalDeviceFeatures2(
features->hostQueryReset = true; features->hostQueryReset = true;
break; break;
} }
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES_KHR: {
VkPhysicalDeviceBufferDeviceAddressFeaturesKHR *features = (void *)ext;
features->bufferDeviceAddress = true;
features->bufferDeviceAddressCaptureReplay = false;
features->bufferDeviceAddressMultiDevice = false;
break;
}
default: default:
break; break;
} }
@@ -1378,6 +1386,7 @@ VKAPI_ATTR VkResult VKAPI_CALL lvp_BindBufferMemory2(VkDevice _device,
LVP_FROM_HANDLE(lvp_device_memory, mem, pBindInfos[i].memory); LVP_FROM_HANDLE(lvp_device_memory, mem, pBindInfos[i].memory);
LVP_FROM_HANDLE(lvp_buffer, buffer, pBindInfos[i].buffer); LVP_FROM_HANDLE(lvp_buffer, buffer, pBindInfos[i].buffer);
buffer->pmem = mem->pmem;
device->pscreen->resource_bind_backing(device->pscreen, device->pscreen->resource_bind_backing(device->pscreen,
buffer->bo, buffer->bo,
mem->pmem, mem->pmem,

View File

@@ -308,6 +308,29 @@ VKAPI_ATTR void VKAPI_CALL lvp_DestroyBuffer(
vk_free2(&device->vk.alloc, pAllocator, buffer); vk_free2(&device->vk.alloc, pAllocator, buffer);
} }
VKAPI_ATTR VkDeviceAddress VKAPI_CALL lvp_GetBufferDeviceAddress(
VkDevice device,
const VkBufferDeviceAddressInfoKHR* pInfo)
{
LVP_FROM_HANDLE(lvp_buffer, buffer, pInfo->buffer);
return (VkDeviceAddress)(unsigned long)buffer->pmem;
}
VKAPI_ATTR uint64_t VKAPI_CALL lvp_GetBufferOpaqueCaptureAddress(
VkDevice device,
const VkBufferDeviceAddressInfoKHR* pInfo)
{
return 0;
}
VKAPI_ATTR uint64_t VKAPI_CALL lvp_GetDeviceMemoryOpaqueCaptureAddress(
VkDevice device,
const VkDeviceMemoryOpaqueCaptureAddressInfoKHR* pInfo)
{
return 0;
}
VKAPI_ATTR VkResult VKAPI_CALL VKAPI_ATTR VkResult VKAPI_CALL
lvp_CreateBufferView(VkDevice _device, lvp_CreateBufferView(VkDevice _device,
const VkBufferViewCreateInfo *pCreateInfo, const VkBufferViewCreateInfo *pCreateInfo,

View File

@@ -469,6 +469,7 @@ lvp_shader_compile_to_ir(struct lvp_pipeline *pipeline,
.draw_parameters = true, .draw_parameters = true,
.shader_viewport_index_layer = true, .shader_viewport_index_layer = true,
.multiview = true, .multiview = true,
.physical_storage_buffer_address = true,
}, },
.ubo_addr_format = nir_address_format_32bit_index_offset, .ubo_addr_format = nir_address_format_32bit_index_offset,
.ssbo_addr_format = nir_address_format_32bit_index_offset, .ssbo_addr_format = nir_address_format_32bit_index_offset,
@@ -527,6 +528,10 @@ lvp_shader_compile_to_ir(struct lvp_pipeline *pipeline,
nir_var_mem_ubo | nir_var_mem_ssbo, nir_var_mem_ubo | nir_var_mem_ssbo,
nir_address_format_32bit_index_offset); nir_address_format_32bit_index_offset);
NIR_PASS_V(nir, nir_lower_explicit_io,
nir_var_mem_global,
nir_address_format_64bit_global);
if (nir->info.stage == MESA_SHADER_COMPUTE) { if (nir->info.stage == MESA_SHADER_COMPUTE) {
NIR_PASS_V(nir, nir_lower_vars_to_explicit_types, nir_var_mem_shared, shared_var_info); NIR_PASS_V(nir, nir_lower_vars_to_explicit_types, nir_var_mem_shared, shared_var_info);
NIR_PASS_V(nir, nir_lower_explicit_io, nir_var_mem_shared, nir_address_format_32bit_offset); NIR_PASS_V(nir, nir_lower_explicit_io, nir_var_mem_shared, nir_address_format_32bit_offset);

View File

@@ -505,12 +505,13 @@ struct lvp_semaphore {
struct lvp_buffer { struct lvp_buffer {
struct vk_object_base base; struct vk_object_base base;
struct lvp_device * device;
VkDeviceSize size; VkDeviceSize size;
VkBufferUsageFlags usage; VkBufferUsageFlags usage;
VkDeviceSize offset; VkDeviceSize offset;
struct pipe_memory_allocation *pmem;
struct pipe_resource *bo; struct pipe_resource *bo;
uint64_t total_size; uint64_t total_size;
}; };