intel: move alloc functions to util
To support global extensions, needed to add pointer
to the intel_instance structure in the intel_handle.
That broke things that were using the icd pointer in the
handle and to avoid catch-22 between the intel.h and instance.h
needed to separate the alloc routines to their own file
rather than static inline in intel.h.
diff --git a/icd/intel/compiler/CMakeLists.txt b/icd/intel/compiler/CMakeLists.txt
index fc68377..f6c886d 100644
--- a/icd/intel/compiler/CMakeLists.txt
+++ b/icd/intel/compiler/CMakeLists.txt
@@ -356,6 +356,7 @@
SET(STANDALONE_COMPILER_SOURCES
shader/main.cpp
+ shader/standalone_utils.c
shader/compiler_interface.cpp
pipeline/pipeline_compiler_interface.cpp
${CREATE_SHADER_SOURCES}
diff --git a/icd/intel/compiler/pipeline/pipeline_compiler_interface_meta.cpp b/icd/intel/compiler/pipeline/pipeline_compiler_interface_meta.cpp
index b357785..571e8d7 100644
--- a/icd/intel/compiler/pipeline/pipeline_compiler_interface_meta.cpp
+++ b/icd/intel/compiler/pipeline/pipeline_compiler_interface_meta.cpp
@@ -25,8 +25,10 @@
* LunarG
*/
+extern "C" {
#include "gpu.h"
#include "pipeline.h"
+}
#include "compiler/shader/compiler_interface.h"
#include "compiler/pipeline/pipeline_compiler_interface.h"
#include "compiler/pipeline/brw_blorp_blit_eu.h"
diff --git a/icd/intel/compiler/shader/standalone_utils.c b/icd/intel/compiler/shader/standalone_utils.c
new file mode 100644
index 0000000..fa5791c
--- /dev/null
+++ b/icd/intel/compiler/shader/standalone_utils.c
@@ -0,0 +1,53 @@
+/*
+ * Copyright © 2008, 2009 Intel Corporation
+ *
+ * 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 (including the next
+ * paragraph) 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 <getopt.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <string.h>
+#include <inttypes.h>
+
+/** @file standalone_utils.cpp
+ *
+ * This file contains the allocation and logging utils needed
+ * by the standalone compiler.
+ */
+
+#include "instance.h"
+
+
+void *intel_alloc(const void *handle,
+ size_t size, size_t alignment,
+ VkSystemAllocType type)
+{
+ assert(intel_handle_validate(handle));
+ return icd_instance_alloc(((const struct intel_handle *) handle)->instance->icd,
+ size, alignment, type);
+}
+
+void intel_free(const void *handle, void *ptr)
+{
+ assert(intel_handle_validate(handle));
+ icd_instance_free(((const struct intel_handle *) handle)->instance->icd, ptr);
+}
+
diff --git a/icd/intel/instance.c b/icd/intel/instance.c
index be074a6..b30e057 100644
--- a/icd/intel/instance.c
+++ b/icd/intel/instance.c
@@ -33,6 +33,42 @@
static int intel_devid_override;
int intel_debug = -1;
+void *intel_alloc(const void *handle,
+ size_t size, size_t alignment,
+ VkSystemAllocType type)
+{
+ assert(intel_handle_validate(handle));
+ return icd_instance_alloc(((const struct intel_handle *) handle)->instance->icd,
+ size, alignment, type);
+}
+
+void intel_free(const void *handle, void *ptr)
+{
+ assert(intel_handle_validate(handle));
+ icd_instance_free(((const struct intel_handle *) handle)->instance->icd, ptr);
+}
+
+void intel_logv(const void *handle,
+ VkFlags msg_flags,
+ VkObjectType obj_type, VkObject src_object,
+ size_t location, int32_t msg_code,
+ const char *format, va_list ap)
+{
+ char msg[256];
+ int ret;
+
+ ret = vsnprintf(msg, sizeof(msg), format, ap);
+ if (ret >= sizeof(msg) || ret < 0)
+ msg[sizeof(msg) - 1] = '\0';
+
+ assert(intel_handle_validate(handle));
+ icd_instance_log(((const struct intel_handle *) handle)->instance->icd,
+ msg_flags,
+ obj_type, src_object, /* obj_type, object */
+ location, msg_code, /* location, msg_code */
+ msg);
+}
+
static void intel_debug_init(void)
{
const char *env;
diff --git a/icd/intel/intel.h b/icd/intel/intel.h
index 203e7cc..a70e1dc 100644
--- a/icd/intel/intel.h
+++ b/icd/intel/intel.h
@@ -122,20 +122,11 @@
return (handle_type == (uint32_t) type);
}
-static inline void *intel_alloc(const void *handle,
- size_t size, size_t alignment,
- VkSystemAllocType type)
-{
- assert(intel_handle_validate(handle));
- return icd_instance_alloc(((const struct intel_handle *) handle)->icd,
- size, alignment, type);
-}
+void *intel_alloc(const void *handle,
+ size_t size, size_t alignment,
+ VkSystemAllocType type);
-static inline void intel_free(const void *handle, void *ptr)
-{
- assert(intel_handle_validate(handle));
- icd_instance_free(((const struct intel_handle *) handle)->icd, ptr);
-}
+void intel_free(const void *handle, void *ptr);
static inline void intel_logv(const void *handle,
VkFlags msg_flags,