Remove redundant attribute from matrix transformation vertex shader.

The texture coordinates can be derived from the frame coordinates.

PiperOrigin-RevId: 446770538
This commit is contained in:
hschlueter 2022-05-05 19:24:44 +01:00 committed by Ian Baker
parent 3dec4266a3
commit e9919f6da1
9 changed files with 6 additions and 20 deletions

View File

@ -16,9 +16,8 @@
// ES 2 vertex shader that leaves the coordinates unchanged. // ES 2 vertex shader that leaves the coordinates unchanged.
attribute vec4 aFramePosition; attribute vec4 aFramePosition;
attribute vec4 aTexSamplingCoord;
varying vec2 vTexSamplingCoord; varying vec2 vTexSamplingCoord;
void main() { void main() {
gl_Position = aFramePosition; gl_Position = aFramePosition;
vTexSamplingCoord = aTexSamplingCoord.xy; vTexSamplingCoord = vec2(aFramePosition.x * 0.5 + 0.5, aFramePosition.y * 0.5 + 0.5);
} }

View File

@ -102,8 +102,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
// Draw the frame on the entire normalized device coordinate space, from -1 to 1, for x and y. // Draw the frame on the entire normalized device coordinate space, from -1 to 1, for x and y.
glProgram.setBufferAttribute( glProgram.setBufferAttribute(
"aFramePosition", GlUtil.getNormalizedCoordinateBounds(), GlUtil.RECTANGLE_VERTICES_COUNT); "aFramePosition", GlUtil.getNormalizedCoordinateBounds(), GlUtil.RECTANGLE_VERTICES_COUNT);
glProgram.setBufferAttribute(
"aTexSamplingCoord", GlUtil.getTextureCoordinateBounds(), GlUtil.RECTANGLE_VERTICES_COUNT);
glProgram.setSamplerTexIdUniform("uTexSampler0", inputTexId, /* texUnitIndex= */ 0); glProgram.setSamplerTexIdUniform("uTexSampler0", inputTexId, /* texUnitIndex= */ 0);
glProgram.setSamplerTexIdUniform("uTexSampler1", bitmapTexId, /* texUnitIndex= */ 1); glProgram.setSamplerTexIdUniform("uTexSampler1", bitmapTexId, /* texUnitIndex= */ 1);
glProgram.setFloatUniform("uScaleX", bitmapScaleX); glProgram.setFloatUniform("uScaleX", bitmapScaleX);

View File

@ -88,8 +88,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
// Draw the frame on the entire normalized device coordinate space, from -1 to 1, for x and y. // Draw the frame on the entire normalized device coordinate space, from -1 to 1, for x and y.
glProgram.setBufferAttribute( glProgram.setBufferAttribute(
"aFramePosition", GlUtil.getNormalizedCoordinateBounds(), GlUtil.RECTANGLE_VERTICES_COUNT); "aFramePosition", GlUtil.getNormalizedCoordinateBounds(), GlUtil.RECTANGLE_VERTICES_COUNT);
glProgram.setBufferAttribute(
"aTexSamplingCoord", GlUtil.getTextureCoordinateBounds(), GlUtil.RECTANGLE_VERTICES_COUNT);
} }
@Override @Override

View File

@ -145,10 +145,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
"aFramePosition", "aFramePosition",
GlUtil.getNormalizedCoordinateBounds(), GlUtil.getNormalizedCoordinateBounds(),
GlUtil.RECTANGLE_VERTICES_COUNT); GlUtil.RECTANGLE_VERTICES_COUNT);
glProgram.setBufferAttribute(
"aTexSamplingCoord",
GlUtil.getTextureCoordinateBounds(),
GlUtil.RECTANGLE_VERTICES_COUNT);
glProgram.bindAttributesAndUniforms(); glProgram.bindAttributesAndUniforms();
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, /* first= */ 0, /* count= */ 4); GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, /* first= */ 0, /* count= */ 4);
GlUtil.checkGlError(); GlUtil.checkGlError();

View File

