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, PIPE_SEARCH_DIR); in init_prog()
95 assert(p->screen); in init_prog()
98 p->pipe = p->screen->context_create(p->screen, NULL); in init_prog()
99 p->cso = cso_create_context(p->pipe); 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.gl_rasterization_rules = 1; in init_prog()
156 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()
191 p->viewport.scale[3] = 1.0f; in init_prog()
193 p->viewport.translate[0] = half_width + x; in init_prog()
194 p->viewport.translate[1] = (half_height + y) * scale + bias; in init_prog()
195 p->viewport.translate[2] = half_depth + z; in init_prog()
196 p->viewport.translate[3] = 0.0f; in init_prog()
200 memset(p->velem, 0, sizeof(p->velem)); in init_prog()
201 p->velem[0].src_offset = 0 * 4 * sizeof(float); /* offset 0, first element */ in init_prog()
202 p->velem[0].instance_divisor = 0; in init_prog()
203 p->velem[0].vertex_buffer_index = 0; in init_prog()
204 p->velem[0].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; in init_prog()
206 p->velem[1].src_offset = 1 * 4 * sizeof(float); /* offset 16, second element */ in init_prog()
207 p->velem[1].instance_divisor = 0; in init_prog()
208 p->velem[1].vertex_buffer_index = 0; in init_prog()
209 p->velem[1].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; in init_prog()
216 p->vs = util_make_vertex_passthrough_shader(p->pipe, 2, semantic_names, semantic_indexes); in init_prog()
220 p->fs = util_make_fragment_passthrough_shader(p->pipe); in init_prog()
223 static void close_prog(struct program *p) in close_prog() argument
226 cso_release_all(p->cso); in close_prog()
228 p->pipe->delete_vs_state(p->pipe, p->vs); in close_prog()
229 p->pipe->delete_fs_state(p->pipe, p->fs); in close_prog()
231 pipe_surface_reference(&p->framebuffer.cbufs[0], NULL); in close_prog()
232 pipe_resource_reference(&p->target, NULL); in close_prog()
233 pipe_resource_reference(&p->vbuf, NULL); in close_prog()
235 cso_destroy_context(p->cso); in close_prog()
236 p->pipe->destroy(p->pipe); in close_prog()
237 p->screen->destroy(p->screen); in close_prog()
238 pipe_loader_release(&p->dev, 1); in close_prog()
240 FREE(p); in close_prog()
243 static void draw(struct program *p) in draw() argument
246 cso_set_framebuffer(p->cso, &p->framebuffer); in draw()
249 p->pipe->clear(p->pipe, PIPE_CLEAR_COLOR, &p->clear_color, 0, 0); in draw()
252 cso_set_blend(p->cso, &p->blend); in draw()
253 cso_set_depth_stencil_alpha(p->cso, &p->depthstencil); in draw()
254 cso_set_rasterizer(p->cso, &p->rasterizer); in draw()
255 cso_set_viewport(p->cso, &p->viewport); in draw()
258 cso_set_fragment_shader_handle(p->cso, p->fs); in draw()
259 cso_set_vertex_shader_handle(p->cso, p->vs); in draw()
262 cso_set_vertex_elements(p->cso, 2, p->velem); in draw()
264 util_draw_vertex_buffer(p->pipe, p->cso, in draw()
265 p->vbuf, 0, in draw()
270 p->pipe->flush(p->pipe, NULL); in draw()
272 debug_dump_surface_bmp(p->pipe, "result.bmp", p->framebuffer.cbufs[0]); in draw()
277 struct program *p = CALLOC_STRUCT(program); in main() local
279 init_prog(p); in main()
280 draw(p); in main()
281 close_prog(p); in main()