2 #include "vl_context.h"
5 #include <pipe/p_context.h>
6 #include <pipe/p_state.h>
8 #include "vl_r16snorm_mc.h"
9 #include "vl_r16snorm_mc_buf.h"
11 #include "vl_basic_csc.h"
13 static int vlInitCommon(struct vlContext
*context
)
15 struct pipe_context
*pipe
;
16 struct pipe_rasterizer_state rast
;
17 struct pipe_blend_state blend
;
18 struct pipe_depth_stencil_alpha_state dsa
;
26 rast
.flatshade_first
= 0;
27 rast
.light_twoside
= 0;
28 rast
.front_winding
= PIPE_WINDING_CCW
;
29 rast
.cull_mode
= PIPE_WINDING_CW
;
30 rast
.fill_cw
= PIPE_POLYGON_MODE_FILL
;
31 rast
.fill_ccw
= PIPE_POLYGON_MODE_FILL
;
36 rast
.poly_stipple_enable
= 0;
37 rast
.point_sprite
= 0;
38 rast
.point_size_per_vertex
= 0;
41 rast
.line_stipple_enable
= 0;
42 rast
.line_stipple_factor
= 0;
43 rast
.line_stipple_pattern
= 0;
44 rast
.line_last_pixel
= 0;
45 /* Don't need clipping, but viewport mapping done here */
46 rast
.bypass_clipping
= 0;
48 rast
.origin_lower_left
= 0;
50 rast
.point_smooth
= 0;
52 rast
.offset_units
= 1;
53 rast
.offset_scale
= 1;
54 /*rast.sprite_coord_mode[i] = ;*/
55 context
->raster
= pipe
->create_rasterizer_state(pipe
, &rast
);
56 pipe
->bind_rasterizer_state(pipe
, context
->raster
);
58 blend
.blend_enable
= 0;
59 blend
.rgb_func
= PIPE_BLEND_ADD
;
60 blend
.rgb_src_factor
= PIPE_BLENDFACTOR_ONE
;
61 blend
.rgb_dst_factor
= PIPE_BLENDFACTOR_ONE
;
62 blend
.alpha_func
= PIPE_BLEND_ADD
;
63 blend
.alpha_src_factor
= PIPE_BLENDFACTOR_ONE
;
64 blend
.alpha_dst_factor
= PIPE_BLENDFACTOR_ONE
;
65 blend
.logicop_enable
= 0;
66 blend
.logicop_func
= PIPE_LOGICOP_CLEAR
;
67 /* Needed to allow color writes to FB, even if blending disabled */
68 blend
.colormask
= PIPE_MASK_RGBA
;
70 context
->blend
= pipe
->create_blend_state(pipe
, &blend
);
71 pipe
->bind_blend_state(pipe
, context
->blend
);
73 dsa
.depth
.enabled
= 0;
74 dsa
.depth
.writemask
= 0;
75 dsa
.depth
.func
= PIPE_FUNC_ALWAYS
;
76 dsa
.depth
.occlusion_count
= 0;
77 for (i
= 0; i
< 2; ++i
)
79 dsa
.stencil
[i
].enabled
= 0;
80 dsa
.stencil
[i
].func
= PIPE_FUNC_ALWAYS
;
81 dsa
.stencil
[i
].fail_op
= PIPE_STENCIL_OP_KEEP
;
82 dsa
.stencil
[i
].zpass_op
= PIPE_STENCIL_OP_KEEP
;
83 dsa
.stencil
[i
].zfail_op
= PIPE_STENCIL_OP_KEEP
;
84 dsa
.stencil
[i
].ref_value
= 0;
85 dsa
.stencil
[i
].value_mask
= 0;
86 dsa
.stencil
[i
].write_mask
= 0;
88 dsa
.alpha
.enabled
= 0;
89 dsa
.alpha
.func
= PIPE_FUNC_ALWAYS
;
91 context
->dsa
= pipe
->create_depth_stencil_alpha_state(pipe
, &dsa
);
92 pipe
->bind_depth_stencil_alpha_state(pipe
, context
->dsa
);
99 struct vlScreen
*screen
,
100 struct pipe_context
*pipe
,
101 unsigned int picture_width
,
102 unsigned int picture_height
,
103 enum vlFormat picture_format
,
104 enum vlProfile profile
,
105 enum vlEntryPoint entry_point
,
106 struct vlContext
**context
109 struct vlContext
*ctx
;
115 ctx
= calloc(1, sizeof(struct vlContext
));
120 ctx
->screen
= screen
;
122 ctx
->picture_width
= picture_width
;
123 ctx
->picture_height
= picture_height
;
124 ctx
->picture_format
= picture_format
;
125 ctx
->profile
= profile
;
126 ctx
->entry_point
= entry_point
;
130 /*vlCreateR16SNormMC(pipe, picture_width, picture_height, picture_format, &ctx->render);*/
131 vlCreateR16SNormBufferedMC(pipe
, picture_width
, picture_height
, picture_format
, &ctx
->render
);
132 vlCreateBasicCSC(pipe
, &ctx
->csc
);
141 struct vlContext
*context
146 /* XXX: Must unbind shaders before we can delete them for some reason */
147 context
->pipe
->bind_vs_state(context
->pipe
, NULL
);
148 context
->pipe
->bind_fs_state(context
->pipe
, NULL
);
150 context
->render
->vlDestroy(context
->render
);
151 context
->csc
->vlDestroy(context
->csc
);
153 context
->pipe
->delete_blend_state(context
->pipe
, context
->blend
);
154 context
->pipe
->delete_rasterizer_state(context
->pipe
, context
->raster
);
155 context
->pipe
->delete_depth_stencil_alpha_state(context
->pipe
, context
->dsa
);
162 struct vlScreen
* vlContextGetScreen
164 struct vlContext
*context
169 return context
->screen
;
172 struct pipe_context
* vlGetPipeContext
174 struct vlContext
*context
179 return context
->pipe
;
182 unsigned int vlGetPictureWidth
184 struct vlContext
*context
189 return context
->picture_width
;
192 unsigned int vlGetPictureHeight
194 struct vlContext
*context
199 return context
->picture_height
;
202 enum vlFormat vlGetPictureFormat
204 struct vlContext
*context
209 return context
->picture_format
;