Lines Matching refs:lpr
108 struct llvmpipe_resource *lpr)
110 struct pipe_resource *pt = &lpr->base;
140 lpr->row_stride[level] = align(nblocksx * block_size, 16);
142 lpr->img_stride[level] = lpr->row_stride[level] * nblocksy;
149 lpr->tiles_per_row[level] = width_t;
150 lpr->tiles_per_image[level] = width_t * height_t;
157 if (lpr->base.target == PIPE_TEXTURE_CUBE)
159 else if (lpr->base.target == PIPE_TEXTURE_3D)
164 lpr->num_slices_faces[level] = num_slices;
166 lpr->layout[level] = alloc_layout_array(num_slices, width, height);
167 if (!lpr->layout[level]) {
172 total_size += lpr->num_slices_faces[level] * lpr->img_stride[level];
187 if (lpr->layout[level]) {
188 FREE(lpr->layout[level]);
199 struct llvmpipe_resource *lpr)
206 const unsigned width = align(lpr->base.width0, TILE_SIZE);
207 const unsigned height = align(lpr->base.height0, TILE_SIZE);
211 lpr->tiles_per_row[0] = width_t;
212 lpr->tiles_per_image[0] = width_t * height_t;
213 lpr->num_slices_faces[0] = 1;
214 lpr->img_stride[0] = 0;
216 lpr->layout[0] = alloc_layout_array(1, width, height);
217 if (!lpr->layout[0]) {
221 lpr->dt = winsys->displaytarget_create(winsys,
222 lpr->base.bind,
223 lpr->base.format,
226 &lpr->row_stride[0] );
228 if (lpr->dt == NULL)
232 void *map = winsys->displaytarget_map(winsys, lpr->dt,
236 memset(map, 0, height * lpr->row_stride[0]);
238 winsys->displaytarget_unmap(winsys, lpr->dt);
250 struct llvmpipe_resource *lpr = CALLOC_STRUCT(llvmpipe_resource);
251 if (!lpr)
254 lpr->base = *templat;
255 pipe_reference_init(&lpr->base.reference, 1);
256 lpr->base.screen = &screen->base;
258 /* assert(lpr->base.bind); */
260 if (resource_is_texture(&lpr->base)) {
261 if (lpr->base.bind & PIPE_BIND_DISPLAY_TARGET) {
263 if (!llvmpipe_displaytarget_layout(screen, lpr))
265 assert(lpr->layout[0][0] == LP_TEX_LAYOUT_NONE);
269 if (!llvmpipe_texture_layout(screen, lpr))
271 assert(lpr->layout[0][0] == LP_TEX_LAYOUT_NONE);
273 assert(lpr->layout[0]);
284 lpr->data = align_malloc(bytes, 16);
285 if (!lpr->data)
287 memset(lpr->data, 0, bytes);
290 lpr->id = id_counter++;
293 insert_at_tail(&resource_list, lpr);
296 return &lpr->base;
299 FREE(lpr);
309 struct llvmpipe_resource *lpr = llvmpipe_resource(pt);
311 if (lpr->dt) {
314 winsys->displaytarget_destroy(winsys, lpr->dt);
316 if (lpr->tiled[0].data) {
317 align_free(lpr->tiled[0].data);
318 lpr->tiled[0].data = NULL;
321 FREE(lpr->layout[0]);
328 for (level = 0; level < Elements(lpr->linear); level++) {
329 if (lpr->linear[level].data) {
330 align_free(lpr->linear[level].data);
331 lpr->linear[level].data = NULL;
336 for (level = 0; level < Elements(lpr->tiled); level++) {
337 if (lpr->tiled[level].data) {
338 align_free(lpr->tiled[level].data);
339 lpr->tiled[level].data = NULL;
344 for (level = 0; level < Elements(lpr->tiled); level++) {
345 FREE(lpr->layout[level]);
346 lpr->layout[level] = NULL;
349 else if (!lpr->userBuffer) {
350 assert(lpr->data);
351 align_free(lpr->data);
355 if (lpr->next)
356 remove_from_list(lpr);
359 FREE(lpr);
373 struct llvmpipe_resource *lpr = llvmpipe_resource(resource);
387 if (lpr->dt) {
405 map = winsys->displaytarget_map(winsys, lpr->dt, dt_usage);
408 lpr->linear[level].data = map;
411 map2 = llvmpipe_get_texture_image(lpr, 0, 0, tex_usage, layout);
419 map = llvmpipe_get_texture_image(lpr, layer, level,
424 return lpr->data;
437 struct llvmpipe_resource *lpr = llvmpipe_resource(resource);
439 if (lpr->dt) {
448 (void) llvmpipe_get_texture_image(lpr, layer, level,
452 winsys->displaytarget_unmap(winsys, lpr->dt);
460 struct llvmpipe_resource *lpr = llvmpipe_resource(resource);
464 return lpr->data;
474 struct llvmpipe_resource *lpr;
479 lpr = CALLOC_STRUCT(llvmpipe_resource);
480 if (!lpr) {
484 lpr->base = *template;
485 pipe_reference_init(&lpr->base.reference, 1);
486 lpr->base.screen = screen;
488 width = align(lpr->base.width0, TILE_SIZE);
489 height = align(lpr->base.height0, TILE_SIZE);
498 assert(lpr->base.width0 == width);
499 assert(lpr->base.height0 == height);
502 lpr->tiles_per_row[0] = width_t;
503 lpr->tiles_per_image[0] = width_t * height_t;
504 lpr->num_slices_faces[0] = 1;
505 lpr->img_stride[0] = 0;
507 lpr->dt = winsys->displaytarget_from_handle(winsys,
510 &lpr->row_stride[0]);
511 if (!lpr->dt) {
515 lpr->layout[0] = alloc_layout_array(1, lpr->base.width0, lpr->base.height0);
516 if (!lpr->layout[0]) {
520 assert(lpr->layout[0][0] == LP_TEX_LAYOUT_NONE);
522 lpr->id = id_counter++;
525 insert_at_tail(&resource_list, lpr);
528 return &lpr->base;
531 winsys->displaytarget_destroy(winsys, lpr->dt);
533 FREE(lpr);
545 struct llvmpipe_resource *lpr = llvmpipe_resource(pt);
547 assert(lpr->dt);
548 if (!lpr->dt)
551 return winsys->displaytarget_get_handle(winsys, lpr->dt, whandle);
605 struct llvmpipe_transfer *lpr;
635 lpr = CALLOC_STRUCT(llvmpipe_transfer);
636 if (lpr) {
637 struct pipe_transfer *pt = &lpr->base;
671 struct llvmpipe_resource *lpr;
696 struct llvmpipe_resource *lpr = llvmpipe_resource(transfer->resource);
697 printf("transfer map tex %u mode %s\n", lpr->id, mode);
702 lpr = llvmpipe_resource(transfer->resource);
703 format = lpr->base.format;
791 tex_image_face_size(const struct llvmpipe_resource *lpr, unsigned level,
794 const unsigned width = u_minify(lpr->base.width0, level);
795 const unsigned height = u_minify(lpr->base.height0, level);
813 return lpr->img_stride[level];
823 tex_image_size(const struct llvmpipe_resource *lpr, unsigned level,
826 const unsigned buf_size = tex_image_face_size(lpr, level, layout);
827 return buf_size * lpr->num_slices_faces[level];
895 llvmpipe_get_texture_image_address(struct llvmpipe_resource *lpr,
903 img = &lpr->linear[level];
907 img = &lpr->tiled[level];
911 offset = face_slice * tex_image_face_size(lpr, level, layout);
920 llvmpipe_get_texture_tile_layout(const struct llvmpipe_resource *lpr,
925 assert(resource_is_texture(&lpr->base));
926 assert(x < lpr->tiles_per_row[level]);
927 i = face_slice * lpr->tiles_per_image[level]
928 + y * lpr->tiles_per_row[level] + x;
929 return lpr->layout[level][i];
934 llvmpipe_set_texture_tile_layout(struct llvmpipe_resource *lpr,
940 assert(resource_is_texture(&lpr->base));
941 assert(x < lpr->tiles_per_row[level]);
942 i = face_slice * lpr->tiles_per_image[level]
943 + y * lpr->tiles_per_row[level] + x;
944 lpr->layout[level][i] = layout;
952 llvmpipe_set_texture_image_layout(struct llvmpipe_resource *lpr,
957 const unsigned start = face_slice * lpr->tiles_per_image[level];
961 lpr->layout[level][start + i] = layout;
971 alloc_image_data(struct llvmpipe_resource *lpr, unsigned level,
976 if (lpr->dt)
981 uint buffer_size = tex_image_size(lpr, level, layout);
982 lpr->tiled[level].data = align_malloc(buffer_size, alignment);
983 if (lpr->tiled[level].data) {
984 memset(lpr->tiled[level].data, 0, buffer_size);
989 if (lpr->dt) {
993 struct llvmpipe_screen *screen = llvmpipe_screen(lpr->base.screen);
996 lpr->linear[0].data =
997 winsys->displaytarget_map(winsys, lpr->dt,
1002 uint buffer_size = tex_image_size(lpr, level, LP_TEX_LAYOUT_LINEAR);
1003 lpr->linear[level].data = align_malloc(buffer_size, alignment);
1004 if (lpr->linear[level].data) {
1005 memset(lpr->linear[level].data, 0, buffer_size);
1022 llvmpipe_get_texture_image(struct llvmpipe_resource *lpr,
1037 const unsigned width = u_minify(lpr->base.width0, level);
1038 const unsigned height = u_minify(lpr->base.height0, level);
1061 if (lpr->dt) {
1062 assert(lpr->linear[level].data);
1067 target_img = &lpr->linear[level];
1068 other_img = &lpr->tiled[level];
1072 target_img = &lpr->tiled[level];
1073 other_img = &lpr->linear[level];
1082 alloc_image_data(lpr, level, layout);
1089 target_offset = face_slice * tex_image_face_size(lpr, level, layout);
1090 other_offset = face_slice * tex_image_face_size(lpr, level, other_layout);
1115 llvmpipe_get_texture_tile_layout(lpr, face_slice, level, x, y);
1125 lpr->base.format,
1126 lpr->row_stride[level],
1127 lpr->tiles_per_row[level]);
1134 lpr->base.format,
1135 lpr->row_stride[level],
1136 lpr->tiles_per_row[level]);
1141 llvmpipe_set_texture_tile_layout(lpr, face_slice, level, x, y,
1148 llvmpipe_set_texture_image_layout(lpr, face_slice, level,
1163 llvmpipe_get_texture_image_all(struct llvmpipe_resource *lpr,
1168 const int slices = lpr->num_slices_faces[level];
1175 map = llvmpipe_get_texture_image(lpr, slice, level, usage, layout);
1189 llvmpipe_get_texture_tile_linear(struct llvmpipe_resource *lpr,
1194 struct llvmpipe_texture_image *linear_img = &lpr->linear[level];
1200 assert(resource_is_texture(&lpr->base));
1206 alloc_image_data(lpr, level, LP_TEX_LAYOUT_LINEAR);
1210 tiled_image = llvmpipe_get_texture_image_address(lpr, face_slice, level,
1212 linear_image = llvmpipe_get_texture_image_address(lpr, face_slice, level,
1216 cur_layout = llvmpipe_get_texture_tile_layout(lpr, face_slice, level, tx, ty);
1223 x, y, TILE_SIZE, TILE_SIZE, lpr->base.format,
1224 lpr->row_stride[level],
1225 lpr->tiles_per_row[level]);
1229 llvmpipe_set_texture_tile_layout(lpr, face_slice, level, tx, ty, new_layout);
1240 llvmpipe_get_texture_tile(struct llvmpipe_resource *lpr,
1245 struct llvmpipe_texture_image *tiled_img = &lpr->tiled[level];
1257 alloc_image_data(lpr, level, LP_TEX_LAYOUT_TILED);
1261 tiled_image = llvmpipe_get_texture_image_address(lpr, face_slice, level,
1263 linear_image = llvmpipe_get_texture_image_address(lpr, face_slice, level,
1267 cur_layout = llvmpipe_get_texture_tile_layout(lpr, face_slice, level, tx, ty);
1272 x, y, TILE_SIZE, TILE_SIZE, lpr->base.format,
1273 lpr->row_stride[level],
1274 lpr->tiles_per_row[level]);
1281 llvmpipe_set_texture_tile_layout(lpr, face_slice, level, tx, ty, new_layout);
1284 tile_offset = (ty * lpr->tiles_per_row[level] + tx)
1296 llvmpipe_unswizzle_cbuf_tile(struct llvmpipe_resource *lpr,
1301 struct llvmpipe_texture_image *linear_img = &lpr->linear[level];
1310 alloc_image_data(lpr, level, LP_TEX_LAYOUT_LINEAR);
1314 linear_image = llvmpipe_get_texture_image_address(lpr, face_slice, level,
1330 lpr->base.format,
1331 lpr->row_stride[level],
1335 llvmpipe_set_texture_tile_layout(lpr, face_slice, level, tx, ty,
1345 llvmpipe_swizzle_cbuf_tile(struct llvmpipe_resource *lpr,
1356 linear_image = llvmpipe_get_texture_image_address(lpr, face_slice, level,
1372 lpr->base.format,
1373 lpr->row_stride[level],
1385 const struct llvmpipe_resource *lpr = llvmpipe_resource_const(resource);
1388 for (lvl = 0; lvl <= lpr->base.last_level; lvl++) {
1389 if (lpr->linear[lvl].data)
1390 size += tex_image_size(lpr, lvl, LP_TEX_LAYOUT_LINEAR);
1392 if (lpr->tiled[lvl].data)
1393 size += tex_image_size(lpr, lvl, LP_TEX_LAYOUT_TILED);
1404 struct llvmpipe_resource *lpr;
1408 foreach(lpr, &resource_list) {
1409 unsigned size = llvmpipe_resource_size(&lpr->base);
1411 lpr->id, (void *) lpr,
1412 lpr->base.width0, lpr->base.height0, lpr->base.depth0,
1413 size, lpr->base.reference.count);