rsdAllocation.h revision c2cfe6abfc74befbaa4d2ca09024a27fbfb1f515
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#include <rsAllocation.h> 23 24#include "../cpu_ref/rsd_cpu.h" 25 26#include <GLES/gl.h> 27#include <GLES2/gl2.h> 28 29class RsdFrameBufferObj; 30struct ANativeWindowBuffer; 31 32struct DrvAllocation { 33 // Is this a legal structure to be used as a texture source. 34 // Initially this will require 1D or 2D and color data 35 uint32_t textureID; 36 37 // Is this a legal structure to be used as a vertex source. 38 // Initially this will require 1D and x(yzw). Additional per element data 39 // is allowed. 40 uint32_t bufferID; 41 42 // Is this a legal structure to be used as an FBO render target 43 uint32_t renderTargetID; 44 45#ifndef RS_COMPATIBILITY_LIB 46 GLenum glTarget; 47 GLenum glType; 48 GLenum glFormat; 49#else 50 int glTarget; 51 int glType; 52 int glFormat; 53#endif 54 55 bool useUserProvidedPtr; 56 bool uploadDeferred; 57 58 RsdFrameBufferObj * readBackFBO; 59 ANativeWindow *wnd; 60 ANativeWindowBuffer *wndBuffer; 61}; 62 63#ifndef RS_COMPATIBILITY_LIB 64GLenum rsdTypeToGLType(RsDataType t); 65GLenum rsdKindToGLFormat(RsDataKind k); 66#endif 67 68 69bool rsdAllocationInit(const android::renderscript::Context *rsc, 70 android::renderscript::Allocation *alloc, 71 bool forceZero); 72void rsdAllocationDestroy(const android::renderscript::Context *rsc, 73 android::renderscript::Allocation *alloc); 74 75void rsdAllocationResize(const android::renderscript::Context *rsc, 76 const android::renderscript::Allocation *alloc, 77 const android::renderscript::Type *newType, bool zeroNew); 78void rsdAllocationSyncAll(const android::renderscript::Context *rsc, 79 const android::renderscript::Allocation *alloc, 80 RsAllocationUsageType src); 81void rsdAllocationMarkDirty(const android::renderscript::Context *rsc, 82 const android::renderscript::Allocation *alloc); 83int32_t rsdAllocationInitSurfaceTexture(const android::renderscript::Context *rsc, 84 const android::renderscript::Allocation *alloc); 85void rsdAllocationSetSurfaceTexture(const android::renderscript::Context *rsc, 86 android::renderscript::Allocation *alloc, ANativeWindow *nw); 87void rsdAllocationIoSend(const android::renderscript::Context *rsc, 88 android::renderscript::Allocation *alloc); 89void rsdAllocationIoReceive(const android::renderscript::Context *rsc, 90 android::renderscript::Allocation *alloc); 91 92void rsdAllocationData1D(const android::renderscript::Context *rsc, 93 const android::renderscript::Allocation *alloc, 94 uint32_t xoff, uint32_t lod, uint32_t count, 95 const void *data, uint32_t sizeBytes); 96void rsdAllocationData2D(const android::renderscript::Context *rsc, 97 const android::renderscript::Allocation *alloc, 98 uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face, 99 uint32_t w, uint32_t h, 100 const void *data, uint32_t sizeBytes, size_t stride); 101void rsdAllocationData3D(const android::renderscript::Context *rsc, 102 const android::renderscript::Allocation *alloc, 103 uint32_t xoff, uint32_t yoff, uint32_t zoff, 104 uint32_t lod, RsAllocationCubemapFace face, 105 uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes); 106 107void rsdAllocationRead1D(const android::renderscript::Context *rsc, 108 const android::renderscript::Allocation *alloc, 109 uint32_t xoff, uint32_t lod, uint32_t count, 110 void *data, uint32_t sizeBytes); 111void rsdAllocationRead2D(const android::renderscript::Context *rsc, 112 const android::renderscript::Allocation *alloc, 113 uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face, 114 uint32_t w, uint32_t h, 115 void *data, uint32_t sizeBytes, size_t stride); 116void rsdAllocationRead3D(const android::renderscript::Context *rsc, 117 const android::renderscript::Allocation *alloc, 118 uint32_t xoff, uint32_t yoff, uint32_t zoff, 119 uint32_t lod, RsAllocationCubemapFace face, 120 uint32_t w, uint32_t h, uint32_t d, void *data, uint32_t sizeBytes); 121 122void * rsdAllocationLock1D(const android::renderscript::Context *rsc, 123 const android::renderscript::Allocation *alloc); 124void rsdAllocationUnlock1D(const android::renderscript::Context *rsc, 125 const android::renderscript::Allocation *alloc); 126 127 128void rsdAllocationData1D_alloc(const android::renderscript::Context *rsc, 129 const android::renderscript::Allocation *dstAlloc, 130 uint32_t dstXoff, uint32_t dstLod, uint32_t count, 131 const android::renderscript::Allocation *srcAlloc, 132 uint32_t srcXoff, uint32_t srcLod); 133void rsdAllocationData2D_alloc(const android::renderscript::Context *rsc, 134 const android::renderscript::Allocation *dstAlloc, 135 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod, 136 RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h, 137 const android::renderscript::Allocation *srcAlloc, 138 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod, 139 RsAllocationCubemapFace srcFace); 140void rsdAllocationData3D_alloc(const android::renderscript::Context *rsc, 141 const android::renderscript::Allocation *dstAlloc, 142 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff, 143 uint32_t dstLod, RsAllocationCubemapFace dstFace, 144 uint32_t w, uint32_t h, uint32_t d, 145 const android::renderscript::Allocation *srcAlloc, 146 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff, 147 uint32_t srcLod, RsAllocationCubemapFace srcFace); 148 149void rsdAllocationElementData1D(const android::renderscript::Context *rsc, 150 const android::renderscript::Allocation *alloc, 151 uint32_t x, 152 const void *data, uint32_t elementOff, uint32_t sizeBytes); 153void rsdAllocationElementData2D(const android::renderscript::Context *rsc, 154 const android::renderscript::Allocation *alloc, 155 uint32_t x, uint32_t y, 156 const void *data, uint32_t elementOff, uint32_t sizeBytes); 157 158void rsdAllocationGenerateMipmaps(const android::renderscript::Context *rsc, 159 const android::renderscript::Allocation *alloc); 160 161 162 163#endif 164