OpenGL: Support B2T and T2T copies with BC formats

This patch implements the creation, buffer-to-texture copies and
texture-to-texture copies with BC formats on OpenGL backend. Note that
OpenGL SPEC also has the same issue about texture-to-texture copies
with compressed textures as Vulkan SPEC, so we have to skip the related
case.

The texture-to-buffer copies with BC formats and related end2end tests
will be supported in the following patches.

BUG=dawn:42
TEST=dawn_end2end_tests

Change-Id: I76b16862259cb2df77f202ed7ed433d41aa3cd47
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/10220
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Jiawei Shao
2019-08-22 08:19:13 +00:00
committed by Commit Bot service account
parent 23edf95528
commit 9d9d76c590
10 changed files with 272 additions and 27 deletions

View File

@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import os, sys
import os, json, sys
from collections import namedtuple
import xml.etree.ElementTree as etree
@@ -96,12 +96,13 @@ EnumDefine = namedtuple('EnumDefine', ['name', 'value'])
Version = namedtuple('Version', ['major', 'minor'])
VersionBlock = namedtuple('VersionBlock', ['version', 'procs', 'enums'])
HeaderBlock = namedtuple('HeaderBlock', ['description', 'procs', 'enums'])
ExtensionBlock = namedtuple('ExtensionBlock', ['extension', 'procs', 'enums', 'supported_specs'])
def parse_version(version):
return Version(*map(int, version.split('.')))
def compute_params(root):
def compute_params(root, supported_extensions):
# Parse all the commands and enums
all_procs = {}
for command in root.findall('''commands[@namespace='GL']/command'''):
@@ -146,6 +147,31 @@ def compute_params(root):
gles_blocks = parse_version_blocks('gles2')
desktop_gl_blocks = parse_version_blocks('gl', core_removed_procs)
def parse_extension_block(extension):
section = root.find('''extensions/extension[@name='{}']'''.format(extension))
supported_specs = section.attrib['supported'].split('|')
section_procs = []
for command in section.findall('./require/command'):
proc_name = command.attrib['name']
assert(all_procs[proc_name].alias == None)
if proc_name not in removed_procs:
section_procs.append(all_procs[proc_name])
section_enums = []
for enum in section.findall('./require/enum'):
section_enums.append(all_enums[enum.attrib['name']])
return ExtensionBlock(extension, section_procs, section_enums, supported_specs)
extension_desktop_gl_blocks = [];
extension_gles_blocks = [];
for extension in supported_extensions:
extension_block = parse_extension_block(extension)
if 'gl' in extension_block.supported_specs:
extension_desktop_gl_blocks.append(extension_block)
if 'gles2' in extension_block.supported_specs:
extension_gles_blocks.append(extension_block)
# Compute the blocks for headers such that there is no duplicate definition
already_added_header_procs = set()
already_added_header_enums = set()
@@ -172,9 +198,17 @@ def compute_params(root):
for block in desktop_gl_blocks:
add_header_block('Desktop OpenGL {}.{}'.format(block.version.major, block.version.minor), block)
for block in extension_desktop_gl_blocks:
add_header_block(block.extension, block)
for block in extension_gles_blocks:
add_header_block(block.extension, block)
return {
'gles_blocks': gles_blocks,
'desktop_gl_blocks': desktop_gl_blocks,
'extension_desktop_gl_blocks': extension_desktop_gl_blocks,
'extension_gles_blocks': extension_gles_blocks,
'header_blocks': header_blocks,
}
@@ -183,10 +217,16 @@ class OpenGLLoaderGenerator(Generator):
return 'Generates code to load OpenGL function pointers'
def add_commandline_arguments(self, parser):
parser.add_argument('--gl-xml', required=True, type=str, help ='The Khronos gl.xml to use.')
parser.add_argument('--gl-xml', required=True, type=str, help='The Khronos gl.xml to use.')
parser.add_argument('--supported-extensions', required=True, type=str, help ='The JSON file that defines the OpenGL and GLES extensions to use.')
def get_file_renders(self, args):
params = compute_params(etree.parse(args.gl_xml).getroot())
supported_extensions = []
with open(args.supported_extensions) as f:
supported_extensions_json = json.loads(f.read())
supported_extensions = supported_extensions_json['supported_extensions']
params = compute_params(etree.parse(args.gl_xml).getroot(), supported_extensions)
return [
FileRender('opengl/OpenGLFunctionsBase.cpp', 'dawn_native/opengl/OpenGLFunctionsBase_autogen.cpp', [params]),