Implement GetDeviceQueue()
[mesa.git] / src / libre-soc / vulkan / libresoc_device.c
index d7290de696278ce56634b38aa298447d3ae89f08..a9da9d96eb19eaefc2c308fda156d6bb4cc9a72b 100644 (file)
@@ -28,6 +28,7 @@
 #include <sys/sysinfo.h>
 #include <unistd.h>
 
+#include "util/debug.h"
 #include "libresoc_private.h"
 #include "vk_util.h"
 #include "vk_alloc.h"
@@ -80,6 +81,44 @@ static const VkAllocationCallbacks default_alloc = {
        .pfnFree = default_free_func,
 };
 
+static const struct debug_control libresoc_debug_options[] = {
+       {"nofastclears", LIBRESOC_DEBUG_NO_FAST_CLEARS},
+       {"nodcc", LIBRESOC_DEBUG_NO_DCC},
+       {"shaders", LIBRESOC_DEBUG_DUMP_SHADERS},
+       {"nocache", LIBRESOC_DEBUG_NO_CACHE},
+       {"shaderstats", LIBRESOC_DEBUG_DUMP_SHADER_STATS},
+       {"nohiz", LIBRESOC_DEBUG_NO_HIZ},
+       {"nocompute", LIBRESOC_DEBUG_NO_COMPUTE_QUEUE},
+       {"allbos", LIBRESOC_DEBUG_ALL_BOS},
+       {"noibs", LIBRESOC_DEBUG_NO_IBS},
+       {"spirv", LIBRESOC_DEBUG_DUMP_SPIRV},
+       {"vmfaults", LIBRESOC_DEBUG_VM_FAULTS},
+       {"zerovram", LIBRESOC_DEBUG_ZERO_VRAM},
+       {"syncshaders", LIBRESOC_DEBUG_SYNC_SHADERS},
+       {"preoptir", LIBRESOC_DEBUG_PREOPTIR},
+       {"nodynamicbounds", LIBRESOC_DEBUG_NO_DYNAMIC_BOUNDS},
+       {"nooutoforder", LIBRESOC_DEBUG_NO_OUT_OF_ORDER},
+       {"info", LIBRESOC_DEBUG_INFO},
+       {"errors", LIBRESOC_DEBUG_ERRORS},
+       {"startup", LIBRESOC_DEBUG_STARTUP},
+       {"checkir", LIBRESOC_DEBUG_CHECKIR},
+       {"nothreadllvm", LIBRESOC_DEBUG_NOTHREADLLVM},
+       {"nobinning", LIBRESOC_DEBUG_NOBINNING},
+       {"nongg", LIBRESOC_DEBUG_NO_NGG},
+       {"allentrypoints", LIBRESOC_DEBUG_ALL_ENTRYPOINTS},
+       {"metashaders", LIBRESOC_DEBUG_DUMP_META_SHADERS},
+       {"nomemorycache", LIBRESOC_DEBUG_NO_MEMORY_CACHE},
+       {"llvm", LIBRESOC_DEBUG_LLVM},
+       {"forcecompress", LIBRESOC_DEBUG_FORCE_COMPRESS},
+       {NULL, 0}
+};
+
+const char *
+libresoc_get_debug_option_name(int id)
+{
+       assert(id < ARRAY_SIZE(libresoc_debug_options) - 1);
+       return libresoc_debug_options[id].string;
+}
 VkResult
 libresoc_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
                     const VkAllocationCallbacks *pAllocator,
@@ -110,6 +149,8 @@ libresoc_CreateInstance(const VkInstanceCreateInfo *pCreateInfo,
                instance->engineVersion = app->engineVersion;
                instance->apiVersion = app->apiVersion;
        }
+       instance->debug_flags = parse_debug_string(getenv("LIBRESOC_DEBUG"),
+                                                  libresoc_debug_options);
        /*TODO : enable extensions*/
        for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
                int idx;
@@ -460,15 +501,15 @@ libresoc_GetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice,
        *pProperties = (VkPhysicalDeviceProperties) {
                .apiVersion = libresoc_physical_device_api_version(pdevice),
                .driverVersion = vk_get_driver_version(),
-               .vendorID = 1,
-               .deviceID = 1,
+               .vendorID = 1, //TODO: some dummy value
+               .deviceID = 1, //TODO: dome dummay value
                .deviceType = VK_PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU,
                .limits = limits,
                .sparseProperties = {0},
        };
 
        strcpy(pProperties->deviceName, pdevice->name);
-//     memcpy(pProperties->pipelineCacheUUID, pdevice->cache_uuid, VK_UUID_SIZE);
+       memcpy(pProperties->pipelineCacheUUID, pdevice->cache_uuid, VK_UUID_SIZE);
 }
 
 static void libresoc_get_physical_device_queue_family_properties(
@@ -946,14 +987,18 @@ libresoc_DestroyDevice(VkDevice _device,
    /* FIXME: stub */
 }
 
-void
-libresoc_GetDeviceQueue(VkDevice _device,
-                    uint32_t queueNodeIndex,
-                    uint32_t queueIndex,
-                    VkQueue *pQueue)
+void libresoc_GetDeviceQueue(
+       VkDevice                                    _device,
+       uint32_t                                    queueFamilyIndex,
+       uint32_t                                    queueIndex,
+       VkQueue*                                    pQueue)
 {
        if (getenv("LIBRESOC_TRACE")) {
                fprintf(stderr, "GetDeviceQueue called. \n");
        }
-   /* FIXME: stub */
+       LIBRESOC_FROM_HANDLE(libresoc_device, device, _device);
+       struct libresoc_queue *queue;
+
+       queue = &device->queues[queueFamilyIndex][queueIndex];
+       *pQueue = libresoc_queue_to_handle(queue);
 }