st/xorg: unite finalization and stub out pipelined copies
[mesa.git] / src / gallium / state_trackers / xorg / xorg_composite.c
1 #include "xorg_composite.h"
2
3 #include "xorg_exa_tgsi.h"
4
5 #include "cso_cache/cso_context.h"
6 #include "util/u_draw_quad.h"
7
8 #include "pipe/p_inlines.h"
9
10 struct xorg_composite_blend {
11 int op:8;
12
13 unsigned rgb_src_factor:5; /**< PIPE_BLENDFACTOR_x */
14 unsigned rgb_dst_factor:5; /**< PIPE_BLENDFACTOR_x */
15
16 unsigned alpha_src_factor:5; /**< PIPE_BLENDFACTOR_x */
17 unsigned alpha_dst_factor:5; /**< PIPE_BLENDFACTOR_x */
18 };
19
20 #define BLEND_OP_OVER 3
21 static const struct xorg_composite_blend xorg_blends[] = {
22 { PictOpClear,
23 PIPE_BLENDFACTOR_CONST_COLOR, PIPE_BLENDFACTOR_CONST_ALPHA,
24 PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ZERO },
25
26 { PictOpSrc,
27 PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_ONE,
28 PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ZERO },
29
30 { PictOpDst,
31 PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ZERO,
32 PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_ONE },
33
34 { PictOpOver,
35 PIPE_BLENDFACTOR_SRC_ALPHA, PIPE_BLENDFACTOR_ONE,
36 PIPE_BLENDFACTOR_INV_SRC_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA },
37
38 { PictOpOverReverse,
39 PIPE_BLENDFACTOR_SRC_ALPHA, PIPE_BLENDFACTOR_ONE,
40 PIPE_BLENDFACTOR_INV_SRC_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA },
41 };
42
43
44 static INLINE void
45 pixel_to_float4(Pixel pixel, float *color)
46 {
47 CARD32 r, g, b, a;
48
49 a = (pixel >> 24) & 0xff;
50 r = (pixel >> 16) & 0xff;
51 g = (pixel >> 8) & 0xff;
52 b = (pixel >> 0) & 0xff;
53 color[0] = ((float)r) / 255.;
54 color[1] = ((float)g) / 255.;
55 color[2] = ((float)b) / 255.;
56 color[3] = ((float)a) / 255.;
57 }
58
59 static INLINE void
60 render_pixel_to_float4(PictFormatPtr format,
61 CARD32 pixel, float *color)
62 {
63 CARD32 r, g, b, a;
64
65 debug_assert(format->type == PictTypeDirect);
66
67 r = (pixel >> format->direct.red) & format->direct.redMask;
68 g = (pixel >> format->direct.green) & format->direct.greenMask;
69 b = (pixel >> format->direct.blue) & format->direct.blueMask;
70 a = (pixel >> format->direct.alpha) & format->direct.alphaMask;
71 color[0] = ((float)r) / ((float)format->direct.redMask);
72 color[1] = ((float)g) / ((float)format->direct.greenMask);
73 color[2] = ((float)b) / ((float)format->direct.blueMask);
74 color[3] = ((float)a) / ((float)format->direct.alphaMask);
75 }
76
77 struct acceleration_info {
78 int op : 16;
79 int with_mask : 1;
80 int component_alpha : 1;
81 };
82 static const struct acceleration_info accelerated_ops[] = {
83 {PictOpClear, 1, 0},
84 {PictOpSrc, 1, 0},
85 {PictOpDst, 1, 0},
86 {PictOpOver, 1, 0},
87 {PictOpOverReverse, 1, 0},
88 {PictOpIn, 1, 0},
89 {PictOpInReverse, 1, 0},
90 {PictOpOut, 1, 0},
91 {PictOpOutReverse, 1, 0},
92 {PictOpAtop, 1, 0},
93 {PictOpAtopReverse, 1, 0},
94 {PictOpXor, 1, 0},
95 {PictOpAdd, 1, 0},
96 {PictOpSaturate, 1, 0},
97 };
98
99 static struct xorg_composite_blend
100 blend_for_op(int op)
101 {
102 const int num_blends =
103 sizeof(xorg_blends)/sizeof(struct xorg_composite_blend);
104 int i;
105
106 for (i = 0; i < num_blends; ++i) {
107 if (xorg_blends[i].op == op)
108 return xorg_blends[i];
109 }
110 return xorg_blends[BLEND_OP_OVER];
111 }
112
113 static INLINE int
114 render_repeat_to_gallium(int mode)
115 {
116 switch(mode) {
117 case RepeatNone:
118 return PIPE_TEX_WRAP_CLAMP;
119 case RepeatNormal:
120 return PIPE_TEX_WRAP_REPEAT;
121 case RepeatReflect:
122 return PIPE_TEX_WRAP_MIRROR_REPEAT;
123 case RepeatPad:
124 return PIPE_TEX_WRAP_CLAMP_TO_EDGE;
125 default:
126 debug_printf("Unsupported repeat mode\n");
127 }
128 return PIPE_TEX_WRAP_REPEAT;
129 }
130
131
132 static INLINE void
133 setup_vertex0(float vertex[2][4], float x, float y,
134 float color[4])
135 {
136 vertex[0][0] = x;
137 vertex[0][1] = y;
138 vertex[0][2] = 0.f; /*z*/
139 vertex[0][3] = 1.f; /*w*/
140
141 vertex[1][0] = color[0]; /*r*/
142 vertex[1][1] = color[1]; /*g*/
143 vertex[1][2] = color[2]; /*b*/
144 vertex[1][3] = color[3]; /*a*/
145 }
146
147 static struct pipe_buffer *
148 setup_vertex_data0(struct exa_context *ctx,
149 int srcX, int srcY, int maskX, int maskY,
150 int dstX, int dstY, int width, int height)
151 {
152 float vertices[4][2][4];
153
154 /* 1st vertex */
155 setup_vertex0(vertices[0], dstX, dstY,
156 ctx->solid_color);
157 /* 2nd vertex */
158 setup_vertex0(vertices[1], dstX + width, dstY,
159 ctx->solid_color);
160 /* 3rd vertex */
161 setup_vertex0(vertices[2], dstX + width, dstY + height,
162 ctx->solid_color);
163 /* 4th vertex */
164 setup_vertex0(vertices[3], dstX, dstY + height,
165 ctx->solid_color);
166
167 return pipe_user_buffer_create(ctx->ctx->screen,
168 vertices,
169 sizeof(vertices));
170 }
171
172 static INLINE void
173 setup_vertex1(float vertex[2][4], float x, float y, float s, float t)
174 {
175 vertex[0][0] = x;
176 vertex[0][1] = y;
177 vertex[0][2] = 0.f; /*z*/
178 vertex[0][3] = 1.f; /*w*/
179
180 vertex[1][0] = s; /*s*/
181 vertex[1][1] = t; /*t*/
182 vertex[1][2] = 0.f; /*r*/
183 vertex[1][3] = 1.f; /*q*/
184 }
185
186 static struct pipe_buffer *
187 setup_vertex_data1(struct exa_context *ctx,
188 int srcX, int srcY, int maskX, int maskY,
189 int dstX, int dstY, int width, int height)
190 {
191 float vertices[4][2][4];
192 float s0, t0, s1, t1;
193 struct pipe_texture *src = ctx->bound_textures[0];
194
195 s0 = srcX / src->width[0];
196 s1 = srcX + width / src->width[0];
197 t0 = srcY / src->height[0];
198 t1 = srcY + height / src->height[0];
199
200 /* 1st vertex */
201 setup_vertex1(vertices[0], dstX, dstY,
202 s0, t0);
203 /* 2nd vertex */
204 setup_vertex1(vertices[1], dstX + width, dstY,
205 s1, t0);
206 /* 3rd vertex */
207 setup_vertex1(vertices[2], dstX + width, dstY + height,
208 s1, t1);
209 /* 4th vertex */
210 setup_vertex1(vertices[3], dstX, dstY + height,
211 s0, t1);
212
213 return pipe_user_buffer_create(ctx->ctx->screen,
214 vertices,
215 sizeof(vertices));
216 }
217
218
219 static INLINE void
220 setup_vertex2(float vertex[3][4], float x, float y,
221 float s0, float t0, float s1, float t1)
222 {
223 vertex[0][0] = x;
224 vertex[0][1] = y;
225 vertex[0][2] = 0.f; /*z*/
226 vertex[0][3] = 1.f; /*w*/
227
228 vertex[1][0] = s0; /*s*/
229 vertex[1][1] = t0; /*t*/
230 vertex[1][2] = 0.f; /*r*/
231 vertex[1][3] = 1.f; /*q*/
232
233 vertex[2][0] = s1; /*s*/
234 vertex[2][1] = t1; /*t*/
235 vertex[2][2] = 0.f; /*r*/
236 vertex[2][3] = 1.f; /*q*/
237 }
238
239 static struct pipe_buffer *
240 setup_vertex_data2(struct exa_context *ctx,
241 int srcX, int srcY, int maskX, int maskY,
242 int dstX, int dstY, int width, int height)
243 {
244 float vertices[4][3][4];
245 float st0[4], st1[4];
246 struct pipe_texture *src = ctx->bound_textures[0];
247 struct pipe_texture *mask = ctx->bound_textures[0];
248
249 st0[0] = srcX / src->width[0];
250 st0[1] = srcY / src->height[0];
251 st0[2] = srcX + width / src->width[0];
252 st0[3] = srcY + height / src->height[0];
253
254 st1[0] = maskX / mask->width[0];
255 st1[1] = maskY / mask->height[0];
256 st1[2] = maskX + width / mask->width[0];
257 st1[3] = maskY + height / mask->height[0];
258
259 /* 1st vertex */
260 setup_vertex2(vertices[0], dstX, dstY,
261 st0[0], st0[1], st1[0], st1[1]);
262 /* 2nd vertex */
263 setup_vertex2(vertices[1], dstX + width, dstY,
264 st0[2], st0[1], st1[2], st1[1]);
265 /* 3rd vertex */
266 setup_vertex2(vertices[2], dstX + width, dstY + height,
267 st0[2], st0[3], st1[2], st1[3]);
268 /* 4th vertex */
269 setup_vertex2(vertices[3], dstX, dstY + height,
270 st0[0], st0[3], st1[0], st1[3]);
271
272 return pipe_user_buffer_create(ctx->ctx->screen,
273 vertices,
274 sizeof(vertices));
275 }
276
277 boolean xorg_composite_accelerated(int op,
278 PicturePtr pSrcPicture,
279 PicturePtr pMaskPicture,
280 PicturePtr pDstPicture)
281 {
282 unsigned i;
283 unsigned accel_ops_count =
284 sizeof(accelerated_ops)/sizeof(struct acceleration_info);
285
286
287 /*FIXME: currently accel is disabled */
288 return FALSE;
289
290 if (pSrcPicture) {
291 /* component alpha not supported */
292 if (pSrcPicture->componentAlpha)
293 return FALSE;
294 /* fills not supported */
295 if (pSrcPicture->pSourcePict)
296 return FALSE;
297 }
298
299 for (i = 0; i < accel_ops_count; ++i) {
300 if (op == accelerated_ops[i].op) {
301 if (pMaskPicture && !accelerated_ops[i].with_mask)
302 return FALSE;
303 return TRUE;
304 }
305 }
306 return FALSE;
307 }
308
309 static void
310 bind_clip_state(struct exa_context *exa)
311 {
312 struct pipe_depth_stencil_alpha_state dsa;
313
314 memset(&dsa, 0, sizeof(struct pipe_depth_stencil_alpha_state));
315 cso_set_depth_stencil_alpha(exa->cso, &dsa);
316 }
317
318 static void
319 bind_framebuffer_state(struct exa_context *exa, struct exa_pixmap_priv *pDst)
320 {
321 unsigned i;
322 struct pipe_framebuffer_state state;
323 struct pipe_surface *surface = exa_gpu_surface(exa, pDst);
324 memset(&state, 0, sizeof(struct pipe_framebuffer_state));
325
326 state.width = pDst->tex->width[0];
327 state.height = pDst->tex->height[0];
328
329 state.nr_cbufs = 1;
330 state.cbufs[0] = surface;
331 for (i = 1; i < PIPE_MAX_COLOR_BUFS; ++i)
332 state.cbufs[i] = 0;
333
334 /* currently we don't use depth/stencil */
335 state.zsbuf = 0;
336
337 cso_set_framebuffer(exa->cso, &state);
338 }
339
340 enum AxisOrientation {
341 Y0_BOTTOM,
342 Y0_TOP
343 };
344
345 static void
346 set_viewport(struct exa_context *exa, int width, int height,
347 enum AxisOrientation orientation)
348 {
349 struct pipe_viewport_state viewport;
350 float y_scale = (orientation == Y0_BOTTOM) ? -2.f : 2.f;
351
352 viewport.scale[0] = width / 2.f;
353 viewport.scale[1] = height / y_scale;
354 viewport.scale[2] = 1.0;
355 viewport.scale[3] = 1.0;
356 viewport.translate[0] = width / 2.f;
357 viewport.translate[1] = height / 2.f;
358 viewport.translate[2] = 0.0;
359 viewport.translate[3] = 0.0;
360
361 cso_set_viewport(exa->cso, &viewport);
362 }
363
364 static void
365 bind_viewport_state(struct exa_context *exa, struct exa_pixmap_priv *pDst)
366 {
367 int width = pDst->tex->width[0];
368 int height = pDst->tex->height[0];
369
370 debug_printf("Bind viewport (%d, %d)\n", width, height);
371
372 set_viewport(exa, width, height, Y0_TOP);
373 }
374
375 static void
376 bind_blend_state(struct exa_context *exa, int op,
377 PicturePtr pSrcPicture, PicturePtr pMaskPicture)
378 {
379 boolean component_alpha = (pSrcPicture) ?
380 pSrcPicture->componentAlpha : FALSE;
381 struct xorg_composite_blend blend_opt;
382 struct pipe_blend_state blend;
383
384 if (component_alpha) {
385 op = PictOpOver;
386 }
387 blend_opt = blend_for_op(op);
388
389 memset(&blend, 0, sizeof(struct pipe_blend_state));
390 blend.blend_enable = 1;
391 blend.colormask |= PIPE_MASK_R;
392 blend.colormask |= PIPE_MASK_G;
393 blend.colormask |= PIPE_MASK_B;
394 blend.colormask |= PIPE_MASK_A;
395
396 blend.rgb_src_factor = blend_opt.rgb_src_factor;
397 blend.alpha_src_factor = blend_opt.alpha_src_factor;
398 blend.rgb_dst_factor = blend_opt.rgb_dst_factor;
399 blend.alpha_dst_factor = blend_opt.alpha_dst_factor;
400
401 cso_set_blend(exa->cso, &blend);
402 }
403
404 static void
405 bind_rasterizer_state(struct exa_context *exa)
406 {
407 struct pipe_rasterizer_state raster;
408 memset(&raster, 0, sizeof(struct pipe_rasterizer_state));
409 raster.gl_rasterization_rules = 1;
410 cso_set_rasterizer(exa->cso, &raster);
411 }
412
413 static void
414 bind_shaders(struct exa_context *exa, int op,
415 PicturePtr pSrcPicture, PicturePtr pMaskPicture)
416 {
417 unsigned vs_traits = 0, fs_traits = 0;
418 struct xorg_shader shader;
419
420 exa->has_solid_color = FALSE;
421
422 if (pSrcPicture) {
423 if (pSrcPicture->pSourcePict) {
424 if (pSrcPicture->pSourcePict->type == SourcePictTypeSolidFill) {
425 fs_traits |= FS_SOLID_FILL;
426 vs_traits |= VS_SOLID_FILL;
427 render_pixel_to_float4(pSrcPicture->pFormat,
428 pSrcPicture->pSourcePict->solidFill.color,
429 exa->solid_color);
430 exa->has_solid_color = TRUE;
431 } else {
432 debug_assert("!gradients not supported");
433 }
434 } else {
435 fs_traits |= FS_COMPOSITE;
436 vs_traits |= VS_COMPOSITE;
437 }
438 }
439
440 if (pMaskPicture) {
441 vs_traits |= VS_MASK;
442 fs_traits |= FS_MASK;
443 }
444
445 shader = xorg_shaders_get(exa->shaders, vs_traits, fs_traits);
446 cso_set_vertex_shader_handle(exa->cso, shader.vs);
447 cso_set_fragment_shader_handle(exa->cso, shader.fs);
448 }
449
450
451 static void
452 bind_samplers(struct exa_context *exa, int op,
453 PicturePtr pSrcPicture, PicturePtr pMaskPicture,
454 PicturePtr pDstPicture,
455 struct exa_pixmap_priv *pSrc,
456 struct exa_pixmap_priv *pMask,
457 struct exa_pixmap_priv *pDst)
458 {
459 struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS];
460 struct pipe_sampler_state src_sampler, mask_sampler;
461
462 exa->num_bound_samplers = 0;
463
464 memset(&src_sampler, 0, sizeof(struct pipe_sampler_state));
465 memset(&mask_sampler, 0, sizeof(struct pipe_sampler_state));
466
467 if (pSrcPicture && pSrc) {
468 unsigned src_wrap = render_repeat_to_gallium(
469 pSrcPicture->repeatType);
470 src_sampler.wrap_s = src_wrap;
471 src_sampler.wrap_t = src_wrap;
472 src_sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST;
473 src_sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST;
474 src_sampler.normalized_coords = 1;
475 samplers[0] = &src_sampler;
476 exa->bound_textures[0] = pSrc->tex;
477 ++exa->num_bound_samplers;
478 }
479
480 if (pMaskPicture && pMask) {
481 unsigned mask_wrap = render_repeat_to_gallium(
482 pMaskPicture->repeatType);
483 mask_sampler.wrap_s = mask_wrap;
484 mask_sampler.wrap_t = mask_wrap;
485 mask_sampler.min_img_filter = PIPE_TEX_MIPFILTER_NEAREST;
486 mask_sampler.mag_img_filter = PIPE_TEX_MIPFILTER_NEAREST;
487 mask_sampler.normalized_coords = 1;
488 samplers[1] = &mask_sampler;
489 exa->bound_textures[1] = pMask->tex;
490 ++exa->num_bound_samplers;
491 }
492
493 cso_set_samplers(exa->cso, exa->num_bound_samplers,
494 (const struct pipe_sampler_state **)samplers);
495 cso_set_sampler_textures(exa->cso, exa->num_bound_samplers,
496 exa->bound_textures);
497 }
498
499 static void
500 setup_vs_constant_buffer(struct exa_context *exa,
501 int width, int height)
502 {
503 const int param_bytes = 8 * sizeof(float);
504 float vs_consts[8] = {
505 2.f/width, 2.f/height, 1, 1,
506 -1, -1, 0, 0
507 };
508 struct pipe_constant_buffer *cbuf = &exa->vs_const_buffer;
509
510 pipe_buffer_reference(&cbuf->buffer, NULL);
511 cbuf->buffer = pipe_buffer_create(exa->ctx->screen, 16,
512 PIPE_BUFFER_USAGE_CONSTANT,
513 param_bytes);
514
515 if (cbuf->buffer) {
516 pipe_buffer_write(exa->ctx->screen, cbuf->buffer,
517 0, param_bytes, vs_consts);
518 }
519 exa->ctx->set_constant_buffer(exa->ctx, PIPE_SHADER_VERTEX, 0, cbuf);
520 }
521
522
523 static void
524 setup_fs_constant_buffer(struct exa_context *exa)
525 {
526 const int param_bytes = 4 * sizeof(float);
527 float fs_consts[8] = {
528 0, 0, 0, 1,
529 };
530 struct pipe_constant_buffer *cbuf = &exa->fs_const_buffer;
531
532 pipe_buffer_reference(&cbuf->buffer, NULL);
533 cbuf->buffer = pipe_buffer_create(exa->ctx->screen, 16,
534 PIPE_BUFFER_USAGE_CONSTANT,
535 param_bytes);
536
537 if (cbuf->buffer) {
538 pipe_buffer_write(exa->ctx->screen, cbuf->buffer,
539 0, param_bytes, fs_consts);
540 }
541 exa->ctx->set_constant_buffer(exa->ctx, PIPE_SHADER_FRAGMENT, 0, cbuf);
542 }
543
544 static void
545 setup_constant_buffers(struct exa_context *exa, struct exa_pixmap_priv *pDst)
546 {
547 int width = pDst->tex->width[0];
548 int height = pDst->tex->height[0];
549
550 setup_vs_constant_buffer(exa, width, height);
551 setup_fs_constant_buffer(exa);
552 }
553
554 boolean xorg_composite_bind_state(struct exa_context *exa,
555 int op,
556 PicturePtr pSrcPicture,
557 PicturePtr pMaskPicture,
558 PicturePtr pDstPicture,
559 struct exa_pixmap_priv *pSrc,
560 struct exa_pixmap_priv *pMask,
561 struct exa_pixmap_priv *pDst)
562 {
563 bind_framebuffer_state(exa, pDst);
564 bind_viewport_state(exa, pDst);
565 bind_blend_state(exa, op, pSrcPicture, pMaskPicture);
566 bind_rasterizer_state(exa);
567 bind_shaders(exa, op, pSrcPicture, pMaskPicture);
568 bind_samplers(exa, op, pSrcPicture, pMaskPicture,
569 pDstPicture, pSrc, pMask, pDst);
570 bind_clip_state(exa);
571 setup_constant_buffers(exa, pDst);
572
573 return FALSE;
574 }
575
576 void xorg_composite(struct exa_context *exa,
577 struct exa_pixmap_priv *dst,
578 int srcX, int srcY, int maskX, int maskY,
579 int dstX, int dstY, int width, int height)
580 {
581 struct pipe_context *pipe = exa->ctx;
582 struct pipe_buffer *buf = 0;
583
584 if (exa->num_bound_samplers == 0 ) { /* solid fill */
585 buf = setup_vertex_data0(exa,
586 srcX, srcY, maskX, maskY,
587 dstX, dstY, width, height);
588 } else if (exa->num_bound_samplers == 1 ) /* src */
589 buf = setup_vertex_data1(exa,
590 srcX, srcY, maskX, maskY,
591 dstX, dstY, width, height);
592 else if (exa->num_bound_samplers == 2) /* src + mask */
593 buf = setup_vertex_data2(exa,
594 srcX, srcY, maskX, maskY,
595 dstX, dstY, width, height);
596 else if (exa->num_bound_samplers == 3) { /* src + mask + dst */
597 debug_assert(!"src/mask/dst not handled right now");
598 #if 0
599 buf = setup_vertex_data2(exa,
600 srcX, srcY, maskX, maskY,
601 dstX, dstY, width, height);
602 #endif
603 }
604
605 if (buf) {
606 int num_attribs = 1; /*pos*/
607 num_attribs += exa->num_bound_samplers;
608 if (exa->has_solid_color)
609 ++num_attribs;
610
611 util_draw_vertex_buffer(pipe, buf, 0,
612 PIPE_PRIM_TRIANGLE_FAN,
613 4, /* verts */
614 num_attribs); /* attribs/vert */
615
616 pipe_buffer_reference(&buf, NULL);
617 }
618 }
619
620 boolean xorg_solid_bind_state(struct exa_context *exa,
621 struct exa_pixmap_priv *pixmap,
622 Pixel fg)
623 {
624 unsigned vs_traits, fs_traits;
625 struct xorg_shader shader;
626
627 pixel_to_float4(fg, exa->solid_color);
628 exa->has_solid_color = TRUE;
629
630 exa->solid_color[3] = 1.f;
631
632 debug_printf("Color Pixel=(%d, %d, %d, %d), RGBA=(%f, %f, %f, %f)\n",
633 (fg >> 24) & 0xff, (fg >> 16) & 0xff,
634 (fg >> 8) & 0xff, (fg >> 0) & 0xff,
635 exa->solid_color[0], exa->solid_color[1],
636 exa->solid_color[2], exa->solid_color[3]);
637
638 #if 0
639 exa->solid_color[0] = 1.f;
640 exa->solid_color[1] = 0.f;
641 exa->solid_color[2] = 0.f;
642 exa->solid_color[3] = 1.f;
643 #endif
644
645 vs_traits = VS_SOLID_FILL;
646 fs_traits = FS_SOLID_FILL;
647
648 bind_framebuffer_state(exa, pixmap);
649 bind_viewport_state(exa, pixmap);
650 bind_rasterizer_state(exa);
651 bind_blend_state(exa, PictOpSrc, NULL, NULL);
652 setup_constant_buffers(exa, pixmap);
653 bind_clip_state(exa);
654
655 shader = xorg_shaders_get(exa->shaders, vs_traits, fs_traits);
656 cso_set_vertex_shader_handle(exa->cso, shader.vs);
657 cso_set_fragment_shader_handle(exa->cso, shader.fs);
658
659 return FALSE;
660 }
661
662 void xorg_solid(struct exa_context *exa,
663 struct exa_pixmap_priv *pixmap,
664 int x0, int y0, int x1, int y1)
665 {
666 struct pipe_context *pipe = exa->ctx;
667 struct pipe_buffer *buf = 0;
668 float vertices[4][2][4];
669
670 x0 = 10; y0 = 10;
671 x1 = 300; y1 = 300;
672
673 /* 1st vertex */
674 setup_vertex0(vertices[0], x0, y0,
675 exa->solid_color);
676 /* 2nd vertex */
677 setup_vertex0(vertices[1], x1, y0,
678 exa->solid_color);
679 /* 3rd vertex */
680 setup_vertex0(vertices[2], x1, y1,
681 exa->solid_color);
682 /* 4th vertex */
683 setup_vertex0(vertices[3], x0, y1,
684 exa->solid_color);
685
686 buf = pipe_user_buffer_create(exa->ctx->screen,
687 vertices,
688 sizeof(vertices));
689
690
691 if (buf) {
692 debug_printf("Drawing buf is %p\n", buf);
693 util_draw_vertex_buffer(pipe, buf, 0,
694 PIPE_PRIM_TRIANGLE_FAN,
695 4, /* verts */
696 2); /* attribs/vert */
697
698 pipe_buffer_reference(&buf, NULL);
699 }
700 }
701
702 void xorg_copy_pixmap(struct exa_context *ctx,
703 struct exa_pixmap_priv *dst, int dx, int dy,
704 struct exa_pixmap_priv *src, int sx, int sy,
705 int width, int height)
706 {
707
708 }
709