2 Copyright (C) Intel Corp. 2006. All Rights Reserved.
3 Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
4 develop this 3D driver.
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files (the
8 "Software"), to deal in the Software without restriction, including
9 without limitation the rights to use, copy, modify, merge, publish,
10 distribute, sublicense, and/or sell copies of the Software, and to
11 permit persons to whom the Software is furnished to do so, subject to
12 the following conditions:
14 The above copyright notice and this permission notice (including the
15 next paragraph) shall be included in all copies or substantial
16 portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
22 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **********************************************************************/
29 * Keith Whitwell <keith@tungstengraphics.com>
33 #include "main/mtypes.h"
34 #include "main/texstore.h"
35 #include "program/prog_parameter.h"
37 #include "intel_mipmap_tree.h"
38 #include "intel_batchbuffer.h"
39 #include "intel_tex.h"
40 #include "intel_fbo.h"
42 #include "brw_context.h"
43 #include "brw_state.h"
44 #include "brw_defines.h"
47 static GLuint
translate_tex_target( GLenum target
)
51 return BRW_SURFACE_1D
;
53 case GL_TEXTURE_RECTANGLE_NV
:
54 return BRW_SURFACE_2D
;
57 return BRW_SURFACE_2D
;
60 return BRW_SURFACE_3D
;
62 case GL_TEXTURE_CUBE_MAP
:
63 return BRW_SURFACE_CUBE
;
72 static GLuint
translate_tex_format( gl_format mesa_format
,
73 GLenum internal_format
,
76 switch( mesa_format
) {
78 return BRW_SURFACEFORMAT_L8_UNORM
;
81 return BRW_SURFACEFORMAT_I8_UNORM
;
84 return BRW_SURFACEFORMAT_A8_UNORM
;
86 case MESA_FORMAT_AL88
:
87 return BRW_SURFACEFORMAT_L8A8_UNORM
;
89 case MESA_FORMAT_AL1616
:
90 return BRW_SURFACEFORMAT_L16A16_UNORM
;
92 case MESA_FORMAT_RGB888
:
93 assert(0); /* not supported for sampling */
94 return BRW_SURFACEFORMAT_R8G8B8_UNORM
;
96 case MESA_FORMAT_ARGB8888
:
97 return BRW_SURFACEFORMAT_B8G8R8A8_UNORM
;
99 case MESA_FORMAT_XRGB8888
:
100 return BRW_SURFACEFORMAT_B8G8R8X8_UNORM
;
102 case MESA_FORMAT_RGBA8888_REV
:
103 _mesa_problem(NULL
, "unexpected format in i965:translate_tex_format()");
104 return BRW_SURFACEFORMAT_R8G8B8A8_UNORM
;
106 case MESA_FORMAT_RGB565
:
107 return BRW_SURFACEFORMAT_B5G6R5_UNORM
;
109 case MESA_FORMAT_ARGB1555
:
110 return BRW_SURFACEFORMAT_B5G5R5A1_UNORM
;
112 case MESA_FORMAT_ARGB4444
:
113 return BRW_SURFACEFORMAT_B4G4R4A4_UNORM
;
115 case MESA_FORMAT_YCBCR_REV
:
116 return BRW_SURFACEFORMAT_YCRCB_NORMAL
;
118 case MESA_FORMAT_YCBCR
:
119 return BRW_SURFACEFORMAT_YCRCB_SWAPUVY
;
121 case MESA_FORMAT_RGB_FXT1
:
122 case MESA_FORMAT_RGBA_FXT1
:
123 return BRW_SURFACEFORMAT_FXT1
;
125 case MESA_FORMAT_Z16
:
126 if (depth_mode
== GL_INTENSITY
)
127 return BRW_SURFACEFORMAT_I16_UNORM
;
128 else if (depth_mode
== GL_ALPHA
)
129 return BRW_SURFACEFORMAT_A16_UNORM
;
131 return BRW_SURFACEFORMAT_L16_UNORM
;
133 case MESA_FORMAT_RGB_DXT1
:
134 return BRW_SURFACEFORMAT_DXT1_RGB
;
136 case MESA_FORMAT_RGBA_DXT1
:
137 return BRW_SURFACEFORMAT_BC1_UNORM
;
139 case MESA_FORMAT_RGBA_DXT3
:
140 return BRW_SURFACEFORMAT_BC2_UNORM
;
142 case MESA_FORMAT_RGBA_DXT5
:
143 return BRW_SURFACEFORMAT_BC3_UNORM
;
145 case MESA_FORMAT_SARGB8
:
146 return BRW_SURFACEFORMAT_B8G8R8A8_UNORM_SRGB
;
148 case MESA_FORMAT_SLA8
:
149 return BRW_SURFACEFORMAT_L8A8_UNORM_SRGB
;
151 case MESA_FORMAT_SL8
:
152 return BRW_SURFACEFORMAT_L8_UNORM_SRGB
;
154 case MESA_FORMAT_SRGB_DXT1
:
155 return BRW_SURFACEFORMAT_BC1_UNORM_SRGB
;
157 case MESA_FORMAT_S8_Z24
:
158 /* XXX: these different surface formats don't seem to
159 * make any difference for shadow sampler/compares.
161 if (depth_mode
== GL_INTENSITY
)
162 return BRW_SURFACEFORMAT_I24X8_UNORM
;
163 else if (depth_mode
== GL_ALPHA
)
164 return BRW_SURFACEFORMAT_A24X8_UNORM
;
166 return BRW_SURFACEFORMAT_L24X8_UNORM
;
168 case MESA_FORMAT_DUDV8
:
169 return BRW_SURFACEFORMAT_R8G8_SNORM
;
171 case MESA_FORMAT_SIGNED_RGBA8888_REV
:
172 return BRW_SURFACEFORMAT_R8G8B8A8_SNORM
;
181 brw_set_surface_tiling(struct brw_surface_state
*surf
, uint32_t tiling
)
184 case I915_TILING_NONE
:
185 surf
->ss3
.tiled_surface
= 0;
186 surf
->ss3
.tile_walk
= 0;
189 surf
->ss3
.tiled_surface
= 1;
190 surf
->ss3
.tile_walk
= BRW_TILEWALK_XMAJOR
;
193 surf
->ss3
.tiled_surface
= 1;
194 surf
->ss3
.tile_walk
= BRW_TILEWALK_YMAJOR
;
200 brw_update_texture_surface( GLcontext
*ctx
, GLuint unit
)
202 struct brw_context
*brw
= brw_context(ctx
);
203 struct gl_texture_object
*tObj
= ctx
->Texture
.Unit
[unit
]._Current
;
204 struct intel_texture_object
*intelObj
= intel_texture_object(tObj
);
205 struct gl_texture_image
*firstImage
= tObj
->Image
[0][intelObj
->firstLevel
];
206 const GLuint surf_index
= SURF_INDEX_TEXTURE(unit
);
207 struct brw_surface_state surf
;
210 memset(&surf
, 0, sizeof(surf
));
212 surf
.ss0
.mipmap_layout_mode
= BRW_SURFACE_MIPMAPLAYOUT_BELOW
;
213 surf
.ss0
.surface_type
= translate_tex_target(tObj
->Target
);
214 surf
.ss0
.surface_format
= translate_tex_format(firstImage
->TexFormat
,
215 firstImage
->InternalFormat
,
218 /* This is ok for all textures with channel width 8bit or less:
220 /* surf.ss0.data_return_format = BRW_SURFACERETURNFORMAT_S1; */
221 surf
.ss1
.base_addr
= intelObj
->mt
->region
->buffer
->offset
; /* reloc */
223 surf
.ss2
.mip_count
= intelObj
->lastLevel
- intelObj
->firstLevel
;
224 surf
.ss2
.width
= firstImage
->Width
- 1;
225 surf
.ss2
.height
= firstImage
->Height
- 1;
226 brw_set_surface_tiling(&surf
, intelObj
->mt
->region
->tiling
);
227 surf
.ss3
.pitch
= (intelObj
->mt
->region
->pitch
* intelObj
->mt
->cpp
) - 1;
228 surf
.ss3
.depth
= firstImage
->Depth
- 1;
230 surf
.ss4
.min_lod
= 0;
232 if (tObj
->Target
== GL_TEXTURE_CUBE_MAP
) {
233 surf
.ss0
.cube_pos_x
= 1;
234 surf
.ss0
.cube_pos_y
= 1;
235 surf
.ss0
.cube_pos_z
= 1;
236 surf
.ss0
.cube_neg_x
= 1;
237 surf
.ss0
.cube_neg_y
= 1;
238 surf
.ss0
.cube_neg_z
= 1;
241 map
= brw_state_batch(brw
, sizeof(surf
), 32,
242 &brw
->wm
.surf_bo
[surf_index
],
243 &brw
->wm
.surf_offset
[surf_index
]);
244 memcpy(map
, &surf
, sizeof(surf
));
246 /* Emit relocation to surface contents */
247 drm_intel_bo_emit_reloc(brw
->wm
.surf_bo
[surf_index
],
248 brw
->wm
.surf_offset
[surf_index
] +
249 offsetof(struct brw_surface_state
, ss1
),
250 intelObj
->mt
->region
->buffer
, 0,
251 I915_GEM_DOMAIN_SAMPLER
, 0);
255 * Create the constant buffer surface. Vertex/fragment shader constants will be
256 * read from this buffer with Data Port Read instructions/messages.
259 brw_create_constant_surface(struct brw_context
*brw
,
262 drm_intel_bo
**out_bo
,
263 uint32_t *out_offset
)
265 const GLint w
= width
- 1;
266 struct brw_surface_state surf
;
269 memset(&surf
, 0, sizeof(surf
));
271 surf
.ss0
.mipmap_layout_mode
= BRW_SURFACE_MIPMAPLAYOUT_BELOW
;
272 surf
.ss0
.surface_type
= BRW_SURFACE_BUFFER
;
273 surf
.ss0
.surface_format
= BRW_SURFACEFORMAT_R32G32B32A32_FLOAT
;
276 surf
.ss1
.base_addr
= bo
->offset
; /* reloc */
278 surf
.ss2
.width
= w
& 0x7f; /* bits 6:0 of size or width */
279 surf
.ss2
.height
= (w
>> 7) & 0x1fff; /* bits 19:7 of size or width */
280 surf
.ss3
.depth
= (w
>> 20) & 0x7f; /* bits 26:20 of size or width */
281 surf
.ss3
.pitch
= (width
* 16) - 1; /* ignored?? */
282 brw_set_surface_tiling(&surf
, I915_TILING_NONE
); /* tiling now allowed */
284 map
= brw_state_batch(brw
, sizeof(surf
), 32, out_bo
, out_offset
);
285 memcpy(map
, &surf
, sizeof(surf
));
287 /* Emit relocation to surface contents. Section 5.1.1 of the gen4
288 * bspec ("Data Cache") says that the data cache does not exist as
289 * a separate cache and is just the sampler cache.
291 drm_intel_bo_emit_reloc(*out_bo
, (*out_offset
+
292 offsetof(struct brw_surface_state
, ss1
)),
294 I915_GEM_DOMAIN_SAMPLER
, 0);
297 /* Creates a new WM constant buffer reflecting the current fragment program's
298 * constants, if needed by the fragment program.
300 * Otherwise, constants go through the CURBEs using the brw_constant_buffer
304 prepare_wm_constants(struct brw_context
*brw
)
306 GLcontext
*ctx
= &brw
->intel
.ctx
;
307 struct intel_context
*intel
= &brw
->intel
;
308 struct brw_fragment_program
*fp
=
309 (struct brw_fragment_program
*) brw
->fragment_program
;
310 const struct gl_program_parameter_list
*params
= fp
->program
.Base
.Parameters
;
311 const int size
= params
->NumParameters
* 4 * sizeof(GLfloat
);
313 _mesa_load_state_parameters(ctx
, fp
->program
.Base
.Parameters
);
315 /* BRW_NEW_FRAGMENT_PROGRAM */
316 if (!fp
->use_const_buffer
) {
317 if (brw
->wm
.const_bo
) {
318 drm_intel_bo_unreference(brw
->wm
.const_bo
);
319 brw
->wm
.const_bo
= NULL
;
320 brw
->state
.dirty
.brw
|= BRW_NEW_WM_CONSTBUF
;
325 drm_intel_bo_unreference(brw
->wm
.const_bo
);
326 brw
->wm
.const_bo
= drm_intel_bo_alloc(intel
->bufmgr
, "vp_const_buffer",
329 /* _NEW_PROGRAM_CONSTANTS */
330 drm_intel_bo_subdata(brw
->wm
.const_bo
, 0, size
, params
->ParameterValues
);
333 const struct brw_tracked_state brw_wm_constants
= {
335 .mesa
= (_NEW_PROGRAM_CONSTANTS
),
336 .brw
= (BRW_NEW_FRAGMENT_PROGRAM
),
339 .prepare
= prepare_wm_constants
,
343 * Updates surface / buffer for fragment shader constant buffer, if
346 * This consumes the state updates for the constant buffer, and produces
347 * BRW_NEW_WM_SURFACES to get picked up by brw_prepare_wm_surfaces for
348 * inclusion in the binding table.
350 static void upload_wm_constant_surface(struct brw_context
*brw
)
352 GLuint surf
= SURF_INDEX_FRAG_CONST_BUFFER
;
353 struct brw_fragment_program
*fp
=
354 (struct brw_fragment_program
*) brw
->fragment_program
;
355 const struct gl_program_parameter_list
*params
=
356 fp
->program
.Base
.Parameters
;
358 /* If there's no constant buffer, then no surface BO is needed to point at
361 if (brw
->wm
.const_bo
== 0) {
362 if (brw
->wm
.surf_bo
[surf
] != NULL
) {
363 drm_intel_bo_unreference(brw
->wm
.surf_bo
[surf
]);
364 brw
->wm
.surf_bo
[surf
] = NULL
;
365 brw
->state
.dirty
.brw
|= BRW_NEW_WM_SURFACES
;
370 brw_create_constant_surface(brw
, brw
->wm
.const_bo
, params
->NumParameters
,
371 &brw
->wm
.surf_bo
[surf
],
372 &brw
->wm
.surf_offset
[surf
]);
373 brw
->state
.dirty
.brw
|= BRW_NEW_WM_SURFACES
;
376 const struct brw_tracked_state brw_wm_constant_surface
= {
379 .brw
= (BRW_NEW_WM_CONSTBUF
|
383 .emit
= upload_wm_constant_surface
,
388 * Sets up a surface state structure to point at the given region.
389 * While it is only used for the front/back buffer currently, it should be
390 * usable for further buffers when doing ARB_draw_buffer support.
393 brw_update_renderbuffer_surface(struct brw_context
*brw
,
394 struct gl_renderbuffer
*rb
,
397 struct intel_context
*intel
= &brw
->intel
;
398 GLcontext
*ctx
= &intel
->ctx
;
399 drm_intel_bo
*region_bo
= NULL
;
400 struct intel_renderbuffer
*irb
= intel_renderbuffer(rb
);
401 struct intel_region
*region
= irb
? irb
->region
: NULL
;
403 unsigned int surface_type
;
404 unsigned int surface_format
;
405 unsigned int width
, height
, pitch
, cpp
;
406 GLubyte color_mask
[4];
407 GLboolean color_blend
;
412 struct brw_surface_state surf
;
415 memset(&key
, 0, sizeof(key
));
417 if (region
!= NULL
) {
418 region_bo
= region
->buffer
;
420 key
.surface_type
= BRW_SURFACE_2D
;
421 switch (irb
->Base
.Format
) {
422 /* XRGB and ARGB are treated the same here because the chips in this
423 * family cannot render to XRGB targets. This means that we have to
424 * mask writes to alpha (ala glColorMask) and reconfigure the alpha
425 * blending hardware to use GL_ONE (or GL_ZERO) for cases where
426 * GL_DST_ALPHA (or GL_ONE_MINUS_DST_ALPHA) is used.
428 case MESA_FORMAT_ARGB8888
:
429 case MESA_FORMAT_XRGB8888
:
430 key
.surface_format
= BRW_SURFACEFORMAT_B8G8R8A8_UNORM
;
432 case MESA_FORMAT_RGB565
:
433 key
.surface_format
= BRW_SURFACEFORMAT_B5G6R5_UNORM
;
435 case MESA_FORMAT_ARGB1555
:
436 key
.surface_format
= BRW_SURFACEFORMAT_B5G5R5A1_UNORM
;
438 case MESA_FORMAT_ARGB4444
:
439 key
.surface_format
= BRW_SURFACEFORMAT_B4G4R4A4_UNORM
;
442 key
.surface_format
= BRW_SURFACEFORMAT_A8_UNORM
;
445 _mesa_problem(ctx
, "Bad renderbuffer format: %d\n", irb
->Base
.Format
);
447 key
.tiling
= region
->tiling
;
448 key
.width
= rb
->Width
;
449 key
.height
= rb
->Height
;
450 key
.pitch
= region
->pitch
;
451 key
.cpp
= region
->cpp
;
452 key
.draw_x
= region
->draw_x
;
453 key
.draw_y
= region
->draw_y
;
455 key
.surface_type
= BRW_SURFACE_NULL
;
456 key
.surface_format
= BRW_SURFACEFORMAT_B8G8R8A8_UNORM
;
457 key
.tiling
= I915_TILING_X
;
465 if (intel
->gen
< 6) {
467 memcpy(key
.color_mask
, ctx
->Color
.ColorMask
[unit
],
468 sizeof(key
.color_mask
));
470 /* As mentioned above, disable writes to the alpha component when the
471 * renderbuffer is XRGB.
473 if (ctx
->DrawBuffer
->Visual
.alphaBits
== 0)
474 key
.color_mask
[3] = GL_FALSE
;
476 key
.color_blend
= (!ctx
->Color
._LogicOpEnabled
&&
477 (ctx
->Color
.BlendEnabled
& (1 << unit
)));
480 memset(&surf
, 0, sizeof(surf
));
482 surf
.ss0
.surface_format
= key
.surface_format
;
483 surf
.ss0
.surface_type
= key
.surface_type
;
484 if (key
.tiling
== I915_TILING_NONE
) {
485 surf
.ss1
.base_addr
= (key
.draw_x
+ key
.draw_y
* key
.pitch
) * key
.cpp
;
487 uint32_t tile_base
, tile_x
, tile_y
;
488 uint32_t pitch
= key
.pitch
* key
.cpp
;
490 if (key
.tiling
== I915_TILING_X
) {
491 tile_x
= key
.draw_x
% (512 / key
.cpp
);
492 tile_y
= key
.draw_y
% 8;
493 tile_base
= ((key
.draw_y
/ 8) * (8 * pitch
));
494 tile_base
+= (key
.draw_x
- tile_x
) / (512 / key
.cpp
) * 4096;
497 tile_x
= key
.draw_x
% (128 / key
.cpp
);
498 tile_y
= key
.draw_y
% 32;
499 tile_base
= ((key
.draw_y
/ 32) * (32 * pitch
));
500 tile_base
+= (key
.draw_x
- tile_x
) / (128 / key
.cpp
) * 4096;
502 assert(brw
->has_surface_tile_offset
|| (tile_x
== 0 && tile_y
== 0));
503 assert(tile_x
% 4 == 0);
504 assert(tile_y
% 2 == 0);
505 /* Note that the low bits of these fields are missing, so
506 * there's the possibility of getting in trouble.
508 surf
.ss1
.base_addr
= tile_base
;
509 surf
.ss5
.x_offset
= tile_x
/ 4;
510 surf
.ss5
.y_offset
= tile_y
/ 2;
512 if (region_bo
!= NULL
)
513 surf
.ss1
.base_addr
+= region_bo
->offset
; /* reloc */
515 surf
.ss2
.width
= key
.width
- 1;
516 surf
.ss2
.height
= key
.height
- 1;
517 brw_set_surface_tiling(&surf
, key
.tiling
);
518 surf
.ss3
.pitch
= (key
.pitch
* key
.cpp
) - 1;
520 if (intel
->gen
< 6) {
522 surf
.ss0
.color_blend
= key
.color_blend
;
523 surf
.ss0
.writedisable_red
= !key
.color_mask
[0];
524 surf
.ss0
.writedisable_green
= !key
.color_mask
[1];
525 surf
.ss0
.writedisable_blue
= !key
.color_mask
[2];
526 surf
.ss0
.writedisable_alpha
= !key
.color_mask
[3];
529 map
= brw_state_batch(brw
, sizeof(surf
), 32,
530 &brw
->wm
.surf_bo
[unit
],
531 &brw
->wm
.surf_offset
[unit
]);
532 memcpy(map
, &surf
, sizeof(surf
));
534 if (region_bo
!= NULL
) {
535 drm_intel_bo_emit_reloc(brw
->wm
.surf_bo
[unit
],
536 brw
->wm
.surf_offset
[unit
] +
537 offsetof(struct brw_surface_state
, ss1
),
539 surf
.ss1
.base_addr
- region_bo
->offset
,
540 I915_GEM_DOMAIN_RENDER
,
541 I915_GEM_DOMAIN_RENDER
);
546 prepare_wm_surfaces(struct brw_context
*brw
)
548 GLcontext
*ctx
= &brw
->intel
.ctx
;
552 if (ctx
->DrawBuffer
->_NumColorDrawBuffers
>= 1) {
553 for (i
= 0; i
< ctx
->DrawBuffer
->_NumColorDrawBuffers
; i
++) {
554 struct gl_renderbuffer
*rb
= ctx
->DrawBuffer
->_ColorDrawBuffers
[i
];
555 struct intel_renderbuffer
*irb
= intel_renderbuffer(rb
);
556 struct intel_region
*region
= irb
? irb
->region
: NULL
;
558 brw_add_validated_bo(brw
, region
->buffer
);
559 nr_surfaces
= SURF_INDEX_DRAW(i
) + 1;
563 if (brw
->wm
.const_bo
) {
564 brw_add_validated_bo(brw
, brw
->wm
.const_bo
);
565 nr_surfaces
= SURF_INDEX_FRAG_CONST_BUFFER
+ 1;
568 for (i
= 0; i
< BRW_MAX_TEX_UNIT
; i
++) {
569 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[i
];
570 struct gl_texture_object
*tObj
= texUnit
->_Current
;
571 struct intel_texture_object
*intelObj
= intel_texture_object(tObj
);
573 if (texUnit
->_ReallyEnabled
) {
574 brw_add_validated_bo(brw
, intelObj
->mt
->region
->buffer
);
575 nr_surfaces
= SURF_INDEX_TEXTURE(i
) + 1;
579 /* Have to update this in our prepare, since the unit's prepare
582 if (brw
->wm
.nr_surfaces
!= nr_surfaces
) {
583 brw
->wm
.nr_surfaces
= nr_surfaces
;
584 brw
->state
.dirty
.brw
|= BRW_NEW_NR_WM_SURFACES
;
589 * Constructs the set of surface state objects pointed to by the
593 upload_wm_surfaces(struct brw_context
*brw
)
595 GLcontext
*ctx
= &brw
->intel
.ctx
;
598 /* _NEW_BUFFERS | _NEW_COLOR */
599 /* Update surfaces for drawing buffers */
600 if (ctx
->DrawBuffer
->_NumColorDrawBuffers
>= 1) {
601 for (i
= 0; i
< ctx
->DrawBuffer
->_NumColorDrawBuffers
; i
++) {
602 brw_update_renderbuffer_surface(brw
,
603 ctx
->DrawBuffer
->_ColorDrawBuffers
[i
],
607 brw_update_renderbuffer_surface(brw
, NULL
, 0);
610 /* Update surfaces for textures */
611 for (i
= 0; i
< BRW_MAX_TEX_UNIT
; i
++) {
612 const struct gl_texture_unit
*texUnit
= &ctx
->Texture
.Unit
[i
];
613 const GLuint surf
= SURF_INDEX_TEXTURE(i
);
616 if (texUnit
->_ReallyEnabled
) {
617 brw_update_texture_surface(ctx
, i
);
619 drm_intel_bo_unreference(brw
->wm
.surf_bo
[surf
]);
620 brw
->wm
.surf_bo
[surf
] = NULL
;
624 brw
->state
.dirty
.brw
|= BRW_NEW_WM_SURFACES
;
627 const struct brw_tracked_state brw_wm_surfaces
= {
629 .mesa
= (_NEW_COLOR
|
632 .brw
= (BRW_NEW_BATCH
),
635 .prepare
= prepare_wm_surfaces
,
636 .emit
= upload_wm_surfaces
,
640 * Constructs the binding table for the WM surface state, which maps unit
641 * numbers to surface state objects.
644 brw_wm_upload_binding_table(struct brw_context
*brw
)
649 /* Might want to calculate nr_surfaces first, to avoid taking up so much
650 * space for the binding table.
652 bind
= brw_state_batch(brw
, sizeof(uint32_t) * BRW_WM_MAX_SURF
,
653 32, &brw
->wm
.bind_bo
, &brw
->wm
.bind_bo_offset
);
655 for (i
= 0; i
< BRW_WM_MAX_SURF
; i
++) {
656 /* BRW_NEW_WM_SURFACES */
657 bind
[i
] = brw
->wm
.surf_offset
[i
];
658 if (brw
->wm
.surf_bo
[i
]) {
659 bind
[i
] = brw
->wm
.surf_offset
[i
];
665 brw
->state
.dirty
.brw
|= BRW_NEW_BINDING_TABLE
;
668 const struct brw_tracked_state brw_wm_binding_table
= {
671 .brw
= (BRW_NEW_BATCH
|
672 BRW_NEW_WM_SURFACES
),
675 .emit
= brw_wm_upload_binding_table
,