blob: 98b1d653ce1facfbcde831e3b08412e40e2dee4b [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
24#include <GLES/gl.h>
25#include <GLES2/gl2.h>
26
Alex Sakhartchouka9495242011-06-16 11:05:13 -070027class RsdFrameBufferObj;
Jason Sams7ac2a4d2012-02-15 12:04:24 -080028struct ANativeWindowBuffer;
Alex Sakhartchouka9495242011-06-16 11:05:13 -070029
Jason Samseb4fe182011-05-26 16:33:01 -070030struct DrvAllocation {
31 // Is this a legal structure to be used as a texture source.
32 // Initially this will require 1D or 2D and color data
33 uint32_t textureID;
34
35 // Is this a legal structure to be used as a vertex source.
36 // Initially this will require 1D and x(yzw). Additional per element data
37 // is allowed.
38 uint32_t bufferID;
39
40 // Is this a legal structure to be used as an FBO render target
41 uint32_t renderTargetID;
42
Jason Samseb4fe182011-05-26 16:33:01 -070043 GLenum glTarget;
Jason Samsa614ae12011-05-26 17:05:51 -070044 GLenum glType;
45 GLenum glFormat;
46
Jason Samseb4fe182011-05-26 16:33:01 -070047 bool uploadDeferred;
Alex Sakhartchouka9495242011-06-16 11:05:13 -070048
49 RsdFrameBufferObj * readBackFBO;
Jason Samsb3220332012-04-02 14:41:54 -070050 ANativeWindow *wnd;
Jason Sams7ac2a4d2012-02-15 12:04:24 -080051 ANativeWindowBuffer *wndBuffer;
Jason Sams807fdc42012-07-25 17:55:39 -070052
53 struct LodState {
54 void * mallocPtr;
55 size_t stride;
56 uint32_t dimX;
57 uint32_t dimY;
58 uint32_t dimZ;
59 } lod[android::renderscript::Allocation::MAX_LOD];
60 size_t faceOffset;
61 uint32_t lodCount;
62 uint32_t faceCount;
63
64
Jason Samseb4fe182011-05-26 16:33:01 -070065};
66
Jason Samsa614ae12011-05-26 17:05:51 -070067GLenum rsdTypeToGLType(RsDataType t);
68GLenum rsdKindToGLFormat(RsDataKind k);
69
70
Jason Samseb4fe182011-05-26 16:33:01 -070071bool rsdAllocationInit(const android::renderscript::Context *rsc,
72 android::renderscript::Allocation *alloc,
73 bool forceZero);
74void rsdAllocationDestroy(const android::renderscript::Context *rsc,
75 android::renderscript::Allocation *alloc);
76
77void rsdAllocationResize(const android::renderscript::Context *rsc,
78 const android::renderscript::Allocation *alloc,
79 const android::renderscript::Type *newType, bool zeroNew);
80void rsdAllocationSyncAll(const android::renderscript::Context *rsc,
81 const android::renderscript::Allocation *alloc,
82 RsAllocationUsageType src);
83void rsdAllocationMarkDirty(const android::renderscript::Context *rsc,
84 const android::renderscript::Allocation *alloc);
Jason Sams41e373d2012-01-13 14:01:20 -080085int32_t rsdAllocationInitSurfaceTexture(const android::renderscript::Context *rsc,
86 const android::renderscript::Allocation *alloc);
Jason Sams7ac2a4d2012-02-15 12:04:24 -080087void rsdAllocationSetSurfaceTexture(const android::renderscript::Context *rsc,
88 android::renderscript::Allocation *alloc, ANativeWindow *nw);
89void rsdAllocationIoSend(const android::renderscript::Context *rsc,
90 android::renderscript::Allocation *alloc);
91void rsdAllocationIoReceive(const android::renderscript::Context *rsc,
92 android::renderscript::Allocation *alloc);
Jason Samseb4fe182011-05-26 16:33:01 -070093
94void rsdAllocationData1D(const android::renderscript::Context *rsc,
95 const android::renderscript::Allocation *alloc,
96 uint32_t xoff, uint32_t lod, uint32_t count,
97 const void *data, uint32_t sizeBytes);
98void rsdAllocationData2D(const android::renderscript::Context *rsc,
99 const android::renderscript::Allocation *alloc,
100 uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
101 uint32_t w, uint32_t h,
102 const void *data, uint32_t sizeBytes);
103void rsdAllocationData3D(const android::renderscript::Context *rsc,
104 const android::renderscript::Allocation *alloc,
105 uint32_t xoff, uint32_t yoff, uint32_t zoff,
106 uint32_t lod, RsAllocationCubemapFace face,
107 uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes);
108
Jason Sams807fdc42012-07-25 17:55:39 -0700109void rsdAllocationRead1D(const android::renderscript::Context *rsc,
110 const android::renderscript::Allocation *alloc,
111 uint32_t xoff, uint32_t lod, uint32_t count,
112 void *data, uint32_t sizeBytes);
113void rsdAllocationRead2D(const android::renderscript::Context *rsc,
114 const android::renderscript::Allocation *alloc,
115 uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
116 uint32_t w, uint32_t h,
117 void *data, uint32_t sizeBytes);
118void rsdAllocationRead3D(const android::renderscript::Context *rsc,
119 const android::renderscript::Allocation *alloc,
120 uint32_t xoff, uint32_t yoff, uint32_t zoff,
121 uint32_t lod, RsAllocationCubemapFace face,
122 uint32_t w, uint32_t h, uint32_t d, void *data, uint32_t sizeBytes);
123
124void * rsdAllocationLock1D(const android::renderscript::Context *rsc,
125 const android::renderscript::Allocation *alloc);
126void rsdAllocationUnlock1D(const android::renderscript::Context *rsc,
127 const android::renderscript::Allocation *alloc);
128
129
Alex Sakhartchouk74a82792011-06-14 11:13:19 -0700130void rsdAllocationData1D_alloc(const android::renderscript::Context *rsc,
131 const android::renderscript::Allocation *dstAlloc,
132 uint32_t dstXoff, uint32_t dstLod, uint32_t count,
133 const android::renderscript::Allocation *srcAlloc,
134 uint32_t srcXoff, uint32_t srcLod);
135void rsdAllocationData2D_alloc(const android::renderscript::Context *rsc,
136 const android::renderscript::Allocation *dstAlloc,
137 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod,
138 RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h,
139 const android::renderscript::Allocation *srcAlloc,
140 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod,
141 RsAllocationCubemapFace srcFace);
142void rsdAllocationData3D_alloc(const android::renderscript::Context *rsc,
143 const android::renderscript::Allocation *dstAlloc,
144 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff,
145 uint32_t dstLod, RsAllocationCubemapFace dstFace,
146 uint32_t w, uint32_t h, uint32_t d,
147 const android::renderscript::Allocation *srcAlloc,
148 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff,
149 uint32_t srcLod, RsAllocationCubemapFace srcFace);
150
Jason Samseb4fe182011-05-26 16:33:01 -0700151void rsdAllocationElementData1D(const android::renderscript::Context *rsc,
152 const android::renderscript::Allocation *alloc,
153 uint32_t x,
154 const void *data, uint32_t elementOff, uint32_t sizeBytes);
155void rsdAllocationElementData2D(const android::renderscript::Context *rsc,
156 const android::renderscript::Allocation *alloc,
157 uint32_t x, uint32_t y,
158 const void *data, uint32_t elementOff, uint32_t sizeBytes);
159
160
161
162
163#endif