1 /**************************************************************************
3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * Copyright 2009, 2012 Intel Corporation.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the
9 * "Software"), to deal in the Software without restriction, including
10 * without limitation the rights to use, copy, modify, merge, publish,
11 * distribute, sub license, and/or sell copies of the Software, and to
12 * permit persons to whom the Software is furnished to do so, subject to
13 * the following conditions:
15 * The above copyright notice and this permission notice (including the
16 * next paragraph) shall be included in all copies or substantial portions
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
22 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
23 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 **************************************************************************/
29 #include "main/glheader.h"
30 #include "main/mtypes.h"
31 #include "main/condrender.h"
32 #include "swrast/swrast.h"
33 #include "drivers/common/meta.h"
35 #include "intel_context.h"
36 #include "intel_blit.h"
37 #include "intel_clear.h"
38 #include "intel_fbo.h"
39 #include "intel_regions.h"
41 #define FILE_DEBUG_FLAG DEBUG_BLIT
43 static const char *buffer_names
[] = {
44 [BUFFER_FRONT_LEFT
] = "front",
45 [BUFFER_BACK_LEFT
] = "back",
46 [BUFFER_FRONT_RIGHT
] = "front right",
47 [BUFFER_BACK_RIGHT
] = "back right",
48 [BUFFER_DEPTH
] = "depth",
49 [BUFFER_STENCIL
] = "stencil",
50 [BUFFER_ACCUM
] = "accum",
51 [BUFFER_AUX0
] = "aux0",
52 [BUFFER_COLOR0
] = "color0",
53 [BUFFER_COLOR1
] = "color1",
54 [BUFFER_COLOR2
] = "color2",
55 [BUFFER_COLOR3
] = "color3",
56 [BUFFER_COLOR4
] = "color4",
57 [BUFFER_COLOR5
] = "color5",
58 [BUFFER_COLOR6
] = "color6",
59 [BUFFER_COLOR7
] = "color7",
63 debug_mask(const char *name
, GLbitfield mask
)
67 if (unlikely(INTEL_DEBUG
& DEBUG_BLIT
)) {
68 DBG("%s clear:", name
);
69 for (i
= 0; i
< BUFFER_COUNT
; i
++) {
71 DBG(" %s", buffer_names
[i
]);
78 * Called by ctx->Driver.Clear.
81 intelClear(struct gl_context
*ctx
, GLbitfield mask
)
83 struct intel_context
*intel
= intel_context(ctx
);
85 if (!_mesa_check_conditional_render(ctx
))
88 if (mask
& (BUFFER_BIT_FRONT_LEFT
| BUFFER_BIT_FRONT_RIGHT
)) {
89 intel
->front_buffer_dirty
= true;
92 GLbitfield tri_mask
= mask
& (BUFFER_BITS_COLOR
|
97 debug_mask("tri", tri_mask
);
99 _mesa_meta_glsl_Clear(&intel
->ctx
, tri_mask
);
102 /* Any strange buffers get passed off to swrast */
104 debug_mask("swrast", mask
);
105 _swrast_Clear(ctx
, mask
);
111 intelInitClearFuncs(struct dd_function_table
*functions
)
113 functions
->Clear
= intelClear
;