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 /* Don't need clipping, but viewport mapping done here */
45 rast
.bypass_clipping
= 0;
47 rast
.origin_lower_left
= 0;
49 rast
.point_smooth
= 0;
51 rast
.offset_units
= 1;
52 rast
.offset_scale
= 1;
53 /*rast.sprite_coord_mode[i] = ;*/
54 context
->raster
= pipe
->create_rasterizer_state(pipe
, &rast
);
55 pipe
->bind_rasterizer_state(pipe
, context
->raster
);
57 blend
.blend_enable
= 0;
58 blend
.rgb_func
= PIPE_BLEND_ADD
;
59 blend
.rgb_src_factor
= PIPE_BLENDFACTOR_ONE
;
60 blend
.rgb_dst_factor
= PIPE_BLENDFACTOR_ONE
;
61 blend
.alpha_func
= PIPE_BLEND_ADD
;
62 blend
.alpha_src_factor
= PIPE_BLENDFACTOR_ONE
;
63 blend
.alpha_dst_factor
= PIPE_BLENDFACTOR_ONE
;
64 blend
.logicop_enable
= 0;
65 blend
.logicop_func
= PIPE_LOGICOP_CLEAR
;
66 /* Needed to allow color writes to FB, even if blending disabled */
67 blend
.colormask
= PIPE_MASK_RGBA
;
69 context
->blend
= pipe
->create_blend_state(pipe
, &blend
);
70 pipe
->bind_blend_state(pipe
, context
->blend
);
72 dsa
.depth
.enabled
= 0;
73 dsa
.depth
.writemask
= 0;
74 dsa
.depth
.func
= PIPE_FUNC_ALWAYS
;
75 dsa
.depth
.occlusion_count
= 0;
76 for (i
= 0; i
< 2; ++i
)
78 dsa
.stencil
[i
].enabled
= 0;
79 dsa
.stencil
[i
].func
= PIPE_FUNC_ALWAYS
;
80 dsa
.stencil
[i
].fail_op
= PIPE_STENCIL_OP_KEEP
;
81 dsa
.stencil
[i
].zpass_op
= PIPE_STENCIL_OP_KEEP
;
82 dsa
.stencil
[i
].zfail_op
= PIPE_STENCIL_OP_KEEP
;
83 dsa
.stencil
[i
].ref_value
= 0;
84 dsa
.stencil
[i
].valuemask
= 0;
85 dsa
.stencil
[i
].writemask
= 0;
87 dsa
.alpha
.enabled
= 0;
88 dsa
.alpha
.func
= PIPE_FUNC_ALWAYS
;
89 dsa
.alpha
.ref_value
= 0;
90 context
->dsa
= pipe
->create_depth_stencil_alpha_state(pipe
, &dsa
);
91 pipe
->bind_depth_stencil_alpha_state(pipe
, context
->dsa
);
98 struct vlScreen
*screen
,
99 struct pipe_context
*pipe
,
100 unsigned int picture_width
,
101 unsigned int picture_height
,
102 enum vlFormat picture_format
,
103 enum vlProfile profile
,
104 enum vlEntryPoint entry_point
,
105 struct vlContext
**context
108 struct vlContext
*ctx
;
114 ctx
= CALLOC_STRUCT(vlContext
);
119 ctx
->screen
= screen
;
121 ctx
->picture_width
= picture_width
;
122 ctx
->picture_height
= picture_height
;
123 ctx
->picture_format
= picture_format
;
124 ctx
->profile
= profile
;
125 ctx
->entry_point
= entry_point
;
129 vlCreateR16SNormBufferedMC(pipe
, picture_width
, picture_height
, picture_format
, &ctx
->render
);
130 vlCreateBasicCSC(pipe
, &ctx
->csc
);
139 struct vlContext
*context
144 /* XXX: Must unbind shaders before we can delete them for some reason */
145 context
->pipe
->bind_vs_state(context
->pipe
, NULL
);
146 context
->pipe
->bind_fs_state(context
->pipe
, NULL
);
148 context
->render
->vlDestroy(context
->render
);
149 context
->csc
->vlDestroy(context
->csc
);
151 context
->pipe
->delete_blend_state(context
->pipe
, context
->blend
);
152 context
->pipe
->delete_rasterizer_state(context
->pipe
, context
->raster
);
153 context
->pipe
->delete_depth_stencil_alpha_state(context
->pipe
, context
->dsa
);
160 struct vlScreen
* vlContextGetScreen
162 struct vlContext
*context
167 return context
->screen
;
170 struct pipe_context
* vlGetPipeContext
172 struct vlContext
*context
177 return context
->pipe
;
180 unsigned int vlGetPictureWidth
182 struct vlContext
*context
187 return context
->picture_width
;
190 unsigned int vlGetPictureHeight
192 struct vlContext
*context
197 return context
->picture_height
;
200 enum vlFormat vlGetPictureFormat
202 struct vlContext
*context
207 return context
->picture_format
;