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

Applicability to other C-like languages? #10

Open
loren-osborn opened this issue May 14, 2019 · 4 comments
Open

Applicability to other C-like languages? #10

loren-osborn opened this issue May 14, 2019 · 4 comments

Comments

@loren-osborn
Copy link

I was wondering if anyone has investigated if some or all of these work on other C-based languages that include support for a similar preprocessor. (I would like to use something like this for explicit loop-unrolling given that the compilers for these languages lack much of the optimization capabilities of modern C compilers.)

I’m thinking specifically of:

These are basically very simplified subsets of C/C++ for writing GPU shaders.

@loren-osborn loren-osborn changed the title Applicability to other C-like languages Applicability to other C-like languages? May 14, 2019
@pfultz2
Copy link
Owner

pfultz2 commented May 15, 2019

If those languages require a compliant C99 preprocessor then that will work, I believe opencl does specify a C99 preprocessor, but that doesn't mean an implementation maybe fully compliant. If the languages are llvm-based its very likely so.

@loren-osborn
Copy link
Author

loren-osborn commented May 15, 2019

I believe earlier versions of GLSL did not include the ## token pasting operator, but i’ve read that current versions do. I’m unsure if GLSL specifies a C99 compliant preprocessor specifically, as I have yet to review the GLSL spec, but the OSL spec simply states:

Open Shading Language compilers support the full complement of
C/C++ preprocessing directives, including:

    #define
    #undef
    #if
    #ifdef
    #ifndef
    #elif
    #else
    #endif
    #include
    #pragma once

which sounds somewhat ambiguous to me.

Updated:
I have already asked the OSL maintainers about the # and ## operators, and they confirmed that they are supported.

@pfultz2
Copy link
Owner

pfultz2 commented May 15, 2019

Yea, you can try to run the test.h header and see if it produces the correct output.

@loren-osborn
Copy link
Author

I will need to investigate if I can capture the Preprocessor output.

Also note: Be aware that most shader languages are currently expected to be compiled primarily at runtime rather than build time until intermediate cross-GPU shader formats like SPIR-V become widely utilized.

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

No branches or pull requests

2 participants