mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-29 06:51:10 +00:00
be09cebb09
In the case where descriptor indexing is not enabled and the number of max images is small (or we use extensive amounts of immutable samplers), we need to be able to switch descriptors. This patch makes that possible.
99 lines
2.7 KiB
C
99 lines
2.7 KiB
C
#include "config.h"
|
|
|
|
#include "gskgpuglobalsopprivate.h"
|
|
|
|
#include "gskgpuframeprivate.h"
|
|
#include "gskgpuprintprivate.h"
|
|
#include "gskroundedrectprivate.h"
|
|
#ifdef GDK_RENDERING_VULKAN
|
|
#include "gskvulkandeviceprivate.h"
|
|
#include "gskvulkanframeprivate.h"
|
|
#include "gskvulkandescriptorsprivate.h"
|
|
#endif
|
|
|
|
typedef struct _GskGpuGlobalsOp GskGpuGlobalsOp;
|
|
|
|
struct _GskGpuGlobalsOp
|
|
{
|
|
GskGpuOp op;
|
|
|
|
GskGpuGlobalsInstance instance;
|
|
};
|
|
|
|
static void
|
|
gsk_gpu_globals_op_finish (GskGpuOp *op)
|
|
{
|
|
}
|
|
|
|
static void
|
|
gsk_gpu_globals_op_print (GskGpuOp *op,
|
|
GskGpuFrame *frame,
|
|
GString *string,
|
|
guint indent)
|
|
{
|
|
gsk_gpu_print_op (string, indent, "globals");
|
|
gsk_gpu_print_newline (string);
|
|
}
|
|
|
|
#ifdef GDK_RENDERING_VULKAN
|
|
static GskGpuOp *
|
|
gsk_gpu_globals_op_vk_command (GskGpuOp *op,
|
|
GskGpuFrame *frame,
|
|
GskVulkanCommandState *state)
|
|
{
|
|
GskGpuGlobalsOp *self = (GskGpuGlobalsOp *) op;
|
|
|
|
vkCmdPushConstants (state->vk_command_buffer,
|
|
gsk_vulkan_descriptors_get_vk_pipeline_layout (state->desc),
|
|
VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT,
|
|
0,
|
|
sizeof (self->instance),
|
|
&self->instance);
|
|
|
|
return op->next;
|
|
}
|
|
#endif
|
|
|
|
static GskGpuOp *
|
|
gsk_gpu_globals_op_gl_command (GskGpuOp *op,
|
|
GskGpuFrame *frame,
|
|
GskGLCommandState *state)
|
|
{
|
|
GskGpuGlobalsOp *self = (GskGpuGlobalsOp *) op;
|
|
|
|
/* the GskGLFrame makes sure the uniform buffer points to the globals */
|
|
/* FIXME: Does it matter if we glBufferData() or glSubBufferData() here? */
|
|
glBufferSubData (GL_UNIFORM_BUFFER,
|
|
0,
|
|
sizeof (self->instance),
|
|
&self->instance);
|
|
|
|
return op->next;
|
|
}
|
|
|
|
static const GskGpuOpClass GSK_GPU_GLOBALS_OP_CLASS = {
|
|
GSK_GPU_OP_SIZE (GskGpuGlobalsOp),
|
|
GSK_GPU_STAGE_COMMAND,
|
|
gsk_gpu_globals_op_finish,
|
|
gsk_gpu_globals_op_print,
|
|
#ifdef GDK_RENDERING_VULKAN
|
|
gsk_gpu_globals_op_vk_command,
|
|
#endif
|
|
gsk_gpu_globals_op_gl_command
|
|
};
|
|
|
|
void
|
|
gsk_gpu_globals_op (GskGpuFrame *frame,
|
|
const graphene_vec2_t *scale,
|
|
const graphene_matrix_t *mvp,
|
|
const GskRoundedRect *clip)
|
|
{
|
|
GskGpuGlobalsOp *self;
|
|
|
|
self = (GskGpuGlobalsOp *) gsk_gpu_op_alloc (frame, &GSK_GPU_GLOBALS_OP_CLASS);
|
|
|
|
graphene_matrix_to_float (mvp, self->instance.mvp);
|
|
gsk_rounded_rect_to_float (clip, graphene_point_zero (), self->instance.clip);
|
|
graphene_vec2_to_float (scale, self->instance.scale);
|
|
}
|