• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /* Conversion to apply in the fragment shader. */
62 enum st_pbo_conversion {
63    ST_PBO_CONVERT_FLOAT = 0,
64    ST_PBO_CONVERT_UINT,
65    ST_PBO_CONVERT_SINT,
66    ST_PBO_CONVERT_UINT_TO_SINT,
67    ST_PBO_CONVERT_SINT_TO_UINT,
68 
69    ST_NUM_PBO_CONVERSIONS
70 };
71 
72 const struct glsl_type *
73 st_pbo_sampler_type_for_target(enum pipe_texture_target target,
74                                enum st_pbo_conversion conv);
75 bool
76 st_pbo_addresses_setup(struct st_context *st,
77                        struct pipe_resource *buf, intptr_t buf_offset,
78                        struct st_pbo_addresses *addr);
79 
80 bool
81 st_pbo_addresses_pixelstore(struct st_context *st,
82                             GLenum gl_target, bool skip_images,
83                             const struct gl_pixelstore_attrib *store,
84                             const void *pixels,
85                             struct st_pbo_addresses *addr);
86 
87 void
88 st_pbo_addresses_invert_y(struct st_pbo_addresses *addr,
89                           unsigned viewport_height);
90 
91 bool
92 st_pbo_draw(struct st_context *st, const struct st_pbo_addresses *addr,
93             unsigned surface_width, unsigned surface_height);
94 
95 void *
96 st_pbo_create_vs(struct st_context *st);
97 
98 void *
99 st_pbo_create_gs(struct st_context *st);
100 
101 void *
102 st_pbo_get_upload_fs(struct st_context *st,
103                      enum pipe_format src_format,
104                      enum pipe_format dst_format,
105                      bool need_layer);
106 
107 void *
108 st_pbo_get_download_fs(struct st_context *st, enum pipe_texture_target target,
109                        enum pipe_format src_format,
110                        enum pipe_format dst_format,
111                        bool need_layer);
112 
113 bool
114 st_GetTexSubImage_shader(struct gl_context * ctx,
115                          GLint xoffset, GLint yoffset, GLint zoffset,
116                          GLsizei width, GLsizei height, GLint depth,
117                          GLenum format, GLenum type, void * pixels,
118                          struct gl_texture_image *texImage);
119 
120 enum pipe_format
121 st_pbo_get_dst_format(struct gl_context *ctx, enum pipe_texture_target target,
122                       enum pipe_format src_format, bool is_compressed,
123                       GLenum format, GLenum type, unsigned bind);
124 enum pipe_format
125 st_pbo_get_src_format(struct pipe_screen *screen, enum pipe_format src_format, struct pipe_resource *src);
126 
127 extern void
128 st_init_pbo_helpers(struct st_context *st);
129 
130 extern void
131 st_destroy_pbo_helpers(struct st_context *st);
132 
133 #endif /* ST_PBO_H */
134