st/mesa: account for "loose", per-mipmap level textures in CopyImageSubData
[mesa.git] / src / mesa / state_tracker / st_pbo.h
1 /*
2 * Copyright 2016 Advanced Micro Devices, Inc.
3 *
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 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
10 *
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
13 * Software.
14 *
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 NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23
24 #ifndef ST_PBO_H
25 #define ST_PBO_H
26
27 struct gl_pixelstore_attrib;
28
29 struct st_context;
30
31 struct st_pbo_addresses {
32 int xoffset;
33 int yoffset;
34 unsigned width;
35 unsigned height;
36 unsigned depth;
37
38 unsigned bytes_per_pixel;
39
40 /* Everything below is filled in by st_pbo_from_pixelstore */
41 unsigned pixels_per_row;
42 unsigned image_height;
43
44 /* Everything below is filled in by st_pbo_setup_buffer */
45
46 /* Buffer and view. */
47 struct pipe_resource *buffer; /* non-owning pointer */
48 unsigned first_element;
49 unsigned last_element;
50
51 /* Constant buffer for the fragment shader. */
52 struct {
53 int32_t xoffset;
54 int32_t yoffset;
55 int32_t stride;
56 int32_t image_size;
57 int32_t layer_offset;
58 } constants;
59 };
60
61 bool
62 st_pbo_addresses_setup(struct st_context *st,
63 struct pipe_resource *buf, intptr_t buf_offset,
64 struct st_pbo_addresses *addr);
65
66 bool
67 st_pbo_addresses_pixelstore(struct st_context *st,
68 GLenum gl_target, bool skip_images,
69 const struct gl_pixelstore_attrib *store,
70 const void *pixels,
71 struct st_pbo_addresses *addr);
72
73 void
74 st_pbo_addresses_invert_y(struct st_pbo_addresses *addr,
75 unsigned viewport_height);
76
77 bool
78 st_pbo_draw(struct st_context *st, const struct st_pbo_addresses *addr,
79 unsigned surface_width, unsigned surface_height);
80
81 void *
82 st_pbo_create_vs(struct st_context *st);
83
84 void *
85 st_pbo_create_gs(struct st_context *st);
86
87 void *
88 st_pbo_get_upload_fs(struct st_context *st,
89 enum pipe_format src_format,
90 enum pipe_format dst_format);
91
92 void *
93 st_pbo_get_download_fs(struct st_context *st, enum pipe_texture_target target,
94 enum pipe_format src_format,
95 enum pipe_format dst_format);
96
97 extern void
98 st_init_pbo_helpers(struct st_context *st);
99
100 extern void
101 st_destroy_pbo_helpers(struct st_context *st);
102
103 #endif /* ST_PBO_H */