[core] Include type in #pragmas
Part of https://github.com/mapbox/mapbox-gl-shaders/pull/13.
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
"csscolorparser": "^1.0.2",
|
||||
"ejs": "^2.4.1",
|
||||
"express": "^4.11.1",
|
||||
"mapbox-gl-shaders": "mapbox/mapbox-gl-shaders#be09fce1d01e63de69f019e953261832d16ec88c",
|
||||
"mapbox-gl-shaders": "mapbox/mapbox-gl-shaders#8dfd9653e6659cb2837a4b98f3e8e1d559b29a09",
|
||||
"mapbox-gl-style-spec": "^8.5.1",
|
||||
"mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#f45fd7aba98650c7f3bf778c9cbbfd3b548a4ee8",
|
||||
"node-gyp": "^3.3.1",
|
||||
|
||||
@@ -20,27 +20,21 @@ with open(input_file, "r") as f:
|
||||
|
||||
# Replace uniform pragmas
|
||||
|
||||
pragma_mapbox_regex = re.compile("(\s*)\#pragma \mapbox\: (initialize|define) (.*) (lowp|mediump|highp)")
|
||||
color_regex = re.compile("(.*)color")
|
||||
pragma_mapbox_regex = re.compile("(\s*)\#pragma \mapbox\: (define|initialize) (low|medium|high)p (float|vec(2|3|4)) (.*)")
|
||||
|
||||
def replace_uniform_pragmas(line):
|
||||
# FIXME We should obtain these from the source code.
|
||||
if pragma_mapbox_regex.match(line):
|
||||
params = line.split()
|
||||
u_method = params[2]
|
||||
u_name = params[3]
|
||||
u_precision = params[4]
|
||||
u_type = "vec4" if color_regex.match(u_name) else "float"
|
||||
if u_method == "define":
|
||||
return """uniform {precision} {type_} u_{name};""".format(
|
||||
precision = u_precision,
|
||||
type_ = u_type,
|
||||
name = u_name)
|
||||
if params[2] == "define":
|
||||
return """uniform {u_precision} {u_type} u_{u_name};""".format(
|
||||
u_precision = params[3],
|
||||
u_type = params[4],
|
||||
u_name = params[5])
|
||||
else:
|
||||
return """ {precision} {type_} {name} = u_{name};""".format(
|
||||
precision = u_precision,
|
||||
type_ = u_type,
|
||||
name = u_name)
|
||||
return """ {u_precision} {u_type} {u_name} = u_{u_name};""".format(
|
||||
u_precision = params[3],
|
||||
u_type = params[4],
|
||||
u_name = params[5])
|
||||
else:
|
||||
return line
|
||||
|
||||
|
||||
Reference in New Issue
Block a user