Piping texture names through shader builder.
Fixing uint size_t mismatch.
Change-Id: Ia7c8bd9f829deaa50e1cc381ccd50f29676bbdfb
diff --git a/graphics/java/android/renderscript/Program.java b/graphics/java/android/renderscript/Program.java
index 3f769ee..4d60ac8 100644
--- a/graphics/java/android/renderscript/Program.java
+++ b/graphics/java/android/renderscript/Program.java
@@ -69,6 +69,7 @@
Element mOutputs[];
Type mConstants[];
TextureType mTextures[];
+ String mTextureNames[];
int mTextureCount;
String mShader;
@@ -111,6 +112,16 @@
}
/**
+ * @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 @@
Type mConstants[];
Type mTextures[];
TextureType mTextureTypes[];
+ String mTextureNames[];
int mInputCount;
int mOutputCount;
int mConstantCount;
@@ -197,6 +209,7 @@
mConstantCount = 0;
mTextureCount = 0;
mTextureTypes = new TextureType[MAX_TEXTURE];
+ mTextureNames = new String[MAX_TEXTURE];
}
/**
@@ -300,10 +313,28 @@
* @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 @@
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);
}
}