lib/vulkan/swapchain_builder.rb
# Chooses and returns a swapchain image format from those supported.
# An override may be specified in
# `config[:graphics][:swapchain][:image][:format]` and/or
# `config[:graphics][:swapchain][:image][:color_space]`. The
# defaults are `:r8g8b8a8_unorm` and `:srgb_nonlinear`, respectively.
Chooses and returns a swapchain image format from those supported.
Chooses and returns a swapchain image format from those supported .
def format
      supported = surface_info.formats
      preferred_format = { format: :r8g8b8a8_unorm, color_space: :srgb_nonlinear }
      if override = config.dig(:graphics, :swapchain, :image)
        preferred_format[:format] = override[:format] if override.key?(:format)
        preferred_format[:color_space] = override[:color_space] if override.key?(:color_space)
      end
      return preferred_format if supported.size == 1 && supported[0][:format] == :undefined
      return preferred_format if supported.include?(preferred_format)
      supported.each { |sup| return sup if sup[:format] == preferred_format[:format] }
      return supported.first || raise('no supported swapchain image formats')
    end
def format supported = surface_info . formats preferred_format = { format : :r8g8b8a8_unorm , color_space : :srgb_nonlinear } if override = config . dig ( :graphics , :swapchain , :image ) preferred_format [ :format ] = override [ :format ] if override . key? ( :format ) preferred_format [ :color_space ] = override [ :color_space ] if override . key? ( :color_space ) end return preferred_format if supported . size == 1 && supported [ 0 ] [ :format ] == :undefined return preferred_format if supported . include? ( preferred_format ) supported . each { | sup | return sup if sup [ :format ] == preferred_format [ :format ] } return supported . first || raise ( 'no supported swapchain image formats' ) end
Chooses and returns a swapchain image format from those supported.
Chooses and returns a swapchain image format from those supported .
# By default use the most widely supported R8 G8 B8 A8 format with # nonlinear colorspace. # If app config specifies an override, and it is supported, then # use it. # If the list contains only one entry with an undefined format then # it means that there are no preferred surface formats and any can # be chosen. # Check if the preferred format is supported, and use it if possible # No match found, try to match the format ignoring colorspace # No match, return the first format in the list