2 * Copyright © 2016 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
24 #include "anv_private.h"
27 lookup_blorp_shader(struct blorp_context
*blorp
,
28 const void *key
, uint32_t key_size
,
29 uint32_t *kernel_out
, void *prog_data_out
)
31 struct anv_device
*device
= blorp
->driver_ctx
;
33 /* The blorp cache must be a real cache */
34 assert(device
->blorp_shader_cache
.cache
);
36 struct anv_shader_bin
*bin
=
37 anv_pipeline_cache_search(&device
->blorp_shader_cache
, key
, key_size
);
41 /* The cache already has a reference and it's not going anywhere so there
42 * is no need to hold a second reference.
44 anv_shader_bin_unref(device
, bin
);
46 *kernel_out
= bin
->kernel
.offset
;
47 *(const struct brw_stage_prog_data
**)prog_data_out
=
48 anv_shader_bin_get_prog_data(bin
);
54 upload_blorp_shader(struct blorp_context
*blorp
,
55 const void *key
, uint32_t key_size
,
56 const void *kernel
, uint32_t kernel_size
,
57 const void *prog_data
, uint32_t prog_data_size
,
58 uint32_t *kernel_out
, void *prog_data_out
)
60 struct anv_device
*device
= blorp
->driver_ctx
;
62 /* The blorp cache must be a real cache */
63 assert(device
->blorp_shader_cache
.cache
);
65 struct anv_pipeline_bind_map bind_map
= {
70 struct anv_shader_bin
*bin
=
71 anv_pipeline_cache_upload_kernel(&device
->blorp_shader_cache
,
72 key
, key_size
, kernel
, kernel_size
,
73 prog_data
, prog_data_size
, &bind_map
);
75 /* The cache already has a reference and it's not going anywhere so there
76 * is no need to hold a second reference.
78 anv_shader_bin_unref(device
, bin
);
80 *kernel_out
= bin
->kernel
.offset
;
81 *(const struct brw_stage_prog_data
**)prog_data_out
=
82 anv_shader_bin_get_prog_data(bin
);
86 anv_device_init_blorp(struct anv_device
*device
)
88 anv_pipeline_cache_init(&device
->blorp_shader_cache
, device
, true);
89 blorp_init(&device
->blorp
, device
, &device
->isl_dev
);
90 device
->blorp
.compiler
= device
->instance
->physicalDevice
.compiler
;
91 device
->blorp
.mocs
.tex
= device
->default_mocs
;
92 device
->blorp
.mocs
.rb
= device
->default_mocs
;
93 device
->blorp
.mocs
.vb
= device
->default_mocs
;
94 device
->blorp
.lookup_shader
= lookup_blorp_shader
;
95 device
->blorp
.upload_shader
= upload_blorp_shader
;
96 switch (device
->info
.gen
) {
98 if (device
->info
.is_haswell
) {
99 device
->blorp
.exec
= gen75_blorp_exec
;
101 device
->blorp
.exec
= gen7_blorp_exec
;
105 device
->blorp
.exec
= gen8_blorp_exec
;
108 device
->blorp
.exec
= gen9_blorp_exec
;
111 unreachable("Unknown hardware generation");
116 anv_device_finish_blorp(struct anv_device
*device
)
118 blorp_finish(&device
->blorp
);
119 anv_pipeline_cache_finish(&device
->blorp_shader_cache
);