rsdAllocation.h revision 74a827988567a9d65954bb0d825a3ba4a97e2947
1/* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17#ifndef RSD_ALLOCATION_H 18#define RSD_ALLOCATION_H 19 20#include <rs_hal.h> 21#include <rsRuntime.h> 22 23#include <GLES/gl.h> 24#include <GLES2/gl2.h> 25 26struct DrvAllocation { 27 // Is this a legal structure to be used as a texture source. 28 // Initially this will require 1D or 2D and color data 29 uint32_t textureID; 30 31 // Is this a legal structure to be used as a vertex source. 32 // Initially this will require 1D and x(yzw). Additional per element data 33 // is allowed. 34 uint32_t bufferID; 35 36 // Is this a legal structure to be used as an FBO render target 37 uint32_t renderTargetID; 38 39 uint8_t * mallocPtr; 40 41 GLenum glTarget; 42 GLenum glType; 43 GLenum glFormat; 44 45 46 bool uploadDeferred; 47}; 48 49GLenum rsdTypeToGLType(RsDataType t); 50GLenum rsdKindToGLFormat(RsDataKind k); 51 52 53bool rsdAllocationInit(const android::renderscript::Context *rsc, 54 android::renderscript::Allocation *alloc, 55 bool forceZero); 56void rsdAllocationDestroy(const android::renderscript::Context *rsc, 57 android::renderscript::Allocation *alloc); 58 59void rsdAllocationResize(const android::renderscript::Context *rsc, 60 const android::renderscript::Allocation *alloc, 61 const android::renderscript::Type *newType, bool zeroNew); 62void rsdAllocationSyncAll(const android::renderscript::Context *rsc, 63 const android::renderscript::Allocation *alloc, 64 RsAllocationUsageType src); 65void rsdAllocationMarkDirty(const android::renderscript::Context *rsc, 66 const android::renderscript::Allocation *alloc); 67 68void rsdAllocationData1D(const android::renderscript::Context *rsc, 69 const android::renderscript::Allocation *alloc, 70 uint32_t xoff, uint32_t lod, uint32_t count, 71 const void *data, uint32_t sizeBytes); 72void rsdAllocationData2D(const android::renderscript::Context *rsc, 73 const android::renderscript::Allocation *alloc, 74 uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face, 75 uint32_t w, uint32_t h, 76 const void *data, uint32_t sizeBytes); 77void rsdAllocationData3D(const android::renderscript::Context *rsc, 78 const android::renderscript::Allocation *alloc, 79 uint32_t xoff, uint32_t yoff, uint32_t zoff, 80 uint32_t lod, RsAllocationCubemapFace face, 81 uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes); 82 83void rsdAllocationData1D_alloc(const android::renderscript::Context *rsc, 84 const android::renderscript::Allocation *dstAlloc, 85 uint32_t dstXoff, uint32_t dstLod, uint32_t count, 86 const android::renderscript::Allocation *srcAlloc, 87 uint32_t srcXoff, uint32_t srcLod); 88void rsdAllocationData2D_alloc(const android::renderscript::Context *rsc, 89 const android::renderscript::Allocation *dstAlloc, 90 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod, 91 RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h, 92 const android::renderscript::Allocation *srcAlloc, 93 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod, 94 RsAllocationCubemapFace srcFace); 95void rsdAllocationData3D_alloc(const android::renderscript::Context *rsc, 96 const android::renderscript::Allocation *dstAlloc, 97 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff, 98 uint32_t dstLod, RsAllocationCubemapFace dstFace, 99 uint32_t w, uint32_t h, uint32_t d, 100 const android::renderscript::Allocation *srcAlloc, 101 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff, 102 uint32_t srcLod, RsAllocationCubemapFace srcFace); 103 104void rsdAllocationElementData1D(const android::renderscript::Context *rsc, 105 const android::renderscript::Allocation *alloc, 106 uint32_t x, 107 const void *data, uint32_t elementOff, uint32_t sizeBytes); 108void rsdAllocationElementData2D(const android::renderscript::Context *rsc, 109 const android::renderscript::Allocation *alloc, 110 uint32_t x, uint32_t y, 111 const void *data, uint32_t elementOff, uint32_t sizeBytes); 112 113 114 115 116#endif 117