101e04c3fSmrg/* 201e04c3fSmrg * Copyright 2016 Advanced Micro Devices, Inc. 301e04c3fSmrg * 401e04c3fSmrg * Permission is hereby granted, free of charge, to any person obtaining a 501e04c3fSmrg * copy of this software and associated documentation files (the "Software"), 601e04c3fSmrg * to deal in the Software without restriction, including without limitation 701e04c3fSmrg * on the rights to use, copy, modify, merge, publish, distribute, sub 801e04c3fSmrg * license, and/or sell copies of the Software, and to permit persons to whom 901e04c3fSmrg * the Software is furnished to do so, subject to the following conditions: 1001e04c3fSmrg * 1101e04c3fSmrg * The above copyright notice and this permission notice (including the next 1201e04c3fSmrg * paragraph) shall be included in all copies or substantial portions of the 1301e04c3fSmrg * Software. 1401e04c3fSmrg * 1501e04c3fSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 1601e04c3fSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 1701e04c3fSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 1801e04c3fSmrg * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 1901e04c3fSmrg * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 2001e04c3fSmrg * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 2101e04c3fSmrg * USE OR OTHER DEALINGS IN THE SOFTWARE. 2201e04c3fSmrg */ 2301e04c3fSmrg 2401e04c3fSmrg#ifndef ST_PBO_H 2501e04c3fSmrg#define ST_PBO_H 2601e04c3fSmrg 2701e04c3fSmrgstruct gl_pixelstore_attrib; 2801e04c3fSmrg 2901e04c3fSmrgstruct st_context; 3001e04c3fSmrg 3101e04c3fSmrgstruct st_pbo_addresses { 3201e04c3fSmrg int xoffset; 3301e04c3fSmrg int yoffset; 3401e04c3fSmrg unsigned width; 3501e04c3fSmrg unsigned height; 3601e04c3fSmrg unsigned depth; 3701e04c3fSmrg 3801e04c3fSmrg unsigned bytes_per_pixel; 3901e04c3fSmrg 4001e04c3fSmrg /* Everything below is filled in by st_pbo_from_pixelstore */ 4101e04c3fSmrg unsigned pixels_per_row; 4201e04c3fSmrg unsigned image_height; 4301e04c3fSmrg 4401e04c3fSmrg /* Everything below is filled in by st_pbo_setup_buffer */ 4501e04c3fSmrg 4601e04c3fSmrg /* Buffer and view. */ 4701e04c3fSmrg struct pipe_resource *buffer; /* non-owning pointer */ 4801e04c3fSmrg unsigned first_element; 4901e04c3fSmrg unsigned last_element; 5001e04c3fSmrg 5101e04c3fSmrg /* Constant buffer for the fragment shader. */ 5201e04c3fSmrg struct { 5301e04c3fSmrg int32_t xoffset; 5401e04c3fSmrg int32_t yoffset; 5501e04c3fSmrg int32_t stride; 5601e04c3fSmrg int32_t image_size; 5701e04c3fSmrg int32_t layer_offset; 5801e04c3fSmrg } constants; 5901e04c3fSmrg}; 6001e04c3fSmrg 6101e04c3fSmrgbool 6201e04c3fSmrgst_pbo_addresses_setup(struct st_context *st, 6301e04c3fSmrg struct pipe_resource *buf, intptr_t buf_offset, 6401e04c3fSmrg struct st_pbo_addresses *addr); 6501e04c3fSmrg 6601e04c3fSmrgbool 6701e04c3fSmrgst_pbo_addresses_pixelstore(struct st_context *st, 6801e04c3fSmrg GLenum gl_target, bool skip_images, 6901e04c3fSmrg const struct gl_pixelstore_attrib *store, 7001e04c3fSmrg const void *pixels, 7101e04c3fSmrg struct st_pbo_addresses *addr); 7201e04c3fSmrg 7301e04c3fSmrgvoid 7401e04c3fSmrgst_pbo_addresses_invert_y(struct st_pbo_addresses *addr, 7501e04c3fSmrg unsigned viewport_height); 7601e04c3fSmrg 7701e04c3fSmrgbool 7801e04c3fSmrgst_pbo_draw(struct st_context *st, const struct st_pbo_addresses *addr, 7901e04c3fSmrg unsigned surface_width, unsigned surface_height); 8001e04c3fSmrg 8101e04c3fSmrgvoid * 8201e04c3fSmrgst_pbo_create_vs(struct st_context *st); 8301e04c3fSmrg 8401e04c3fSmrgvoid * 8501e04c3fSmrgst_pbo_create_gs(struct st_context *st); 8601e04c3fSmrg 8701e04c3fSmrgvoid * 8801e04c3fSmrgst_pbo_get_upload_fs(struct st_context *st, 8901e04c3fSmrg enum pipe_format src_format, 907ec681f3Smrg enum pipe_format dst_format, 917ec681f3Smrg bool need_layer); 9201e04c3fSmrg 9301e04c3fSmrgvoid * 9401e04c3fSmrgst_pbo_get_download_fs(struct st_context *st, enum pipe_texture_target target, 9501e04c3fSmrg enum pipe_format src_format, 967ec681f3Smrg enum pipe_format dst_format, 977ec681f3Smrg bool need_layer); 9801e04c3fSmrg 9901e04c3fSmrgextern void 10001e04c3fSmrgst_init_pbo_helpers(struct st_context *st); 10101e04c3fSmrg 10201e04c3fSmrgextern void 10301e04c3fSmrgst_destroy_pbo_helpers(struct st_context *st); 10401e04c3fSmrg 10501e04c3fSmrg#endif /* ST_PBO_H */ 106