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