e84be3862217da6e18c37a74c8572a23978c0a1c
2 * Copyright (C) 2008-2009 Advanced Micro Devices, Inc.
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 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
18 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 * Richard Li <RichardZ.Li@amd.com>, <richardradeon@gmail.com>
25 * CooperYuan <cooper.yuan@amd.com>, <cooperyuan@gmail.com>
28 #include "main/glheader.h"
29 #include "main/context.h"
30 #include "main/macros.h"
31 #include "main/imports.h"
32 #include "main/mtypes.h"
33 #include "main/enums.h"
35 #include "radeon_lock.h"
36 #include "r600_context.h"
38 #include "r700_shaderinst.h"
39 #include "r600_emit.h"
40 #include "r700_clear.h"
42 static GLboolean
r700ClearFast(context_t
*context
, GLbitfield mask
)
44 /* TODO, fast clear need implementation */
48 #define R600_NEWPRIM( rmesa ) \
50 if ( rmesa->radeon.dma.flush ) \
51 rmesa->radeon.dma.flush( rmesa->radeon.glCtx ); \
54 void r700Clear(GLcontext
* ctx
, GLbitfield mask
)
56 context_t
*context
= R700_CONTEXT(ctx
);
57 __DRIdrawablePrivate
*dPriv
= radeon_get_drawable(&context
->radeon
);
58 const GLuint colorMask
= *((GLuint
*) & ctx
->Color
.ColorMask
);
59 GLbitfield swrast_mask
= 0, tri_mask
= 0;
61 struct gl_framebuffer
*fb
= ctx
->DrawBuffer
;
63 if( GL_TRUE
== r700ClearFast(context
, mask
) )
67 if (!context
->radeon
.radeonScreen
->driScreen
->dri2
.enabled
) {
68 LOCK_HARDWARE(&context
->radeon
);
69 UNLOCK_HARDWARE(&context
->radeon
);
70 if (dPriv
->numClipRects
== 0)
74 R600_NEWPRIM(context
);
77 tri_mask
|= (mask
& BUFFER_BITS_COLOR
);
79 tri_mask
|= (mask
& (BUFFER_BIT_FRONT_LEFT
| BUFFER_BIT_BACK_LEFT
));
83 if (mask
& BUFFER_BIT_STENCIL
) {
84 tri_mask
|= BUFFER_BIT_STENCIL
;
88 if (mask
& BUFFER_BIT_DEPTH
) {
89 tri_mask
|= BUFFER_BIT_DEPTH
;
92 /* If we're doing a tri pass for depth/stencil, include a likely color
96 for (i
= 0; i
< BUFFER_COUNT
; i
++) {
97 GLuint bufBit
= 1 << i
;
98 if ((tri_mask
) & bufBit
) {
99 if (!fb
->Attachment
[i
].Renderbuffer
->ClassID
) {
101 swrast_mask
|= bufBit
;
106 /* SW fallback clearing */
107 swrast_mask
= mask
& ~tri_mask
;
110 radeonUserClear(ctx
, tri_mask
);
114 if (RADEON_DEBUG
& DEBUG_FALLBACKS
)
115 fprintf(stderr
, "%s: swrast clear, mask: %x\n",
116 __FUNCTION__
, swrast_mask
);
117 _swrast_Clear(ctx
, swrast_mask
);