Home | History | Annotate | Download | only in driver
      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 
     26 class RsdFrameBufferObj;
     27 struct ANativeWindowBuffer;
     28 
     29 struct 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     uint32_t width;
     43     uint32_t height;
     44 
     45     GLenum glTarget;
     46     GLenum glType;
     47     GLenum glFormat;
     48 
     49     bool uploadDeferred;
     50 
     51     RsdFrameBufferObj * readBackFBO;
     52     ANativeWindow *wnd;
     53     ANativeWindowBuffer *wndBuffer;
     54 };
     55 
     56 GLenum rsdTypeToGLType(RsDataType t);
     57 GLenum rsdKindToGLFormat(RsDataKind k);
     58 
     59 
     60 bool rsdAllocationInit(const android::renderscript::Context *rsc,
     61                        android::renderscript::Allocation *alloc,
     62                        bool forceZero);
     63 void rsdAllocationDestroy(const android::renderscript::Context *rsc,
     64                           android::renderscript::Allocation *alloc);
     65 
     66 void rsdAllocationResize(const android::renderscript::Context *rsc,
     67                          const android::renderscript::Allocation *alloc,
     68                          const android::renderscript::Type *newType, bool zeroNew);
     69 void rsdAllocationSyncAll(const android::renderscript::Context *rsc,
     70                           const android::renderscript::Allocation *alloc,
     71                           RsAllocationUsageType src);
     72 void rsdAllocationMarkDirty(const android::renderscript::Context *rsc,
     73                             const android::renderscript::Allocation *alloc);
     74 int32_t rsdAllocationInitSurfaceTexture(const android::renderscript::Context *rsc,
     75                                         const android::renderscript::Allocation *alloc);
     76 void rsdAllocationSetSurfaceTexture(const android::renderscript::Context *rsc,
     77                                     android::renderscript::Allocation *alloc, ANativeWindow *nw);
     78 void rsdAllocationIoSend(const android::renderscript::Context *rsc,
     79                          android::renderscript::Allocation *alloc);
     80 void rsdAllocationIoReceive(const android::renderscript::Context *rsc,
     81                             android::renderscript::Allocation *alloc);
     82 
     83 void rsdAllocationData1D(const android::renderscript::Context *rsc,
     84                          const android::renderscript::Allocation *alloc,
     85                          uint32_t xoff, uint32_t lod, uint32_t count,
     86                          const void *data, uint32_t sizeBytes);
     87 void rsdAllocationData2D(const android::renderscript::Context *rsc,
     88                          const android::renderscript::Allocation *alloc,
     89                          uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
     90                          uint32_t w, uint32_t h,
     91                          const void *data, uint32_t sizeBytes);
     92 void rsdAllocationData3D(const android::renderscript::Context *rsc,
     93                          const android::renderscript::Allocation *alloc,
     94                          uint32_t xoff, uint32_t yoff, uint32_t zoff,
     95                          uint32_t lod, RsAllocationCubemapFace face,
     96                          uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes);
     97 
     98 void rsdAllocationData1D_alloc(const android::renderscript::Context *rsc,
     99                                const android::renderscript::Allocation *dstAlloc,
    100                                uint32_t dstXoff, uint32_t dstLod, uint32_t count,
    101                                const android::renderscript::Allocation *srcAlloc,
    102                                uint32_t srcXoff, uint32_t srcLod);
    103 void rsdAllocationData2D_alloc(const android::renderscript::Context *rsc,
    104                                const android::renderscript::Allocation *dstAlloc,
    105                                uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod,
    106                                RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h,
    107                                const android::renderscript::Allocation *srcAlloc,
    108                                uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod,
    109                                RsAllocationCubemapFace srcFace);
    110 void rsdAllocationData3D_alloc(const android::renderscript::Context *rsc,
    111                                const android::renderscript::Allocation *dstAlloc,
    112                                uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff,
    113                                uint32_t dstLod, RsAllocationCubemapFace dstFace,
    114                                uint32_t w, uint32_t h, uint32_t d,
    115                                const android::renderscript::Allocation *srcAlloc,
    116                                uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff,
    117                                uint32_t srcLod, RsAllocationCubemapFace srcFace);
    118 
    119 void rsdAllocationElementData1D(const android::renderscript::Context *rsc,
    120                                 const android::renderscript::Allocation *alloc,
    121                                 uint32_t x,
    122                                 const void *data, uint32_t elementOff, uint32_t sizeBytes);
    123 void rsdAllocationElementData2D(const android::renderscript::Context *rsc,
    124                                 const android::renderscript::Allocation *alloc,
    125                                 uint32_t x, uint32_t y,
    126                                 const void *data, uint32_t elementOff, uint32_t sizeBytes);
    127 
    128 
    129 
    130 
    131 #endif
    132