tests: Add queue init to common.
diff --git a/tests/common.c b/tests/common.c
index 67b5bee..08fef7b 100644
--- a/tests/common.c
+++ b/tests/common.c
@@ -133,6 +133,31 @@
}
}
+static const char *xgl_qtype_string(XGL_QUEUE_TYPE qtype) {
+ switch (qtype) {
+#define STR(r) case r: return #r
+ STR(XGL_QUEUE_TYPE_GRAPHICS);
+ STR(XGL_QUEUE_TYPE_COMPUTE);
+ STR(XGL_QUEUE_TYPE_DMA);
+ default: return "UNKNOWN_RESULT";
+ }
+}
+
+// TODO: May need to extend to more than one queue per type
+void app_dev_init_queue(struct app_dev *dev, XGL_QUEUE_TYPE qtype)
+{
+ XGL_RESULT err;
+
+ /* abort before we go past the end of our queue array */
+ assert(qtype < MAX_QUEUE_TYPES);
+
+ err = xglGetDeviceQueue(dev->obj, qtype, 0, &dev->queues[qtype]);
+ if (err) {
+ printf("xglGetDeviceQueue: %s queue #%d: Failed\n",
+ xgl_qtype_string(qtype), 0);
+ }
+}
+
void app_gpu_init(struct app_gpu *gpu, XGL_UINT id, XGL_PHYSICAL_GPU obj)
{
XGL_SIZE size;
diff --git a/tests/common.h b/tests/common.h
index 8244549..88e8f77 100644
--- a/tests/common.h
+++ b/tests/common.h
@@ -29,6 +29,7 @@
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
+#include <assert.h>
#include <xgl.h>
@@ -46,6 +47,8 @@
#define MAX_GPUS 8
+#define MAX_QUEUE_TYPES 5
+
struct app_dev {
struct app_gpu *gpu; /* point back to the GPU */
@@ -53,6 +56,7 @@
XGL_UINT heap_count;
XGL_MEMORY_HEAP_PROPERTIES *heap_props;
+ XGL_QUEUE queues[MAX_QUEUE_TYPES];
XGL_FORMAT_PROPERTIES format_props[XGL_MAX_CH_FMT][XGL_MAX_NUM_FMT];
};
@@ -131,5 +135,6 @@
void app_gpu_init_extensions(struct app_gpu *gpu);
void app_gpu_init(struct app_gpu *gpu, XGL_UINT id, XGL_PHYSICAL_GPU obj);
void app_gpu_destroy(struct app_gpu *gpu);
+void app_dev_init_queue(struct app_dev *dev, XGL_QUEUE_TYPE qtype);
#endif // COMMON_H