diff options
author | Alex Sakhartchouk <alexst@google.com> | 2012-02-15 16:21:46 -0800 |
---|---|---|
committer | Alex Sakhartchouk <alexst@google.com> | 2012-02-15 16:21:46 -0800 |
commit | 2123b46ba85adb2cfb78068f8368e830640118d3 (patch) | |
tree | a941f2bca3185b5ad067b0593e8a54f9a07497cb /graphics/java/android/renderscript/Program.java | |
parent | a3f154324ae74bc8db8c7751e3c83b6be342eace (diff) |
Piping texture names through shader builder.
Fixing uint size_t mismatch.
Change-Id: Ia7c8bd9f829deaa50e1cc381ccd50f29676bbdfb
Diffstat (limited to 'graphics/java/android/renderscript/Program.java')
-rw-r--r-- | graphics/java/android/renderscript/Program.java | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/graphics/java/android/renderscript/Program.java b/graphics/java/android/renderscript/Program.java index 3f769eecdd97..4d60ac860621 100644 --- a/graphics/java/android/renderscript/Program.java +++ b/graphics/java/android/renderscript/Program.java @@ -69,6 +69,7 @@ public class Program extends BaseObj { Element mOutputs[]; Type mConstants[]; TextureType mTextures[]; + String mTextureNames[]; int mTextureCount; String mShader; @@ -111,6 +112,16 @@ public class Program extends BaseObj { } /** + * @hide + */ + public String getTextureName(int slot) { + if ((slot < 0) || (slot >= mTextureCount)) { + throw new IllegalArgumentException("Slot ID out of range."); + } + return mTextureNames[slot]; + } + + /** * Binds a constant buffer to be used as uniform inputs to the * program * @@ -180,6 +191,7 @@ public class Program extends BaseObj { Type mConstants[]; Type mTextures[]; TextureType mTextureTypes[]; + String mTextureNames[]; int mInputCount; int mOutputCount; int mConstantCount; @@ -197,6 +209,7 @@ public class Program extends BaseObj { mConstantCount = 0; mTextureCount = 0; mTextureTypes = new TextureType[MAX_TEXTURE]; + mTextureNames = new String[MAX_TEXTURE]; } /** @@ -300,10 +313,28 @@ public class Program extends BaseObj { * @return self */ public BaseProgramBuilder addTexture(TextureType texType) throws IllegalArgumentException { + addTexture(texType, "Tex" + mTextureCount); + return this; + } + + /** + * @hide + * Adds a texture input to the Program + * + * @param texType describes that the texture to append it (2D, + * Cubemap, etc.) + * @param texName what the texture should be called in the + * shader + * @return self + */ + public BaseProgramBuilder addTexture(TextureType texType, String texName) + throws IllegalArgumentException { if(mTextureCount >= MAX_TEXTURE) { throw new IllegalArgumentException("Max texture count exceeded."); } - mTextureTypes[mTextureCount ++] = texType; + mTextureTypes[mTextureCount] = texType; + mTextureNames[mTextureCount] = texName; + mTextureCount ++; return this; } @@ -317,6 +348,8 @@ public class Program extends BaseObj { p.mTextureCount = mTextureCount; p.mTextures = new TextureType[mTextureCount]; System.arraycopy(mTextureTypes, 0, p.mTextures, 0, mTextureCount); + p.mTextureNames = new String[mTextureCount]; + System.arraycopy(mTextureNames, 0, p.mTextureNames, 0, mTextureCount); } } |