Module: Mesa Branch: staging/20.0 Commit: 081efbbc79dfdf33c9c5202ed0ec24c18f6dd0c5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=081efbbc79dfdf33c9c5202ed0ec24c18f6dd0c5
Author: Jason Ekstrand <[email protected]> Date: Wed Apr 22 13:43:51 2020 -0500 turnip: Properly handle all sizes of specialization constants cc: [email protected] Reviewed-by: Caio Marcelo de Oliveira Filho <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4675> (cherry picked from commit 6211e79ba5f4be57c088fdf6140854f67c9a37ec) --- .pick_status.json | 2 +- src/freedreno/vulkan/tu_shader.c | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 1359da32fb8..b48abd117b2 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1228,7 +1228,7 @@ "description": "turnip: Properly handle all sizes of specialization constants", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": null }, diff --git a/src/freedreno/vulkan/tu_shader.c b/src/freedreno/vulkan/tu_shader.c index 323a244e81a..c6abf90b5b2 100644 --- a/src/freedreno/vulkan/tu_shader.c +++ b/src/freedreno/vulkan/tu_shader.c @@ -58,10 +58,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; } _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
