Browse Source

no message

Hongtae Kim 7 years ago
parent
commit
74b7044f57
1 changed files with 21 additions and 1 deletions
  1. 21
    1
      TestApp1/TestApp1.cpp

+ 21
- 1
TestApp1/TestApp1.cpp View File

@@ -26,11 +26,31 @@ public:
26 26
 			NULL, NULL);
27 27
 
28 28
 		DKObject<DKGraphicsDevice> device = DKGraphicsDevice::SharedInstance();
29
-		device->CreateCommandQueue();
29
+		DKObject<DKCommandQueue> queue = device->CreateCommandQueue();
30
+		DKObject<DKCommandBuffer> buffer = queue->CreateCommandBuffer();
30 31
 	}
31 32
 	void OnTerminate(void) override
32 33
 	{
33 34
 		DKLog("%s", DKGL_FUNCTION_NAME);
35
+		DKLog("Memory Pool Statistics");
36
+		size_t numBuckets = DKMemoryPoolNumberOfBuckets();
37
+		DKMemoryPoolBucketStatus* buckets = new DKMemoryPoolBucketStatus[numBuckets];
38
+		DKMemoryPoolQueryAllocationStatus(buckets, numBuckets);
39
+		size_t usedBytes = 0;
40
+		for (int i = 0; i < numBuckets; ++i)
41
+		{
42
+			if (buckets[i].totalChunks > 0)
43
+			{
44
+				DKLog("--> %lu: allocated:%lu, reserved:%.1fKB. (usage:%.1f%%)",
45
+					buckets[i].chunkSize,
46
+					buckets[i].chunkSize * buckets[i].usedChunks,
47
+					double(buckets[i].chunkSize * (buckets[i].totalChunks - buckets[i].usedChunks)) / 1024.0,
48
+					double(buckets[i].usedChunks) / double(buckets[i].totalChunks) * 100.0);
49
+				usedBytes += buckets[i].chunkSize * buckets[i].usedChunks;
50
+			}
51
+		}
52
+		DKLog("MemoryPool Usage: %.1fMB / %.1fMB", double(usedBytes) / (1024 * 1024), double(DKMemoryPoolSize()) / (1024 * 1024));
53
+		delete[] buckets;
34 54
 	}
35 55
 };
36 56