blob: ff47f03573ae8b59b26e7bba2d3517b80b69e5cb [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;
Alex Sakhartchouka9495242011-06-16 11:05:13 -070038
Jason Samseb4fe182011-05-26 16:33:01 -070039struct DrvAllocation {
40 // Is this a legal structure to be used as a texture source.
41 // Initially this will require 1D or 2D and color data
42 uint32_t textureID;
43
44 // Is this a legal structure to be used as a vertex source.
45 // Initially this will require 1D and x(yzw). Additional per element data
46 // is allowed.
47 uint32_t bufferID;
48
49 // Is this a legal structure to be used as an FBO render target
50 uint32_t renderTargetID;
51
Jason Sams93eacc72012-12-18 14:26:57 -080052#ifndef RS_COMPATIBILITY_LIB
Jason Samseb4fe182011-05-26 16:33:01 -070053 GLenum glTarget;
Jason Samsa614ae12011-05-26 17:05:51 -070054 GLenum glType;
55 GLenum glFormat;
Tim Murray3a25fdd2013-02-22 17:56:56 -080056
57 ANativeWindow *wndSurface;
58 android::GLConsumer *surfaceTexture;
Jason Sams93eacc72012-12-18 14:26:57 -080059#else
60 int glTarget;
61 int glType;
62 int glFormat;
63#endif
Jason Samsa614ae12011-05-26 17:05:51 -070064
Tim Murrayc2cfe6a2013-02-14 16:21:33 -080065 bool useUserProvidedPtr;
Jason Samseb4fe182011-05-26 16:33:01 -070066 bool uploadDeferred;
Alex Sakhartchouka9495242011-06-16 11:05:13 -070067
68 RsdFrameBufferObj * readBackFBO;
Jason Samsb3220332012-04-02 14:41:54 -070069 ANativeWindow *wnd;
Jason Sams7ac2a4d2012-02-15 12:04:24 -080070 ANativeWindowBuffer *wndBuffer;
Jason Samseb4fe182011-05-26 16:33:01 -070071};
72
Jason Sams93eacc72012-12-18 14:26:57 -080073#ifndef RS_COMPATIBILITY_LIB
Jason Samsa614ae12011-05-26 17:05:51 -070074GLenum rsdTypeToGLType(RsDataType t);
75GLenum rsdKindToGLFormat(RsDataKind k);
Jason Sams93eacc72012-12-18 14:26:57 -080076#endif
Jason Samsa614ae12011-05-26 17:05:51 -070077
78
Jason Samsddceab92013-08-07 13:02:32 -070079uint32_t rsdAllocationGrallocBits(const android::renderscript::Context *rsc,
80 android::renderscript::Allocation *alloc);
Jason Samseb4fe182011-05-26 16:33:01 -070081bool rsdAllocationInit(const android::renderscript::Context *rsc,
82 android::renderscript::Allocation *alloc,
83 bool forceZero);
84void rsdAllocationDestroy(const android::renderscript::Context *rsc,
85 android::renderscript::Allocation *alloc);
86
87void rsdAllocationResize(const android::renderscript::Context *rsc,
88 const android::renderscript::Allocation *alloc,
89 const android::renderscript::Type *newType, bool zeroNew);
90void rsdAllocationSyncAll(const android::renderscript::Context *rsc,
91 const android::renderscript::Allocation *alloc,
92 RsAllocationUsageType src);
93void rsdAllocationMarkDirty(const android::renderscript::Context *rsc,
94 const android::renderscript::Allocation *alloc);
Jason Sams733396b2013-02-22 12:46:18 -080095void rsdAllocationSetSurface(const android::renderscript::Context *rsc,
96 android::renderscript::Allocation *alloc, ANativeWindow *nw);
Jason Sams7ac2a4d2012-02-15 12:04:24 -080097void rsdAllocationIoSend(const android::renderscript::Context *rsc,
98 android::renderscript::Allocation *alloc);
99void rsdAllocationIoReceive(const android::renderscript::Context *rsc,
100 android::renderscript::Allocation *alloc);
Jason Samseb4fe182011-05-26 16:33:01 -0700101
102void rsdAllocationData1D(const android::renderscript::Context *rsc,
103 const android::renderscript::Allocation *alloc,
Tim Murray099bc262013-03-20 16:54:03 -0700104 uint32_t xoff, uint32_t lod, size_t count,
105 const void *data, size_t sizeBytes);
Jason Samseb4fe182011-05-26 16:33:01 -0700106void rsdAllocationData2D(const android::renderscript::Context *rsc,
107 const android::renderscript::Allocation *alloc,
108 uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
109 uint32_t w, uint32_t h,
Tim Murray099bc262013-03-20 16:54:03 -0700110 const void *data, size_t sizeBytes, size_t stride);
Jason Samseb4fe182011-05-26 16:33:01 -0700111void rsdAllocationData3D(const android::renderscript::Context *rsc,
112 const android::renderscript::Allocation *alloc,
Jason Sams3bbc0fd2013-04-09 14:16:13 -0700113 uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t lod,
114 uint32_t w, uint32_t h, uint32_t d, const void *data, size_t sizeBytes,
115 size_t stride);
Jason Samseb4fe182011-05-26 16:33:01 -0700116
Jason Sams807fdc42012-07-25 17:55:39 -0700117void rsdAllocationRead1D(const android::renderscript::Context *rsc,
118 const android::renderscript::Allocation *alloc,
Tim Murray099bc262013-03-20 16:54:03 -0700119 uint32_t xoff, uint32_t lod, size_t count,
120 void *data, size_t sizeBytes);
Jason Sams807fdc42012-07-25 17:55:39 -0700121void rsdAllocationRead2D(const android::renderscript::Context *rsc,
122 const android::renderscript::Allocation *alloc,
123 uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
124 uint32_t w, uint32_t h,
Tim Murray099bc262013-03-20 16:54:03 -0700125 void *data, size_t sizeBytes, size_t stride);
Jason Sams807fdc42012-07-25 17:55:39 -0700126void rsdAllocationRead3D(const android::renderscript::Context *rsc,
127 const android::renderscript::Allocation *alloc,
Jason Sams3bbc0fd2013-04-09 14:16:13 -0700128 uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t lod,
129 uint32_t w, uint32_t h, uint32_t d, void *data, size_t sizeBytes,
130 size_t stride);
Jason Sams807fdc42012-07-25 17:55:39 -0700131
132void * rsdAllocationLock1D(const android::renderscript::Context *rsc,
133 const android::renderscript::Allocation *alloc);
134void rsdAllocationUnlock1D(const android::renderscript::Context *rsc,
135 const android::renderscript::Allocation *alloc);
136
137
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700138void rsdAllocationData1D_alloc(const android::renderscript::Context *rsc,
139 const android::renderscript::Allocation *dstAlloc,
Tim Murray099bc262013-03-20 16:54:03 -0700140 uint32_t dstXoff, uint32_t dstLod, size_t count,
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700141 const android::renderscript::Allocation *srcAlloc,
142 uint32_t srcXoff, uint32_t srcLod);
143void rsdAllocationData2D_alloc(const android::renderscript::Context *rsc,
144 const android::renderscript::Allocation *dstAlloc,
145 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod,
146 RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h,
147 const android::renderscript::Allocation *srcAlloc,
148 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod,
149 RsAllocationCubemapFace srcFace);
150void rsdAllocationData3D_alloc(const android::renderscript::Context *rsc,
151 const android::renderscript::Allocation *dstAlloc,
152 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff,
Jason Sams3bbc0fd2013-04-09 14:16:13 -0700153 uint32_t dstLod,
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700154 uint32_t w, uint32_t h, uint32_t d,
155 const android::renderscript::Allocation *srcAlloc,
156 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff,
Jason Sams3bbc0fd2013-04-09 14:16:13 -0700157 uint32_t srcLod);
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700158
Jason Samseb4fe182011-05-26 16:33:01 -0700159void rsdAllocationElementData1D(const android::renderscript::Context *rsc,
160 const android::renderscript::Allocation *alloc,
161 uint32_t x,
Tim Murray099bc262013-03-20 16:54:03 -0700162 const void *data, uint32_t elementOff, size_t sizeBytes);
Jason Samseb4fe182011-05-26 16:33:01 -0700163void rsdAllocationElementData2D(const android::renderscript::Context *rsc,
164 const android::renderscript::Allocation *alloc,
165 uint32_t x, uint32_t y,
Tim Murray099bc262013-03-20 16:54:03 -0700166 const void *data, uint32_t elementOff, size_t sizeBytes);
Jason Samseb4fe182011-05-26 16:33:01 -0700167
Jason Samsa6dd8232012-07-25 19:33:43 -0700168void rsdAllocationGenerateMipmaps(const android::renderscript::Context *rsc,
169 const android::renderscript::Allocation *alloc);
Jason Samseb4fe182011-05-26 16:33:01 -0700170
171
172
173#endif