[MA-155] Rename magma_system abi to magma
Change-Id: I3f5609e76155d7261862ef00b76688292933ec72
diff --git a/src/intel/vulkan/anv_magma.cc b/src/intel/vulkan/anv_magma.cc
index e69a90b..0fa6652 100644
--- a/src/intel/vulkan/anv_magma.cc
+++ b/src/intel/vulkan/anv_magma.cc
@@ -11,7 +11,7 @@
#include "anv_private.h"
// clang-format on
-static magma_system_connection* magma_connection(anv_device* device)
+static magma_connection_t* magma_connection(anv_device* device)
{
DASSERT(device);
DASSERT(device->connection);
@@ -20,8 +20,8 @@
int anv_gem_connect(anv_device* device)
{
- device->connection = magma_system_open(device->fd, MAGMA_SYSTEM_CAPABILITY_RENDERING |
- MAGMA_SYSTEM_CAPABILITY_DISPLAY);
+ device->connection =
+ magma_open(device->fd, MAGMA_SYSTEM_CAPABILITY_RENDERING | MAGMA_SYSTEM_CAPABILITY_DISPLAY);
if (!device->connection)
return DRET_MSG(-1, "magma_system_open failed");
@@ -31,7 +31,7 @@
void anv_gem_disconnect(anv_device* device)
{
- magma_system_close(magma_connection(device));
+ magma_close(magma_connection(device));
DLOG("closed the magma system connection");
}
@@ -40,7 +40,7 @@
{
magma_buffer_t buffer;
uint64_t magma_size = size;
- if (magma_system_alloc(magma_connection(device), magma_size, &magma_size, &buffer) != 0) {
+ if (magma_alloc(magma_connection(device), magma_size, &magma_size, &buffer) != 0) {
DLOG("magma_system_alloc failed size 0x%zx", magma_size);
return 0;
}
@@ -53,7 +53,7 @@
void anv_gem_close(anv_device* device, anv_buffer_handle_t handle)
{
DLOG("anv_gem_close handle 0x%lx", handle);
- magma_system_free(magma_connection(device), handle);
+ magma_free(magma_connection(device), handle);
}
void* anv_gem_mmap(anv_device* device, anv_buffer_handle_t handle, uint64_t offset, uint64_t size,
@@ -61,18 +61,18 @@
{
DASSERT(flags == 0);
void* addr;
- if (magma_system_map(magma_connection(device), handle, &addr) != 0)
+ if (magma_map(magma_connection(device), handle, &addr) != 0)
return DRETP(nullptr, "magma_system_map failed");
DLOG("magma_system_map handle 0x%lx size 0x%zx returning %p", handle, size, addr);
return reinterpret_cast<uint8_t*>(addr) + offset;
}
-void anv_gem_munmap(struct anv_device* device, anv_buffer_handle_t gem_handle, void* addr, uint64_t size)
+void anv_gem_munmap(anv_device* device, anv_buffer_handle_t gem_handle, void* addr, uint64_t size)
{
if (!addr)
return;
- if (magma_system_unmap(magma_connection(device), gem_handle) != 0) {
+ if (magma_unmap(magma_connection(device), gem_handle) != 0) {
DLOG("magma_system_unmap failed");
return;
}
@@ -105,7 +105,7 @@
*/
int anv_gem_wait(anv_device* device, anv_buffer_handle_t handle, int64_t* timeout_ns)
{
- magma_system_wait_rendering(magma_connection(device), handle);
+ magma_wait_rendering(magma_connection(device), handle);
return 0;
}
@@ -125,43 +125,43 @@
uint64_t cmd_buf_id;
int32_t error;
- error = magma_system_alloc(magma_connection(device), required_size, &allocated_size, &cmd_buf_id);
+ error = magma_alloc(magma_connection(device), required_size, &allocated_size, &cmd_buf_id);
if (error)
return DRET_MSG(error, "magma_system_alloc failed size 0x%" PRIx64, required_size);
DASSERT(allocated_size >= required_size);
void* cmd_buf_data;
- error = magma_system_map(magma_connection(device), cmd_buf_id, &cmd_buf_data);
+ error = magma_map(magma_connection(device), cmd_buf_id, &cmd_buf_data);
if (error) {
- magma_system_free(magma_connection(device), cmd_buf_id);
+ magma_free(magma_connection(device), cmd_buf_id);
return DRET_MSG(error, "magma_system_map failed");
}
std::vector<uint64_t> wait_semaphore_ids(wait_semaphore_count);
for (uint32_t i = 0; i < wait_semaphore_count; i++) {
- wait_semaphore_ids[i] = magma_system_get_semaphore_id(wait_semaphores[i]);
+ wait_semaphore_ids[i] = magma_get_semaphore_id(wait_semaphores[i]);
}
std::vector<uint64_t> signal_semaphore_ids(signal_semaphore_count);
for (uint32_t i = 0; i < signal_semaphore_count; i++) {
- signal_semaphore_ids[i] = magma_system_get_semaphore_id(signal_semaphores[i]);
+ signal_semaphore_ids[i] = magma_get_semaphore_id(signal_semaphores[i]);
}
if (!DrmCommandBuffer::Translate(execbuf, std::move(wait_semaphore_ids),
std::move(signal_semaphore_ids), cmd_buf_data)) {
- error = magma_system_unmap(magma_connection(device), cmd_buf_id);
+ error = magma_unmap(magma_connection(device), cmd_buf_id);
DASSERT(!error);
- magma_system_free(magma_connection(device), cmd_buf_id);
+ magma_free(magma_connection(device), cmd_buf_id);
return DRET_MSG(error, "DrmCommandBuffer::Translate failed");
}
- magma_system_submit_command_buffer(magma_connection(device), cmd_buf_id, device->context_id);
+ magma_submit_command_buffer(magma_connection(device), cmd_buf_id, device->context_id);
- error = magma_system_unmap(magma_connection(device), cmd_buf_id);
+ error = magma_unmap(magma_connection(device), cmd_buf_id);
DASSERT(!error);
- magma_system_free(magma_connection(device), cmd_buf_id);
+ magma_free(magma_connection(device), cmd_buf_id);
return 0;
}
@@ -179,7 +179,7 @@
switch (param) {
case I915_PARAM_CHIPSET_ID:
- result = magma_system_get_device_id(fd);
+ result = magma_get_device_id(fd);
break;
case I915_PARAM_HAS_WAIT_TIMEOUT:
case I915_PARAM_HAS_EXECBUF2:
@@ -200,7 +200,7 @@
int anv_gem_create_context(anv_device* device)
{
uint32_t context_id;
- magma_system_create_context(magma_connection(device), &context_id);
+ magma_create_context(magma_connection(device), &context_id);
DLOG("magma_system_create_context returned context_id %u", context_id);
return static_cast<int>(context_id);
@@ -208,7 +208,7 @@
int anv_gem_destroy_context(anv_device* device, int context_id)
{
- magma_system_destroy_context(magma_connection(device), context_id);
+ magma_destroy_context(magma_connection(device), context_id);
return 0;
}
@@ -237,7 +237,7 @@
ANV_FROM_HANDLE(anv_device, device, _device);
ANV_FROM_HANDLE(anv_device_memory, mem, _memory);
- auto result = magma_system_export(magma_connection(device), mem->bo.gem_handle, pHandle);
+ auto result = magma_export(magma_connection(device), mem->bo.gem_handle, pHandle);
DASSERT(result == MAGMA_STATUS_OK);
return VK_SUCCESS;
@@ -255,10 +255,10 @@
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
magma_buffer_t magma_buffer;
- auto result = magma_system_import(magma_connection(device), handle, &magma_buffer);
+ auto result = magma_import(magma_connection(device), handle, &magma_buffer);
DASSERT(result == MAGMA_STATUS_OK);
- anv_bo_init(&mem->bo, magma_buffer, magma_system_get_buffer_size(magma_buffer));
+ anv_bo_init(&mem->bo, magma_buffer, magma_get_buffer_size(magma_buffer));
*pMem = anv_device_memory_to_handle(mem);
diff --git a/src/intel/vulkan/anv_platform.cc b/src/intel/vulkan/anv_platform.cc
index b0a763d..a218afa 100644
--- a/src/intel/vulkan/anv_platform.cc
+++ b/src/intel/vulkan/anv_platform.cc
@@ -31,7 +31,7 @@
{
DLOG("anv_platform_create_semaphore");
magma_semaphore_t semaphore;
- magma_status_t status = magma_system_create_semaphore(device->connection, &semaphore);
+ magma_status_t status = magma_create_semaphore(device->connection, &semaphore);
if (status != MAGMA_STATUS_OK)
return DRET_MSG(-EINVAL, "magma_system_create_semaphore failed: %d", status);
*semaphore_out = reinterpret_cast<anv_semaphore_t>(semaphore);
@@ -41,21 +41,20 @@
void anv_platform_destroy_semaphore(anv_device* device, anv_semaphore_t semaphore)
{
DLOG("anv_platform_destroy_semaphore");
- magma_system_destroy_semaphore(device->connection,
- reinterpret_cast<magma_semaphore_t>(semaphore));
+ magma_destroy_semaphore(device->connection, reinterpret_cast<magma_semaphore_t>(semaphore));
}
void anv_platform_reset_semaphore(anv_semaphore_t semaphore)
{
DLOG("anv_platform_reset_semaphore");
- magma_system_reset_semaphore(reinterpret_cast<magma_semaphore_t>(semaphore));
+ magma_reset_semaphore(reinterpret_cast<magma_semaphore_t>(semaphore));
}
int anv_platform_wait_semaphore(anv_semaphore_t semaphore, uint64_t timeout)
{
DLOG("anv_platform_wait_semaphore");
magma_status_t status =
- magma_system_wait_semaphore(reinterpret_cast<magma_semaphore_t>(semaphore), timeout);
+ magma_wait_semaphore(reinterpret_cast<magma_semaphore_t>(semaphore), timeout);
switch (status) {
case MAGMA_STATUS_OK:
return 0;
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index 9def7c2..b4d9262 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -594,7 +594,7 @@
pthread_mutex_t mutex;
pthread_cond_t queue_submit;
- struct magma_system_connection* connection;
+ struct magma_connection_t* connection;
};
typedef uintptr_t anv_semaphore_t;
diff --git a/src/magma/drm_command_buffer.cc b/src/magma/drm_command_buffer.cc
index 97da6e3..f41def3 100644
--- a/src/magma/drm_command_buffer.cc
+++ b/src/magma/drm_command_buffer.cc
@@ -67,7 +67,7 @@
uint32_t num_relocations = dst_res->num_relocations = src_res->relocation_count;
auto relocations = &relocation_entries[res_reloc_base];
- dst_res->buffer_id = magma_system_get_buffer_id(src_res->handle);
+ dst_res->buffer_id = magma_get_buffer_id(src_res->handle);
dst_res->offset = src_res->rsvd1;
dst_res->length = src_res->rsvd2;
diff --git a/src/vulkan/wsi/wsi_common_magma.cc b/src/vulkan/wsi/wsi_common_magma.cc
index 570e063..02c843a 100644
--- a/src/vulkan/wsi/wsi_common_magma.cc
+++ b/src/vulkan/wsi/wsi_common_magma.cc
@@ -32,9 +32,9 @@
public:
WsiMagma(const wsi_magma_callbacks* callbacks) : callbacks_(callbacks) {}
- magma_system_connection* connection(VkDevice device)
+ magma_connection_t* connection(VkDevice device)
{
- return reinterpret_cast<magma_system_connection*>(callbacks_->get_magma_connection(device));
+ return reinterpret_cast<magma_connection_t*>(callbacks_->get_magma_connection(device));
}
const wsi_magma_callbacks* callbacks() { return callbacks_; }
@@ -48,7 +48,7 @@
class MagmaImage {
public:
static std::unique_ptr<MagmaImage> Create(VkDevice device, const wsi_magma_callbacks* callbacks,
- magma_system_connection* connection,
+ magma_connection_t* connection,
const VkSwapchainCreateInfoKHR* create_info,
const VkAllocationCallbacks* pAllocator);
@@ -81,7 +81,7 @@
std::unique_ptr<MagmaImage> MagmaImage::Create(VkDevice device,
const wsi_magma_callbacks* callbacks,
- magma_system_connection* connection,
+ magma_connection_t* connection,
const VkSwapchainCreateInfoKHR* pCreateInfo,
const VkAllocationCallbacks* allocator)
{
@@ -100,11 +100,11 @@
return DRETP(nullptr, "create_wsi_image failed");
magma_semaphore_t semaphore;
- magma_status_t status = magma_system_create_semaphore(connection, &semaphore);
+ magma_status_t status = magma_create_semaphore(connection, &semaphore);
if (status != MAGMA_STATUS_OK)
return DRETP(nullptr, "failed to create semaphore");
- magma_system_signal_semaphore(semaphore);
+ magma_signal_semaphore(semaphore);
auto magma_image = std::unique_ptr<MagmaImage>(new MagmaImage(
device, callbacks, allocator, buffer_handle, image, device_memory, semaphore));
@@ -116,7 +116,7 @@
class MagmaSwapchain : public wsi_swapchain {
public:
- MagmaSwapchain(VkDevice device, magma_system_connection* connection) : connection_(connection)
+ MagmaSwapchain(VkDevice device, magma_connection_t* connection) : connection_(connection)
{
// Default-initialize the anv_swapchain base
wsi_swapchain* base = static_cast<wsi_swapchain*>(this);
@@ -133,7 +133,7 @@
this->queue_present = QueuePresent;
}
- magma_system_connection* connection() { return connection_; }
+ magma_connection_t* connection() { return connection_; }
uint32_t image_count() { return images_.size(); }
@@ -183,10 +183,9 @@
uint32_t index = chain->next_index_;
MagmaImage* image = chain->get_image(index);
- DLOG("AcquireNextImage semaphore id 0x%" PRIx64,
- magma_system_get_semaphore_id(image->semaphore()));
+ DLOG("AcquireNextImage semaphore id 0x%" PRIx64, magma_get_semaphore_id(image->semaphore()));
- magma_status_t status = magma_system_wait_semaphore(image->semaphore(), timeout);
+ magma_status_t status = magma_wait_semaphore(image->semaphore(), timeout);
if (status == MAGMA_STATUS_TIMED_OUT) {
DLOG("timeout waiting for image semaphore");
return VK_TIMEOUT;
@@ -199,7 +198,7 @@
*pImageIndex = index;
DLOG("AcquireNextImage returning index %u id 0x%" PRIx64, *pImageIndex,
- magma_system_get_buffer_id(image->buffer_handle()));
+ magma_get_buffer_id(image->buffer_handle()));
return VK_SUCCESS;
}
@@ -211,10 +210,10 @@
MagmaImage* image = magma_swapchain->get_image(image_index);
DLOG("QueuePresent image_index %u id 0x%" PRIx64, image_index,
- magma_system_get_buffer_id(image->buffer_handle()));
+ magma_get_buffer_id(image->buffer_handle()));
magma_semaphore_t signal_semaphores[1]{image->semaphore()};
- magma_system_display_page_flip(
+ magma_display_page_flip(
magma_swapchain->connection(), image->buffer_handle(), wait_semaphore_count,
reinterpret_cast<const magma_semaphore_t*>(wait_semaphores), 1, signal_semaphores);
@@ -232,7 +231,7 @@
static constexpr uint32_t kMagic = 0x6D617377; // 'masw'
const uint32_t magic_ = kMagic;
- magma_system_connection* connection_;
+ magma_connection_t* connection_;
std::vector<std::unique_ptr<MagmaImage>> images_;
uint32_t next_index_ = 0;
};
diff --git a/tests/unit_tests/test_drm_command_buffer.cc b/tests/unit_tests/test_drm_command_buffer.cc
index 4207351..cf39c13 100644
--- a/tests/unit_tests/test_drm_command_buffer.cc
+++ b/tests/unit_tests/test_drm_command_buffer.cc
@@ -6,27 +6,27 @@
class Buffer {
public:
- Buffer(magma_system_connection* connection, magma_buffer_t handle, uint64_t size)
+ Buffer(magma_connection_t* connection, magma_buffer_t handle, uint64_t size)
: connection_(connection), handle_(handle), size_(size)
{
}
- ~Buffer() { magma_system_free(connection_, handle_); }
+ ~Buffer() { magma_free(connection_, handle_); }
uint64_t size() { return size_; }
- uint64_t id() { return magma_system_get_buffer_id(handle_); }
+ uint64_t id() { return magma_get_buffer_id(handle_); }
magma_buffer_t handle() { return handle_; }
private:
- magma_system_connection* connection_;
+ magma_connection_t* connection_;
magma_buffer_t handle_;
uint64_t size_;
};
class TestDrmCommandBuffer {
public:
- TestDrmCommandBuffer() { connection_ = magma_system_open(0, MAGMA_SYSTEM_CAPABILITY_RENDERING); }
+ TestDrmCommandBuffer() { connection_ = magma_open(0, MAGMA_SYSTEM_CAPABILITY_RENDERING); }
- ~TestDrmCommandBuffer() { magma_system_close(connection_); }
+ ~TestDrmCommandBuffer() { magma_close(connection_); }
void NoBuffers()
{
@@ -60,7 +60,7 @@
std::unique_ptr<Buffer> CreateBuffer(uint64_t size)
{
magma_buffer_t handle;
- if (magma_system_alloc(connection_, size, &size, &handle) != 0)
+ if (magma_alloc(connection_, size, &size, &handle) != 0)
return DRETP(nullptr, "magma_system_alloc failed");
return std::make_unique<Buffer>(connection_, handle, size);
}
@@ -197,7 +197,7 @@
}
private:
- magma_system_connection* connection_;
+ magma_connection_t* connection_;
};
TEST(DrmCommandBuffer, NoBuffers)