get rid of chip_object struct
[mesa.git] / src / mesa / drivers / dri / r600 / r700_clear.c
1 /*
2 * Copyright (C) 2008-2009 Advanced Micro Devices, Inc.
3 *
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:
10 *
11 * The above copyright notice and this permission notice shall be included
12 * in all copies or substantial portions of the Software.
13 *
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.
20 */
21
22 /*
23 * Authors:
24 * Richard Li <RichardZ.Li@amd.com>, <richardradeon@gmail.com>
25 * CooperYuan <cooper.yuan@amd.com>, <cooperyuan@gmail.com>
26 */
27
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"
34
35 #include "r600_context.h"
36
37 #include "r700_shaderinst.h"
38 #include "r600_emit.h"
39
40 static GLboolean r700ClearFast(context_t *context, GLbitfield mask)
41 {
42 /* TODO, fast clear need implementation */
43 return GL_FALSE;
44 }
45
46 static void r700UserClear(GLcontext *ctx, GLuint mask)
47 {
48 radeon_clear_tris(ctx, mask);
49 }
50
51 #define R600_NEWPRIM( rmesa ) \
52 do { \
53 if ( rmesa->radeon.dma.flush ) \
54 rmesa->radeon.dma.flush( rmesa->radeon.glCtx ); \
55 } while (0)
56
57 void r700Clear(GLcontext * ctx, GLbitfield mask)
58 {
59 context_t *context = R700_CONTEXT(ctx);
60 __DRIdrawablePrivate *dPriv = context->radeon.dri.drawable;
61 const GLuint colorMask = *((GLuint *) & ctx->Color.ColorMask);
62 GLbitfield swrast_mask = 0, tri_mask = 0;
63 int i;
64 struct gl_framebuffer *fb = ctx->DrawBuffer;
65
66 if( GL_TRUE == r700ClearFast(context, mask) )
67 {
68 return;
69 }
70
71 #if 0
72 if (!context->radeon.radeonScreen->driScreen->dri2.enabled) {
73 LOCK_HARDWARE(&context->radeon);
74 UNLOCK_HARDWARE(&context->radeon);
75 if (dPriv->numClipRects == 0)
76 return;
77 }
78 #endif
79
80 R600_NEWPRIM(context);
81
82 if (colorMask == ~0)
83 tri_mask |= (mask & BUFFER_BITS_COLOR);
84
85
86 /* HW stencil */
87 if (mask & BUFFER_BIT_STENCIL) {
88 tri_mask |= BUFFER_BIT_STENCIL;
89 }
90
91 /* HW depth */
92 if (mask & BUFFER_BIT_DEPTH) {
93 tri_mask |= BUFFER_BIT_DEPTH;
94 }
95
96 /* If we're doing a tri pass for depth/stencil, include a likely color
97 * buffer with it.
98 */
99
100 for (i = 0; i < BUFFER_COUNT; i++) {
101 GLuint bufBit = 1 << i;
102 if ((tri_mask) & bufBit) {
103 if (!fb->Attachment[i].Renderbuffer->ClassID) {
104 tri_mask &= ~bufBit;
105 swrast_mask |= bufBit;
106 }
107 }
108 }
109
110 /* SW fallback clearing */
111 swrast_mask = mask & ~tri_mask;
112
113 if (tri_mask)
114 r700UserClear(ctx, tri_mask);
115 if (swrast_mask) {
116 if (RADEON_DEBUG & DEBUG_FALLBACKS)
117 fprintf(stderr, "%s: swrast clear, mask: %x\n",
118 __FUNCTION__, swrast_mask);
119 _swrast_Clear(ctx, swrast_mask);
120 }
121
122 }
123
124