~mmach/netext73/mesa-haswell

« back to all changes in this revision

Viewing changes to src/amd/vulkan/winsys/null/radv_null_winsys.c

  • Committer: mmach
  • Date: 2022-09-22 19:56:13 UTC
  • Revision ID: netbit73@gmail.com-20220922195613-wtik9mmy20tmor0i
2022-09-22 21:17:09

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright © 2020 Valve Corporation
3
 
 *
4
 
 * based on amdgpu winsys.
5
 
 * Copyright © 2016 Red Hat.
6
 
 * Copyright © 2016 Bas Nieuwenhuizen
7
 
 *
8
 
 * Permission is hereby granted, free of charge, to any person obtaining a
9
 
 * copy of this software and associated documentation files (the "Software"),
10
 
 * to deal in the Software without restriction, including without limitation
11
 
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12
 
 * and/or sell copies of the Software, and to permit persons to whom the
13
 
 * Software is furnished to do so, subject to the following conditions:
14
 
 *
15
 
 * The above copyright notice and this permission notice (including the next
16
 
 * paragraph) shall be included in all copies or substantial portions of the
17
 
 * Software.
18
 
 *
19
 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
 
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
 
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
22
 
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
 
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24
 
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25
 
 * IN THE SOFTWARE.
26
 
 */
27
 
#include "radv_null_winsys_public.h"
28
 
 
29
 
#include "util/u_string.h"
30
 
#include "radv_null_bo.h"
31
 
#include "radv_null_cs.h"
32
 
#include "vk_sync_dummy.h"
33
 
 
34
 
/* Hardcode some GPU info that are needed for the driver or for some tools. */
35
 
static const struct {
36
 
   uint32_t pci_id;
37
 
   uint32_t num_render_backends;
38
 
   bool has_dedicated_vram;
39
 
} gpu_info[] = {
40
 
   [CHIP_TAHITI] = {0x6780, 8, true},
41
 
   [CHIP_PITCAIRN] = {0x6800, 8, true},
42
 
   [CHIP_VERDE] = {0x6820, 4, true},
43
 
   [CHIP_OLAND] = {0x6060, 2, true},
44
 
   [CHIP_HAINAN] = {0x6660, 2, true},
45
 
   [CHIP_BONAIRE] = {0x6640, 4, true},
46
 
   [CHIP_KAVERI] = {0x1304, 2, false},
47
 
   [CHIP_KABINI] = {0x9830, 2, false},
48
 
   [CHIP_HAWAII] = {0x67A0, 16, true},
49
 
   [CHIP_TONGA] = {0x6920, 8, true},
50
 
   [CHIP_ICELAND] = {0x6900, 2, true},
51
 
   [CHIP_CARRIZO] = {0x9870, 2, false},
52
 
   [CHIP_FIJI] = {0x7300, 16, true},
53
 
   [CHIP_STONEY] = {0x98E4, 2, false},
54
 
   [CHIP_POLARIS10] = {0x67C0, 8, true},
55
 
   [CHIP_POLARIS11] = {0x67E0, 4, true},
56
 
   [CHIP_POLARIS12] = {0x6980, 4, true},
57
 
   [CHIP_VEGAM] = {0x694C, 4, true},
58
 
   [CHIP_VEGA10] = {0x6860, 16, true},
59
 
   [CHIP_VEGA12] = {0x69A0, 8, true},
60
 
   [CHIP_VEGA20] = {0x66A0, 16, true},
61
 
   [CHIP_RAVEN] = {0x15DD, 2, false},
62
 
   [CHIP_RENOIR] = {0x1636, 2, false},
63
 
   [CHIP_ARCTURUS] = {0x738C, 2, true},
64
 
   [CHIP_NAVI10] = {0x7310, 16, true},
65
 
   [CHIP_NAVI12] = {0x7360, 8, true},
66
 
   [CHIP_NAVI14] = {0x7340, 8, true},
67
 
   [CHIP_SIENNA_CICHLID] = {0x73A0, 16, true},
68
 
   [CHIP_VANGOGH] = {0x163F, 8, false},
69
 
   [CHIP_NAVY_FLOUNDER] = {0x73C0, 8, true},
70
 
   [CHIP_DIMGREY_CAVEFISH] = {0x73E0, 8, true},
71
 
};
72
 
 
73
 
static void
74
 
radv_null_winsys_query_info(struct radeon_winsys *rws, struct radeon_info *info)
75
 
