2 * Copyright © 2017 Intel Corporation
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.
25 #include "pipe/p_defines.h"
26 #include "pipe/p_state.h"
27 #include "pipe/p_context.h"
28 #include "pipe/p_screen.h"
29 #include "util/u_inlines.h"
30 #include "util/u_format.h"
31 #include "util/u_upload_mgr.h"
32 #include "util/ralloc.h"
33 #include "iris_context.h"
34 #include "iris_resource.h"
35 #include "iris_screen.h"
36 #include "intel/compiler/brw_compiler.h"
39 * The pipe->clear() driver hook.
41 * This clears buffers attached to the current draw framebuffer.
44 iris_clear(struct pipe_context
*ctx
,
46 const union pipe_color_union
*p_color
,
50 struct iris_context
*ice
= (void *) ctx
;
51 struct pipe_framebuffer_state
*cso_fb
= &ice
->state
.framebuffer
;
54 struct iris_batch
*batch
= &ice
->render_batch
;
56 iris_batch_maybe_flush(batch
, 1500);
58 struct blorp_batch blorp_batch
;
59 blorp_batch_init(&ice
->blorp
, &blorp_batch
, batch
, 0);
61 if (buffers
& PIPE_CLEAR_DEPTHSTENCIL
) {
62 struct pipe_surface
*psurf
= cso_fb
->zsbuf
;
63 struct blorp_surf z_surf
;
64 const unsigned num_layers
=
65 psurf
->u
.tex
.last_layer
- psurf
->u
.tex
.first_layer
+ 1;
67 iris_blorp_surf_for_resource(&z_surf
, psurf
->texture
,
68 ISL_AUX_USAGE_NONE
, true);
70 blorp_clear_depth_stencil(&blorp_batch
, &z_surf
, NULL
/* XXX */,
71 psurf
->u
.tex
.level
, psurf
->u
.tex
.first_layer
,
72 num_layers
, 0, 0, psurf
->width
, psurf
->height
,
73 (buffers
& PIPE_CLEAR_DEPTH
) != 0,
74 depth
, 0 /* XXX */, stencil
);
76 if (buffers
& PIPE_CLEAR_STENCIL
)
77 fprintf(stderr
, "XXX: stencil clears not implemented\n");
80 if (buffers
& PIPE_CLEAR_COLOR
) {
81 /* pipe_color_union and isl_color_value are interchangeable */
82 union isl_color_value
*clear_color
= (void *) p_color
;
83 bool color_write_disable
[4] = { false, false, false, false };
85 for (unsigned i
= 0; i
< cso_fb
->nr_cbufs
; i
++) {
86 if (buffers
& (PIPE_CLEAR_COLOR0
<< i
)) {
87 struct pipe_surface
*psurf
= cso_fb
->cbufs
[i
];
88 struct iris_surface
*isurf
= (void *) psurf
;
89 struct blorp_surf surf
;
91 iris_blorp_surf_for_resource(&surf
, psurf
->texture
,
92 ISL_AUX_USAGE_NONE
, true);
94 blorp_clear(&blorp_batch
, &surf
, isurf
->view
.format
,
96 psurf
->u
.tex
.level
, psurf
->u
.tex
.first_layer
,
97 psurf
->u
.tex
.last_layer
- psurf
->u
.tex
.first_layer
+ 1,
98 0, 0, psurf
->width
, psurf
->height
,
99 *clear_color
, color_write_disable
);
104 blorp_batch_finish(&blorp_batch
);
108 iris_clear_render_target(struct pipe_context
*ctx
,
109 struct pipe_surface
*dst
,
110 const union pipe_color_union
*color
,
111 unsigned dst_x
, unsigned dst_y
,
112 unsigned width
, unsigned height
,
113 bool render_condition_enabled
)
115 fprintf(stderr
, "XXX: iris_clear_render_target\n");
119 iris_clear_depth_stencil(struct pipe_context
*ctx
,
120 struct pipe_surface
*dst
,
121 unsigned clear_flags
,
124 unsigned dst_x
, unsigned dst_y
,
125 unsigned width
, unsigned height
,
126 bool render_condition_enabled
)
128 fprintf(stderr
, "XXX: iris_clear_depth_stencil\n");
132 iris_init_clear_functions(struct pipe_context
*ctx
)
134 ctx
->clear
= iris_clear
;
135 ctx
->clear_render_target
= iris_clear_render_target
;
136 ctx
->clear_depth_stencil
= iris_clear_depth_stencil
;