Prep for swapping JSON parser.

This commit is contained in:
Chinmay Garde
2021-06-11 15:29:29 -07:00
committed by Dan Field
parent 58c4d7ea73
commit 75eff71fe3
2 changed files with 24 additions and 5 deletions

View File

@@ -29,7 +29,6 @@ struct {{camel_case(shader_name)}}{{camel_case(shader_stage)}}Info {
// ===========================================================================
// Stage Uniforms ============================================================
// ===========================================================================
{% for uniform in uniform_buffers %}
static constexpr auto kUniform{{camel_case(uniform.name)}} = ShaderStageIOSlot { // {{uniform.name}}

View File

@@ -123,6 +123,7 @@ static bool ReflectType(Writer& writer,
writer.Key("columns");
writer.Uint64(type.columns);
// Member types should only be present if the base type is a struct.
if (!type.member_types.empty()) {
writer.Key("member");
writer.StartArray();
@@ -254,11 +255,12 @@ static std::shared_ptr<fml::Mapping> ReflectTemplateArguments(
writer.String(options.header_file_name);
}
const auto all_shader_resources = compiler.get_shader_resources();
{
writer.Key("uniform_buffers");
writer.StartArray();
for (const auto& uniform_buffer :
compiler.get_shader_resources().uniform_buffers) {
for (const auto& uniform_buffer : all_shader_resources.uniform_buffers) {
if (!ReflectUniformBuffer(writer, ir, compiler, uniform_buffer)) {
FML_LOG(ERROR) << "Could not reflect uniform buffer.";
return nullptr;
@@ -270,7 +272,7 @@ static std::shared_ptr<fml::Mapping> ReflectTemplateArguments(
{
writer.Key("stage_inputs");
writer.StartArray();
for (const auto& input : compiler.get_shader_resources().stage_inputs) {
for (const auto& input : all_shader_resources.stage_inputs) {
if (!ReflectStageIO(writer, ir, compiler, input)) {
FML_LOG(ERROR) << "Could not reflect stage input.";
return nullptr;
@@ -282,7 +284,7 @@ static std::shared_ptr<fml::Mapping> ReflectTemplateArguments(
{
writer.Key("stage_outputs");
writer.StartArray();
for (const auto& output : compiler.get_shader_resources().stage_outputs) {
for (const auto& output : all_shader_resources.stage_outputs) {
if (!ReflectStageIO(writer, ir, compiler, output)) {
FML_LOG(ERROR) << "Could not reflect stage output.";
return nullptr;
@@ -291,6 +293,24 @@ static std::shared_ptr<fml::Mapping> ReflectTemplateArguments(
writer.EndArray();
}
{
auto reflect_types =
[&](const spirv_cross::SmallVector<spirv_cross::Resource> resources)
-> bool {
for (const auto& resource : resources) {
}
return true;
};
writer.Key("type_definitions");
writer.StartArray();
if (!reflect_types(all_shader_resources.uniform_buffers) ||
!reflect_types(all_shader_resources.stage_inputs) ||
!reflect_types(all_shader_resources.stage_outputs)) {
return nullptr;
}
writer.EndArray();
}
writer.EndObject(); // root
return std::make_shared<fml::NonOwnedMapping>(