Mesa (master): turnip: Properly handle all sizes of specialization constants
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Apr 24 09:40:45 UTC 2020
Module: Mesa
Branch: master
Commit: 6211e79ba5f4be57c088fdf6140854f67c9a37ec
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=6211e79ba5f4be57c088fdf6140854f67c9a37ec
Author: Jason Ekstrand <jason at jlekstrand.net>
Date: Wed Apr 22 13:43:51 2020 -0500
turnip: Properly handle all sizes of specialization constants
cc: mesa-stable at lists.freedesktop.org
Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4675>
---
src/freedreno/vulkan/tu_shader.c | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
diff --git a/src/freedreno/vulkan/tu_shader.c b/src/freedreno/vulkan/tu_shader.c
index d58209c404c..3c674156afe 100644
--- a/src/freedreno/vulkan/tu_shader.c
+++ b/src/freedreno/vulkan/tu_shader.c
@@ -62,10 +62,23 @@ tu_spirv_to_nir(struct ir3_compiler *compiler,
const void *data = spec_info->pData + entry->offset;
assert(data + entry->size <= spec_info->pData + spec_info->dataSize);
spec[i].id = entry->constantID;
- if (entry->size == 8)
- spec[i].data64 = *(const uint64_t *) data;
- else
- spec[i].data32 = *(const uint32_t *) data;
+ switch (entry->size) {
+ case 8:
+ spec[i].data64 = *(const uint64_t *)data;
+ break;
+ case 4:
+ spec[i].data32 = *(const uint32_t *)data;
+ break;
+ case 2:
+ spec[i].data32 = *(const uint16_t *)data;
+ break;
+ case 1:
+ spec[i].data32 = *(const uint8_t *)data;
+ break;
+ default:
+ assert(!"Invalid spec constant size");
+ break;
+ }
spec[i].defined_on_module = false;
}
More information about the mesa-commit
mailing list