Reflection: Emit reflection information for array size literalness.

If not literal, check specialization_constant entries for "variable_id"
to link up ID with spec constant values. This maps directly to C++ API.
This commit is contained in:
Hans-Kristian Arntzen 2020-01-15 16:46:38 +01:00
parent 172e39f039
commit 18e24c3ca2
18 changed files with 235 additions and 0 deletions

View File

@ -34,6 +34,9 @@
"type" : "float",
"array" : [
1
],
"array_size_is_literal" : [
true
]
},
{
@ -41,6 +44,9 @@
"type" : "float",
"array" : [
1
],
"array_size_is_literal" : [
true
]
}
]

View File

@ -25,6 +25,9 @@
"array" : [
0
],
"array_size_is_literal" : [
true
],
"offset" : 0
}
]

View File

@ -25,6 +25,9 @@
"array" : [
0
],
"array_size_is_literal" : [
true
],
"offset" : 0
}
]
@ -38,6 +41,9 @@
"array" : [
0
],
"array_size_is_literal" : [
true
],
"offset" : 0
}
]

View File

@ -25,6 +25,9 @@
"array" : [
0
],
"array_size_is_literal" : [
true
],
"offset" : 0
}
]

View File

@ -25,6 +25,9 @@
"array" : [
0
],
"array_size_is_literal" : [
true
],
"offset" : 0
}
]

View File

@ -25,6 +25,9 @@
"array" : [
0
],
"array_size_is_literal" : [
true
],
"offset" : 0
}
]

View File

@ -25,6 +25,9 @@
"array" : [
0
],
"array_size_is_literal" : [
true
],
"offset" : 0
}
]
@ -38,6 +41,9 @@
"array" : [
0
],
"array_size_is_literal" : [
true
],
"offset" : 0
}
]

View File

@ -25,6 +25,9 @@
"array" : [
0
],
"array_size_is_literal" : [
true
],
"offset" : 0
}
]

View File

@ -25,6 +25,9 @@
"array" : [
0
],
"array_size_is_literal" : [
true
],
"offset" : 0
}
]

View File

@ -35,6 +35,9 @@
"array" : [
0
],
"array_size_is_literal" : [
true
],
"offset" : 0
}
]
@ -48,6 +51,9 @@
"array" : [
0
],
"array_size_is_literal" : [
true
],
"offset" : 0
}
]

View File

@ -25,6 +25,9 @@
"array" : [
1
],
"array_size_is_literal" : [
true
],
"offset" : 0
},
{
@ -58,6 +61,9 @@
"array" : [
1
],
"array_size_is_literal" : [
true
],
"offset" : 0
},
{
@ -101,6 +107,9 @@
"array" : [
1
],
"array_size_is_literal" : [
true
],
"offset" : 0
},
{
@ -109,6 +118,9 @@
"array" : [
1
],
"array_size_is_literal" : [
true
],
"offset" : 16
},
{
@ -117,6 +129,9 @@
"array" : [
1
],
"array_size_is_literal" : [
true
],
"offset" : 32
},
{
@ -150,6 +165,9 @@
"array" : [
8
],
"array_size_is_literal" : [
true
],
"offset" : 152
}
]
@ -168,6 +186,9 @@
"array" : [
2
],
"array_size_is_literal" : [
true
],
"offset" : 224
},
{
@ -191,6 +212,9 @@
"array" : [
4
],
"array_size_is_literal" : [
true
],
"offset" : 928
},
{
@ -211,6 +235,9 @@
"array" : [
9
],
"array_size_is_literal" : [
true
],
"offset" : 1096
},
{
@ -221,6 +248,10 @@
2,
4
],
"array_size_is_literal" : [
true,
true
],
"offset" : 1240
},
{
@ -235,6 +266,9 @@
"array" : [
0
],
"array_size_is_literal" : [
true
],
"offset" : 1472
}
]
@ -248,6 +282,9 @@
"array" : [
1
],
"array_size_is_literal" : [
true
],
"offset" : 0
},
{
@ -281,6 +318,9 @@
"array" : [
1
],
"array_size_is_literal" : [
true
],
"offset" : 0
},
{
@ -324,6 +364,9 @@
"array" : [
1
],
"array_size_is_literal" : [
true
],
"offset" : 0
},
{
@ -332,6 +375,9 @@
"array" : [
1
],
"array_size_is_literal" : [
true
],
"offset" : 32
},
{
@ -340,6 +386,9 @@
"array" : [
1
],
"array_size_is_literal" : [
true
],
"offset" : 48
},
{
@ -373,6 +422,9 @@
"array" : [
8
],
"array_size_is_literal" : [
true
],
"offset" : 192
}
]
@ -391,6 +443,9 @@
"array" : [
2
],
"array_size_is_literal" : [
true
],
"offset" : 320
},
{
@ -414,6 +469,9 @@
"array" : [
4
],
"array_size_is_literal" : [
true
],
"offset" : 1344
},
{
@ -434,6 +492,9 @@
"array" : [
9
],
"array_size_is_literal" : [
true
],
"offset" : 1552
},
{
@ -444,6 +505,10 @@
2,
4
],
"array_size_is_literal" : [
true,
true
],
"offset" : 1840
},
{
@ -458,6 +523,9 @@
"array" : [
0
],
"array_size_is_literal" : [
true
],
"offset" : 2256
}
]

