Commit graph

334 commits

Author SHA1 Message Date
Fredrik Höglund
479ea5db61 kwin: Resolve functions for GL_ARB_copy_buffer 2013-06-05 00:41:24 +02:00
Fredrik Höglund
5e7b2a34a8 kwin: Resolve functions for GL_ARB_draw_elements_base_vertex 2013-06-05 00:41:23 +02:00
Fredrik Höglund
993b50cf1c kwin: Add a new GLVertexBuffer::draw() method
Expose bindArrays(), unbindArrays() and add a draw() method that takes
an offset and a count. This makes it possible to upload geometry, call
bindArrays(), and then call draw() multiple times to draw different
subsets of the uploaded geometry.
2013-06-05 00:41:23 +02:00
Fredrik Höglund
ac5f1317e9 kwin: Split WindowQuadDecoration into two types
Split WindowQuadDecoration into WindowQuadDecorationLeftRight
and WindowQuadDecorationTopBottom.

This simplifies the code in SceneOpenGL::Window::paintDecoration().
2013-06-05 00:41:22 +02:00
Martin Gräßlin
4b4646973b Use QList<KWin::EffectWindow*> as return type for mainWindows()
QtScript bindings fails when using EffectWindowList.
2013-06-04 17:17:08 +02:00
Martin Gräßlin
aa92d2dbd9 No repaints for keepAtTarget and before started
Do not schedule repaints in AnimationEffect if there are no animations
going on. If an animation is waiting for starting or kept after ending
the visual appearance is no longer changed, so no repaint is needed.

REVIEW: 110795
2013-06-03 15:45:02 +02:00
Fredrik Höglund
d6fadfa91c kwin: Add an SSE2 vertex upload path
Use MOVNTDQ instructions to write vertex data into the buffer object.
2013-05-29 17:53:08 +02:00
Fredrik Höglund
de4b7e8db1 kwin: Add WindowQuadList::makeInterleavedArrays()
Unlike makeArrays() this function writes into a pre-allocated array,
and takes a matrix that's used to transform the texture coordinates.
This allows this function to handle coordinates for rectangular
textures correctly.
2013-05-28 18:13:06 +02:00
Fredrik Höglund
a5a2561f69 kwin: Simplify WindowQuadList::makeArrays()
Note that unlike the previous commit, this doesn't fix texture coordinates
for rectangular textures. That case cannot be handled correctly without
knowing the dimensions of the texture.
2013-05-28 16:35:37 +02:00
Fredrik Höglund
d4aacd678e kwin: Add more accessors in WindowVertex
Reorder some of the methods and add new u() and v() accessors,
which are aliases of textureX() and textureY().
2013-05-28 16:35:37 +02:00
Fredrik Höglund
7a99b8c0ef kwin: Add GLTexture::matrix()
This method returns a matrix that transforms normalized or un-normalized
texture coordinates, taking the texture target and y-inversion flag into
account.
2013-05-28 16:35:36 +02:00
Fredrik Höglund
38678bb84f kwin: Don't unbind vertex array buffers
KWin always updates the array buffer binding before it calls GL functions
that reference it, so there is never any need to reset it.

This should eliminate half the calls to glBindBuffer() while painting
the scene.
2013-05-28 16:35:36 +02:00
Fredrik Höglund
159bcf11b6 kwin: Simplify the two setData() methods
Simplify the two setData() methods in GLVertexBuffer by implementing
them in terms of the new map() and unmap() methods.
2013-05-28 16:35:36 +02:00
Fredrik Höglund
188e6d04ca kwin: Expose a map() and an unmap() method in GLVertexBuffer
These methods make it possible to write directly into the buffer object
when building vertex arrays.

If the buffer object cannot be mapped, the map() method will return
a pointer to local memory which will be submitted to the buffer object
with glBufferData() when unmap() is called.
2013-05-28 16:35:36 +02:00
Fredrik Höglund
ab8c6aeec3 kwin: Add a new setData() method in GLVertexBuffer
This overload makes it possible to upload data of an arbitrary size and
type into the buffer object.  The intent is for this method to be used
to upload interleaved vertex data.

This commit also adds setVertexCount() and setAttribLayout().

The rationale for decoupling attribute specification from data uploading
is that the attribute formats and layout change less frequently than
the vertex data.

