blob: eff5e3022a39f39665d81ecaa5ca26ad98e07db9 [file] [log] [blame]
Jason Samseb4fe182011-05-26 16:33:01 -07001/*
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>
Jason Sams807fdc42012-07-25 17:55:39 -070022#include <rsAllocation.h>
Jason Samseb4fe182011-05-26 16:33:01 -070023
Jason Sams709a0972012-11-15 18:18:04 -080024#include "../cpu_ref/rsd_cpu.h"
Tim Murray0b575de2013-03-15 15:56:43 -070025
26#ifndef RS_SERVER
Jason Samseb4fe182011-05-26 16:33:01 -070027#include <GLES/gl.h>
28#include <GLES2/gl2.h>
Tim Murray0b575de2013-03-15 15:56:43 -070029#endif
Jason Samseb4fe182011-05-26 16:33:01 -070030
Stephen Hinesb0934b62013-07-03 17:27:38 -070031#if !defined(RS_SERVER) && !defined(RS_COMPATIBILITY_LIB)
Stephen Hinesb0934b62013-07-03 17:27:38 -070032#include "gui/GLConsumer.h"
33#endif
34
Alex Sakhartchouka9495242011-06-16 11:05:13 -070035class RsdFrameBufferObj;
Tim Murray3a25fdd2013-02-22 17:56:56 -080036struct ANativeWindow;
Jason Sams7ac2a4d2012-02-15 12:04:24 -080037struct ANativeWindowBuffer;
Miao Wang2bd78f22014-11-20 10:49:43 -080038struct ANativeWindow_Buffer;
Alex Sakhartchouka9495242011-06-16 11:05:13 -070039
Jason Samseb4fe182011-05-26 16:33:01 -070040struct DrvAllocation {
41 // Is this a legal structure to be used as a texture source.
42 // Initially this will require 1D or 2D and color data
43 uint32_t textureID;
44
45 // Is this a legal structure to be used as a vertex source.
46 // Initially this will require 1D and x(yzw). Additional per element data
47 // is allowed.
48 uint32_t bufferID;
49
50 // Is this a legal structure to be used as an FBO render target
51 uint32_t renderTargetID;
52
Jason Sams93eacc72012-12-18 14:26:57 -080053#ifndef RS_COMPATIBILITY_LIB
Jason Samseb4fe182011-05-26 16:33:01 -070054 GLenum glTarget;
Jason Samsa614ae12011-05-26 17:05:51 -070055 GLenum glType;
56 GLenum glFormat;
Tim Murray3a25fdd2013-02-22 17:56:56 -080057
Miao Wang2bd78f22014-11-20 10:49:43 -080058 ANativeWindowBuffer *wndBuffer;
Tim Murray3a25fdd2013-02-22 17:56:56 -080059 android::GLConsumer *surfaceTexture;
Jason Sams93eacc72012-12-18 14:26:57 -080060#else
61 int glTarget;
62 int glType;
63 int glFormat;
Miao Wang2bd78f22014-11-20 10:49:43 -080064
65 ANativeWindow_Buffer *wndBuffer;
Jason Sams93eacc72012-12-18 14:26:57 -080066#endif
Jason Samsa614ae12011-05-26 17:05:51 -070067
Tim Murrayc2cfe6a2013-02-14 16:21:33 -080068 bool useUserProvidedPtr;
Jason Samseb4fe182011-05-26 16:33:01 -070069 bool uploadDeferred;
Alex Sakhartchouka9495242011-06-16 11:05:13 -070070
71 RsdFrameBufferObj * readBackFBO;
Jason Samsb3220332012-04-02 14:41:54 -070072 ANativeWindow *wnd;
Miao Wang2bd78f22014-11-20 10:49:43 -080073 ANativeWindow *wndSurface;
Jason Samseb4fe182011-05-26 16:33:01 -070074};
75
Jason Sams93eacc72012-12-18 14:26:57 -080076#ifndef RS_COMPATIBILITY_LIB
Jason Samsa614ae12011-05-26 17:05:51 -070077GLenum rsdTypeToGLType(RsDataType t);
78GLenum rsdKindToGLFormat(RsDataKind k);
Jason Sams93eacc72012-12-18 14:26:57 -080079#endif
Jason Samsa614ae12011-05-26 17:05:51 -070080
81
Jason Samsddceab92013-08-07 13:02:32 -070082uint32_t rsdAllocationGrallocBits(const android::renderscript::Context *rsc,
83 android::renderscript::Allocation *alloc);
Jason Samseb4fe182011-05-26 16:33:01 -070084bool rsdAllocationInit(const android::renderscript::Context *rsc,
85 android::renderscript::Allocation *alloc,
86 bool forceZero);
Jason Samsbc9dc272015-02-09 12:50:22 -080087bool rsdAllocationAdapterInit(const android::renderscript::Context *rsc,
88 android::renderscript::Allocation *alloc);
Jason Samseb4fe182011-05-26 16:33:01 -070089void rsdAllocationDestroy(const android::renderscript::Context *rsc,
90 android::renderscript::Allocation *alloc);
91
92void rsdAllocationResize(const android::renderscript::Context *rsc,
93 const android::renderscript::Allocation *alloc,
94 const android::renderscript::Type *newType, bool zeroNew);
95void rsdAllocationSyncAll(const android::renderscript::Context *rsc,
96 const android::renderscript::Allocation *alloc,
97 RsAllocationUsageType src);
98void rsdAllocationMarkDirty(const android::renderscript::Context *rsc,
99 const android::renderscript::Allocation *alloc);
Jason Sams733396b2013-02-22 12:46:18 -0800100void rsdAllocationSetSurface(const android::renderscript::Context *rsc,
101 android::renderscript::Allocation *alloc, ANativeWindow *nw);
Jason Sams7ac2a4d2012-02-15 12:04:24 -0800102void rsdAllocationIoSend(const android::renderscript::Context *rsc,
103 android::renderscript::Allocation *alloc);
104void rsdAllocationIoReceive(const android::renderscript::Context *rsc,
105 android::renderscript::Allocation *alloc);
Jason Samseb4fe182011-05-26 16:33:01 -0700106
107void rsdAllocationData1D(const android::renderscript::Context *rsc,
108 const android::renderscript::Allocation *alloc,
Tim Murray099bc262013-03-20 16:54:03 -0700109 uint32_t xoff, uint32_t lod, size_t count,
110 const void *data, size_t sizeBytes);
Jason Samseb4fe182011-05-26 16:33:01 -0700111void rsdAllocationData2D(const android::renderscript::Context *rsc,
112 const android::renderscript::Allocation *alloc,
113 uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
114 uint32_t w, uint32_t h,
Tim Murray099bc262013-03-20 16:54:03 -0700115 const void *data, size_t sizeBytes, size_t stride);
Jason Samseb4fe182011-05-26 16:33:01 -0700116void rsdAllocationData3D(const android::renderscript::Context *rsc,
117 const android::renderscript::Allocation *alloc,
Jason Sams3bbc0fd2013-04-09 14:16:13 -0700118 uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t lod,
119 uint32_t w, uint32_t h, uint32_t d, const void *data, size_t sizeBytes,
120 size_t stride);
Jason Samseb4fe182011-05-26 16:33:01 -0700121
Jason Sams807fdc42012-07-25 17:55:39 -0700122void rsdAllocationRead1D(const android::renderscript::Context *rsc,
123 const android::renderscript::Allocation *alloc,
Tim Murray099bc262013-03-20 16:54:03 -0700124 uint32_t xoff, uint32_t lod, size_t count,
125 void *data, size_t sizeBytes);
Jason Sams807fdc42012-07-25 17:55:39 -0700126void rsdAllocationRead2D(const android::renderscript::Context *rsc,
127 const android::renderscript::Allocation *alloc,
128 uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
129 uint32_t w, uint32_t h,
Tim Murray099bc262013-03-20 16:54:03 -0700130 void *data, size_t sizeBytes, size_t stride);
Jason Sams807fdc42012-07-25 17:55:39 -0700131void rsdAllocationRead3D(const android::renderscript::Context *rsc,
132 const android::renderscript::Allocation *alloc,
Jason Sams3bbc0fd2013-04-09 14:16:13 -0700133 uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t lod,
134 uint32_t w, uint32_t h, uint32_t d, void *data, size_t sizeBytes,
135 size_t stride);
Jason Sams807fdc42012-07-25 17:55:39 -0700136
137void * rsdAllocationLock1D(const android::renderscript::Context *rsc,
138 const android::renderscript::Allocation *alloc);
139void rsdAllocationUnlock1D(const android::renderscript::Context *rsc,
140 const android::renderscript::Allocation *alloc);
141
142
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700143void rsdAllocationData1D_alloc(const android::renderscript::Context *rsc,
144 const android::renderscript::Allocation *dstAlloc,
Tim Murray099bc262013-03-20 16:54:03 -0700145 uint32_t dstXoff, uint32_t dstLod, size_t count,
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700146 const android::renderscript::Allocation *srcAlloc,
147 uint32_t srcXoff, uint32_t srcLod);
148void rsdAllocationData2D_alloc(const android::renderscript::Context *rsc,
149 const android::renderscript::Allocation *dstAlloc,
150 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod,
151 RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h,
152 const android::renderscript::Allocation *srcAlloc,
153 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod,
154 RsAllocationCubemapFace srcFace);
155void rsdAllocationData3D_alloc(const android::renderscript::Context *rsc,
156 const android::renderscript::Allocation *dstAlloc,
157 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff,
Jason Sams3bbc0fd2013-04-09 14:16:13 -0700158 uint32_t dstLod,
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700159 uint32_t w, uint32_t h, uint32_t d,
160 const android::renderscript::Allocation *srcAlloc,
161 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff,
Jason Sams3bbc0fd2013-04-09 14:16:13 -0700162 uint32_t srcLod);
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700163
Miao Wangcc8cea72015-02-19 18:14:46 -0800164void rsdAllocationElementData(const android::renderscript::Context *rsc,
165 const android::renderscript::Allocation *alloc,
166 uint32_t x, uint32_t y, uint32_t z,
167 const void *data, uint32_t elementOff, size_t sizeBytes);
168
169void rsdAllocationElementRead(const android::renderscript::Context *rsc,
170 const android::renderscript::Allocation *alloc,
171 uint32_t x, uint32_t y, uint32_t z,
172 void *data, uint32_t elementOff, size_t sizeBytes);
Jason Samseb4fe182011-05-26 16:33:01 -0700173
Jason Samsa6dd8232012-07-25 19:33:43 -0700174void rsdAllocationGenerateMipmaps(const android::renderscript::Context *rsc,
175 const android::renderscript::Allocation *alloc);
Jason Samseb4fe182011-05-26 16:33:01 -0700176
Jason Samsa36c50a2014-06-17 12:06:06 -0700177void rsdAllocationUpdateCachedObject(const android::renderscript::Context *rsc,
178 const android::renderscript::Allocation *alloc,
179 android::renderscript::rs_allocation *obj);
Jason Samseb4fe182011-05-26 16:33:01 -0700180
Jason Samsbc9dc272015-02-09 12:50:22 -0800181void rsdAllocationAdapterOffset(const android::renderscript::Context *rsc,
182 const android::renderscript::Allocation *alloc);
183
Jason Samseb4fe182011-05-26 16:33:01 -0700184
185#endif