@@ -181,6 +181,8 @@ SpvId spv_emit_decl(Emitter* emitter, const Node* decl) {
181181 spvb_global_variable (emitter -> file_builder , given_id , spv_emit_type (emitter , decl -> type ), storage_class , false, init );
182182 spv_emit_aliased_restrict (emitter , given_id , decl -> type );
183183
184+ bool is_descriptor_binding = false;
185+
184186 for (size_t i = 0 ; i < decl -> annotations .count ; i ++ ) {
185187 const Node * a = decl -> annotations .nodes [i ];
186188 assert (is_annotation (a ));
@@ -193,13 +195,20 @@ SpvId spv_emit_decl(Emitter* emitter, const Node* decl) {
193195 size_t loc = shd_get_int_literal_value (* shd_resolve_to_int_literal (shd_get_annotation_value (a )), false);
194196 assert (loc >= 0 );
195197 spvb_decorate (emitter -> file_builder , given_id , SpvDecorationDescriptorSet , 1 , (uint32_t []) { loc });
198+ is_descriptor_binding = true;
196199 } else if (strcmp (name , "DescriptorBinding" ) == 0 ) {
197200 size_t loc = shd_get_int_literal_value (* shd_resolve_to_int_literal (shd_get_annotation_value (a )), false);
198201 assert (loc >= 0 );
199202 spvb_decorate (emitter -> file_builder , given_id , SpvDecorationBinding , 1 , (uint32_t []) { loc });
203+ is_descriptor_binding = true;
200204 }
201205 }
202206
207+ if (is_descriptor_binding && gvar -> type -> tag == ArrType_TAG && !gvar -> type -> payload .arr_type .size ) {
208+ spvb_extension (emitter -> file_builder , "SPV_EXT_descriptor_indexing" );
209+ spvb_capability (emitter -> file_builder , SpvCapabilityRuntimeDescriptorArray );
210+ }
211+
203212 switch (storage_class ) {
204213 case SpvStorageClassPushConstant : {
205214 break ;
0 commit comments