The vertex count is also specified using a separate function to enable
the caller to upload data for multiple draw calls at the same time.
2013-05-28 16:35:35 +02:00
Fredrik Höglund
395ff72555 kwin: Change the way attrib formats are stored in GLVertexBuffer
Store the formats as an array in GLVertexBufferPrivate.

This simplifies the code for enabling the generic vertex arrays,
and also makes it easier to add new arrays.
2013-05-28 16:35:35 +02:00
Fredrik Höglund
1de20a39a0 kwin: Add convenience classes for working with bitfields 2013-05-28 16:35:35 +02:00
Fredrik Höglund
5782d5307e kwin: Add a Color uniform in GLShader
And use it in GLVertexBufferPrivate::bindArrays(). Also store the color
as a QVector4D in GLVertexBufferPrivate.
2013-05-28 16:35:35 +02:00
Fredrik Höglund
c41d05d36c kwin: Do some more refactoring in GLVertexBuffer
Consolidate the code for binding and unbinding the vertex arrays into
two new methods called bindArrays() and unbindArrays() respectively.

This patch also removes the three paint implementations, since the only
difference between them is the code that sets up the arrays. The actual
painting code is moved into GLVertexBuffer::render(), which uses the
new methods to bind and unbind the arrays.
2013-05-28 16:35:35 +02:00
Martin Gräßlin
769c746a06 Use GLSL 1.40 shaders as GLSL 300 es shaders
In case OpenGL ES 3 is provided by the driver we can use the GLSL 1.40
shaders as GLSL 300 ES shaders. The #version declarative is rewritten in
such a case.

REVIEW: 110590
2013-05-23 09:06:21 +02:00
Martin Gräßlin
ad1203e3b2 Add defines from EXT_robustness
Seem to be missing in the headers used on build.kde.org.
2013-05-23 08:38:16 +02:00
Fredrik Höglund
19796b8263 kwin: Use the robust access functions
Use glReadnPixels() instead of glReadPixels(), and glGetnUniformfv()
instead of glGetUniformfv().
2013-05-21 00:22:57 +02:00
Fredrik Höglund
2f87b7542f kwin/es: Resolve functions for GL_EXT_robustness 2013-05-21 00:22:57 +02:00
Fredrik Höglund
adc581d2ab kwin: Resolve functions for GL_ARB_robustness
Only the subset of functions available in core contexts is resolved,
except for glGetnTexImageARB() and glGetnUniformivARB(), which are
not used by kwin.

Instead of setting the function pointers to NULL when the extension isn't
supported, kwin provides its own implementations that call the non-robust
versions of the functions.  This is so callers don't have to check if the
extension is supported before calling the functions.
2013-05-21 00:22:55 +02:00
Montel Laurent
dd8cf0b678 normalize signal/slot 2013-05-11 14:09:15 +02:00
Fredrik Höglund
2f11f71930 kwin: Bind attributes to the same indices in all shaders
This saves us from having to look up the attribute locations each
time we update the vertex array state.
2013-05-08 18:37:39 +02:00
Fredrik Höglund
87ad8789f1 kwin: Update the GL1 code in GLVertexBuffer to match the VBO code
This saves two memory allocations in the GL1 path in setData().
2013-05-08 18:37:27 +02:00
Fredrik Höglund
e1a33cec44 kwin: Don't reallocate the vertex buffer on every setData() call
Allocate enough space to hold the geometry for multiple draw calls,
and use glMapBufferRange() to gradually fill the buffer.  Once the
data store is full, it's orphaned and a new one is allocated.
2013-05-08 18:37:12 +02:00
Fredrik Höglund
0475559120 kwin: Use one buffer object in GLVertexBuffer
Store the vertex positions and texture coordinates in the same buffer
object. This saves one buffer allocation in every setData() call.

The attributes are also interleaved as they are uploaded into the buffer
to maximize locality of reference.
2013-05-08 18:37:02 +02:00
Fredrik Höglund
e65f717b47 kwin/es: Resolve functions for GL_EXT_map_buffer_range 2013-05-08 18:36:50 +02:00
Fredrik Höglund
b6585c2d8b kwin/es: Resolve functions for GL_OES_mapbuffer 2013-05-08 18:36:45 +02:00
Fredrik Höglund
11b9323f3d kwin: Resolve functions for GL_ARB_map_buffer_range 2013-05-08 18:36:38 +02:00
Fredrik Höglund
08d3b6cc3a kwin: Resolve more functions from ARB_vertex_buffer_object
This patch resolves:
    glMapBuffer()
    glUnmapBuffer()
    glBufferSubData()
    glGetBufferSubData()
