Skip to content

Commit a744ead

Browse files
Alex SakhartchoukAndroid (Google) Code Review
authored andcommitted
Merge "Adding getter functions for script side RS objects. Multiproject change involving on device linker"
2 parents 6aa1e80 + 7e6aac1 commit a744ead

File tree

11 files changed

+704
-39
lines changed

11 files changed

+704
-39
lines changed

libs/rs/rsProgramRaster.h

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,16 @@ namespace android {
2424
namespace renderscript {
2525

2626
class ProgramRasterState;
27-
27+
/*****************************************************************************
28+
* CAUTION
29+
*
30+
* Any layout changes for this class may require a corresponding change to be
31+
* made to frameworks/compile/libbcc/lib/ScriptCRT/rs_core.c, which contains
32+
* a partial copy of the information below.
33+
*
34+
*****************************************************************************/
2835
class ProgramRaster : public ProgramBase {
2936
public:
30-
virtual void setup(const Context *, ProgramRasterState *);
31-
virtual void serialize(OStream *stream) const;
32-
virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_RASTER; }
33-
static ProgramRaster *createFromStream(Context *rsc, IStream *stream);
34-
35-
static ObjectBaseRef<ProgramRaster> getProgramRaster(Context *rsc,
36-
bool pointSprite,
37-
RsCullMode cull);
3837
struct Hal {
3938
mutable void *drv;
4039

@@ -46,6 +45,14 @@ class ProgramRaster : public ProgramBase {
4645
};
4746
Hal mHal;
4847

48+
virtual void setup(const Context *, ProgramRasterState *);
49+
virtual void serialize(OStream *stream) const;
50+
virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_RASTER; }
51+
static ProgramRaster *createFromStream(Context *rsc, IStream *stream);
52+
53+
static ObjectBaseRef<ProgramRaster> getProgramRaster(Context *rsc,
54+
bool pointSprite,
55+
RsCullMode cull);
4956
protected:
5057
virtual void preDestroy() const;
5158
virtual ~ProgramRaster();

libs/rs/rsProgramStore.h

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,16 @@ namespace android {
2525
namespace renderscript {
2626

2727
class ProgramStoreState;
28-
28+
/*****************************************************************************
29+
* CAUTION
30+
*
31+
* Any layout changes for this class may require a corresponding change to be
32+
* made to frameworks/compile/libbcc/lib/ScriptCRT/rs_core.c, which contains
33+
* a partial copy of the information below.
34+
*
35+
*****************************************************************************/
2936
class ProgramStore : public ProgramBase {
3037
public:
31-
virtual void setup(const Context *, ProgramStoreState *);
32-
33-
virtual void serialize(OStream *stream) const;
34-
virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_STORE; }
35-
static ProgramStore *createFromStream(Context *rsc, IStream *stream);
36-
static ObjectBaseRef<ProgramStore> getProgramStore(Context *,
37-
bool colorMaskR, bool colorMaskG,
38-
bool colorMaskB, bool colorMaskA,
39-
bool depthMask, bool ditherEnable,
40-
RsBlendSrcFunc srcFunc, RsBlendDstFunc destFunc,
41-
RsDepthFunc depthFunc);
42-
43-
void init();
44-
4538
struct Hal {
4639
mutable void *drv;
4740

@@ -64,6 +57,18 @@ class ProgramStore : public ProgramBase {
6457
};
6558
Hal mHal;
6659

60+
virtual void setup(const Context *, ProgramStoreState *);
61+
62+
virtual void serialize(OStream *stream) const;
63+
virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_STORE; }
64+
static ProgramStore *createFromStream(Context *rsc, IStream *stream);
65+
static ObjectBaseRef<ProgramStore> getProgramStore(Context *,
66+
bool colorMaskR, bool colorMaskG,
67+
bool colorMaskB, bool colorMaskA,
68+
bool depthMask, bool ditherEnable,
69+
RsBlendSrcFunc srcFunc, RsBlendDstFunc destFunc,
70+
RsDepthFunc depthFunc);
71+
void init();
6772
protected:
6873
virtual void preDestroy() const;
6974
virtual ~ProgramStore();

libs/rs/rsSampler.h

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,16 @@ namespace renderscript {
2727
const static uint32_t RS_MAX_SAMPLER_SLOT = 16;
2828

2929
class SamplerState;
30-
30+
/*****************************************************************************
31+
* CAUTION
32+
*
33+
* Any layout changes for this class may require a corresponding change to be
34+
* made to frameworks/compile/libbcc/lib/ScriptCRT/rs_core.c, which contains
35+
* a partial copy of the information below.
36+
*
37+
*****************************************************************************/
3138
class Sampler : public ObjectBase {
3239
public:
33-
static ObjectBaseRef<Sampler> getSampler(Context *,
34-
RsSamplerValue magFilter,
35-
RsSamplerValue minFilter,
36-
RsSamplerValue wrapS,
37-
RsSamplerValue wrapT,
38-
RsSamplerValue wrapR,
39-
float aniso = 1.0f);
40-
void bindToContext(SamplerState *, uint32_t slot);
41-
void unbindFromContext(SamplerState *);
42-
43-
virtual void serialize(OStream *stream) const;
44-
virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_SAMPLER; }
45-
static Sampler *createFromStream(Context *rsc, IStream *stream);
46-
4740
struct Hal {
4841
mutable void *drv;
4942

@@ -59,6 +52,20 @@ class Sampler : public ObjectBase {
5952
};
6053
Hal mHal;
6154

55+
static ObjectBaseRef<Sampler> getSampler(Context *,
56+
RsSamplerValue magFilter,
57+
RsSamplerValue minFilter,
58+
RsSamplerValue wrapS,
59+
RsSamplerValue wrapT,
60+
RsSamplerValue wrapR,
61+
float aniso = 1.0f);
62+
void bindToContext(SamplerState *, uint32_t slot);
63+
void unbindFromContext(SamplerState *);
64+
65+
virtual void serialize(OStream *stream) const;
66+
virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_SAMPLER; }
67+
static Sampler *createFromStream(Context *rsc, IStream *stream);
68+
6269
protected:
6370
int32_t mBoundSlot;
6471

libs/rs/scriptc/rs_graphics.rsh

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,55 @@
2323
#ifndef __RS_GRAPHICS_RSH__
2424
#define __RS_GRAPHICS_RSH__
2525

26+
// These are API 15 once it get official
27+
typedef enum {
28+
RS_DEPTH_FUNC_ALWAYS,
29+
RS_DEPTH_FUNC_LESS,
30+
RS_DEPTH_FUNC_LEQUAL,
31+
RS_DEPTH_FUNC_GREATER,
32+
RS_DEPTH_FUNC_GEQUAL,
33+
RS_DEPTH_FUNC_EQUAL,
34+
RS_DEPTH_FUNC_NOTEQUAL
35+
} rs_depth_func;
36+
37+
typedef enum {
38+
RS_BLEND_SRC_ZERO, // 0
39+
RS_BLEND_SRC_ONE, // 1
40+
RS_BLEND_SRC_DST_COLOR, // 2
41+
RS_BLEND_SRC_ONE_MINUS_DST_COLOR, // 3
42+
RS_BLEND_SRC_SRC_ALPHA, // 4
43+
RS_BLEND_SRC_ONE_MINUS_SRC_ALPHA, // 5
44+
RS_BLEND_SRC_DST_ALPHA, // 6
45+
RS_BLEND_SRC_ONE_MINUS_DST_ALPHA, // 7
46+
RS_BLEND_SRC_SRC_ALPHA_SATURATE // 8
47+
} rs_blend_src_func;
48+
49+
typedef enum {
50+
RS_BLEND_DST_ZERO, // 0
51+
RS_BLEND_DST_ONE, // 1
52+
RS_BLEND_DST_SRC_COLOR, // 2
53+
RS_BLEND_DST_ONE_MINUS_SRC_COLOR, // 3
54+
RS_BLEND_DST_SRC_ALPHA, // 4
55+
RS_BLEND_DST_ONE_MINUS_SRC_ALPHA, // 5
56+
RS_BLEND_DST_DST_ALPHA, // 6
57+
RS_BLEND_DST_ONE_MINUS_DST_ALPHA // 7
58+
} rs_blend_dst_func;
59+
60+
typedef enum {
61+
RS_CULL_BACK,
62+
RS_CULL_FRONT,
63+
RS_CULL_NONE
64+
} rs_cull_mode;
65+
66+
typedef enum {
67+
RS_SAMPLER_NEAREST,
68+
RS_SAMPLER_LINEAR,
69+
RS_SAMPLER_LINEAR_MIP_LINEAR,
70+
RS_SAMPLER_WRAP,
71+
RS_SAMPLER_CLAMP,
72+
RS_SAMPLER_LINEAR_MIP_NEAREST,
73+
} rs_sampler_value;
74+
2675
#if (defined(RS_VERSION) && (RS_VERSION >= 14))
2776
/**
2877
* Set the color target used for all subsequent rendering calls
@@ -83,6 +132,88 @@ extern void __attribute__((overloadable))
83132
extern void __attribute__((overloadable))
84133
rsgBindProgramStore(rs_program_store ps);
85134

135+
136+
/**
137+
* @hide
138+
* Get program store depth function
139+
*
140+
* @param ps
141+
*/
142+
extern rs_depth_func __attribute__((overloadable))
143+
rsgProgramStoreGetDepthFunc(rs_program_store ps);
144+
145+
/**
146+
* @hide
147+
* Get program store depth mask
148+
*
149+
* @param ps
150+
*/
151+
extern bool __attribute__((overloadable))
152+
rsgProgramStoreGetDepthMask(rs_program_store ps);
153+
/**
154+
* @hide
155+
* Get program store red component color mask
156+
*
157+
* @param ps
158+
*/
159+
extern bool __attribute__((overloadable))
160+
rsgProgramStoreGetColorMaskR(rs_program_store ps);
161+
162+
/**
163+
* @hide
164+
* Get program store green component color mask
165+
*
166+
* @param ps
167+
*/
168+
extern bool __attribute__((overloadable))
169+
rsgProgramStoreGetColorMaskG(rs_program_store ps);
170+
171+
/**
172+
* @hide
173+
* Get program store blur component color mask
174+
*
175+
* @param ps
176+
*/
177+
extern bool __attribute__((overloadable))
178+
rsgProgramStoreGetColorMaskB(rs_program_store ps);
179+
180+
/**
181+
* @hide
182+
* Get program store alpha component color mask
183+
*
184+
* @param ps
185+
*/
186+
extern bool __attribute__((overloadable))
187+
rsgProgramStoreGetColorMaskA(rs_program_store ps);
188+
189+
/**
190+
* @hide
191+
* Get program store blend source function
192+
*
193+
* @param ps
194+
*/
195+
extern rs_blend_src_func __attribute__((overloadable))
196+
rsgProgramStoreGetBlendSrcFunc(rs_program_store ps);
197+
198+
/**
199+
* @hide
200+
* Get program store blend destination function
201+
*
202+
* @param ps
203+
*/
204+
extern rs_blend_dst_func __attribute__((overloadable))
205+
rsgProgramStoreGetBlendDstFunc(rs_program_store ps);
206+
207+
/**
208+
* @hide
209+
* Get program store dither state
210+
*
211+
* @param ps
212+
*/
213+
extern bool __attribute__((overloadable))
214+
rsgProgramStoreGetDitherEnabled(rs_program_store ps);
215+
216+
86217
/**
87218
* Bind a new ProgramVertex to the rendering context.
88219
*
@@ -99,6 +230,24 @@ extern void __attribute__((overloadable))
99230
extern void __attribute__((overloadable))
100231
rsgBindProgramRaster(rs_program_raster pr);
101232

233+
/**
234+
* @hide
235+
* Get program raster point sprite state
236+
*
237+
* @param pr
238+
*/
239+
extern bool __attribute__((overloadable))
240+
rsgProgramRasterGetPointSpriteEnabled(rs_program_raster pr);
241+
242+
/**
243+
* @hide
244+
* Get program raster cull mode
245+
*
246+
* @param pr
247+
*/
248+
extern rs_cull_mode __attribute__((overloadable))
249+
rsgProgramRasterGetCullMode(rs_program_raster pr);
250+
102251
/**
103252
* Bind a new Sampler object to a ProgramFragment. The sampler will
104253
* operate on the texture bound at the matching slot.
@@ -108,6 +257,51 @@ extern void __attribute__((overloadable))
108257
extern void __attribute__((overloadable))
109258
rsgBindSampler(rs_program_fragment, uint slot, rs_sampler);
110259

260+
/**
261+
* @hide
262+
* Get sampler minification value
263+
*
264+
* @param pr
265+
*/
266+
extern rs_sampler_value __attribute__((overloadable))
267+
rsgSamplerGetMinification(rs_sampler s);
268+
269+
/**
270+
* @hide
271+
* Get sampler magnification value
272+
*
273+
* @param pr
274+
*/
275+
extern rs_sampler_value __attribute__((overloadable))
276+
rsgSamplerGetMagnification(rs_sampler s);
277+
278+
/**
279+
* @hide
280+
* Get sampler wrap S value
281+
*
282+
* @param pr
283+
*/
284+
extern rs_sampler_value __attribute__((overloadable))
285+
rsgSamplerGetWrapS(rs_sampler s);
286+
287+
/**
288+
* @hide
289+
* Get sampler wrap T value
290+
*
291+
* @param pr
292+
*/
293+
extern rs_sampler_value __attribute__((overloadable))
294+
rsgSamplerGetWrapT(rs_sampler s);
295+
296+
/**
297+
* @hide
298+
* Get sampler anisotropy
299+
*
300+
* @param pr
301+
*/
302+
extern float __attribute__((overloadable))
303+
rsgSamplerGetAnisotropy(rs_sampler s);
304+
111305
/**
112306
* Bind a new Allocation object to a ProgramFragment. The
113307
* Allocation must be a valid texture for the Program. The sampling

tests/RenderScriptTests/tests/src/com/android/rs/test/RSTestCore.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ public void init(RenderScriptGL rs, Resources res, int width, int height) {
6464

6565
unitTests = new ArrayList<UnitTest>();
6666

67+
unitTests.add(new UT_sampler(this, mRes, mCtx));
68+
unitTests.add(new UT_program_store(this, mRes, mCtx));
69+
unitTests.add(new UT_program_raster(this, mRes, mCtx));
6770
unitTests.add(new UT_primitives(this, mRes, mCtx));
6871
unitTests.add(new UT_vector(this, mRes, mCtx));
6972
unitTests.add(new UT_rsdebug(this, mRes, mCtx));

0 commit comments

Comments
 (0)