FileDocCategorySizeDatePackage
Program.javaAPI DocAndroid 5.1 API11822Thu Mar 12 22:22:42 GMT 2015android.renderscript

Program

public class Program extends BaseObj
hide
Program is a base class for all the objects that modify various stages of the graphics pipeline

Fields Summary
static final int
MAX_INPUT
static final int
MAX_OUTPUT
static final int
MAX_CONSTANT
static final int
MAX_TEXTURE
Element[]
mInputs
Element[]
mOutputs
Type[]
mConstants
TextureType[]
mTextures
String[]
mTextureNames
int
mTextureCount
String
mShader
Constructors Summary
Program(long id, RenderScript rs)

        super(id, rs);
    
Methods Summary
public voidbindConstants(Allocation a, int slot)
Binds a constant buffer to be used as uniform inputs to the program

param
a allocation containing uniform data
param
slot index within the program's list of constant buffer allocations

        if (slot < 0 || slot >= mConstants.length) {
            throw new IllegalArgumentException("Slot ID out of range.");
        }
        if (a != null &&
            a.getType().getID(mRS) != mConstants[slot].getID(mRS)) {
            throw new IllegalArgumentException("Allocation type does not match slot type.");
        }
        long id = a != null ? a.getID(mRS) : 0;
        mRS.nProgramBindConstants(getID(mRS), slot, id);
    
public voidbindSampler(Sampler vs, int slot)
Binds an object that describes how a texture at the corresponding location is sampled

param
vs sampler for a corresponding texture
param
slot index within the program's list of textures to use the sampler on

        mRS.validate();
        if ((slot < 0) || (slot >= mTextureCount)) {
            throw new IllegalArgumentException("Slot ID out of range.");
        }

        long id = vs != null ? vs.getID(mRS) : 0;
        mRS.nProgramBindSampler(getID(mRS), slot, id);
    
public voidbindTexture(Allocation va, int slot)
Binds a texture to be used in the program

param
va allocation containing texture data
param
slot index within the program's list of textures

        mRS.validate();
        if ((slot < 0) || (slot >= mTextureCount)) {
            throw new IllegalArgumentException("Slot ID out of range.");
        }
        if (va != null && va.getType().hasFaces() &&
            mTextures[slot] != TextureType.TEXTURE_CUBE) {
            throw new IllegalArgumentException("Cannot bind cubemap to 2d texture slot");
        }

        long id = va != null ? va.getID(mRS) : 0;
        mRS.nProgramBindTexture(getID(mRS), slot, id);
    
public TypegetConstant(int slot)
Returns the type of the constant buffer used in the program object. It could be used to query internal elements or create an allocation to store constant data.

param
slot index of the constant input type to return
return
constant input type

        if (slot < 0 || slot >= mConstants.length) {
            throw new IllegalArgumentException("Slot ID out of range.");
        }
        return mConstants[slot];
    
public intgetConstantCount()
Program object can have zero or more constant allocations associated with it. This method returns the total count.

return
number of constant input types

        return mConstants != null ? mConstants.length : 0;
    
public intgetTextureCount()
Returns the number of textures used in this program object

return
number of texture inputs

        return mTextureCount;
    
public java.lang.StringgetTextureName(int slot)
Returns the name of the texture input at a given slot. e.g. tex0, diffuse, spec

param
slot index of the texture input
return
texture input name

        if ((slot < 0) || (slot >= mTextureCount)) {
            throw new IllegalArgumentException("Slot ID out of range.");
        }
        return mTextureNames[slot];
    
public android.renderscript.Program$TextureTypegetTextureType(int slot)
Returns the type of texture at a given slot. e.g. 2D or Cube

param
slot index of the texture input
return
texture input type

        if ((slot < 0) || (slot >= mTextureCount)) {
            throw new IllegalArgumentException("Slot ID out of range.");
        }
        return mTextures[slot];