From 3276917be8cb8a6b61d9fd5ae86d052a88b6f4e6 Mon Sep 17 00:00:00 2001 From: Jon Ashburn Date: Tue, 20 Jan 2015 15:06:59 -0700 Subject: [PATCH] memory alloc: Remove MEMORY_ALLOC_FLAGS add MEMORY_TYPE --- demos/cube.c | 6 +++--- demos/tri.c | 8 ++++---- icd/intel/wsi_x11.c | 2 +- include/xgl.h | 13 +++++++++---- tests/blit_tests.cpp | 2 +- tests/image_tests.cpp | 2 +- tests/init.cpp | 9 ++++----- tests/render_tests.cpp | 2 +- tests/xgltestbinding.h | 1 + 9 files changed, 25 insertions(+), 20 deletions(-) diff --git a/demos/cube.c b/demos/cube.c index 54237e8..e482ffd 100644 --- a/demos/cube.c +++ b/demos/cube.c @@ -473,7 +473,7 @@ static void demo_prepare_depth(struct demo *demo) .allocationSize = 0, .alignment = 0, .memProps = XGL_MEMORY_PROPERTY_GPU_ONLY, - .flags = 0, + .memType = XGL_MEMORY_TYPE_IMAGE, .heapCount = 0, .memPriority = XGL_MEMORY_PRIORITY_NORMAL, }; @@ -744,7 +744,7 @@ static void demo_prepare_textures(struct demo *demo) .allocationSize = 0, .alignment = 0, .memProps = XGL_MEMORY_PROPERTY_GPU_ONLY, - .flags = 0, + .memType = XGL_MEMORY_TYPE_IMAGE, .heapCount = 0, .pHeaps = 0, .memPriority = XGL_MEMORY_PRIORITY_NORMAL, @@ -864,7 +864,7 @@ void demo_prepare_cube_data_buffer(struct demo *demo) .allocationSize = 0, .alignment = 0, .memProps = XGL_MEMORY_PROPERTY_CPU_VISIBLE_BIT, - .flags = 0, + .memType = XGL_MEMORY_TYPE_BUFFER, .heapCount = 0, .memPriority = XGL_MEMORY_PRIORITY_NORMAL, }; diff --git a/demos/tri.c b/demos/tri.c index 3b21eb7..32a37a1 100644 --- a/demos/tri.c +++ b/demos/tri.c @@ -291,7 +291,7 @@ static void demo_prepare_depth(struct demo *demo) .allocationSize = 0, .alignment = 0, .memProps = XGL_MEMORY_PROPERTY_GPU_ONLY, - .flags = 0, + .memType = XGL_MEMORY_TYPE_IMAGE, .heapCount = 0, .memPriority = XGL_MEMORY_PRIORITY_NORMAL, }; @@ -415,7 +415,7 @@ static void demo_prepare_textures(struct demo *demo) .allocationSize = 0, .alignment = 0, .memProps = XGL_MEMORY_PROPERTY_GPU_ONLY, - .flags = 0, + .memType = XGL_MEMORY_TYPE_IMAGE, .heapCount = 0, .memPriority = XGL_MEMORY_PRIORITY_NORMAL, }; @@ -550,7 +550,7 @@ static void demo_prepare_vertices(struct demo *demo) .allocationSize = 0, .alignment = 0, .memProps = XGL_MEMORY_PROPERTY_CPU_VISIBLE_BIT, - .flags = 0, + .memType = XGL_MEMORY_TYPE_BUFFER, .heapCount = 0, .pHeaps = 0, .memPriority = XGL_MEMORY_PRIORITY_NORMAL, @@ -590,7 +590,7 @@ static void demo_prepare_vertices(struct demo *demo) mem_alloc.alignment = mem_reqs[i].alignment; mem_alloc.heapCount = mem_reqs[i].heapCount; mem_alloc.pHeaps = mem_reqs[i].pHeaps; - memcpy(mem_alloc.pHeaps, mem_reqs[i].pHeaps, + memcpy((void *) mem_alloc.pHeaps, mem_reqs[i].pHeaps, sizeof(mem_reqs[i].pHeaps[0]) * mem_reqs[i].heapCount); err = xglAllocMemory(demo->device, &mem_alloc, &demo->vertices.mem[i]); diff --git a/icd/intel/wsi_x11.c b/icd/intel/wsi_x11.c index 77039d2..e6edee4 100644 --- a/icd/intel/wsi_x11.c +++ b/icd/intel/wsi_x11.c @@ -519,8 +519,8 @@ static XGL_RESULT wsi_x11_img_create(struct intel_wsi_x11 *x11, mem_info.sType = XGL_STRUCTURE_TYPE_MEMORY_ALLOC_INFO; mem_info.allocationSize = img->total_size; mem_info.alignment = 4096; - mem_info.flags = 0; mem_info.memProps = 0; + mem_info.memType = XGL_MEMORY_TYPE_IMAGE; mem_info.heapCount = 1; mem_info.memPriority = XGL_MEMORY_PRIORITY_HIGH; static XGL_UINT heapInfo[1]; diff --git a/include/xgl.h b/include/xgl.h index fc1b38f..6f4659b 100644 --- a/include/xgl.h +++ b/include/xgl.h @@ -990,10 +990,14 @@ typedef enum _XGL_MEMORY_PROPERTY_FLAGS } XGL_MEMORY_PROPERTY_FLAGS; // Memory allocation flags -typedef enum _XGL_MEMORY_ALLOC_FLAGS +typedef enum _XGL_MEMORY_TYPE { - XGL_MEMORY_ALLOC_SHAREABLE_BIT = 0x00000001, -} XGL_MEMORY_ALLOC_FLAGS; + XGL_MEMORY_TYPE_OTHER = 0x00000000, // device memory that is not any of the others + XGL_MEMORY_TYPE_BUFFER = 0x00000001, // memory for buffers and associated information + XGL_MEMORY_TYPE_IMAGE = 0x00000002, // memory for images and associated information + XGL_MEMORY_TYPE_PIPELINE = 0x00000003, // memory for pipeline objects + XGL_MAX_ENUM(_XGL_MEMORY_TYPE) +} XGL_MEMORY_TYPE; // Buffer and buffer allocation usage flags typedef enum _XGL_BUFFER_USAGE_FLAGS @@ -1315,11 +1319,11 @@ typedef struct _XGL_MEMORY_ALLOC_INFO XGL_VOID* pNext; // Pointer to next structure XGL_GPU_SIZE allocationSize; // Size of memory allocation XGL_GPU_SIZE alignment; - XGL_FLAGS flags; // XGL_MEMORY_ALLOC_FLAGS XGL_UINT heapCount; const XGL_UINT* pHeaps; XGL_MEMORY_PRIORITY memPriority; XGL_FLAGS memProps; // XGL_MEMORY_PROPERTY_FLAGS + XGL_MEMORY_TYPE memType; } XGL_MEMORY_ALLOC_INFO; // This structure is included in the XGL_MEMORY_ALLOC_INFO chain @@ -1364,6 +1368,7 @@ typedef struct _XGL_MEMORY_REQUIREMENTS XGL_UINT heapCount; XGL_UINT* pHeaps; XGL_FLAGS memProps; // XGL_MEMORY_PROPERTY_FLAGS + XGL_MEMORY_TYPE memType; } XGL_MEMORY_REQUIREMENTS; typedef struct _XGL_BUFFER_MEMORY_REQUIREMENTS diff --git a/tests/blit_tests.cpp b/tests/blit_tests.cpp index 0441a9c..599a041 100644 --- a/tests/blit_tests.cpp +++ b/tests/blit_tests.cpp @@ -750,7 +750,7 @@ TEST_F(XglCmdCopyBufferTest, RAWHazard) mem_info.pHeaps = heapInfo; memcpy(heapInfo, mem_req.pHeaps, sizeof(XGL_UINT)*mem_info.heapCount); mem_info.memPriority = XGL_MEMORY_PRIORITY_NORMAL; - mem_info.flags = XGL_MEMORY_ALLOC_SHAREABLE_BIT; + mem_info.memProps = XGL_MEMORY_PROPERTY_SHAREABLE_BIT; err = xglAllocMemory(dev_.obj(), &mem_info, &event_mem); ASSERT_XGL_SUCCESS(err); diff --git a/tests/image_tests.cpp b/tests/image_tests.cpp index b0e5620..f3f4d7b 100644 --- a/tests/image_tests.cpp +++ b/tests/image_tests.cpp @@ -234,7 +234,7 @@ void XglImageTest::CreateImage(XGL_UINT w, XGL_UINT h) memcpy(heapInfo, mem_req[i].pHeaps, sizeof(XGL_UINT)*mem_info.heapCount); mem_info.memProps = XGL_MEMORY_PROPERTY_SHAREABLE_BIT; mem_info.memPriority = XGL_MEMORY_PRIORITY_NORMAL; - mem_info.flags = XGL_MEMORY_ALLOC_SHAREABLE_BIT; + mem_info.memType = XGL_MEMORY_TYPE_IMAGE; /* allocate memory */ err = xglAllocMemory(device(), &mem_info, &m_image_mem[i]); diff --git a/tests/init.cpp b/tests/init.cpp index 82d5f33..60cca3e 100644 --- a/tests/init.cpp +++ b/tests/init.cpp @@ -166,6 +166,7 @@ TEST_F(XglTest, AllocMemory) { alloc_info.alignment = 0; alloc_info.memProps = XGL_MEMORY_PROPERTY_SHAREABLE_BIT | XGL_MEMORY_PROPERTY_CPU_VISIBLE_BIT; + alloc_info.memType = XGL_MEMORY_TYPE_OTHER, alloc_info.heapCount = 1; alloc_info.pHeaps = localHeap; @@ -231,7 +232,7 @@ TEST_F(XglTest, Event) { mem_info.pHeaps = heapInfo; memcpy(heapInfo, mem_req.pHeaps, sizeof(XGL_UINT)*mem_info.heapCount); mem_info.memPriority = XGL_MEMORY_PRIORITY_NORMAL; - mem_info.flags = XGL_MEMORY_ALLOC_SHAREABLE_BIT; + mem_info.memType = XGL_MEMORY_TYPE_OTHER; err = xglAllocMemory(device(), &mem_info, &event_mem); ASSERT_XGL_SUCCESS(err); @@ -368,10 +369,8 @@ TEST_F(XglTest, Query) { memcpy(heapInfo, mem_req.pHeaps, sizeof(XGL_UINT)*mem_info.heapCount); mem_info.memProps = XGL_MEMORY_PROPERTY_SHAREABLE_BIT; mem_info.memPriority = XGL_MEMORY_PRIORITY_NORMAL; - - // TODO: are the flags right? + mem_info.memType = XGL_MEMORY_TYPE_OTHER; // TODO: Should this be pinned? Or maybe a separate test with pinned. - mem_info.flags = XGL_MEMORY_ALLOC_SHAREABLE_BIT; err = xglAllocMemory(device(), &mem_info, &query_mem); ASSERT_XGL_SUCCESS(err); @@ -656,7 +655,7 @@ void XglTest::CreateImageTest() memcpy(heapInfo, mem_req.pHeaps, sizeof(XGL_UINT)*mem_info.heapCount); mem_info.memProps = XGL_MEMORY_PROPERTY_SHAREABLE_BIT; mem_info.memPriority = XGL_MEMORY_PRIORITY_NORMAL; - mem_info.flags = XGL_MEMORY_ALLOC_SHAREABLE_BIT; + mem_info.memType = XGL_MEMORY_TYPE_IMAGE; err = xglAllocMemory(device(), &mem_info, &image_mem); ASSERT_XGL_SUCCESS(err); diff --git a/tests/render_tests.cpp b/tests/render_tests.cpp index 9ccba70..b3dc938 100644 --- a/tests/render_tests.cpp +++ b/tests/render_tests.cpp @@ -365,7 +365,7 @@ void XglRenderTest::InitDepthStencil() mem_alloc.allocationSize = 0; mem_alloc.alignment = 0; mem_alloc.memProps = XGL_MEMORY_PROPERTY_GPU_ONLY; - mem_alloc.flags = 0; + mem_alloc.memType = XGL_MEMORY_TYPE_IMAGE; mem_alloc.heapCount = 0; mem_alloc.memPriority = XGL_MEMORY_PRIORITY_NORMAL; diff --git a/tests/xgltestbinding.h b/tests/xgltestbinding.h index 03ea70f..bf8cb4d 100644 --- a/tests/xgltestbinding.h +++ b/tests/xgltestbinding.h @@ -630,6 +630,7 @@ inline XGL_MEMORY_ALLOC_INFO GpuMemory::alloc_info(const XGL_MEMORY_REQUIREMENTS info.heapCount = reqs.heapCount; info.pHeaps = reqs.pHeaps; info.memProps = reqs.memProps; + info.memType = reqs.memType; info.memPriority = XGL_MEMORY_PRIORITY_NORMAL; return info; } -- 2.7.4