Module: Vulkan::Conversions

Constant Summary collapse

IMAGE_FORMATS =
{}
IMAGE_TILING =
{}
DESCRIPTOR_TYPES =
{}
BUFFER_USAGE_BITS =
{}
IMAGE_USAGE_BITS =
{}
IMAGE_TYPES =
{}
SHADER_STAGE_BITS =
{}
SHARING_MODES =
{}
IMAGE_CREATE_BITS =
{}
PIPELINE_STAGE_BITS =
{}
DEPENDENCY_FLAG_BITS =
{}
IMAGE_ASPECT_BITS =
{}
ACCESS_MASK_BITS =
{}
FILTERS =
{}
SAMPLER_ADDRESS_MODES =
{}
SAMPLER_MIPMAP_MODES =
{}
COMPARE_OPS =
{}
BORDER_COLORS =
{}
MEMORY_PROPERTIES =
{}
FORMAT_FEATURE_BITS =
{}
VERTEX_INPUT_RATES =
{}
PRESENT_MODES =
{}
SURFACE_TRANSFORMS =
{}
DYNAMIC_STATES =
{}

Instance Method Summary collapse

Instance Method Details

#array_of_pointers(ary, pointers = nil) ⇒ Object



435
436
437
438
439
440
441
442
443
# File 'lib/vulkan/conversions.rb', line 435

def array_of_pointers(ary, pointers = nil)
  return nil if ary.nil? || ary.empty?
  pointers ||= Fiddle::Pointer.malloc(ary.size * Fiddle::SIZEOF_VOIDP)
  ary.each_with_index do |ptr, i|
    mem = [ptr.to_ptr.to_i].pack(Fiddle::PackInfo::PACK_MAP[Fiddle::TYPE_VOIDP])
    pointers[i * Fiddle::SIZEOF_VOIDP, Fiddle::SIZEOF_VOIDP] = mem
  end
  pointers
end

#array_of_structures(ary) ⇒ Object

Raises:

  • (ArgumentError)


422
423
424
425
426
427
428
429
430
431
432
433
# File 'lib/vulkan/conversions.rb', line 422

def array_of_structures(ary)
  return nil if ary.nil? || ary.empty?
  size = ary.map { |struct| struct.to_ptr.size }.sum
  pointers = Fiddle::Pointer.malloc(size)
  raise ArgumentError, "size is 0?, #{ary}" if size == 0
  offset = 0
  ary.each_with_index do |addr, i|
    (pointers + offset).copy_from(addr.to_ptr)
    offset += addr.to_ptr.size
  end
  pointers
end

#array_of_uint32s(ary) ⇒ Object



414
415
416
417
418
419
420
# File 'lib/vulkan/conversions.rb', line 414

def array_of_uint32s(ary)
  return nil if ary.nil? || ary.empty?
  size = ary.size * 4
  ints = Fiddle::Pointer.malloc(size)
  ints[0, size] = ary.pack("L")
  ints
end

#bool_to_vk(bool) ⇒ Object



145
146
147
# File 'lib/vulkan/conversions.rb', line 145

def bool_to_vk(bool)
  bool ? VK_TRUE : VK_FALSE
end

#buffer_usage_flags_to_syms(bits) ⇒ Object



125
126
127
# File 'lib/vulkan/conversions.rb', line 125

def buffer_usage_flags_to_syms(bits)
  flags_to_syms(bits, BUFFER_USAGE_BITS)
end

#const_to_symbol(val, rx) ⇒ Object

