xref: /aosp_15_r20/frameworks/rs/driver/rsdAllocation.h (revision e1eccf28f96817838ad6867f7f39d2351ec11f56)
1*e1eccf28SAndroid Build Coastguard Worker /*
2*e1eccf28SAndroid Build Coastguard Worker  * Copyright (C) 2011 The Android Open Source Project
3*e1eccf28SAndroid Build Coastguard Worker  *
4*e1eccf28SAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*e1eccf28SAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*e1eccf28SAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*e1eccf28SAndroid Build Coastguard Worker  *
8*e1eccf28SAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*e1eccf28SAndroid Build Coastguard Worker  *
10*e1eccf28SAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*e1eccf28SAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*e1eccf28SAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*e1eccf28SAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*e1eccf28SAndroid Build Coastguard Worker  * limitations under the License.
15*e1eccf28SAndroid Build Coastguard Worker  */
16*e1eccf28SAndroid Build Coastguard Worker 
17*e1eccf28SAndroid Build Coastguard Worker #ifndef RSD_ALLOCATION_H
18*e1eccf28SAndroid Build Coastguard Worker #define RSD_ALLOCATION_H
19*e1eccf28SAndroid Build Coastguard Worker 
20*e1eccf28SAndroid Build Coastguard Worker #include <rs_hal.h>
21*e1eccf28SAndroid Build Coastguard Worker #include <rsRuntime.h>
22*e1eccf28SAndroid Build Coastguard Worker #include <rsAllocation.h>
23*e1eccf28SAndroid Build Coastguard Worker 
24*e1eccf28SAndroid Build Coastguard Worker #include "../cpu_ref/rsd_cpu.h"
25*e1eccf28SAndroid Build Coastguard Worker 
26*e1eccf28SAndroid Build Coastguard Worker #include <GLES/gl.h>
27*e1eccf28SAndroid Build Coastguard Worker #include <GLES2/gl2.h>
28*e1eccf28SAndroid Build Coastguard Worker 
29*e1eccf28SAndroid Build Coastguard Worker 
30*e1eccf28SAndroid Build Coastguard Worker class RsdFrameBufferObj;
31*e1eccf28SAndroid Build Coastguard Worker struct ANativeWindow;
32*e1eccf28SAndroid Build Coastguard Worker struct ANativeWindowBuffer;
33*e1eccf28SAndroid Build Coastguard Worker struct ANativeWindow_Buffer;
34*e1eccf28SAndroid Build Coastguard Worker 
35*e1eccf28SAndroid Build Coastguard Worker struct DrvAllocation {
36*e1eccf28SAndroid Build Coastguard Worker     // Is this a legal structure to be used as a texture source.
37*e1eccf28SAndroid Build Coastguard Worker     // Initially this will require 1D or 2D and color data
38*e1eccf28SAndroid Build Coastguard Worker     uint32_t textureID;
39*e1eccf28SAndroid Build Coastguard Worker 
40*e1eccf28SAndroid Build Coastguard Worker     // Is this a legal structure to be used as a vertex source.
41*e1eccf28SAndroid Build Coastguard Worker     // Initially this will require 1D and x(yzw).  Additional per element data
42*e1eccf28SAndroid Build Coastguard Worker     // is allowed.
43*e1eccf28SAndroid Build Coastguard Worker     uint32_t bufferID;
44*e1eccf28SAndroid Build Coastguard Worker 
45*e1eccf28SAndroid Build Coastguard Worker     // Is this a legal structure to be used as an FBO render target
46*e1eccf28SAndroid Build Coastguard Worker     uint32_t renderTargetID;
47*e1eccf28SAndroid Build Coastguard Worker 
48*e1eccf28SAndroid Build Coastguard Worker #if !defined(RS_VENDOR_LIB) && !defined(RS_COMPATIBILITY_LIB)
49*e1eccf28SAndroid Build Coastguard Worker     GLenum glTarget;
50*e1eccf28SAndroid Build Coastguard Worker     GLenum glType;
51*e1eccf28SAndroid Build Coastguard Worker     GLenum glFormat;
52*e1eccf28SAndroid Build Coastguard Worker #else
53*e1eccf28SAndroid Build Coastguard Worker     int glTarget;
54*e1eccf28SAndroid Build Coastguard Worker     int glType;
55*e1eccf28SAndroid Build Coastguard Worker     int glFormat;
56*e1eccf28SAndroid Build Coastguard Worker #endif
57*e1eccf28SAndroid Build Coastguard Worker 
58*e1eccf28SAndroid Build Coastguard Worker #if !defined(RS_COMPATIBILITY_LIB)
59*e1eccf28SAndroid Build Coastguard Worker     ANativeWindowBuffer *wndBuffer;
60*e1eccf28SAndroid Build Coastguard Worker #else
61*e1eccf28SAndroid Build Coastguard Worker     ANativeWindow_Buffer *wndBuffer;
62*e1eccf28SAndroid Build Coastguard Worker #endif
63*e1eccf28SAndroid Build Coastguard Worker 
64*e1eccf28SAndroid Build Coastguard Worker     bool useUserProvidedPtr;
65*e1eccf28SAndroid Build Coastguard Worker     bool uploadDeferred;
66*e1eccf28SAndroid Build Coastguard Worker 
67*e1eccf28SAndroid Build Coastguard Worker #if !defined(RS_VENDOR_LIB) && !defined(RS_COMPATIBILITY_LIB)
68*e1eccf28SAndroid Build Coastguard Worker     RsdFrameBufferObj * readBackFBO;
69*e1eccf28SAndroid Build Coastguard Worker #endif
70*e1eccf28SAndroid Build Coastguard Worker     ANativeWindow *wnd;
71*e1eccf28SAndroid Build Coastguard Worker     ANativeWindow *wndSurface;
72*e1eccf28SAndroid Build Coastguard Worker };
73*e1eccf28SAndroid Build Coastguard Worker 
74*e1eccf28SAndroid Build Coastguard Worker #ifndef RS_COMPATIBILITY_LIB
75*e1eccf28SAndroid Build Coastguard Worker GLenum rsdTypeToGLType(RsDataType t);
76*e1eccf28SAndroid Build Coastguard Worker GLenum rsdKindToGLFormat(RsDataKind k);
77*e1eccf28SAndroid Build Coastguard Worker #endif
78*e1eccf28SAndroid Build Coastguard Worker 
79*e1eccf28SAndroid Build Coastguard Worker 
80*e1eccf28SAndroid Build Coastguard Worker uint32_t rsdAllocationGrallocBits(const android::renderscript::Context *rsc,
81*e1eccf28SAndroid Build Coastguard Worker                                   android::renderscript::Allocation *alloc);
82*e1eccf28SAndroid Build Coastguard Worker bool rsdAllocationInit(const android::renderscript::Context *rsc,
83*e1eccf28SAndroid Build Coastguard Worker                        android::renderscript::Allocation *alloc,
84*e1eccf28SAndroid Build Coastguard Worker                        bool forceZero);
85*e1eccf28SAndroid Build Coastguard Worker #ifdef RS_COMPATIBILITY_LIB
86*e1eccf28SAndroid Build Coastguard Worker bool rsdAllocationInitStrided(const android::renderscript::Context *rsc,
87*e1eccf28SAndroid Build Coastguard Worker                               android::renderscript::Allocation *alloc,
88*e1eccf28SAndroid Build Coastguard Worker                               bool forceZero, size_t requiredAlignment);
89*e1eccf28SAndroid Build Coastguard Worker #endif
90*e1eccf28SAndroid Build Coastguard Worker bool rsdAllocationAdapterInit(const android::renderscript::Context *rsc,
91*e1eccf28SAndroid Build Coastguard Worker                               android::renderscript::Allocation *alloc);
92*e1eccf28SAndroid Build Coastguard Worker void rsdAllocationDestroy(const android::renderscript::Context *rsc,
93*e1eccf28SAndroid Build Coastguard Worker                           android::renderscript::Allocation *alloc);
94*e1eccf28SAndroid Build Coastguard Worker 
95*e1eccf28SAndroid Build Coastguard Worker void rsdAllocationResize(const android::renderscript::Context *rsc,
96*e1eccf28SAndroid Build Coastguard Worker                          const android::renderscript::Allocation *alloc,
97*e1eccf28SAndroid Build Coastguard Worker                          const android::renderscript::Type *newType, bool zeroNew);
98*e1eccf28SAndroid Build Coastguard Worker void rsdAllocationSyncAll(const android::renderscript::Context *rsc,
99*e1eccf28SAndroid Build Coastguard Worker                           const android::renderscript::Allocation *alloc,
100*e1eccf28SAndroid Build Coastguard Worker                           RsAllocationUsageType src);
101*e1eccf28SAndroid Build Coastguard Worker void rsdAllocationMarkDirty(const android::renderscript::Context *rsc,
102*e1eccf28SAndroid Build Coastguard Worker                             const android::renderscript::Allocation *alloc);
103*e1eccf28SAndroid Build Coastguard Worker void rsdAllocationSetSurface(const android::renderscript::Context *rsc,
104*e1eccf28SAndroid Build Coastguard Worker                             android::renderscript::Allocation *alloc, ANativeWindow *nw);
105*e1eccf28SAndroid Build Coastguard Worker void rsdAllocationIoSend(const android::renderscript::Context *rsc,
106*e1eccf28SAndroid Build Coastguard Worker                          android::renderscript::Allocation *alloc);
107*e1eccf28SAndroid Build Coastguard Worker void rsdAllocationIoReceive(const android::renderscript::Context *rsc,
108*e1eccf28SAndroid Build Coastguard Worker                             android::renderscript::Allocation *alloc);
109*e1eccf28SAndroid Build Coastguard Worker 
110*e1eccf28SAndroid Build Coastguard Worker void rsdAllocationData1D(const android::renderscript::Context *rsc,
111*e1eccf28SAndroid Build Coastguard Worker                          const android::renderscript::Allocation *alloc,
112*e1eccf28SAndroid Build Coastguard Worker                          uint32_t xoff, uint32_t lod, size_t count,
113*e1eccf28SAndroid Build Coastguard Worker                          const void *data, size_t sizeBytes);
114*e1eccf28SAndroid Build Coastguard Worker void rsdAllocationData2D(const android::renderscript::Context *rsc,
115*e1eccf28SAndroid Build Coastguard Worker                          const android::renderscript::Allocation *alloc,
116*e1eccf28SAndroid Build Coastguard Worker                          uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
117*e1eccf28SAndroid Build Coastguard Worker                          uint32_t w, uint32_t h,
118*e1eccf28SAndroid Build Coastguard Worker                          const void *data, size_t sizeBytes, size_t stride);
119*e1eccf28SAndroid Build Coastguard Worker void rsdAllocationData3D(const android::renderscript::Context *rsc,
120*e1eccf28SAndroid Build Coastguard Worker                          const android::renderscript::Allocation *alloc,
121*e1eccf28SAndroid Build Coastguard Worker                          uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t lod,
122*e1eccf28SAndroid Build Coastguard Worker                          uint32_t w, uint32_t h, uint32_t d, const void *data, size_t sizeBytes,
123*e1eccf28SAndroid Build Coastguard Worker                          size_t stride);
124*e1eccf28SAndroid Build Coastguard Worker 
125*e1eccf28SAndroid Build Coastguard Worker void rsdAllocationRead1D(const android::renderscript::Context *rsc,
126*e1eccf28SAndroid Build Coastguard Worker                          const android::renderscript::Allocation *alloc,
127*e1eccf28SAndroid Build Coastguard Worker                          uint32_t xoff, uint32_t lod, size_t count,
128*e1eccf28SAndroid Build Coastguard Worker                          void *data, size_t sizeBytes);
129*e1eccf28SAndroid Build Coastguard Worker void rsdAllocationRead2D(const android::renderscript::Context *rsc,
130*e1eccf28SAndroid Build Coastguard Worker                          const android::renderscript::Allocation *alloc,
131*e1eccf28SAndroid Build Coastguard Worker                          uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
132*e1eccf28SAndroid Build Coastguard Worker                          uint32_t w, uint32_t h,
133*e1eccf28SAndroid Build Coastguard Worker                          void *data, size_t sizeBytes, size_t stride);
134*e1eccf28SAndroid Build Coastguard Worker void rsdAllocationRead3D(const android::renderscript::Context *rsc,
135*e1eccf28SAndroid Build Coastguard Worker                          const android::renderscript::Allocation *alloc,
136*e1eccf28SAndroid Build Coastguard Worker                          uint32_t xoff, uint32_t yoff, uint32_t zoff, uint32_t lod,
137*e1eccf28SAndroid Build Coastguard Worker                          uint32_t w, uint32_t h, uint32_t d, void *data, size_t sizeBytes,
138*e1eccf28SAndroid Build Coastguard Worker                          size_t stride);
139*e1eccf28SAndroid Build Coastguard Worker 
140*e1eccf28SAndroid Build Coastguard Worker void * rsdAllocationLock1D(const android::renderscript::Context *rsc,
141*e1eccf28SAndroid Build Coastguard Worker                           const android::renderscript::Allocation *alloc);
142*e1eccf28SAndroid Build Coastguard Worker void rsdAllocationUnlock1D(const android::renderscript::Context *rsc,
143*e1eccf28SAndroid Build Coastguard Worker                           const android::renderscript::Allocation *alloc);
144*e1eccf28SAndroid Build Coastguard Worker 
145*e1eccf28SAndroid Build Coastguard Worker 
146*e1eccf28SAndroid Build Coastguard Worker void rsdAllocationData1D_alloc(const android::renderscript::Context *rsc,
147*e1eccf28SAndroid Build Coastguard Worker                                const android::renderscript::Allocation *dstAlloc,
148*e1eccf28SAndroid Build Coastguard Worker                                uint32_t dstXoff, uint32_t dstLod, size_t count,
149*e1eccf28SAndroid Build Coastguard Worker                                const android::renderscript::Allocation *srcAlloc,
150*e1eccf28SAndroid Build Coastguard Worker                                uint32_t srcXoff, uint32_t srcLod);
151*e1eccf28SAndroid Build Coastguard Worker void rsdAllocationData2D_alloc(const android::renderscript::Context *rsc,
152*e1eccf28SAndroid Build Coastguard Worker                                const android::renderscript::Allocation *dstAlloc,
153*e1eccf28SAndroid Build Coastguard Worker                                uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod,
154*e1eccf28SAndroid Build Coastguard Worker                                RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h,
155*e1eccf28SAndroid Build Coastguard Worker                                const android::renderscript::Allocation *srcAlloc,
156*e1eccf28SAndroid Build Coastguard Worker                                uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod,
157*e1eccf28SAndroid Build Coastguard Worker                                RsAllocationCubemapFace srcFace);
158*e1eccf28SAndroid Build Coastguard Worker void rsdAllocationData3D_alloc(const android::renderscript::Context *rsc,
159*e1eccf28SAndroid Build Coastguard Worker                                const android::renderscript::Allocation *dstAlloc,
160*e1eccf28SAndroid Build Coastguard Worker                                uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff,
161*e1eccf28SAndroid Build Coastguard Worker                                uint32_t dstLod,
162*e1eccf28SAndroid Build Coastguard Worker                                uint32_t w, uint32_t h, uint32_t d,
163*e1eccf28SAndroid Build Coastguard Worker                                const android::renderscript::Allocation *srcAlloc,
164*e1eccf28SAndroid Build Coastguard Worker                                uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff,
165*e1eccf28SAndroid Build Coastguard Worker                                uint32_t srcLod);
166*e1eccf28SAndroid Build Coastguard Worker 
167*e1eccf28SAndroid Build Coastguard Worker void rsdAllocationElementData(const android::renderscript::Context *rsc,
168*e1eccf28SAndroid Build Coastguard Worker                               const android::renderscript::Allocation *alloc,
169*e1eccf28SAndroid Build Coastguard Worker                               uint32_t x, uint32_t y, uint32_t z,
170*e1eccf28SAndroid Build Coastguard Worker                               const void *data, uint32_t elementOff, size_t sizeBytes);
171*e1eccf28SAndroid Build Coastguard Worker 
172*e1eccf28SAndroid Build Coastguard Worker void rsdAllocationElementRead(const android::renderscript::Context *rsc,
173*e1eccf28SAndroid Build Coastguard Worker                               const android::renderscript::Allocation *alloc,
174*e1eccf28SAndroid Build Coastguard Worker                               uint32_t x, uint32_t y, uint32_t z,
175*e1eccf28SAndroid Build Coastguard Worker                               void *data, uint32_t elementOff, size_t sizeBytes);
176*e1eccf28SAndroid Build Coastguard Worker 
177*e1eccf28SAndroid Build Coastguard Worker void rsdAllocationGenerateMipmaps(const android::renderscript::Context *rsc,
178*e1eccf28SAndroid Build Coastguard Worker                                   const android::renderscript::Allocation *alloc);
179*e1eccf28SAndroid Build Coastguard Worker 
180*e1eccf28SAndroid Build Coastguard Worker void rsdAllocationUpdateCachedObject(const android::renderscript::Context *rsc,
181*e1eccf28SAndroid Build Coastguard Worker                                      const android::renderscript::Allocation *alloc,
182*e1eccf28SAndroid Build Coastguard Worker                                      android::renderscript::rs_allocation *obj);
183*e1eccf28SAndroid Build Coastguard Worker 
184*e1eccf28SAndroid Build Coastguard Worker void rsdAllocationAdapterOffset(const android::renderscript::Context *rsc,
185*e1eccf28SAndroid Build Coastguard Worker                                 const android::renderscript::Allocation *alloc);
186*e1eccf28SAndroid Build Coastguard Worker 
187*e1eccf28SAndroid Build Coastguard Worker 
188*e1eccf28SAndroid Build Coastguard Worker #endif
189