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

Use OpenGL texture arrays where available to improve batching. #60

Merged
merged 1 commit into from Oct 28, 2015

Conversation

@pcwalton
Copy link
Collaborator

pcwalton commented Oct 27, 2015

This takes an upgrade to OpenGL 3.x on the Mac. Because the Mac OpenGL
implementation does not support the Compatibility Profile as far as I'm
aware, the shaders have been rewritten to use some preprocessor magic to
work on both OpenGL ES 2.1 and OpenGL 3.x.

Memory usage will likely be somewhat suboptimal until we are dynamically
resizing texture arrays.

Closes #38.

@pcwalton
Copy link
Collaborator Author

pcwalton commented Oct 27, 2015

@@ -8,8 +6,10 @@ uniform sampler2D sDiffuse;
uniform sampler2D sMask;
uniform vec4 uBlendParams;

varying vec2 vColorTexCoord;
varying vec2 vMaskTexCoord;
IN_VARYING vec2 vColorTexCoord;

This comment has been minimized.

@glennw

glennw Oct 27, 2015

Member

I think what we should do is introduce 2 new resource files, something like es2_common.glsl and gl3_common.glsl. These could define a function for sampling a texture, and also define all the attributes, varyings etc. Then the runtime code can prefix the shader compiles with the appropriate file. This means we won't need any preprocessor tricks, which I've found flaky in several real world GL drivers. It will also simplify the shaders since we'll have one place to declare all varyings etc (it doesn't matter if you declare unused varyings, attributes etc - they'll get stripped out).


mat4 matrix = uMatrixPalette[int(aMatrixIndex.x)];
vec4 pos = matrix * vec4(aPosition, 1.0);
pos.xy = floor(pos.xy * uDevicePixelRatio + 0.5) / uDevicePixelRatio;

This comment has been minimized.

@glennw

glennw Oct 27, 2015

Member

You removed the hidpi scale here.

@@ -2,9 +2,11 @@
precision mediump float;

This comment has been minimized.

@glennw

glennw Oct 27, 2015

Member

I don't think this shader is used at all - we should just remove it I think.

@@ -179,12 +183,26 @@ pub struct Device {

#[cfg(not(any(target_os = "android", target_os = "gonk")))]
fn shader_preamble() -> &'static str {
""

This comment has been minimized.

@glennw

glennw Oct 27, 2015

Member

This whole string should disappear with common shader include files.

@@ -742,11 +1055,23 @@ impl Device {
vertex_stride,
16);
gl::vertex_attrib_pointer(VertexAttribute::MatrixIndex as gl::GLuint,
4,

This comment has been minimized.

@glennw

glennw Oct 27, 2015

Member

Some GPUs pay a per-attribute cycle fetch penalty. Let's make this one attribute of four bytes, with x=matrix index, y=color tex index etc.

@pcwalton pcwalton force-pushed the pcwalton:texture-array branch 2 times, most recently from 9589ede to 813153f Oct 28, 2015
This takes an upgrade to OpenGL 3.x on the Mac. Because the Mac OpenGL
implementation does not support the Compatibility Profile as far as I'm
aware, the shaders have been rewritten to use some preprocessor magic to
work on both OpenGL ES 2.1 and OpenGL 3.x.

Memory usage will likely be somewhat suboptimal until we are dynamically
resizing texture arrays.

Closes #38.
@pcwalton
Copy link
Collaborator Author

pcwalton commented Oct 28, 2015

Rebased and updated per review.

glennw added a commit that referenced this pull request Oct 28, 2015
Use OpenGL texture arrays where available to improve batching.
@glennw glennw merged commit 2b91022 into servo:master Oct 28, 2015
nox pushed a commit to nox/webrender that referenced this pull request Aug 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.