Using the specified regular expression, scans the list of Vulkan constants, looking for the first constant whose name matches the regular expression AND whose value matches the given value. The return value is the first regex group (‘$1`) from the match, converted to a symbol.



475
476
477
478
479
480
481
482
# File 'lib/vulkan/conversions.rb', line 475

def const_to_symbol(val, rx)
  Vulkan.constants.each do |konst|
    if konst.to_s[rx]
      return $1.downcase.to_sym if val == Vulkan.const_get(konst)
    end
  end
  val
end

#cstr_to_rbstr(byte_array_or_ptr) ⇒ Object

Converts a byte array (array of numbers) representing a null-terminated C-string into a Ruby string.



447
448
449
450
451
452
# File 'lib/vulkan/conversions.rb', line 447

def cstr_to_rbstr(byte_array_or_ptr)
  case byte_array_or_ptr
  when Fiddle::Pointer then byte_array_or_ptr.to_s
  else byte_array_or_ptr.pack('C*').sub(/\x00*\z/, '')
  end
end

#flags_to_symbols(val, rx) ⇒ Object

Performs similarly to #const_to_symbol, but returns an array of symbols for a set of matching flag names, rather than for a single value.



486
487
488
489
490
491
492
493
494
495
# File 'lib/vulkan/conversions.rb', line 486

def flags_to_symbols(val, rx)
  [].tap do |ary|
    Vulkan.constants.each do |konst|
      if konst.to_s[rx]
        flag_value = Vulkan.const_get(konst)
        ary << $1.downcase.to_sym if val & flag_value > 0
      end
    end
  end
end

#flags_to_syms(flags, bits) ⇒ Object



103
104
105
106
107
108
109
110
111
# File 'lib/vulkan/conversions.rb', line 103

def flags_to_syms(flags, bits)
  return flags   if flags.kind_of?(Array)
  return [flags] if flags.kind_of?(Symbol)
  bits.reduce([]) do |syms, (name, bit)|
    syms << name if flags & bit != 0
    syms
  end
  syms
end

#num_to_samples(i) ⇒ Object



401
402
403
404
405
406
407
408
409
410
411
412
# File 'lib/vulkan/conversions.rb', line 401

def num_to_samples(i)
  case i
  when 1  then VK_SAMPLE_COUNT_1_BIT
  when 2  then VK_SAMPLE_COUNT_2_BIT
  when 4  then VK_SAMPLE_COUNT_4_BIT
  when 8  then VK_SAMPLE_COUNT_8_BIT
  when 16 then VK_SAMPLE_COUNT_16_BIT
  when 32 then VK_SAMPLE_COUNT_32_BIT
  when 64 then VK_SAMPLE_COUNT_64_BIT
  else i
  end
end

#present_mode_to_sym(mode) ⇒ Object



76
77
78
# File 'lib/vulkan/conversions.rb', line 76

def present_mode_to_sym(mode)
  PRESENT_MODES.key(mode)&.to_sym
end

#queue_family_to_index(family) ⇒ Object



254
255
256
257
258
259
260
261
# File 'lib/vulkan/conversions.rb', line 254

def queue_family_to_index(family)
  case family
  when nil, :ignored then VK_QUEUE_FAMILY_IGNORED
  when Numeric       then family
  when Hash          then queue_family_to_index(family[:index])
  else raise ArgumentError, 'queue family must be :ignored, a number, or a hash containing :index'
  end
end

#struct_to_hash(struct, initial = {}) ⇒ Object

Converts a Fiddle/FFI memory struct into a simple Ruby hash, mostly for happier debugging.



499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
# File 'lib/vulkan/conversions.rb', line 499

def struct_to_hash(struct, initial = {})
  struct.class.members.each_with_index.inject(initial) do |hash, (member, index)|
    member = member[0] if member.kind_of?(Array)
    member_name = member.gsub(/[0-9A-Z]+/) { |x| "_#{x.downcase}" }.to_sym
    type = struct.class.types[index]
    hash.tap do |h|
      val = struct.send(member)
      val = struct_to_hash(val) if val.respond_to?(:to_ptr) && !val.kind_of?(Array)
      if val.kind_of?(Array)
        val = val.map do |v|
          if v.respond_to?(:to_ptr) && v.to_ptr.kind_of?(Fiddle::CStructEntity)
            struct_to_hash(v)
          else
            v
          end
        end
      end
      h[member_name] = val
      h[member_name] = cstr_to_rbstr(h[member_name]) if type.kind_of?(Array) && type[0] == Fiddle::TYPE_CHAR
    end
  end
end

#sym_to_blend_factor(sym) ⇒ Object



263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
# File 'lib/vulkan/conversions.rb', line 263

def sym_to_blend_factor(sym)
  case sym
  when 0, :zero                  then VK_BLEND_FACTOR_ZERO
  when 1, :one                   then VK_BLEND_FACTOR_ONE
  when :src_color                then VK_BLEND_FACTOR_SRC_COLOR
  when :one_minus_src_color      then VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR
  when :dst_color                then VK_BLEND_FACTOR_DST_COLOR
  when :one_minus_dst_color      then VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR
  when :src_alpha                then VK_BLEND_FACTOR_SRC_ALPHA
  when :one_minus_src_alpha      then VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA
  when :dst_alpha                then VK_BLEND_FACTOR_DST_ALPHA
  when :one_minus_dst_alpha      then VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA
  when :constant_color           then VK_BLEND_FACTOR_CONSTANT_COLOR
  when :one_minus_constant_color then VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR
  when :constant_alpha           then VK_BLEND_FACTOR_CONSTANT_ALPHA
  when :one_minus_constant_alpha then VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_ALPHA
  when :src_alpha_saturate       then VK_BLEND_FACTOR_SRC_ALPHA_SATURATE
  when :src1_color               then VK_BLEND_FACTOR_SRC1_COLOR
  when :one_minus_src1_color     then VK_BLEND_FACTOR_ONE_MINUS_SRC1_COLOR
  when :src1_alpha               then VK_BLEND_FACTOR_SRC1_ALPHA
  when :one_minus_src1_alpha     then VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA
  else sym
  end
end

#sym_to_blend_op(sym) ⇒ Object



288
289
290
291
292
293
294
295
296
297
# File 'lib/vulkan/conversions.rb', line 288

def sym_to_blend_op(sym)
  case sym
  when :add              then VK_BLEND_OP_ADD
  when :subtract         then VK_BLEND_OP_SUBTRACT
  when :reverse_subtract then VK_BLEND_OP_REVERSE_SUBTRACT
  when :min              then VK_BLEND_OP_MIN
  when :max              then VK_BLEND_OP_MAX
  else sym
  end
end

#sym_to_border_color(sym) ⇒ Object



141
142
143
# File 'lib/vulkan/conversions.rb', line 141

def sym_to_border_color(sym)
  sym_to_val(sym, BORDER_COLORS)
end

#sym_to_color_component_bit(sym) ⇒ Object



337
338
339
340
341
342
343
344
345
# File 'lib/vulkan/conversions.rb', line 337

def sym_to_color_component_bit(sym)
  case sym
  when :r, :red   then VK_COLOR_COMPONENT_R_BIT
  when :g, :green then VK_COLOR_COMPONENT_G_BIT
  when :b, :blue  then VK_COLOR_COMPONENT_B_BIT
  when :a, :alpha then VK_COLOR_COMPONENT_A_BIT
  else sym
  end
end

#sym_to_command_buffer_level(sym) ⇒ Object



229
230
231
232
233
234
235
# File 'lib/vulkan/conversions.rb', line 229

def sym_to_command_buffer_level(sym)
  case sym
  when :primary   then VK_COMMAND_BUFFER_LEVEL_PRIMARY
  when :secondary then VK_COMMAND_BUFFER_LEVEL_SECONDARY
  else sym
  end
end

#sym_to_command_buffer_usage(sym) ⇒ Object



237
238
239
240
241
242
243
244
# File 'lib/vulkan/conversions.rb', line 237

def sym_to_command_buffer_usage(sym)
  case sym
  when :simultaneous         then VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT
  when :one_time_submit      then VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT
  when :render_pass_continue then VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT
  else sym
  end
end

#sym_to_compare_op(sym) ⇒ Object



117
118
119
# File 'lib/vulkan/conversions.rb', line 117

def sym_to_compare_op(sym)
  sym_to_val(sym, COMPARE_OPS)
end

#sym_to_cull_mode(sym) ⇒ Object



319
320
321
322
323
324
325
326
327
# File 'lib/vulkan/conversions.rb', line 319

def sym_to_cull_mode(sym)
  case sym
  when :back           then VK_CULL_MODE_BACK_BIT
  when :front          then VK_CULL_MODE_FRONT_BIT
  when :front_and_back then VK_CULL_MODE_FRONT_AND_BACK
  when :none, nil      then VK_CULL_MODE_NONE
  else sym
  end
end

#sym_to_descriptor_type(sym) ⇒ Object



213
214
215
# File 'lib/vulkan/conversions.rb', line 213

def sym_to_descriptor_type(sym)
  DESCRIPTOR_TYPES[sym] || sym
end

#sym_to_dynamic_state(sym) ⇒ Object



87
88
89
# File 'lib/vulkan/conversions.rb', line 87

def sym_to_dynamic_state(sym)
  DYNAMIC_STATES[sym]
end

#sym_to_filter(sym) ⇒ Object



165
166
167
# File 'lib/vulkan/conversions.rb', line 165

def sym_to_filter(sym)
  sym_to_val sym, FILTERS
end

#sym_to_front_face(sym) ⇒ Object



329
330
331
332
333
334
335
# File 'lib/vulkan/conversions.rb', line 329

def sym_to_front_face(sym)
  case sym
  when :clockwise         then VK_FRONT_FACE_CLOCKWISE
  when :counter_clockwise then VK_FRONT_FACE_COUNTER_CLOCKWISE
  else sym
  end
end

#sym_to_image_format(sym) ⇒ Object Also known as: sym_to_format



185
186
187
# File 'lib/vulkan/conversions.rb', line 185

def sym_to_image_format(sym)
  sym_to_val sym, IMAGE_FORMATS
end

#sym_to_image_layout(sym) ⇒ Object



364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
# File 'lib/vulkan/conversions.rb', line 364

def sym_to_image_layout(sym)
  case sym
  when :undefined, nil, :any
    VK_IMAGE_LAYOUT_UNDEFINED
  when :general
    VK_IMAGE_LAYOUT_GENERAL
  when :color_optimal, :color, :color_attachment_optimal
    VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
  when :stencil_optimal, :depth_optimal, :depth_stencil_optimal, :depth_stencil_attachment_optimal,
       :stencil,         :depth,         :depth_stencil,         :depth_stencil_attachment
    VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
  when :stencil_read_only_optimal, :stencil_ro_optimal, :stencil_read_only, :stencil_ro,
       :depth_read_only_optimal, :depth_ro_optimal, :depth_read_only, :depth_ro,
       :depth_stencil_ro_optimal, :depth_stencil_read_only, :depth_stencil_ro
    VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL
  when :shader_read_only_optimal, :shader_ro_optimal, :shader_read_only, :shader_ro
    VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
  when :transfer_src_optimal, :transfer_src, :src_optimal
    VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL
  when :transfer_dst_optimal, :transfer_dst, :dst_optimal
    VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
  when :preinitialized
    VK_IMAGE_LAYOUT_PREINITIALIZED
  when :present_src, :presentation_src, :presentment_src
    VK_IMAGE_LAYOUT_PRESENT_SRC_KHR
  else sym
  end
end

#sym_to_image_tiling(sym) ⇒ Object



177
178
179
# File 'lib/vulkan/conversions.rb', line 177

def sym_to_image_tiling(sym)
  sym_to_val sym, IMAGE_TILING
end

#sym_to_image_type(sym) ⇒ Object



191
192
193
194
195
# File 'lib/vulkan/conversions.rb', line 191

def sym_to_image_type(sym)
  # can't let it be a number because if it is numeric then it might
  # need to be passed-through without transformation.
  sym_to_val sym, IMAGE_TYPES
end

#sym_to_index_type(sym) ⇒ Object



246
247
248
249
250
251
252
# File 'lib/vulkan/conversions.rb', line 246

def sym_to_index_type(sym)
  case sym
  when :uint16 then VK_INDEX_TYPE_UINT16
  when :uint32 then VK_INDEX_TYPE_UINT32
  else sym
  end
end

#sym_to_load_op(sym) ⇒ Object



347
348
349
350
351
352
353
354
# File 'lib/vulkan/conversions.rb', line 347

def sym_to_load_op(sym)
  case sym
  when :load           then VK_ATTACHMENT_LOAD_OP_LOAD
  when :clear          then VK_ATTACHMENT_LOAD_OP_CLEAR
  when :dont_care, nil then VK_ATTACHMENT_LOAD_OP_DONT_CARE
  else sym
  end
end

#sym_to_pipeline_bind_point(sym) ⇒ Object



393
394
395
396
397
398
399
# File 'lib/vulkan/conversions.rb', line 393

def sym_to_pipeline_bind_point(sym)
  case sym
  when :graphics then VK_PIPELINE_BIND_POINT_GRAPHICS
  when :compute  then VK_PIPELINE_BIND_POINT_COMPUTE
  else sym
  end
end

#sym_to_polygon_mode(sym) ⇒ Object



310
311
312
313
314
315
316
317
# File 'lib/vulkan/conversions.rb', line 310

def sym_to_polygon_mode(sym)
  case sym
  when :fill  then VK_POLYGON_MODE_FILL
  when :line  then VK_POLYGON_MODE_LINE
  when :point then VK_POLYGON_MODE_POINT
  else sym
  end
end

#sym_to_present_mode(sym) ⇒ Object



72
73
74
# File 'lib/vulkan/conversions.rb', line 72

def sym_to_present_mode(sym)
  PRESENT_MODES[sym]
end

#sym_to_sampler_address_mode(sym) ⇒ Object



169
170
171
# File 'lib/vulkan/conversions.rb', line 169

def sym_to_sampler_address_mode(sym)
  sym_to_val sym, SAMPLER_ADDRESS_MODES
end

#sym_to_sampler_mipmap_mode(sym) ⇒ Object



173
174
175
# File 'lib/vulkan/conversions.rb', line 173

def sym_to_sampler_mipmap_mode(sym)
  sym_to_val sym, SAMPLER_MIPMAP_MODES
end

#sym_to_samples(sym) ⇒ Object



80
81
82
83
84
85
# File 'lib/vulkan/conversions.rb', line 80

def sym_to_samples(sym)
  # 4 => 4 because VK_SAMPLE_COUNT_4_BIT == 4.
  # But we'll keep this method here in case that changes or is not always
  # true.
  sym
end

#sym_to_sharing_mode(sym) ⇒ Object



197
198
199
# File 'lib/vulkan/conversions.rb', line 197

def sym_to_sharing_mode(sym)
  sym_to_val sym, SHARING_MODES
end

#sym_to_store_op(sym) ⇒ Object



356
357
358
359
360
361
362
# File 'lib/vulkan/conversions.rb', line 356

def sym_to_store_op(sym)
  case sym
  when :store          then VK_ATTACHMENT_STORE_OP_STORE
  when :dont_care, nil then VK_ATTACHMENT_STORE_OP_DONT_CARE
  else sym
  end
end

#sym_to_subpass_contents(sym) ⇒ Object



221
222
223
224
225
226
227
# File 'lib/vulkan/conversions.rb', line 221

def sym_to_subpass_contents(sym)
  case sym
  when :inline                                then VK_SUBPASS_CONTENTS_INLINE
  when :secondary, :secondary_command_buffers then VK_SUBPASS_CONTENTS_SECONDARY_COMMAND_BUFFERS
  else sym
  end
end

#sym_to_topology(sym) ⇒ Object



299
300
301
302
303
304
305
306
307
308
# File 'lib/vulkan/conversions.rb', line 299

def sym_to_topology(sym)
  case sym
  when :triangle, :triangles, :triangle_list then VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST
  when :point,    :points,    :point_list    then VK_PRIMITIVE_TOPOLOGY_POINT_LIST
  when :line,     :lines,     :line_list     then VK_PRIMITIVE_TOPOLOGY_LINE_LIST
  when :line_strip                           then VK_PRIMITIVE_TOPOLOGY_LINE_STRIP
  when :triangle_strip                       then VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP
  else sym
  end
end

#sym_to_val(sym, vals) ⇒ Object



95
96
97
# File 'lib/vulkan/conversions.rb', line 95

def sym_to_val(sym, vals)
  vals[sym] || sym
end

#sym_to_vertex_input_rate(sym) ⇒ Object



113
114
115
# File 'lib/vulkan/conversions.rb', line 113

def sym_to_vertex_input_rate(sym)
  sym_to_val(sym, VERTEX_INPUT_RATES)
end

#syms_to_access_mask(syms) ⇒ Object



133
134
135
# File 'lib/vulkan/conversions.rb', line 133

def syms_to_access_mask(syms)
  syms_to_flags(syms, ACCESS_MASK_BITS)
end

#syms_to_buffer_usage_flags(syms) ⇒ Object



121
122
123
# File 'lib/vulkan/conversions.rb', line 121

def syms_to_buffer_usage_flags(syms)
  syms_to_flags(syms, BUFFER_USAGE_BITS)
end

#syms_to_dependency_flags(syms) ⇒ Object



157
158
159
# File 'lib/vulkan/conversions.rb', line 157

def syms_to_dependency_flags(syms)
  syms_to_flags(syms, DEPENDENCY_FLAG_BITS)
end

#syms_to_descriptor_set_layout_type_flags(syms) ⇒ Object



201
202
203
204
205
206
207
208
209
210
211
# File 'lib/vulkan/conversions.rb', line 201

def syms_to_descriptor_set_layout_type_flags(syms)
  flags = 0
  syms.each do |sym|
    flags |= case sym
             when :push                   then VK_DESCRIPTOR_SET_LAYOUT_CREATE_PUSH_DESCRIPTOR_BIT_KHR
             when :update_after_bind_pool then VK_DESCRIPTOR_SET_LAYOUT_CREATE_UPDATE_AFTER_BIND_POOL_BIT_EXT
             else sym
             end
  end
  flags
end

#syms_to_flags(syms, bits) ⇒ Object



99
100
101
# File 'lib/vulkan/conversions.rb', line 99

def syms_to_flags(syms, bits)
  [syms].flatten.reduce(0) { |bit, sym| bit | sym_to_val(sym, bits) }
end

#syms_to_format_feature_flags(syms) ⇒ Object



129
130
131
# File 'lib/vulkan/conversions.rb', line 129

def syms_to_format_feature_flags(syms)
  syms_to_flags(syms, FORMAT_FEATURE_BITS)
end

#syms_to_image_aspect_flags(syms) ⇒ Object



153
154
155
# File 'lib/vulkan/conversions.rb', line 153

def syms_to_image_aspect_flags(syms)
  syms_to_flags(syms, IMAGE_ASPECT_BITS)
end

#syms_to_image_create_flags(syms) ⇒ Object



161
162
163
# File 'lib/vulkan/conversions.rb', line 161

def syms_to_image_create_flags(syms)
  syms_to_flags(syms, IMAGE_CREATE_BITS)
end

#syms_to_image_usage_flags(syms) ⇒ Object



181
182
183
# File 'lib/vulkan/conversions.rb', line 181

def syms_to_image_usage_flags(syms)
  syms_to_flags(syms, IMAGE_USAGE_BITS)
end

#syms_to_memory_properties(syms) ⇒ Object



137
138
139
# File 'lib/vulkan/conversions.rb', line 137

def syms_to_memory_properties(syms)
  syms_to_flags(syms, MEMORY_PROPERTIES)
end

#syms_to_pipeline_stage_flags(syms) ⇒ Object



149
150
151
# File 'lib/vulkan/conversions.rb', line 149

def syms_to_pipeline_stage_flags(syms)
  syms_to_flags(syms, PIPELINE_STAGE_BITS)
end

#syms_to_shader_stage_flags(syms) ⇒ Object



217
218
219
# File 'lib/vulkan/conversions.rb', line 217

def syms_to_shader_stage_flags(syms)
  syms_to_flags syms, SHADER_STAGE_BITS
end

#syms_to_surface_transforms(sym) ⇒ Object



91
92
93
# File 'lib/vulkan/conversions.rb', line 91

def syms_to_surface_transforms(sym)
  syms_to_flags sym, SURFACE_TRANSFORMS
end

#vk_make_version(version) ⇒ Object

Takes a version string and constructs a Vulkan packed version number from it.



456
457
458
459
460
# File 'lib/vulkan/conversions.rb', line 456

def vk_make_version(version)
  version = Gem::Version.new(version)
  major, minor, patch = *version.segments
  (((major) << 22) | ((minor || 0) << 12) | (patch || 0))
end

#vk_parse_version(version) ⇒ Object

returns a Gem::Version from the specified numeric Vulkan packed version number.



464
465
466
467
468
469
# File 'lib/vulkan/conversions.rb', line 464

def vk_parse_version(version)
  major = (version >> 22) & 0x3ff
  minor = (version >> 12) & 0x3ff
  patch = (version      ) & 0xfff
  Gem::Version.new([major, minor, patch].join('.'))
end