Module: Mesa
Branch: master
Commit: a986d1ed633eb161c659f0a2e07c0d063ada4429
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=a986d1ed633eb161c659f0a2e07c0d063ada4429

Author: Dave Airlie <[email protected]>
Date:   Tue Mar 16 11:15:47 2021 +1000

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 <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9616>

---

 docs/features.txt                             |  2 +-
 src/gallium/frontends/lavapipe/lvp_device.c   |  9 +++++++++
 src/gallium/frontends/lavapipe/lvp_image.c    | 23 +++++++++++++++++++++++
 src/gallium/frontends/lavapipe/lvp_pipeline.c |  5 +++++
 src/gallium/frontends/lavapipe/lvp_private.h  |  3 ++-
 5 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/docs/features.txt b/docs/features.txt
index 0747e5b3bfc..0cb93a74332 100644
--- a/docs/features.txt
+++ b/docs/features.txt
@@ -448,7 +448,7 @@ Vulkan 1.1 -- all DONE: anv, radv
 Vulkan 1.2 -- all DONE: anv
 
   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_depth_stencil_resolve                          DONE (anv, radv, tu)
   VK_KHR_draw_indirect_count                            DONE (anv, lvp, radv, 
tu)
diff --git a/src/gallium/frontends/lavapipe/lvp_device.c 
b/src/gallium/frontends/lavapipe/lvp_device.c
index 6c17d20154d..9bff31dd035 100644
--- a/src/gallium/frontends/lavapipe/lvp_device.c
+++ b/src/gallium/frontends/lavapipe/lvp_device.c
@@ -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 
= {
    .KHR_bind_memory2                      = true,
+   .KHR_buffer_device_address             = true,
    .KHR_create_renderpass2                = true,
    .KHR_dedicated_allocation              = true,
    .KHR_descriptor_update_template        = true,
@@ -525,6 +526,13 @@ VKAPI_ATTR void VKAPI_CALL lvp_GetPhysicalDeviceFeatures2(
          features->hostQueryReset = true;
          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:
          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_buffer, buffer, pBindInfos[i].buffer);
 
+      buffer->pmem = mem->pmem;
       device->pscreen->resource_bind_backing(device->pscreen,
                                              buffer->bo,
                                              mem->pmem,
diff --git a/src/gallium/frontends/lavapipe/lvp_image.c 
b/src/gallium/frontends/lavapipe/lvp_image.c
index 83a5478e2bb..a743d7292c7 100644
--- a/src/gallium/frontends/lavapipe/lvp_image.c
+++ b/src/gallium/frontends/lavapipe/lvp_image.c
@@ -308,6 +308,29 @@ VKAPI_ATTR void VKAPI_CALL lvp_DestroyBuffer(
    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
 lvp_CreateBufferView(VkDevice _device,
                      const VkBufferViewCreateInfo *pCreateInfo,
diff --git a/src/gallium/frontends/lavapipe/lvp_pipeline.c 
b/src/gallium/frontends/lavapipe/lvp_pipeline.c
index b3d794dcea2..13967752140 100644
--- a/src/gallium/frontends/lavapipe/lvp_pipeline.c
+++ b/src/gallium/frontends/lavapipe/lvp_pipeline.c
@@ -469,6 +469,7 @@ lvp_shader_compile_to_ir(struct lvp_pipeline *pipeline,
          .draw_parameters = true,
          .shader_viewport_index_layer = true,
          .multiview = true,
+         .physical_storage_buffer_address = true,
       },
       .ubo_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_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) {
       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);
diff --git a/src/gallium/frontends/lavapipe/lvp_private.h 
b/src/gallium/frontends/lavapipe/lvp_private.h
index 6607c0b39e9..da2ac5dc7f8 100644
--- a/src/gallium/frontends/lavapipe/lvp_private.h
+++ b/src/gallium/frontends/lavapipe/lvp_private.h
@@ -505,12 +505,13 @@ struct lvp_semaphore {
 
 struct lvp_buffer {
    struct vk_object_base base;
-   struct lvp_device *                          device;
+
    VkDeviceSize                                 size;
 
    VkBufferUsageFlags                           usage;
    VkDeviceSize                                 offset;
 
+   struct pipe_memory_allocation *pmem;
    struct pipe_resource *bo;
    uint64_t total_size;
 };

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to