Merge "Adding ability to bind constants to shaders." into graphics-dev

This commit is contained in:
Alex Sakhartchouk
2012-01-10 14:39:59 -08:00
committed by Android (Google) Code Review
4 changed files with 48 additions and 0 deletions

View File

@@ -90,6 +90,16 @@ static void SC_BindTexture(ProgramFragment *pf, uint32_t slot, Allocation *a) {
rsrBindTexture(rsc, sc, pf, slot, a);
}
static void SC_BindVertexConstant(ProgramVertex *pv, uint32_t slot, Allocation *a) {
GET_TLS();
rsrBindConstant(rsc, sc, pv, slot, a);
}
static void SC_BindFragmentConstant(ProgramFragment *pf, uint32_t slot, Allocation *a) {
GET_TLS();
rsrBindConstant(rsc, sc, pf, slot, a);
}
static void SC_BindSampler(ProgramFragment *pf, uint32_t slot, Sampler *s) {
GET_TLS();
rsrBindSampler(rsc, sc, pf, slot, s);
@@ -591,6 +601,8 @@ static RsdSymbolTable gSyms[] = {
{ "_Z20rsgBindProgramRaster17rs_program_raster", (void *)&SC_BindProgramRaster, false },
{ "_Z14rsgBindSampler19rs_program_fragmentj10rs_sampler", (void *)&SC_BindSampler, false },
{ "_Z14rsgBindTexture19rs_program_fragmentj13rs_allocation", (void *)&SC_BindTexture, false },
{ "_Z15rsgBindConstant19rs_program_fragmentj13rs_allocation", (void *)&SC_BindFragmentConstant, false },
{ "_Z15rsgBindConstant17rs_program_vertexj13rs_allocation", (void *)&SC_BindVertexConstant, false },
{ "_Z36rsgProgramVertexLoadProjectionMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadProjectionMatrix, false },
{ "_Z31rsgProgramVertexLoadModelMatrixPK12rs_matrix4x4", (void *)&SC_VpLoadModelMatrix, false },

View File

@@ -30,6 +30,8 @@ namespace renderscript {
//////////////////////////////////////////////////////////////////////////////
void rsrBindTexture(Context *, Script *, ProgramFragment *, uint32_t slot, Allocation *);
void rsrBindConstant(Context *, Script *, ProgramFragment *, uint32_t slot, Allocation *);
void rsrBindConstant(Context *, Script *, ProgramVertex*, uint32_t slot, Allocation *);
void rsrBindSampler(Context *, Script *, ProgramFragment *, uint32_t slot, Sampler *);
void rsrBindProgramStore(Context *, Script *, ProgramStore *);
void rsrBindProgramFragment(Context *, Script *, ProgramFragment *);

View File

@@ -50,6 +50,18 @@ void rsrBindTexture(Context *rsc, Script *sc, ProgramFragment *pf, uint32_t slot
pf->bindTexture(rsc, slot, a);
}
void rsrBindConstant(Context *rsc, Script *sc, ProgramFragment *pf, uint32_t slot, Allocation *a) {
CHECK_OBJ_OR_NULL(a);
CHECK_OBJ(pf);
pf->bindAllocation(rsc, a, slot);
}
void rsrBindConstant(Context *rsc, Script *sc, ProgramVertex *pf, uint32_t slot, Allocation *a) {
CHECK_OBJ_OR_NULL(a);
CHECK_OBJ(pf);
pf->bindAllocation(rsc, a, slot);
}
void rsrBindSampler(Context *rsc, Script *sc, ProgramFragment *pf, uint32_t slot, Sampler *s) {
CHECK_OBJ_OR_NULL(vs);
CHECK_OBJ(vpf);

View File

@@ -368,6 +368,28 @@ extern void __attribute__((overloadable))
extern void __attribute__((overloadable))
rsgProgramFragmentConstantColor(rs_program_fragment pf, float r, float g, float b, float a);
/**
* Bind a new Allocation object to a ProgramFragment. The
* Allocation must be a valid constant input for the Program.
*
* @param ps program object
* @param slot index of the constant buffer on the program
* @param c constants to bind
*/
extern void __attribute__((overloadable))
rsgBindConstant(rs_program_fragment ps, uint slot, rs_allocation c);
/**
* Bind a new Allocation object to a ProgramVertex. The
* Allocation must be a valid constant input for the Program.
*
* @param pv program object
* @param slot index of the constant buffer on the program
* @param c constants to bind
*/
extern void __attribute__((overloadable))
rsgBindConstant(rs_program_vertex pv, uint slot, rs_allocation c);
/**
* Get the width of the current rendering surface.
*