diff options
Diffstat (limited to 'libs/rs/rsProgram.h')
-rw-r--r-- | libs/rs/rsProgram.h | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/libs/rs/rsProgram.h b/libs/rs/rsProgram.h index 86f85fb..c93033b 100644 --- a/libs/rs/rsProgram.h +++ b/libs/rs/rsProgram.h @@ -23,29 +23,30 @@ // --------------------------------------------------------------------------- namespace android { namespace renderscript { - - class ShaderCache; +#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); @@ -71,6 +72,12 @@ protected: 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 *count, const char *prefix); ObjectBaseRef<Allocation> mConstants[MAX_UNIFORMS]; @@ -91,8 +98,8 @@ 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; bool loadShader(Context *, uint32_t type); |