diff options
author | Android (Google) Code Review <android-gerrit@google.com> | 2009-12-15 13:00:25 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-12-15 13:00:25 -0800 |
commit | b686ec70445226d3f865b6e838b3f2cdf034ca31 (patch) | |
tree | 521af59aa15cbe1dec696067f0749c7e9f4006a3 /libs/rs/rsProgram.cpp | |
parent | e2f126cc30f2449ff32f343565c974ede9455f2c (diff) | |
parent | 0011bcf57ff711a221a3a4c73f2a79125111647d (diff) |
Merge change I0011bcf5
* changes:
Continue development of es2.0 user shader support for renderscript. This change cleans up ProgramVertex creation and adds support for passing input, output, and constant type info.
Diffstat (limited to 'libs/rs/rsProgram.cpp')
-rw-r--r-- | libs/rs/rsProgram.cpp | 81 |
1 files changed, 78 insertions, 3 deletions
diff --git a/libs/rs/rsProgram.cpp b/libs/rs/rsProgram.cpp index db40f1619185..ba27fd4196a7 100644 --- a/libs/rs/rsProgram.cpp +++ b/libs/rs/rsProgram.cpp @@ -24,7 +24,7 @@ using namespace android; using namespace android::renderscript; -Program::Program(Context *rsc, Element *in, Element *out) : ObjectBase(rsc) +Program::Program(Context *rsc) : ObjectBase(rsc) { mAllocFile = __FILE__; mAllocLine = __LINE__; @@ -33,13 +33,72 @@ Program::Program(Context *rsc, Element *in, Element *out) : ObjectBase(rsc) mAttribCount = 0; mUniformCount = 0; - mElementIn.set(in); - mElementOut.set(out); + mInputElements = NULL; + mOutputElements = NULL; + mConstantTypes = NULL; + mInputCount = 0; + mOutputCount = 0; + mConstantCount = 0; +} + +Program::Program(Context *rsc, const char * shaderText, uint32_t shaderLength, + const uint32_t * params, uint32_t paramLength) : + ObjectBase(rsc) +{ + mAllocFile = __FILE__; + mAllocLine = __LINE__; + mDirty = true; + mShaderID = 0; + mAttribCount = 0; + mUniformCount = 0; + + mInputCount = 0; + mOutputCount = 0; + mConstantCount = 0; + + for (uint32_t ct=0; ct < paramLength; ct+=2) { + if (params[ct] == RS_PROGRAM_PARAM_INPUT) { + mInputCount++; + } + if (params[ct] == RS_PROGRAM_PARAM_OUTPUT) { + mOutputCount++; + } + if (params[ct] == RS_PROGRAM_PARAM_CONSTANT) { + mConstantCount++; + } + } + + mInputElements = new ObjectBaseRef<Element>[mInputCount]; + mOutputElements = new ObjectBaseRef<Element>[mOutputCount]; + mConstantTypes = new ObjectBaseRef<Type>[mConstantCount]; + + uint32_t input = 0; + uint32_t output = 0; + uint32_t constant = 0; + for (uint32_t ct=0; ct < paramLength; ct+=2) { + if (params[ct] == RS_PROGRAM_PARAM_INPUT) { + mInputElements[input++].set(reinterpret_cast<Element *>(params[ct+1])); + } + if (params[ct] == RS_PROGRAM_PARAM_OUTPUT) { + mOutputElements[output++].set(reinterpret_cast<Element *>(params[ct+1])); + } + if (params[ct] == RS_PROGRAM_PARAM_CONSTANT) { + mConstantTypes[constant++].set(reinterpret_cast<Type *>(params[ct+1])); + } + } + mUserShader.setTo(shaderText, shaderLength); } Program::~Program() { bindAllocation(NULL); + + delete[] mInputElements; + delete[] mOutputElements; + delete[] mConstantTypes; + mInputCount = 0; + mOutputCount = 0; + mConstantCount = 0; } @@ -102,3 +161,19 @@ void Program::setShader(const char *txt, uint32_t len) mUserShader.setTo(txt, len); } + + +namespace android { +namespace renderscript { + + +void rsi_ProgramBindConstants(Context *rsc, RsProgram vp, uint32_t slot, RsAllocation constants) +{ + Program *p = static_cast<Program *>(vp); + p->bindAllocation(static_cast<Allocation *>(constants)); +} + + +} +} + |