r300g: make r300_translate_texformat private
[mesa.git] / src / gallium / drivers / r300 / r300_texture.c
1 /*
2 * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE. */
22
23 #include "pipe/p_screen.h"
24
25 #include "util/u_format.h"
26 #include "util/u_math.h"
27 #include "util/u_memory.h"
28
29 #include "r300_context.h"
30 #include "r300_texture.h"
31 #include "r300_screen.h"
32
33 #include "radeon_winsys.h"
34
35 #define TILE_WIDTH 0
36 #define TILE_HEIGHT 1
37
38 static const unsigned microblock_table[5][3][2] = {
39 /*linear tiled square-tiled */
40 {{32, 1}, {8, 4}, {0, 0}}, /* 8 bits per pixel */
41 {{16, 1}, {8, 2}, {4, 4}}, /* 16 bits per pixel */
42 {{ 8, 1}, {4, 2}, {0, 0}}, /* 32 bits per pixel */
43 {{ 4, 1}, {0, 0}, {2, 2}}, /* 64 bits per pixel */
44 {{ 2, 1}, {0, 0}, {0, 0}} /* 128 bits per pixel */
45 };
46
47 /* Translate a pipe_format into a useful texture format for sampling.
48 *
49 * Some special formats are translated directly using R300_EASY_TX_FORMAT,
50 * but the majority of them is translated in a generic way, automatically
51 * supporting all the formats hw can support.
52 *
53 * R300_EASY_TX_FORMAT swizzles the texture.
54 * Note the signature of R300_EASY_TX_FORMAT:
55 * R300_EASY_TX_FORMAT(B, G, R, A, FORMAT);
56 *
57 * The FORMAT specifies how the texture sampler will treat the texture, and
58 * makes available X, Y, Z, W, ZERO, and ONE for swizzling. */
59 static uint32_t r300_translate_texformat(enum pipe_format format)
60 {
61 uint32_t result = 0;
62 const struct util_format_description *desc;
63 unsigned components = 0, i;
64 boolean uniform = TRUE;
65 const uint32_t swizzle_shift[4] = {
66 R300_TX_FORMAT_R_SHIFT,
67 R300_TX_FORMAT_G_SHIFT,
68 R300_TX_FORMAT_B_SHIFT,
69 R300_TX_FORMAT_A_SHIFT
70 };
71 const uint32_t sign_bit[4] = {
72 R300_TX_FORMAT_SIGNED_X,
73 R300_TX_FORMAT_SIGNED_Y,
74 R300_TX_FORMAT_SIGNED_Z,
75 R300_TX_FORMAT_SIGNED_W,
76 };
77
78 desc = util_format_description(format);
79
80 /* Colorspace (return non-RGB formats directly). */
81 switch (desc->colorspace) {
82 /* Depth stencil formats. */
83 case UTIL_FORMAT_COLORSPACE_ZS:
84 switch (format) {
85 case PIPE_FORMAT_Z16_UNORM:
86 return R300_EASY_TX_FORMAT(X, X, X, X, X16);
87 case PIPE_FORMAT_Z24X8_UNORM:
88 case PIPE_FORMAT_Z24S8_UNORM:
89 return R300_EASY_TX_FORMAT(X, X, X, X, W24_FP);
90 default:
91 return ~0; /* Unsupported. */
92 }
93
94 /* YUV formats. */
95 case UTIL_FORMAT_COLORSPACE_YUV:
96 result |= R300_TX_FORMAT_YUV_TO_RGB;
97
98 switch (format) {
99 case PIPE_FORMAT_YCBCR:
100 return R300_EASY_TX_FORMAT(X, Y, Z, ONE, YVYU422) | result;
101 case PIPE_FORMAT_YCBCR_REV:
102 return R300_EASY_TX_FORMAT(X, Y, Z, ONE, VYUY422) | result;
103 default:
104 return ~0; /* Unsupported/unknown. */
105 }
106
107 /* Add gamma correction. */
108 case UTIL_FORMAT_COLORSPACE_SRGB:
109 result |= R300_TX_FORMAT_GAMMA;
110 break;
111
112 default:;
113 }
114
115 /* Add swizzle. */
116 for (i = 0; i < 4; i++) {
117 switch (desc->swizzle[i]) {
118 case UTIL_FORMAT_SWIZZLE_X:
119 case UTIL_FORMAT_SWIZZLE_NONE:
120 result |= R300_TX_FORMAT_X << swizzle_shift[i];
121 break;
122 case UTIL_FORMAT_SWIZZLE_Y:
123 result |= R300_TX_FORMAT_Y << swizzle_shift[i];
124 break;
125 case UTIL_FORMAT_SWIZZLE_Z:
126 result |= R300_TX_FORMAT_Z << swizzle_shift[i];
127 break;
128 case UTIL_FORMAT_SWIZZLE_W:
129 result |= R300_TX_FORMAT_W << swizzle_shift[i];
130 break;
131 case UTIL_FORMAT_SWIZZLE_0:
132 result |= R300_TX_FORMAT_ZERO << swizzle_shift[i];
133 break;
134 case UTIL_FORMAT_SWIZZLE_1:
135 result |= R300_TX_FORMAT_ONE << swizzle_shift[i];
136 break;
137 default:
138 return ~0; /* Unsupported. */
139 }
140 }
141
142 /* Compressed formats. */
143 if (desc->layout == UTIL_FORMAT_LAYOUT_DXT) {
144 switch (format) {
145 case PIPE_FORMAT_DXT1_RGB:
146 case PIPE_FORMAT_DXT1_RGBA:
147 case PIPE_FORMAT_DXT1_SRGB:
148 case PIPE_FORMAT_DXT1_SRGBA:
149 return R300_TX_FORMAT_DXT1 | result;
150 case PIPE_FORMAT_DXT3_RGBA:
151 case PIPE_FORMAT_DXT3_SRGBA:
152 return R300_TX_FORMAT_DXT3 | result;
153 case PIPE_FORMAT_DXT5_RGBA:
154 case PIPE_FORMAT_DXT5_SRGBA:
155 return R300_TX_FORMAT_DXT5 | result;
156 default:
157 return ~0; /* Unsupported/unknown. */
158 }
159 }
160
161 /* Get the number of components. */
162 for (i = 0; i < 4; i++) {
163 if (desc->channel[i].type != UTIL_FORMAT_TYPE_VOID) {
164 ++components;
165 }
166 }
167
168 /* Add sign. */
169 for (i = 0; i < components; i++) {
170 if (desc->channel[i].type == UTIL_FORMAT_TYPE_SIGNED) {
171 result |= sign_bit[i];
172 }
173 }
174
175 /* See whether the components are of the same size. */
176 for (i = 1; i < components; i++) {
177 uniform = uniform && desc->channel[0].size == desc->channel[i].size;
178 }
179
180 /* Non-uniform formats. */
181 if (!uniform) {
182 switch (components) {
183 case 3:
184 if (desc->channel[0].size == 5 &&
185 desc->channel[1].size == 6 &&
186 desc->channel[2].size == 5) {
187 return R300_TX_FORMAT_Z5Y6X5 | result;
188 }
189 if (desc->channel[0].size == 5 &&
190 desc->channel[1].size == 5 &&
191 desc->channel[2].size == 6) {
192 return R300_TX_FORMAT_Z6Y5X5 | result;
193 }
194 return ~0; /* Unsupported/unknown. */
195
196 case 4:
197 if (desc->channel[0].size == 5 &&
198 desc->channel[1].size == 5 &&
199 desc->channel[2].size == 5 &&
200 desc->channel[3].size == 1) {
201 return R300_TX_FORMAT_W1Z5Y5X5 | result;
202 }
203 if (desc->channel[0].size == 10 &&
204 desc->channel[1].size == 10 &&
205 desc->channel[2].size == 10 &&
206 desc->channel[3].size == 2) {
207 return R300_TX_FORMAT_W2Z10Y10X10 | result;
208 }
209 }
210 return ~0; /* Unsupported/unknown. */
211 }
212
213 /* And finally, uniform formats. */
214 switch (desc->channel[0].type) {
215 case UTIL_FORMAT_TYPE_UNSIGNED:
216 case UTIL_FORMAT_TYPE_SIGNED:
217 if (!desc->channel[0].normalized &&
218 desc->colorspace != UTIL_FORMAT_COLORSPACE_SRGB) {
219 return ~0;
220 }
221
222 switch (desc->channel[0].size) {
223 case 4:
224 switch (components) {
225 case 2:
226 return R300_TX_FORMAT_Y4X4 | result;
227 case 4:
228 return R300_TX_FORMAT_W4Z4Y4X4 | result;
229 }
230 return ~0;
231
232 case 8:
233 switch (components) {
234 case 1:
235 return R300_TX_FORMAT_X8 | result;
236 case 2:
237 return R300_TX_FORMAT_Y8X8 | result;
238 case 4:
239 return R300_TX_FORMAT_W8Z8Y8X8 | result;
240 }
241 return ~0;
242
243 case 16:
244 switch (components) {
245 case 1:
246 return R300_TX_FORMAT_X16 | result;
247 case 2:
248 return R300_TX_FORMAT_Y16X16 | result;
249 case 4:
250 return R300_TX_FORMAT_W16Z16Y16X16 | result;
251 }
252 }
253 return ~0;
254
255 /* XXX Enable float textures here. */
256 #if 0
257 case UTIL_FORMAT_TYPE_FLOAT:
258 switch (desc->channel[0].size) {
259 case 16:
260 switch (components) {
261 case 1:
262 return R300_TX_FORMAT_16F | result;
263 case 2:
264 return R300_TX_FORMAT_16F_16F | result;
265 case 4:
266 return R300_TX_FORMAT_16F_16F_16F_16F | result;
267 }
268 return ~0;
269
270 case 32:
271 switch (components) {
272 case 1:
273 return R300_TX_FORMAT_32F | result;
274 case 2:
275 return R300_TX_FORMAT_32F_32F | result;
276 case 4:
277 return R300_TX_FORMAT_32F_32F_32F_32F | result;
278 }
279 }
280 #endif
281 }
282
283 return ~0; /* Unsupported/unknown. */
284 }
285
286 boolean r300_is_sampler_format_supported(enum pipe_format format)
287 {
288 return r300_translate_texformat(format) != ~0;
289 }
290
291 static void r300_setup_texture_state(struct r300_screen* screen, struct r300_texture* tex)
292 {
293 struct r300_texture_state* state = &tex->state;
294 struct pipe_texture *pt = &tex->tex;
295 boolean is_r500 = screen->caps->is_r500;
296
297 state->format0 = R300_TX_WIDTH((pt->width0 - 1) & 0x7ff) |
298 R300_TX_HEIGHT((pt->height0 - 1) & 0x7ff);
299
300 if (tex->is_npot) {
301 /* rectangles love this */
302 state->format0 |= R300_TX_PITCH_EN;
303 state->format2 = (tex->pitch[0] - 1) & 0x1fff;
304 } else {
305 /* power of two textures (3D, mipmaps, and no pitch) */
306 state->format0 |= R300_TX_DEPTH(util_logbase2(pt->depth0) & 0xf);
307 }
308
309 state->format1 = r300_translate_texformat(pt->format);
310 if (pt->target == PIPE_TEXTURE_CUBE) {
311 state->format1 |= R300_TX_FORMAT_CUBIC_MAP;
312 }
313 if (pt->target == PIPE_TEXTURE_3D) {
314 state->format1 |= R300_TX_FORMAT_3D;
315 }
316
317 /* large textures on r500 */
318 if (is_r500)
319 {
320 if (pt->width0 > 2048) {
321 state->format2 |= R500_TXWIDTH_BIT11;
322 }
323 if (pt->height0 > 2048) {
324 state->format2 |= R500_TXHEIGHT_BIT11;
325 }
326 }
327
328 SCREEN_DBG(screen, DBG_TEX, "r300: Set texture state (%dx%d, %d levels)\n",
329 pt->width0, pt->height0, pt->last_level);
330 }
331
332 void r300_texture_reinterpret_format(struct pipe_screen *screen,
333 struct pipe_texture *tex,
334 enum pipe_format new_format)
335 {
336 struct r300_screen *r300screen = r300_screen(screen);
337
338 SCREEN_DBG(r300screen, DBG_TEX, "r300: Reinterpreting format: %s -> %s\n",
339 util_format_name(tex->format), util_format_name(new_format));
340
341 tex->format = new_format;
342
343 r300_setup_texture_state(r300_screen(screen), (struct r300_texture*)tex);
344 }
345
346 unsigned r300_texture_get_offset(struct r300_texture* tex, unsigned level,
347 unsigned zslice, unsigned face)
348 {
349 unsigned offset = tex->offset[level];
350
351 switch (tex->tex.target) {
352 case PIPE_TEXTURE_3D:
353 assert(face == 0);
354 return offset + zslice * tex->layer_size[level];
355
356 case PIPE_TEXTURE_CUBE:
357 assert(zslice == 0);
358 return offset + face * tex->layer_size[level];
359
360 default:
361 assert(zslice == 0 && face == 0);
362 return offset;
363 }
364 }
365
366 /**
367 * Return the width (dim==TILE_WIDTH) or height (dim==TILE_HEIGHT) of one tile
368 * of the given texture.
369 */
370 static unsigned r300_texture_get_tile_size(struct r300_texture* tex,
371 int dim, boolean macrotile)
372 {
373 unsigned pixsize, tile_size;
374
375 pixsize = util_format_get_blocksize(tex->tex.format);
376 tile_size = microblock_table[util_logbase2(pixsize)][tex->microtile][dim];
377
378 if (macrotile) {
379 tile_size *= 8;
380 }
381
382 assert(tile_size);
383 return tile_size;
384 }
385
386 /* Return true if macrotiling should be enabled on the miplevel. */
387 static boolean r300_texture_macro_switch(struct r300_texture *tex,
388 unsigned level,
389 boolean rv350_mode)
390 {
391 unsigned tile_width, width;
392
393 tile_width = r300_texture_get_tile_size(tex, TILE_WIDTH, TRUE);
394 width = u_minify(tex->tex.width0, level);
395
396 /* See TX_FILTER1_n.MACRO_SWITCH. */
397 if (rv350_mode) {
398 return width >= tile_width;
399 } else {
400 return width > tile_width;
401 }
402 }
403
404 /**
405 * Return the stride, in bytes, of the texture images of the given texture
406 * at the given level.
407 */
408 unsigned r300_texture_get_stride(struct r300_screen* screen,
409 struct r300_texture* tex, unsigned level)
410 {
411 unsigned tile_width, width;
412
413 if (tex->stride_override)
414 return tex->stride_override;
415
416 /* Check the level. */
417 if (level > tex->tex.last_level) {
418 SCREEN_DBG(screen, DBG_TEX, "%s: level (%u) > last_level (%u)\n",
419 __FUNCTION__, level, tex->tex.last_level);
420 return 0;
421 }
422
423 width = u_minify(tex->tex.width0, level);
424
425 if (!util_format_is_compressed(tex->tex.format)) {
426 tile_width = r300_texture_get_tile_size(tex, TILE_WIDTH,
427 tex->mip_macrotile[level]);
428 width = align(width, tile_width);
429
430 return util_format_get_stride(tex->tex.format, width);
431 } else {
432 return align(util_format_get_stride(tex->tex.format, width), 32);
433 }
434 }
435
436 static unsigned r300_texture_get_nblocksy(struct r300_texture* tex,
437 unsigned level)
438 {
439 unsigned height, tile_height;
440
441 height = u_minify(tex->tex.height0, level);
442
443 if (!util_format_is_compressed(tex->tex.format)) {
444 tile_height = r300_texture_get_tile_size(tex, TILE_HEIGHT,
445 tex->mip_macrotile[level]);
446 height = align(height, tile_height);
447 }
448
449 return util_format_get_nblocksy(tex->tex.format, height);
450 }
451
452 static void r300_setup_miptree(struct r300_screen* screen,
453 struct r300_texture* tex)
454 {
455 struct pipe_texture* base = &tex->tex;
456 unsigned stride, size, layer_size, nblocksy, i;
457 boolean rv350_mode = screen->caps->family >= CHIP_FAMILY_RV350;
458
459 SCREEN_DBG(screen, DBG_TEX, "r300: Making miptree for texture, format %s\n",
460 util_format_name(base->format));
461
462 for (i = 0; i <= base->last_level; i++) {
463 /* Let's see if this miplevel can be macrotiled. */
464 tex->mip_macrotile[i] = (tex->macrotile == R300_BUFFER_TILED &&
465 r300_texture_macro_switch(tex, i, rv350_mode)) ?
466 R300_BUFFER_TILED : R300_BUFFER_LINEAR;
467
468 stride = r300_texture_get_stride(screen, tex, i);
469 nblocksy = r300_texture_get_nblocksy(tex, i);
470 layer_size = stride * nblocksy;
471
472 if (base->target == PIPE_TEXTURE_CUBE)
473 size = layer_size * 6;
474 else
475 size = layer_size * u_minify(base->depth0, i);
476
477 tex->offset[i] = tex->size;
478 tex->size = tex->offset[i] + size;
479 tex->layer_size[i] = layer_size;
480 tex->pitch[i] = stride / util_format_get_blocksize(base->format);
481
482 SCREEN_DBG(screen, DBG_TEX, "r300: Texture miptree: Level %d "
483 "(%dx%dx%d px, pitch %d bytes) %d bytes total, macrotiled %s\n",
484 i, u_minify(base->width0, i), u_minify(base->height0, i),
485 u_minify(base->depth0, i), stride, tex->size,
486 tex->mip_macrotile[i] ? "TRUE" : "FALSE");
487 }
488 }
489
490 static void r300_setup_flags(struct r300_texture* tex)
491 {
492 tex->is_npot = !util_is_power_of_two(tex->tex.width0) ||
493 !util_is_power_of_two(tex->tex.height0);
494 }
495
496 /* Create a new texture. */
497 static struct pipe_texture*
498 r300_texture_create(struct pipe_screen* screen,
499 const struct pipe_texture* template)
500 {
501 struct r300_texture* tex = CALLOC_STRUCT(r300_texture);
502 struct r300_screen* rscreen = r300_screen(screen);
503 struct radeon_winsys* winsys = (struct radeon_winsys*)screen->winsys;
504
505 if (!tex) {
506 return NULL;
507 }
508
509 tex->tex = *template;
510 pipe_reference_init(&tex->tex.reference, 1);
511 tex->tex.screen = screen;
512
513 r300_setup_flags(tex);
514 r300_setup_miptree(rscreen, tex);
515 r300_setup_texture_state(rscreen, tex);
516
517 tex->buffer = screen->buffer_create(screen, 2048,
518 PIPE_BUFFER_USAGE_PIXEL,
519 tex->size);
520 winsys->buffer_set_tiling(winsys, tex->buffer,
521 tex->pitch[0],
522 tex->microtile != R300_BUFFER_LINEAR,
523 tex->macrotile != R300_BUFFER_LINEAR);
524
525 if (!tex->buffer) {
526 FREE(tex);
527 return NULL;
528 }
529
530 return (struct pipe_texture*)tex;
531 }
532
533 static void r300_texture_destroy(struct pipe_texture* texture)
534 {
535 struct r300_texture* tex = (struct r300_texture*)texture;
536
537 pipe_buffer_reference(&tex->buffer, NULL);
538
539 FREE(tex);
540 }
541
542 static struct pipe_surface* r300_get_tex_surface(struct pipe_screen* screen,
543 struct pipe_texture* texture,
544 unsigned face,
545 unsigned level,
546 unsigned zslice,
547 unsigned flags)
548 {
549 struct r300_texture* tex = (struct r300_texture*)texture;
550 struct pipe_surface* surface = CALLOC_STRUCT(pipe_surface);
551 unsigned offset;
552
553 offset = r300_texture_get_offset(tex, level, zslice, face);
554
555 if (surface) {
556 pipe_reference_init(&surface->reference, 1);
557 pipe_texture_reference(&surface->texture, texture);
558 surface->format = texture->format;
559 surface->width = u_minify(texture->width0, level);
560 surface->height = u_minify(texture->height0, level);
561 surface->offset = offset;
562 surface->usage = flags;
563 surface->zslice = zslice;
564 surface->texture = texture;
565 surface->face = face;
566 surface->level = level;
567 }
568
569 return surface;
570 }
571
572 static void r300_tex_surface_destroy(struct pipe_surface* s)
573 {
574 pipe_texture_reference(&s->texture, NULL);
575 FREE(s);
576 }
577
578 static struct pipe_texture*
579 r300_texture_blanket(struct pipe_screen* screen,
580 const struct pipe_texture* base,
581 const unsigned* stride,
582 struct pipe_buffer* buffer)
583 {
584 struct r300_texture* tex;
585 struct r300_screen* rscreen = r300_screen(screen);
586
587 /* Support only 2D textures without mipmaps */
588 if (base->target != PIPE_TEXTURE_2D ||
589 base->depth0 != 1 ||
590 base->last_level != 0) {
591 return NULL;
592 }
593
594 tex = CALLOC_STRUCT(r300_texture);
595 if (!tex) {
596 return NULL;
597 }
598
599 tex->tex = *base;
600 pipe_reference_init(&tex->tex.reference, 1);
601 tex->tex.screen = screen;
602
603 tex->stride_override = *stride;
604 tex->pitch[0] = *stride / util_format_get_blocksize(base->format);
605
606 r300_setup_flags(tex);
607 r300_setup_texture_state(rscreen, tex);
608
609 pipe_buffer_reference(&tex->buffer, buffer);
610
611 return (struct pipe_texture*)tex;
612 }
613
614 static struct pipe_video_surface *
615 r300_video_surface_create(struct pipe_screen *screen,
616 enum pipe_video_chroma_format chroma_format,
617 unsigned width, unsigned height)
618 {
619 struct r300_video_surface *r300_vsfc;
620 struct pipe_texture template;
621
622 assert(screen);
623 assert(width && height);
624
625 r300_vsfc = CALLOC_STRUCT(r300_video_surface);
626 if (!r300_vsfc)
627 return NULL;
628
629 pipe_reference_init(&r300_vsfc->base.reference, 1);
630 r300_vsfc->base.screen = screen;
631 r300_vsfc->base.chroma_format = chroma_format;
632 r300_vsfc->base.width = width;
633 r300_vsfc->base.height = height;
634
635 memset(&template, 0, sizeof(struct pipe_texture));
636 template.target = PIPE_TEXTURE_2D;
637 template.format = PIPE_FORMAT_X8R8G8B8_UNORM;
638 template.last_level = 0;
639 template.width0 = util_next_power_of_two(width);
640 template.height0 = util_next_power_of_two(height);
641 template.depth0 = 1;
642 template.tex_usage = PIPE_TEXTURE_USAGE_SAMPLER |
643 PIPE_TEXTURE_USAGE_RENDER_TARGET;
644
645 r300_vsfc->tex = screen->texture_create(screen, &template);
646 if (!r300_vsfc->tex)
647 {
648 FREE(r300_vsfc);
649 return NULL;
650 }
651
652 return &r300_vsfc->base;
653 }
654
655 static void r300_video_surface_destroy(struct pipe_video_surface *vsfc)
656 {
657 struct r300_video_surface *r300_vsfc = r300_video_surface(vsfc);
658 pipe_texture_reference(&r300_vsfc->tex, NULL);
659 FREE(r300_vsfc);
660 }
661
662 void r300_init_screen_texture_functions(struct pipe_screen* screen)
663 {
664 screen->texture_create = r300_texture_create;
665 screen->texture_destroy = r300_texture_destroy;
666 screen->get_tex_surface = r300_get_tex_surface;
667 screen->tex_surface_destroy = r300_tex_surface_destroy;
668 screen->texture_blanket = r300_texture_blanket;
669
670 screen->video_surface_create = r300_video_surface_create;
671 screen->video_surface_destroy= r300_video_surface_destroy;
672 }
673
674 boolean r300_get_texture_buffer(struct pipe_screen* screen,
675 struct pipe_texture* texture,
676 struct pipe_buffer** buffer,
677 unsigned* stride)
678 {
679 struct r300_texture* tex = (struct r300_texture*)texture;
680 if (!tex) {
681 return FALSE;
682 }
683
684 pipe_buffer_reference(buffer, tex->buffer);
685
686 if (stride) {
687 *stride = r300_texture_get_stride(r300_screen(screen), tex, 0);
688 }
689
690 return TRUE;
691 }