Lines Matching refs:p

84 static void init_prog(struct program *p)  in init_prog()  argument
90 ret = pipe_loader_probe(&p->dev, 1); in init_prog()
94 p->screen = pipe_loader_create_screen(p->dev); in init_prog()
95 assert(p->screen); in init_prog()
98 p->pipe = p->screen->context_create(p->screen, NULL, 0); in init_prog()
99 p->cso = cso_create_context(p->pipe, 0); in init_prog()
102 p->clear_color.f[0] = 0.3; in init_prog()
103 p->clear_color.f[1] = 0.1; in init_prog()
104 p->clear_color.f[2] = 0.3; in init_prog()
105 p->clear_color.f[3] = 1.0; in init_prog()
124 p->vbuf = pipe_buffer_create(p->screen, PIPE_BIND_VERTEX_BUFFER, in init_prog()
126 pipe_buffer_write(p->pipe, p->vbuf, 0, sizeof(vertices), vertices); in init_prog()
142 p->target = p->screen->resource_create(p->screen, &tmplt); in init_prog()
146 memset(&p->blend, 0, sizeof(p->blend)); in init_prog()
147 p->blend.rt[0].colormask = PIPE_MASK_RGBA; in init_prog()
150 memset(&p->depthstencil, 0, sizeof(p->depthstencil)); in init_prog()
153 memset(&p->rasterizer, 0, sizeof(p->rasterizer)); in init_prog()
154 p->rasterizer.cull_face = PIPE_FACE_NONE; in init_prog()
155 p->rasterizer.half_pixel_center = 1; in init_prog()
156 p->rasterizer.bottom_edge_rule = 1; in init_prog()
157 p->rasterizer.depth_clip = 1; in init_prog()
164 memset(&p->framebuffer, 0, sizeof(p->framebuffer)); in init_prog()
165 p->framebuffer.width = WIDTH; in init_prog()
166 p->framebuffer.height = HEIGHT; in init_prog()
167 p->framebuffer.nr_cbufs = 1; in init_prog()
168 p->framebuffer.cbufs[0] = p->pipe->create_surface(p->pipe, p->target, &surf_tmpl); in init_prog()
188 p->viewport.scale[0] = half_width; in init_prog()
189 p->viewport.scale[1] = half_height * scale; in init_prog()
190 p->viewport.scale[2] = half_depth; in init_prog()
192 p->viewport.translate[0] = half_width + x; in init_prog()
193 p->viewport.translate[1] = (half_height + y) * scale + bias; in init_prog()
194 p->viewport.translate[2] = half_depth + z; in init_prog()
198 memset(p->velem, 0, sizeof(p->velem)); in init_prog()
199 p->velem[0].src_offset = 0 * 4 * sizeof(float); /* offset 0, first element */ in init_prog()
200 p->velem[0].instance_divisor = 0; in init_prog()
201 p->velem[0].vertex_buffer_index = 0; in init_prog()
202 p->velem[0].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; in init_prog()
204 p->velem[1].src_offset = 1 * 4 * sizeof(float); /* offset 16, second element */ in init_prog()
205 p->velem[1].instance_divisor = 0; in init_prog()
206 p->velem[1].vertex_buffer_index = 0; in init_prog()
207 p->velem[1].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; in init_prog()
214 p->vs = util_make_vertex_passthrough_shader(p->pipe, 2, semantic_names, semantic_indexes, FALSE); in init_prog()
218 p->fs = util_make_fragment_passthrough_shader(p->pipe, in init_prog()
222 static void close_prog(struct program *p) in close_prog() argument
224 cso_destroy_context(p->cso); in close_prog()
226 p->pipe->delete_vs_state(p->pipe, p->vs); in close_prog()
227 p->pipe->delete_fs_state(p->pipe, p->fs); in close_prog()
229 pipe_surface_reference(&p->framebuffer.cbufs[0], NULL); in close_prog()
230 pipe_resource_reference(&p->target, NULL); in close_prog()
231 pipe_resource_reference(&p->vbuf, NULL); in close_prog()
233 p->pipe->destroy(p->pipe); in close_prog()
234 p->screen->destroy(p->screen); in close_prog()
235 pipe_loader_release(&p->dev, 1); in close_prog()
237 FREE(p); in close_prog()
240 static void draw(struct program *p) in draw() argument
243 cso_set_framebuffer(p->cso, &p->framebuffer); in draw()
246 p->pipe->clear(p->pipe, PIPE_CLEAR_COLOR, &p->clear_color, 0, 0); in draw()
249 cso_set_blend(p->cso, &p->blend); in draw()
250 cso_set_depth_stencil_alpha(p->cso, &p->depthstencil); in draw()
251 cso_set_rasterizer(p->cso, &p->rasterizer); in draw()
252 cso_set_viewport(p->cso, &p->viewport); in draw()
255 cso_set_fragment_shader_handle(p->cso, p->fs); in draw()
256 cso_set_vertex_shader_handle(p->cso, p->vs); in draw()
259 cso_set_vertex_elements(p->cso, 2, p->velem); in draw()
261 util_draw_vertex_buffer(p->pipe, p->cso, in draw()
262 p->vbuf, 0, 0, in draw()
267 p->pipe->flush(p->pipe, NULL, 0); in draw()
269 debug_dump_surface_bmp(p->pipe, "result.bmp", p->framebuffer.cbufs[0]); in draw()
274 struct program *p = CALLOC_STRUCT(program); in main() local
276 init_prog(p); in main()
277 draw(p); in main()
278 close_prog(p); in main()