blob: e3a5126383d0c439fc4fc3b565c2733db08479c5 [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>
22
23#include <GLES/gl.h>
24#include <GLES2/gl2.h>
25
Alex Sakhartchouka9495242011-06-16 11:05:13 -070026class RsdFrameBufferObj;
Jason Sams7ac2a4d2012-02-15 12:04:24 -080027struct ANativeWindowBuffer;
Alex Sakhartchouka9495242011-06-16 11:05:13 -070028
Jason Samseb4fe182011-05-26 16:33:01 -070029struct DrvAllocation {
30 // Is this a legal structure to be used as a texture source.
31 // Initially this will require 1D or 2D and color data
32 uint32_t textureID;
33
34 // Is this a legal structure to be used as a vertex source.
35 // Initially this will require 1D and x(yzw). Additional per element data
36 // is allowed.
37 uint32_t bufferID;
38
39 // Is this a legal structure to be used as an FBO render target
40 uint32_t renderTargetID;
41
42 uint8_t * mallocPtr;
43
44 GLenum glTarget;
Jason Samsa614ae12011-05-26 17:05:51 -070045 GLenum glType;
46 GLenum glFormat;
47
Jason Samseb4fe182011-05-26 16:33:01 -070048 bool uploadDeferred;
Alex Sakhartchouka9495242011-06-16 11:05:13 -070049
50 RsdFrameBufferObj * readBackFBO;
Jason Sams7ac2a4d2012-02-15 12:04:24 -080051 ANativeWindowBuffer *wndBuffer;
Jason Samseb4fe182011-05-26 16:33:01 -070052};
53
Jason Samsa614ae12011-05-26 17:05:51 -070054GLenum rsdTypeToGLType(RsDataType t);
55GLenum rsdKindToGLFormat(RsDataKind k);
56
57
Jason Samseb4fe182011-05-26 16:33:01 -070058bool rsdAllocationInit(const android::renderscript::Context *rsc,
59 android::renderscript::Allocation *alloc,
60 bool forceZero);
61void rsdAllocationDestroy(const android::renderscript::Context *rsc,
62 android::renderscript::Allocation *alloc);
63
64void rsdAllocationResize(const android::renderscript::Context *rsc,
65 const android::renderscript::Allocation *alloc,
66 const android::renderscript::Type *newType, bool zeroNew);
67void rsdAllocationSyncAll(const android::renderscript::Context *rsc,
68 const android::renderscript::Allocation *alloc,
69 RsAllocationUsageType src);
70void rsdAllocationMarkDirty(const android::renderscript::Context *rsc,
71 const android::renderscript::Allocation *alloc);
Jason Sams41e373d2012-01-13 14:01:20 -080072int32_t rsdAllocationInitSurfaceTexture(const android::renderscript::Context *rsc,
73 const android::renderscript::Allocation *alloc);
Jason Sams7ac2a4d2012-02-15 12:04:24 -080074void rsdAllocationSetSurfaceTexture(const android::renderscript::Context *rsc,
75 android::renderscript::Allocation *alloc, ANativeWindow *nw);
76void rsdAllocationIoSend(const android::renderscript::Context *rsc,
77 android::renderscript::Allocation *alloc);
78void rsdAllocationIoReceive(const android::renderscript::Context *rsc,
79 android::renderscript::Allocation *alloc);
Jason Samseb4fe182011-05-26 16:33:01 -070080
81void rsdAllocationData1D(const android::renderscript::Context *rsc,
82 const android::renderscript::Allocation *alloc,
83 uint32_t xoff, uint32_t lod, uint32_t count,
84 const void *data, uint32_t sizeBytes);
85void rsdAllocationData2D(const android::renderscript::Context *rsc,
86 const android::renderscript::Allocation *alloc,
87 uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
88 uint32_t w, uint32_t h,
89 const void *data, uint32_t sizeBytes);
90void rsdAllocationData3D(const android::renderscript::Context *rsc,
91 const android::renderscript::Allocation *alloc,
92 uint32_t xoff, uint32_t yoff, uint32_t zoff,
93 uint32_t lod, RsAllocationCubemapFace face,
94 uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes);
95
Alex Sakhartchouk74a82792011-06-14 11:13:19 -070096void rsdAllocationData1D_alloc(const android::renderscript::Context *rsc,
97 const android::renderscript::Allocation *dstAlloc,
98 uint32_t dstXoff, uint32_t dstLod, uint32_t count,
99 const android::renderscript::Allocation *srcAlloc,
100 uint32_t srcXoff, uint32_t srcLod);
101void rsdAllocationData2D_alloc(const android::renderscript::Context *rsc,
102 const android::renderscript::Allocation *dstAlloc,
103 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod,
104 RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h,
105 const android::renderscript::Allocation *srcAlloc,
106 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod,
107 RsAllocationCubemapFace srcFace);
108void rsdAllocationData3D_alloc(const android::renderscript::Context *rsc,
109 const android::renderscript::Allocation *dstAlloc,
110 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff,
111 uint32_t dstLod, RsAllocationCubemapFace dstFace,
112 uint32_t w, uint32_t h, uint32_t d,
113 const android::renderscript::Allocation *srcAlloc,
114 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff,
115 uint32_t srcLod, RsAllocationCubemapFace srcFace);
116
Jason Samseb4fe182011-05-26 16:33:01 -0700117void rsdAllocationElementData1D(const android::renderscript::Context *rsc,
118 const android::renderscript::Allocation *alloc,
119 uint32_t x,
120 const void *data, uint32_t elementOff, uint32_t sizeBytes);
121void rsdAllocationElementData2D(const android::renderscript::Context *rsc,
122 const android::renderscript::Allocation *alloc,
123 uint32_t x, uint32_t y,
124 const void *data, uint32_t elementOff, uint32_t sizeBytes);
125
126
127
128
129#endif