Commit 21b786b1 by Jamie Madill Committed by Commit Bot

ES3: Make copy conversion set a static switch.

This removes the global std::set initialization. BUG=angleproject:1389 BUG=angleproject:1459 Change-Id: I6a7f4211905ea4a83e0e2337977e2f6fb375a7dd Reviewed-on: https://chromium-review.googlesource.com/405368Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent b0817d17
{
"From ES 3.0.1 spec, table 3.15":
[
[ "GL_ALPHA", "GL_RGBA" ],
[ "GL_LUMINANCE", "GL_RED" ],
[ "GL_LUMINANCE", "GL_RG" ],
[ "GL_LUMINANCE", "GL_RGB" ],
[ "GL_LUMINANCE", "GL_RGBA" ],
[ "GL_LUMINANCE_ALPHA", "GL_RGBA" ],
[ "GL_RED", "GL_RED" ],
[ "GL_RED", "GL_RG" ],
[ "GL_RED", "GL_RGB" ],
[ "GL_RED", "GL_RGBA" ],
[ "GL_RG", "GL_RG" ],
[ "GL_RG", "GL_RGB" ],
[ "GL_RG", "GL_RGBA" ],
[ "GL_RGB", "GL_RGB" ],
[ "GL_RGB", "GL_RGBA" ],
[ "GL_RGBA", "GL_RGBA" ]
],
"Necessary for ANGLE back-buffers":
[
[ "GL_ALPHA", "GL_BGRA_EXT" ],
[ "GL_LUMINANCE", "GL_BGRA_EXT" ],
[ "GL_LUMINANCE_ALPHA", "GL_BGRA_EXT" ],
[ "GL_RED", "GL_BGRA_EXT" ],
[ "GL_RG", "GL_BGRA_EXT" ],
[ "GL_RGB", "GL_BGRA_EXT" ],
[ "GL_RGBA", "GL_BGRA_EXT" ],
[ "GL_BGRA_EXT", "GL_BGRA_EXT" ],
[ "GL_RED_INTEGER", "GL_RED_INTEGER" ],
[ "GL_RED_INTEGER", "GL_RG_INTEGER" ],
[ "GL_RED_INTEGER", "GL_RGB_INTEGER" ],
[ "GL_RED_INTEGER", "GL_RGBA_INTEGER" ],
[ "GL_RG_INTEGER", "GL_RG_INTEGER" ],
[ "GL_RG_INTEGER", "GL_RGB_INTEGER" ],
[ "GL_RG_INTEGER", "GL_RGBA_INTEGER" ],
[ "GL_RGB_INTEGER", "GL_RGB_INTEGER" ],
[ "GL_RGB_INTEGER", "GL_RGBA_INTEGER" ],
[ "GL_RGBA_INTEGER", "GL_RGBA_INTEGER" ]
]
}
// GENERATED FILE - DO NOT EDIT.
// Generated by gen_copy_conversion_table.py using data from es3_copy_conversion_formats.json.
//
// Copyright 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// format_map:
// Determining the sized internal format from a (format,type) pair.
// Also check es3 format combinations for validity.
#include "angle_gl.h"
#include "common/debug.h"
namespace gl
{
bool ValidES3CopyConversion(GLenum textureFormat, GLenum framebufferFormat)
{
switch (textureFormat)
{
case GL_ALPHA:
switch (framebufferFormat)
{
case GL_BGRA_EXT:
case GL_RGBA:
return true;
default:
break;
}
break;
case GL_BGRA_EXT:
switch (framebufferFormat)
{
case GL_BGRA_EXT:
return true;
default:
break;
}
break;
case GL_LUMINANCE:
switch (framebufferFormat)
{
case GL_BGRA_EXT:
case GL_RED:
case GL_RG:
case GL_RGB:
case GL_RGBA:
return true;
default:
break;
}
break;
case GL_LUMINANCE_ALPHA:
switch (framebufferFormat)
{
case GL_BGRA_EXT:
case GL_RGBA:
return true;
default:
break;
}
break;
case GL_RED:
switch (framebufferFormat)
{
case GL_BGRA_EXT:
case GL_RED:
case GL_RG:
case GL_RGB:
case GL_RGBA:
return true;
default:
break;
}
break;
case GL_RED_INTEGER:
switch (framebufferFormat)
{
case GL_RED_INTEGER:
case GL_RGBA_INTEGER:
case GL_RGB_INTEGER:
case GL_RG_INTEGER:
return true;
default:
break;
}
break;
case GL_RG:
switch (framebufferFormat)
{
case GL_BGRA_EXT:
case GL_RG:
case GL_RGB:
case GL_RGBA:
return true;
default:
break;
}
break;
case GL_RGB:
switch (framebufferFormat)
{
case GL_BGRA_EXT:
case GL_RGB:
case GL_RGBA:
return true;
default:
break;
}
break;
case GL_RGBA:
switch (framebufferFormat)
{
case GL_BGRA_EXT:
case GL_RGBA:
return true;
default:
break;
}
break;
case GL_RGBA_INTEGER:
switch (framebufferFormat)
{
case GL_RGBA_INTEGER:
return true;
default:
break;
}
break;
case GL_RGB_INTEGER:
switch (framebufferFormat)
{
case GL_RGBA_INTEGER:
case GL_RGB_INTEGER:
return true;
default:
break;
}
break;
case GL_RG_INTEGER:
switch (framebufferFormat)
{
case GL_RGBA_INTEGER:
case GL_RGB_INTEGER:
case GL_RG_INTEGER:
return true;
default:
break;
}
break;
default:
break;
}
return false;
}
} // namespace gl
......@@ -299,6 +299,9 @@ bool ValidES3Format(GLenum format);
bool ValidES3Type(GLenum type);
bool ValidES3FormatCombination(GLenum format, GLenum type, GLenum internalFormat);
// Implemented in es3_copy_conversion_table_autogen.cpp
bool ValidES3CopyConversion(GLenum textureFormat, GLenum framebufferFormat);
} // namespace gl
#endif // LIBANGLE_FORMATUTILS_H_
#!/usr/bin/python
# Copyright 2016 The ANGLE Project Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# gen_copy_conversion_table.py:
# Code generation for ES3 valid copy conversions table format map.
from datetime import date
import sys
sys.path.append('renderer')
import angle_format
template_cpp = """// GENERATED FILE - DO NOT EDIT.
// Generated by {script_name} using data from {data_source_name}.
//
// Copyright {copyright_year} The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// format_map:
// Determining the sized internal format from a (format,type) pair.
// Also check es3 format combinations for validity.
#include "angle_gl.h"
#include "common/debug.h"
namespace gl
{{
bool ValidES3CopyConversion(GLenum textureFormat, GLenum framebufferFormat)
{{
switch (textureFormat)
{{
{texture_format_cases} default:
break;
}}
return false;
}}
}} // namespace gl
"""
template_format_case = """ case {texture_format}:
switch (framebufferFormat)
{{
{framebuffer_format_cases} return true;
default:
break;
}}
break;
"""
template_simple_case = """ case {key}:
"""
def parse_texture_format_case(texture_format, framebuffer_formats):
framebuffer_format_cases = ""
for framebuffer_format in sorted(framebuffer_formats):
framebuffer_format_cases += template_simple_case.format(key = framebuffer_format)
return template_format_case.format(
texture_format = texture_format, framebuffer_format_cases = framebuffer_format_cases)
data_source_name = 'es3_copy_conversion_formats.json'
json_data = angle_format.load_json(data_source_name)
format_map = {}
for description, data in json_data.iteritems():
for texture_format, framebuffer_format in data:
if texture_format not in format_map:
format_map[texture_format] = []
format_map[texture_format] += [ framebuffer_format ]
texture_format_cases = ""
for texture_format, framebuffer_formats in sorted(format_map.iteritems()):
texture_format_cases += parse_texture_format_case(texture_format, framebuffer_formats)
with open('es3_copy_conversion_table_autogen.cpp', 'wt') as out_file:
output_cpp = template_cpp.format(
script_name = sys.argv[0],
data_source_name = data_source_name,
copyright_year = date.today().year,
texture_format_cases = texture_format_cases)
out_file.write(output_cpp)
out_file.close()
......@@ -152,6 +152,7 @@
'libANGLE/angletypes.cpp',
'libANGLE/angletypes.h',
'libANGLE/angletypes.inl',
'libANGLE/es3_copy_conversion_table_autogen.cpp',
'libANGLE/features.h',
'libANGLE/format_map_autogen.cpp',
'libANGLE/formatutils.cpp',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment