rsdAllocation.h revision 807fdc4b6f3fb893015ee136565d6151bb2332d3
105436638acc7c010349a69c3395f1a57c642dc62Ying Wang/* 205436638acc7c010349a69c3395f1a57c642dc62Ying Wang * Copyright (C) 2011 The Android Open Source Project 305436638acc7c010349a69c3395f1a57c642dc62Ying Wang * 405436638acc7c010349a69c3395f1a57c642dc62Ying Wang * Licensed under the Apache License, Version 2.0 (the "License"); 505436638acc7c010349a69c3395f1a57c642dc62Ying Wang * you may not use this file except in compliance with the License. 605436638acc7c010349a69c3395f1a57c642dc62Ying Wang * You may obtain a copy of the License at 705436638acc7c010349a69c3395f1a57c642dc62Ying Wang * 805436638acc7c010349a69c3395f1a57c642dc62Ying Wang * http://www.apache.org/licenses/LICENSE-2.0 905436638acc7c010349a69c3395f1a57c642dc62Ying Wang * 1005436638acc7c010349a69c3395f1a57c642dc62Ying Wang * Unless required by applicable law or agreed to in writing, software 1105436638acc7c010349a69c3395f1a57c642dc62Ying Wang * distributed under the License is distributed on an "AS IS" BASIS, 1205436638acc7c010349a69c3395f1a57c642dc62Ying Wang * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1305436638acc7c010349a69c3395f1a57c642dc62Ying Wang * See the License for the specific language governing permissions and 1405436638acc7c010349a69c3395f1a57c642dc62Ying Wang * limitations under the License. 1505436638acc7c010349a69c3395f1a57c642dc62Ying Wang */ 1605436638acc7c010349a69c3395f1a57c642dc62Ying Wang 1705436638acc7c010349a69c3395f1a57c642dc62Ying Wang#ifndef RSD_ALLOCATION_H 1805436638acc7c010349a69c3395f1a57c642dc62Ying Wang#define RSD_ALLOCATION_H 1905436638acc7c010349a69c3395f1a57c642dc62Ying Wang 2005436638acc7c010349a69c3395f1a57c642dc62Ying Wang#include <rs_hal.h> 2105436638acc7c010349a69c3395f1a57c642dc62Ying Wang#include <rsRuntime.h> 2205436638acc7c010349a69c3395f1a57c642dc62Ying Wang#include <rsAllocation.h> 2305436638acc7c010349a69c3395f1a57c642dc62Ying Wang 2405436638acc7c010349a69c3395f1a57c642dc62Ying Wang#include <GLES/gl.h> 2505436638acc7c010349a69c3395f1a57c642dc62Ying Wang#include <GLES2/gl2.h> 2605436638acc7c010349a69c3395f1a57c642dc62Ying Wang 2705436638acc7c010349a69c3395f1a57c642dc62Ying Wangclass RsdFrameBufferObj; 2805436638acc7c010349a69c3395f1a57c642dc62Ying Wangstruct ANativeWindowBuffer; 2905436638acc7c010349a69c3395f1a57c642dc62Ying Wang 3005436638acc7c010349a69c3395f1a57c642dc62Ying Wangstruct DrvAllocation { 3105436638acc7c010349a69c3395f1a57c642dc62Ying Wang // Is this a legal structure to be used as a texture source. 3205436638acc7c010349a69c3395f1a57c642dc62Ying Wang // Initially this will require 1D or 2D and color data 3305436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t textureID; 3405436638acc7c010349a69c3395f1a57c642dc62Ying Wang 3505436638acc7c010349a69c3395f1a57c642dc62Ying Wang // Is this a legal structure to be used as a vertex source. 3605436638acc7c010349a69c3395f1a57c642dc62Ying Wang // Initially this will require 1D and x(yzw). Additional per element data 3705436638acc7c010349a69c3395f1a57c642dc62Ying Wang // is allowed. 3805436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t bufferID; 3905436638acc7c010349a69c3395f1a57c642dc62Ying Wang 4005436638acc7c010349a69c3395f1a57c642dc62Ying Wang // Is this a legal structure to be used as an FBO render target 4105436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t renderTargetID; 4205436638acc7c010349a69c3395f1a57c642dc62Ying Wang 4305436638acc7c010349a69c3395f1a57c642dc62Ying Wang GLenum glTarget; 4405436638acc7c010349a69c3395f1a57c642dc62Ying Wang GLenum glType; 4505436638acc7c010349a69c3395f1a57c642dc62Ying Wang GLenum glFormat; 4605436638acc7c010349a69c3395f1a57c642dc62Ying Wang 4705436638acc7c010349a69c3395f1a57c642dc62Ying Wang bool uploadDeferred; 4805436638acc7c010349a69c3395f1a57c642dc62Ying Wang 4905436638acc7c010349a69c3395f1a57c642dc62Ying Wang RsdFrameBufferObj * readBackFBO; 5005436638acc7c010349a69c3395f1a57c642dc62Ying Wang ANativeWindow *wnd; 5105436638acc7c010349a69c3395f1a57c642dc62Ying Wang ANativeWindowBuffer *wndBuffer; 5205436638acc7c010349a69c3395f1a57c642dc62Ying Wang 5305436638acc7c010349a69c3395f1a57c642dc62Ying Wang struct LodState { 5405436638acc7c010349a69c3395f1a57c642dc62Ying Wang void * mallocPtr; 5505436638acc7c010349a69c3395f1a57c642dc62Ying Wang size_t stride; 5605436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t dimX; 5705436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t dimY; 5805436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t dimZ; 5905436638acc7c010349a69c3395f1a57c642dc62Ying Wang } lod[android::renderscript::Allocation::MAX_LOD]; 6005436638acc7c010349a69c3395f1a57c642dc62Ying Wang size_t faceOffset; 6105436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t lodCount; 6205436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t faceCount; 6305436638acc7c010349a69c3395f1a57c642dc62Ying Wang 6405436638acc7c010349a69c3395f1a57c642dc62Ying Wang 6505436638acc7c010349a69c3395f1a57c642dc62Ying Wang}; 6605436638acc7c010349a69c3395f1a57c642dc62Ying Wang 6705436638acc7c010349a69c3395f1a57c642dc62Ying WangGLenum rsdTypeToGLType(RsDataType t); 6805436638acc7c010349a69c3395f1a57c642dc62Ying WangGLenum rsdKindToGLFormat(RsDataKind k); 6905436638acc7c010349a69c3395f1a57c642dc62Ying Wang 7005436638acc7c010349a69c3395f1a57c642dc62Ying Wang 7105436638acc7c010349a69c3395f1a57c642dc62Ying Wangbool rsdAllocationInit(const android::renderscript::Context *rsc, 7205436638acc7c010349a69c3395f1a57c642dc62Ying Wang android::renderscript::Allocation *alloc, 7305436638acc7c010349a69c3395f1a57c642dc62Ying Wang bool forceZero); 7405436638acc7c010349a69c3395f1a57c642dc62Ying Wangvoid rsdAllocationDestroy(const android::renderscript::Context *rsc, 7505436638acc7c010349a69c3395f1a57c642dc62Ying Wang android::renderscript::Allocation *alloc); 7605436638acc7c010349a69c3395f1a57c642dc62Ying Wang 7705436638acc7c010349a69c3395f1a57c642dc62Ying Wangvoid rsdAllocationResize(const android::renderscript::Context *rsc, 7805436638acc7c010349a69c3395f1a57c642dc62Ying Wang const android::renderscript::Allocation *alloc, 7905436638acc7c010349a69c3395f1a57c642dc62Ying Wang const android::renderscript::Type *newType, bool zeroNew); 8005436638acc7c010349a69c3395f1a57c642dc62Ying Wangvoid rsdAllocationSyncAll(const android::renderscript::Context *rsc, 8105436638acc7c010349a69c3395f1a57c642dc62Ying Wang const android::renderscript::Allocation *alloc, 8205436638acc7c010349a69c3395f1a57c642dc62Ying Wang RsAllocationUsageType src); 8305436638acc7c010349a69c3395f1a57c642dc62Ying Wangvoid rsdAllocationMarkDirty(const android::renderscript::Context *rsc, 8405436638acc7c010349a69c3395f1a57c642dc62Ying Wang const android::renderscript::Allocation *alloc); 8505436638acc7c010349a69c3395f1a57c642dc62Ying Wangint32_t rsdAllocationInitSurfaceTexture(const android::renderscript::Context *rsc, 8605436638acc7c010349a69c3395f1a57c642dc62Ying Wang const android::renderscript::Allocation *alloc); 8705436638acc7c010349a69c3395f1a57c642dc62Ying Wangvoid rsdAllocationSetSurfaceTexture(const android::renderscript::Context *rsc, 8805436638acc7c010349a69c3395f1a57c642dc62Ying Wang android::renderscript::Allocation *alloc, ANativeWindow *nw); 8905436638acc7c010349a69c3395f1a57c642dc62Ying Wangvoid rsdAllocationIoSend(const android::renderscript::Context *rsc, 9005436638acc7c010349a69c3395f1a57c642dc62Ying Wang android::renderscript::Allocation *alloc); 9105436638acc7c010349a69c3395f1a57c642dc62Ying Wangvoid rsdAllocationIoReceive(const android::renderscript::Context *rsc, 9205436638acc7c010349a69c3395f1a57c642dc62Ying Wang android::renderscript::Allocation *alloc); 9305436638acc7c010349a69c3395f1a57c642dc62Ying Wang 9405436638acc7c010349a69c3395f1a57c642dc62Ying Wangvoid rsdAllocationData1D(const android::renderscript::Context *rsc, 9505436638acc7c010349a69c3395f1a57c642dc62Ying Wang const android::renderscript::Allocation *alloc, 9605436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t xoff, uint32_t lod, uint32_t count, 9705436638acc7c010349a69c3395f1a57c642dc62Ying Wang const void *data, uint32_t sizeBytes); 9805436638acc7c010349a69c3395f1a57c642dc62Ying Wangvoid rsdAllocationData2D(const android::renderscript::Context *rsc, 9905436638acc7c010349a69c3395f1a57c642dc62Ying Wang const android::renderscript::Allocation *alloc, 10005436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face, 10105436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t w, uint32_t h, 10205436638acc7c010349a69c3395f1a57c642dc62Ying Wang const void *data, uint32_t sizeBytes); 10305436638acc7c010349a69c3395f1a57c642dc62Ying Wangvoid rsdAllocationData3D(const android::renderscript::Context *rsc, 10405436638acc7c010349a69c3395f1a57c642dc62Ying Wang const android::renderscript::Allocation *alloc, 10505436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t xoff, uint32_t yoff, uint32_t zoff, 10605436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t lod, RsAllocationCubemapFace face, 10705436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes); 10805436638acc7c010349a69c3395f1a57c642dc62Ying Wang 10905436638acc7c010349a69c3395f1a57c642dc62Ying Wangvoid rsdAllocationRead1D(const android::renderscript::Context *rsc, 11005436638acc7c010349a69c3395f1a57c642dc62Ying Wang const android::renderscript::Allocation *alloc, 11105436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t xoff, uint32_t lod, uint32_t count, 11205436638acc7c010349a69c3395f1a57c642dc62Ying Wang void *data, uint32_t sizeBytes); 11305436638acc7c010349a69c3395f1a57c642dc62Ying Wangvoid rsdAllocationRead2D(const android::renderscript::Context *rsc, 11405436638acc7c010349a69c3395f1a57c642dc62Ying Wang const android::renderscript::Allocation *alloc, 11505436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face, 11605436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t w, uint32_t h, 11705436638acc7c010349a69c3395f1a57c642dc62Ying Wang void *data, uint32_t sizeBytes); 11805436638acc7c010349a69c3395f1a57c642dc62Ying Wangvoid rsdAllocationRead3D(const android::renderscript::Context *rsc, 11905436638acc7c010349a69c3395f1a57c642dc62Ying Wang const android::renderscript::Allocation *alloc, 12005436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t xoff, uint32_t yoff, uint32_t zoff, 12105436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t lod, RsAllocationCubemapFace face, 12205436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t w, uint32_t h, uint32_t d, void *data, uint32_t sizeBytes); 12305436638acc7c010349a69c3395f1a57c642dc62Ying Wang 12405436638acc7c010349a69c3395f1a57c642dc62Ying Wangvoid * rsdAllocationLock1D(const android::renderscript::Context *rsc, 12505436638acc7c010349a69c3395f1a57c642dc62Ying Wang const android::renderscript::Allocation *alloc); 12605436638acc7c010349a69c3395f1a57c642dc62Ying Wangvoid rsdAllocationUnlock1D(const android::renderscript::Context *rsc, 12705436638acc7c010349a69c3395f1a57c642dc62Ying Wang const android::renderscript::Allocation *alloc); 12805436638acc7c010349a69c3395f1a57c642dc62Ying Wang 12905436638acc7c010349a69c3395f1a57c642dc62Ying Wang 13005436638acc7c010349a69c3395f1a57c642dc62Ying Wangvoid rsdAllocationData1D_alloc(const android::renderscript::Context *rsc, 13105436638acc7c010349a69c3395f1a57c642dc62Ying Wang const android::renderscript::Allocation *dstAlloc, 13205436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t dstXoff, uint32_t dstLod, uint32_t count, 13305436638acc7c010349a69c3395f1a57c642dc62Ying Wang const android::renderscript::Allocation *srcAlloc, 13405436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t srcXoff, uint32_t srcLod); 13505436638acc7c010349a69c3395f1a57c642dc62Ying Wangvoid rsdAllocationData2D_alloc(const android::renderscript::Context *rsc, 13605436638acc7c010349a69c3395f1a57c642dc62Ying Wang const android::renderscript::Allocation *dstAlloc, 13705436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod, 13805436638acc7c010349a69c3395f1a57c642dc62Ying Wang RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h, 13905436638acc7c010349a69c3395f1a57c642dc62Ying Wang const android::renderscript::Allocation *srcAlloc, 14005436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod, 14105436638acc7c010349a69c3395f1a57c642dc62Ying Wang RsAllocationCubemapFace srcFace); 14205436638acc7c010349a69c3395f1a57c642dc62Ying Wangvoid rsdAllocationData3D_alloc(const android::renderscript::Context *rsc, 14305436638acc7c010349a69c3395f1a57c642dc62Ying Wang const android::renderscript::Allocation *dstAlloc, 14405436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff, 14505436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t dstLod, RsAllocationCubemapFace dstFace, 14605436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t w, uint32_t h, uint32_t d, 14705436638acc7c010349a69c3395f1a57c642dc62Ying Wang const android::renderscript::Allocation *srcAlloc, 14805436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff, 14905436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t srcLod, RsAllocationCubemapFace srcFace); 15005436638acc7c010349a69c3395f1a57c642dc62Ying Wang 15105436638acc7c010349a69c3395f1a57c642dc62Ying Wangvoid rsdAllocationElementData1D(const android::renderscript::Context *rsc, 15205436638acc7c010349a69c3395f1a57c642dc62Ying Wang const android::renderscript::Allocation *alloc, 15305436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t x, 15405436638acc7c010349a69c3395f1a57c642dc62Ying Wang const void *data, uint32_t elementOff, uint32_t sizeBytes); 15505436638acc7c010349a69c3395f1a57c642dc62Ying Wangvoid rsdAllocationElementData2D(const android::renderscript::Context *rsc, 15605436638acc7c010349a69c3395f1a57c642dc62Ying Wang const android::renderscript::Allocation *alloc, 15705436638acc7c010349a69c3395f1a57c642dc62Ying Wang uint32_t x, uint32_t y, 15805436638acc7c010349a69c3395f1a57c642dc62Ying Wang const void *data, uint32_t elementOff, uint32_t sizeBytes); 15905436638acc7c010349a69c3395f1a57c642dc62Ying Wang 16005436638acc7c010349a69c3395f1a57c642dc62Ying Wang 16105436638acc7c010349a69c3395f1a57c642dc62Ying Wang 16205436638acc7c010349a69c3395f1a57c642dc62Ying Wang 16305436638acc7c010349a69c3395f1a57c642dc62Ying Wang#endif 16405436638acc7c010349a69c3395f1a57c642dc62Ying Wang