deb0b549ebd51844eb9cf96dbdc5dab51973d878
[mesa.git] / src / gallium / drivers / ilo / core / ilo_state_surface.h
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 #include "intel_winsys.h"
33
34 #include "ilo_core.h"
35 #include "ilo_dev.h"
36
37 struct ilo_buffer;
38 struct ilo_image;
39
40 enum ilo_state_surface_access {
41 ILO_STATE_SURFACE_ACCESS_SAMPLER, /* sampling engine surfaces */
42 ILO_STATE_SURFACE_ACCESS_DP_RENDER, /* render target surfaces */
43 ILO_STATE_SURFACE_ACCESS_DP_TYPED, /* typed surfaces */
44 ILO_STATE_SURFACE_ACCESS_DP_UNTYPED, /* untyped surfaces */
45 ILO_STATE_SURFACE_ACCESS_DP_DATA,
46 ILO_STATE_SURFACE_ACCESS_DP_SVB,
47 };
48
49 struct ilo_state_surface_buffer_info {
50 const struct ilo_buffer *buf;
51
52 enum ilo_state_surface_access access;
53
54 enum gen_surface_format format;
55 uint8_t format_size;
56
57 bool readonly;
58 uint16_t struct_size;
59
60 uint32_t offset;
61 uint32_t size;
62 };
63
64 struct ilo_state_surface_image_info {
65 const struct ilo_image *img;
66
67 enum ilo_state_surface_access access;
68
69 enum gen_surface_format format;
70 bool is_integer;
71
72 bool readonly;
73 bool is_cube_map;
74 bool is_array;
75
76 uint8_t level_base;
77 uint8_t level_count;
78 uint16_t slice_base;
79 uint16_t slice_count;
80 };
81
82 struct ilo_state_surface {
83 uint32_t surface[13];
84
85 enum gen_surface_type type;
86 uint8_t min_lod;
87 uint8_t mip_count;
88 bool is_integer;
89
90 bool readonly;
91 bool scanout;
92
93 /* managed by users */
94 struct intel_bo *bo;
95 };
96
97 bool
98 ilo_state_surface_init_for_null(struct ilo_state_surface *surf,
99 const struct ilo_dev *dev);
100
101 bool
102 ilo_state_surface_init_for_buffer(struct ilo_state_surface *surf,
103 const struct ilo_dev *dev,
104 const struct ilo_state_surface_buffer_info *info);
105
106 bool
107 ilo_state_surface_init_for_image(struct ilo_state_surface *surf,
108 const struct ilo_dev *dev,
109 const struct ilo_state_surface_image_info *info);
110
111 bool
112 ilo_state_surface_set_scs(struct ilo_state_surface *surf,
113 const struct ilo_dev *dev,
114 enum gen_surface_scs rgba[4]);
115
116 #endif /* ILO_STATE_SURFACE_H */