blob: 9f13c98fb83b8b9a735e12d01316ff69ca5061d5 [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);
87void rsdAllocationDestroy(const android::renderscript::Context *rsc,
88 android::renderscript::Allocation *alloc);
89
90void rsdAllocationResize(const android::renderscript::Context *rsc,
91 const android::renderscript::Allocation *alloc,
92 const android::renderscript::Type *newType, bool zeroNew);
93void rsdAllocationSyncAll(const android::renderscript::Context *rsc,
94 const android::renderscript::Allocation *alloc,
95 RsAllocationUsageType src);
96void rsdAllocationMarkDirty(const android::renderscript::Context *rsc,
97 const android::renderscript::Allocation *alloc);
Jason Sams733396b2013-02-22 12:46:18 -080098void rsdAllocationSetSurface(const android::renderscript::Context *rsc,
99 android::renderscript::Allocation *alloc, ANativeWindow *nw);
Jason Sams7ac2a4d2012-02-15 12:04:24 -0800100void rsdAllocationIoSend(const android::renderscript::Context *rsc,
101 android::renderscript::Allocation *alloc);
102void rsdAllocationIoReceive(const android::renderscript::Context *rsc,
103 android::renderscript::Allocation *alloc);
Jason Samseb4fe182011-05-26 16:33:01 -0700104
105void rsdAllocationData1D(const android::renderscript::Context *rsc,
106 const android::renderscript::Allocation *alloc,
Tim Murray099bc262013-03-20 16:54:03 -0700107 uint32_t xoff, uint32_t lod, size_t count,
108 const void *data, size_t sizeBytes);
Jason Samseb4fe182011-05-26 16:33:01 -0700109void rsdAllocationData2D(const android::renderscript::Context *rsc,
110 const android::renderscript::Allocation *alloc,
111 uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
112 uint32_t w, uint32_t h,
Tim Murray099bc262013-03-20 16:54:03 -0700113 const void *data, size_t sizeBytes, size_t stride);
Jason Samseb4fe182011-05-26 16:33:01 -0700114void rsdAllocationData3D(const android::renderscript::Context *rsc,
115 const android::renderscript::Allocation *alloc,
Jason Sams3bbc0fd2013-04-09 14:16:13 -0700116 uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t lod,
117 uint32_t w, uint32_t h, uint32_t d, const void *data, size_t sizeBytes,
118 size_t stride);
Jason Samseb4fe182011-05-26 16:33:01 -0700119
Jason Sams807fdc42012-07-25 17:55:39 -0700120void rsdAllocationRead1D(const android::renderscript::Context *rsc,
121 const android::renderscript::Allocation *alloc,
Tim Murray099bc262013-03-20 16:54:03 -0700122 uint32_t xoff, uint32_t lod, size_t count,
123 void *data, size_t sizeBytes);
Jason Sams807fdc42012-07-25 17:55:39 -0700124void rsdAllocationRead2D(const android::renderscript::Context *rsc,
125 const android::renderscript::Allocation *alloc,
126 uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
127 uint32_t w, uint32_t h,
Tim Murray099bc262013-03-20 16:54:03 -0700128 void *data, size_t sizeBytes, size_t stride);
Jason Sams807fdc42012-07-25 17:55:39 -0700129void rsdAllocationRead3D(const android::renderscript::Context *rsc,
130 const android::renderscript::Allocation *alloc,
Jason Sams3bbc0fd2013-04-09 14:16:13 -0700131 uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t lod,
132 uint32_t w, uint32_t h, uint32_t d, void *data, size_t sizeBytes,
133 size_t stride);
Jason Sams807fdc42012-07-25 17:55:39 -0700134
135void * rsdAllocationLock1D(const android::renderscript::Context *rsc,
136 const android::renderscript::Allocation *alloc);
137void rsdAllocationUnlock1D(const android::renderscript::Context *rsc,
138 const android::renderscript::Allocation *alloc);
139
140
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700141void rsdAllocationData1D_alloc(const android::renderscript::Context *rsc,
142 const android::renderscript::Allocation *dstAlloc,
Tim Murray099bc262013-03-20 16:54:03 -0700143 uint32_t dstXoff, uint32_t dstLod, size_t count,
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700144 const android::renderscript::Allocation *srcAlloc,
145 uint32_t srcXoff, uint32_t srcLod);
146void rsdAllocationData2D_alloc(const android::renderscript::Context *rsc,
147 const android::renderscript::Allocation *dstAlloc,
148 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod,
149 RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h,
150 const android::renderscript::Allocation *srcAlloc,
151 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod,
152 RsAllocationCubemapFace srcFace);
153void rsdAllocationData3D_alloc(const android::renderscript::Context *rsc,
154 const android::renderscript::Allocation *dstAlloc,
155 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff,
Jason Sams3bbc0fd2013-04-09 14:16:13 -0700156 uint32_t dstLod,
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700157 uint32_t w, uint32_t h, uint32_t d,
158 const android::renderscript::Allocation *srcAlloc,
159 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff,
Jason Sams3bbc0fd2013-04-09 14:16:13 -0700160 uint32_t srcLod);
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700161
Jason Samseb4fe182011-05-26 16:33:01 -0700162void rsdAllocationElementData1D(const android::renderscript::Context *rsc,
163 const android::renderscript::Allocation *alloc,
164 uint32_t x,
Tim Murray099bc262013-03-20 16:54:03 -0700165 const void *data, uint32_t elementOff, size_t sizeBytes);
Jason Samseb4fe182011-05-26 16:33:01 -0700166void rsdAllocationElementData2D(const android::renderscript::Context *rsc,
167 const android::renderscript::Allocation *alloc,
168 uint32_t x, uint32_t y,
Tim Murray099bc262013-03-20 16:54:03 -0700169 const void *data, uint32_t elementOff, size_t sizeBytes);
Jason Samseb4fe182011-05-26 16:33:01 -0700170
Jason Samsa6dd8232012-07-25 19:33:43 -0700171void rsdAllocationGenerateMipmaps(const android::renderscript::Context *rsc,
172 const android::renderscript::Allocation *alloc);
Jason Samseb4fe182011-05-26 16:33:01 -0700173
Jason Samsa36c50a2014-06-17 12:06:06 -0700174void rsdAllocationUpdateCachedObject(const android::renderscript::Context *rsc,
175 const android::renderscript::Allocation *alloc,
176 android::renderscript::rs_allocation *obj);
Jason Samseb4fe182011-05-26 16:33:01 -0700177
178
179#endif