spirv-cross 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2441261f9f58a2fc569cfa3fab88a9a6ecc9666514e89d5a559a55f83f6b9487
4
- data.tar.gz: 4545b775ac721125cdbf1af53377a1ce26c5924cf6957ce1d47c3f9180788537
3
+ metadata.gz: e62c57d6e3232497997e81833a8b2713b178d4c542ca110af080b29868352034
4
+ data.tar.gz: bb5662e887cc1bdf57d1d48c1158e6c50035d2dfb506936711a411ebbbbd0f5d
5
5
  SHA512:
6
- metadata.gz: c9ae1805ee23b5c02c047dbb39820e9a1990fef23357fe26d7eaeabbaa8c16a1e1c5fd4a68489d2628ca01ea3d177f8cbe66e27a8408e4316eaa31a9192d0d8d
7
- data.tar.gz: 9aa286c888bbda09f8f56d29a0a5bd728295d1e1ea65235d88988f3a415a4436c54e5797a26f1d5453eb77416a2d98f6958721959a7385d0bcd299efc4f76940
6
+ metadata.gz: c65c5b3473be69fa35949ac0199d621f06674772544c055cb0634c418d73b042dd9ac912018d6f6aaaab7d3e534b0417851ff929f55edc10a75fdd8670de9830
7
+ data.tar.gz: e9542610a4b59094a13f7ef5089178847d0a4f4e1cfcdf9e122370861e0897a10e80361a3e5d1ac902ed2cab5c98f8fc989f160c23635834f934530e0d4be684
data/Gemfile.lock CHANGED
@@ -1,12 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- spirv-cross (0.1.2)
4
+ spirv-cross (0.1.4)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- minitest (5.13.0)
9
+ minitest (5.24.1)
10
10
  rake (13.0.1)
11
11
  rake-compiler (1.1.0)
12
12
  rake
@@ -22,4 +22,4 @@ DEPENDENCIES
22
22
  spirv-cross!
23
23
 
24
24
  BUNDLED WITH
25
- 2.1.1
25
+ 2.5.17
@@ -179,11 +179,9 @@ extern "C" {
179
179
  return vres;
180
180
  }
181
181
 
