memory alloc: Add allocation index to BindObjectMemory
authorJon Ashburn <jon@lunarg.com>
Thu, 15 Jan 2015 17:39:19 +0000 (10:39 -0700)
committerCourtney Goeltzenleuchter <courtney@LunarG.com>
Thu, 5 Feb 2015 00:58:09 +0000 (17:58 -0700)
For now it is always index 0.  Updates, driver, glave, tests, demos, include,
and layers.

12 files changed:
demos/cube.c
demos/tri.c
icd/intel/obj.c
include/xgl.h
layers/draw_state.c
layers/mem_tracker.c
tests/blit_tests.cpp
tests/image_tests.cpp
tests/init.cpp
tests/render_tests.cpp
tests/xgltestbinding.cpp
xgl.py

index ad3ba5d..d6dec16 100644 (file)
@@ -507,7 +507,7 @@ static void demo_prepare_depth(struct demo *demo)
     assert(!err);
 
     /* bind memory */
-    err = xglBindObjectMemory(demo->depth.image,
+    err = xglBindObjectMemory(demo->depth.image, 0,
             demo->depth.mem, 0);
     assert(!err);
 
@@ -762,7 +762,7 @@ static void demo_prepare_textures(struct demo *demo)
         assert(!err);
 
         /* bind memory */
-        err = xglBindObjectMemory(demo->textures[i].image,
+        err = xglBindObjectMemory(demo->textures[i].image, 0,
                 demo->textures[i].mem, 0);
         assert(!err);
 
@@ -860,7 +860,7 @@ void demo_prepare_cube_data_buffer(struct demo *demo)
     err = xglUnmapMemory(demo->uniform_data.mem);
     assert(!err);
 
-    err = xglBindObjectMemory(demo->uniform_data.buf,
+    err = xglBindObjectMemory(demo->uniform_data.buf, 0,
             demo->uniform_data.mem, 0);
     assert(!err);
 
index ee085dc..5c16e53 100644 (file)
@@ -318,7 +318,7 @@ static void demo_prepare_depth(struct demo *demo)
     assert(!err);
 
     /* bind memory */
-    err = xglBindObjectMemory(demo->depth.image,
+    err = xglBindObjectMemory(demo->depth.image, 0,
             demo->depth.mem, 0);
     assert(!err);
 
@@ -424,7 +424,7 @@ static void demo_prepare_textures(struct demo *demo)
         assert(!err);
 
         /* bind memory */
-        err = xglBindObjectMemory(demo->textures[i].image,
+        err = xglBindObjectMemory(demo->textures[i].image, 0,
                 demo->textures[i].mem, 0);
         assert(!err);
 
@@ -521,7 +521,7 @@ static void demo_prepare_vertices(struct demo *demo)
     err = xglUnmapMemory(demo->vertices.mem);
     assert(!err);
 
-    err = xglBindObjectMemory(demo->vertices.buf, demo->vertices.mem, 0);
+    err = xglBindObjectMemory(demo->vertices.buf, 0, demo->vertices.mem, 0);
     assert(!err);
 
     demo->vertices.vi.sType = XGL_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_CREATE_INFO;
@@ -1037,20 +1037,20 @@ static void demo_cleanup(struct demo *demo)
     xglDestroyObject(demo->pipeline);
     xglDestroyObject(demo->desc_layout);
 
-    xglBindObjectMemory(demo->vertices.buf, XGL_NULL_HANDLE, 0);
+    xglBindObjectMemory(demo->vertices.buf, 0, XGL_NULL_HANDLE, 0);
     xglDestroyObject(demo->vertices.buf);
     xglFreeMemory(demo->vertices.mem);
 
     for (i = 0; i < DEMO_TEXTURE_COUNT; i++) {
         xglDestroyObject(demo->textures[i].view);
-        xglBindObjectMemory(demo->textures[i].image, XGL_NULL_HANDLE, 0);
+        xglBindObjectMemory(demo->textures[i].image, 0, XGL_NULL_HANDLE, 0);
         xglDestroyObject(demo->textures[i].image);
         xglFreeMemory(demo->textures[i].mem);
         xglDestroyObject(demo->textures[i].sampler);
     }
 
     xglDestroyObject(demo->depth.view);
-    xglBindObjectMemory(demo->depth.image, XGL_NULL_HANDLE, 0);
+    xglBindObjectMemory(demo->depth.image, 0, XGL_NULL_HANDLE, 0);
     xglDestroyObject(demo->depth.image);
     xglFreeMemory(demo->depth.mem);
 
index c3493dd..817affa 100644 (file)
@@ -363,6 +363,7 @@ ICD_EXPORT XGL_RESULT XGLAPI xglGetObjectInfo(
 
 ICD_EXPORT XGL_RESULT XGLAPI xglBindObjectMemory(
     XGL_OBJECT                                  object,
+    XGL_UINT                                    allocationIdx,
     XGL_GPU_MEMORY                              mem_,
     XGL_GPU_SIZE                                memOffset)
 {
@@ -376,6 +377,7 @@ ICD_EXPORT XGL_RESULT XGLAPI xglBindObjectMemory(
 
 ICD_EXPORT XGL_RESULT XGLAPI xglBindObjectMemoryRange(
     XGL_OBJECT                                  object,
+    XGL_UINT                                    allocationIdx,
     XGL_GPU_SIZE                                rangeOffset,
     XGL_GPU_SIZE                                rangeSize,
     XGL_GPU_MEMORY                              mem,
@@ -386,6 +388,7 @@ ICD_EXPORT XGL_RESULT XGLAPI xglBindObjectMemoryRange(
 
 ICD_EXPORT XGL_RESULT XGLAPI xglBindImageMemoryRange(
     XGL_IMAGE                                   image,
+    XGL_UINT                                    allocationIdx,
     const XGL_IMAGE_MEMORY_BIND_INFO*           bindInfo,
     XGL_GPU_MEMORY                              mem,
     XGL_GPU_SIZE                                memOffset)
index c243b68..f9e794b 100644 (file)
@@ -2045,9 +2045,9 @@ typedef XGL_RESULT (XGLAPI *xglOpenPeerMemoryType)(XGL_DEVICE device, const XGL_
 typedef XGL_RESULT (XGLAPI *xglOpenPeerImageType)(XGL_DEVICE device, const XGL_PEER_IMAGE_OPEN_INFO* pOpenInfo, XGL_IMAGE* pImage, XGL_GPU_MEMORY* pMem);
 typedef XGL_RESULT (XGLAPI *xglDestroyObjectType)(XGL_OBJECT object);
 typedef XGL_RESULT (XGLAPI *xglGetObjectInfoType)(XGL_BASE_OBJECT object, XGL_OBJECT_INFO_TYPE infoType, XGL_SIZE* pDataSize, XGL_VOID* pData);
-typedef XGL_RESULT (XGLAPI *xglBindObjectMemoryType)(XGL_OBJECT object, XGL_GPU_MEMORY mem, XGL_GPU_SIZE memOffset);
-typedef XGL_RESULT (XGLAPI *xglBindObjectMemoryRangeType)(XGL_OBJECT object, XGL_GPU_SIZE rangeOffset, XGL_GPU_SIZE rangeSize, XGL_GPU_MEMORY mem, XGL_GPU_SIZE memOffset);
-typedef XGL_RESULT (XGLAPI *xglBindImageMemoryRangeType)(XGL_IMAGE image, const XGL_IMAGE_MEMORY_BIND_INFO* bindInfo, XGL_GPU_MEMORY mem, XGL_GPU_SIZE memOffset);
+typedef XGL_RESULT (XGLAPI *xglBindObjectMemoryType)(XGL_OBJECT object, XGL_UINT allocationIdx, XGL_GPU_MEMORY mem, XGL_GPU_SIZE memOffset);
+typedef XGL_RESULT (XGLAPI *xglBindObjectMemoryRangeType)(XGL_OBJECT object, XGL_UINT allocationIdx, XGL_GPU_SIZE rangeOffset, XGL_GPU_SIZE rangeSize, XGL_GPU_MEMORY mem, XGL_GPU_SIZE memOffset);
+typedef XGL_RESULT (XGLAPI *xglBindImageMemoryRangeType)(XGL_IMAGE image, XGL_UINT allocationIdx, const XGL_IMAGE_MEMORY_BIND_INFO* bindInfo, XGL_GPU_MEMORY mem, XGL_GPU_SIZE memOffset);
 typedef XGL_RESULT (XGLAPI *xglCreateFenceType)(XGL_DEVICE device, const XGL_FENCE_CREATE_INFO* pCreateInfo, XGL_FENCE* pFence);
 typedef XGL_RESULT (XGLAPI *xglGetFenceStatusType)(XGL_FENCE fence);
 typedef XGL_RESULT (XGLAPI *xglWaitForFencesType)(XGL_DEVICE device, XGL_UINT fenceCount, const XGL_FENCE* pFences, XGL_BOOL waitAll, XGL_UINT64 timeout);
@@ -2271,11 +2271,13 @@ XGL_RESULT XGLAPI xglGetObjectInfo(
 
 XGL_RESULT XGLAPI xglBindObjectMemory(
     XGL_OBJECT                                  object,
+    XGL_UINT                                    allocationIdx,
     XGL_GPU_MEMORY                              mem,
     XGL_GPU_SIZE                                memOffset);
 
 XGL_RESULT XGLAPI xglBindObjectMemoryRange(
     XGL_OBJECT                                  object,
+    XGL_UINT                                    allocationIdx,
     XGL_GPU_SIZE                                rangeOffset,
     XGL_GPU_SIZE                                rangeSize,
     XGL_GPU_MEMORY                              mem,
@@ -2283,6 +2285,7 @@ XGL_RESULT XGLAPI xglBindObjectMemoryRange(
 
 XGL_RESULT XGLAPI xglBindImageMemoryRange(
     XGL_IMAGE                                   image,
+    XGL_UINT                                    allocationIdx,
     const XGL_IMAGE_MEMORY_BIND_INFO*           bindInfo,
     XGL_GPU_MEMORY                              mem,
     XGL_GPU_SIZE                                memOffset);
index 4f936ce..b871de4 100644 (file)
@@ -1125,9 +1125,9 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetObjectInfo(XGL_BASE_OBJECT object, XGL_
     return result;
 }
 
-XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglBindObjectMemory(XGL_OBJECT object, XGL_GPU_MEMORY mem, XGL_GPU_SIZE offset)
+XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglBindObjectMemory(XGL_OBJECT object, XGL_UINT allocationIdx, XGL_GPU_MEMORY mem, XGL_GPU_SIZE offset)
 {
-    XGL_RESULT result = nextTable.BindObjectMemory(object, mem, offset);
+    XGL_RESULT result = nextTable.BindObjectMemory(object, allocationIdx, mem, offset);
     return result;
 }
 
index d43ff53..3da0b43 100644 (file)
@@ -1243,9 +1243,9 @@ XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglGetObjectInfo(XGL_BASE_OBJECT object, XGL_
     return result;
 }
 
-XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglBindObjectMemory(XGL_OBJECT object, XGL_GPU_MEMORY mem, XGL_GPU_SIZE offset)
+XGL_LAYER_EXPORT XGL_RESULT XGLAPI xglBindObjectMemory(XGL_OBJECT object, XGL_UINT allocationIdx, XGL_GPU_MEMORY mem, XGL_GPU_SIZE offset)
 {
-    XGL_RESULT result = nextTable.BindObjectMemory(object, mem, offset);
+    XGL_RESULT result = nextTable.BindObjectMemory(object, allocationIdx, mem, offset);
     // Track objects tied to memory
     if (XGL_FALSE == updateObjectBinding(object, mem)) {
         char str[1024];
index 0721f0b..2316b25 100644 (file)
@@ -754,7 +754,7 @@ TEST_F(XglCmdCopyBufferTest, RAWHazard)
     err = xglAllocMemory(dev_.obj(), &mem_info, &event_mem);
     ASSERT_XGL_SUCCESS(err);
 
-    err = xglBindObjectMemory(event, event_mem, 0);
+    err = xglBindObjectMemory(event, 0, event_mem, 0);
     ASSERT_XGL_SUCCESS(err);
 
     err = xglResetEvent(event);
@@ -829,7 +829,7 @@ TEST_F(XglCmdCopyBufferTest, RAWHazard)
     bufs[2].unmap();
 
     // All done with event memory, clean up
-    err = xglBindObjectMemory(event, XGL_NULL_HANDLE, 0);
+    err = xglBindObjectMemory(event, 0, XGL_NULL_HANDLE, 0);
     ASSERT_XGL_SUCCESS(err);
 
     err = xglDestroyObject(event);
index aefe657..2694e92 100644 (file)
@@ -215,14 +215,14 @@ void XglImageTest::CreateImage(XGL_UINT w, XGL_UINT h)
     err = xglAllocMemory(device(), &mem_info, &m_image_mem);
     ASSERT_XGL_SUCCESS(err);
 
-    err = xglBindObjectMemory(m_image, m_image_mem, 0);
+    err = xglBindObjectMemory(m_image, 0, m_image_mem, 0);
     ASSERT_XGL_SUCCESS(err);
 }
 
 void XglImageTest::DestroyImage()
 {
     // All done with image memory, clean up
-    ASSERT_XGL_SUCCESS(xglBindObjectMemory(m_image, XGL_NULL_HANDLE, 0));
+    ASSERT_XGL_SUCCESS(xglBindObjectMemory(m_image, 0, XGL_NULL_HANDLE, 0));
 
     ASSERT_XGL_SUCCESS(xglFreeMemory(m_image_mem));
 
index a97283e..f8e2e8e 100644 (file)
@@ -235,7 +235,7 @@ TEST_F(XglTest, Event) {
     err = xglAllocMemory(device(), &mem_info, &event_mem);
     ASSERT_XGL_SUCCESS(err);
 
-    err = xglBindObjectMemory(event, event_mem, 0);
+    err = xglBindObjectMemory(event, 0, event_mem, 0);
     ASSERT_XGL_SUCCESS(err);
 
     err = xglResetEvent(event);
@@ -253,7 +253,7 @@ TEST_F(XglTest, Event) {
     // TODO: Test actual synchronization with command buffer event.
 
     // All done with event memory, clean up
-    err = xglBindObjectMemory(event, XGL_NULL_HANDLE, 0);
+    err = xglBindObjectMemory(event, 0, XGL_NULL_HANDLE, 0);
     ASSERT_XGL_SUCCESS(err);
 
     err = xglDestroyObject(event);
@@ -374,7 +374,7 @@ TEST_F(XglTest, Query) {
     err = xglAllocMemory(device(), &mem_info, &query_mem);
     ASSERT_XGL_SUCCESS(err);
 
-    err = xglBindObjectMemory(query_pool, query_mem, 0);
+    err = xglBindObjectMemory(query_pool, 0, query_mem, 0);
     ASSERT_XGL_SUCCESS(err);
 
     // TODO: Test actual synchronization with command buffer event.
@@ -399,7 +399,7 @@ TEST_F(XglTest, Query) {
     }
 
     // All done with QueryPool memory, clean up
-    err = xglBindObjectMemory(query_pool, XGL_NULL_HANDLE, 0);
+    err = xglBindObjectMemory(query_pool, 0, XGL_NULL_HANDLE, 0);
     ASSERT_XGL_SUCCESS(err);
 
     err = xglDestroyObject(query_pool);
@@ -645,7 +645,7 @@ void XglTest::CreateImageTest()
     err = xglAllocMemory(device(), &mem_info, &image_mem);
     ASSERT_XGL_SUCCESS(err);
 
-    err = xglBindObjectMemory(image, image_mem, 0);
+    err = xglBindObjectMemory(image, 0, image_mem, 0);
     ASSERT_XGL_SUCCESS(err);
 
 //    typedef struct _XGL_IMAGE_VIEW_CREATE_INFO
@@ -688,7 +688,7 @@ void XglTest::CreateImageTest()
     // TODO: Test image memory.
 
     // All done with image memory, clean up
-    ASSERT_XGL_SUCCESS(xglBindObjectMemory(image, XGL_NULL_HANDLE, 0));
+    ASSERT_XGL_SUCCESS(xglBindObjectMemory(image, 0, XGL_NULL_HANDLE, 0));
 
     ASSERT_XGL_SUCCESS(xglFreeMemory(image_mem));
 
index ffaaa7b..226472f 100644 (file)
@@ -384,7 +384,7 @@ void XglRenderTest::InitDepthStencil()
     ASSERT_XGL_SUCCESS(err);
 
     /* bind memory */
-    err = xglBindObjectMemory(m_depthStencilImage, m_depthStencilMem, 0);
+    err = xglBindObjectMemory(m_depthStencilImage, 0, m_depthStencilMem, 0);
     ASSERT_XGL_SUCCESS(err);
 
     XGL_DYNAMIC_DS_STATE_CREATE_INFO depthStencil = {};
index f31fa4e..1f388a4 100644 (file)
@@ -230,18 +230,18 @@ void Object::cleanup()
 
 void Object::bind_memory(uint32_t alloc_idx, const GpuMemory &mem, XGL_GPU_SIZE mem_offset)
 {
-    EXPECT(!alloc_idx && xglBindObjectMemory(obj(), mem.obj(), mem_offset) == XGL_SUCCESS);
+    EXPECT(!alloc_idx && xglBindObjectMemory(obj(), 0, mem.obj(), mem_offset) == XGL_SUCCESS);
 }
 
 void Object::bind_memory(uint32_t alloc_idx, XGL_GPU_SIZE offset, XGL_GPU_SIZE size,
                          const GpuMemory &mem, XGL_GPU_SIZE mem_offset)
 {
-    EXPECT(!alloc_idx && xglBindObjectMemoryRange(obj(), offset, size, mem.obj(), mem_offset) == XGL_SUCCESS);
+    EXPECT(!alloc_idx && xglBindObjectMemoryRange(obj(), 0, offset, size, mem.obj(), mem_offset) == XGL_SUCCESS);
 }
 
 void Object::unbind_memory(uint32_t alloc_idx)
 {
-    EXPECT(!alloc_idx && xglBindObjectMemory(obj(), XGL_NULL_HANDLE, 0) == XGL_SUCCESS);
+    EXPECT(!alloc_idx && xglBindObjectMemory(obj(), 0, XGL_NULL_HANDLE, 0) == XGL_SUCCESS);
 }
 
 void Object::unbind_memory()
@@ -656,7 +656,7 @@ void Image::init_info(const Device &dev, const XGL_IMAGE_CREATE_INFO &info)
 void Image::bind_memory(uint32_t alloc_idx, const XGL_IMAGE_MEMORY_BIND_INFO &info,
                         const GpuMemory &mem, XGL_GPU_SIZE mem_offset)
 {
-    EXPECT(!alloc_idx && xglBindImageMemoryRange(obj(), &info, mem.obj(), mem_offset) == XGL_SUCCESS);
+    EXPECT(!alloc_idx && xglBindImageMemoryRange(obj(), 0, &info, mem.obj(), mem_offset) == XGL_SUCCESS);
 }
 
 XGL_SUBRESOURCE_LAYOUT Image::subresource_layout(const XGL_IMAGE_SUBRESOURCE &subres) const
diff --git a/xgl.py b/xgl.py
index 315f676..653584a 100644 (file)
--- a/xgl.py
+++ b/xgl.py
@@ -341,11 +341,13 @@ core = Extension(
 
         Proto("XGL_RESULT", "BindObjectMemory",
             [Param("XGL_OBJECT", "object"),
+             Param("XGL_UINT", "allocationIdx"),
              Param("XGL_GPU_MEMORY", "mem"),
              Param("XGL_GPU_SIZE", "memOffset")]),
 
         Proto("XGL_RESULT", "BindObjectMemoryRange",
             [Param("XGL_OBJECT", "object"),
+             Param("XGL_UINT", "allocationIdx"),
              Param("XGL_GPU_SIZE", "rangeOffset"),
              Param("XGL_GPU_SIZE", "rangeSize"),
              Param("XGL_GPU_MEMORY", "mem"),
@@ -353,6 +355,7 @@ core = Extension(
 
         Proto("XGL_RESULT", "BindImageMemoryRange",
             [Param("XGL_IMAGE", "image"),
+             Param("XGL_UINT", "allocationIdx"),
              Param("const XGL_IMAGE_MEMORY_BIND_INFO*", "bindInfo"),
              Param("XGL_GPU_MEMORY", "mem"),
              Param("XGL_GPU_SIZE", "memOffset")]),