Jason Sams | 07ae406 | 2009-08-27 20:23:34 -0700 | [diff] [blame] | 1 | |
| 2 | #define DATA_SYNC_SIZE 1024 |
| 3 | |
| 4 | static inline void rsHCAPI_AllocationData (RsContext rsc, RsAllocation va, const void * data, uint32_t sizeBytes) |
| 5 | { |
| 6 | ThreadIO *io = &((Context *)rsc)->mIO; |
| 7 | uint32_t size = sizeof(RS_CMD_AllocationData); |
| 8 | if (sizeBytes < DATA_SYNC_SIZE) { |
| 9 | size += (sizeBytes + 3) & ~3; |
| 10 | } |
| 11 | RS_CMD_AllocationData *cmd = static_cast<RS_CMD_AllocationData *>(io->mToCore.reserve(size)); |
| 12 | cmd->va = va; |
| 13 | cmd->bytes = sizeBytes; |
| 14 | cmd->data = data; |
| 15 | if (sizeBytes < DATA_SYNC_SIZE) { |
| 16 | cmd->data = (void *)(cmd+1); |
| 17 | memcpy(cmd+1, data, sizeBytes); |
| 18 | io->mToCore.commit(RS_CMD_ID_AllocationData, size); |
| 19 | } else { |
| 20 | io->mToCore.commitSync(RS_CMD_ID_AllocationData, size); |
| 21 | } |
| 22 | } |
| 23 | |
| 24 | |
| 25 | static inline void rsHCAPI_Allocation1DSubData (RsContext rsc, RsAllocation va, uint32_t xoff, uint32_t count, const void * data, uint32_t sizeBytes) |
| 26 | { |
| 27 | ThreadIO *io = &((Context *)rsc)->mIO; |
| 28 | uint32_t size = sizeof(RS_CMD_Allocation1DSubData); |
| 29 | if (sizeBytes < DATA_SYNC_SIZE) { |
| 30 | size += (sizeBytes + 3) & ~3; |
| 31 | } |
| 32 | RS_CMD_Allocation1DSubData *cmd = static_cast<RS_CMD_Allocation1DSubData *>(io->mToCore.reserve(size)); |
| 33 | cmd->va = va; |
| 34 | cmd->xoff = xoff; |
| 35 | cmd->count = count; |
| 36 | cmd->data = data; |
| 37 | cmd->bytes = sizeBytes; |
| 38 | if (sizeBytes < DATA_SYNC_SIZE) { |
| 39 | cmd->data = (void *)(cmd+1); |
| 40 | memcpy(cmd+1, data, sizeBytes); |
| 41 | io->mToCore.commit(RS_CMD_ID_Allocation1DSubData, size); |
| 42 | } else { |
| 43 | io->mToCore.commitSync(RS_CMD_ID_Allocation1DSubData, size); |
| 44 | } |
| 45 | |
| 46 | } |
| 47 | |