Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NV12 and TEXTURE_EXTERNAL_OES target support in WR. #1150

Merged
merged 21 commits into from Apr 27, 2017
Merged
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
deeebf5
Remove the vStretchSize assignment in ps_image vertex shader
JerryShih Apr 19, 2017
06d7376
Add samplerExternalOES support.
JerryShih Apr 19, 2017
bfc555f
Remove the unused data member in YuvImage.
JerryShih Apr 19, 2017
9dfebbb
Add samplerExternalOES support in ps_image shader.
JerryShih Apr 20, 2017
a559829
Use preprocessor to select the yuv color matrix in ps_yuv_image shader.
JerryShih Apr 20, 2017
0f5a96f
Reorder some function calls in ps_yuv_image shader.
JerryShih Apr 20, 2017
c75bb28
Add samplerExternalOES, sampler2dRect target and NV12 format support …
JerryShih Apr 20, 2017
7f53f91
Add new package in webrender and webrender_traits.
JerryShih Apr 20, 2017
652735a
Add enum ImageBufferKind, ImageBufferKind and YuvColorSpace.
JerryShih Apr 20, 2017
5a65e6c
Update push_yuv_image() interface.
JerryShih Apr 20, 2017
f734c68
Remove the match of |_| with ExternalImageType type.
JerryShih Apr 20, 2017
41ce8dd
Pass ImageBufferKind, YuvFormat and YuvColorSpace in AlphaBatchKind t…
JerryShih Apr 20, 2017
9fe5754
Create the ps_image and ps_yuv_image arrays for different feature set…
JerryShih Apr 20, 2017
d3bd47e
Add yuv_image usage in sample.
JerryShih Apr 21, 2017
06ccad4
Set default yuv color space setting in ps_yuv_image.
JerryShih Apr 21, 2017
2e76503
Move the push_yuv_image() sample code from basic.rs to yuv.rs
JerryShih Apr 27, 2017
096f2c5
Update for review comment for ps_yuv_image shader.
JerryShih Apr 27, 2017
56b2d1d
Use a macro TEX_SAMPLE() to replace the different texture sampling fu…
JerryShih Apr 27, 2017
656303c
Remove the num::FromPrimitive usage for the enum YuvColorSpace, YuvFo…
JerryShih Apr 27, 2017
52b7331
Update for review comment.
JerryShih Apr 27, 2017
1d10e44
Add a YuvData type which contains the channel data and format informa…
JerryShih Apr 27, 2017
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Use a macro TEX_SAMPLE() to replace the different texture sampling fu…

…nctions for WR_FEATURE_TEXTURE_EXTERNAL and WR_FEATURE_TEXTURE_RECT features.
  • Loading branch information
JerryShih committed Apr 27, 2017
commit 56b2d1d1094948704c0b602a3b970442b67c40ac
@@ -28,15 +28,5 @@ void main(void) {

alpha = alpha * float(all(bvec2(step(position_in_tile, vStretchSize))));

#if defined(WR_FEATURE_TEXTURE_EXTERNAL) || defined(WR_FEATURE_TEXTURE_RECT)
// The textureLod() doesn't support samplerExternalOES.
// https://www.khronos.org/registry/OpenGL/extensions/OES/OES_EGL_image_external_essl3.txt
//
// The textureLod() doesn't support sampler2DRect, too.
//
// Use texture() instead.
oFragColor = vec4(alpha) * texture(sColor0, st);
#else
oFragColor = vec4(alpha) * textureLod(sColor0, st, 0.0);
#endif
oFragColor = vec4(alpha) * TEX_SAMPLE(sColor0, st);
}
@@ -64,32 +64,15 @@ void main(void) {

vec3 yuv_value;
#ifdef WR_FEATURE_NV12
#if defined(WR_FEATURE_TEXTURE_EXTERNAL) || defined(WR_FEATURE_TEXTURE_RECT)
// The textureLod() doesn't support samplerExternalOES.
// https://www.khronos.org/registry/OpenGL/extensions/OES/OES_EGL_image_external_essl3.txt
//
// The textureLod() doesn't support sampler2DRect, too.
//
// Use texture() instead.
yuv_value.x = texture(sColor0, st_y).r;
yuv_value.yz = texture(sColor1, st_u).rg;
#else
yuv_value.x = textureLod(sColor0, st_y, 0.0).r;
yuv_value.yz = textureLod(sColor1, st_u, 0.0).rg;
#endif
yuv_value.x = TEX_SAMPLE(sColor0, st_y).r;
yuv_value.yz = TEX_SAMPLE(sColor1, st_u).rg;
#else
// The yuv_planar format should have this third texture coordinate.
vec2 st_v = vTextureOffsetV + uv_offset;

#if defined(WR_FEATURE_TEXTURE_EXTERNAL) || defined(WR_FEATURE_TEXTURE_RECT)
yuv_value.x = texture(sColor0, st_y).r;
yuv_value.y = texture(sColor1, st_u).r;
yuv_value.z = texture(sColor2, st_v).r;
#else
yuv_value.x = textureLod(sColor0, st_y, 0.0).r;
yuv_value.y = textureLod(sColor1, st_u, 0.0).r;
yuv_value.z = textureLod(sColor2, st_v, 0.0).r;
#endif
yuv_value.x = TEX_SAMPLE(sColor0, st_y).r;
yuv_value.y = TEX_SAMPLE(sColor1, st_u).r;
yuv_value.z = TEX_SAMPLE(sColor2, st_v).r;
#endif

// See the YuvColorMatrix definition for an explanation of where the constants come from.
@@ -8,6 +8,19 @@
#extension GL_OES_EGL_image_external_essl3 : require

This comment has been minimized.

@JerryShih

JerryShih Apr 21, 2017

Author Contributor

The "#extension" should be placed before the first non-preprocessor-code.

#endif

// The textureLod() doesn't support samplerExternalOES for WR_FEATURE_TEXTURE_EXTERNAL.
// https://www.khronos.org/registry/OpenGL/extensions/OES/OES_EGL_image_external_essl3.txt
//
// The textureLod() doesn't support sampler2DRect for WR_FEATURE_TEXTURE_RECT, too.
//
// Use texture() instead.
#if defined(WR_FEATURE_TEXTURE_EXTERNAL) || defined(WR_FEATURE_TEXTURE_RECT)
#define TEX_SAMPLE(sampler, tex_coord) texture(sampler, tex_coord)
#else
// In normal case, we use textureLod(). We haven't used the lod yet. So, we always pass 0.0 now.
#define TEX_SAMPLE(sampler, tex_coord) textureLod(sampler, tex_coord, 0.0)
#endif

//======================================================================================
// Vertex shader attributes and uniforms
//======================================================================================
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.