rsdAllocation.h revision 74a827988567a9d65954bb0d825a3ba4a97e2947
1eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams/* 2eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams * Copyright (C) 2011 The Android Open Source Project 3eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams * 4eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams * Licensed under the Apache License, Version 2.0 (the "License"); 5eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams * you may not use this file except in compliance with the License. 6eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams * You may obtain a copy of the License at 7eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams * 8eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams * http://www.apache.org/licenses/LICENSE-2.0 9eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams * 10eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams * Unless required by applicable law or agreed to in writing, software 11eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams * distributed under the License is distributed on an "AS IS" BASIS, 12eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams * See the License for the specific language governing permissions and 14eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams * limitations under the License. 15eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams */ 16eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams 17eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams#ifndef RSD_ALLOCATION_H 18eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams#define RSD_ALLOCATION_H 19eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams 20eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams#include <rs_hal.h> 21eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams#include <rsRuntime.h> 22eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams 23eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams#include <GLES/gl.h> 24eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams#include <GLES2/gl2.h> 25eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams 26eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Samsstruct DrvAllocation { 27eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams // Is this a legal structure to be used as a texture source. 28eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams // Initially this will require 1D or 2D and color data 29eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams uint32_t textureID; 30eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams 31eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams // Is this a legal structure to be used as a vertex source. 32eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams // Initially this will require 1D and x(yzw). Additional per element data 33eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams // is allowed. 34eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams uint32_t bufferID; 35eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams 36eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams // Is this a legal structure to be used as an FBO render target 37eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams uint32_t renderTargetID; 38eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams 39eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams uint8_t * mallocPtr; 40eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams 41eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams GLenum glTarget; 42a614ae175bbf97201b5e18984d814a1d3e86faa8Jason Sams GLenum glType; 43a614ae175bbf97201b5e18984d814a1d3e86faa8Jason Sams GLenum glFormat; 44a614ae175bbf97201b5e18984d814a1d3e86faa8Jason Sams 45eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams 46eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams bool uploadDeferred; 47eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams}; 48eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams 49a614ae175bbf97201b5e18984d814a1d3e86faa8Jason SamsGLenum rsdTypeToGLType(RsDataType t); 50a614ae175bbf97201b5e18984d814a1d3e86faa8Jason SamsGLenum rsdKindToGLFormat(RsDataKind k); 51a614ae175bbf97201b5e18984d814a1d3e86faa8Jason Sams 52a614ae175bbf97201b5e18984d814a1d3e86faa8Jason Sams 53eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Samsbool rsdAllocationInit(const android::renderscript::Context *rsc, 54eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams android::renderscript::Allocation *alloc, 55eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams bool forceZero); 56eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Samsvoid rsdAllocationDestroy(const android::renderscript::Context *rsc, 57eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams android::renderscript::Allocation *alloc); 58eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams 59eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Samsvoid rsdAllocationResize(const android::renderscript::Context *rsc, 60eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams const android::renderscript::Allocation *alloc, 61eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams const android::renderscript::Type *newType, bool zeroNew); 62eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Samsvoid rsdAllocationSyncAll(const android::renderscript::Context *rsc, 63eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams const android::renderscript::Allocation *alloc, 64eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams RsAllocationUsageType src); 65eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Samsvoid rsdAllocationMarkDirty(const android::renderscript::Context *rsc, 66eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams const android::renderscript::Allocation *alloc); 67eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams 68eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Samsvoid rsdAllocationData1D(const android::renderscript::Context *rsc, 69eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams const android::renderscript::Allocation *alloc, 70eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams uint32_t xoff, uint32_t lod, uint32_t count, 71eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams const void *data, uint32_t sizeBytes); 72eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Samsvoid rsdAllocationData2D(const android::renderscript::Context *rsc, 73eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams const android::renderscript::Allocation *alloc, 74eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face, 75eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams uint32_t w, uint32_t h, 76eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams const void *data, uint32_t sizeBytes); 77eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Samsvoid rsdAllocationData3D(const android::renderscript::Context *rsc, 78eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams const android::renderscript::Allocation *alloc, 79eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams uint32_t xoff, uint32_t yoff, uint32_t zoff, 80eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams uint32_t lod, RsAllocationCubemapFace face, 81eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes); 82eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams 8374a827988567a9d65954bb0d825a3ba4a97e2947Alex Sakhartchoukvoid rsdAllocationData1D_alloc(const android::renderscript::Context *rsc, 8474a827988567a9d65954bb0d825a3ba4a97e2947Alex Sakhartchouk const android::renderscript::Allocation *dstAlloc, 8574a827988567a9d65954bb0d825a3ba4a97e2947Alex Sakhartchouk uint32_t dstXoff, uint32_t dstLod, uint32_t count, 8674a827988567a9d65954bb0d825a3ba4a97e2947Alex Sakhartchouk const android::renderscript::Allocation *srcAlloc, 8774a827988567a9d65954bb0d825a3ba4a97e2947Alex Sakhartchouk uint32_t srcXoff, uint32_t srcLod); 8874a827988567a9d65954bb0d825a3ba4a97e2947Alex Sakhartchoukvoid rsdAllocationData2D_alloc(const android::renderscript::Context *rsc, 8974a827988567a9d65954bb0d825a3ba4a97e2947Alex Sakhartchouk const android::renderscript::Allocation *dstAlloc, 9074a827988567a9d65954bb0d825a3ba4a97e2947Alex Sakhartchouk uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod, 9174a827988567a9d65954bb0d825a3ba4a97e2947Alex Sakhartchouk RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h, 9274a827988567a9d65954bb0d825a3ba4a97e2947Alex Sakhartchouk const android::renderscript::Allocation *srcAlloc, 9374a827988567a9d65954bb0d825a3ba4a97e2947Alex Sakhartchouk uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod, 9474a827988567a9d65954bb0d825a3ba4a97e2947Alex Sakhartchouk RsAllocationCubemapFace srcFace); 9574a827988567a9d65954bb0d825a3ba4a97e2947Alex Sakhartchoukvoid rsdAllocationData3D_alloc(const android::renderscript::Context *rsc, 9674a827988567a9d65954bb0d825a3ba4a97e2947Alex Sakhartchouk const android::renderscript::Allocation *dstAlloc, 9774a827988567a9d65954bb0d825a3ba4a97e2947Alex Sakhartchouk uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff, 9874a827988567a9d65954bb0d825a3ba4a97e2947Alex Sakhartchouk uint32_t dstLod, RsAllocationCubemapFace dstFace, 9974a827988567a9d65954bb0d825a3ba4a97e2947Alex Sakhartchouk uint32_t w, uint32_t h, uint32_t d, 10074a827988567a9d65954bb0d825a3ba4a97e2947Alex Sakhartchouk const android::renderscript::Allocation *srcAlloc, 10174a827988567a9d65954bb0d825a3ba4a97e2947Alex Sakhartchouk uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff, 10274a827988567a9d65954bb0d825a3ba4a97e2947Alex Sakhartchouk uint32_t srcLod, RsAllocationCubemapFace srcFace); 10374a827988567a9d65954bb0d825a3ba4a97e2947Alex Sakhartchouk 104eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Samsvoid rsdAllocationElementData1D(const android::renderscript::Context *rsc, 105eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams const android::renderscript::Allocation *alloc, 106eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams uint32_t x, 107eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams const void *data, uint32_t elementOff, uint32_t sizeBytes); 108eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Samsvoid rsdAllocationElementData2D(const android::renderscript::Context *rsc, 109eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams const android::renderscript::Allocation *alloc, 110eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams uint32_t x, uint32_t y, 111eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams const void *data, uint32_t elementOff, uint32_t sizeBytes); 112eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams 113eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams 114eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams 115eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams 116eb4fe18dd88634330f9566cbb9e785d8c7ec5813Jason Sams#endif 117