summaryrefslogtreecommitdiffstats
path: root/libs/rs/rsProgram.h
diff options
context:
space:
mode:
Diffstat (limited to 'libs/rs/rsProgram.h')
-rw-r--r--libs/rs/rsProgram.h51
1 files changed, 29 insertions, 22 deletions
diff --git a/libs/rs/rsProgram.h b/libs/rs/rsProgram.h
index 86f85fb..c48464d 100644
--- a/libs/rs/rsProgram.h
+++ b/libs/rs/rsProgram.h
@@ -23,29 +23,27 @@
// ---------------------------------------------------------------------------
namespace android {
namespace renderscript {
-
-
class ShaderCache;
-class Program : public ObjectBase
-{
+#define RS_SHADER_INTERNAL "//rs_shader_internal\n"
+#define RS_SHADER_ATTR "ATTRIB_"
+#define RS_SHADER_UNI "UNI_"
+
+class Program : public ObjectBase {
public:
- const static uint32_t MAX_ATTRIBS = 8;
- const static uint32_t MAX_UNIFORMS = 16;
- const static uint32_t MAX_TEXTURE = 2;
Program(Context *);
Program(Context *, const char * shaderText, uint32_t shaderLength,
const uint32_t * params, uint32_t paramLength);
virtual ~Program();
- void bindAllocation(Allocation *, uint32_t slot);
+ void bindAllocation(Context *, Allocation *, uint32_t slot);
virtual void createShader();
- bool isUserProgram() const {return mUserShader.size() > 0;}
+ bool isUserProgram() const {return !mIsInternal;}
- void bindTexture(uint32_t slot, Allocation *);
- void bindSampler(uint32_t slot, Sampler *);
+ void bindTexture(Context *, uint32_t slot, Allocation *);
+ void bindSampler(Context *, uint32_t slot, Sampler *);
uint32_t getShaderID() const {return mShaderID;}
void setShader(const char *, uint32_t len);
@@ -54,12 +52,14 @@ public:
uint32_t getUniformCount() const {return mUniformCount;}
const String8 & getAttribName(uint32_t i) const {return mAttribNames[i];}
const String8 & getUniformName(uint32_t i) const {return mUniformNames[i];}
+ uint32_t getUniformArraySize(uint32_t i) const {return mUniformArraySizes[i];}
String8 getGLSLInputString() const;
String8 getGLSLOutputString() const;
String8 getGLSLConstantString() const;
bool isValid() const {return mIsValid;}
+ void forceDirty() const {mDirty = true;}
protected:
// Components not listed in "in" will be passed though
@@ -67,12 +67,19 @@ protected:
ObjectBaseRef<Element> *mInputElements;
ObjectBaseRef<Element> *mOutputElements;
ObjectBaseRef<Type> *mConstantTypes;
+ ObjectBaseRef<Allocation> *mConstants;
uint32_t mInputCount;
uint32_t mOutputCount;
uint32_t mConstantCount;
bool mIsValid;
+ bool mIsInternal;
+
+ // Applies to vertex and fragment shaders only
+ void appendUserConstants();
+ void setupUserConstants(Context *rsc, ShaderCache *sc, bool isFragment);
+ void initAddUserElement(const Element *e, String8 *names, uint32_t *arrayLengths, uint32_t *count, const char *prefix);
- ObjectBaseRef<Allocation> mConstants[MAX_UNIFORMS];
+ void initAttribAndUniformArray();
mutable bool mDirty;
String8 mShader;
@@ -82,8 +89,13 @@ protected:
uint32_t mTextureCount;
uint32_t mAttribCount;
uint32_t mUniformCount;
- String8 mAttribNames[MAX_ATTRIBS];
- String8 mUniformNames[MAX_UNIFORMS];
+ String8 *mAttribNames;
+ String8 *mUniformNames;
+ uint32_t *mUniformArraySizes;
+
+ void logUniform(const Element *field, const float *fd, uint32_t arraySize );
+ void setUniform(Context *rsc, const Element *field, const float *fd, int32_t slot, uint32_t arraySize );
+ void initMemberVars();
// The difference between Textures and Constants is how they are accessed
// Texture lookups go though a sampler which in effect converts normalized
@@ -91,17 +103,12 @@ protected:
// and filtered.
//
// Constants are strictly accessed by programetic loads.
- ObjectBaseRef<Allocation> mTextures[MAX_TEXTURE];
- ObjectBaseRef<Sampler> mSamplers[MAX_TEXTURE];
-
+ ObjectBaseRef<Allocation> *mTextures;
+ ObjectBaseRef<Sampler> *mSamplers;
+ RsTextureTarget *mTextureTargets;
bool loadShader(Context *, uint32_t type);
-
-public:
- void forceDirty() const {mDirty = true;}
};
-
-
}
}
#endif