rsdAllocation.h revision b322033c13487a174bb9c26466e9684d1ff4de8d
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 26class RsdFrameBufferObj; 27struct ANativeWindowBuffer; 28 29struct DrvAllocation { 30 // Is this a legal structure to be used as a texture source. 31 // Initially this will require 1D or 2D and color data 32 uint32_t textureID; 33 34 // Is this a legal structure to be used as a vertex source. 35 // Initially this will require 1D and x(yzw). Additional per element data 36 // is allowed. 37 uint32_t bufferID; 38 39 // Is this a legal structure to be used as an FBO render target 40 uint32_t renderTargetID; 41 42 uint8_t * mallocPtr; 43 uint32_t width; 44 uint32_t height; 45 46 GLenum glTarget; 47 GLenum glType; 48 GLenum glFormat; 49 50 bool uploadDeferred; 51 52 RsdFrameBufferObj * readBackFBO; 53 ANativeWindow *wnd; 54 ANativeWindowBuffer *wndBuffer; 55}; 56 57GLenum rsdTypeToGLType(RsDataType t); 58GLenum rsdKindToGLFormat(RsDataKind k); 59 60 61bool rsdAllocationInit(const android::renderscript::Context *rsc, 62 android::renderscript::Allocation *alloc, 63 bool forceZero); 64void rsdAllocationDestroy(const android::renderscript::Context *rsc, 65 android::renderscript::Allocation *alloc); 66 67void rsdAllocationResize(const android::renderscript::Context *rsc, 68 const android::renderscript::Allocation *alloc, 69 const android::renderscript::Type *newType, bool zeroNew); 70void rsdAllocationSyncAll(const android::renderscript::Context *rsc, 71 const android::renderscript::Allocation *alloc, 72 RsAllocationUsageType src); 73void rsdAllocationMarkDirty(const android::renderscript::Context *rsc, 74 const android::renderscript::Allocation *alloc); 75int32_t rsdAllocationInitSurfaceTexture(const android::renderscript::Context *rsc, 76 const android::renderscript::Allocation *alloc); 77void rsdAllocationSetSurfaceTexture(const android::renderscript::Context *rsc, 78 android::renderscript::Allocation *alloc, ANativeWindow *nw); 79void rsdAllocationIoSend(const android::renderscript::Context *rsc, 80 android::renderscript::Allocation *alloc); 81void rsdAllocationIoReceive(const android::renderscript::Context *rsc, 82 android::renderscript::Allocation *alloc); 83 84void rsdAllocationData1D(const android::renderscript::Context *rsc, 85 const android::renderscript::Allocation *alloc, 86 uint32_t xoff, uint32_t lod, uint32_t count, 87 const void *data, uint32_t sizeBytes); 88void rsdAllocationData2D(const android::renderscript::Context *rsc, 89 const android::renderscript::Allocation *alloc, 90 uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face, 91 uint32_t w, uint32_t h, 92 const void *data, uint32_t sizeBytes); 93void rsdAllocationData3D(const android::renderscript::Context *rsc, 94 const android::renderscript::Allocation *alloc, 95 uint32_t xoff, uint32_t yoff, uint32_t zoff, 96 uint32_t lod, RsAllocationCubemapFace face, 97 uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes); 98 99void rsdAllocationData1D_alloc(const android::renderscript::Context *rsc, 100 const android::renderscript::Allocation *dstAlloc, 101 uint32_t dstXoff, uint32_t dstLod, uint32_t count, 102 const android::renderscript::Allocation *srcAlloc, 103 uint32_t srcXoff, uint32_t srcLod); 104void rsdAllocationData2D_alloc(const android::renderscript::Context *rsc, 105 const android::renderscript::Allocation *dstAlloc, 106 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod, 107 RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h, 108 const android::renderscript::Allocation *srcAlloc, 109 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod, 110 RsAllocationCubemapFace srcFace); 111void rsdAllocationData3D_alloc(const android::renderscript::Context *rsc, 112 const android::renderscript::Allocation *dstAlloc, 113 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff, 114 uint32_t dstLod, RsAllocationCubemapFace dstFace, 115 uint32_t w, uint32_t h, uint32_t d, 116 const android::renderscript::Allocation *srcAlloc, 117 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff, 118 uint32_t srcLod, RsAllocationCubemapFace srcFace); 119 120void rsdAllocationElementData1D(const android::renderscript::Context *rsc, 121 const android::renderscript::Allocation *alloc, 122 uint32_t x, 123 const void *data, uint32_t elementOff, uint32_t sizeBytes); 124void rsdAllocationElementData2D(const android::renderscript::Context *rsc, 125 const android::renderscript::Allocation *alloc, 126 uint32_t x, uint32_t y, 127 const void *data, uint32_t elementOff, uint32_t sizeBytes); 128 129 130 131 132#endif 133