summaryrefslogtreecommitdiff
path: root/src/sna/sna_render.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/sna/sna_render.h')
-rw-r--r--src/sna/sna_render.h100
1 files changed, 79 insertions, 21 deletions
diff --git a/src/sna/sna_render.h b/src/sna/sna_render.h
index 03a700571..01176c6aa 100644
--- a/src/sna/sna_render.h
+++ b/src/sna/sna_render.h
@@ -5,6 +5,11 @@
#include <picturestr.h>
+#include <stdbool.h>
+#include <stdint.h>
+#include <pthread.h>
+#include "atomic.h"
+
#define GRADIENT_CACHE_SIZE 16
#define GXinvalid 0xff
@@ -30,6 +35,8 @@ struct sna_composite_op {
const BoxRec *box);
void (*boxes)(struct sna *sna, const struct sna_composite_op *op,
const BoxRec *box, int nbox);
+ void (*thread_boxes)(struct sna *sna, const struct sna_composite_op *op,
+ const BoxRec *box, int nbox);
void (*done)(struct sna *sna, const struct sna_composite_op *op);
struct sna_damage **damage;
@@ -66,10 +73,10 @@ struct sna_composite_op {
union {
struct {
+ float dx, dy, offset;
+ } linear;
+ struct {
uint32_t pixel;
- float linear_dx;
- float linear_dy;
- float linear_offset;
} gen2;
struct gen3_shader_channel {
int type;
@@ -88,6 +95,9 @@ struct sna_composite_op {
fastcall void (*prim_emit)(struct sna *sna,
const struct sna_composite_op *op,
const struct sna_composite_rectangles *r);
+ fastcall void (*emit_boxes)(const struct sna_composite_op *op,
+ const BoxRec *box, int nbox,
+ float *v);
struct sna_composite_redirect {
struct kgem_bo *real_bo;
@@ -122,8 +132,8 @@ struct sna_composite_op {
} gen4;
struct {
- int wm_kernel;
- int ve_id;
+ int16_t wm_kernel;
+ int16_t ve_id;
} gen5;
struct {
@@ -138,6 +148,11 @@ struct sna_composite_op {
void *priv;
};
+struct sna_opacity_box {
+ BoxRec box;
+ float alpha;
+} __packed__;
+
struct sna_composite_spans_op {
struct sna_composite_op base;
@@ -149,6 +164,12 @@ struct sna_composite_spans_op {
const struct sna_composite_spans_op *op,
const BoxRec *box, int nbox,
float opacity);
+
+ fastcall void (*thread_boxes)(struct sna *sna,
+ const struct sna_composite_spans_op *op,
+ const struct sna_opacity_box *box,
+ int nbox);
+
fastcall void (*done)(struct sna *sna,
const struct sna_composite_spans_op *op);
@@ -156,6 +177,9 @@ struct sna_composite_spans_op {
const struct sna_composite_spans_op *op,
const BoxRec *box,
float opacity);
+ fastcall void (*emit_boxes)(const struct sna_composite_spans_op *op,
+ const struct sna_opacity_box *box, int nbox,
+ float *v);
};
struct sna_fill_op {
@@ -184,9 +208,18 @@ struct sna_copy_op {
};
struct sna_render {
+ pthread_mutex_t lock;
+ pthread_cond_t wait;
+ int active;
+
int max_3d_size;
int max_3d_pitch;
+ unsigned prefer_gpu;
+#define PREFER_GPU_BLT 0x1
+#define PREFER_GPU_RENDER 0x2
+#define PREFER_GPU_SPANS 0x4
+
bool (*composite)(struct sna *sna, uint8_t op,
PicturePtr dst, PicturePtr src, PicturePtr mask,
int16_t src_x, int16_t src_y,
@@ -214,6 +247,7 @@ struct sna_render {
RegionPtr dstRegion,
short src_w, short src_h,
short drw_w, short drw_h,
+ short dx, short dy,
PixmapPtr pixmap);
bool (*fill_boxes)(struct sna *sna,
@@ -237,6 +271,7 @@ struct sna_render {
PixmapPtr dst, struct kgem_bo *dst_bo, int16_t dst_dx, int16_t dst_dy,
const BoxRec *box, int n, unsigned flags);
#define COPY_LAST 0x1
+#define COPY_SYNC 0x2
bool (*copy)(struct sna *sna, uint8_t alu,
PixmapPtr src, struct kgem_bo *src_bo,
@@ -249,13 +284,13 @@ struct sna_render {
struct sna_alpha_cache {
struct kgem_bo *cache_bo;
- struct kgem_bo *bo[256];
+ struct kgem_bo *bo[256+7];
} alpha_cache;
struct sna_solid_cache {
struct kgem_bo *cache_bo;
- uint32_t color[1024];
struct kgem_bo *bo[1024];
+ uint32_t color[1025];
int last;
int size;
int dirty;
@@ -282,6 +317,8 @@ struct sna_render {
pixman_glyph_cache_t *glyph_cache;
#endif
+ uint16_t vb_id;
+ uint16_t vertex_offset;
uint16_t vertex_start;
uint16_t vertex_index;
uint16_t vertex_used;
@@ -302,7 +339,6 @@ struct gen2_render_state {
uint32_t ls1, ls2, vft;
uint32_t diffuse;
uint32_t specular;
- uint16_t vertex_offset;
};
struct gen3_render_state {
@@ -318,7 +354,6 @@ struct gen3_render_state {
uint32_t last_diffuse;
uint32_t last_specular;
- uint16_t vertex_offset;
uint16_t last_vertex_offset;
uint16_t floats_per_vertex;
uint16_t last_floats_per_vertex;
@@ -332,16 +367,14 @@ struct gen4_render_state {
struct kgem_bo *general_bo;
uint32_t vs;
- uint32_t sf[2];
+ uint32_t sf;
uint32_t wm;
uint32_t cc;
int ve_id;
uint32_t drawrect_offset;
uint32_t drawrect_limit;
- uint32_t vb_id;
uint32_t last_pipelined_pointers;
- uint16_t vertex_offset;
uint16_t last_primitive;
int16_t floats_per_vertex;
uint16_t surface_table;
@@ -361,8 +394,6 @@ struct gen5_render_state {
int ve_id;
uint32_t drawrect_offset;
uint32_t drawrect_limit;
- uint32_t vb_id;
- uint16_t vertex_offset;
uint16_t last_primitive;
int16_t floats_per_vertex;
uint16_t surface_table;
@@ -402,7 +433,6 @@ struct gen6_render_state {
uint32_t wm_state;
uint32_t wm_kernel[GEN6_KERNEL_COUNT][3];
- uint32_t cc_vp;
uint32_t cc_blend;
uint32_t drawrect_offset;
@@ -412,9 +442,7 @@ struct gen6_render_state {
uint32_t kernel;
uint16_t num_sf_outputs;
- uint16_t vb_id;
uint16_t ve_id;
- uint16_t vertex_offset;
uint16_t last_primitive;
int16_t floats_per_vertex;
uint16_t surface_table;
@@ -454,7 +482,6 @@ struct gen7_render_state {
uint32_t wm_state;
uint32_t wm_kernel[GEN7_WM_KERNEL_COUNT][3];
- uint32_t cc_vp;
uint32_t cc_blend;
uint32_t drawrect_offset;
@@ -464,9 +491,7 @@ struct gen7_render_state {
uint32_t kernel;
uint16_t num_sf_outputs;
- uint16_t vb_id;
uint16_t ve_id;
- uint16_t vertex_offset;
uint16_t last_primitive;
int16_t floats_per_vertex;
uint16_t surface_table;
@@ -690,7 +715,8 @@ sna_render_picture_convert(struct sna *sna,
PixmapPtr pixmap,
int16_t x, int16_t y,
int16_t w, int16_t h,
- int16_t dst_x, int16_t dst_y);
+ int16_t dst_x, int16_t dst_y,
+ bool fixup_alpha);
inline static void sna_render_composite_redirect_init(struct sna_composite_op *op)
{
@@ -717,4 +743,36 @@ sna_render_copy_boxes__overlap(struct sna *sna, uint8_t alu,
bool
sna_composite_mask_is_opaque(PicturePtr mask);
+void sna_vertex_init(struct sna *sna);
+
+static inline void sna_vertex_lock(struct sna_render *r)
+{
+ pthread_mutex_lock(&r->lock);
+}
+
+static inline void sna_vertex_acquire__locked(struct sna_render *r)
+{
+ r->active++;
+}
+
+static inline void sna_vertex_unlock(struct sna_render *r)
+{
+ pthread_mutex_unlock(&r->lock);
+}
+
+static inline void sna_vertex_release__locked(struct sna_render *r)
+{
+ assert(r->active > 0);
+ if (--r->active == 0)
+ pthread_cond_signal(&r->wait);
+}
+
+static inline bool sna_vertex_wait__locked(struct sna_render *r)
+{
+ bool was_active = r->active;
+ while (r->active)
+ pthread_cond_wait(&r->wait, &r->lock);
+ return was_active;
+}
+
#endif /* SNA_RENDER_H */