blob: 122a9ed08c95489f93a3813fe0295b6260c0ffa8 [file] [log] [blame]
Jason Sams9397e302009-08-27 20:23:34 -07001
2#define DATA_SYNC_SIZE 1024
3
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -08004static inline void rsHCAPI_ContextFinish (RsContext rsc) {
Jason Sams8c880902010-06-15 12:15:57 -07005 ThreadIO *io = &((Context *)rsc)->mIO;
6 uint32_t size = sizeof(RS_CMD_ContextFinish);
7 RS_CMD_ContextFinish *cmd = static_cast<RS_CMD_ContextFinish *>(io->mToCore.reserve(size));
8 io->mToCore.commitSync(RS_CMD_ID_ContextFinish, size);
9}
10
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080011static inline void rsHCAPI_ScriptInvokeV (RsContext rsc, RsScript va, uint32_t slot, const void * data, uint32_t sizeBytes) {
Jason Samsbe36bf32010-05-11 14:03:58 -070012 ThreadIO *io = &((Context *)rsc)->mIO;
13 uint32_t size = sizeof(RS_CMD_ScriptInvokeV);
14 if (sizeBytes < DATA_SYNC_SIZE) {
15 size += (sizeBytes + 3) & ~3;
16 }
17 RS_CMD_ScriptInvokeV *cmd = static_cast<RS_CMD_ScriptInvokeV *>(io->mToCore.reserve(size));
18 cmd->s = va;
19 cmd->slot = slot;
20 cmd->dataLen = sizeBytes;
21 cmd->data = data;
22 if (sizeBytes < DATA_SYNC_SIZE) {
23 cmd->data = (void *)(cmd+1);
24 memcpy(cmd+1, data, sizeBytes);
25 io->mToCore.commit(RS_CMD_ID_ScriptInvokeV, size);
26 } else {
27 io->mToCore.commitSync(RS_CMD_ID_ScriptInvokeV, size);
28 }
29}
30
31
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080032static inline void rsHCAPI_ScriptSetVarV (RsContext rsc, RsScript va, uint32_t slot, const void * data, uint32_t sizeBytes) {
Jason Samsbe36bf32010-05-11 14:03:58 -070033 ThreadIO *io = &((Context *)rsc)->mIO;
34 uint32_t size = sizeof(RS_CMD_ScriptSetVarV);
35 if (sizeBytes < DATA_SYNC_SIZE) {
36 size += (sizeBytes + 3) & ~3;
37 }
38 RS_CMD_ScriptSetVarV *cmd = static_cast<RS_CMD_ScriptSetVarV *>(io->mToCore.reserve(size));
39 cmd->s = va;
40 cmd->slot = slot;
41 cmd->dataLen = sizeBytes;
42 cmd->data = data;
43 if (sizeBytes < DATA_SYNC_SIZE) {
44 cmd->data = (void *)(cmd+1);
45 memcpy(cmd+1, data, sizeBytes);
46 io->mToCore.commit(RS_CMD_ID_ScriptSetVarV, size);
47 } else {
48 io->mToCore.commitSync(RS_CMD_ID_ScriptSetVarV, size);
49 }
50}
51
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080052static inline void rsHCAPI_AllocationData (RsContext rsc, RsAllocation va, const void * data, uint32_t sizeBytes) {
Jason Sams9397e302009-08-27 20:23:34 -070053 ThreadIO *io = &((Context *)rsc)->mIO;
54 uint32_t size = sizeof(RS_CMD_AllocationData);
55 if (sizeBytes < DATA_SYNC_SIZE) {
56 size += (sizeBytes + 3) & ~3;
57 }
58 RS_CMD_AllocationData *cmd = static_cast<RS_CMD_AllocationData *>(io->mToCore.reserve(size));
59 cmd->va = va;
60 cmd->bytes = sizeBytes;
61 cmd->data = data;
62 if (sizeBytes < DATA_SYNC_SIZE) {
63 cmd->data = (void *)(cmd+1);
64 memcpy(cmd+1, data, sizeBytes);
65 io->mToCore.commit(RS_CMD_ID_AllocationData, size);
66 } else {
67 io->mToCore.commitSync(RS_CMD_ID_AllocationData, size);
68 }
69}
70
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080071static inline void rsHCAPI_Allocation1DSubData (RsContext rsc, RsAllocation va, uint32_t xoff, uint32_t count, const void * data, uint32_t sizeBytes) {
Jason Sams9397e302009-08-27 20:23:34 -070072 ThreadIO *io = &((Context *)rsc)->mIO;
73 uint32_t size = sizeof(RS_CMD_Allocation1DSubData);
74 if (sizeBytes < DATA_SYNC_SIZE) {
75 size += (sizeBytes + 3) & ~3;
76 }
77 RS_CMD_Allocation1DSubData *cmd = static_cast<RS_CMD_Allocation1DSubData *>(io->mToCore.reserve(size));
78 cmd->va = va;
79 cmd->xoff = xoff;
80 cmd->count = count;
81 cmd->data = data;
82 cmd->bytes = sizeBytes;
83 if (sizeBytes < DATA_SYNC_SIZE) {
84 cmd->data = (void *)(cmd+1);
85 memcpy(cmd+1, data, sizeBytes);
86 io->mToCore.commit(RS_CMD_ID_Allocation1DSubData, size);
87 } else {
88 io->mToCore.commitSync(RS_CMD_ID_Allocation1DSubData, size);
89 }
Jason Sams9397e302009-08-27 20:23:34 -070090}
91
Alex Sakhartchoukafb743a2010-11-09 17:00:54 -080092static inline void rsHCAPI_Allocation1DSubElementData (RsContext rsc, RsAllocation va, uint32_t x, const void * data, uint32_t comp_offset, uint32_t sizeBytes) {
Jason Sams5f0c84c2010-08-31 13:50:42 -070093 ThreadIO *io = &((Context *)rsc)->mIO;
94 uint32_t size = sizeof(RS_CMD_Allocation1DSubElementData);
95 if (sizeBytes < DATA_SYNC_SIZE) {
96 size += (sizeBytes + 3) & ~3;
97 }
98 RS_CMD_Allocation1DSubElementData *cmd = static_cast<RS_CMD_Allocation1DSubElementData *>(io->mToCore.reserve(size));
99 cmd->va = va;
100 cmd->x = x;
101 cmd->data = data;
102 cmd->comp_offset = comp_offset;
103 cmd->bytes = sizeBytes;
104 if (sizeBytes < DATA_SYNC_SIZE) {
105 cmd->data = (void *)(cmd+1);
106 memcpy(cmd+1, data, sizeBytes);
107 io->mToCore.commit(RS_CMD_ID_Allocation1DSubElementData, size);
108 } else {
109 io->mToCore.commitSync(RS_CMD_ID_Allocation1DSubElementData, size);
110 }
Jason Sams5f0c84c2010-08-31 13:50:42 -0700111}
112