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 | |
Jason Sams | 4b45b89 | 2010-12-29 14:31:29 -0800 | [diff] [blame] | 52 | static 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 Sams | 9397e30 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 54 | ThreadIO *io = &((Context *)rsc)->mIO; |
Jason Sams | 4b45b89 | 2010-12-29 14:31:29 -0800 | [diff] [blame] | 55 | uint32_t size = sizeof(RS_CMD_Allocation1DData); |
Jason Sams | 9397e30 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 56 | if (sizeBytes < DATA_SYNC_SIZE) { |
| 57 | size += (sizeBytes + 3) & ~3; |
| 58 | } |
Jason Sams | 4b45b89 | 2010-12-29 14:31:29 -0800 | [diff] [blame] | 59 | RS_CMD_Allocation1DData *cmd = static_cast<RS_CMD_Allocation1DData *>(io->mToCore.reserve(size)); |
Jason Sams | 9397e30 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 60 | cmd->va = va; |
| 61 | cmd->xoff = xoff; |
Jason Sams | 4b45b89 | 2010-12-29 14:31:29 -0800 | [diff] [blame] | 62 | cmd->lod = lod; |
Jason Sams | 9397e30 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 63 | 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 Sams | 4b45b89 | 2010-12-29 14:31:29 -0800 | [diff] [blame] | 69 | io->mToCore.commit(RS_CMD_ID_Allocation1DData, size); |
Jason Sams | 9397e30 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 70 | } else { |
Jason Sams | 4b45b89 | 2010-12-29 14:31:29 -0800 | [diff] [blame] | 71 | io->mToCore.commitSync(RS_CMD_ID_Allocation1DData, size); |
Jason Sams | 9397e30 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 72 | } |
Jason Sams | 9397e30 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 73 | } |
| 74 | |
Jason Sams | 4b45b89 | 2010-12-29 14:31:29 -0800 | [diff] [blame] | 75 | static 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 Sams | 5f0c84c | 2010-08-31 13:50:42 -0700 | [diff] [blame] | 77 | ThreadIO *io = &((Context *)rsc)->mIO; |
Jason Sams | 4b45b89 | 2010-12-29 14:31:29 -0800 | [diff] [blame] | 78 | uint32_t size = sizeof(RS_CMD_Allocation1DElementData); |
Jason Sams | 5f0c84c | 2010-08-31 13:50:42 -0700 | [diff] [blame] | 79 | if (sizeBytes < DATA_SYNC_SIZE) { |
| 80 | size += (sizeBytes + 3) & ~3; |
| 81 | } |
Jason Sams | 4b45b89 | 2010-12-29 14:31:29 -0800 | [diff] [blame] | 82 | RS_CMD_Allocation1DElementData *cmd = static_cast<RS_CMD_Allocation1DElementData *>(io->mToCore.reserve(size)); |
Jason Sams | 5f0c84c | 2010-08-31 13:50:42 -0700 | [diff] [blame] | 83 | cmd->va = va; |
| 84 | cmd->x = x; |
Jason Sams | 4b45b89 | 2010-12-29 14:31:29 -0800 | [diff] [blame] | 85 | cmd->lod = lod; |
Jason Sams | 5f0c84c | 2010-08-31 13:50:42 -0700 | [diff] [blame] | 86 | 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 Sams | 4b45b89 | 2010-12-29 14:31:29 -0800 | [diff] [blame] | 92 | io->mToCore.commit(RS_CMD_ID_Allocation1DElementData, size); |
Jason Sams | 5f0c84c | 2010-08-31 13:50:42 -0700 | [diff] [blame] | 93 | } else { |
Jason Sams | 4b45b89 | 2010-12-29 14:31:29 -0800 | [diff] [blame] | 94 | io->mToCore.commitSync(RS_CMD_ID_Allocation1DElementData, size); |
Jason Sams | 5f0c84c | 2010-08-31 13:50:42 -0700 | [diff] [blame] | 95 | } |
Jason Sams | 5f0c84c | 2010-08-31 13:50:42 -0700 | [diff] [blame] | 96 | } |
| 97 | |