zink: refactor spec constant handling
This makes it simpler to add more spec constants Signed-off-by: Karol Herbst <kherbst@redhat.com> Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24839>
This commit is contained in:
parent
6e0bb08116
commit
566112fdf8
1 changed files with 24 additions and 11 deletions
|
|
@ -458,18 +458,31 @@ zink_create_compute_pipeline(struct zink_screen *screen, struct zink_compute_pro
|
|||
|
||||
VkSpecializationInfo sinfo = {0};
|
||||
VkSpecializationMapEntry me[3];
|
||||
if (comp->use_local_size) {
|
||||
stage.pSpecializationInfo = &sinfo;
|
||||
sinfo.mapEntryCount = 3;
|
||||
sinfo.pMapEntries = &me[0];
|
||||
sinfo.dataSize = sizeof(state->local_size);
|
||||
sinfo.pData = &state->local_size[0];
|
||||
uint32_t ids[] = {ZINK_WORKGROUP_SIZE_X, ZINK_WORKGROUP_SIZE_Y, ZINK_WORKGROUP_SIZE_Z};
|
||||
for (int i = 0; i < 3; i++) {
|
||||
me[i].size = sizeof(uint32_t);
|
||||
me[i].constantID = ids[i];
|
||||
me[i].offset = i * sizeof(uint32_t);
|
||||
uint32_t data[3];
|
||||
if (state) {
|
||||
int i = 0;
|
||||
|
||||
if (comp->use_local_size) {
|
||||
sinfo.mapEntryCount += 3;
|
||||
sinfo.dataSize += sizeof(state->local_size);
|
||||
|
||||
uint32_t ids[] = {ZINK_WORKGROUP_SIZE_X, ZINK_WORKGROUP_SIZE_Y, ZINK_WORKGROUP_SIZE_Z};
|
||||
for (int l = 0; l < 3; l++, i++) {
|
||||
data[i] = state->local_size[l];
|
||||
me[i].size = sizeof(uint32_t);
|
||||
me[i].constantID = ids[l];
|
||||
me[i].offset = i * sizeof(uint32_t);
|
||||
}
|
||||
}
|
||||
|
||||
if (sinfo.dataSize) {
|
||||
stage.pSpecializationInfo = &sinfo;
|
||||
sinfo.pData = data;
|
||||
sinfo.pMapEntries = me;
|
||||
}
|
||||
|
||||
assert(i <= ARRAY_SIZE(data));
|
||||
STATIC_ASSERT(ARRAY_SIZE(data) == ARRAY_SIZE(me));
|
||||
}
|
||||
|
||||
pci.stage = stage;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue