2 * Copyright 2008 Ben Skeggs
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 in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
19 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 #include "pipe/p_context.h"
24 #include "pipe/p_defines.h"
25 #include "pipe/p_state.h"
27 #include "nv50_context.h"
30 nv50_clear(struct pipe_context
*pipe
, struct pipe_surface
*ps
,
33 struct nv50_context
*nv50
= nv50_context(pipe
);
34 struct pipe_framebuffer_state fb
, s_fb
= nv50
->framebuffer
;
35 struct pipe_scissor_state sc
, s_sc
= nv50
->scissor
;
36 unsigned dirty
= nv50
->dirty
;
40 if (ps
->format
== PIPE_FORMAT_Z24S8_UNORM
||
41 ps
->format
== PIPE_FORMAT_Z16_UNORM
) {
50 fb
.height
= ps
->height
;
51 pipe
->set_framebuffer_state(pipe
, &fb
);
53 sc
.minx
= sc
.miny
= 0;
56 pipe
->set_scissor_state(pipe
, &sc
);
58 nv50_state_validate(nv50
);
61 case PIPE_FORMAT_A8R8G8B8_UNORM
:
62 BEGIN_RING(tesla
, 0x0d80, 4);
63 OUT_RINGf (ubyte_to_float((clearValue
>> 16) & 0xff));
64 OUT_RINGf (ubyte_to_float((clearValue
>> 8) & 0xff));
65 OUT_RINGf (ubyte_to_float((clearValue
>> 0) & 0xff));
66 OUT_RINGf (ubyte_to_float((clearValue
>> 24) & 0xff));
67 BEGIN_RING(tesla
, 0x19d0, 1);
70 case PIPE_FORMAT_Z24S8_UNORM
:
71 BEGIN_RING(tesla
, 0x0d90, 1);
72 OUT_RINGf ((float)(clearValue
>> 8) * (1.0 / 16777215.0));
73 BEGIN_RING(tesla
, 0x0da0, 1);
74 OUT_RING (clearValue
& 0xff);
75 BEGIN_RING(tesla
, 0x19d0, 1);
79 pipe
->surface_fill(pipe
, ps
, 0, 0, ps
->width
, ps
->height
,
84 pipe
->set_framebuffer_state(pipe
, &s_fb
);
85 pipe
->set_scissor_state(pipe
, &s_sc
);
88 ps
->status
= PIPE_SURFACE_STATUS_CLEAR
;