diff options
author | Alex Sakhartchouk <alexst@google.com> | 2010-10-06 11:15:01 -0700 |
---|---|---|
committer | Alex Sakhartchouk <alexst@google.com> | 2010-10-06 11:15:01 -0700 |
commit | d2091639be426574c04f74969fe553162d7a51c9 (patch) | |
tree | 29be1a27b9724fb95d53d127771fa38016929fe3 | |
parent | 76322af2a6c109a79431f019dcef6e038c030686 (diff) | |
download | frameworks_base-d2091639be426574c04f74969fe553162d7a51c9.zip frameworks_base-d2091639be426574c04f74969fe553162d7a51c9.tar.gz frameworks_base-d2091639be426574c04f74969fe553162d7a51c9.tar.bz2 |
changing vec4 to vec2 for perf reasons.
Change-Id: Ic885a6dc697af4fd82e184158772863673f041bd
-rw-r--r-- | graphics/java/android/renderscript/ProgramFragment.java | 2 | ||||
-rw-r--r-- | graphics/java/android/renderscript/ProgramVertex.java | 6 | ||||
-rw-r--r-- | libs/rs/java/Samples/res/raw/multitexf.glsl | 2 | ||||
-rw-r--r-- | libs/rs/rsFont.cpp | 2 | ||||
-rw-r--r-- | libs/rs/rsProgramFragment.cpp | 2 | ||||
-rw-r--r-- | libs/rs/rsProgramVertex.cpp | 5 |
6 files changed, 10 insertions, 9 deletions
diff --git a/graphics/java/android/renderscript/ProgramFragment.java b/graphics/java/android/renderscript/ProgramFragment.java index c1d6428..8858b74 100644 --- a/graphics/java/android/renderscript/ProgramFragment.java +++ b/graphics/java/android/renderscript/ProgramFragment.java @@ -104,7 +104,7 @@ public class ProgramFragment extends Program { private void buildShaderString() { mShader = "//rs_shader_internal\n"; mShader += "varying lowp vec4 varColor;\n"; - mShader += "varying vec4 varTex0;\n"; + mShader += "varying vec2 varTex0;\n"; mShader += "void main() {\n"; if (mVaryingColorEnable) { diff --git a/graphics/java/android/renderscript/ProgramVertex.java b/graphics/java/android/renderscript/ProgramVertex.java index 63e2598..65a0af2 100644 --- a/graphics/java/android/renderscript/ProgramVertex.java +++ b/graphics/java/android/renderscript/ProgramVertex.java @@ -101,7 +101,7 @@ public class ProgramVertex extends Program { mShader = "//rs_shader_internal\n"; mShader += "varying vec4 varColor;\n"; - mShader += "varying vec4 varTex0;\n"; + mShader += "varying vec2 varTex0;\n"; mShader += "void main() {\n"; mShader += " gl_Position = UNI_MVP * ATTRIB_position;\n"; @@ -109,7 +109,7 @@ public class ProgramVertex extends Program { mShader += " varColor = ATTRIB_color;\n"; if (mTextureMatrixEnable) { - mShader += " varTex0 = UNI_TexMatrix * ATTRIB_texture0;\n"; + mShader += " varTex0 = (UNI_TexMatrix * vec4(ATTRIB_texture0, 0.0, 1.0)).xy;\n"; } else { mShader += " varTex0 = ATTRIB_texture0;\n"; } @@ -126,7 +126,7 @@ public class ProgramVertex extends Program { b.add(Element.F32_4(mRS), "position"); b.add(Element.F32_4(mRS), "color"); b.add(Element.F32_3(mRS), "normal"); - b.add(Element.F32_4(mRS), "texture0"); + b.add(Element.F32_2(mRS), "texture0"); addInput(b.create()); return super.create(); diff --git a/libs/rs/java/Samples/res/raw/multitexf.glsl b/libs/rs/java/Samples/res/raw/multitexf.glsl index 91151ad..351ff9b 100644 --- a/libs/rs/java/Samples/res/raw/multitexf.glsl +++ b/libs/rs/java/Samples/res/raw/multitexf.glsl @@ -1,4 +1,4 @@ -varying vec4 varTex0; +varying vec2 varTex0; void main() { vec2 t0 = varTex0.xy; diff --git a/libs/rs/rsFont.cpp b/libs/rs/rsFont.cpp index b9de7e1..a951005 100644 --- a/libs/rs/rsFont.cpp +++ b/libs/rs/rsFont.cpp @@ -497,7 +497,7 @@ bool FontState::cacheBitmap(FT_Bitmap *bitmap, uint32_t *retOriginX, uint32_t *r void FontState::initRenderState() { - String8 shaderString("varying vec4 varTex0;\n"); + String8 shaderString("varying vec2 varTex0;\n"); shaderString.append("void main() {\n"); shaderString.append(" lowp vec4 col = UNI_Color;\n"); shaderString.append(" col.a = texture2D(UNI_Tex0, varTex0.xy).a;\n"); diff --git a/libs/rs/rsProgramFragment.cpp b/libs/rs/rsProgramFragment.cpp index c94f294..81b4fa4 100644 --- a/libs/rs/rsProgramFragment.cpp +++ b/libs/rs/rsProgramFragment.cpp @@ -190,7 +190,7 @@ void ProgramFragmentState::init(Context *rsc) { String8 shaderString(RS_SHADER_INTERNAL); shaderString.append("varying lowp vec4 varColor;\n"); - shaderString.append("varying vec4 varTex0;\n"); + shaderString.append("varying vec2 varTex0;\n"); shaderString.append("void main() {\n"); shaderString.append(" lowp vec4 col = UNI_Color;\n"); shaderString.append(" gl_FragColor = col;\n"); diff --git a/libs/rs/rsProgramVertex.cpp b/libs/rs/rsProgramVertex.cpp index d3dbfb2..a785262 100644 --- a/libs/rs/rsProgramVertex.cpp +++ b/libs/rs/rsProgramVertex.cpp @@ -242,6 +242,7 @@ ProgramVertexState::~ProgramVertexState() void ProgramVertexState::init(Context *rsc) { const Element *matrixElem = Element::create(rsc, RS_TYPE_MATRIX_4X4, RS_KIND_USER, false, 1); + const Element *f2Elem = Element::create(rsc, RS_TYPE_FLOAT_32, RS_KIND_USER, false, 2); const Element *f3Elem = Element::create(rsc, RS_TYPE_FLOAT_32, RS_KIND_USER, false, 3); const Element *f4Elem = Element::create(rsc, RS_TYPE_FLOAT_32, RS_KIND_USER, false, 4); @@ -256,7 +257,7 @@ void ProgramVertexState::init(Context *rsc) rsc->mStateElement.elementBuilderAdd(f4Elem, "position", 1); rsc->mStateElement.elementBuilderAdd(f4Elem, "color", 1); rsc->mStateElement.elementBuilderAdd(f3Elem, "normal", 1); - rsc->mStateElement.elementBuilderAdd(f4Elem, "texture0", 1); + rsc->mStateElement.elementBuilderAdd(f2Elem, "texture0", 1); const Element *attrElem = rsc->mStateElement.elementBuilderCreate(rsc); Type *inputType = new Type(rsc); @@ -266,7 +267,7 @@ void ProgramVertexState::init(Context *rsc) String8 shaderString(RS_SHADER_INTERNAL); shaderString.append("varying vec4 varColor;\n"); - shaderString.append("varying vec4 varTex0;\n"); + shaderString.append("varying vec2 varTex0;\n"); shaderString.append("void main() {\n"); shaderString.append(" gl_Position = UNI_MVP * ATTRIB_position;\n"); shaderString.append(" gl_PointSize = 1.0;\n"); |