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