spirv: Skip creating unused variables in SPIR-V >= 1.4
Newer versions of SPIR-V require that all the global variables used by the entry point are declared (in contrast to only I/O in previous versions), so there's no need to remove dead variables or keep track of the indirectly used variables. Reviewed-by: Rhys Perry <pendingchaos02@gmail.com> Reviewed-by: Jason Ekstrand <jason@jlekstrand.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8456>
This commit is contained in:

committed by
Marge Bot

parent
e3abbe7a24
commit
0c3fe06421
@@ -2287,12 +2287,19 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,
|
||||
|
||||
SpvStorageClass storage_class = w[3];
|
||||
|
||||
/* Skip I/O variables that are not used by the entry point. */
|
||||
const bool is_global = storage_class != SpvStorageClassFunction;
|
||||
const bool is_io = storage_class == SpvStorageClassInput ||
|
||||
storage_class == SpvStorageClassOutput;
|
||||
|
||||
/* Skip global variables that are not used by the entrypoint. Before
|
||||
* SPIR-V 1.4 the interface is only used for I/O variables, so extra
|
||||
* variables will still need to be removed later.
|
||||
*/
|
||||
if (!b->options->create_library &&
|
||||
(storage_class == SpvStorageClassInput ||
|
||||
storage_class == SpvStorageClassOutput) &&
|
||||
!bsearch(&w[2], b->interface_ids, b->interface_ids_count, 4, cmp_uint32_t))
|
||||
break;
|
||||
(is_io || (b->version >= 0x10400 && is_global))) {
|
||||
if (!bsearch(&w[2], b->interface_ids, b->interface_ids_count, 4, cmp_uint32_t))
|
||||
break;
|
||||
}
|
||||
|
||||
struct vtn_value *val = vtn_push_value(b, w[2], vtn_value_type_pointer);
|
||||
struct vtn_value *initializer = count > 4 ? vtn_untyped_value(b, w[4]) : NULL;
|
||||
|
Reference in New Issue
Block a user