blob: 6f21a35c55056860adcb328cbf972e77fe81f75e [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
Jason Sams4b45b892010-12-29 14:31:29 -080052static inline void rsHCAPI_Allocation1DData (RsContext rsc, RsAllocation va, uint32_t xoff, uint32_t lod,
53 uint32_t count, const void * data, uint32_t sizeBytes) {
Jason Sams9397e302009-08-27 20:23:34 -070054 ThreadIO *io = &((Context *)rsc)->mIO;
Jason Sams4b45b892010-12-29 14:31:29 -080055 uint32_t size = sizeof(RS_CMD_Allocation1DData);
Jason Sams9397e302009-08-27 20:23:34 -070056 if (sizeBytes < DATA_SYNC_SIZE) {
57 size += (sizeBytes + 3) & ~3;
58 }
Jason Sams4b45b892010-12-29 14:31:29 -080059 RS_CMD_Allocation1DData *cmd = static_cast<RS_CMD_Allocation1DData *>(io->mToCore.reserve(size));
Jason Sams9397e302009-08-27 20:23:34 -070060 cmd->va = va;
61 cmd->xoff = xoff;
Jason Sams4b45b892010-12-29 14:31:29 -080062 cmd->lod = lod;
Jason Sams9397e302009-08-27 20:23:34 -070063 cmd->count = count;
64 cmd->data = data;
65 cmd->bytes = sizeBytes;
66 if (sizeBytes < DATA_SYNC_SIZE) {
67 cmd->data = (void *)(cmd+1);
68 memcpy(cmd+1, data, sizeBytes);
Jason Sams4b45b892010-12-29 14:31:29 -080069 io->mToCore.commit(RS_CMD_ID_Allocation1DData, size);
Jason Sams9397e302009-08-27 20:23:34 -070070 } else {
Jason Sams4b45b892010-12-29 14:31:29 -080071 io->mToCore.commitSync(RS_CMD_ID_Allocation1DData, size);
Jason Sams9397e302009-08-27 20:23:34 -070072 }
Jason Sams9397e302009-08-27 20:23:34 -070073}
74
Jason Sams4b45b892010-12-29 14:31:29 -080075static inline void rsHCAPI_Allocation1DElementData (RsContext rsc, RsAllocation va, uint32_t x, uint32_t lod,
76 const void * data, uint32_t comp_offset, uint32_t sizeBytes) {
Jason Sams5f0c84c2010-08-31 13:50:42 -070077 ThreadIO *io = &((Context *)rsc)->mIO;
Jason Sams4b45b892010-12-29 14:31:29 -080078 uint32_t size = sizeof(RS_CMD_Allocation1DElementData);
Jason Sams5f0c84c2010-08-31 13:50:42 -070079 if (sizeBytes < DATA_SYNC_SIZE) {
80 size += (sizeBytes + 3) & ~3;
81 }
Jason Sams4b45b892010-12-29 14:31:29 -080082 RS_CMD_Allocation1DElementData *cmd = static_cast<RS_CMD_Allocation1DElementData *>(io->mToCore.reserve(size));
Jason Sams5f0c84c2010-08-31 13:50:42 -070083 cmd->va = va;
84 cmd->x = x;
Jason Sams4b45b892010-12-29 14:31:29 -080085 cmd->lod = lod;
Jason Sams5f0c84c2010-08-31 13:50:42 -070086 cmd->data = data;
87 cmd->comp_offset = comp_offset;
88 cmd->bytes = sizeBytes;
89 if (sizeBytes < DATA_SYNC_SIZE) {
90 cmd->data = (void *)(cmd+1);
91 memcpy(cmd+1, data, sizeBytes);
Jason Sams4b45b892010-12-29 14:31:29 -080092 io->mToCore.commit(RS_CMD_ID_Allocation1DElementData, size);
Jason Sams5f0c84c2010-08-31 13:50:42 -070093 } else {
Jason Sams4b45b892010-12-29 14:31:29 -080094 io->mToCore.commitSync(RS_CMD_ID_Allocation1DElementData, size);
Jason Sams5f0c84c2010-08-31 13:50:42 -070095 }
Jason Sams5f0c84c2010-08-31 13:50:42 -070096}
97