2 * Copyright 2010 Jerome Glisse <glisse@freedesktop.org>
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:
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
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.
28 #include <pipe/p_screen.h>
29 #include <util/u_format.h>
30 #include <util/u_math.h>
31 #include <util/u_inlines.h>
32 #include <util/u_memory.h>
33 #include "state_tracker/drm_driver.h"
34 #include "r600_screen.h"
35 #include "r600_context.h"
36 #include "r600_resource.h"
37 #include "r600_state_inlines.h"
40 extern struct u_resource_vtbl r600_texture_vtbl
;
42 /* Copy from a tiled texture to a detiled one. */
43 static void r600_copy_from_tiled_texture(struct pipe_context
*ctx
, struct r600_transfer
*rtransfer
)
45 struct pipe_transfer
*transfer
= (struct pipe_transfer
*)rtransfer
;
46 struct pipe_resource
*texture
= transfer
->resource
;
47 struct pipe_subresource subdst
;
51 ctx
->resource_copy_region(ctx
, rtransfer
->linear_texture
,
52 subdst
, 0, 0, 0, texture
, transfer
->sr
,
53 transfer
->box
.x
, transfer
->box
.y
, transfer
->box
.z
,
54 transfer
->box
.width
, transfer
->box
.height
);
57 static unsigned long r600_texture_get_offset(struct r600_resource_texture
*rtex
,
58 unsigned level
, unsigned zslice
,
61 unsigned long offset
= rtex
->offset
[level
];
63 switch (rtex
->resource
.base
.b
.target
) {
66 return offset
+ zslice
* rtex
->layer_size
[level
];
67 case PIPE_TEXTURE_CUBE
:
69 return offset
+ face
* rtex
->layer_size
[level
];
71 assert(zslice
== 0 && face
== 0);
76 static void r600_setup_miptree(struct r600_resource_texture
*rtex
, enum chip_class chipc
)
78 struct pipe_resource
*ptex
= &rtex
->resource
.base
.b
;
79 unsigned long w
, h
, pitch
, size
, layer_size
, i
, offset
;
81 rtex
->bpt
= util_format_get_blocksize(ptex
->format
);
82 for (i
= 0, offset
= 0; i
<= ptex
->last_level
; i
++) {
83 w
= u_minify(ptex
->width0
, i
);
84 h
= u_minify(ptex
->height0
, i
);
85 h
= util_next_power_of_two(h
);
86 pitch
= util_format_get_stride(ptex
->format
, align(w
, 64));
87 pitch
= align(pitch
, 256);
88 layer_size
= pitch
* h
;
89 if (ptex
->target
== PIPE_TEXTURE_CUBE
) {
91 size
= layer_size
* 8;
93 size
= layer_size
* 6;
96 size
= layer_size
* u_minify(ptex
->depth0
, i
);
97 rtex
->offset
[i
] = offset
;
98 rtex
->layer_size
[i
] = layer_size
;
99 rtex
->pitch
[i
] = pitch
;
107 struct pipe_resource
*r600_texture_create(struct pipe_screen
*screen
,
108 const struct pipe_resource
*templ
)
110 struct r600_resource_texture
*rtex
;
111 struct r600_resource
*resource
;
112 struct radeon
*radeon
= (struct radeon
*)screen
->winsys
;
114 rtex
= CALLOC_STRUCT(r600_resource_texture
);
118 resource
= &rtex
->resource
;
119 resource
->base
.b
= *templ
;
120 resource
->base
.vtbl
= &r600_texture_vtbl
;
121 pipe_reference_init(&resource
->base
.b
.reference
, 1);
122 resource
->base
.b
.screen
= screen
;
123 r600_setup_miptree(rtex
, radeon_get_family_class(radeon
));
125 /* FIXME alignment 4096 enought ? too much ? */
126 resource
->domain
= r600_domain_from_usage(resource
->base
.b
.bind
);
127 resource
->size
= rtex
->size
;
128 resource
->bo
= radeon_ws_bo(radeon
, rtex
->size
, 4096, 0);
129 if (resource
->bo
== NULL
) {
133 return &resource
->base
.b
;
136 static void r600_texture_destroy_state(struct pipe_resource
*ptexture
)
138 struct r600_resource_texture
*rtexture
= (struct r600_resource_texture
*)ptexture
;
140 for (int i
= 0; i
< PIPE_MAX_TEXTURE_LEVELS
; i
++) {
141 radeon_state_fini(&rtexture
->scissor
[i
]);
142 radeon_state_fini(&rtexture
->db
[i
]);
143 for (int j
= 0; j
< 8; j
++) {
144 radeon_state_fini(&rtexture
->cb
[j
][i
]);
149 static void r600_texture_destroy(struct pipe_screen
*screen
,
150 struct pipe_resource
*ptex
)
152 struct r600_resource_texture
*rtex
= (struct r600_resource_texture
*)ptex
;
153 struct r600_resource
*resource
= &rtex
->resource
;
154 struct radeon
*radeon
= (struct radeon
*)screen
->winsys
;
157 radeon_ws_bo_reference(radeon
, &resource
->bo
, NULL
);
159 if (rtex
->uncompressed
) {
160 radeon_ws_bo_reference(radeon
, &rtex
->uncompressed
, NULL
);
162 r600_texture_destroy_state(ptex
);
166 static struct pipe_surface
*r600_get_tex_surface(struct pipe_screen
*screen
,
167 struct pipe_resource
*texture
,
168 unsigned face
, unsigned level
,
169 unsigned zslice
, unsigned flags
)
171 struct r600_resource_texture
*rtex
= (struct r600_resource_texture
*)texture
;
172 struct pipe_surface
*surface
= CALLOC_STRUCT(pipe_surface
);
173 unsigned long offset
;
177 offset
= r600_texture_get_offset(rtex
, level
, zslice
, face
);
178 pipe_reference_init(&surface
->reference
, 1);
179 pipe_resource_reference(&surface
->texture
, texture
);
180 surface
->format
= texture
->format
;
181 surface
->width
= u_minify(texture
->width0
, level
);
182 surface
->height
= u_minify(texture
->height0
, level
);
183 surface
->offset
= offset
;
184 surface
->usage
= flags
;
185 surface
->zslice
= zslice
;
186 surface
->texture
= texture
;
187 surface
->face
= face
;
188 surface
->level
= level
;
192 static void r600_tex_surface_destroy(struct pipe_surface
*surface
)
194 pipe_resource_reference(&surface
->texture
, NULL
);
198 struct pipe_resource
*r600_texture_from_handle(struct pipe_screen
*screen
,
199 const struct pipe_resource
*templ
,
200 struct winsys_handle
*whandle
)
202 struct radeon
*rw
= (struct radeon
*)screen
->winsys
;
203 struct r600_resource_texture
*rtex
;
204 struct r600_resource
*resource
;
205 struct radeon_ws_bo
*bo
= NULL
;
207 /* Support only 2D textures without mipmaps */
208 if ((templ
->target
!= PIPE_TEXTURE_2D
&& templ
->target
!= PIPE_TEXTURE_RECT
) ||
209 templ
->depth0
!= 1 || templ
->last_level
!= 0)
212 rtex
= CALLOC_STRUCT(r600_resource_texture
);
216 bo
= radeon_ws_bo_handle(rw
, whandle
->handle
);
222 resource
= &rtex
->resource
;
223 resource
->base
.b
= *templ
;
224 resource
->base
.vtbl
= &r600_texture_vtbl
;
225 pipe_reference_init(&resource
->base
.b
.reference
, 1);
226 resource
->base
.b
.screen
= screen
;
229 rtex
->pitch_override
= whandle
->stride
;
230 rtex
->bpt
= util_format_get_blocksize(templ
->format
);
231 rtex
->pitch
[0] = whandle
->stride
;
232 rtex
->width
[0] = templ
->width0
;
233 rtex
->height
[0] = templ
->height0
;
235 rtex
->size
= align(rtex
->pitch
[0] * templ
->height0
, 64);
237 return &resource
->base
.b
;
240 static unsigned int r600_texture_is_referenced(struct pipe_context
*context
,
241 struct pipe_resource
*texture
,
242 unsigned face
, unsigned level
)
245 return PIPE_REFERENCED_FOR_READ
| PIPE_REFERENCED_FOR_WRITE
;
248 struct pipe_transfer
* r600_texture_get_transfer(struct pipe_context
*ctx
,
249 struct pipe_resource
*texture
,
250 struct pipe_subresource sr
,
252 const struct pipe_box
*box
)
254 struct r600_resource_texture
*rtex
= (struct r600_resource_texture
*)texture
;
255 struct pipe_resource resource
;
256 struct r600_transfer
*trans
;
258 trans
= CALLOC_STRUCT(r600_transfer
);
261 pipe_resource_reference(&trans
->transfer
.resource
, texture
);
262 trans
->transfer
.sr
= sr
;
263 trans
->transfer
.usage
= usage
;
264 trans
->transfer
.box
= *box
;
265 trans
->transfer
.stride
= rtex
->pitch
[sr
.level
];
266 trans
->offset
= r600_texture_get_offset(rtex
, sr
.level
, box
->z
, sr
.face
);
267 if (rtex
->tilled
&& !rtex
->depth
) {
268 resource
.target
= PIPE_TEXTURE_2D
;
269 resource
.format
= texture
->format
;
270 resource
.width0
= box
->width
;
271 resource
.height0
= box
->height
;
273 resource
.last_level
= 0;
274 resource
.nr_samples
= 0;
275 resource
.usage
= PIPE_USAGE_DYNAMIC
;
278 /* For texture reading, the temporary (detiled) texture is used as
279 * a render target when blitting from a tiled texture. */
280 if (usage
& PIPE_TRANSFER_READ
) {
281 resource
.bind
|= PIPE_BIND_RENDER_TARGET
;
283 /* For texture writing, the temporary texture is used as a sampler
284 * when blitting into a tiled texture. */
285 if (usage
& PIPE_TRANSFER_WRITE
) {
286 resource
.bind
|= PIPE_BIND_SAMPLER_VIEW
;
288 /* Create the temporary texture. */
289 trans
->linear_texture
= ctx
->screen
->resource_create(ctx
->screen
, &resource
);
290 if (trans
->linear_texture
== NULL
) {
291 R600_ERR("failed to create temporary texture to hold untiled copy\n");
292 pipe_resource_reference(&trans
->transfer
.resource
, NULL
);
296 if (usage
& PIPE_TRANSFER_READ
) {
297 /* We cannot map a tiled texture directly because the data is
298 * in a different order, therefore we do detiling using a blit. */
299 r600_copy_from_tiled_texture(ctx
, trans
);
300 /* Always referenced in the blit. */
301 ctx
->flush(ctx
, 0, NULL
);
304 return &trans
->transfer
;
307 void r600_texture_transfer_destroy(struct pipe_context
*ctx
,
308 struct pipe_transfer
*transfer
)
310 struct r600_transfer
*rtransfer
= (struct r600_transfer
*)transfer
;
312 if (rtransfer
->linear_texture
) {
313 pipe_resource_reference(&rtransfer
->linear_texture
, NULL
);
315 pipe_resource_reference(&transfer
->resource
, NULL
);
319 void* r600_texture_transfer_map(struct pipe_context
*ctx
,
320 struct pipe_transfer
* transfer
)
322 struct r600_transfer
*rtransfer
= (struct r600_transfer
*)transfer
;
323 struct radeon_ws_bo
*bo
;
324 enum pipe_format format
= transfer
->resource
->format
;
325 struct radeon
*radeon
= (struct radeon
*)ctx
->screen
->winsys
;
326 struct r600_resource_texture
*rtex
;
327 unsigned long offset
= 0;
331 if (rtransfer
->linear_texture
) {
332 bo
= ((struct r600_resource
*)rtransfer
->linear_texture
)->bo
;
334 rtex
= (struct r600_resource_texture
*)transfer
->resource
;
335 if (rtex
->depth
&& radeon_get_family_class(radeon
) != EVERGREEN
) {
336 r
= r600_texture_from_depth(ctx
, rtex
, transfer
->sr
.level
);
340 r600_flush(ctx
, 0, NULL
);
341 bo
= rtex
->uncompressed
;
343 bo
= ((struct r600_resource
*)transfer
->resource
)->bo
;
345 offset
= rtransfer
->offset
+
346 transfer
->box
.y
/ util_format_get_blockheight(format
) * transfer
->stride
+
347 transfer
->box
.x
/ util_format_get_blockwidth(format
) * util_format_get_blocksize(format
);
349 map
= radeon_ws_bo_map(radeon
, bo
, 0, r600_context(ctx
));
357 void r600_texture_transfer_unmap(struct pipe_context
*ctx
,
358 struct pipe_transfer
* transfer
)
360 struct r600_transfer
*rtransfer
= (struct r600_transfer
*)transfer
;
361 struct radeon
*radeon
= (struct radeon
*)ctx
->screen
->winsys
;
362 struct r600_resource_texture
*rtex
;
363 struct radeon_ws_bo
*bo
;
365 if (rtransfer
->linear_texture
) {
366 bo
= ((struct r600_resource
*)rtransfer
->linear_texture
)->bo
;
368 rtex
= (struct r600_resource_texture
*)transfer
->resource
;
370 bo
= rtex
->uncompressed
;
372 bo
= ((struct r600_resource
*)transfer
->resource
)->bo
;
375 radeon_ws_bo_unmap(radeon
, bo
);
378 struct u_resource_vtbl r600_texture_vtbl
=
380 u_default_resource_get_handle
, /* get_handle */
381 r600_texture_destroy
, /* resource_destroy */
382 r600_texture_is_referenced
, /* is_resource_referenced */
383 r600_texture_get_transfer
, /* get_transfer */
384 r600_texture_transfer_destroy
, /* transfer_destroy */
385 r600_texture_transfer_map
, /* transfer_map */
386 u_default_transfer_flush_region
,/* transfer_flush_region */
387 r600_texture_transfer_unmap
, /* transfer_unmap */
388 u_default_transfer_inline_write
/* transfer_inline_write */
391 void r600_init_screen_texture_functions(struct pipe_screen
*screen
)
393 screen
->get_tex_surface
= r600_get_tex_surface
;
394 screen
->tex_surface_destroy
= r600_tex_surface_destroy
;
397 static unsigned r600_get_swizzle_combined(const unsigned char *swizzle_format
,
398 const unsigned char *swizzle_view
)
401 unsigned char swizzle
[4];
403 const uint32_t swizzle_shift
[4] = {
406 const uint32_t swizzle_bit
[4] = {
411 /* Combine two sets of swizzles. */
412 for (i
= 0; i
< 4; i
++) {
413 swizzle
[i
] = swizzle_view
[i
] <= UTIL_FORMAT_SWIZZLE_W
?
414 swizzle_format
[swizzle_view
[i
]] : swizzle_view
[i
];
417 memcpy(swizzle
, swizzle_format
, 4);
421 for (i
= 0; i
< 4; i
++) {
422 switch (swizzle
[i
]) {
423 case UTIL_FORMAT_SWIZZLE_Y
:
424 result
|= swizzle_bit
[1] << swizzle_shift
[i
];
426 case UTIL_FORMAT_SWIZZLE_Z
:
427 result
|= swizzle_bit
[2] << swizzle_shift
[i
];
429 case UTIL_FORMAT_SWIZZLE_W
:
430 result
|= swizzle_bit
[3] << swizzle_shift
[i
];
432 case UTIL_FORMAT_SWIZZLE_0
:
433 result
|= V_038010_SQ_SEL_0
<< swizzle_shift
[i
];
435 case UTIL_FORMAT_SWIZZLE_1
:
436 result
|= V_038010_SQ_SEL_1
<< swizzle_shift
[i
];
438 default: /* UTIL_FORMAT_SWIZZLE_X */
439 result
|= swizzle_bit
[0] << swizzle_shift
[i
];
445 /* texture format translate */
446 uint32_t r600_translate_texformat(enum pipe_format format
,
447 const unsigned char *swizzle_view
,
448 uint32_t *word4_p
, uint32_t *yuv_format_p
)
450 uint32_t result
= 0, word4
= 0, yuv_format
= 0;
451 const struct util_format_description
*desc
;
452 boolean uniform
= TRUE
;
454 const uint32_t sign_bit
[4] = {
455 S_038010_FORMAT_COMP_X(V_038010_SQ_FORMAT_COMP_SIGNED
),
456 S_038010_FORMAT_COMP_Y(V_038010_SQ_FORMAT_COMP_SIGNED
),
457 S_038010_FORMAT_COMP_Z(V_038010_SQ_FORMAT_COMP_SIGNED
),
458 S_038010_FORMAT_COMP_W(V_038010_SQ_FORMAT_COMP_SIGNED
)
460 desc
= util_format_description(format
);
462 word4
|= r600_get_swizzle_combined(desc
->swizzle
, swizzle_view
);
464 /* Colorspace (return non-RGB formats directly). */
465 switch (desc
->colorspace
) {
466 /* Depth stencil formats */
467 case UTIL_FORMAT_COLORSPACE_ZS
:
469 case PIPE_FORMAT_Z16_UNORM
:
470 result
= V_0280A0_COLOR_16
;
472 case PIPE_FORMAT_Z24X8_UNORM
:
473 case PIPE_FORMAT_Z24_UNORM_S8_USCALED
:
474 result
= V_0280A0_COLOR_8_24
;
476 case PIPE_FORMAT_X8Z24_UNORM
:
477 case PIPE_FORMAT_S8_USCALED_Z24_UNORM
:
478 result
= V_0280A0_COLOR_24_8
;
484 case UTIL_FORMAT_COLORSPACE_YUV
:
485 yuv_format
|= (1 << 30);
487 case PIPE_FORMAT_UYVY
:
488 case PIPE_FORMAT_YUYV
:
492 goto out_unknown
; /* TODO */
494 case UTIL_FORMAT_COLORSPACE_SRGB
:
495 word4
|= S_038010_FORCE_DEGAMMA(1);
496 if (format
== PIPE_FORMAT_L8A8_SRGB
|| format
== PIPE_FORMAT_L8_SRGB
)
497 goto out_unknown
; /* fails for some reason - TODO */
504 /* S3TC formats. TODO */
505 if (desc
->layout
== UTIL_FORMAT_LAYOUT_S3TC
) {
510 for (i
= 0; i
< desc
->nr_channels
; i
++) {
511 if (desc
->channel
[i
].type
== UTIL_FORMAT_TYPE_SIGNED
) {
512 word4
|= sign_bit
[i
];
516 /* R8G8Bx_SNORM - TODO CxV8U8 */
520 /* See whether the components are of the same size. */
521 for (i
= 1; i
< desc
->nr_channels
; i
++) {
522 uniform
= uniform
&& desc
->channel
[0].size
== desc
->channel
[i
].size
;
525 /* Non-uniform formats. */
527 switch(desc
->nr_channels
) {
529 if (desc
->channel
[0].size
== 5 &&
530 desc
->channel
[1].size
== 6 &&
531 desc
->channel
[2].size
== 5) {
532 result
= V_0280A0_COLOR_5_6_5
;
537 if (desc
->channel
[0].size
== 5 &&
538 desc
->channel
[1].size
== 5 &&
539 desc
->channel
[2].size
== 5 &&
540 desc
->channel
[3].size
== 1) {
541 result
= V_0280A0_COLOR_1_5_5_5
;
544 if (desc
->channel
[0].size
== 10 &&
545 desc
->channel
[1].size
== 10 &&
546 desc
->channel
[2].size
== 10 &&
547 desc
->channel
[3].size
== 2) {
548 result
= V_0280A0_COLOR_10_10_10_2
;
556 /* uniform formats */
557 switch (desc
->channel
[0].type
) {
558 case UTIL_FORMAT_TYPE_UNSIGNED
:
559 case UTIL_FORMAT_TYPE_SIGNED
:
560 if (!desc
->channel
[0].normalized
&&
561 desc
->colorspace
!= UTIL_FORMAT_COLORSPACE_SRGB
) {
565 switch (desc
->channel
[0].size
) {
567 switch (desc
->nr_channels
) {
569 result
= V_0280A0_COLOR_4_4
;
572 result
= V_0280A0_COLOR_4_4_4_4
;
577 switch (desc
->nr_channels
) {
579 result
= V_0280A0_COLOR_8
;
582 result
= V_0280A0_COLOR_8_8
;
585 result
= V_0280A0_COLOR_8_8_8_8
;
590 switch (desc
->nr_channels
) {
592 result
= V_0280A0_COLOR_16
;
595 result
= V_0280A0_COLOR_16_16
;
598 result
= V_0280A0_COLOR_16_16_16_16
;
604 case UTIL_FORMAT_TYPE_FLOAT
:
605 switch (desc
->channel
[0].size
) {
607 switch (desc
->nr_channels
) {
609 result
= V_0280A0_COLOR_16_FLOAT
;
612 result
= V_0280A0_COLOR_16_16_FLOAT
;
615 result
= V_0280A0_COLOR_16_16_16_16_FLOAT
;
620 switch (desc
->nr_channels
) {
622 result
= V_0280A0_COLOR_32_FLOAT
;
625 result
= V_0280A0_COLOR_32_32_FLOAT
;
628 result
= V_0280A0_COLOR_32_32_32_32_FLOAT
;
638 *yuv_format_p
= yuv_format
;
641 // R600_ERR("Unable to handle texformat %d %s\n", format, util_format_name(format));
645 int r600_texture_from_depth(struct pipe_context
*ctx
, struct r600_resource_texture
*rtexture
, unsigned level
)
647 struct r600_screen
*rscreen
= r600_screen(ctx
->screen
);
650 if (!rtexture
->depth
) {
651 /* This shouldn't happen maybe print a warning */
654 if (rtexture
->uncompressed
&& !rtexture
->dirty
) {
655 /* Uncompressed bo already in good state */
659 /* allocate uncompressed texture */
660 if (rtexture
->uncompressed
== NULL
) {
661 rtexture
->uncompressed
= radeon_ws_bo(rscreen
->rw
, rtexture
->size
, 4096, 0);
662 if (rtexture
->uncompressed
== NULL
) {
667 /* render a rectangle covering whole buffer to uncompress depth */
668 r
= r600_blit_uncompress_depth(ctx
, rtexture
, level
);
679 int r600_texture_scissor(struct pipe_context
*ctx
, struct r600_resource_texture
*rtexture
, unsigned level
)
681 struct r600_screen
*rscreen
= r600_screen(ctx
->screen
);
682 struct r600_context
*rctx
= r600_context(ctx
);
684 if (!rtexture
->scissor
[level
].cpm4
) {
685 rctx
->vtbl
->texture_state_scissor(rscreen
, rtexture
, level
);
690 int r600_texture_cb(struct pipe_context
*ctx
, struct r600_resource_texture
*rtexture
, unsigned cb
, unsigned level
)
692 struct r600_screen
*rscreen
= r600_screen(ctx
->screen
);
693 struct r600_context
*rctx
= r600_context(ctx
);
695 if (!rtexture
->cb
[cb
][level
].cpm4
) {
696 rctx
->vtbl
->texture_state_cb(rscreen
, rtexture
, cb
, level
);
701 int r600_texture_db(struct pipe_context
*ctx
, struct r600_resource_texture
*rtexture
, unsigned level
)
703 struct r600_screen
*rscreen
= r600_screen(ctx
->screen
);
704 struct r600_context
*rctx
= r600_context(ctx
);
706 if (!rtexture
->db
[level
].cpm4
) {
707 rctx
->vtbl
->texture_state_db(rscreen
, rtexture
, level
);
712 int r600_texture_viewport(struct pipe_context
*ctx
, struct r600_resource_texture
*rtexture
, unsigned level
)
714 struct r600_screen
*rscreen
= r600_screen(ctx
->screen
);
715 struct r600_context
*rctx
= r600_context(ctx
);
717 if (!rtexture
->viewport
[level
].cpm4
) {
718 rctx
->vtbl
->texture_state_viewport(rscreen
, rtexture
, level
);