diff --git a/libs/rs/driver/rsdRuntimeStubs.cpp b/libs/rs/driver/rsdRuntimeStubs.cpp index 506308ff5f5e2..44bfb1c8fe9f3 100644 --- a/libs/rs/driver/rsdRuntimeStubs.cpp +++ b/libs/rs/driver/rsdRuntimeStubs.cpp @@ -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 }, diff --git a/libs/rs/rsRuntime.h b/libs/rs/rsRuntime.h index b0869f6e1f183..3bded620e0d3c 100644 --- a/libs/rs/rsRuntime.h +++ b/libs/rs/rsRuntime.h @@ -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 *); diff --git a/libs/rs/rsScriptC_LibGL.cpp b/libs/rs/rsScriptC_LibGL.cpp index 742da96b5f503..dece3636b1c83 100644 --- a/libs/rs/rsScriptC_LibGL.cpp +++ b/libs/rs/rsScriptC_LibGL.cpp @@ -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); diff --git a/libs/rs/scriptc/rs_graphics.rsh b/libs/rs/scriptc/rs_graphics.rsh index 64fcd23cc65cd..7fdebdcd0468d 100644 --- a/libs/rs/scriptc/rs_graphics.rsh +++ b/libs/rs/scriptc/rs_graphics.rsh @@ -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. *