2 * Mesa 3-D graphics library
4 * Copyright (C) 2012-2013 LunarG, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
25 * Chia-I Wu <olv@lunarg.com>
28 #include "util/u_surface.h"
29 #include "intel_reg.h"
31 #include "ilo_blitter.h"
32 #include "ilo_context.h"
34 #include "ilo_resource.h"
35 #include "ilo_screen.h"
39 ilo_resource_copy_region(struct pipe_context
*pipe
,
40 struct pipe_resource
*dst
,
42 unsigned dstx
, unsigned dsty
, unsigned dstz
,
43 struct pipe_resource
*src
,
45 const struct pipe_box
*src_box
)
47 struct ilo_context
*ilo
= ilo_context(pipe
);
49 if (ilo_blitter_blt_copy_resource(ilo
->blitter
,
50 dst
, dst_level
, dstx
, dsty
, dstz
,
51 src
, src_level
, src_box
))
54 util_resource_copy_region(&ilo
->base
, dst
, dst_level
,
55 dstx
, dsty
, dstz
, src
, src_level
, src_box
);
59 ilo_clear(struct pipe_context
*pipe
,
61 const union pipe_color_union
*color
,
65 struct ilo_context
*ilo
= ilo_context(pipe
);
67 ilo_blitter_pipe_clear_fb(ilo
->blitter
, buffers
, color
, depth
, stencil
);
71 ilo_clear_render_target(struct pipe_context
*pipe
,
72 struct pipe_surface
*dst
,
73 const union pipe_color_union
*color
,
74 unsigned dstx
, unsigned dsty
,
75 unsigned width
, unsigned height
)
77 struct ilo_context
*ilo
= ilo_context(pipe
);
79 if (!width
|| !height
|| dstx
>= dst
->width
|| dsty
>= dst
->height
)
82 if (dstx
+ width
> dst
->width
)
83 width
= dst
->width
- dstx
;
84 if (dsty
+ height
> dst
->height
)
85 height
= dst
->height
- dsty
;
87 if (ilo_blitter_blt_clear_rt(ilo
->blitter
,
88 dst
, color
, dstx
, dsty
, width
, height
))
91 ilo_blitter_pipe_clear_rt(ilo
->blitter
,
92 dst
, color
, dstx
, dsty
, width
, height
);
96 ilo_clear_depth_stencil(struct pipe_context
*pipe
,
97 struct pipe_surface
*dst
,
101 unsigned dstx
, unsigned dsty
,
102 unsigned width
, unsigned height
)
104 struct ilo_context
*ilo
= ilo_context(pipe
);
106 if (!width
|| !height
|| dstx
>= dst
->width
|| dsty
>= dst
->height
)
109 if (dstx
+ width
> dst
->width
)
110 width
= dst
->width
- dstx
;
111 if (dsty
+ height
> dst
->height
)
112 height
= dst
->height
- dsty
;
114 if (ilo_blitter_blt_clear_zs(ilo
->blitter
,
115 dst
, clear_flags
, depth
, stencil
, dstx
, dsty
, width
, height
))
118 ilo_blitter_pipe_clear_zs(ilo
->blitter
,
119 dst
, clear_flags
, depth
, stencil
, dstx
, dsty
, width
, height
);
123 ilo_blit(struct pipe_context
*pipe
, const struct pipe_blit_info
*info
)
125 struct ilo_context
*ilo
= ilo_context(pipe
);
127 ilo_blitter_pipe_blit(ilo
->blitter
, info
);
131 * Initialize blit-related functions.
134 ilo_init_blit_functions(struct ilo_context
*ilo
)
136 ilo
->base
.resource_copy_region
= ilo_resource_copy_region
;
137 ilo
->base
.blit
= ilo_blit
;
139 ilo
->base
.clear
= ilo_clear
;
140 ilo
->base
.clear_render_target
= ilo_clear_render_target
;
141 ilo
->base
.clear_depth_stencil
= ilo_clear_depth_stencil
;