rsdAllocation.h revision 93eacc7ce0aad4314b4cb41a281f59ce54bb3286
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 uploadDeferred; 56 57 RsdFrameBufferObj * readBackFBO; 58 ANativeWindow *wnd; 59 ANativeWindowBuffer *wndBuffer; 60}; 61 62#ifndef RS_COMPATIBILITY_LIB 63GLenum rsdTypeToGLType(RsDataType t); 64GLenum rsdKindToGLFormat(RsDataKind k); 65#endif 66 67 68bool rsdAllocationInit(const android::renderscript::Context *rsc, 69 android::renderscript::Allocation *alloc, 70 bool forceZero); 71void rsdAllocationDestroy(const android::renderscript::Context *rsc, 72 android::renderscript::Allocation *alloc); 73 74void rsdAllocationResize(const android::renderscript::Context *rsc, 75 const android::renderscript::Allocation *alloc, 76 const android::renderscript::Type *newType, bool zeroNew); 77void rsdAllocationSyncAll(const android::renderscript::Context *rsc, 78 const android::renderscript::Allocation *alloc, 79 RsAllocationUsageType src); 80void rsdAllocationMarkDirty(const android::renderscript::Context *rsc, 81 const android::renderscript::Allocation *alloc); 82int32_t rsdAllocationInitSurfaceTexture(const android::renderscript::Context *rsc, 83 const android::renderscript::Allocation *alloc); 84void rsdAllocationSetSurfaceTexture(const android::renderscript::Context *rsc, 85 android::renderscript::Allocation *alloc, ANativeWindow *nw); 86void rsdAllocationIoSend(const android::renderscript::Context *rsc, 87 android::renderscript::Allocation *alloc); 88void rsdAllocationIoReceive(const android::renderscript::Context *rsc, 89 android::renderscript::Allocation *alloc); 90 91void rsdAllocationData1D(const android::renderscript::Context *rsc, 92 const android::renderscript::Allocation *alloc, 93 uint32_t xoff, uint32_t lod, uint32_t count, 94 const void *data, uint32_t sizeBytes); 95void rsdAllocationData2D(const android::renderscript::Context *rsc, 96 const android::renderscript::Allocation *alloc, 97 uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face, 98 uint32_t w, uint32_t h, 99 const void *data, uint32_t sizeBytes, size_t stride); 100void rsdAllocationData3D(const android::renderscript::Context *rsc, 101 const android::renderscript::Allocation *alloc, 102 uint32_t xoff, uint32_t yoff, uint32_t zoff, 103 uint32_t lod, RsAllocationCubemapFace face, 104 uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes); 105 106void rsdAllocationRead1D(const android::renderscript::Context *rsc, 107 const android::renderscript::Allocation *alloc, 108 uint32_t xoff, uint32_t lod, uint32_t count, 109 void *data, uint32_t sizeBytes); 110void rsdAllocationRead2D(const android::renderscript::Context *rsc, 111 const android::renderscript::Allocation *alloc, 112 uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face, 113 uint32_t w, uint32_t h, 114 void *data, uint32_t sizeBytes, size_t stride); 115void rsdAllocationRead3D(const android::renderscript::Context *rsc, 116 const android::renderscript::Allocation *alloc, 117 uint32_t xoff, uint32_t yoff, uint32_t zoff, 118 uint32_t lod, RsAllocationCubemapFace face, 119 uint32_t w, uint32_t h, uint32_t d, void *data, uint32_t sizeBytes); 120 121void * rsdAllocationLock1D(const android::renderscript::Context *rsc, 122 const android::renderscript::Allocation *alloc); 123void rsdAllocationUnlock1D(const android::renderscript::Context *rsc, 124 const android::renderscript::Allocation *alloc); 125 126 127void rsdAllocationData1D_alloc(const android::renderscript::Context *rsc, 128 const android::renderscript::Allocation *dstAlloc, 129 uint32_t dstXoff, uint32_t dstLod, uint32_t count, 130 const android::renderscript::Allocation *srcAlloc, 131 uint32_t srcXoff, uint32_t srcLod); 132void rsdAllocationData2D_alloc(const android::renderscript::Context *rsc, 133 const android::renderscript::Allocation *dstAlloc, 134 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod, 135 RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h, 136 const android::renderscript::Allocation *srcAlloc, 137 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod, 138 RsAllocationCubemapFace srcFace); 139void rsdAllocationData3D_alloc(const android::renderscript::Context *rsc, 140 const android::renderscript::Allocation *dstAlloc, 141 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff, 142 uint32_t dstLod, RsAllocationCubemapFace dstFace, 143 uint32_t w, uint32_t h, uint32_t d, 144 const android::renderscript::Allocation *srcAlloc, 145 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff, 146 uint32_t srcLod, RsAllocationCubemapFace srcFace); 147 148void rsdAllocationElementData1D(const android::renderscript::Context *rsc, 149 const android::renderscript::Allocation *alloc, 150 uint32_t x, 151 const void *data, uint32_t elementOff, uint32_t sizeBytes); 152void rsdAllocationElementData2D(const android::renderscript::Context *rsc, 153 const android::renderscript::Allocation *alloc, 154 uint32_t x, uint32_t y, 155 const void *data, uint32_t elementOff, uint32_t sizeBytes); 156 157void rsdAllocationGenerateMipmaps(const android::renderscript::Context *rsc, 158 const android::renderscript::Allocation *alloc); 159 160 161 162#endif 163