1e5c31af7Sopenharmony_ci# -*- coding: utf-8 -*-
2e5c31af7Sopenharmony_ci
3e5c31af7Sopenharmony_ci#-------------------------------------------------------------------------
4e5c31af7Sopenharmony_ci# drawElements Quality Program utilities
5e5c31af7Sopenharmony_ci# --------------------------------------
6e5c31af7Sopenharmony_ci#
7e5c31af7Sopenharmony_ci# Copyright 2015 The Android Open Source Project
8e5c31af7Sopenharmony_ci#
9e5c31af7Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
10e5c31af7Sopenharmony_ci# you may not use this file except in compliance with the License.
11e5c31af7Sopenharmony_ci# You may obtain a copy of the License at
12e5c31af7Sopenharmony_ci#
13e5c31af7Sopenharmony_ci#      http://www.apache.org/licenses/LICENSE-2.0
14e5c31af7Sopenharmony_ci#
15e5c31af7Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
16e5c31af7Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
17e5c31af7Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18e5c31af7Sopenharmony_ci# See the License for the specific language governing permissions and
19e5c31af7Sopenharmony_ci# limitations under the License.
20e5c31af7Sopenharmony_ci#
21e5c31af7Sopenharmony_ci#-------------------------------------------------------------------------
22e5c31af7Sopenharmony_ci
23e5c31af7Sopenharmony_cifrom src_util import *
24e5c31af7Sopenharmony_ci
25e5c31af7Sopenharmony_ci# Functions that have special implementation
26e5c31af7Sopenharmony_ciOVERRIDE_FUNCS = set([
27e5c31af7Sopenharmony_ci	"glGetError",
28e5c31af7Sopenharmony_ci	"glGetIntegerv",
29e5c31af7Sopenharmony_ci	"glGetBooleanv",
30e5c31af7Sopenharmony_ci	"glGetFloatv",
31e5c31af7Sopenharmony_ci	"glGetString",
32e5c31af7Sopenharmony_ci	"glGetStringi",
33e5c31af7Sopenharmony_ci	"glCreateShader",
34e5c31af7Sopenharmony_ci	"glCreateProgram",
35e5c31af7Sopenharmony_ci	"glGetShaderiv",
36e5c31af7Sopenharmony_ci	"glGetProgramiv",
37e5c31af7Sopenharmony_ci	"glGenTextures",
38e5c31af7Sopenharmony_ci	"glGenQueries",
39e5c31af7Sopenharmony_ci	"glGenBuffers",
40e5c31af7Sopenharmony_ci	"glGenRenderbuffers",
41e5c31af7Sopenharmony_ci	"glGenFramebuffers",
42e5c31af7Sopenharmony_ci	"glGenVertexArrays",
43e5c31af7Sopenharmony_ci	"glGenSamplers",
44e5c31af7Sopenharmony_ci	"glGenTransformFeedbacks",
45e5c31af7Sopenharmony_ci	"glGenProgramPipelines",
46e5c31af7Sopenharmony_ci	"glGetInternalformativ",
47e5c31af7Sopenharmony_ci	"glMapBufferRange",
48e5c31af7Sopenharmony_ci	"glCheckFramebufferStatus",
49e5c31af7Sopenharmony_ci	"glReadPixels",
50e5c31af7Sopenharmony_ci	"glBindBuffer",
51e5c31af7Sopenharmony_ci	"glDeleteBuffers",
52e5c31af7Sopenharmony_ci	"glGetAttribLocation",
53e5c31af7Sopenharmony_ci])
54e5c31af7Sopenharmony_ci
55e5c31af7Sopenharmony_ciNULL_PLATFORM_DIR = os.path.normpath(os.path.join(SCRIPTS_DIR, "..", "..", "framework", "platform", "null"))
56e5c31af7Sopenharmony_ci
57e5c31af7Sopenharmony_cidef commandDummyImpl (command):
58e5c31af7Sopenharmony_ci	if command.name in OVERRIDE_FUNCS:
59e5c31af7Sopenharmony_ci		return None
60e5c31af7Sopenharmony_ci	template = """
61e5c31af7Sopenharmony_ciGLW_APICALL {returnType} GLW_APIENTRY {commandName} ({paramDecls})
62e5c31af7Sopenharmony_ci{{
63e5c31af7Sopenharmony_ci{body}{maybeReturn}
64e5c31af7Sopenharmony_ci}}"""
65e5c31af7Sopenharmony_ci	return template.format(
66e5c31af7Sopenharmony_ci		returnType	= command.type,
67e5c31af7Sopenharmony_ci		commandName	= command.name,
68e5c31af7Sopenharmony_ci		paramDecls	= commandParams(command),
69e5c31af7Sopenharmony_ci		body		= ''.join("\tDE_UNREF(%s);\n" % p.name for p in command.params),
70e5c31af7Sopenharmony_ci		maybeReturn = "\n\treturn (%s)0;" % command.type if command.type != 'void' else "")
71e5c31af7Sopenharmony_ci
72e5c31af7Sopenharmony_cidef commandInitStatement (command):
73e5c31af7Sopenharmony_ci	return "gl->%s\t= %s;" % (getFunctionMemberName(command.name), command.name)
74e5c31af7Sopenharmony_ci
75e5c31af7Sopenharmony_cidef genNullRenderContext (iface):
76e5c31af7Sopenharmony_ci	genCommandList(iface, commandInitStatement,
77e5c31af7Sopenharmony_ci				   directory	= NULL_PLATFORM_DIR,
78e5c31af7Sopenharmony_ci				   filename		= "tcuNullRenderContextInitFuncs.inl",
79e5c31af7Sopenharmony_ci				   align		= True)
80e5c31af7Sopenharmony_ci	genCommandList(iface, commandDummyImpl,
81e5c31af7Sopenharmony_ci				   directory	= NULL_PLATFORM_DIR,
82e5c31af7Sopenharmony_ci				   filename		= "tcuNullRenderContextFuncs.inl")
83e5c31af7Sopenharmony_ci
84e5c31af7Sopenharmony_ciif __name__ == "__main__":
85e5c31af7Sopenharmony_ci	genNullRenderContext(getHybridInterface())
86