1 module dcompute.driver.ocl.memory;
2 
3 import dcompute.driver.ocl;
4 
5 struct Memory
6 {
7     enum Type
8     {
9         buffer         = 0x10F0,
10         image2D        = 0x10F1,
11         image3D        = 0x10F2,
12         image2Darray   = 0x10F3,
13         image1D        = 0x10F4,
14         image1Darray   = 0x10F5,
15         image1Dbuffer = 0x10F6,
16     }
17     
18     enum Flags
19     {
20         none                = 0,
21         readWrite           = 1 << 0,
22         writeOnly           = 1 << 1,
23         readOnly            = 1 << 2,
24         useHostPointer      = 1 << 3,
25         allocateHostPointer = 1 << 4,
26         copyHostPointer     = 1 << 5,
27         //reserved            1 << 6,
28         hostReadWrite       = 1 << 7,
29         hostReadOnly        = 1 << 8,
30         hostNoAccess        = 1 << 9,
31     }
32     
33     static struct Info
34     {
35         @(0x1100) Type type;
36         @(0x1101) Flags flags;
37         @(0x1102) size_t size;
38         @(0x1103) void* hostPointer;
39         @(0x1104) uint mapCount;
40         @(0x1105) uint referenceCount;
41         @(0x1106) Context context;
42         @(0x1107) Memory associatedMemory;
43         @(0x1108) size_t offset;
44         
45         // Extensions
46         //@(0x4015) D3D10_RESOURCE_KHR
47         //@(0x401E) D3D10_RESOURCE_KHR
48         //@(0x2028) DX9_MEDIA_ADAPTER_TYPE_KHR
49         //@(0x2029) DX9_MEDIA_SURFACE_INFO_KHR
50     }
51     cl_mem raw;
52     
53     //mixin(generateGetInfo!(Info,clGetMemObjectInfo));
54     void retain()
55     {
56         status = cast(Status)clRetainMemObject(raw);
57         checkErrors();
58     }
59     void release()
60     {
61         status = cast(Status)clReleaseMemObject(raw);
62         checkErrors();
63     }
64 }