mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-24 03:18:25 +02:00
panvk: Move desc_info to panvk_shader
Once we start actually compiling variants, it's going to be much more convenient if we only have one descriptor table per logical shader. All the variants can fetch from the one set of tables. We can't duplicate push, however, because that depends on the behavior of the back-end compiler and might be different per-variant. Signed-off-by: Olivia Lee <olivia.lee@collabora.com> Reviewed-by: Eric R. Smith <eric.smith@collabora.com> Reviewed-by: Christian Gmeiner <cgmeiner@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41654>
This commit is contained in:
parent
b894d88c38
commit
960444ff46
8 changed files with 118 additions and 79 deletions
|
|
@ -35,18 +35,17 @@
|
|||
static VkResult
|
||||
prepare_driver_set(struct panvk_cmd_buffer *cmdbuf)
|
||||
{
|
||||
struct panvk_shader_desc_state *cs_desc_state =
|
||||
&cmdbuf->state.compute.cs.desc;
|
||||
|
||||
if (!compute_state_dirty(cmdbuf, CS) &&
|
||||
!compute_state_dirty(cmdbuf, DESC_STATE))
|
||||
return VK_SUCCESS;
|
||||
|
||||
const struct panvk_shader_desc_info *cs_desc_info =
|
||||
&cmdbuf->state.compute.shader->desc_info;
|
||||
const struct panvk_descriptor_state *desc_state =
|
||||
&cmdbuf->state.compute.desc_state;
|
||||
const struct panvk_shader_variant *cs =
|
||||
panvk_shader_only_variant(cmdbuf->state.compute.shader);
|
||||
uint32_t desc_count = cs->desc_info.dyn_bufs.count + 1;
|
||||
struct panvk_shader_desc_state *cs_desc_state =
|
||||
&cmdbuf->state.compute.cs.desc;
|
||||
uint32_t desc_count = cs_desc_info->dyn_bufs.count + 1;
|
||||
struct pan_ptr driver_set = panvk_cmd_alloc_dev_mem(
|
||||
cmdbuf, desc, desc_count * PANVK_DESCRIPTOR_SIZE, PANVK_DESCRIPTOR_SIZE);
|
||||
struct panvk_opaque_desc *descs = driver_set.cpu;
|
||||
|
|
@ -59,7 +58,7 @@ prepare_driver_set(struct panvk_cmd_buffer *cmdbuf)
|
|||
cfg.clamp_integer_array_indices = false;
|
||||
}
|
||||
|
||||
panvk_per_arch(cmd_fill_dyn_bufs)(desc_state, &cs->desc_info,
|
||||
panvk_per_arch(cmd_fill_dyn_bufs)(desc_state, cs_desc_info,
|
||||
(struct mali_buffer_packed *)(&descs[1]));
|
||||
|
||||
cs_desc_state->driver_set.dev_addr = driver_set.gpu;
|
||||
|
|
@ -133,6 +132,8 @@ cmd_dispatch(struct panvk_cmd_buffer *cmdbuf, struct panvk_dispatch_info *info)
|
|||
|
||||
struct panvk_physical_device *phys_dev =
|
||||
to_panvk_physical_device(cmdbuf->vk.base.device->physical);
|
||||
const struct panvk_shader_desc_info *cs_desc_info =
|
||||
&cmdbuf->state.compute.shader->desc_info;
|
||||
struct panvk_descriptor_state *desc_state =
|
||||
&cmdbuf->state.compute.desc_state;
|
||||
struct panvk_shader_desc_state *cs_desc_state =
|
||||
|
|
@ -161,7 +162,7 @@ cmd_dispatch(struct panvk_cmd_buffer *cmdbuf, struct panvk_dispatch_info *info)
|
|||
if (compute_state_dirty(cmdbuf, DESC_STATE) ||
|
||||
compute_state_dirty(cmdbuf, CS)) {
|
||||
result = panvk_per_arch(cmd_prepare_push_descs)(
|
||||
cmdbuf, desc_state, cs->desc_info.used_set_mask);
|
||||
cmdbuf, desc_state, cs_desc_info->used_set_mask);
|
||||
if (result != VK_SUCCESS)
|
||||
return;
|
||||
}
|
||||
|
|
@ -179,7 +180,7 @@ cmd_dispatch(struct panvk_cmd_buffer *cmdbuf, struct panvk_dispatch_info *info)
|
|||
if (compute_state_dirty(cmdbuf, CS) ||
|
||||
compute_state_dirty(cmdbuf, DESC_STATE)) {
|
||||
result = panvk_per_arch(cmd_prepare_shader_res_table)(
|
||||
cmdbuf, desc_state, &cs->desc_info, cs_desc_state, 1);
|
||||
cmdbuf, desc_state, cs_desc_info, cs_desc_state, 1);
|
||||
if (result != VK_SUCCESS)
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -273,12 +273,13 @@ vs_driver_set_is_dirty(struct panvk_cmd_buffer *cmdbuf)
|
|||
|
||||
static VkResult
|
||||
prepare_vs_driver_set(struct panvk_cmd_buffer *cmdbuf,
|
||||
const struct panvk_draw_info *draw,
|
||||
const struct panvk_shader_variant *vs)
|
||||
const struct panvk_draw_info *draw)
|
||||
{
|
||||
if (!vs_driver_set_is_dirty(cmdbuf))
|
||||
return VK_SUCCESS;
|
||||
|
||||
const struct panvk_shader_desc_info *vs_desc_info =
|
||||
&cmdbuf->state.gfx.vs.shader->desc_info;
|
||||
struct panvk_shader_desc_state *vs_desc_state = &cmdbuf->state.gfx.vs.desc;
|
||||
const struct vk_dynamic_graphics_state *dyns =
|
||||
&cmdbuf->vk.dynamic_graphics_state;
|
||||
|
|
@ -300,7 +301,7 @@ prepare_vs_driver_set(struct panvk_cmd_buffer *cmdbuf,
|
|||
vb_count = MAX2(vi->attributes[i].binding + 1, vb_count);
|
||||
}
|
||||
|
||||
uint32_t vb_offset = vs->desc_info.dyn_bufs.count + MAX_VS_ATTRIBS + 1;
|
||||
uint32_t vb_offset = vs_desc_info->dyn_bufs.count + MAX_VS_ATTRIBS + 1;
|
||||
uint32_t desc_count = vb_offset + vb_count;
|
||||
uint32_t repeat_count = 1;
|
||||
|
||||
|
|
@ -336,7 +337,7 @@ prepare_vs_driver_set(struct panvk_cmd_buffer *cmdbuf,
|
|||
}
|
||||
|
||||
panvk_per_arch(cmd_fill_dyn_bufs)(
|
||||
desc_state, &vs->desc_info,
|
||||
desc_state, vs_desc_info,
|
||||
(struct mali_buffer_packed *)(&descs[MAX_VS_ATTRIBS + 1]));
|
||||
|
||||
for (uint32_t i = 0; i < vb_count; i++) {
|
||||
|
|
@ -417,16 +418,16 @@ emit_varying_descs(const struct panvk_cmd_buffer *cmdbuf,
|
|||
static VkResult
|
||||
prepare_fs_driver_set(struct panvk_cmd_buffer *cmdbuf)
|
||||
{
|
||||
const struct panvk_shader_desc_info *fs_desc_info =
|
||||
&cmdbuf->state.gfx.fs.shader->desc_info;
|
||||
struct panvk_shader_desc_state *fs_desc_state = &cmdbuf->state.gfx.fs.desc;
|
||||
const struct panvk_shader_variant *fs =
|
||||
panvk_shader_only_variant(cmdbuf->state.gfx.fs.shader);
|
||||
const struct panvk_descriptor_state *desc_state =
|
||||
&cmdbuf->state.gfx.desc_state;
|
||||
/* If the shader is using LD_VAR_BUF[_IMM], we do not have to set up
|
||||
* Attribute Descriptors for varying loads. */
|
||||
const uint32_t desc_count =
|
||||
fs->desc_info.fs_varying_attr_desc_count +
|
||||
fs->desc_info.dyn_bufs.count + 1;
|
||||
fs_desc_info->fs_varying_attr_desc_count +
|
||||
fs_desc_info->dyn_bufs.count + 1;
|
||||
struct pan_ptr driver_set = panvk_cmd_alloc_dev_mem(
|
||||
cmdbuf, desc, desc_count * PANVK_DESCRIPTOR_SIZE, PANVK_DESCRIPTOR_SIZE);
|
||||
struct panvk_opaque_desc *descs = driver_set.cpu;
|
||||
|
|
@ -434,17 +435,17 @@ prepare_fs_driver_set(struct panvk_cmd_buffer *cmdbuf)
|
|||
if (desc_count && !driver_set.gpu)
|
||||
return VK_ERROR_OUT_OF_DEVICE_MEMORY;
|
||||
|
||||
if (fs->desc_info.fs_varying_attr_desc_count > 0)
|
||||
if (fs_desc_info->fs_varying_attr_desc_count > 0)
|
||||
emit_varying_descs(cmdbuf, (struct mali_attribute_packed *)(&descs[0]));
|
||||
|
||||
/* Dummy sampler always comes right after the varyings. */
|
||||
const uint32_t sampler_idx = fs->desc_info.fs_varying_attr_desc_count;
|
||||
const uint32_t sampler_idx = fs_desc_info->fs_varying_attr_desc_count;
|
||||
pan_cast_and_pack(&descs[sampler_idx], SAMPLER, cfg) {
|
||||
cfg.clamp_integer_array_indices = false;
|
||||
}
|
||||
|
||||
panvk_per_arch(cmd_fill_dyn_bufs)(
|
||||
desc_state, &fs->desc_info,
|
||||
desc_state, fs_desc_info,
|
||||
(struct mali_buffer_packed *)(&descs[sampler_idx + 1]));
|
||||
|
||||
fs_desc_state->driver_set.dev_addr = driver_set.gpu;
|
||||
|
|
@ -1715,12 +1716,15 @@ prepare_vs(struct panvk_cmd_buffer *cmdbuf, const struct panvk_draw_info *draw,
|
|||
panvk_get_cs_builder(cmdbuf, PANVK_SUBQUEUE_VERTEX_TILER);
|
||||
bool upd_res_table = false;
|
||||
|
||||
VkResult result = prepare_vs_driver_set(cmdbuf, draw, vs);
|
||||
VkResult result = prepare_vs_driver_set(cmdbuf, draw);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
if (gfx_state_dirty(cmdbuf, VS) || gfx_state_dirty(cmdbuf, DESC_STATE) ||
|
||||
vs_driver_set_is_dirty(cmdbuf)) {
|
||||
const struct panvk_shader_desc_info *vs_desc_info =
|
||||
&cmdbuf->state.gfx.vs.shader->desc_info;
|
||||
|
||||
uint32_t repeat_count = 1;
|
||||
|
||||
if (draw->indirect.draw_count > 1 &&
|
||||
|
|
@ -1728,7 +1732,7 @@ prepare_vs(struct panvk_cmd_buffer *cmdbuf, const struct panvk_draw_info *draw,
|
|||
repeat_count = draw->indirect.draw_count;
|
||||
|
||||
result = panvk_per_arch(cmd_prepare_shader_res_table)(
|
||||
cmdbuf, desc_state, &vs->desc_info, vs_desc_state, repeat_count);
|
||||
cmdbuf, desc_state, vs_desc_info, vs_desc_state, repeat_count);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
|
|
@ -1781,12 +1785,16 @@ prepare_fs(struct panvk_cmd_buffer *cmdbuf,
|
|||
(gfx_state_dirty(cmdbuf, VS) ||
|
||||
gfx_state_dirty(cmdbuf, FS) ||
|
||||
gfx_state_dirty(cmdbuf, DESC_STATE))) {
|
||||
|
||||
const struct panvk_shader_desc_info *fs_desc_info =
|
||||
&cmdbuf->state.gfx.fs.shader->desc_info;
|
||||
|
||||
VkResult result = prepare_fs_driver_set(cmdbuf);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
result = panvk_per_arch(cmd_prepare_shader_res_table)(
|
||||
cmdbuf, desc_state, &fs->desc_info, fs_desc_state, 1);
|
||||
cmdbuf, desc_state, fs_desc_info, fs_desc_state, 1);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
}
|
||||
|
|
@ -2479,8 +2487,14 @@ prepare_draw(struct panvk_cmd_buffer *cmdbuf, struct panvk_draw_info *draw)
|
|||
struct cs_builder *b =
|
||||
panvk_get_cs_builder(cmdbuf, PANVK_SUBQUEUE_VERTEX_TILER);
|
||||
|
||||
uint32_t used_set_mask =
|
||||
vs->desc_info.used_set_mask | (fs ? fs->desc_info.used_set_mask : 0);
|
||||
const struct panvk_shader_desc_info *vs_desc_info =
|
||||
&cmdbuf->state.gfx.vs.shader->desc_info;
|
||||
uint32_t used_set_mask = vs_desc_info->used_set_mask;
|
||||
if (fs) {
|
||||
const struct panvk_shader_desc_info *fs_desc_info =
|
||||
&cmdbuf->state.gfx.fs.shader->desc_info;
|
||||
used_set_mask |= fs_desc_info->used_set_mask;
|
||||
}
|
||||
|
||||
if (gfx_state_dirty(cmdbuf, DESC_STATE) || gfx_state_dirty(cmdbuf, VS) ||
|
||||
gfx_state_dirty(cmdbuf, FS)) {
|
||||
|
|
@ -4123,6 +4137,10 @@ panvk_per_arch(cmd_draw_fullscreen)(struct vk_command_buffer *cmd,
|
|||
panvk_shader_hw_variant(cmdbuf->state.gfx.vs.shader);
|
||||
const struct panvk_shader_variant *fs =
|
||||
panvk_shader_only_variant(get_fs(cmdbuf));
|
||||
const struct panvk_shader_desc_info *vs_desc_info =
|
||||
&cmdbuf->state.gfx.vs.shader->desc_info;
|
||||
const struct panvk_shader_desc_info *fs_desc_info =
|
||||
fs ? &cmdbuf->state.gfx.fs.shader->desc_info : 0;
|
||||
const bool depth_write_enable =
|
||||
cmdbuf->vk.dynamic_graphics_state.ds.depth.write_enable;
|
||||
const bool fixed_func_depth_write =
|
||||
|
|
@ -4144,7 +4162,7 @@ panvk_per_arch(cmd_draw_fullscreen)(struct vk_command_buffer *cmd,
|
|||
if (gfx_state_dirty(cmdbuf, DESC_STATE) || gfx_state_dirty(cmdbuf, VS) ||
|
||||
gfx_state_dirty(cmdbuf, FS)) {
|
||||
uint32_t used_set_mask =
|
||||
vs->desc_info.used_set_mask | (fs ? fs->desc_info.used_set_mask : 0);
|
||||
vs_desc_info->used_set_mask | (fs ? fs_desc_info->used_set_mask : 0);
|
||||
struct panvk_descriptor_state *desc_state = &cmdbuf->state.gfx.desc_state;
|
||||
|
||||
result = panvk_per_arch(cmd_prepare_push_descs)(cmdbuf, desc_state,
|
||||
|
|
|
|||
|
|
@ -74,6 +74,8 @@ cmd_dispatch(struct panvk_cmd_buffer *cmdbuf, struct panvk_dispatch_info *info)
|
|||
panvk_per_arch(cmd_close_batch)(cmdbuf);
|
||||
struct panvk_batch *batch = panvk_per_arch(cmd_open_batch)(cmdbuf);
|
||||
|
||||
const struct panvk_shader_desc_info *cs_desc_info =
|
||||
&cmdbuf->state.compute.shader->desc_info;
|
||||
struct panvk_descriptor_state *desc_state =
|
||||
&cmdbuf->state.compute.desc_state;
|
||||
struct panvk_shader_desc_state *cs_desc_state =
|
||||
|
|
@ -89,7 +91,7 @@ cmd_dispatch(struct panvk_cmd_buffer *cmdbuf, struct panvk_dispatch_info *info)
|
|||
&wg_count, indirect);
|
||||
|
||||
result = panvk_per_arch(cmd_prepare_push_descs)(
|
||||
cmdbuf, desc_state, cs->desc_info.used_set_mask);
|
||||
cmdbuf, desc_state, cs_desc_info->used_set_mask);
|
||||
if (result != VK_SUCCESS)
|
||||
return;
|
||||
|
||||
|
|
@ -98,17 +100,17 @@ cmd_dispatch(struct panvk_cmd_buffer *cmdbuf, struct panvk_dispatch_info *info)
|
|||
if (compute_state_dirty(cmdbuf, CS) ||
|
||||
compute_state_dirty(cmdbuf, DESC_STATE)) {
|
||||
result = panvk_per_arch(cmd_prepare_shader_desc_tables)(
|
||||
cmdbuf, desc_state, &cs->desc_info, true, cs_desc_state);
|
||||
cmdbuf, desc_state, cs_desc_info, true, cs_desc_state);
|
||||
if (result != VK_SUCCESS)
|
||||
return;
|
||||
|
||||
result = panvk_per_arch(cmd_prepare_dyn_ssbos)(
|
||||
cmdbuf, desc_state, &cs->desc_info, cs_desc_state);
|
||||
cmdbuf, desc_state, cs_desc_info, cs_desc_state);
|
||||
if (result != VK_SUCCESS)
|
||||
return;
|
||||
|
||||
result = panvk_per_arch(meta_get_copy_desc_job)(
|
||||
cmdbuf, &cs->desc_info, &cmdbuf->state.compute.desc_state,
|
||||
cmdbuf, cs_desc_info, &cmdbuf->state.compute.desc_state,
|
||||
cs_desc_state, 0, ©_desc_job);
|
||||
if (result != VK_SUCCESS)
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -615,8 +615,7 @@ static VkResult
|
|||
panvk_draw_prepare_vs_attribs(struct panvk_cmd_buffer *cmdbuf,
|
||||
struct panvk_draw_data *draw)
|
||||
{
|
||||
const struct panvk_shader_variant *vs =
|
||||
panvk_shader_hw_variant(cmdbuf->state.gfx.vs.shader);
|
||||
const struct panvk_shader *vs = cmdbuf->state.gfx.vs.shader;
|
||||
const struct vk_dynamic_graphics_state *dyns =
|
||||
&cmdbuf->vk.dynamic_graphics_state;
|
||||
const struct vk_vertex_input_state *vi = dyns->vi;
|
||||
|
|
@ -1084,14 +1083,15 @@ panvk_draw_prepare_tiler_job(struct panvk_cmd_buffer *cmdbuf,
|
|||
struct panvk_draw_data *draw)
|
||||
{
|
||||
struct panvk_batch *batch = cmdbuf->cur_batch;
|
||||
const struct panvk_shader_variant *fs =
|
||||
panvk_shader_only_variant(cmdbuf->state.gfx.fs.shader);
|
||||
struct panvk_shader_desc_state *fs_desc_state = &cmdbuf->state.gfx.fs.desc;
|
||||
struct pan_ptr ptr;
|
||||
|
||||
if (fs) {
|
||||
if (cmdbuf->state.gfx.fs.required) {
|
||||
const struct panvk_shader_desc_info *fs_desc_info =
|
||||
&cmdbuf->state.gfx.fs.shader->desc_info;
|
||||
struct panvk_shader_desc_state *fs_desc_state =
|
||||
&cmdbuf->state.gfx.fs.desc;
|
||||
VkResult result = panvk_per_arch(meta_get_copy_desc_job)(
|
||||
cmdbuf, &fs->desc_info, &cmdbuf->state.gfx.desc_state,
|
||||
cmdbuf, fs_desc_info, &cmdbuf->state.gfx.desc_state,
|
||||
fs_desc_state, 0, &ptr);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
|
@ -1173,8 +1173,8 @@ panvk_draw_prepare_vs_copy_desc_job(struct panvk_cmd_buffer *cmdbuf,
|
|||
struct panvk_draw_data *draw)
|
||||
{
|
||||
struct panvk_batch *batch = cmdbuf->cur_batch;
|
||||
const struct panvk_shader_variant *vs =
|
||||
panvk_shader_hw_variant(cmdbuf->state.gfx.vs.shader);
|
||||
const struct panvk_shader_desc_info *vs_desc_info =
|
||||
&cmdbuf->state.gfx.vs.shader->desc_info;
|
||||
const struct panvk_shader_desc_state *vs_desc_state =
|
||||
&cmdbuf->state.gfx.vs.desc;
|
||||
const struct vk_vertex_input_state *vi =
|
||||
|
|
@ -1183,7 +1183,7 @@ panvk_draw_prepare_vs_copy_desc_job(struct panvk_cmd_buffer *cmdbuf,
|
|||
struct pan_ptr ptr;
|
||||
|
||||
VkResult result = panvk_per_arch(meta_get_copy_desc_job)(
|
||||
cmdbuf, &vs->desc_info, &cmdbuf->state.gfx.desc_state, vs_desc_state,
|
||||
cmdbuf, vs_desc_info, &cmdbuf->state.gfx.desc_state, vs_desc_state,
|
||||
num_vbs * pan_size(ATTRIBUTE_BUFFER) * 2, &ptr);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
|
@ -1200,14 +1200,14 @@ static VkResult
|
|||
panvk_draw_prepare_fs_copy_desc_job(struct panvk_cmd_buffer *cmdbuf,
|
||||
struct panvk_draw_data *draw)
|
||||
{
|
||||
const struct panvk_shader_variant *fs =
|
||||
panvk_shader_only_variant(cmdbuf->state.gfx.fs.shader);
|
||||
const struct panvk_shader_desc_info *fs_desc_info =
|
||||
&cmdbuf->state.gfx.fs.shader->desc_info;
|
||||
struct panvk_shader_desc_state *fs_desc_state = &cmdbuf->state.gfx.fs.desc;
|
||||
struct panvk_batch *batch = cmdbuf->cur_batch;
|
||||
struct pan_ptr ptr;
|
||||
|
||||
VkResult result = panvk_per_arch(meta_get_copy_desc_job)(
|
||||
cmdbuf, &fs->desc_info, &cmdbuf->state.gfx.desc_state,
|
||||
cmdbuf, fs_desc_info, &cmdbuf->state.gfx.desc_state,
|
||||
fs_desc_state, 0, &ptr);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
|
@ -1321,8 +1321,13 @@ prepare_draw(struct panvk_cmd_buffer *cmdbuf, struct panvk_draw_data *draw)
|
|||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
const struct panvk_shader_desc_info *vs_desc_info =
|
||||
&cmdbuf->state.gfx.vs.shader->desc_info;
|
||||
const struct panvk_shader_desc_info *fs_desc_info =
|
||||
fs ? &cmdbuf->state.gfx.fs.shader->desc_info : NULL;
|
||||
|
||||
uint32_t used_set_mask =
|
||||
vs->desc_info.used_set_mask | (fs ? fs->desc_info.used_set_mask : 0);
|
||||
vs_desc_info->used_set_mask | (fs ? fs_desc_info->used_set_mask : 0);
|
||||
|
||||
if (gfx_state_dirty(cmdbuf, DESC_STATE) || gfx_state_dirty(cmdbuf, VS) ||
|
||||
gfx_state_dirty(cmdbuf, FS)) {
|
||||
|
|
@ -1334,12 +1339,12 @@ prepare_draw(struct panvk_cmd_buffer *cmdbuf, struct panvk_draw_data *draw)
|
|||
|
||||
if (gfx_state_dirty(cmdbuf, DESC_STATE) || gfx_state_dirty(cmdbuf, VS)) {
|
||||
result = panvk_per_arch(cmd_prepare_shader_desc_tables)(
|
||||
cmdbuf, desc_state, &vs->desc_info, false, vs_desc_state);
|
||||
cmdbuf, desc_state, vs_desc_info, false, vs_desc_state);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
result = panvk_per_arch(cmd_prepare_dyn_ssbos)(
|
||||
cmdbuf, desc_state, &vs->desc_info, vs_desc_state);
|
||||
cmdbuf, desc_state, vs_desc_info, vs_desc_state);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
}
|
||||
|
|
@ -1361,12 +1366,12 @@ prepare_draw(struct panvk_cmd_buffer *cmdbuf, struct panvk_draw_data *draw)
|
|||
memset(fs_desc_state, 0, sizeof(*fs_desc_state));
|
||||
} else {
|
||||
result = panvk_per_arch(cmd_prepare_shader_desc_tables)(
|
||||
cmdbuf, desc_state, &fs->desc_info, true, fs_desc_state);
|
||||
cmdbuf, desc_state, fs_desc_info, true, fs_desc_state);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
result = panvk_per_arch(cmd_prepare_dyn_ssbos)(
|
||||
cmdbuf, desc_state, &fs->desc_info, fs_desc_state);
|
||||
cmdbuf, desc_state, fs_desc_info, fs_desc_state);
|
||||
if (result != VK_SUCCESS)
|
||||
return result;
|
||||
|
||||
|
|
|
|||
|
|
@ -398,8 +398,6 @@ struct panvk_shader_variant {
|
|||
} fs;
|
||||
};
|
||||
|
||||
struct panvk_shader_desc_info desc_info;
|
||||
|
||||
struct panvk_shader_fau_info fau;
|
||||
|
||||
const void *bin_ptr;
|
||||
|
|
@ -440,6 +438,8 @@ enum panvk_vs_variant {
|
|||
struct panvk_shader {
|
||||
struct vk_shader vk;
|
||||
|
||||
struct panvk_shader_desc_info desc_info;
|
||||
|
||||
struct panvk_shader_variant variants[];
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -44,6 +44,8 @@ panvk_per_arch(cmd_prepare_dispatch_sysvals)(
|
|||
cs->cs.local_size.z);
|
||||
|
||||
#if PAN_ARCH < 9
|
||||
const struct panvk_shader_desc_info *cs_desc_info =
|
||||
&cmdbuf->state.compute.shader->desc_info;
|
||||
struct panvk_descriptor_state *desc_state =
|
||||
&cmdbuf->state.compute.desc_state;
|
||||
struct panvk_shader_desc_state *cs_desc_state =
|
||||
|
|
@ -57,7 +59,7 @@ panvk_per_arch(cmd_prepare_dispatch_sysvals)(
|
|||
}
|
||||
|
||||
for (uint32_t i = 0; i < MAX_SETS; i++) {
|
||||
if (cs->desc_info.used_set_mask & BITFIELD_BIT(i)) {
|
||||
if (cs_desc_info->used_set_mask & BITFIELD_BIT(i)) {
|
||||
set_compute_sysval(cmdbuf, dirty_sysvals, desc.sets[i],
|
||||
desc_state->sets[i]->descs.dev);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -938,10 +938,12 @@ panvk_per_arch(cmd_prepare_draw_sysvals)(struct panvk_cmd_buffer *cmdbuf,
|
|||
fs_desc_state->dyn_ssbos);
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < MAX_SETS; i++) {
|
||||
uint32_t used_set_mask =
|
||||
vs->desc_info.used_set_mask | (fs ? fs->desc_info.used_set_mask : 0);
|
||||
uint32_t used_set_mask = 0;
|
||||
used_set_mask |= cmdbuf->state.gfx.vs.shader->desc_info.used_set_mask;
|
||||
if (fs)
|
||||
used_set_mask |= cmdbuf->state.gfx.fs.shader->desc_info.used_set_mask;
|
||||
|
||||
for (uint32_t i = 0; i < MAX_SETS; i++) {
|
||||
if (used_set_mask & BITFIELD_BIT(i)) {
|
||||
set_gfx_sysval(cmdbuf, dirty_sysvals, desc.sets[i],
|
||||
desc_state->sets[i]->descs.dev);
|
||||
|
|
|
|||
|
|
@ -955,6 +955,7 @@ panvk_compile_nir(struct panvk_device *dev, nir_shader *nir,
|
|||
const struct pan_compile_inputs *compile_input,
|
||||
const struct vk_graphics_pipeline_state *state,
|
||||
const uint32_t *noperspective_varyings,
|
||||
struct panvk_shader_desc_info *desc_info,
|
||||
struct panvk_shader_variant *shader)
|
||||
{
|
||||
const bool dump_asm =
|
||||
|
|
@ -1050,12 +1051,12 @@ panvk_compile_nir(struct panvk_device *dev, nir_shader *nir,
|
|||
#if PAN_ARCH < 9
|
||||
/* Patch the descriptor count */
|
||||
shader->info.ubo_count =
|
||||
shader->desc_info.others.count[PANVK_BIFROST_DESC_TABLE_UBO] +
|
||||
shader->desc_info.dyn_ubos.count;
|
||||
desc_info->others.count[PANVK_BIFROST_DESC_TABLE_UBO] +
|
||||
desc_info->dyn_ubos.count;
|
||||
shader->info.texture_count =
|
||||
shader->desc_info.others.count[PANVK_BIFROST_DESC_TABLE_TEXTURE];
|
||||
desc_info->others.count[PANVK_BIFROST_DESC_TABLE_TEXTURE];
|
||||
shader->info.sampler_count =
|
||||
shader->desc_info.others.count[PANVK_BIFROST_DESC_TABLE_SAMPLER];
|
||||
desc_info->others.count[PANVK_BIFROST_DESC_TABLE_SAMPLER];
|
||||
|
||||
/* Dummy sampler. */
|
||||
if (!shader->info.sampler_count && shader->info.texture_count)
|
||||
|
|
@ -1080,9 +1081,9 @@ panvk_compile_nir(struct panvk_device *dev, nir_shader *nir,
|
|||
/* Image attributes start at MAX_VS_ATTRIBS in the VS attribute table,
|
||||
* and zero in other stages.
|
||||
*/
|
||||
if (shader->desc_info.others.count[PANVK_BIFROST_DESC_TABLE_IMG] > 0)
|
||||
if (desc_info->others.count[PANVK_BIFROST_DESC_TABLE_IMG] > 0)
|
||||
shader->info.attribute_count =
|
||||
shader->desc_info.others.count[PANVK_BIFROST_DESC_TABLE_IMG] +
|
||||
desc_info->others.count[PANVK_BIFROST_DESC_TABLE_IMG] +
|
||||
(nir->info.stage == MESA_SHADER_VERTEX ? MAX_VS_ATTRIBS : 0);
|
||||
#endif
|
||||
|
||||
|
|
@ -1283,7 +1284,6 @@ panvk_shader_variant_destroy(struct panvk_shader_variant *shader)
|
|||
|
||||
#if PAN_ARCH < 9
|
||||
panvk_pool_free_mem(&shader->rsd);
|
||||
panvk_pool_free_mem(&shader->desc_info.others.map);
|
||||
#else
|
||||
if (shader->info.stage != MESA_SHADER_VERTEX) {
|
||||
panvk_pool_free_mem(&shader->spd);
|
||||
|
|
@ -1314,6 +1314,10 @@ panvk_shader_destroy(struct vk_device *vk_dev, struct vk_shader *vk_shader,
|
|||
panvk_shader_variant_destroy(variant);
|
||||
}
|
||||
|
||||
#if PAN_ARCH < 9
|
||||
panvk_pool_free_mem(&shader->desc_info.others.map);
|
||||
#endif
|
||||
|
||||
vk_shader_free(vk_dev, pAllocator, &shader->vk);
|
||||
}
|
||||
|
||||
|
|
@ -1392,7 +1396,7 @@ panvk_compile_shader(struct panvk_device *dev,
|
|||
|
||||
panvk_lower_nir(dev, nir, info->set_layout_count,
|
||||
info->set_layouts, info->robustness,
|
||||
state, &variant->desc_info, false);
|
||||
state, &shader->desc_info, false);
|
||||
|
||||
/* We need the driver_location to match the vertex attribute
|
||||
* location, so we can use the attribute layout described by
|
||||
|
|
@ -1424,7 +1428,8 @@ panvk_compile_shader(struct panvk_device *dev,
|
|||
variant->own_bin = true;
|
||||
|
||||
result = panvk_compile_nir(dev, nir, info->flags, &inputs, state,
|
||||
noperspective_varyings, variant);
|
||||
noperspective_varyings,
|
||||
&shader->desc_info, variant);
|
||||
|
||||
/* If we cloned, it's our job to clean up */
|
||||
if (clone_nir)
|
||||
|
|
@ -1466,7 +1471,7 @@ panvk_compile_shader(struct panvk_device *dev,
|
|||
inputs.varying_layout = vs_varying_layout;
|
||||
|
||||
panvk_lower_nir(dev, nir, info->set_layout_count, info->set_layouts,
|
||||
info->robustness, state, &variant->desc_info, false);
|
||||
info->robustness, state, &shader->desc_info, false);
|
||||
|
||||
nir_assign_io_var_locations(nir, nir_var_shader_out);
|
||||
panvk_lower_nir_io(nir);
|
||||
|
|
@ -1480,7 +1485,8 @@ panvk_compile_shader(struct panvk_device *dev,
|
|||
variant->own_bin = true;
|
||||
|
||||
result = panvk_compile_nir(dev, nir, info->flags, &inputs, state,
|
||||
noperspective_varyings, variant);
|
||||
noperspective_varyings,
|
||||
&shader->desc_info, variant);
|
||||
if (result != VK_SUCCESS) {
|
||||
panvk_shader_destroy(&dev->vk, &shader->vk, pAllocator);
|
||||
return result;
|
||||
|
|
@ -1492,7 +1498,7 @@ panvk_compile_shader(struct panvk_device *dev,
|
|||
* TODO: We could only emit descriptors that overflow the offset,
|
||||
* saving a bit of space.
|
||||
*/
|
||||
variant->desc_info.fs_varying_attr_desc_count =
|
||||
shader->desc_info.fs_varying_attr_desc_count =
|
||||
variant->info.bifrost.uses_ld_var ? nir->num_inputs : 0;
|
||||
#endif
|
||||
|
||||
|
|
@ -1522,13 +1528,14 @@ panvk_compile_shader(struct panvk_device *dev,
|
|||
#endif
|
||||
|
||||
panvk_lower_nir(dev, nir, info->set_layout_count, info->set_layouts,
|
||||
info->robustness, state, &variant->desc_info,
|
||||
info->robustness, state, &shader->desc_info,
|
||||
variant->info.cs.allow_merging_workgroups);
|
||||
|
||||
variant->own_bin = true;
|
||||
|
||||
result = panvk_compile_nir(dev, nir, info->flags, &inputs, state,
|
||||
noperspective_varyings, variant);
|
||||
noperspective_varyings,
|
||||
&shader->desc_info, variant);
|
||||
if (result != VK_SUCCESS) {
|
||||
panvk_shader_destroy(&dev->vk, &shader->vk, pAllocator);
|
||||
return result;
|
||||
|
|
@ -1713,7 +1720,7 @@ panvk_compile_shaders(struct vk_device *vk_dev, uint32_t shader_count,
|
|||
static VkResult
|
||||
shader_desc_info_deserialize(struct panvk_device *dev,
|
||||
struct blob_reader *blob,
|
||||
struct panvk_shader_variant *shader)
|
||||
struct panvk_shader *shader)
|
||||
{
|
||||
shader->desc_info.used_set_mask = blob_read_uint32(blob);
|
||||
|
||||
|
|
@ -1811,11 +1818,6 @@ panvk_deserialize_shader_variant(struct vk_device *vk_dev,
|
|||
shader->own_bin = true;
|
||||
blob_copy_bytes(blob, (void *)shader->bin_ptr, shader->bin_size);
|
||||
|
||||
result = shader_desc_info_deserialize(device, blob, shader);
|
||||
|
||||
if (result != VK_SUCCESS)
|
||||
return panvk_error(device, result);
|
||||
|
||||
uint32_t nir_str_size = blob_read_uint32(blob);
|
||||
uint32_t asm_str_size = blob_read_uint32(blob);
|
||||
const char *nir_str = blob_read_bytes(blob, nir_str_size);
|
||||
|
|
@ -1852,6 +1854,7 @@ panvk_deserialize_shader(struct vk_device *vk_dev, struct blob_reader *blob,
|
|||
{
|
||||
struct panvk_device *device = to_panvk_device(vk_dev);
|
||||
struct panvk_shader *shader;
|
||||
VkResult result;
|
||||
|
||||
mesa_shader_stage stage = blob_read_uint8(blob);
|
||||
if (blob->overrun)
|
||||
|
|
@ -1865,10 +1868,15 @@ panvk_deserialize_shader(struct vk_device *vk_dev, struct blob_reader *blob,
|
|||
if (shader == NULL)
|
||||
return panvk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
panvk_shader_foreach_variant(shader, variant) {
|
||||
VkResult result =
|
||||
panvk_deserialize_shader_variant(vk_dev, blob, pAllocator, variant);
|
||||
result = shader_desc_info_deserialize(device, blob, shader);
|
||||
if (result != VK_SUCCESS) {
|
||||
panvk_shader_destroy(vk_dev, &shader->vk, pAllocator);
|
||||
return result;
|
||||
}
|
||||
|
||||
panvk_shader_foreach_variant(shader, variant) {
|
||||
result = panvk_deserialize_shader_variant(vk_dev, blob, pAllocator,
|
||||
variant);
|
||||
if (result != VK_SUCCESS) {
|
||||
panvk_shader_destroy(vk_dev, &shader->vk, pAllocator);
|
||||
return result;
|
||||
|
|
@ -1882,7 +1890,7 @@ panvk_deserialize_shader(struct vk_device *vk_dev, struct blob_reader *blob,
|
|||
|
||||
static void
|
||||
shader_desc_info_serialize(struct blob *blob,
|
||||
const struct panvk_shader_variant *shader)
|
||||
const struct panvk_shader *shader)
|
||||
{
|
||||
blob_write_uint32(blob, shader->desc_info.used_set_mask);
|
||||
|
||||
|
|
@ -1948,7 +1956,6 @@ panvk_shader_serialize_variant(struct vk_device *vk_dev,
|
|||
|
||||
blob_write_uint32(blob, shader->bin_size);
|
||||
blob_write_bytes(blob, shader->bin_ptr, shader->bin_size);
|
||||
shader_desc_info_serialize(blob, shader);
|
||||
|
||||
/* Include the terminating NULL in the serialization */
|
||||
uint32_t nir_str_size = shader->nir_str ? strlen(shader->nir_str) + 1 : 0;
|
||||
|
|
@ -1970,6 +1977,8 @@ panvk_shader_serialize(struct vk_device *vk_dev,
|
|||
|
||||
blob_write_uint8(blob, vk_shader->stage);
|
||||
|
||||
shader_desc_info_serialize(blob, shader);
|
||||
|
||||
panvk_shader_foreach_variant(shader, variant) {
|
||||
panvk_shader_serialize_variant(vk_dev, variant, blob);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue