blob: 41ccfe7aa5cc11f4487df49a71f89915a0e2c25b [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"
Jason Sams733396b2013-02-22 12:46:18 -080025#include "gui/CpuConsumer.h"
Jason Sams709a0972012-11-15 18:18:04 -080026
Jason Samseb4fe182011-05-26 16:33:01 -070027#include <GLES/gl.h>
28#include <GLES2/gl2.h>
29
Alex Sakhartchouka9495242011-06-16 11:05:13 -070030class RsdFrameBufferObj;
Jason Sams7ac2a4d2012-02-15 12:04:24 -080031struct ANativeWindowBuffer;
Alex Sakhartchouka9495242011-06-16 11:05:13 -070032
Jason Sams733396b2013-02-22 12:46:18 -080033
Jason Samseb4fe182011-05-26 16:33:01 -070034struct DrvAllocation {
35 // Is this a legal structure to be used as a texture source.
36 // Initially this will require 1D or 2D and color data
37 uint32_t textureID;
38
39 // Is this a legal structure to be used as a vertex source.
40 // Initially this will require 1D and x(yzw). Additional per element data
41 // is allowed.
42 uint32_t bufferID;
43
44 // Is this a legal structure to be used as an FBO render target
45 uint32_t renderTargetID;
46
Jason Sams93eacc72012-12-18 14:26:57 -080047#ifndef RS_COMPATIBILITY_LIB
Jason Samseb4fe182011-05-26 16:33:01 -070048 GLenum glTarget;
Jason Samsa614ae12011-05-26 17:05:51 -070049 GLenum glType;
50 GLenum glFormat;
Jason Sams93eacc72012-12-18 14:26:57 -080051#else
52 int glTarget;
53 int glType;
54 int glFormat;
55#endif
Jason Samsa614ae12011-05-26 17:05:51 -070056
Tim Murrayc2cfe6a2013-02-14 16:21:33 -080057 bool useUserProvidedPtr;
Jason Samseb4fe182011-05-26 16:33:01 -070058 bool uploadDeferred;
Alex Sakhartchouka9495242011-06-16 11:05:13 -070059
60 RsdFrameBufferObj * readBackFBO;
Jason Samsb3220332012-04-02 14:41:54 -070061 ANativeWindow *wnd;
Jason Sams7ac2a4d2012-02-15 12:04:24 -080062 ANativeWindowBuffer *wndBuffer;
Jason Sams733396b2013-02-22 12:46:18 -080063
64 android::sp< android::CpuConsumer > cpuConsumer;
65 android::CpuConsumer::LockedBuffer lb;
Jason Samseb4fe182011-05-26 16:33:01 -070066};
67
Jason Sams93eacc72012-12-18 14:26:57 -080068#ifndef RS_COMPATIBILITY_LIB
Jason Samsa614ae12011-05-26 17:05:51 -070069GLenum rsdTypeToGLType(RsDataType t);
70GLenum rsdKindToGLFormat(RsDataKind k);
Jason Sams93eacc72012-12-18 14:26:57 -080071#endif
Jason Samsa614ae12011-05-26 17:05:51 -070072
73
Jason Samseb4fe182011-05-26 16:33:01 -070074bool rsdAllocationInit(const android::renderscript::Context *rsc,
75 android::renderscript::Allocation *alloc,
76 bool forceZero);
77void rsdAllocationDestroy(const android::renderscript::Context *rsc,
78 android::renderscript::Allocation *alloc);
79
80void rsdAllocationResize(const android::renderscript::Context *rsc,
81 const android::renderscript::Allocation *alloc,
82 const android::renderscript::Type *newType, bool zeroNew);
83void rsdAllocationSyncAll(const android::renderscript::Context *rsc,
84 const android::renderscript::Allocation *alloc,
85 RsAllocationUsageType src);
86void rsdAllocationMarkDirty(const android::renderscript::Context *rsc,
87 const android::renderscript::Allocation *alloc);
Jason Sams733396b2013-02-22 12:46:18 -080088void* rsdAllocationGetSurface(const android::renderscript::Context *rsc,
89 const android::renderscript::Allocation *alloc);
90void rsdAllocationSetSurface(const android::renderscript::Context *rsc,
91 android::renderscript::Allocation *alloc, ANativeWindow *nw);
Jason Sams7ac2a4d2012-02-15 12:04:24 -080092void rsdAllocationIoSend(const android::renderscript::Context *rsc,
93 android::renderscript::Allocation *alloc);
94void rsdAllocationIoReceive(const android::renderscript::Context *rsc,
95 android::renderscript::Allocation *alloc);
Jason Samseb4fe182011-05-26 16:33:01 -070096
97void rsdAllocationData1D(const android::renderscript::Context *rsc,
98 const android::renderscript::Allocation *alloc,
99 uint32_t xoff, uint32_t lod, uint32_t count,
100 const void *data, uint32_t sizeBytes);
101void rsdAllocationData2D(const android::renderscript::Context *rsc,
102 const android::renderscript::Allocation *alloc,
103 uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
104 uint32_t w, uint32_t h,
Tim Murray358747a2012-11-26 13:52:04 -0800105 const void *data, uint32_t sizeBytes, size_t stride);
Jason Samseb4fe182011-05-26 16:33:01 -0700106void rsdAllocationData3D(const android::renderscript::Context *rsc,
107 const android::renderscript::Allocation *alloc,
108 uint32_t xoff, uint32_t yoff, uint32_t zoff,
109 uint32_t lod, RsAllocationCubemapFace face,
110 uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes);
111
Jason Sams807fdc42012-07-25 17:55:39 -0700112void rsdAllocationRead1D(const android::renderscript::Context *rsc,
113 const android::renderscript::Allocation *alloc,
114 uint32_t xoff, uint32_t lod, uint32_t count,
115 void *data, uint32_t sizeBytes);
116void rsdAllocationRead2D(const android::renderscript::Context *rsc,
117 const android::renderscript::Allocation *alloc,
118 uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
119 uint32_t w, uint32_t h,
Tim Murray358747a2012-11-26 13:52:04 -0800120 void *data, uint32_t sizeBytes, size_t stride);
Jason Sams807fdc42012-07-25 17:55:39 -0700121void rsdAllocationRead3D(const android::renderscript::Context *rsc,
122 const android::renderscript::Allocation *alloc,
123 uint32_t xoff, uint32_t yoff, uint32_t zoff,
124 uint32_t lod, RsAllocationCubemapFace face,
125 uint32_t w, uint32_t h, uint32_t d, void *data, uint32_t sizeBytes);
126
127void * rsdAllocationLock1D(const android::renderscript::Context *rsc,
128 const android::renderscript::Allocation *alloc);
129void rsdAllocationUnlock1D(const android::renderscript::Context *rsc,
130 const android::renderscript::Allocation *alloc);
131
132
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700133void rsdAllocationData1D_alloc(const android::renderscript::Context *rsc,
134 const android::renderscript::Allocation *dstAlloc,
135 uint32_t dstXoff, uint32_t dstLod, uint32_t count,
136 const android::renderscript::Allocation *srcAlloc,
137 uint32_t srcXoff, uint32_t srcLod);
138void rsdAllocationData2D_alloc(const android::renderscript::Context *rsc,
139 const android::renderscript::Allocation *dstAlloc,
140 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod,
141 RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h,
142 const android::renderscript::Allocation *srcAlloc,
143 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod,
144 RsAllocationCubemapFace srcFace);
145void rsdAllocationData3D_alloc(const android::renderscript::Context *rsc,
146 const android::renderscript::Allocation *dstAlloc,
147 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff,
148 uint32_t dstLod, RsAllocationCubemapFace dstFace,
149 uint32_t w, uint32_t h, uint32_t d,
150 const android::renderscript::Allocation *srcAlloc,
151 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff,
152 uint32_t srcLod, RsAllocationCubemapFace srcFace);
153
Jason Samseb4fe182011-05-26 16:33:01 -0700154void rsdAllocationElementData1D(const android::renderscript::Context *rsc,
155 const android::renderscript::Allocation *alloc,
156 uint32_t x,
157 const void *data, uint32_t elementOff, uint32_t sizeBytes);
158void rsdAllocationElementData2D(const android::renderscript::Context *rsc,
159 const android::renderscript::Allocation *alloc,
160 uint32_t x, uint32_t y,
161 const void *data, uint32_t elementOff, uint32_t sizeBytes);
162
Jason Samsa6dd8232012-07-25 19:33:43 -0700163void rsdAllocationGenerateMipmaps(const android::renderscript::Context *rsc,
164 const android::renderscript::Allocation *alloc);
Jason Samseb4fe182011-05-26 16:33:01 -0700165
166
167
168#endif