2 #include "vl_context.h"
4 #include <pipe/p_context.h>
5 #include <pipe/p_state.h>
6 #include <util/u_memory.h>
8 #include "vl_r16snorm_mc_buf.h"
10 #include "vl_basic_csc.h"
12 static int vlInitCommon(struct vlContext
*context
)
14 struct pipe_context
*pipe
;
15 struct pipe_rasterizer_state rast
;
16 struct pipe_blend_state blend
;
17 struct pipe_depth_stencil_alpha_state dsa
;
25 rast
.flatshade_first
= 0;
26 rast
.light_twoside
= 0;
27 rast
.front_winding
= PIPE_WINDING_CCW
;
28 rast
.cull_mode
= PIPE_WINDING_CW
;
29 rast
.fill_cw
= PIPE_POLYGON_MODE_FILL
;
30 rast
.fill_ccw
= PIPE_POLYGON_MODE_FILL
;
35 rast
.poly_stipple_enable
= 0;
36 rast
.point_sprite
= 0;
37 rast
.point_size_per_vertex
= 0;
40 rast
.line_stipple_enable
= 0;
41 rast
.line_stipple_factor
= 0;
42 rast
.line_stipple_pattern
= 0;
43 rast
.line_last_pixel
= 0;
44 rast
.bypass_vs_clip_and_viewport
= 0;
46 rast
.point_smooth
= 0;
48 rast
.offset_units
= 1;
49 rast
.offset_scale
= 1;
50 /*rast.sprite_coord_mode[i] = ;*/
51 context
->raster
= pipe
->create_rasterizer_state(pipe
, &rast
);
52 pipe
->bind_rasterizer_state(pipe
, context
->raster
);
54 blend
.blend_enable
= 0;
55 blend
.rgb_func
= PIPE_BLEND_ADD
;
56 blend
.rgb_src_factor
= PIPE_BLENDFACTOR_ONE
;
57 blend
.rgb_dst_factor
= PIPE_BLENDFACTOR_ONE
;
58 blend
.alpha_func
= PIPE_BLEND_ADD
;
59 blend
.alpha_src_factor
= PIPE_BLENDFACTOR_ONE
;
60 blend
.alpha_dst_factor
= PIPE_BLENDFACTOR_ONE
;
61 blend
.logicop_enable
= 0;
62 blend
.logicop_func
= PIPE_LOGICOP_CLEAR
;
63 /* Needed to allow color writes to FB, even if blending disabled */
64 blend
.colormask
= PIPE_MASK_RGBA
;
66 context
->blend
= pipe
->create_blend_state(pipe
, &blend
);
67 pipe
->bind_blend_state(pipe
, context
->blend
);
69 dsa
.depth
.enabled
= 0;
70 dsa
.depth
.writemask
= 0;
71 dsa
.depth
.func
= PIPE_FUNC_ALWAYS
;
72 dsa
.depth
.occlusion_count
= 0;
73 for (i
= 0; i
< 2; ++i
)
75 dsa
.stencil
[i
].enabled
= 0;
76 dsa
.stencil
[i
].func
= PIPE_FUNC_ALWAYS
;
77 dsa
.stencil
[i
].fail_op
= PIPE_STENCIL_OP_KEEP
;
78 dsa
.stencil
[i
].zpass_op
= PIPE_STENCIL_OP_KEEP
;
79 dsa
.stencil
[i
].zfail_op
= PIPE_STENCIL_OP_KEEP
;
80 dsa
.stencil
[i
].ref_value
= 0;
81 dsa
.stencil
[i
].valuemask
= 0;
82 dsa
.stencil
[i
].writemask
= 0;
84 dsa
.alpha
.enabled
= 0;
85 dsa
.alpha
.func
= PIPE_FUNC_ALWAYS
;
86 dsa
.alpha
.ref_value
= 0;
87 context
->dsa
= pipe
->create_depth_stencil_alpha_state(pipe
, &dsa
);
88 pipe
->bind_depth_stencil_alpha_state(pipe
, context
->dsa
);
95 struct vlScreen
*screen
,
96 struct pipe_context
*pipe
,
97 unsigned int picture_width
,
98 unsigned int picture_height
,
99 enum vlFormat picture_format
,
100 enum vlProfile profile
,
101 enum vlEntryPoint entry_point
,
102 struct vlContext
**context
105 struct vlContext
*ctx
;
111 ctx
= CALLOC_STRUCT(vlContext
);
116 ctx
->screen
= screen
;
118 ctx
->picture_width
= picture_width
;
119 ctx
->picture_height
= picture_height
;
120 ctx
->picture_format
= picture_format
;
121 ctx
->profile
= profile
;
122 ctx
->entry_point
= entry_point
;
126 vlCreateR16SNormBufferedMC(pipe
, picture_width
, picture_height
, picture_format
, &ctx
->render
);
127 vlCreateBasicCSC(pipe
, &ctx
->csc
);
136 struct vlContext
*context
141 /* XXX: Must unbind shaders before we can delete them for some reason */
142 context
->pipe
->bind_vs_state(context
->pipe
, NULL
);
143 context
->pipe
->bind_fs_state(context
->pipe
, NULL
);
145 context
->render
->vlDestroy(context
->render
);
146 context
->csc
->vlDestroy(context
->csc
);
148 context
->pipe
->delete_blend_state(context
->pipe
, context
->blend
);
149 context
->pipe
->delete_rasterizer_state(context
->pipe
, context
->raster
);
150 context
->pipe
->delete_depth_stencil_alpha_state(context
->pipe
, context
->dsa
);
157 struct vlScreen
* vlContextGetScreen
159 struct vlContext
*context
164 return context
->screen
;
167 struct pipe_context
* vlGetPipeContext
169 struct vlContext
*context
174 return context
->pipe
;
177 unsigned int vlGetPictureWidth
179 struct vlContext
*context
184 return context
->picture_width
;
187 unsigned int vlGetPictureHeight
189 struct vlContext
*context
194 return context
->picture_height
;
197 enum vlFormat vlGetPictureFormat
199 struct vlContext
*context
204 return context
->picture_format
;