2013-05-08 18:36:04 +02:00
Fredrik Höglund
b7f1856a35 kwin: Fix color correction with GLSL 1.40 2013-05-08 18:33:03 +02:00
Fredrik Höglund
54308889f0 kwin: Bind fragdata locations in ShaderManager
Fragment shaders are expected to declare a vec4 fragColor output,
which will be bound to the first draw buffer.
2013-05-08 18:33:03 +02:00
Fredrik Höglund
54b63a85a6 kwin: Add GLSL 1.40 versions of the scene shaders
Adjust ShaderManager to load the 1.40 versions when GLSL 1.40
is supported.
2013-05-08 18:33:03 +02:00
Fredrik Höglund
79db2fc98a kwin: Move the scene shaders into shaders/1.10 2013-05-08 18:33:03 +02:00
Fredrik Höglund
fe559c2f2c kwin: Refactor the ShaderManager code
This patch reduces code duplication and simplifies the code in general.
2013-05-08 18:33:03 +02:00
Fredrik Höglund
85a87bfcd1 kwin: Refactor GLShader to allow explicit linking
This patch adds a link() function, along with bindAttributeLocation()
and bindFragDataLocation().

These functions must be called after creating the program, but before
linking it.

A new ExplicitLinking flag must be passed to the constructor to prevent
automatic linking. This is to keep existing code working without
modifications.
2013-05-08 18:33:02 +02:00
Fredrik Höglund
e0003db385 kwin: Resolve functions for GL_EXT_gpu_shader4 2013-05-08 18:33:02 +02:00
Fredrik Höglund
2bcad53bbb kwin: Resolve functions for GL_ARB_vertex_array_object 2013-05-08 18:33:02 +02:00
Fredrik Höglund
2b00beecd2 kwin: Don't require GL_ARB_shading_language_100
This version of GLSL is not supported in a core context.
2013-05-08 18:33:02 +02:00
Fredrik Höglund
5b80d8d513 kwin: Fix shader function resolution for core contexts 2013-05-08 18:33:02 +02:00
Fredrik Höglund
cb81e11375 kwin: Fix FBO function resolution for core contexts 2013-05-08 18:33:02 +02:00
Fredrik Höglund
855a7cc897 kwin: Fix glActiveTexture() resolution for core contexts 2013-05-08 18:33:02 +02:00
Fredrik Höglund
1bcf95f3f9 kwin: Fix VBO function resolution for core contexts
Mesa doesn't advertise extensions that were core in 1.5 in an OpenGL
context that uses the core profile.
2013-05-08 18:33:02 +02:00
Fredrik Höglund
63e0d32706 kwin: Fix extension list query for core contexts
Use glGetStringi() to list the extensions when the GL version is 3.0
or greater. glGetString() does not accept the GL_EXTENSIONS token
in an OpenGL core context.
2013-05-08 18:33:01 +02:00
Fredrik Höglund
d116ef6655 kwin/egl: Add defines for EGL_KHR_create_context 2013-05-08 18:33:01 +02:00
Fredrik Höglund
aab026af93 kwin: Resolve functions for GLX_ARB_create_context 2013-05-08 18:12:43 +02:00
Martin Gräßlin
49e734f743 Change the way how effects can get mouse events
With the removal of BoxSwitch all effects which want mouse events use the
fullscreen input window. The available functionality is too complex both
in EffectsHandler and in the Effects.

With this change only fullscreen input windows are supported and all
effects share the input window. This means there is at maximum one input
window. This simplifies the code in the Effects as they don't have to
keep track of the window they created any more. In EffectsHandler it
means that only one window needs to be created, destroyed and raised.
Also it means that we can properly react on screen size changes which had
been ignored in the past. Also quite some roundtrips to X are no longer
needed as we do not need to query the window geometry when creating the
input window.

REVIEW: 110156
2013-05-03 08:15:42 +02:00