tests: Add test for xglCreateFence
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 206d8d6..96b7df5 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -4,5 +4,7 @@
add_executable(xglinfo xglinfo.c ${COMMON})
add_executable(xglAllocMemory xglAllocMemory.c ${COMMON})
+add_executable(xglFence xglFence.c ${COMMON})
target_link_libraries(xglinfo XGL)
target_link_libraries(xglAllocMemory XGL)
+target_link_libraries(xglFence XGL)
diff --git a/tests/xglFence.c b/tests/xglFence.c
new file mode 100644
index 0000000..fa9570f
--- /dev/null
+++ b/tests/xglFence.c
@@ -0,0 +1,100 @@
+/*
+ * XGL
+ *
+ * Copyright (C) 2014 LunarG, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#include "common.h"
+#include "debug.h"
+
+int main(int argc, char **argv)
+{
+ static const XGL_APPLICATION_INFO app_info = {
+ .sType = XGL_STRUCTURE_TYPE_APPLICATION_INFO,
+ .pNext = NULL,
+ .pAppName = (const XGL_CHAR *) "xglCreateDevice",
+ .appVersion = 1,
+ .pEngineName = (const XGL_CHAR *) "xglCreateDevice",
+ .engineVersion = 1,
+ .apiVersion = XGL_MAKE_VERSION(0, 22, 0),
+ };
+ struct app_gpu gpus[MAX_GPUS];
+ XGL_PHYSICAL_GPU objs[MAX_GPUS];
+ XGL_UINT gpu_count, i, gpu_idx;
+ XGL_RESULT err;
+ XGL_FENCE_CREATE_INFO fence_info;
+ XGL_FENCE fence;
+
+ err = xglInitAndEnumerateGpus(&app_info, NULL,
+ MAX_GPUS, &gpu_count, objs);
+ if (err)
+ ERR_EXIT(err);
+
+ if (gpu_count <= 0) {
+ ERR_MSG_EXIT("No GPU avialable");
+ }
+
+ for (i = 0; i < gpu_count; i++) {
+ app_gpu_init(&gpus[i], i, objs[i]);
+ }
+
+ for (gpu_idx = 0; gpu_idx < gpu_count; gpu_idx++) {
+ if (gpus[gpu_idx].dev.heap_count > 0) {
+ memset(&fence_info, 0, sizeof(fence_info));
+
+// typedef struct _XGL_FENCE_CREATE_INFO
+// {
+// XGL_STRUCTURE_TYPE sType; // Must be XGL_STRUCTURE_TYPE_FENCE_CREATE_INFO
+// const XGL_VOID* pNext; // Pointer to next structure
+// XGL_FLAGS flags; // Reserved
+ fence_info.sType = XGL_STRUCTURE_TYPE_FENCE_CREATE_INFO;
+
+ err = xglCreateFence(gpus[gpu_idx].dev.obj, &fence_info, &fence);
+ if (err)
+ ERR_EXIT(err);
+
+ printf("xglCreateFence: Passed\n");
+
+ err = xglGetFenceStatus(fence);
+ // We've not submitted this fence on a command buffer so should get
+ // XGL_ERROR_UNAVAILABLE
+ if (err != XGL_ERROR_UNAVAILABLE) {
+ ERR_EXIT(err);
+ }
+
+ // TODO: Attached to command buffer and test GetFenceStatus
+
+ err = xglDestroyObject(fence);
+ if (err)
+ ERR_EXIT(err);
+
+ printf("xglDestoryObject(fence): Passed\n");
+
+ } else {
+ debug_printf("No heaps available for GPU #%d: %s", gpu_idx, gpus[gpu_idx].props.gpuName);
+ }
+ }
+
+ for (i = 0; i < gpu_count; i++)
+ app_gpu_destroy(&gpus[i]);
+
+ return 0;
+}