Commit Graph

15 Commits

Author SHA1 Message Date
Benjamin Otte
2d2209859e gsk: Rename to gsk_texture_download_surface()
I want to reuse the name gsk_texture_download() for downloading the
actual bytes.
2016-12-23 08:11:01 +01:00
Benjamin Otte
4b484557f5 gsk: Allow 0 for gsk_gl_driver_begin_frame()
Special-case this situation to unset the current framebuffer and render
to the backbuffer again.
2016-12-05 15:02:47 +01:00
Matthias Clasen
585b1d5f67 gsk: Don't leak texture surfaces
gsk_texture_download returns a reference.
2016-11-17 20:30:34 -05:00
Benjamin Otte
48e7f4191f gsktexture: Allow attaching render data to textures
This allows renderers (or anyone really) to attach "render data" to
textures. Only the first render data sticks.

You can gsk_texture_set_render_data() with the key you will use to
look the data up again, and if no data has been set yet, yours will be
set.

You can retrieve this data via gsk_texture_get_render_data() later on.
If your data has been cleared, NULL will be returned.

When gsk_texture_clear_render_data() is called (which the texture will
call when it is finalized), your destory notify will be called and you
have to release your render data.

The GL driver uses this to attach texture ids to GskTextures.
2016-11-16 17:36:33 +01:00
Benjamin Otte
46eb2c1be9 gsk: Add GskTexture 2016-11-08 20:31:34 +01:00
Emmanuele Bassi
e161f9eba3 gsk: Add check on GL_MAX_TEXTURE_SIZE
We should check (once) what's the maximum GL texture size and then use
that size to check when we create any GL texture, to avoid errors.
2016-10-26 15:49:28 +01:00
Emmanuele Bassi
0812d691b3 gsk: Reuse VAOs with identical buffers
Just like we reuse texture ids with the same size we can, at the expense
of a little memory, reuse vertex buffers if they reference the same
attributes and contain the same data.

Each VAO is marked as free at the end of the frame, and if it's not
reused in the following frame, it gets dropped.
2016-10-18 11:49:13 +01:00
Emmanuele Bassi
32d45b0081 gsk: Pass the appropriate value for the n_quads argument
Instead of passing the size of the buffer, we should pass the number of
quads; we know what the size of a single quad structure is, so we can do
the multiplication internally when creating the VAO.

This allows us to print the quads for debugging purposes.
2016-10-18 11:49:12 +01:00
Emmanuele Bassi
702befc697 gsk: Recycle textures across frames
We keep the textures used inside a frame around until the end of the
following frame; whenever we need a texture with the same size, and
it's not marked in use, then we just reuse the existing texture.
2016-10-18 11:49:11 +01:00
Emmanuele Bassi
24a6f3c055 gsk: Move resource handling inside GskGLDriver
We want the GL driver to cache as many resources as possible, so we can
always ensure that we're in a consistent state, and we can handle state
transitions more appropriately.
2016-10-18 11:49:09 +01:00
Emmanuele Bassi
b169ce374e gsk: Rework surface -> texture API
Drop the texture parameters handling from the texture creation, and
associate them with the contents upload. Also, rename the function to
something more in line with what it does.
2016-10-18 11:49:09 +01:00
Emmanuele Bassi
e2a43a8701 gsk: Add GL driver API to create render targets
It's going to be used by the GL renderer to safely create and bind
FBOs when needed.
2016-10-18 11:49:09 +01:00
Emmanuele Bassi
9836d2259f gsk: Turn texture cache into a hash table
We want to add the list of FBOs tied to a texture; this means we cannot
trivally copy the Texture structure when adding it to a GArray. We're
also going to have more textures than VAOs, so it makes more sense to
use a O(1) access data structure for them.
2016-10-18 11:49:08 +01:00
Emmanuele Bassi
8807f23f76 gsk: Split surface upload from texture creation
We're going to need a method to create textures without a surface.
2016-10-18 11:49:08 +01:00
Emmanuele Bassi
46bb14e173 gsk: Add GskGLDriver
We can move the caching and management of textures, VAOs, and state of
the GL machinery into a single object, GskGLDriver.
2016-10-18 11:49:08 +01:00