blob: 021f22beab987965495c646409d60a3a281be51f [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
Jason Samseb4fe182011-05-26 16:33:01 -070026#include <GLES/gl.h>
27#include <GLES2/gl2.h>
28
Stephen Hinesb0934b62013-07-03 17:27:38 -070029
Alex Sakhartchouka9495242011-06-16 11:05:13 -070030class RsdFrameBufferObj;
Tim Murray3a25fdd2013-02-22 17:56:56 -080031struct ANativeWindow;
Jason Sams7ac2a4d2012-02-15 12:04:24 -080032struct ANativeWindowBuffer;
Miao Wang2bd78f22014-11-20 10:49:43 -080033struct ANativeWindow_Buffer;
Alex Sakhartchouka9495242011-06-16 11:05:13 -070034
Jason Samseb4fe182011-05-26 16:33:01 -070035struct DrvAllocation {
36 // Is this a legal structure to be used as a texture source.
37 // Initially this will require 1D or 2D and color data
38 uint32_t textureID;
39
40 // Is this a legal structure to be used as a vertex source.
41 // Initially this will require 1D and x(yzw). Additional per element data
42 // is allowed.
43 uint32_t bufferID;
44
45 // Is this a legal structure to be used as an FBO render target
46 uint32_t renderTargetID;
47
Miao Wang59f61422017-03-14 14:23:52 -070048#if !defined(RS_VENDOR_LIB) && !defined(RS_COMPATIBILITY_LIB)
Jason Samseb4fe182011-05-26 16:33:01 -070049 GLenum glTarget;
Jason Samsa614ae12011-05-26 17:05:51 -070050 GLenum glType;
51 GLenum glFormat;
Jason Sams93eacc72012-12-18 14:26:57 -080052#else
53 int glTarget;
54 int glType;
55 int glFormat;
Miao Wang5d955c92017-03-01 11:57:47 -080056#endif
Miao Wang2bd78f22014-11-20 10:49:43 -080057
Miao Wangc3e57652017-03-24 11:45:47 -070058#if !defined(RS_COMPATIBILITY_LIB)
59 ANativeWindowBuffer *wndBuffer;
60#else
Miao Wang2bd78f22014-11-20 10:49:43 -080061 ANativeWindow_Buffer *wndBuffer;
Miao Wangc3e57652017-03-24 11:45:47 -070062#endif
Jason Samsa614ae12011-05-26 17:05:51 -070063
Tim Murrayc2cfe6a2013-02-14 16:21:33 -080064 bool useUserProvidedPtr;
Jason Samseb4fe182011-05-26 16:33:01 -070065 bool uploadDeferred;
Alex Sakhartchouka9495242011-06-16 11:05:13 -070066
Miao Wang59f61422017-03-14 14:23:52 -070067#if !defined(RS_VENDOR_LIB) && !defined(RS_COMPATIBILITY_LIB)
Alex Sakhartchouka9495242011-06-16 11:05:13 -070068 RsdFrameBufferObj * readBackFBO;
Miao Wang59f61422017-03-14 14:23:52 -070069#endif
Jason Samsb3220332012-04-02 14:41:54 -070070 ANativeWindow *wnd;
Miao Wang2bd78f22014-11-20 10:49:43 -080071 ANativeWindow *wndSurface;
Jason Samseb4fe182011-05-26 16:33:01 -070072};
73
Jason Sams93eacc72012-12-18 14:26:57 -080074#ifndef RS_COMPATIBILITY_LIB
Jason Samsa614ae12011-05-26 17:05:51 -070075GLenum rsdTypeToGLType(RsDataType t);
76GLenum rsdKindToGLFormat(RsDataKind k);
Jason Sams93eacc72012-12-18 14:26:57 -080077#endif
Jason Samsa614ae12011-05-26 17:05:51 -070078
79
Jason Samsddceab92013-08-07 13:02:32 -070080uint32_t rsdAllocationGrallocBits(const android::renderscript::Context *rsc,
81 android::renderscript::Allocation *alloc);
Jason Samseb4fe182011-05-26 16:33:01 -070082bool rsdAllocationInit(const android::renderscript::Context *rsc,
83 android::renderscript::Allocation *alloc,
84 bool forceZero);
Miao Wang47a58812015-07-23 21:59:16 -070085#ifdef RS_COMPATIBILITY_LIB
86bool rsdAllocationInitStrided(const android::renderscript::Context *rsc,
87 android::renderscript::Allocation *alloc,
88 bool forceZero, size_t requiredAlignment);
89#endif
Jason Samsbc9dc272015-02-09 12:50:22 -080090bool rsdAllocationAdapterInit(const android::renderscript::Context *rsc,
91 android::renderscript::Allocation *alloc);
Jason Samseb4fe182011-05-26 16:33:01 -070092void rsdAllocationDestroy(const android::renderscript::Context *rsc,
93 android::renderscript::Allocation *alloc);
94
95void rsdAllocationResize(const android::renderscript::Context *rsc,
96 const android::renderscript::Allocation *alloc,
97 const android::renderscript::Type *newType, bool zeroNew);
98void rsdAllocationSyncAll(const android::renderscript::Context *rsc,
99 const android::renderscript::Allocation *alloc,
100 RsAllocationUsageType src);
101void rsdAllocationMarkDirty(const android::renderscript::Context *rsc,
102 const android::renderscript::Allocation *alloc);
Jason Sams733396b2013-02-22 12:46:18 -0800103void rsdAllocationSetSurface(const android::renderscript::Context *rsc,
104 android::renderscript::Allocation *alloc, ANativeWindow *nw);
Jason Sams7ac2a4d2012-02-15 12:04:24 -0800105void rsdAllocationIoSend(const android::renderscript::Context *rsc,
106 android::renderscript::Allocation *alloc);
107void rsdAllocationIoReceive(const android::renderscript::Context *rsc,
108 android::renderscript::Allocation *alloc);
Jason Samseb4fe182011-05-26 16:33:01 -0700109
110void rsdAllocationData1D(const android::renderscript::Context *rsc,
111 const android::renderscript::Allocation *alloc,
Tim Murray099bc262013-03-20 16:54:03 -0700112 uint32_t xoff, uint32_t lod, size_t count,
113 const void *data, size_t sizeBytes);
Jason Samseb4fe182011-05-26 16:33:01 -0700114void rsdAllocationData2D(const android::renderscript::Context *rsc,
115 const android::renderscript::Allocation *alloc,
116 uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
117 uint32_t w, uint32_t h,
Tim Murray099bc262013-03-20 16:54:03 -0700118 const void *data, size_t sizeBytes, size_t stride);
Jason Samseb4fe182011-05-26 16:33:01 -0700119void rsdAllocationData3D(const android::renderscript::Context *rsc,
120 const android::renderscript::Allocation *alloc,
Jason Sams3bbc0fd2013-04-09 14:16:13 -0700121 uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t lod,
122 uint32_t w, uint32_t h, uint32_t d, const void *data, size_t sizeBytes,
123 size_t stride);
Jason Samseb4fe182011-05-26 16:33:01 -0700124
Jason Sams807fdc42012-07-25 17:55:39 -0700125void rsdAllocationRead1D(const android::renderscript::Context *rsc,
126 const android::renderscript::Allocation *alloc,
Tim Murray099bc262013-03-20 16:54:03 -0700127 uint32_t xoff, uint32_t lod, size_t count,
128 void *data, size_t sizeBytes);
Jason Sams807fdc42012-07-25 17:55:39 -0700129void rsdAllocationRead2D(const android::renderscript::Context *rsc,
130 const android::renderscript::Allocation *alloc,
131 uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
132 uint32_t w, uint32_t h,
Tim Murray099bc262013-03-20 16:54:03 -0700133 void *data, size_t sizeBytes, size_t stride);
Jason Sams807fdc42012-07-25 17:55:39 -0700134void rsdAllocationRead3D(const android::renderscript::Context *rsc,
135 const android::renderscript::Allocation *alloc,
Jason Sams3bbc0fd2013-04-09 14:16:13 -0700136 uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t lod,
137 uint32_t w, uint32_t h, uint32_t d, void *data, size_t sizeBytes,
138 size_t stride);
Jason Sams807fdc42012-07-25 17:55:39 -0700139
140void * rsdAllocationLock1D(const android::renderscript::Context *rsc,
141 const android::renderscript::Allocation *alloc);
142void rsdAllocationUnlock1D(const android::renderscript::Context *rsc,
143 const android::renderscript::Allocation *alloc);
144
145
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700146void rsdAllocationData1D_alloc(const android::renderscript::Context *rsc,
147 const android::renderscript::Allocation *dstAlloc,
Tim Murray099bc262013-03-20 16:54:03 -0700148 uint32_t dstXoff, uint32_t dstLod, size_t count,
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700149 const android::renderscript::Allocation *srcAlloc,
150 uint32_t srcXoff, uint32_t srcLod);
151void rsdAllocationData2D_alloc(const android::renderscript::Context *rsc,
152 const android::renderscript::Allocation *dstAlloc,
153 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod,
154 RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h,
155 const android::renderscript::Allocation *srcAlloc,
156 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod,
157 RsAllocationCubemapFace srcFace);
158void rsdAllocationData3D_alloc(const android::renderscript::Context *rsc,
159 const android::renderscript::Allocation *dstAlloc,
160 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff,
Jason Sams3bbc0fd2013-04-09 14:16:13 -0700161 uint32_t dstLod,
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700162 uint32_t w, uint32_t h, uint32_t d,
163 const android::renderscript::Allocation *srcAlloc,
164 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff,
Jason Sams3bbc0fd2013-04-09 14:16:13 -0700165 uint32_t srcLod);
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700166
Miao Wangcc8cea72015-02-19 18:14:46 -0800167void rsdAllocationElementData(const android::renderscript::Context *rsc,
168 const android::renderscript::Allocation *alloc,
169 uint32_t x, uint32_t y, uint32_t z,
170 const void *data, uint32_t elementOff, size_t sizeBytes);
171
172void rsdAllocationElementRead(const android::renderscript::Context *rsc,
173 const android::renderscript::Allocation *alloc,
174 uint32_t x, uint32_t y, uint32_t z,
175 void *data, uint32_t elementOff, size_t sizeBytes);
Jason Samseb4fe182011-05-26 16:33:01 -0700176
Jason Samsa6dd8232012-07-25 19:33:43 -0700177void rsdAllocationGenerateMipmaps(const android::renderscript::Context *rsc,
178 const android::renderscript::Allocation *alloc);
Jason Samseb4fe182011-05-26 16:33:01 -0700179
Jason Samsa36c50a2014-06-17 12:06:06 -0700180void rsdAllocationUpdateCachedObject(const android::renderscript::Context *rsc,
181 const android::renderscript::Allocation *alloc,
182 android::renderscript::rs_allocation *obj);
Jason Samseb4fe182011-05-26 16:33:01 -0700183
Jason Samsbc9dc272015-02-09 12:50:22 -0800184void rsdAllocationAdapterOffset(const android::renderscript::Context *rsc,
185 const android::renderscript::Allocation *alloc);
186
Jason Samseb4fe182011-05-26 16:33:01 -0700187
188#endif