2 * Mesa 3-D graphics library
4 * Copyright (C) 2014 Intel Corporation All Rights Reserved.
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
17 * OR 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
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
25 * Jason Ekstrand <jason.ekstrand@intel.com>
28 #include "brw_blorp.h"
29 #include "intel_fbo.h"
30 #include "intel_tex.h"
31 #include "intel_blit.h"
32 #include "intel_mipmap_tree.h"
33 #include "main/formats.h"
34 #include "main/teximage.h"
35 #include "drivers/common/meta.h"
38 copy_miptrees(struct brw_context
*brw
,
39 struct intel_mipmap_tree
*src_mt
,
40 int src_x
, int src_y
, int src_z
, unsigned src_level
,
41 struct intel_mipmap_tree
*dst_mt
,
42 int dst_x
, int dst_y
, int dst_z
, unsigned dst_level
,
43 int src_width
, int src_height
)
46 /* On gen4-5, try BLT first.
48 * Gen4-5 have a single ring for both 3D and BLT operations, so there's
49 * no inter-ring synchronization issues like on Gen6+. It is apparently
50 * faster than using the 3D pipeline. Original Gen4 also has to rebase
51 * and copy miptree slices in order to render to unaligned locations.
53 if (intel_miptree_copy(brw
, src_mt
, src_level
, src_z
, src_x
, src_y
,
54 dst_mt
, dst_level
, dst_z
, dst_x
, dst_y
,
55 src_width
, src_height
))
59 brw_blorp_copy_miptrees(brw
,
60 src_mt
, src_level
, src_z
,
61 dst_mt
, dst_level
, dst_z
,
62 src_x
, src_y
, dst_x
, dst_y
,
63 src_width
, src_height
);
67 intel_copy_image_sub_data(struct gl_context
*ctx
,
68 struct gl_texture_image
*src_image
,
69 struct gl_renderbuffer
*src_renderbuffer
,
70 int src_x
, int src_y
, int src_z
,
71 struct gl_texture_image
*dst_image
,
72 struct gl_renderbuffer
*dst_renderbuffer
,
73 int dst_x
, int dst_y
, int dst_z
,
74 int src_width
, int src_height
)
76 struct brw_context
*brw
= brw_context(ctx
);
77 struct intel_mipmap_tree
*src_mt
, *dst_mt
;
78 unsigned src_level
, dst_level
;
81 src_mt
= intel_texture_image(src_image
)->mt
;
82 src_level
= src_image
->Level
+ src_image
->TexObject
->MinLevel
;
84 /* Cube maps actually have different images per face */
85 if (src_image
->TexObject
->Target
== GL_TEXTURE_CUBE_MAP
)
86 src_z
= src_image
->Face
;
88 src_z
+= src_image
->TexObject
->MinLayer
;
90 assert(src_renderbuffer
);
91 src_mt
= intel_renderbuffer(src_renderbuffer
)->mt
;
92 src_image
= src_renderbuffer
->TexImage
;
97 dst_mt
= intel_texture_image(dst_image
)->mt
;
99 dst_level
= dst_image
->Level
+ dst_image
->TexObject
->MinLevel
;
101 /* Cube maps actually have different images per face */
102 if (dst_image
->TexObject
->Target
== GL_TEXTURE_CUBE_MAP
)
103 dst_z
= dst_image
->Face
;
105 dst_z
+= dst_image
->TexObject
->MinLayer
;
107 assert(dst_renderbuffer
);
108 dst_mt
= intel_renderbuffer(dst_renderbuffer
)->mt
;
109 dst_image
= dst_renderbuffer
->TexImage
;
113 copy_miptrees(brw
, src_mt
, src_x
, src_y
, src_z
, src_level
,
114 dst_mt
, dst_x
, dst_y
, dst_z
, dst_level
,
115 src_width
, src_height
);
117 /* CopyImage only works for equal formats, texture view equivalence
118 * classes, and a couple special cases for compressed textures.
120 * Notably, GL_DEPTH_STENCIL does not appear in any equivalence
121 * classes, so we know the formats must be the same, and thus both
122 * will either have stencil, or not. They can't be mismatched.
124 assert((src_mt
->stencil_mt
!= NULL
) == (dst_mt
->stencil_mt
!= NULL
));
126 if (dst_mt
->stencil_mt
) {
127 copy_miptrees(brw
, src_mt
->stencil_mt
, src_x
, src_y
, src_z
, src_level
,
128 dst_mt
->stencil_mt
, dst_x
, dst_y
, dst_z
, dst_level
,
129 src_width
, src_height
);
134 intelInitCopyImageFuncs(struct dd_function_table
*functions
)
136 functions
->CopyImageSubData
= intel_copy_image_sub_data
;