~mmach/netext73/mesa-ryzen

« back to all changes in this revision

Viewing changes to src/intel/vulkan/i915/anv_device.c

  • Committer: mmach
  • Date: 2023-11-02 21:31:35 UTC
  • Revision ID: netbit73@gmail.com-20231102213135-18d4tzh7tj0uz752
2023-11-02 22:11:57

Show diffs side-by-side

added added

removed removed

Lines of Context:
126
126
}
127
127
 
128
128
VkResult
 
129
anv_i915_physical_device_init_memory_types(struct anv_physical_device *device)
 
130
{
 
131
   if (anv_physical_device_has_vram(device)) {
 
132
      device->memory.type_count = 3;
 
133
      device->memory.types[0] = (struct anv_memory_type) {
 
134
         .propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
 
135
         .heapIndex = 0,
 
136
      };
 
137
      device->memory.types[1] = (struct anv_memory_type) {
 
138
         .propertyFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
 
139
                          VK_MEMORY_PROPERTY_HOST_COHERENT_BIT |
 
140
                          VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
 
141
         .heapIndex = 1,
 
142
      };
 
143
      device->memory.types[2] = (struct anv_memory_type) {
 
144
         .propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
 
145
                          VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
 
146
                          VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
 
147
         /* This memory type either comes from heaps[0] if there is only
 
148
          * mappable vram region, or from heaps[2] if there is both mappable &
 
149
          * non-mappable vram regions.
 
150
          */
 
151
         .heapIndex = device->vram_non_mappable.size > 0 ? 2 : 0,
 
152
      };
 
153
   } else if (device->info.has_llc) {
 
154
      /* Big core GPUs share LLC with the CPU and thus one memory type can be
 
155
       * both cached and coherent at the same time.
 
156
       *
 
157
       * But some game engines can't handle single type well
 
158
       * https://gitlab.freedesktop.org/mesa/mesa/-/issues/7360#note_1719438
 
159
       *
 
160
       * The second memory type w/out HOST_CACHED_BIT will get write-combining.
 
161
       * See anv_AllocateMemory()).
 
162
       *
 
163
       * The Intel Vulkan driver for Windows also advertises these memory types.
 
164
       */
 
165
      device->memory.type_count = 3;
 
166
      device->memory.types[0] = (struct anv_memory_type) {
 
167
         .propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
 
168
         .heapIndex = 0,
 
169
      };
 
170
      device->memory.types[1] = (struct anv_memory_type) {
 
171
         .propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
 
172
                          VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
 
173
                          VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
 
174
         .heapIndex = 0,
 
175
      };
 
176
      device->memory.types[2] = (struct anv_memory_type) {
 
177
         .propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
 
178
                          VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
 
179
                          VK_MEMORY_PROPERTY_HOST_COHERENT_BIT |
 
180
                          VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
 
181
         .heapIndex = 0,
 
182
      };
 
183
   } else {
 
184
      /* The spec requires that we expose a host-visible, coherent memory
 
185
       * type, but Atom GPUs don't share LLC. Thus we offer two memory types
 
186
       * to give the application a choice between cached, but not coherent and
 
187
       * coherent but uncached (WC though).
 
188
       */
 
189
      device->memory.type_count = 2;
 
190
      device->memory.types[0] = (struct anv_memory_type) {
 
191
         .propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
 
192
                          VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
 
193
                          VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
 
194
         .heapIndex = 0,
 
195
      };
 
196
      device->memory.types[1] = (struct anv_memory_type) {
 
197
         .propertyFlags = VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT |
 
198
                          VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
 
199
                          VK_MEMORY_PROPERTY_HOST_CACHED_BIT,
 
200
         .heapIndex = 0,
 
201
      };
 
202
   }
 
203
 
 
204
   return VK_SUCCESS;
 
205
}
 
206
 
 
207
VkResult
129
208
anv_i915_device_setup_context(struct anv_device *device,
130
209
                              const VkDeviceCreateInfo *pCreateInfo,
131
210
                              const uint32_t num_queues)
150
229
         for (uint32_t j = 0; j < queueCreateInfo->queueCount; j++)
151
230
            engine_classes[engine_count++] = queue_family->engine_class;
152
231
      }
153
 
      if (!intel_gem_create_context_engines(device->fd,
 
232
      if (!intel_gem_create_context_engines(device->fd, 0 /* flags */,
154
233
                                            physical_device->engine_info,
155
234
                                            engine_count, engine_classes,
156
235
                                            (uint32_t *)&device->context_id))