mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-13 14:00:09 +00:00
gpu: Cache GL state
That way we don't need to setup the textures and program for every command.
This commit is contained in:
parent
1733671295
commit
6230ff0fc4
@ -155,10 +155,10 @@ gsk_gpu_mipmap_op_gl_command (GskGpuOp *op,
|
||||
{
|
||||
GskGpuMipmapOp *self = (GskGpuMipmapOp *) op;
|
||||
|
||||
/* not sure the ActiveTexture call is needed, but better not
|
||||
* use any random texturing instance */
|
||||
glActiveTexture (GL_TEXTURE0);
|
||||
gsk_gl_image_bind_texture (GSK_GL_IMAGE (self->image));
|
||||
/* need to reset the images again */
|
||||
state->desc = NULL;
|
||||
|
||||
glGenerateMipmap (GL_TEXTURE_2D);
|
||||
|
||||
|
@ -23,6 +23,12 @@ typedef struct _GskVulkanCommandState GskVulkanCommandState;
|
||||
struct _GskGLCommandState
|
||||
{
|
||||
gsize flip_y;
|
||||
struct {
|
||||
const GskGpuOpClass *op_class;
|
||||
GskGpuShaderClip clip;
|
||||
gsize n_external;
|
||||
} current_program;
|
||||
GskGLDescriptors *desc;
|
||||
};
|
||||
|
||||
#ifdef GDK_RENDERING_VULKAN
|
||||
|
@ -92,16 +92,32 @@ gsk_gpu_shader_op_gl_command_n (GskGpuOp *op,
|
||||
GskGpuShaderOpClass *shader_op_class = (GskGpuShaderOpClass *) op->op_class;
|
||||
GskGLDescriptors *desc;
|
||||
GskGpuOp *next;
|
||||
gsize i, n;
|
||||
gsize i, n, n_external;
|
||||
|
||||
desc = GSK_GL_DESCRIPTORS (self->desc);
|
||||
if (desc)
|
||||
n_external = gsk_gl_descriptors_get_n_external (desc);
|
||||
else
|
||||
n_external = 0;
|
||||
|
||||
if (state->current_program.op_class != op->op_class ||
|
||||
state->current_program.clip != self->clip ||
|
||||
state->current_program.n_external != n_external)
|
||||
{
|
||||
state->current_program.op_class = op->op_class;
|
||||
state->current_program.clip = self->clip;
|
||||
state->current_program.n_external = n_external;
|
||||
gsk_gl_frame_use_program (GSK_GL_FRAME (frame),
|
||||
shader_op_class,
|
||||
self->clip,
|
||||
desc ? gsk_gl_descriptors_get_n_external (desc) : 0);
|
||||
n_external);
|
||||
}
|
||||
|
||||
if (desc)
|
||||
gsk_gl_descriptors_use (GSK_GL_DESCRIPTORS (desc));
|
||||
if (desc != state->desc && desc)
|
||||
{
|
||||
gsk_gl_descriptors_use (desc);
|
||||
state->desc = desc;
|
||||
}
|
||||
|
||||
if (gsk_gpu_frame_should_optimize (frame, GSK_GPU_OPTIMIZE_MERGE))
|
||||
n = MAX_MERGE_OPS;
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#define GSK_GPU_PATTERN_STACK_SIZE 16
|
||||
|
||||
typedef struct _GskGLDescriptors GskGLDescriptors;
|
||||
typedef struct _GskGpuBuffer GskGpuBuffer;
|
||||
typedef struct _GskGpuDescriptors GskGpuDescriptors;
|
||||
typedef struct _GskGpuDevice GskGpuDevice;
|
||||
|
Loading…
Reference in New Issue
Block a user