1 /****************************************************************************
2 * Copyright (C) 2015 Intel Corporation. All Rights Reserved.
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 (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22 ***************************************************************************/
24 #include "swr_context.h"
25 #include "swr_query.h"
28 swr_clear(struct pipe_context
*pipe
,
30 const union pipe_color_union
*color
,
34 struct swr_context
*ctx
= swr_context(pipe
);
35 struct pipe_framebuffer_state
*fb
= &ctx
->framebuffer
;
39 if (!swr_check_render_cond(pipe
))
42 swr_update_derived(pipe
);
44 if (buffers
& PIPE_CLEAR_COLOR
&& fb
->nr_cbufs
) {
45 for (unsigned i
= 0; i
< fb
->nr_cbufs
; ++i
)
47 clearMask
|= (SWR_ATTACHMENT_COLOR0_BIT
<< i
);
50 if (buffers
& PIPE_CLEAR_DEPTH
&& fb
->zsbuf
)
51 clearMask
|= SWR_ATTACHMENT_DEPTH_BIT
;
53 if (buffers
& PIPE_CLEAR_STENCIL
&& fb
->zsbuf
)
54 clearMask
|= SWR_ATTACHMENT_STENCIL_BIT
;
56 #if 0 // XXX HACK, override clear color alpha. On ubuntu, clears are
58 ((union pipe_color_union
*)color
)->f
[3] = 1.0; /* cast off your const'd-ness */
61 swr_update_draw_context(ctx
);
62 SwrClearRenderTarget(ctx
->swrContext
, clearMask
, color
->f
, depth
, stencil
,
67 #if 0 // XXX, these don't get called. how to get these called? Do we need
70 swr_clear_render_target(struct pipe_context
*pipe
, struct pipe_surface
*ps
,
71 const union pipe_color_union
*color
,
72 unsigned x
, unsigned y
, unsigned w
, unsigned h
,
73 bool render_condition_enabled
)
75 struct swr_context
*ctx
= swr_context(pipe
);
76 fprintf(stderr
, "SWR swr_clear_render_target!\n");
78 ctx
->dirty
|= SWR_NEW_FRAMEBUFFER
| SWR_NEW_SCISSOR
;
82 swr_clear_depth_stencil(struct pipe_context
*pipe
, struct pipe_surface
*ps
,
83 unsigned buffers
, double depth
, unsigned stencil
,
84 unsigned x
, unsigned y
, unsigned w
, unsigned h
,
85 bool render_condition_enabled
)
87 struct swr_context
*ctx
= swr_context(pipe
);
88 fprintf(stderr
, "SWR swr_clear_depth_stencil!\n");
90 ctx
->dirty
|= SWR_NEW_FRAMEBUFFER
| SWR_NEW_SCISSOR
;
94 swr_clear_buffer(struct pipe_context
*pipe
,
95 struct pipe_resource
*res
,
96 unsigned offset
, unsigned size
,
97 const void *data
, int data_size
)
99 fprintf(stderr
, "SWR swr_clear_buffer!\n");
100 struct swr_context
*ctx
= swr_context(pipe
);
101 struct swr_resource
*buf
= swr_resource(res
);
102 union pipe_color_union color
;
103 enum pipe_format dst_fmt
;
104 unsigned width
, height
, elements
;
106 assert(res
->target
== PIPE_BUFFER
);
108 assert(size
% data_size
== 0);
110 SWR_SURFACE_STATE
&swr_buffer
= buf
->swr
;
112 ctx
->dirty
|= SWR_NEW_FRAMEBUFFER
| SWR_NEW_SCISSOR
;
118 swr_clear_init(struct pipe_context
*pipe
)
120 pipe
->clear
= swr_clear
;
121 #if 0 // XXX, these don't get called. how to get these called? Do we need
123 pipe
->clear_render_target
= swr_clear_render_target
;
124 pipe
->clear_depth_stencil
= swr_clear_depth_stencil
;
125 pipe
->clear_buffer
= swr_clear_buffer
;