1 #include "xorg_exa_tgsi.h"
3 /*### stupidity defined in X11/extensions/XI.h */
6 #include "pipe/p_format.h"
7 #include "pipe/p_context.h"
8 #include "pipe/p_state.h"
9 #include "pipe/p_inlines.h"
10 #include "pipe/p_shader_tokens.h"
12 #include "util/u_memory.h"
13 #include "util/u_simple_shaders.h"
15 #include "tgsi/tgsi_ureg.h"
17 #include "cso_cache/cso_context.h"
19 #define UNSUPPORTED_OP 0
24 int component_alpha
: 1;
34 * CONST[0] = (0, 0, 0, 1)
36 struct xorg_render_ops_tgsi
{
41 static const char over_op
[] =
42 "SUB TEMP[3], CONST[0].wwww, TEMP[1].wwww\n"
43 "MUL TEMP[3], TEMP[0], TEMP[3]\n"
44 "ADD TEMP[0], TEMP[3], TEMP[0]\n";
46 static const struct xorg_render_ops_tgsi ops_map
[] = {
65 create_preamble(struct ureg_program
*ureg
)
71 src_in_mask(struct ureg_program
*ureg
,
76 /* MUL dst, src, mask.wwww */
77 ureg_MUL(ureg
, dst
, src
,
78 ureg_scalar(mask
, TGSI_SWIZZLE_W
));
82 struct shader_id
shader_state(int op
,
83 PicturePtr src_picture
,
84 PicturePtr mask_picture
,
85 PicturePtr dst_picture
)
90 sid
.mask
= (mask_picture
!= 0);
91 sid
.component_alpha
= (mask_picture
->componentAlpha
);
92 sid
.is_fill
= (src_picture
->pSourcePict
!= 0);
95 (src_picture
->pSourcePict
->type
== SourcePictTypeSolidFill
);
101 struct xorg_shader
xorg_shader_construct(struct exa_context
*exa
,
103 PicturePtr src_picture
,
104 PicturePtr mask_picture
,
105 PicturePtr dst_picture
)
107 struct ureg_program
*ureg
;
108 struct ureg_src dst_sampler
, src_sampler
, mask_sampler
;
109 struct ureg_src dst_pos
, src_pos
, mask_pos
;
110 struct ureg_src src
, mask
;
111 struct shader_id sid
= shader_state(op
, src_picture
,
114 struct xorg_shader shader
= {0};
116 ureg
= ureg_create(TGSI_PROCESSOR_FRAGMENT
);
123 #if 0 /* unused right now */
124 dst_sampler
= ureg_DECL_sampler(ureg
);
125 dst_pos
= ureg_DECL_fs_input(ureg
,
126 TGSI_SEMANTIC_POSITION
,
128 TGSI_INTERPOLATE_PERSPECTIVE
);
131 src_sampler
= ureg_DECL_sampler(ureg
);
132 src_pos
= ureg_DECL_fs_input(ureg
,
133 TGSI_SEMANTIC_POSITION
,
135 TGSI_INTERPOLATE_PERSPECTIVE
);
138 mask_sampler
= ureg_DECL_sampler(ureg
);
139 src_pos
= ureg_DECL_fs_input(ureg
,
140 TGSI_SEMANTIC_POSITION
,
142 TGSI_INTERPOLATE_PERSPECTIVE
);
145 ureg_TEX(ureg
, ureg_dst(src
),
146 TGSI_TEXTURE_2D
, src_pos
, src_sampler
);
149 ureg_TEX(ureg
, ureg_dst(mask
),
150 TGSI_TEXTURE_2D
, mask_pos
, mask_sampler
);
152 src_in_mask(ureg
, ureg_dst(src
), src
, mask
);