1 /* 2 * Mesa 3-D graphics library 3 * 4 * Copyright (C) 2015 LunarG, Inc. 5 * 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: 12 * 13 * The above copyright notice and this permission notice shall be included 14 * in all copies or substantial portions of the Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * 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 OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 * DEALINGS IN THE SOFTWARE. 23 * 24 * Authors: 25 * Chia-I Wu <olv@lunarg.com> 26 */ 27 28 #ifndef ILO_STATE_SURFACE_H 29 #define ILO_STATE_SURFACE_H 30 31 #include "genhw/genhw.h" 32 33 #include "ilo_core.h" 34 #include "ilo_dev.h" 35 36 enum ilo_state_surface_access { 37 ILO_STATE_SURFACE_ACCESS_SAMPLER, /* sampling engine surfaces */ 38 ILO_STATE_SURFACE_ACCESS_DP_RENDER, /* render target surfaces */ 39 ILO_STATE_SURFACE_ACCESS_DP_TYPED, /* typed surfaces */ 40 ILO_STATE_SURFACE_ACCESS_DP_UNTYPED, /* untyped surfaces */ 41 ILO_STATE_SURFACE_ACCESS_DP_DATA, 42 ILO_STATE_SURFACE_ACCESS_DP_SVB, 43 }; 44 45 struct ilo_vma; 46 struct ilo_image; 47 48 struct ilo_state_surface_buffer_info { 49 const struct ilo_vma *vma; 50 uint32_t offset; 51 uint32_t size; 52 53 enum ilo_state_surface_access access; 54 55 /* format_size may be less than, equal to, or greater than struct_size */ 56 enum gen_surface_format format; 57 uint8_t format_size; 58 59 bool readonly; 60 uint16_t struct_size; 61 }; 62 63 struct ilo_state_surface_image_info { 64 const struct ilo_image *img; 65 uint8_t level_base; 66 uint8_t level_count; 67 uint16_t slice_base; 68 uint16_t slice_count; 69 70 const struct ilo_vma *vma; 71 const struct ilo_vma *aux_vma; 72 73 enum ilo_state_surface_access access; 74 75 enum gen_surface_type type; 76 77 enum gen_surface_format format; 78 bool is_integer; 79 80 bool readonly; 81 bool is_array; 82 }; 83 84 struct ilo_state_surface { 85 uint32_t surface[13]; 86 87 const struct ilo_vma *vma; 88 const struct ilo_vma *aux_vma; 89 90 enum gen_surface_type type; 91 uint8_t min_lod; 92 uint8_t mip_count; 93 bool is_integer; 94 95 bool readonly; 96 bool scanout; 97 }; 98 99 bool 100 ilo_state_surface_valid_format(const struct ilo_dev *dev, 101 enum ilo_state_surface_access access, 102 enum gen_surface_format format); 103 104 uint32_t 105 ilo_state_surface_buffer_size(const struct ilo_dev *dev, 106 enum ilo_state_surface_access access, 107 uint32_t size, uint32_t *alignment); 108 109 bool 110 ilo_state_surface_init_for_null(struct ilo_state_surface *surf, 111 const struct ilo_dev *dev); 112 113 bool 114 ilo_state_surface_init_for_buffer(struct ilo_state_surface *surf, 115 const struct ilo_dev *dev, 116 const struct ilo_state_surface_buffer_info *info); 117 118 bool 119 ilo_state_surface_init_for_image(struct ilo_state_surface *surf, 120 const struct ilo_dev *dev, 121 const struct ilo_state_surface_image_info *info); 122 123 bool 124 ilo_state_surface_set_scs(struct ilo_state_surface *surf, 125 const struct ilo_dev *dev, 126 enum gen_surface_scs rgba[4]); 127 128 #endif /* ILO_STATE_SURFACE_H */ 129