Jason Sams | 9397e30 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 1 | |
| 2 | #define DATA_SYNC_SIZE 1024 |
| 3 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 4 | static inline void rsHCAPI_ContextFinish (RsContext rsc) { |
Jason Sams | 8c88090 | 2010-06-15 12:15:57 -0700 | [diff] [blame] | 5 | 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 Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 11 | static inline void rsHCAPI_ScriptInvokeV (RsContext rsc, RsScript va, uint32_t slot, const void * data, uint32_t sizeBytes) { |
Jason Sams | be36bf3 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 12 | 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 Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 32 | static inline void rsHCAPI_ScriptSetVarV (RsContext rsc, RsScript va, uint32_t slot, const void * data, uint32_t sizeBytes) { |
Jason Sams | be36bf3 | 2010-05-11 14:03:58 -0700 | [diff] [blame] | 33 | 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 Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 52 | static inline void rsHCAPI_AllocationData (RsContext rsc, RsAllocation va, const void * data, uint32_t sizeBytes) { |
Jason Sams | 9397e30 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 53 | 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 Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 71 | static inline void rsHCAPI_Allocation1DSubData (RsContext rsc, RsAllocation va, uint32_t xoff, uint32_t count, const void * data, uint32_t sizeBytes) { |
Jason Sams | 9397e30 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 72 | 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 Sams | 9397e30 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 90 | } |
| 91 | |
Alex Sakhartchouk | afb743a | 2010-11-09 17:00:54 -0800 | [diff] [blame] | 92 | static inline void rsHCAPI_Allocation1DSubElementData (RsContext rsc, RsAllocation va, uint32_t x, const void * data, uint32_t comp_offset, uint32_t sizeBytes) { |
Jason Sams | 5f0c84c | 2010-08-31 13:50:42 -0700 | [diff] [blame] | 93 | 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 Sams | 5f0c84c | 2010-08-31 13:50:42 -0700 | [diff] [blame] | 111 | } |
| 112 | |