blob: abd461b55cf7dbf3c3766acfd7de675d4f918402 [file] [log] [blame]
Jason Samsd19f10d2009-05-22 14:03:28 -07001/*
2 * Copyright (C) 2009 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 ANDROID_RS_PROGRAM_H
18#define ANDROID_RS_PROGRAM_H
19
20#include "rsObjectBase.h"
21#include "rsElement.h"
22
23// ---------------------------------------------------------------------------
24namespace android {
25namespace renderscript {
26
27
Jason Samsbb51c402009-11-25 13:22:07 -080028class ShaderCache;
Jason Samsd19f10d2009-05-22 14:03:28 -070029
30class Program : public ObjectBase
31{
32public:
Jason Samsbb51c402009-11-25 13:22:07 -080033 const static uint32_t MAX_ATTRIBS = 8;
34 const static uint32_t MAX_UNIFORMS = 16;
35
Jason Samsa9e7a052009-09-25 14:51:22 -070036 Program(Context *, Element *in, Element *out);
Jason Samsd19f10d2009-05-22 14:03:28 -070037 virtual ~Program();
38
Jason Sams9bee51c2009-08-05 13:57:03 -070039 void bindAllocation(Allocation *);
Jason Samsbb51c402009-11-25 13:22:07 -080040 virtual void createShader();
41
42 uint32_t getShaderID() const {return mShaderID;}
Jason Sams54c0ec12009-11-30 14:49:55 -080043 void setShader(const char *, uint32_t len);
Jason Samsbb51c402009-11-25 13:22:07 -080044
45 uint32_t getAttribCount() const {return mAttribCount;}
46 uint32_t getUniformCount() const {return mUniformCount;}
47 const String8 & getAttribName(uint32_t i) const {return mAttribNames[i];}
48 const String8 & getUniformName(uint32_t i) const {return mUniformNames[i];}
Jason Sams9bee51c2009-08-05 13:57:03 -070049
Jason Samsd19f10d2009-05-22 14:03:28 -070050protected:
51 // Components not listed in "in" will be passed though
52 // unless overwritten by components in out.
53 ObjectBaseRef<Element> mElementIn;
54 ObjectBaseRef<Element> mElementOut;
55
56 ObjectBaseRef<Allocation> mConstants;
57
Jason Sams9bee51c2009-08-05 13:57:03 -070058 mutable bool mDirty;
Jason Samsbb51c402009-11-25 13:22:07 -080059 String8 mShader;
Jason Sams54c0ec12009-11-30 14:49:55 -080060 String8 mUserShader;
Jason Samsbb51c402009-11-25 13:22:07 -080061 uint32_t mShaderID;
Jason Sams741a6102009-10-15 18:45:45 -070062
Jason Samsbb51c402009-11-25 13:22:07 -080063 uint32_t mAttribCount;
64 uint32_t mUniformCount;
65 String8 mAttribNames[MAX_ATTRIBS];
66 String8 mUniformNames[MAX_UNIFORMS];
67
68 bool loadShader(uint32_t type);
Jason Sams741a6102009-10-15 18:45:45 -070069
70public:
Jason Sams83f1c632009-10-26 15:19:28 -070071 void forceDirty() const {mDirty = true;}
Jason Samsd19f10d2009-05-22 14:03:28 -070072};
73
74
75
76}
77}
78#endif
79
80
81