{
76
 
   const char *family = getenv("RADV_FORCE_FAMILY");
77
 
   unsigned i;
78
 
 
79
 
   info->chip_class = CLASS_UNKNOWN;
80
 
   info->family = CHIP_UNKNOWN;
81
 
 
82
 
   for (i = CHIP_TAHITI; i < CHIP_LAST; i++) {
83
 
      if (!strcasecmp(family, ac_get_family_name(i))) {
84
 
         /* Override family and chip_class. */
85
 
         info->family = i;
86
 
         info->name = ac_get_family_name(i);
87
 
 
88
 
         if (i >= CHIP_SIENNA_CICHLID)
89
 
            info->chip_class = GFX10_3;
90
 
         else if (i >= CHIP_NAVI10)
91
 
            info->chip_class = GFX10;
92
 
         else if (i >= CHIP_VEGA10)
93
 
            info->chip_class = GFX9;
94
 
         else if (i >= CHIP_TONGA)
95
 
            info->chip_class = GFX8;
96
 
         else if (i >= CHIP_BONAIRE)
97
 
            info->chip_class = GFX7;
98
 
         else
99
 
            info->chip_class = GFX6;
100
 
      }
101
 
   }
102
 
 
103
 
   if (info->family == CHIP_UNKNOWN) {
104
 
      fprintf(stderr, "radv: Unknown family: %s\n", family);
105
 
      abort();
106
 
   }
107
 
 
108
 
   info->pci_id = gpu_info[info->family].pci_id;
109
 
   info->max_se = 4;
110
 
   info->num_se = 4;
111
 
   if (info->chip_class >= GFX10_3)
112
 
      info->max_wave64_per_simd = 16;
113
 
   else if (info->chip_class >= GFX10)
114
 
      info->max_wave64_per_simd = 20;
115
 
   else if (info->family >= CHIP_POLARIS10 && info->family <= CHIP_VEGAM)
116
 
      info->max_wave64_per_simd = 8;
117
 
   else
118
 
      info->max_wave64_per_simd = 10;
119
 
 
120
 
   if (info->chip_class >= GFX10)
121
 
      info->num_physical_sgprs_per_simd = 128 * info->max_wave64_per_simd * 2;
122
 
   else if (info->chip_class >= GFX8)
123
 
      info->num_physical_sgprs_per_simd = 800;
124
 
   else
125
 
      info->num_physical_sgprs_per_simd = 512;
126
 
 
127
 
   info->num_physical_wave64_vgprs_per_simd = info->chip_class >= GFX10 ? 512 : 256;
128
 
   info->num_simd_per_compute_unit = info->chip_class >= GFX10 ? 2 : 4;
129
 
   info->lds_size_per_workgroup = info->chip_class >= GFX10 ? 128 * 1024 : 64 * 1024;
130
 
   info->lds_encode_granularity = info->chip_class >= GFX7 ? 128 * 4 : 64 * 4;
131
 
   info->lds_alloc_granularity =
132
 
      info->chip_class >= GFX10_3 ? 256 * 4 : info->lds_encode_granularity;
133
 
   info->max_render_backends = gpu_info[info->family].num_render_backends;
134
 
 
135
 
   info->has_dedicated_vram = gpu_info[info->family].has_dedicated_vram;
136
 
   info->has_packed_math_16bit = info->chip_class >= GFX9;
137
 
 
138
 
   info->has_image_load_dcc_bug =
139
 
      info->family == CHIP_DIMGREY_CAVEFISH || info->family == CHIP_VANGOGH;
140
 
 
141
 
   info->has_accelerated_dot_product =
142
 
      info->family == CHIP_ARCTURUS || info->family == CHIP_ALDEBARAN ||
143
 
      info->family == CHIP_VEGA20 || info->family >= CHIP_NAVI12;
144
 
 
145
 
   info->address32_hi = info->chip_class >= GFX9 ? 0xffff8000u : 0x0;
146
 
 
147
 
   info->has_rbplus = info->family == CHIP_STONEY || info->chip_class >= GFX9;
148
 
   info->rbplus_allowed =
149
 
      info->has_rbplus &&
150
 
      (info->family == CHIP_STONEY || info->family == CHIP_VEGA12 || info->family == CHIP_RAVEN ||
151
 
       info->family == CHIP_RAVEN2 || info->family == CHIP_RENOIR || info->chip_class >= GFX10_3);
152
 
 
153
 
}
154
 
 
155
 
static void
156
 
radv_null_winsys_destroy(struct radeon_winsys *rws)
157
 
{
158
 
   FREE(rws);
159
 
}
160
 
 
161
 
static int
162
 
radv_null_winsys_get_fd(struct radeon_winsys *rws)
163
 
{
164
 
   return -1;
165
 
}
166
 
 
167
 
static const struct vk_sync_type *const *
168
 
radv_null_winsys_get_sync_types(struct radeon_winsys *rws)
169
 
{
170
 
   return radv_null_winsys(rws)->sync_types;
171
 
}
172
 
 
173
 
struct radeon_winsys *
174
 
radv_null_winsys_create()
175
 
{
176
 
   struct radv_null_winsys *ws;
177
 
 
178
 
   ws = calloc(1, sizeof(struct radv_null_winsys));
179
 
   if (!ws)
180
 
      return NULL;
181
 
 
182
 
   ws->base.destroy = radv_null_winsys_destroy;
183
 
   ws->base.query_info = radv_null_winsys_query_info;
184
 
   ws->base.get_fd = radv_null_winsys_get_fd;
185
 
   ws->base.get_sync_types = radv_null_winsys_get_sync_types;
186
 
   radv_null_bo_init_functions(ws);
187
 
   radv_null_cs_init_functions(ws);
188
 
 
189
 
   ws->sync_types[0] = &vk_sync_dummy_type;
190
 
   ws->sync_types[1] = NULL;
191
 
   return &ws->base;
192
 
}