ilo: make ilo_fence opaque
[mesa.git] / src / gallium / drivers / ilo / ilo_gpe_gen6.h
1 /*
2 * Mesa 3-D graphics library
3 *
4 * Copyright (C) 2012-2013 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_GPE_GEN6_H
29 #define ILO_GPE_GEN6_H
30
31 #include "genhw/genhw.h"
32 #include "intel_winsys.h"
33
34 #include "ilo_common.h"
35 #include "ilo_gpe.h"
36
37 /**
38 * Translate winsys tiling to hardware tiling.
39 */
40 static inline int
41 ilo_gpe_gen6_translate_winsys_tiling(enum intel_tiling_mode tiling)
42 {
43 switch (tiling) {
44 case INTEL_TILING_NONE:
45 return GEN6_TILING_NONE;
46 case INTEL_TILING_X:
47 return GEN6_TILING_X;
48 case INTEL_TILING_Y:
49 return GEN6_TILING_Y;
50 default:
51 assert(!"unknown tiling");
52 return GEN6_TILING_NONE;
53 }
54 }
55
56 /**
57 * Translate a pipe texture target to the matching hardware surface type.
58 */
59 static inline int
60 ilo_gpe_gen6_translate_texture(enum pipe_texture_target target)
61 {
62 switch (target) {
63 case PIPE_BUFFER:
64 return GEN6_SURFTYPE_BUFFER;
65 case PIPE_TEXTURE_1D:
66 case PIPE_TEXTURE_1D_ARRAY:
67 return GEN6_SURFTYPE_1D;
68 case PIPE_TEXTURE_2D:
69 case PIPE_TEXTURE_RECT:
70 case PIPE_TEXTURE_2D_ARRAY:
71 return GEN6_SURFTYPE_2D;
72 case PIPE_TEXTURE_3D:
73 return GEN6_SURFTYPE_3D;
74 case PIPE_TEXTURE_CUBE:
75 case PIPE_TEXTURE_CUBE_ARRAY:
76 return GEN6_SURFTYPE_CUBE;
77 default:
78 assert(!"unknown texture target");
79 return GEN6_SURFTYPE_BUFFER;
80 }
81 }
82
83 static inline void
84 zs_align_surface(const struct ilo_dev_info *dev,
85 unsigned align_w, unsigned align_h,
86 struct ilo_zs_surface *zs)
87 {
88 unsigned mask, shift_w, shift_h;
89 unsigned width, height;
90 uint32_t dw3;
91
92 ILO_DEV_ASSERT(dev, 6, 7.5);
93
94 if (ilo_dev_gen(dev) >= ILO_GEN(7)) {
95 shift_w = 4;
96 shift_h = 18;
97 mask = 0x3fff;
98 }
99 else {
100 shift_w = 6;
101 shift_h = 19;
102 mask = 0x1fff;
103 }
104
105 dw3 = zs->payload[2];
106
107 /* aligned width and height */
108 width = align(((dw3 >> shift_w) & mask) + 1, align_w);
109 height = align(((dw3 >> shift_h) & mask) + 1, align_h);
110
111 dw3 = (dw3 & ~((mask << shift_w) | (mask << shift_h))) |
112 (width - 1) << shift_w |
113 (height - 1) << shift_h;
114
115 zs->payload[2] = dw3;
116 }
117
118 #endif /* ILO_GPE_GEN6_H */