Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[opengl] Save opengl aot data in json format. #3417

Merged
merged 1 commit into from
Nov 8, 2021

Conversation

ailzhang
Copy link
Contributor

@ailzhang ailzhang commented Nov 8, 2021

This PR does two things:

  1. It converts TextSerializer to output json format instead of a customized format. I tried to not introduce any extra dependency like jsoncpp but just make our output json compliant. (two regex tricks are used :P)
  2. Since Json doesn't support multiple line string, it saves each glsl kernel source code in a .glsl file and only saves the filename in json.

Example generated aot json file: https://gist.github.com/ailzhang/48b6126cabae2e9f2d35da02b210a719

Currently I only changed opengl backend to json, will change metal later together with enabling its tests.

@ailzhang ailzhang requested a review from k-ye November 8, 2021 01:23
@netlify
Copy link

netlify bot commented Nov 8, 2021

✔️ Deploy Preview for jovial-fermat-aa59dc canceled.

🔨 Explore the source changes: 56da36b

🔍 Inspect the deploy log: https://app.netlify.com/sites/jovial-fermat-aa59dc/deploys/61887bfb8369ad0007d1897a

@ailzhang ailzhang requested a review from bobcao3 November 8, 2021 01:23
@@ -636,9 +638,25 @@ class TextSerializer : public Serializer {
this->process(key, t);
}

// Entry to make an AOT json file
template <typename T>
void serialize_to_json(const char *key, const T &t) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, is this all we need for generating conforming JSON... ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since our output structure is kinda stable so yea it's pretty simple to generate a conforming JSON. To simplify the problem, I didn't use [] at all, but keep using {} for now which is sufficient for simple cases. :P

Copy link
Member

@k-ye k-ye left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, LGTM!

@ailzhang ailzhang merged commit 2ea7007 into taichi-dev:master Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants