2 * Copyright (C) 2009 Francisco Jerez.
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
13 * The above copyright notice and this permission notice (including the
14 * next paragraph) shall be included in all copies or substantial
15 * portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
21 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 #include "main/mfeatures.h"
29 #include "nouveau_driver.h"
30 #include "nouveau_context.h"
31 #include "nouveau_fbo.h"
32 #include "nouveau_util.h"
34 #include "drivers/common/meta.h"
36 static const GLubyte
*
37 nouveau_get_string(struct gl_context
*ctx
, GLenum name
)
39 static char buffer
[128];
40 char hardware_name
[32];
44 return (GLubyte
*)"Nouveau";
47 sprintf(hardware_name
, "nv%02X", context_chipset(ctx
));
48 driGetRendererString(buffer
, hardware_name
, 0);
50 return (GLubyte
*)buffer
;
57 nouveau_flush(struct gl_context
*ctx
)
59 struct nouveau_context
*nctx
= to_nouveau_context(ctx
);
60 struct nouveau_channel
*chan
= context_chan(ctx
);
64 if (ctx
->DrawBuffer
->Name
== 0 &&
65 ctx
->DrawBuffer
->_ColorDrawBufferIndexes
[0] == BUFFER_FRONT_LEFT
) {
66 __DRIscreen
*screen
= nctx
->screen
->dri_screen
;
67 __DRIdri2LoaderExtension
*dri2
= screen
->dri2
.loader
;
68 __DRIdrawable
*drawable
= nctx
->dri_context
->driDrawablePriv
;
70 dri2
->flushFrontBuffer(drawable
, drawable
->loaderPrivate
);
75 nouveau_finish(struct gl_context
*ctx
)
81 nouveau_clear(struct gl_context
*ctx
, GLbitfield buffers
)
83 struct gl_framebuffer
*fb
= ctx
->DrawBuffer
;
87 nouveau_validate_framebuffer(ctx
);
88 get_scissors(fb
, &x
, &y
, &w
, &h
);
90 for (i
= 0; i
< BUFFER_COUNT
; i
++) {
91 struct nouveau_surface
*s
;
94 buf
= buffers
& (1 << i
);
98 s
= &to_nouveau_renderbuffer(
99 fb
->Attachment
[i
].Renderbuffer
)->surface
;
101 if (buf
& BUFFER_BITS_COLOR
) {
102 mask
= pack_rgba_i(s
->format
, ctx
->Color
.ColorMask
[0]);
103 value
= pack_rgba_clamp_f(s
->format
, ctx
->Color
.ClearColor
.f
);
106 context_drv(ctx
)->surface_fill(
107 ctx
, s
, mask
, value
, x
, y
, w
, h
);
111 } else if (buf
& (BUFFER_BIT_DEPTH
| BUFFER_BIT_STENCIL
)) {
112 mask
= pack_zs_i(s
->format
,
113 (buffers
& BUFFER_BIT_DEPTH
&&
114 ctx
->Depth
.Mask
) ? ~0 : 0,
115 (buffers
& BUFFER_BIT_STENCIL
?
116 ctx
->Stencil
.WriteMask
[0] : 0));
117 value
= pack_zs_f(s
->format
,
122 context_drv(ctx
)->surface_fill(
123 ctx
, s
, mask
, value
, x
, y
, w
, h
);
125 buffers
&= ~(BUFFER_BIT_DEPTH
| BUFFER_BIT_STENCIL
);
130 _mesa_meta_Clear(ctx
, buffers
);
134 nouveau_driver_functions_init(struct dd_function_table
*functions
)
136 functions
->GetString
= nouveau_get_string
;
137 functions
->Flush
= nouveau_flush
;
138 functions
->Finish
= nouveau_finish
;
139 functions
->Clear
= nouveau_clear
;
140 functions
->DrawPixels
= _mesa_meta_DrawPixels
;
141 functions
->CopyPixels
= _mesa_meta_CopyPixels
;
142 functions
->Bitmap
= _mesa_meta_Bitmap
;
143 #if FEATURE_EXT_framebuffer_blit
144 functions
->BlitFramebuffer
= _mesa_meta_BlitFramebuffer
;