Merge "Adding getter functions for script side RS objects. Multiproject change involving on device linker"

This commit is contained in:
Alex Sakhartchouk
2011-10-16 12:13:18 -07:00
committed by Android (Google) Code Review
11 changed files with 704 additions and 39 deletions

View File

@ -24,17 +24,16 @@ namespace android {
namespace renderscript { namespace renderscript {
class ProgramRasterState; class ProgramRasterState;
/*****************************************************************************
* CAUTION
*
* Any layout changes for this class may require a corresponding change to be
* made to frameworks/compile/libbcc/lib/ScriptCRT/rs_core.c, which contains
* a partial copy of the information below.
*
*****************************************************************************/
class ProgramRaster : public ProgramBase { class ProgramRaster : public ProgramBase {
public: public:
virtual void setup(const Context *, ProgramRasterState *);
virtual void serialize(OStream *stream) const;
virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_RASTER; }
static ProgramRaster *createFromStream(Context *rsc, IStream *stream);
static ObjectBaseRef<ProgramRaster> getProgramRaster(Context *rsc,
bool pointSprite,
RsCullMode cull);
struct Hal { struct Hal {
mutable void *drv; mutable void *drv;
@ -46,6 +45,14 @@ public:
}; };
Hal mHal; Hal mHal;
virtual void setup(const Context *, ProgramRasterState *);
virtual void serialize(OStream *stream) const;
virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_RASTER; }
static ProgramRaster *createFromStream(Context *rsc, IStream *stream);
static ObjectBaseRef<ProgramRaster> getProgramRaster(Context *rsc,
bool pointSprite,
RsCullMode cull);
protected: protected:
virtual void preDestroy() const; virtual void preDestroy() const;
virtual ~ProgramRaster(); virtual ~ProgramRaster();

View File

@ -25,23 +25,16 @@ namespace android {
namespace renderscript { namespace renderscript {
class ProgramStoreState; class ProgramStoreState;
/*****************************************************************************
* CAUTION
*
* Any layout changes for this class may require a corresponding change to be
* made to frameworks/compile/libbcc/lib/ScriptCRT/rs_core.c, which contains
* a partial copy of the information below.
*
*****************************************************************************/
class ProgramStore : public ProgramBase { class ProgramStore : public ProgramBase {
public: public:
virtual void setup(const Context *, ProgramStoreState *);
virtual void serialize(OStream *stream) const;
virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_STORE; }
static ProgramStore *createFromStream(Context *rsc, IStream *stream);
static ObjectBaseRef<ProgramStore> getProgramStore(Context *,
bool colorMaskR, bool colorMaskG,
bool colorMaskB, bool colorMaskA,
bool depthMask, bool ditherEnable,
RsBlendSrcFunc srcFunc, RsBlendDstFunc destFunc,
RsDepthFunc depthFunc);
void init();
struct Hal { struct Hal {
mutable void *drv; mutable void *drv;
@ -64,6 +57,18 @@ public:
}; };
Hal mHal; Hal mHal;
virtual void setup(const Context *, ProgramStoreState *);
virtual void serialize(OStream *stream) const;
virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_PROGRAM_STORE; }
static ProgramStore *createFromStream(Context *rsc, IStream *stream);
static ObjectBaseRef<ProgramStore> getProgramStore(Context *,
bool colorMaskR, bool colorMaskG,
bool colorMaskB, bool colorMaskA,
bool depthMask, bool ditherEnable,
RsBlendSrcFunc srcFunc, RsBlendDstFunc destFunc,
RsDepthFunc depthFunc);
void init();
protected: protected:
virtual void preDestroy() const; virtual void preDestroy() const;
virtual ~ProgramStore(); virtual ~ProgramStore();

View File

@ -27,23 +27,16 @@ namespace renderscript {
const static uint32_t RS_MAX_SAMPLER_SLOT = 16; const static uint32_t RS_MAX_SAMPLER_SLOT = 16;
class SamplerState; class SamplerState;
/*****************************************************************************
* CAUTION
*
* Any layout changes for this class may require a corresponding change to be
* made to frameworks/compile/libbcc/lib/ScriptCRT/rs_core.c, which contains
* a partial copy of the information below.
*
*****************************************************************************/
class Sampler : public ObjectBase { class Sampler : public ObjectBase {
public: public:
static ObjectBaseRef<Sampler> getSampler(Context *,
RsSamplerValue magFilter,
RsSamplerValue minFilter,
RsSamplerValue wrapS,
RsSamplerValue wrapT,
RsSamplerValue wrapR,
float aniso = 1.0f);
void bindToContext(SamplerState *, uint32_t slot);
void unbindFromContext(SamplerState *);
virtual void serialize(OStream *stream) const;
virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_SAMPLER; }
static Sampler *createFromStream(Context *rsc, IStream *stream);
struct Hal { struct Hal {
mutable void *drv; mutable void *drv;
@ -59,6 +52,20 @@ public:
}; };
Hal mHal; Hal mHal;
static ObjectBaseRef<Sampler> getSampler(Context *,
RsSamplerValue magFilter,
RsSamplerValue minFilter,
RsSamplerValue wrapS,
RsSamplerValue wrapT,
RsSamplerValue wrapR,
float aniso = 1.0f);
void bindToContext(SamplerState *, uint32_t slot);
void unbindFromContext(SamplerState *);
virtual void serialize(OStream *stream) const;
virtual RsA3DClassID getClassId() const { return RS_A3D_CLASS_ID_SAMPLER; }
static Sampler *createFromStream(Context *rsc, IStream *stream);
protected: protected:
int32_t mBoundSlot; int32_t mBoundSlot;

View File

@ -23,6 +23,55 @@
#ifndef __RS_GRAPHICS_RSH__ #ifndef __RS_GRAPHICS_RSH__
#define __RS_GRAPHICS_RSH__ #define __RS_GRAPHICS_RSH__
// These are API 15 once it get official
typedef enum {
RS_DEPTH_FUNC_ALWAYS,
RS_DEPTH_FUNC_LESS,
RS_DEPTH_FUNC_LEQUAL,
RS_DEPTH_FUNC_GREATER,
RS_DEPTH_FUNC_GEQUAL,
RS_DEPTH_FUNC_EQUAL,
RS_DEPTH_FUNC_NOTEQUAL
} rs_depth_func;
typedef enum {
RS_BLEND_SRC_ZERO, // 0
RS_BLEND_SRC_ONE, // 1
RS_BLEND_SRC_DST_COLOR, // 2
RS_BLEND_SRC_ONE_MINUS_DST_COLOR, // 3
RS_BLEND_SRC_SRC_ALPHA, // 4
RS_BLEND_SRC_ONE_MINUS_SRC_ALPHA, // 5
RS_BLEND_SRC_DST_ALPHA, // 6
RS_BLEND_SRC_ONE_MINUS_DST_ALPHA, // 7
RS_BLEND_SRC_SRC_ALPHA_SATURATE // 8
} rs_blend_src_func;
typedef enum {
RS_BLEND_DST_ZERO, // 0
RS_BLEND_DST_ONE, // 1
RS_BLEND_DST_SRC_COLOR, // 2
RS_BLEND_DST_ONE_MINUS_SRC_COLOR, // 3
RS_BLEND_DST_SRC_ALPHA, // 4
RS_BLEND_DST_ONE_MINUS_SRC_ALPHA, // 5
RS_BLEND_DST_DST_ALPHA, // 6
RS_BLEND_DST_ONE_MINUS_DST_ALPHA // 7
} rs_blend_dst_func;
typedef enum {
RS_CULL_BACK,
RS_CULL_FRONT,
RS_CULL_NONE
} rs_cull_mode;
typedef enum {
RS_SAMPLER_NEAREST,
RS_SAMPLER_LINEAR,
RS_SAMPLER_LINEAR_MIP_LINEAR,
RS_SAMPLER_WRAP,
RS_SAMPLER_CLAMP,
RS_SAMPLER_LINEAR_MIP_NEAREST,
} rs_sampler_value;
#if (defined(RS_VERSION) && (RS_VERSION >= 14)) #if (defined(RS_VERSION) && (RS_VERSION >= 14))
/** /**
* Set the color target used for all subsequent rendering calls * Set the color target used for all subsequent rendering calls
@ -83,6 +132,88 @@ extern void __attribute__((overloadable))
extern void __attribute__((overloadable)) extern void __attribute__((overloadable))
rsgBindProgramStore(rs_program_store ps); rsgBindProgramStore(rs_program_store ps);
/**
* @hide
* Get program store depth function
*
* @param ps
*/
extern rs_depth_func __attribute__((overloadable))
rsgProgramStoreGetDepthFunc(rs_program_store ps);
/**
* @hide
* Get program store depth mask
*
* @param ps
*/
extern bool __attribute__((overloadable))
rsgProgramStoreGetDepthMask(rs_program_store ps);
/**
* @hide
* Get program store red component color mask
*
* @param ps
*/
extern bool __attribute__((overloadable))
rsgProgramStoreGetColorMaskR(rs_program_store ps);
/**
* @hide
* Get program store green component color mask
*
* @param ps
*/
extern bool __attribute__((overloadable))
rsgProgramStoreGetColorMaskG(rs_program_store ps);
/**
* @hide
* Get program store blur component color mask
*
* @param ps
*/
extern bool __attribute__((overloadable))
rsgProgramStoreGetColorMaskB(rs_program_store ps);
/**
* @hide
* Get program store alpha component color mask
*
* @param ps
*/
extern bool __attribute__((overloadable))
rsgProgramStoreGetColorMaskA(rs_program_store ps);
/**
* @hide
* Get program store blend source function
*
* @param ps
*/
extern rs_blend_src_func __attribute__((overloadable))
rsgProgramStoreGetBlendSrcFunc(rs_program_store ps);
/**
* @hide
* Get program store blend destination function
*
* @param ps
*/
extern rs_blend_dst_func __attribute__((overloadable))
rsgProgramStoreGetBlendDstFunc(rs_program_store ps);
/**
* @hide
* Get program store dither state
*
* @param ps
*/
extern bool __attribute__((overloadable))
rsgProgramStoreGetDitherEnabled(rs_program_store ps);
/** /**
* Bind a new ProgramVertex to the rendering context. * Bind a new ProgramVertex to the rendering context.
* *
@ -99,6 +230,24 @@ extern void __attribute__((overloadable))
extern void __attribute__((overloadable)) extern void __attribute__((overloadable))
rsgBindProgramRaster(rs_program_raster pr); rsgBindProgramRaster(rs_program_raster pr);
/**
* @hide
* Get program raster point sprite state
*
* @param pr
*/
extern bool __attribute__((overloadable))
rsgProgramRasterGetPointSpriteEnabled(rs_program_raster pr);
/**
* @hide
* Get program raster cull mode
*
* @param pr
*/
extern rs_cull_mode __attribute__((overloadable))
rsgProgramRasterGetCullMode(rs_program_raster pr);
/** /**
* Bind a new Sampler object to a ProgramFragment. The sampler will * Bind a new Sampler object to a ProgramFragment. The sampler will
* operate on the texture bound at the matching slot. * operate on the texture bound at the matching slot.
@ -108,6 +257,51 @@ extern void __attribute__((overloadable))
extern void __attribute__((overloadable)) extern void __attribute__((overloadable))
rsgBindSampler(rs_program_fragment, uint slot, rs_sampler); rsgBindSampler(rs_program_fragment, uint slot, rs_sampler);
/**
* @hide
* Get sampler minification value
*
* @param pr
*/
extern rs_sampler_value __attribute__((overloadable))
rsgSamplerGetMinification(rs_sampler s);
/**
* @hide
* Get sampler magnification value
*
* @param pr
*/
extern rs_sampler_value __attribute__((overloadable))
rsgSamplerGetMagnification(rs_sampler s);
/**
* @hide
* Get sampler wrap S value
*
* @param pr
*/
extern rs_sampler_value __attribute__((overloadable))
rsgSamplerGetWrapS(rs_sampler s);
/**
* @hide
* Get sampler wrap T value
*
* @param pr
*/
extern rs_sampler_value __attribute__((overloadable))
rsgSamplerGetWrapT(rs_sampler s);
/**
* @hide
* Get sampler anisotropy
*
* @param pr
*/
extern float __attribute__((overloadable))
rsgSamplerGetAnisotropy(rs_sampler s);
/** /**
* Bind a new Allocation object to a ProgramFragment. The * Bind a new Allocation object to a ProgramFragment. The
* Allocation must be a valid texture for the Program. The sampling * Allocation must be a valid texture for the Program. The sampling

View File

@ -64,6 +64,9 @@ public class RSTestCore {
unitTests = new ArrayList<UnitTest>(); unitTests = new ArrayList<UnitTest>();
unitTests.add(new UT_sampler(this, mRes, mCtx));
unitTests.add(new UT_program_store(this, mRes, mCtx));
unitTests.add(new UT_program_raster(this, mRes, mCtx));
unitTests.add(new UT_primitives(this, mRes, mCtx)); unitTests.add(new UT_primitives(this, mRes, mCtx));
unitTests.add(new UT_vector(this, mRes, mCtx)); unitTests.add(new UT_vector(this, mRes, mCtx));
unitTests.add(new UT_rsdebug(this, mRes, mCtx)); unitTests.add(new UT_rsdebug(this, mRes, mCtx));

View File

@ -0,0 +1,58 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.rs.test;
import android.content.Context;
import android.content.res.Resources;
import android.renderscript.*;
import android.renderscript.ProgramRaster;
import android.renderscript.ProgramRaster.CullMode;
public class UT_program_raster extends UnitTest {
private Resources mRes;
protected UT_program_raster(RSTestCore rstc, Resources res, Context ctx) {
super(rstc, "ProgramRaster", ctx);
mRes = res;
}
private ProgramRaster.Builder getDefaultBuilder(RenderScript RS) {
ProgramRaster.Builder b = new ProgramRaster.Builder(RS);
b.setCullMode(CullMode.BACK);
b.setPointSpriteEnabled(false);
return b;
}
private void initializeGlobals(RenderScript RS, ScriptC_program_raster s) {
ProgramRaster.Builder b = getDefaultBuilder(RS);
s.set_pointSpriteEnabled(b.setPointSpriteEnabled(true).create());
b = getDefaultBuilder(RS);
s.set_cullMode(b.setCullMode(CullMode.FRONT).create());
return;
}
public void run() {
RenderScript pRS = RenderScript.create(mCtx);
ScriptC_program_raster s = new ScriptC_program_raster(pRS, mRes, R.raw.program_raster);
pRS.setMessageHandler(mRsMessage);
initializeGlobals(pRS, s);
s.invoke_program_raster_test();
pRS.finish();
waitForMessage();
pRS.destroy();
}
}

View File

@ -0,0 +1,87 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.rs.test;
import android.content.Context;
import android.content.res.Resources;
import android.renderscript.*;
import android.renderscript.ProgramStore.BlendDstFunc;
import android.renderscript.ProgramStore.BlendSrcFunc;
import android.renderscript.ProgramStore.Builder;
import android.renderscript.ProgramStore.DepthFunc;
public class UT_program_store extends UnitTest {
private Resources mRes;
protected UT_program_store(RSTestCore rstc, Resources res, Context ctx) {
super(rstc, "ProgramStore", ctx);
mRes = res;
}
private ProgramStore.Builder getDefaultBuilder(RenderScript RS) {
ProgramStore.Builder b = new ProgramStore.Builder(RS);
b.setBlendFunc(ProgramStore.BlendSrcFunc.ZERO, ProgramStore.BlendDstFunc.ZERO);
b.setColorMaskEnabled(false, false, false, false);
b.setDepthFunc(ProgramStore.DepthFunc.ALWAYS);
b.setDepthMaskEnabled(false);
b.setDitherEnabled(false);
return b;
}
private void initializeGlobals(RenderScript RS, ScriptC_program_store s) {
ProgramStore.Builder b = getDefaultBuilder(RS);
s.set_ditherEnable(b.setDitherEnabled(true).create());
b = getDefaultBuilder(RS);
s.set_colorRWriteEnable(b.setColorMaskEnabled(true, false, false, false).create());
b = getDefaultBuilder(RS);
s.set_colorGWriteEnable(b.setColorMaskEnabled(false, true, false, false).create());
b = getDefaultBuilder(RS);
s.set_colorBWriteEnable(b.setColorMaskEnabled(false, false, true, false).create());
b = getDefaultBuilder(RS);
s.set_colorAWriteEnable(b.setColorMaskEnabled(false, false, false, true).create());
b = getDefaultBuilder(RS);
s.set_blendSrc(b.setBlendFunc(ProgramStore.BlendSrcFunc.DST_COLOR,
ProgramStore.BlendDstFunc.ZERO).create());
b = getDefaultBuilder(RS);
s.set_blendDst(b.setBlendFunc(ProgramStore.BlendSrcFunc.ZERO,
ProgramStore.BlendDstFunc.DST_ALPHA).create());
b = getDefaultBuilder(RS);
s.set_depthWriteEnable(b.setDepthMaskEnabled(true).create());
b = getDefaultBuilder(RS);
s.set_depthFunc(b.setDepthFunc(ProgramStore.DepthFunc.GREATER).create());
return;
}
public void run() {
RenderScript pRS = RenderScript.create(mCtx);
ScriptC_program_store s = new ScriptC_program_store(pRS, mRes, R.raw.program_store);
pRS.setMessageHandler(mRsMessage);
initializeGlobals(pRS, s);
s.invoke_program_store_test();
pRS.finish();
waitForMessage();
pRS.destroy();
}
}

View File

@ -0,0 +1,76 @@
/*
* Copyright (C) 2011 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.rs.test;
import android.content.Context;
import android.content.res.Resources;
import android.renderscript.*;
import android.renderscript.Sampler;
import android.renderscript.Sampler.Value;
public class UT_sampler extends UnitTest {
private Resources mRes;
protected UT_sampler(RSTestCore rstc, Resources res, Context ctx) {
super(rstc, "Sampler", ctx);
mRes = res;
}
private Sampler.Builder getDefaultBuilder(RenderScript RS) {
Sampler.Builder b = new Sampler.Builder(RS);
b.setMinification(Value.NEAREST);
b.setMagnification(Value.NEAREST);
b.setWrapS(Value.CLAMP);
b.setWrapT(Value.CLAMP);
b.setAnisotropy(1.0f);
return b;
}
private void initializeGlobals(RenderScript RS, ScriptC_sampler s) {
Sampler.Builder b = getDefaultBuilder(RS);
b.setMinification(Value.LINEAR_MIP_LINEAR);
s.set_minification(b.create());
b = getDefaultBuilder(RS);
b.setMagnification(Value.LINEAR);
s.set_magnification(b.create());
b = getDefaultBuilder(RS);
b.setWrapS(Value.WRAP);
s.set_wrapS(b.create());
b = getDefaultBuilder(RS);
b.setWrapT(Value.WRAP);
s.set_wrapT(b.create());
b = getDefaultBuilder(RS);
b.setAnisotropy(8.0f);
s.set_anisotropy(b.create());
return;
}
public void run() {
RenderScript pRS = RenderScript.create(mCtx);
ScriptC_sampler s = new ScriptC_sampler(pRS, mRes, R.raw.sampler);
pRS.setMessageHandler(mRsMessage);
initializeGlobals(pRS, s);
s.invoke_sampler_test();
pRS.finish();
waitForMessage();
pRS.destroy();
}
}

View File

@ -0,0 +1,37 @@
#include "shared.rsh"
#include "rs_graphics.rsh"
rs_program_raster pointSpriteEnabled;
rs_program_raster cullMode;
static bool test_program_raster_getters() {
bool failed = false;
_RS_ASSERT(rsgProgramRasterGetPointSpriteEnabled(pointSpriteEnabled) == true);
_RS_ASSERT(rsgProgramRasterGetCullMode(pointSpriteEnabled) == RS_CULL_BACK);
_RS_ASSERT(rsgProgramRasterGetPointSpriteEnabled(cullMode) == false);
_RS_ASSERT(rsgProgramRasterGetCullMode(cullMode) == RS_CULL_FRONT);
if (failed) {
rsDebug("test_program_raster_getters FAILED", 0);
}
else {
rsDebug("test_program_raster_getters PASSED", 0);
}
return failed;
}
void program_raster_test() {
bool failed = false;
failed |= test_program_raster_getters();
if (failed) {
rsSendToClientBlocking(RS_MSG_TEST_FAILED);
}
else {
rsSendToClientBlocking(RS_MSG_TEST_PASSED);
}
}

View File

@ -0,0 +1,128 @@
#include "shared.rsh"
#include "rs_graphics.rsh"
rs_program_store ditherEnable;
rs_program_store colorRWriteEnable;
rs_program_store colorGWriteEnable;
rs_program_store colorBWriteEnable;
rs_program_store colorAWriteEnable;
rs_program_store blendSrc;
rs_program_store blendDst;
rs_program_store depthWriteEnable;
rs_program_store depthFunc;
static bool test_program_store_getters() {
bool failed = false;
_RS_ASSERT(rsgProgramStoreGetDepthFunc(depthFunc) == RS_DEPTH_FUNC_GREATER);
_RS_ASSERT(rsgProgramStoreGetDepthMask(depthFunc) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskR(depthFunc) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskG(depthFunc) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskB(depthFunc) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskA(depthFunc) == false);
_RS_ASSERT(rsgProgramStoreGetDitherEnabled(depthFunc) == false);
_RS_ASSERT(rsgProgramStoreGetBlendSrcFunc(depthFunc) == RS_BLEND_SRC_ZERO);
_RS_ASSERT(rsgProgramStoreGetBlendDstFunc(depthFunc) == RS_BLEND_DST_ZERO);
_RS_ASSERT(rsgProgramStoreGetDepthFunc(depthWriteEnable) == RS_DEPTH_FUNC_ALWAYS);
_RS_ASSERT(rsgProgramStoreGetDepthMask(depthWriteEnable) == true);
_RS_ASSERT(rsgProgramStoreGetColorMaskR(depthWriteEnable) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskG(depthWriteEnable) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskB(depthWriteEnable) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskA(depthWriteEnable) == false);
_RS_ASSERT(rsgProgramStoreGetDitherEnabled(depthWriteEnable) == false);
_RS_ASSERT(rsgProgramStoreGetBlendSrcFunc(depthWriteEnable) == RS_BLEND_SRC_ZERO);
_RS_ASSERT(rsgProgramStoreGetBlendDstFunc(depthWriteEnable) == RS_BLEND_DST_ZERO);
_RS_ASSERT(rsgProgramStoreGetDepthFunc(colorRWriteEnable) == RS_DEPTH_FUNC_ALWAYS);
_RS_ASSERT(rsgProgramStoreGetDepthMask(colorRWriteEnable) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskR(colorRWriteEnable) == true);
_RS_ASSERT(rsgProgramStoreGetColorMaskG(colorRWriteEnable) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskB(colorRWriteEnable) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskA(colorRWriteEnable) == false);
_RS_ASSERT(rsgProgramStoreGetDitherEnabled(colorRWriteEnable) == false);
_RS_ASSERT(rsgProgramStoreGetBlendSrcFunc(colorRWriteEnable) == RS_BLEND_SRC_ZERO);
_RS_ASSERT(rsgProgramStoreGetBlendDstFunc(colorRWriteEnable) == RS_BLEND_DST_ZERO);
_RS_ASSERT(rsgProgramStoreGetDepthFunc(colorGWriteEnable) == RS_DEPTH_FUNC_ALWAYS);
_RS_ASSERT(rsgProgramStoreGetDepthMask(colorGWriteEnable) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskR(colorGWriteEnable) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskG(colorGWriteEnable) == true);
_RS_ASSERT(rsgProgramStoreGetColorMaskB(colorGWriteEnable) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskA(colorGWriteEnable) == false);
_RS_ASSERT(rsgProgramStoreGetDitherEnabled(colorGWriteEnable) == false);
_RS_ASSERT(rsgProgramStoreGetBlendSrcFunc(colorGWriteEnable) == RS_BLEND_SRC_ZERO);
_RS_ASSERT(rsgProgramStoreGetBlendDstFunc(colorGWriteEnable) == RS_BLEND_DST_ZERO);
_RS_ASSERT(rsgProgramStoreGetDepthFunc(colorBWriteEnable) == RS_DEPTH_FUNC_ALWAYS);
_RS_ASSERT(rsgProgramStoreGetDepthMask(colorBWriteEnable) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskR(colorBWriteEnable) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskG(colorBWriteEnable) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskB(colorBWriteEnable) == true);
_RS_ASSERT(rsgProgramStoreGetColorMaskA(colorBWriteEnable) == false);
_RS_ASSERT(rsgProgramStoreGetDitherEnabled(colorBWriteEnable) == false);
_RS_ASSERT(rsgProgramStoreGetBlendSrcFunc(colorBWriteEnable) == RS_BLEND_SRC_ZERO);
_RS_ASSERT(rsgProgramStoreGetBlendDstFunc(colorBWriteEnable) == RS_BLEND_DST_ZERO);
_RS_ASSERT(rsgProgramStoreGetDepthFunc(colorAWriteEnable) == RS_DEPTH_FUNC_ALWAYS);
_RS_ASSERT(rsgProgramStoreGetDepthMask(colorAWriteEnable) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskR(colorAWriteEnable) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskG(colorAWriteEnable) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskB(colorAWriteEnable) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskA(colorAWriteEnable) == true);
_RS_ASSERT(rsgProgramStoreGetDitherEnabled(colorAWriteEnable) == false);
_RS_ASSERT(rsgProgramStoreGetBlendSrcFunc(colorAWriteEnable) == RS_BLEND_SRC_ZERO);
_RS_ASSERT(rsgProgramStoreGetBlendDstFunc(colorAWriteEnable) == RS_BLEND_DST_ZERO);
_RS_ASSERT(rsgProgramStoreGetDepthFunc(ditherEnable) == RS_DEPTH_FUNC_ALWAYS);
_RS_ASSERT(rsgProgramStoreGetDepthMask(ditherEnable) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskR(ditherEnable) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskG(ditherEnable) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskB(ditherEnable) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskA(ditherEnable) == false);
_RS_ASSERT(rsgProgramStoreGetDitherEnabled(ditherEnable) == true);
_RS_ASSERT(rsgProgramStoreGetBlendSrcFunc(ditherEnable) == RS_BLEND_SRC_ZERO);
_RS_ASSERT(rsgProgramStoreGetBlendDstFunc(ditherEnable) == RS_BLEND_DST_ZERO);
_RS_ASSERT(rsgProgramStoreGetDepthFunc(blendSrc) == RS_DEPTH_FUNC_ALWAYS);
_RS_ASSERT(rsgProgramStoreGetDepthMask(blendSrc) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskR(blendSrc) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskG(blendSrc) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskB(blendSrc) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskA(blendSrc) == false);
_RS_ASSERT(rsgProgramStoreGetDitherEnabled(blendSrc) == false);
_RS_ASSERT(rsgProgramStoreGetBlendSrcFunc(blendSrc) == RS_BLEND_SRC_DST_COLOR);
_RS_ASSERT(rsgProgramStoreGetBlendDstFunc(blendSrc) == RS_BLEND_DST_ZERO);
_RS_ASSERT(rsgProgramStoreGetDepthFunc(blendDst) == RS_DEPTH_FUNC_ALWAYS);
_RS_ASSERT(rsgProgramStoreGetDepthMask(blendDst) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskR(blendDst) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskG(blendDst) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskB(blendDst) == false);
_RS_ASSERT(rsgProgramStoreGetColorMaskA(blendDst) == false);
_RS_ASSERT(rsgProgramStoreGetDitherEnabled(blendDst) == false);
_RS_ASSERT(rsgProgramStoreGetBlendSrcFunc(blendDst) == RS_BLEND_SRC_ZERO);
_RS_ASSERT(rsgProgramStoreGetBlendDstFunc(blendDst) == RS_BLEND_DST_DST_ALPHA);
if (failed) {
rsDebug("test_program_store_getters FAILED", 0);
}
else {
rsDebug("test_program_store_getters PASSED", 0);
}
return failed;
}
void program_store_test() {
bool failed = false;
failed |= test_program_store_getters();
if (failed) {
rsSendToClientBlocking(RS_MSG_TEST_FAILED);
}
else {
rsSendToClientBlocking(RS_MSG_TEST_PASSED);
}
}

View File

@ -0,0 +1,63 @@
#include "shared.rsh"
#include "rs_graphics.rsh"
rs_sampler minification;
rs_sampler magnification;
rs_sampler wrapS;
rs_sampler wrapT;
rs_sampler anisotropy;
static bool test_sampler_getters() {
bool failed = false;
_RS_ASSERT(rsgSamplerGetMagnification(minification) == RS_SAMPLER_NEAREST);
_RS_ASSERT(rsgSamplerGetMinification(minification) == RS_SAMPLER_LINEAR_MIP_LINEAR);
_RS_ASSERT(rsgSamplerGetWrapS(minification) == RS_SAMPLER_CLAMP);
_RS_ASSERT(rsgSamplerGetWrapT(minification) == RS_SAMPLER_CLAMP);
_RS_ASSERT(rsgSamplerGetAnisotropy(minification) == 1.0f);
_RS_ASSERT(rsgSamplerGetMagnification(magnification) == RS_SAMPLER_LINEAR);
_RS_ASSERT(rsgSamplerGetMinification(magnification) == RS_SAMPLER_NEAREST);
_RS_ASSERT(rsgSamplerGetWrapS(magnification) == RS_SAMPLER_CLAMP);
_RS_ASSERT(rsgSamplerGetWrapT(magnification) == RS_SAMPLER_CLAMP);
_RS_ASSERT(rsgSamplerGetAnisotropy(magnification) == 1.0f);
_RS_ASSERT(rsgSamplerGetMagnification(wrapS) == RS_SAMPLER_NEAREST);
_RS_ASSERT(rsgSamplerGetMinification(wrapS) == RS_SAMPLER_NEAREST);
_RS_ASSERT(rsgSamplerGetWrapS(wrapS) == RS_SAMPLER_WRAP);
_RS_ASSERT(rsgSamplerGetWrapT(wrapS) == RS_SAMPLER_CLAMP);
_RS_ASSERT(rsgSamplerGetAnisotropy(wrapS) == 1.0f);
_RS_ASSERT(rsgSamplerGetMagnification(wrapT) == RS_SAMPLER_NEAREST);
_RS_ASSERT(rsgSamplerGetMinification(wrapT) == RS_SAMPLER_NEAREST);
_RS_ASSERT(rsgSamplerGetWrapS(wrapT) == RS_SAMPLER_CLAMP);
_RS_ASSERT(rsgSamplerGetWrapT(wrapT) == RS_SAMPLER_WRAP);
_RS_ASSERT(rsgSamplerGetAnisotropy(wrapT) == 1.0f);
_RS_ASSERT(rsgSamplerGetMagnification(anisotropy) == RS_SAMPLER_NEAREST);
_RS_ASSERT(rsgSamplerGetMinification(anisotropy) == RS_SAMPLER_NEAREST);
_RS_ASSERT(rsgSamplerGetWrapS(anisotropy) == RS_SAMPLER_CLAMP);
_RS_ASSERT(rsgSamplerGetWrapT(anisotropy) == RS_SAMPLER_CLAMP);
_RS_ASSERT(rsgSamplerGetAnisotropy(anisotropy) == 8.0f);
if (failed) {
rsDebug("test_sampler_getters FAILED", 0);
}
else {
rsDebug("test_sampler_getters PASSED", 0);
}
return failed;
}
void sampler_test() {
bool failed = false;
failed |= test_sampler_getters();
if (failed) {
rsSendToClientBlocking(RS_MSG_TEST_FAILED);
}
else {
rsSendToClientBlocking(RS_MSG_TEST_PASSED);
}
}