summaryrefslogtreecommitdiffstats
path: root/tests/RenderScriptTests/SceneGraph/src
diff options
context:
space:
mode:
authorAlex Sakhartchouk <alexst@google.com>2012-01-10 14:30:34 -0800
committerAlex Sakhartchouk <alexst@google.com>2012-01-10 14:30:34 -0800
commitfdccec9c21fafe1bc70b6437115d42e75643ba75 (patch)
tree61ac00a69166e0fe5d28045798e7f8c14be8dddc /tests/RenderScriptTests/SceneGraph/src
parent33680ff630760228c33cc3731eb5718be7bbc04f (diff)
downloadframeworks_base-fdccec9c21fafe1bc70b6437115d42e75643ba75.zip
frameworks_base-fdccec9c21fafe1bc70b6437115d42e75643ba75.tar.gz
frameworks_base-fdccec9c21fafe1bc70b6437115d42e75643ba75.tar.bz2
Now utilizing ability to bind constants.
Fixing small copy/paste typo. Change-Id: I8ca993f3e894214b710bea019dfd65822a4cd88f
Diffstat (limited to 'tests/RenderScriptTests/SceneGraph/src')
-rw-r--r--tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TestAppRS.java4
-rw-r--r--tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/export.rs6
-rw-r--r--tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/params.rs20
-rw-r--r--tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/render.rs128
4 files changed, 16 insertions, 142 deletions
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TestAppRS.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TestAppRS.java
index 8987408..58af120 100644
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TestAppRS.java
+++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/TestAppRS.java
@@ -261,7 +261,6 @@ public class TestAppRS {
fb.addTexture(TextureType.TEXTURE_CUBE);
}
ProgramFragment pf = fb.create();
- pf.bindConstants(mFsConst.getAllocation(), 0);
pf.bindSampler(Sampler.WRAP_LINEAR_MIP_LINEAR(mRS), 0);
if (addCubemap) {
pf.bindSampler(Sampler.CLAMP_LINEAR_MIP_LINEAR(mRS), 1);
@@ -278,7 +277,6 @@ public class TestAppRS {
vb.addInput(ScriptField_VertexShaderInputs_s.createElement(mRS));
vb.setShader(mRes, R.raw.shader2v);
mPV_Paint = vb.create();
- mPV_Paint.bindConstants(mVsConst.getAllocation(), 0);
mFsConst = new ScriptField_FShaderParams_s(mRS, 1);
@@ -422,8 +420,6 @@ public class TestAppRS {
new ImageLoaderTask().execute();
ScriptC_render renderLoop = mSceneManager.getRenderLoop();
- renderLoop.bind_vConst(mVsConst);
- renderLoop.bind_fConst(mFsConst);
mScript.set_gRenderLoop(renderLoop);
Allocation dummyAlloc = Allocation.createSized(mRS, Element.I32(mRS), 1);
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/export.rs b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/export.rs
index b8edd2a..1065d87 100644
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/export.rs
+++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/export.rs
@@ -27,4 +27,8 @@ SgCamera *exportPtrCam;
SgLight *exportPtrLight;
SgShaderParam *spExport;
FBlurOffsets *blurExport;
-VertexShaderInputs *iExport; \ No newline at end of file
+VertexShaderInputs *iExport;
+
+VShaderParams *vConst;
+FShaderParams *fConst;
+
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/params.rs b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/params.rs
index 270fa58..873c7e6 100644
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/params.rs
+++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/params.rs
@@ -1,4 +1,4 @@
-// Copyright (C) 2011 The Android Open Source Project
+// Copyright (C) 2012 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.
@@ -16,7 +16,6 @@
#pragma rs java_package_name(com.android.scenegraph)
-//#define DEBUG_PARAMS
#include "transform_def.rsh"
static void writeFloatData(float *ptr, const float4 *input, uint32_t vecSize) {
@@ -128,7 +127,7 @@ static bool frustumCulled(SgRenderable *obj, SgCamera *cam) {
return !rsIsSphereInFrustum(&obj->worldBoundingSphere,
&cam->frustumPlanes[0], &cam->frustumPlanes[1],
&cam->frustumPlanes[2], &cam->frustumPlanes[3],
- &cam->frustumPlanes[3], &cam->frustumPlanes[4]);
+ &cam->frustumPlanes[4], &cam->frustumPlanes[5]);
}
@@ -149,24 +148,24 @@ void root(const rs_allocation *v_in, rs_allocation *v_out, const void *usrData)
#ifdef DEBUG_RENDERABLES
rsDebug("Culled", drawable);
printName(drawable->name);
-#endif //DEBUG_RENDERABLES
+#endif // DEBUG_RENDERABLES
return;
}
drawable->isVisible = 1;
// Data we are updating
- /*if (rsIsObject(drawable->pf_const)) {
+ if (rsIsObject(drawable->pf_const)) {
uint8_t *constantBuffer = (uint8_t*)rsGetElementAt(drawable->pf_const, 0);
int numParams = 0;
if (rsIsObject(drawable->pf_constParams)) {
- rsAllocationGetDimX(drawable->pf_constParams);
+ numParams = rsAllocationGetDimX(drawable->pf_constParams);
}
for (int i = 0; i < numParams; i ++) {
SgShaderParam *current = (SgShaderParam*)rsGetElementAt(drawable->pf_constParams, i);
processParam(current, constantBuffer, camera);
}
- rsgAllocationSyncAll(drawable->pf_const);
+ //rsgAllocationSyncAll(drawable->pf_const);
}
if (rsIsObject(drawable->pv_const)) {
@@ -180,9 +179,6 @@ void root(const rs_allocation *v_in, rs_allocation *v_out, const void *usrData)
SgShaderParam *current = (SgShaderParam*)rsGetElementAt(drawable->pv_constParams, i);
processParam(current, constantBuffer, camera);
}
- rsgAllocationSyncAll(drawable->pv_const);
- }*/
-
-#ifdef DEBUG_PARAMS
-#endif //DEBUG_PARAMS
+ //rsgAllocationSyncAll(drawable->pv_const);
+ }
}
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/render.rs b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/render.rs
index ceaca40..fc337f5 100644
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/render.rs
+++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/render.rs
@@ -1,4 +1,4 @@
-// Copyright (C) 2011 The Android Open Source Project
+// Copyright (C) 2011-2012 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.
@@ -35,9 +35,6 @@ rs_allocation gRenderPasses;
rs_allocation gTGrid;
rs_program_store gPFSBackground;
-VShaderParams *vConst;
-FShaderParams *fConst;
-
uint32_t *gFrontToBack;
static uint32_t gFrontToBackCount = 0;
uint32_t *gBackToFront;
@@ -47,113 +44,6 @@ static SgCamera *gActiveCamera = NULL;
static rs_allocation nullAlloc;
-static void writeFloatData(float *ptr, const float4 *input, uint32_t vecSize) {
- switch (vecSize) {
- case 1:
- *ptr = input->x;
- break;
- case 2:
- *ptr++ = input->x;
- *ptr = input->y;
- break;
- case 3:
- *ptr++ = input->x;
- *ptr++ = input->y;
- *ptr = input->z;
- break;
- case 4:
- *((float4*)ptr) = *input;
- break;
- }
-}
-
-static void processParam(SgShaderParam *p, uint8_t *constantBuffer, const SgCamera *currentCam) {
- uint8_t *dataPtr = constantBuffer + p->bufferOffset;
- const SgTransform *pTransform = NULL;
- if (rsIsObject(p->transform)) {
- pTransform = (const SgTransform *)rsGetElementAt(p->transform, 0);
- }
-
- rsDebug("data ptr: ", (void*)dataPtr);
- rsDebug("p type: ", p->type);
-
- switch(p->type) {
- case SHADER_PARAM_FLOAT4_DATA:
- writeFloatData((float*)dataPtr, &p->float_value, p->float_vecSize);
- break;
- case SHADER_PARAM_FLOAT4_CAMERA_POS:
- writeFloatData((float*)dataPtr, &currentCam->position, p->float_vecSize);
- break;
- case SHADER_PARAM_FLOAT4_CAMERA_DIR: break;
- case SHADER_PARAM_FLOAT4_LIGHT_COLOR: break;
- case SHADER_PARAM_FLOAT4_LIGHT_POS: break;
- case SHADER_PARAM_FLOAT4_LIGHT_DIR: break;
-
- case SHADER_PARAM_TRANSFORM_DATA:
- rsMatrixLoad((rs_matrix4x4*)dataPtr, &pTransform->globalMat);
- break;
- case SHADER_PARAM_TRANSFORM_VIEW:
- rsMatrixLoad((rs_matrix4x4*)dataPtr, &currentCam->view);
- break;
- case SHADER_PARAM_TRANSFORM_PROJ:
- rsMatrixLoad((rs_matrix4x4*)dataPtr, &currentCam->proj);
- break;
- case SHADER_PARAM_TRANSFORM_VIEW_PROJ:
- rsDebug("View proj ptr: ", (void*)&vConst->viewProj);
- rsMatrixLoad((rs_matrix4x4*)dataPtr, &currentCam->viewProj);
- break;
- case SHADER_PARAM_TRANSFORM_MODEL:
- rsDebug("Model ptr: ", (void*)&vConst->model);
- rsMatrixLoad((rs_matrix4x4*)dataPtr, &pTransform->globalMat);
- break;
- case SHADER_PARAM_TRANSFORM_MODEL_VIEW:
- rsMatrixLoad((rs_matrix4x4*)dataPtr, &currentCam->view);
- rsMatrixLoadMultiply((rs_matrix4x4*)dataPtr,
- (rs_matrix4x4*)dataPtr,
- &pTransform->globalMat);
- break;
- case SHADER_PARAM_TRANSFORM_MODEL_VIEW_PROJ:
- rsMatrixLoad((rs_matrix4x4*)dataPtr, &currentCam->viewProj);
- rsMatrixLoadMultiply((rs_matrix4x4*)dataPtr,
- (rs_matrix4x4*)dataPtr,
- &pTransform->globalMat);
- break;
- }
-}
-
-static void updateParams(SgRenderable *drawable) {
- if (rsIsObject(drawable->pf_const)) {
- uint8_t *constantBuffer = (uint8_t*)fConst;
-
- int numParams = 0;
- if (rsIsObject(drawable->pf_constParams)) {
- rsAllocationGetDimX(drawable->pf_constParams);
- }
- for (int i = 0; i < numParams; i ++) {
- SgShaderParam *current = (SgShaderParam*)rsGetElementAt(drawable->pf_constParams, i);
- processParam(current, constantBuffer, gActiveCamera);
- rsDebug("Setting f param", i);
- }
- rsgAllocationSyncAll(rsGetAllocation(fConst));
- }
-
- if (rsIsObject(drawable->pv_const)) {
- uint8_t *constantBuffer = (uint8_t*)vConst;
-
- rsDebug("_______________________", 0);
-
- int numParams = 0;
- if (rsIsObject(drawable->pv_constParams)) {
- numParams = rsAllocationGetDimX(drawable->pv_constParams);
- }
- for (int i = 0; i < numParams; i ++) {
- SgShaderParam *current = (SgShaderParam*)rsGetElementAt(drawable->pv_constParams, i);
- processParam(current, constantBuffer, gActiveCamera);
- }
- rsgAllocationSyncAll(rsGetAllocation(vConst));
- }
-}
-
//#define DEBUG_RENDERABLES
static void draw(SgRenderable *obj) {
@@ -166,14 +56,8 @@ static void draw(SgRenderable *obj) {
printName(obj->name);
#endif //DEBUG_RENDERABLES
- updateParams(obj);
- /*SgCamera *cam = gActiveCamera;
-
- rsMatrixLoad(&vConst->model, &objTransform->globalMat);
- rsMatrixLoad(&vConst->viewProj, &cam->viewProj);
- rsgAllocationSyncAll(rsGetAllocation(vConst));*/
- fConst->cameraPos = gActiveCamera->position;
- rsgAllocationSyncAll(rsGetAllocation(fConst));
+ rsgBindConstant(renderState->pv, 0, obj->pv_const);
+ rsgBindConstant(renderState->pf, 0, obj->pf_const);
if (rsIsObject(renderState->ps)) {
rsgBindProgramStore(renderState->ps);
@@ -203,13 +87,7 @@ static void draw(SgRenderable *obj) {
static void sortToBucket(SgRenderable *obj) {
const SgRenderState *renderState = (const SgRenderState *)rsGetElementAt(obj->render_state, 0);
if (rsIsObject(renderState->ps)) {
-#define MR1_API
-#ifndef MR1_API
- bool isOpaque = (rsgProgramStoreGetBlendSrcFunc(renderState->ps) == RS_BLEND_SRC_ONE) &&
- (rsgProgramStoreGetBlendDstFunc(renderState->ps) == RS_BLEND_DST_ZERO);
-#else
bool isOpaque = false;
-#endif
if (isOpaque) {
gFrontToBack[gFrontToBackCount++] = (uint32_t)obj;
} else {