update for buffer object changes
diff --git a/icd/intel/buf.c b/icd/intel/buf.c
new file mode 100644
index 0000000..f783eec
--- /dev/null
+++ b/icd/intel/buf.c
@@ -0,0 +1,115 @@
+/*
+ * 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.
+ *
+ * Authors:
+ * Chia-I Wu <olv@lunarg.com>
+ */
+
+#include "dev.h"
+#include "obj.h"
+#include "buf.h"
+
+static void buf_destroy(struct intel_obj *obj)
+{
+ struct intel_buf *buf = intel_buf_from_obj(obj);
+
+ intel_buf_destroy(buf);
+}
+
+static XGL_RESULT buf_get_info(struct intel_base *base, int type,
+ XGL_SIZE *size, XGL_VOID *data)
+{
+ struct intel_buf *buf = intel_buf_from_base(base);
+ XGL_RESULT ret = XGL_SUCCESS;
+
+ switch (type) {
+ case XGL_INFO_TYPE_MEMORY_REQUIREMENTS:
+ {
+ XGL_MEMORY_REQUIREMENTS *mem_req = data;
+
+ *size = sizeof(XGL_MEMORY_REQUIREMENTS);
+ if (data == NULL)
+ return ret;
+
+ /*
+ * From the Sandy Bridge PRM, volume 1 part 1, page 118:
+ *
+ * "For buffers, which have no inherent "height," padding
+ * requirements are different. A buffer must be padded to the
+ * next multiple of 256 array elements, with an additional 16
+ * bytes added beyond that to account for the L1 cache line."
+ */
+ mem_req->size = buf->size;
+ if (buf->usage & XGL_BUFFER_USAGE_SHADER_ACCESS_READ_BIT)
+ mem_req->size = u_align(mem_req->size, 256) + 16;
+
+ mem_req->alignment = 4096;
+ mem_req->heapCount = 1;
+ mem_req->heaps[0] = 0;
+
+ }
+ break;
+ default:
+ ret = intel_base_get_info(base, type, size, data);
+ break;
+ }
+
+ return ret;
+}
+
+XGL_RESULT intel_buf_create(struct intel_dev *dev,
+ const XGL_BUFFER_CREATE_INFO *info,
+ struct intel_buf **buf_ret)
+{
+ struct intel_buf *buf;
+
+ buf = (struct intel_buf *) intel_base_create(dev, sizeof(*buf),
+ dev->base.dbg, XGL_DBG_OBJECT_BUFFER, info, 0);
+ if (!buf)
+ return XGL_ERROR_OUT_OF_MEMORY;
+
+ buf->size = info->size;
+ buf->usage = info->usage;
+
+ buf->obj.destroy = buf_destroy;
+ buf->obj.base.get_info = buf_get_info;
+
+ *buf_ret = buf;
+
+ return XGL_SUCCESS;
+}
+
+void intel_buf_destroy(struct intel_buf *buf)
+{
+ intel_base_destroy(&buf->obj.base);
+}
+
+ICD_EXPORT XGL_RESULT XGLAPI xglCreateBuffer(
+ XGL_DEVICE device,
+ const XGL_BUFFER_CREATE_INFO* pCreateInfo,
+ XGL_BUFFER* pBuffer)
+{
+ struct intel_dev *dev = intel_dev(device);
+
+ return intel_buf_create(dev, pCreateInfo, (struct intel_buf **) pBuffer);
+}