Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upUse OpenGL texture arrays where available to improve batching. #60
Conversation
|
See glennw/servo#8 |
| @@ -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.
This comment has been minimized.
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.
This comment has been minimized.
| @@ -2,9 +2,11 @@ | |||
| precision mediump float; | |||
This comment has been minimized.
This comment has been minimized.
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.
This comment has been minimized.
| @@ -742,11 +1055,23 @@ impl Device { | |||
| vertex_stride, | |||
| 16); | |||
| gl::vertex_attrib_pointer(VertexAttribute::MatrixIndex as gl::GLuint, | |||
| 4, | |||
This comment has been minimized.
This comment has been minimized.
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.
9589ede
to
813153f
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.
|
Rebased and updated per review. |
Use OpenGL texture arrays where available to improve batching.
Allow serde_macros to be used
pcwalton commentedOct 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.