@ -18,10 +18,10 @@
// locations. // locations.
attribute vec4 aFramePosition; attribute vec4 aFramePosition;
attribute vec4 aTexSamplingCoord;
uniform mat4 uTexTransform; uniform mat4 uTexTransform;
varying vec2 vTexSamplingCoord; varying vec2 vTexSamplingCoord;
void main() { void main() {
gl_Position = aFramePosition; gl_Position = aFramePosition;
vTexSamplingCoord = (uTexTransform * aTexSamplingCoord).xy; vec4 texturePosition = vec4(aFramePosition.x * 0.5 + 0.5, aFramePosition.y * 0.5 + 0.5, 0.0, 1.0);
vTexSamplingCoord = (uTexTransform * texturePosition).xy;
} }

View File

@ -18,10 +18,10 @@
// locations. // locations.
in vec4 aFramePosition; in vec4 aFramePosition;
in vec4 aTexSamplingCoord;
uniform mat4 uTexTransform; uniform mat4 uTexTransform;
out vec2 vTexSamplingCoord; out vec2 vTexSamplingCoord;
void main() { void main() {
gl_Position = aFramePosition; gl_Position = aFramePosition;
vTexSamplingCoord = (uTexTransform * aTexSamplingCoord).xy; vec4 texturePosition = vec4(aFramePosition.x * 0.5 + 0.5, aFramePosition.y * 0.5 + 0.5, 0.0, 1.0);
vTexSamplingCoord = (uTexTransform * texturePosition).xy;
} }

View File

@ -17,10 +17,9 @@
// uTransformationMatrix. // uTransformationMatrix.
attribute vec4 aFramePosition; attribute vec4 aFramePosition;
attribute vec4 aTexSamplingCoord;
uniform mat4 uTransformationMatrix; uniform mat4 uTransformationMatrix;
varying vec2 vTexSamplingCoord; varying vec2 vTexSamplingCoord;
void main() { void main() {
gl_Position = uTransformationMatrix * aFramePosition; gl_Position = uTransformationMatrix * aFramePosition;
vTexSamplingCoord = aTexSamplingCoord.xy; vTexSamplingCoord = vec2(aFramePosition.x * 0.5 + 0.5, aFramePosition.y * 0.5 + 0.5);
} }

View File

@ -80,8 +80,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
// Draw the frame on the entire normalized device coordinate space, from -1 to 1, for x and y. // Draw the frame on the entire normalized device coordinate space, from -1 to 1, for x and y.
glProgram.setBufferAttribute( glProgram.setBufferAttribute(
"aFramePosition", GlUtil.getNormalizedCoordinateBounds(), GlUtil.RECTANGLE_VERTICES_COUNT); "aFramePosition", GlUtil.getNormalizedCoordinateBounds(), GlUtil.RECTANGLE_VERTICES_COUNT);
glProgram.setBufferAttribute(
"aTexSamplingCoord", GlUtil.getTextureCoordinateBounds(), GlUtil.RECTANGLE_VERTICES_COUNT);
if (enableExperimentalHdrEditing) { if (enableExperimentalHdrEditing) {
// In HDR editing mode the decoder output is sampled in YUV. // In HDR editing mode the decoder output is sampled in YUV.
glProgram.setFloatsUniform("uColorTransform", MATRIX_YUV_TO_BT2020_COLOR_TRANSFORM); glProgram.setFloatsUniform("uColorTransform", MATRIX_YUV_TO_BT2020_COLOR_TRANSFORM);

View File

@ -89,8 +89,6 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
// Draw the frame on the entire normalized device coordinate space, from -1 to 1, for x and y. // Draw the frame on the entire normalized device coordinate space, from -1 to 1, for x and y.
glProgram.setBufferAttribute( glProgram.setBufferAttribute(
"aFramePosition", GlUtil.getNormalizedCoordinateBounds(), GlUtil.RECTANGLE_VERTICES_COUNT); "aFramePosition", GlUtil.getNormalizedCoordinateBounds(), GlUtil.RECTANGLE_VERTICES_COUNT);
glProgram.setBufferAttribute(
"aTexSamplingCoord", GlUtil.getTextureCoordinateBounds(), GlUtil.RECTANGLE_VERTICES_COUNT);
} }
@Override @Override