summaryrefslogtreecommitdiffstats
path: root/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/ShaderParam.java
diff options
context:
space:
mode:
authorAlex Sakhartchouk <alexst@google.com>2012-01-20 14:22:48 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-01-20 14:22:48 -0800
commit3e60290d96ca28a97542aa13dc7b1d77a8243eaf (patch)
treed9718b2e1d7684ec106dde648e7483126c552b75 /tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/ShaderParam.java
parentab42f56f4c9af02d7881a59888071cdfd61bd12e (diff)
parent4fd35d8f49dbed174828da60b70c37e7a77a0d13 (diff)
downloadframeworks_base-3e60290d96ca28a97542aa13dc7b1d77a8243eaf.zip
frameworks_base-3e60290d96ca28a97542aa13dc7b1d77a8243eaf.tar.gz
frameworks_base-3e60290d96ca28a97542aa13dc7b1d77a8243eaf.tar.bz2
Merge "Many optimizations of rendering path. Adding ability to split up per shader and per object updates. Added cubemaps as scenegraph objects." into graphics-dev
Diffstat (limited to 'tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/ShaderParam.java')
-rw-r--r--tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/ShaderParam.java37
1 files changed, 35 insertions, 2 deletions
diff --git a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/ShaderParam.java b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/ShaderParam.java
index 627d3b7..742b14d 100644
--- a/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/ShaderParam.java
+++ b/tests/RenderScriptTests/SceneGraph/src/com/android/scenegraph/ShaderParam.java
@@ -18,13 +18,16 @@ package com.android.scenegraph;
import java.lang.Math;
import java.util.ArrayList;
+import java.util.HashMap;
-import android.renderscript.RenderScriptGL;
+import com.android.scenegraph.Transform;
+
+import android.renderscript.Element;
import android.renderscript.Matrix4f;
import android.renderscript.ProgramFragment;
import android.renderscript.ProgramStore;
import android.renderscript.ProgramVertex;
-import android.renderscript.Element;
+import android.renderscript.RenderScriptGL;
import android.util.Log;
/**
@@ -67,6 +70,36 @@ public abstract class ShaderParam extends SceneGraphBase {
String mParamName;
int mOffset;
+ static void fillInParams(Element constantElem,
+ HashMap<String, ShaderParam> sourceParams,
+ Transform transform,
+ ArrayList<ShaderParam> paramList) {
+ int subElemCount = constantElem.getSubElementCount();
+ for (int i = 0; i < subElemCount; i ++) {
+ String inputName = constantElem.getSubElementName(i);
+ int offset = constantElem.getSubElementOffsetBytes(i);
+
+ ShaderParam matchingParam = sourceParams.get(inputName);
+ Element subElem = constantElem.getSubElement(i);
+ // Make one if it's not there
+ if (matchingParam == null) {
+ if (subElem.getDataType() == Element.DataType.FLOAT_32) {
+ matchingParam = new Float4Param(inputName);
+ } else if (subElem.getDataType() == Element.DataType.MATRIX_4X4) {
+ TransformParam trParam = new TransformParam(inputName);
+ trParam.setTransform(transform);
+ matchingParam = trParam;
+ }
+ }
+ matchingParam.setOffset(offset);
+ if (subElem.getDataType() == Element.DataType.FLOAT_32) {
+ Float4Param fParam = (Float4Param)matchingParam;
+ fParam.setVecSize(subElem.getVectorSize());
+ }
+ paramList.add(matchingParam);
+ }
+ }
+
public ShaderParam(String name) {
mParamName = name;
}