1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright 2016 Advanced Micro Devices, Inc. 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 7bf215546Sopenharmony_ci * on the rights to use, copy, modify, merge, publish, distribute, sub 8bf215546Sopenharmony_ci * license, and/or sell copies of the Software, and to permit persons to whom 9bf215546Sopenharmony_ci * the Software is furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 13bf215546Sopenharmony_ci * Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 18bf215546Sopenharmony_ci * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 19bf215546Sopenharmony_ci * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 20bf215546Sopenharmony_ci * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 21bf215546Sopenharmony_ci * USE OR OTHER DEALINGS IN THE SOFTWARE. 22bf215546Sopenharmony_ci */ 23bf215546Sopenharmony_ci 24bf215546Sopenharmony_ci#ifndef ST_PBO_H 25bf215546Sopenharmony_ci#define ST_PBO_H 26bf215546Sopenharmony_ci 27bf215546Sopenharmony_cistruct gl_pixelstore_attrib; 28bf215546Sopenharmony_ci 29bf215546Sopenharmony_cistruct st_context; 30bf215546Sopenharmony_ci 31bf215546Sopenharmony_cistruct st_pbo_addresses { 32bf215546Sopenharmony_ci int xoffset; 33bf215546Sopenharmony_ci int yoffset; 34bf215546Sopenharmony_ci unsigned width; 35bf215546Sopenharmony_ci unsigned height; 36bf215546Sopenharmony_ci unsigned depth; 37bf215546Sopenharmony_ci 38bf215546Sopenharmony_ci unsigned bytes_per_pixel; 39bf215546Sopenharmony_ci 40bf215546Sopenharmony_ci /* Everything below is filled in by st_pbo_from_pixelstore */ 41bf215546Sopenharmony_ci unsigned pixels_per_row; 42bf215546Sopenharmony_ci unsigned image_height; 43bf215546Sopenharmony_ci 44bf215546Sopenharmony_ci /* Everything below is filled in by st_pbo_setup_buffer */ 45bf215546Sopenharmony_ci 46bf215546Sopenharmony_ci /* Buffer and view. */ 47bf215546Sopenharmony_ci struct pipe_resource *buffer; /* non-owning pointer */ 48bf215546Sopenharmony_ci unsigned first_element; 49bf215546Sopenharmony_ci unsigned last_element; 50bf215546Sopenharmony_ci 51bf215546Sopenharmony_ci /* Constant buffer for the fragment shader. */ 52bf215546Sopenharmony_ci struct { 53bf215546Sopenharmony_ci int32_t xoffset; 54bf215546Sopenharmony_ci int32_t yoffset; 55bf215546Sopenharmony_ci int32_t stride; 56bf215546Sopenharmony_ci int32_t image_size; 57bf215546Sopenharmony_ci int32_t layer_offset; 58bf215546Sopenharmony_ci } constants; 59bf215546Sopenharmony_ci}; 60bf215546Sopenharmony_ci 61bf215546Sopenharmony_ci/* Conversion to apply in the fragment shader. */ 62bf215546Sopenharmony_cienum st_pbo_conversion { 63bf215546Sopenharmony_ci ST_PBO_CONVERT_FLOAT = 0, 64bf215546Sopenharmony_ci ST_PBO_CONVERT_UINT, 65bf215546Sopenharmony_ci ST_PBO_CONVERT_SINT, 66bf215546Sopenharmony_ci ST_PBO_CONVERT_UINT_TO_SINT, 67bf215546Sopenharmony_ci ST_PBO_CONVERT_SINT_TO_UINT, 68bf215546Sopenharmony_ci 69bf215546Sopenharmony_ci ST_NUM_PBO_CONVERSIONS 70bf215546Sopenharmony_ci}; 71bf215546Sopenharmony_ci 72bf215546Sopenharmony_ciconst struct glsl_type * 73bf215546Sopenharmony_cist_pbo_sampler_type_for_target(enum pipe_texture_target target, 74bf215546Sopenharmony_ci enum st_pbo_conversion conv); 75bf215546Sopenharmony_cibool 76bf215546Sopenharmony_cist_pbo_addresses_setup(struct st_context *st, 77bf215546Sopenharmony_ci struct pipe_resource *buf, intptr_t buf_offset, 78bf215546Sopenharmony_ci struct st_pbo_addresses *addr); 79bf215546Sopenharmony_ci 80bf215546Sopenharmony_cibool 81bf215546Sopenharmony_cist_pbo_addresses_pixelstore(struct st_context *st, 82bf215546Sopenharmony_ci GLenum gl_target, bool skip_images, 83bf215546Sopenharmony_ci const struct gl_pixelstore_attrib *store, 84bf215546Sopenharmony_ci const void *pixels, 85bf215546Sopenharmony_ci struct st_pbo_addresses *addr); 86bf215546Sopenharmony_ci 87bf215546Sopenharmony_civoid 88bf215546Sopenharmony_cist_pbo_addresses_invert_y(struct st_pbo_addresses *addr, 89bf215546Sopenharmony_ci unsigned viewport_height); 90bf215546Sopenharmony_ci 91bf215546Sopenharmony_cibool 92bf215546Sopenharmony_cist_pbo_draw(struct st_context *st, const struct st_pbo_addresses *addr, 93bf215546Sopenharmony_ci unsigned surface_width, unsigned surface_height); 94bf215546Sopenharmony_ci 95bf215546Sopenharmony_civoid * 96bf215546Sopenharmony_cist_pbo_create_vs(struct st_context *st); 97bf215546Sopenharmony_ci 98bf215546Sopenharmony_civoid * 99bf215546Sopenharmony_cist_pbo_create_gs(struct st_context *st); 100bf215546Sopenharmony_ci 101bf215546Sopenharmony_civoid * 102bf215546Sopenharmony_cist_pbo_get_upload_fs(struct st_context *st, 103bf215546Sopenharmony_ci enum pipe_format src_format, 104bf215546Sopenharmony_ci enum pipe_format dst_format, 105bf215546Sopenharmony_ci bool need_layer); 106bf215546Sopenharmony_ci 107bf215546Sopenharmony_civoid * 108bf215546Sopenharmony_cist_pbo_get_download_fs(struct st_context *st, enum pipe_texture_target target, 109bf215546Sopenharmony_ci enum pipe_format src_format, 110bf215546Sopenharmony_ci enum pipe_format dst_format, 111bf215546Sopenharmony_ci bool need_layer); 112bf215546Sopenharmony_ci 113bf215546Sopenharmony_cibool 114bf215546Sopenharmony_cist_GetTexSubImage_shader(struct gl_context * ctx, 115bf215546Sopenharmony_ci GLint xoffset, GLint yoffset, GLint zoffset, 116bf215546Sopenharmony_ci GLsizei width, GLsizei height, GLint depth, 117bf215546Sopenharmony_ci GLenum format, GLenum type, void * pixels, 118bf215546Sopenharmony_ci struct gl_texture_image *texImage); 119bf215546Sopenharmony_ci 120bf215546Sopenharmony_cienum pipe_format 121bf215546Sopenharmony_cist_pbo_get_dst_format(struct gl_context *ctx, enum pipe_texture_target target, 122bf215546Sopenharmony_ci enum pipe_format src_format, bool is_compressed, 123bf215546Sopenharmony_ci GLenum format, GLenum type, unsigned bind); 124bf215546Sopenharmony_cienum pipe_format 125bf215546Sopenharmony_cist_pbo_get_src_format(struct pipe_screen *screen, enum pipe_format src_format, struct pipe_resource *src); 126bf215546Sopenharmony_ci 127bf215546Sopenharmony_ciextern void 128bf215546Sopenharmony_cist_init_pbo_helpers(struct st_context *st); 129bf215546Sopenharmony_ci 130bf215546Sopenharmony_ciextern void 131bf215546Sopenharmony_cist_destroy_pbo_helpers(struct st_context *st); 132bf215546Sopenharmony_ci 133bf215546Sopenharmony_ci#endif /* ST_PBO_H */ 134