1 /**************************************************************************
3 * Copyright 2003 Tungsten Graphics, Inc., Cedar Park, Texas.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
29 #include "brw_context.h"
30 #include "brw_state.h"
31 #include "pipe/p_defines.h"
32 #include "pipe/p_inlines.h"
33 #include "pipe/internal/p_winsys_screen.h"
34 #include "util/u_tile.h"
35 #include "util/u_rect.h"
39 /* Assumes all values are within bounds -- no checking at this level -
40 * do it higher up if required.
43 brw_surface_copy(struct pipe_context
*pipe
,
44 struct pipe_surface
*dst
,
45 unsigned dstx
, unsigned dsty
,
46 struct pipe_surface
*src
,
47 unsigned srcx
, unsigned srcy
, unsigned width
, unsigned height
)
50 assert( dst
->block
.size
== src
->block
.size
);
51 assert( dst
->block
.width
== src
->block
.height
);
52 assert( dst
->block
.height
== src
->block
.height
);
55 void *dst_map
= pipe
->screen
->surface_map( pipe
->screen
,
57 PIPE_BUFFER_USAGE_CPU_WRITE
);
59 const void *src_map
= pipe
->screen
->surface_map( pipe
->screen
,
61 PIPE_BUFFER_USAGE_CPU_READ
);
63 util_copy_rect(dst_map
,
72 pipe
->screen
->surface_unmap(pipe
->screen
, src
);
73 pipe
->screen
->surface_unmap(pipe
->screen
, dst
);
76 struct brw_texture
*dst_tex
= (struct brw_texture
*)dst
->texture
;
77 struct brw_texture
*src_tex
= (struct brw_texture
*)src
->texture
;
78 assert(dst
->block
.width
== 1);
79 assert(dst
->block
.height
== 1);
80 brw_copy_blit(brw_context(pipe
),
83 (short) src
->stride
/src
->block
.size
, src_tex
->buffer
, src
->offset
, FALSE
,
84 (short) dst
->stride
/dst
->block
.size
, dst_tex
->buffer
, dst
->offset
, FALSE
,
85 (short) srcx
, (short) srcy
, (short) dstx
, (short) dsty
,
86 (short) width
, (short) height
, PIPE_LOGICOP_COPY
);
92 brw_surface_fill(struct pipe_context
*pipe
,
93 struct pipe_surface
*dst
,
94 unsigned dstx
, unsigned dsty
,
95 unsigned width
, unsigned height
, unsigned value
)
98 void *dst_map
= pipe
->screen
->surface_map( pipe
->screen
,
100 PIPE_BUFFER_USAGE_CPU_WRITE
);
102 util_fill_rect(dst_map
, &dst
->block
, dst
->stride
, dstx
, dsty
, width
, height
, value
);
104 pipe
->screen
->surface_unmap(pipe
->screen
, dst
);
107 struct brw_texture
*tex
= (struct brw_texture
*)dst
->texture
;
108 assert(dst
->block
.width
== 1);
109 assert(dst
->block
.height
== 1);
110 brw_fill_blit(brw_context(pipe
),
112 (short) dst
->stride
/dst
->block
.size
,
113 tex
->buffer
, dst
->offset
, FALSE
,
114 (short) dstx
, (short) dsty
,
115 (short) width
, (short) height
,
122 brw_init_surface_functions(struct brw_context
*brw
)
124 brw
->pipe
.surface_copy
= brw_surface_copy
;
125 brw
->pipe
.surface_fill
= brw_surface_fill
;