View File

@ -40,16 +40,19 @@
{
"id" : 10,
"type" : "uint",
"variable_id" : 18,
"default_value" : 1
},
{
"id" : 40,
"type" : "uint",
"variable_id" : 19,
"default_value" : 1
},
{
"id" : 60,
"type" : "uint",
"variable_id" : 20,
"default_value" : 1
}
]

View File

@ -31,6 +31,9 @@
"array" : [
4
],
"array_size_is_literal" : [
true
],
"set" : 0,
"binding" : 1
},
@ -40,6 +43,9 @@
"array" : [
4
],
"array_size_is_literal" : [
true
],
"set" : 0,
"binding" : 4
},
@ -49,6 +55,9 @@
"array" : [
4
],
"array_size_is_literal" : [
true
],
"set" : 0,
"binding" : 3
},
@ -58,6 +67,9 @@
"array" : [
4
],
"array_size_is_literal" : [
true
],
"set" : 0,
"binding" : 2
}

View File

@ -14,6 +14,9 @@
"type" : "float",
"array" : [
135
],
"array_size_is_literal" : [
false
]
}
]
@ -30,41 +33,49 @@
{
"id" : 1,
"type" : "float",
"variable_id" : 9,
"default_value" : 1.5
},
{
"id" : 2,
"type" : "float",
"variable_id" : 11,
"default_value" : 2.5
},
{
"id" : 3,
"type" : "int",
"variable_id" : 16,
"default_value" : 3
},
{
"id" : 4,
"type" : "int",
"variable_id" : 25,
"default_value" : 4
},
{
"id" : 5,
"type" : "uint",
"variable_id" : 34,
"default_value" : 5
},
{
"id" : 6,
"type" : "uint",
"variable_id" : 35,
"default_value" : 6
},
{
"id" : 7,
"type" : "bool",
"variable_id" : 56,
"default_value" : false
},
{
"id" : 8,
"type" : "bool",
"variable_id" : 57,
"default_value" : true
}
]

View File

@ -0,0 +1,76 @@
{
"entryPoints" : [
{
"name" : "main",
"mode" : "vert"
}
],
"types" : {
"_11" : {
"name" : "gl_PerVertex",
"members" : [
{
"name" : "gl_Position",
"type" : "vec4"
},
{
"name" : "gl_PointSize",
"type" : "float"
},
{
"name" : "gl_ClipDistance",
"type" : "float",
"array" : [
1
],
"array_size_is_literal" : [
true
]
},
{
"name" : "gl_CullDistance",
"type" : "float",
"array" : [
1
],
"array_size_is_literal" : [
true
]
}
]
},
"_18" : {
"name" : "u_",
"members" : [
{
"name" : "u_0",
"type" : "vec4",
"array" : [
16
],
"array_size_is_literal" : [
false
],
"offset" : 0
}
]
}
},
"ubos" : [
{
"type" : "_18",
"name" : "u_",
"block_size" : 16,
"set" : 1,
"binding" : 0
}
],
"specialization_constants" : [
{
"id" : 0,
"type" : "int",
"variable_id" : 16,
"default_value" : 1
}
]
}

View File

@ -30,6 +30,10 @@
4,
3
],
"array_size_is_literal" : [
true,
true
],
"offset" : 0
}
]

View File

@ -0,0 +1,13 @@
#version 450
layout(constant_id = 0) const int ARR_SIZE = 1;
layout(binding = 0, set = 1, std140) uniform u_
{
vec4 u_0[ARR_SIZE];
};
void main()
{
gl_Position = u_0[0];
}

View File

@ -358,6 +358,11 @@ void CompilerReflection::emit_type_array(const SPIRType &type)
for (const auto &value : type.array)
json_stream->emit_json_array_value(value);
json_stream->end_json_array();
json_stream->emit_json_key_array("array_size_is_literal");
for (const auto &value : type.array_size_literal)
json_stream->emit_json_array_value(value);
json_stream->end_json_array();
}
}
@ -592,6 +597,7 @@ void CompilerReflection::emit_specialization_constants()
json_stream->begin_json_object();
json_stream->emit_json_key_value("id", spec_const.constant_id);
json_stream->emit_json_key_value("type", type_to_glsl(type));
json_stream->emit_json_key_value("variable_id", spec_const.id);
switch (type.basetype)
{
case SPIRType::UInt: