blob: 4fc4419f4420e1293c9a89fc7a75d471dc6908bb [file] [log] [blame]
Jason Sams7e8aae72011-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 Sakhartchouk8650c322011-06-16 11:05:13 -070026class RsdFrameBufferObj;
27
Jason Sams7e8aae72011-05-26 16:33:01 -070028struct DrvAllocation {
29 // Is this a legal structure to be used as a texture source.
30 // Initially this will require 1D or 2D and color data
31 uint32_t textureID;
32
33 // Is this a legal structure to be used as a vertex source.
34 // Initially this will require 1D and x(yzw). Additional per element data
35 // is allowed.
36 uint32_t bufferID;
37
38 // Is this a legal structure to be used as an FBO render target
39 uint32_t renderTargetID;
40
41 uint8_t * mallocPtr;
42
43 GLenum glTarget;
Jason Sams66db3ab2011-05-26 17:05:51 -070044 GLenum glType;
45 GLenum glFormat;
46
Jason Sams7e8aae72011-05-26 16:33:01 -070047 bool uploadDeferred;
Alex Sakhartchouk8650c322011-06-16 11:05:13 -070048
49 RsdFrameBufferObj * readBackFBO;
Jason Sams7e8aae72011-05-26 16:33:01 -070050};
51
Jason Sams66db3ab2011-05-26 17:05:51 -070052GLenum rsdTypeToGLType(RsDataType t);
53GLenum rsdKindToGLFormat(RsDataKind k);
54
55
Jason Sams7e8aae72011-05-26 16:33:01 -070056bool rsdAllocationInit(const android::renderscript::Context *rsc,
57 android::renderscript::Allocation *alloc,
58 bool forceZero);
59void rsdAllocationDestroy(const android::renderscript::Context *rsc,
60 android::renderscript::Allocation *alloc);
61
62void rsdAllocationResize(const android::renderscript::Context *rsc,
63 const android::renderscript::Allocation *alloc,
64 const android::renderscript::Type *newType, bool zeroNew);
65void rsdAllocationSyncAll(const android::renderscript::Context *rsc,
66 const android::renderscript::Allocation *alloc,
67 RsAllocationUsageType src);
68void rsdAllocationMarkDirty(const android::renderscript::Context *rsc,
69 const android::renderscript::Allocation *alloc);
70
71void rsdAllocationData1D(const android::renderscript::Context *rsc,
72 const android::renderscript::Allocation *alloc,
73 uint32_t xoff, uint32_t lod, uint32_t count,
74 const void *data, uint32_t sizeBytes);
75void rsdAllocationData2D(const android::renderscript::Context *rsc,
76 const android::renderscript::Allocation *alloc,
77 uint32_t xoff, uint32_t yoff, uint32_t lod, RsAllocationCubemapFace face,
78 uint32_t w, uint32_t h,
79 const void *data, uint32_t sizeBytes);
80void rsdAllocationData3D(const android::renderscript::Context *rsc,
81 const android::renderscript::Allocation *alloc,
82 uint32_t xoff, uint32_t yoff, uint32_t zoff,
83 uint32_t lod, RsAllocationCubemapFace face,
84 uint32_t w, uint32_t h, uint32_t d, const void *data, uint32_t sizeBytes);
85
Alex Sakhartchouk304b1f52011-06-14 11:13:19 -070086void rsdAllocationData1D_alloc(const android::renderscript::Context *rsc,
87 const android::renderscript::Allocation *dstAlloc,
88 uint32_t dstXoff, uint32_t dstLod, uint32_t count,
89 const android::renderscript::Allocation *srcAlloc,
90 uint32_t srcXoff, uint32_t srcLod);
91void rsdAllocationData2D_alloc(const android::renderscript::Context *rsc,
92 const android::renderscript::Allocation *dstAlloc,
93 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstLod,
94 RsAllocationCubemapFace dstFace, uint32_t w, uint32_t h,
95 const android::renderscript::Allocation *srcAlloc,
96 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcLod,
97 RsAllocationCubemapFace srcFace);
98void rsdAllocationData3D_alloc(const android::renderscript::Context *rsc,
99 const android::renderscript::Allocation *dstAlloc,
100 uint32_t dstXoff, uint32_t dstYoff, uint32_t dstZoff,
101 uint32_t dstLod, RsAllocationCubemapFace dstFace,
102 uint32_t w, uint32_t h, uint32_t d,
103 const android::renderscript::Allocation *srcAlloc,
104 uint32_t srcXoff, uint32_t srcYoff, uint32_t srcZoff,
105 uint32_t srcLod, RsAllocationCubemapFace srcFace);
106
Jason Sams7e8aae72011-05-26 16:33:01 -0700107void rsdAllocationElementData1D(const android::renderscript::Context *rsc,
108 const android::renderscript::Allocation *alloc,
109 uint32_t x,
110 const void *data, uint32_t elementOff, uint32_t sizeBytes);
111void rsdAllocationElementData2D(const android::renderscript::Context *rsc,
112 const android::renderscript::Allocation *alloc,
113 uint32_t x, uint32_t y,
114 const void *data, uint32_t elementOff, uint32_t sizeBytes);
115
116
117
118
119#endif