182
- VALUE shader_resource_vector_to_ary(spirv_cross::Compiler &compiler, spirv_cross::SmallVector<spirv_cross::Resource> &vec, bool print_ssbo) {
182
+ VALUE shader_resource_vector_to_ary(spirv_cross::Compiler &compiler, spirv_cross::SmallVector<spirv_cross::Resource> &vec, bool print_ssbo, bool is_buffer) {
183
183
  VALUE ret = rb_ary_new();
184
- for (size_t i = 0; i < vec.size(); i++) {
185
- spirv_cross::Resource &res = vec[i];
186
-
184
+ for (auto &res : vec) {
187
185
  // just merge extra data into the type hash instead of creating a nested type hash
188
186
  VALUE vres = rb_spirv_type(compiler, res.type_id);
189
187
 
@@ -193,23 +191,27 @@ extern "C" {
193
191
  // // rb_hash_aset(vres, ID2SYM(rb_intern("base_type")), rb_spirv_type(compiler, res.base_type_id));
194
192
  // rb_hash_aset(vres, ID2SYM(rb_intern("type")), rb_spirv_type(compiler, res.type_id));
195
193
 
196
- spirv_cross::SmallVector<spirv_cross::BufferRange> ranges = compiler.get_active_buffer_ranges(res.id);
197
- VALUE vranges = rb_ary_new();
198
- rb_hash_aset(vres, ID2SYM(rb_intern("active_buffer_ranges")), vranges);
199
- for (auto &range : ranges) {
200
- VALUE vrange = rb_hash_new();
201
- rb_hash_aset(vrange, ID2SYM(rb_intern("index")), UINT2NUM(range.index));
202
- rb_hash_aset(vrange, ID2SYM(rb_intern("offset")), SIZET2NUM(range.offset));
203
- rb_hash_aset(vrange, ID2SYM(rb_intern("size")), SIZET2NUM(range.range));
204
- rb_ary_push(vranges, vrange);
194
+ // This can be used for Buffer (UBO), BufferBlock/StorageBuffer (SSBO) and PushConstant blocks.
195
+ if (is_buffer) {
196
+ auto ranges = compiler.get_active_buffer_ranges(res.id);
197
+ VALUE vranges = rb_ary_new();
198
+ rb_hash_aset(vres, ID2SYM(rb_intern("active_buffer_ranges")), vranges);
199
+ for (auto &range : ranges) {
200
+ VALUE vrange = rb_hash_new();
201
+ rb_hash_aset(vrange, ID2SYM(rb_intern("index")), UINT2NUM(range.index));
202
+ rb_hash_aset(vrange, ID2SYM(rb_intern("offset")), SIZET2NUM(range.offset));
203
+ rb_hash_aset(vrange, ID2SYM(rb_intern("size")), SIZET2NUM(range.range));
204
+ rb_ary_push(vranges, vrange);
205
+ }
205
206
  }
206
207
 
207
208
  auto &type = compiler.get_type(res.type_id);
208
209
 
209
210
  /* The following code was basically lifted from spirv-cross/main.cpp */
210
211
 
211
- if (print_ssbo && compiler.buffer_is_hlsl_counter_buffer(res.id))
212
+ if (print_ssbo && compiler.buffer_is_hlsl_counter_buffer(res.id)) {
212
213
  continue;
214
+ }
213
215
 
214
216
  // If we don't have a name, use the fallback for the type instead of the variable
215
217
  // for SSBOs and UBOs since those are the only meaningful names to use externally.
@@ -232,18 +234,20 @@ extern "C" {
232
234
  }
233
235
 
234
236
  spirv_cross::Bitset mask;
235
- if (print_ssbo)
237
+ if (print_ssbo) {
236
238
  mask = compiler.get_buffer_block_flags(res.id);
237
- else
239
+ } else {
238
240
  mask = compiler.get_decoration_bitset(res.id);
241
+ }
239
242
 
240
243
  VALUE ary = rb_ary_new();
241
244
  rb_hash_aset(vres, ID2SYM(rb_intern("array_sizes")), ary);
242
245
  for (size_t j = 0; j < type.array.size(); j++) {
243
- if (type.array_size_literal[j])
246
+ if (type.array_size_literal[j]) {
244
247
  rb_ary_push(ary, UINT2NUM(type.array[j]));
245
- else
248
+ } else {
246
249
  rb_ary_push(ary, ID2SYM(rb_intern("expression")));
250
+ }
247
251
  }
248
252
 
249
253
  rb_hash_aset(vres, ID2SYM(rb_intern("name")),
@@ -266,13 +270,15 @@ extern "C" {
266
270
  if (is_sized_block)
267
271
  {
268
272
  rb_hash_aset(vres, ID2SYM(rb_intern("block_size")), UINT2NUM(block_size));
269
- if (runtime_array_stride)
273
+ if (runtime_array_stride) {
270
274
  rb_hash_aset(vres, ID2SYM(rb_intern("unsized_array_stride")), UINT2NUM(runtime_array_stride));
275
+ }
271
276
  }
272
277
 
273
278
  uint32_t counter_id = 0;
274
- if (print_ssbo && compiler.buffer_get_hlsl_counter_buffer(res.id, counter_id))
279
+ if (print_ssbo && compiler.buffer_get_hlsl_counter_buffer(res.id, counter_id)) {
275
280
  rb_hash_aset(vres, ID2SYM(rb_intern("hlsl_counter_buffer_id")), UINT2NUM(counter_id));
281
+ }
276
282
 
277
283
  rb_ary_push(ret, vres);
278
284
  }
@@ -281,19 +287,19 @@ extern "C" {
281
287
 
282
288
  inline VALUE shader_resources_to_hash(spirv_cross::Compiler *comp, spirv_cross::ShaderResources &resources) {
283
289
  VALUE vsr = rb_hash_new();
284
- #define HASH_PUSH_RESOURCE_ARY(name, ssbo) \
285
- rb_hash_aset(vsr, ID2SYM(rb_intern(#name)), shader_resource_vector_to_ary(*comp, resources.name, ssbo));
286
- HASH_PUSH_RESOURCE_ARY(uniform_buffers, false);
287
- HASH_PUSH_RESOURCE_ARY(storage_buffers, true);
288
- HASH_PUSH_RESOURCE_ARY(stage_inputs, false);
289
- HASH_PUSH_RESOURCE_ARY(stage_outputs, false);
290
- HASH_PUSH_RESOURCE_ARY(subpass_inputs, false);
291
- HASH_PUSH_RESOURCE_ARY(storage_images, false);
292
- HASH_PUSH_RESOURCE_ARY(sampled_images, false);
293
- HASH_PUSH_RESOURCE_ARY(atomic_counters, false);
294
- HASH_PUSH_RESOURCE_ARY(push_constant_buffers, false);
295
- HASH_PUSH_RESOURCE_ARY(separate_images, false);
296
- HASH_PUSH_RESOURCE_ARY(separate_samplers, false);
290
+ #define HASH_PUSH_RESOURCE_ARY(name, ssbo, is_buffer) \
291
+ rb_hash_aset(vsr, ID2SYM(rb_intern(#name)), shader_resource_vector_to_ary(*comp, resources.name, ssbo, is_buffer));
292
+ HASH_PUSH_RESOURCE_ARY(uniform_buffers, false, true);
293
+ HASH_PUSH_RESOURCE_ARY(storage_buffers, true, true);
294
+ HASH_PUSH_RESOURCE_ARY(stage_inputs, false, false);
295
+ HASH_PUSH_RESOURCE_ARY(stage_outputs, false, false);
296
+ HASH_PUSH_RESOURCE_ARY(subpass_inputs, false, false);
297
+ HASH_PUSH_RESOURCE_ARY(storage_images, false, false);
298
+ HASH_PUSH_RESOURCE_ARY(sampled_images, false, false);
299
+ HASH_PUSH_RESOURCE_ARY(atomic_counters, false, false);
300
+ HASH_PUSH_RESOURCE_ARY(push_constant_buffers, false, true);
301
+ HASH_PUSH_RESOURCE_ARY(separate_images, false, false);
302
+ HASH_PUSH_RESOURCE_ARY(separate_samplers, false, false);
297
303
  return vsr;
298
304
  }
299
305
 
@@ -361,7 +367,7 @@ extern "C" {
361
367
 
362
368
  try {
363
369
  spirv_cross::Compiler *compiler = new spirv_cross::Compiler(std::move(spirv));
364
- rb_ivar_set(self, rb_intern("@handle"), TypedData_Wrap_Struct(rb_cData, &compiler_type, compiler));
370
+ rb_ivar_set(self, rb_intern("@handle"), TypedData_Wrap_Struct(rb_cObject, &compiler_type, compiler));
365
371
  } catch(const std::exception &ex) {
366
372
  rb_raise(rb_eSPIRVError, "%s", ex.what());
367
373
  }
@@ -1,5 +1,5 @@
1
1
  module SPIRV
2
2
  module Cross
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.4"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spirv-cross
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin MacKenzie IV
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-10 00:00:00.000000000 Z
11
+ date: 2024-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,7 +66,7 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '5.0'
69
- description:
69
+ description:
70
70
  email:
71
71
  - sinisterchipmunk@gmail.com
72
72
  executables:
@@ -100,7 +100,7 @@ licenses:
100
100
  metadata:
101
101
  allowed_push_host: https://rubygems.org
102
102
  homepage_uri: https://github.com/sinisterchipmunk/spirv-cross-ruby
103
- post_install_message:
103
+ post_install_message:
104
104
  rdoc_options: []
105
105
  require_paths:
106
106
  - lib
@@ -115,8 +115,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
117
  requirements: []
118
- rubygems_version: 3.1.1
119
- signing_key:
118
+ rubygems_version: 3.5.0.dev
119
+ signing_key:
120
120
  specification_version: 4
121
121
  summary: Ruby bindings for SPIRV-Cross to provide reflection of SPIR-V shaders.
122
122
  test_files: []