Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GL API support info #99

Merged
merged 2 commits into from
Oct 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 33 additions & 13 deletions formats-include.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

METAL_URL_BASE = 'https://developer.apple.com/documentation/metal/mtlpixelformat/'
DXGI_URL = 'https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format'
WEBGL_EX_URL_BASE = 'https://www.khronos.org/registry/webgl/extensions/'

formats = JSON.parse(File.read(File.join(reader.dir, target)), :symbolize_names => true).freeze

Expand All @@ -18,45 +19,64 @@
content << "#{format[:vkFormat]}::\n"

content << "Layout:::\n"
content << "* Type Size: #{format[:typeSize]}\n"
content << "* Type Size: #{format[:typeSize]}.\n"
if format[:blockWidth] > 0
content << "* Texel Block Dimensions: #{format[:blockWidth]}x#{format[:blockHeight]}x#{format[:blockDepth]}\n"
content << "* Texel Block Dimensions: #{format[:blockWidth]}x#{format[:blockHeight]}x#{format[:blockDepth]}.\n"
end

content << "OpenGL:::\n"
if format[:glInternalFormat]
content << "* `glInternalFormat`: #{format[:glInternalFormat]}\n"
content << "* `glInternalFormat`: #{format[:glInternalFormat]}.\n"

if format[:glFormat] && format[:glType]
content << "* `glFormat`: #{format[:glFormat]}\n"
content << "* `glType`: #{format[:glType]}\n"

if format[:glDesktopOnly]
content << "* This mapping relies on OpenGL driver conversion. It may be unavailable in OpenGL ES.\n"
end
content << "* `glFormat`: #{format[:glFormat]}.\n"
content << "* `glType`: #{format[:glType]}.\n"
end

write_gl_api_support('OpenGL', format[:glVersion], format[:glExtensions], content)
write_gl_api_support('OpenGL ES', format[:glEsVersion], format[:glEsExtensions], content)
write_gl_api_support('WebGL', format[:glWebVersion], format[:glWebExtensions], content)

else
content << "* No mapping available.\n"
end

content << "Direct3D:::\n"
if format[:dxgiFormat]
content << "* `DXGI_FORMAT`: #{DXGI_URL}[#{format[:dxgiFormat]}]\n"
content << "* `DXGI_FORMAT`: #{DXGI_URL}[#{format[:dxgiFormat]}].\n"
else
content << "* No mapping available.\n"
end

content << "Metal:::\n"
if format[:mtlFormat]
content << "* `MTLPixelFormat`: #{METAL_URL_BASE}#{format[:mtlFormat]}[#{format[:mtlFormat]}]\n"
content << "* `MTLPixelFormat`: #{METAL_URL_BASE}#{format[:mtlFormat]}[#{format[:mtlFormat]}].\n"
else
content << "* No mapping available.\n"
end

content << "\n"
end

reader.push_include content
end
end
end

def write_gl_api_support(name, version, extensions, content)
content << "#{name} Support::::\n"

if version
content << "** Core #{version}+.\n"
end

if extensions
extensions.each do |exts|
content << "** "
content << exts.map { |ext| name == 'WebGL' ? "#{WEBGL_EX_URL_BASE}#{ext}[`#{ext}`]" : "`#{ext}`" }.join(' + ')
content << ".\n"
end
end

unless version || extensions
content << "** None.\n"
end
end
Loading