Coder Social home page Coder Social logo

Comments (9)

dneto0 avatar dneto0 commented on June 27, 2024 2

I think we should mimic GCC's -masm=dialect option.
https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html#index-masm_003d_0040var_007bdialect_007d-2832

So you'd use -S to emit assembly and -masm=c to say you want C source.

One difficulty is in saying what variable name you want for the result. You might want to do this with several binaries.
So how about we just emit a brace-initialization list of values, and it's up to you to wrap the result.
eg. the output could be

  {  0x07230203, 0x00010000, 0x00080000, 1, 0 }

And you'd put that into a "binary.inc"
Then in your C code (or C++ code) you'd say

static uint32_t empty_binary[] = 
#include "binary.inc"
;

The point is that all the decisions about integrating it into the rest of your program are left to you, rather than adding lots of config parameters to glslc.

In this case I'd be tempted to use -masm=c-init-list as the option.

from shaderc.

dekimir avatar dekimir commented on June 27, 2024

Shaderc follows closely the glslang design here, and glslang only has functions to compile into a vector<unsigned int> for now.

from shaderc.

Themaister avatar Themaister commented on June 27, 2024

True, but emitting a C header is essentially just a different way of dumping the u32 vector to disk, so it shouldn't affect glslang at all. It is standalone enough that this could even be a separate binary.

from shaderc.

dekimir avatar dekimir commented on June 27, 2024

Sorry, I thought you were proposing a libshaderc interface extension. But it sounds like you just want to take the spv_binary and print its elements into a .h file? That's doable in ~4 lines of code, I think. Or are you proposing that we add a flag to glslc to do it automatically?

from shaderc.

Themaister avatar Themaister commented on June 27, 2024

I was thinking about adding some flags to glslc to dump out a header instead of raw .spv.
Again, trivial to do, but it's very convenient.

from shaderc.

dekimir avatar dekimir commented on June 27, 2024

@Themaister: makes sense. We'll come up with a suitable flag name and implement.

from shaderc.

Themaister avatar Themaister commented on June 27, 2024

That's a solid solution. It is indeed nice to avoid having to specify the array name on CLI, and it's also nice to avoid having to specify static/constness of the array in question. It can also be used as an initializer list in C++11 that way too.

from shaderc.

antiagainst avatar antiagainst commented on June 27, 2024

#218 is landed. Closing.

from shaderc.

Themaister avatar Themaister commented on June 27, 2024

Works great. Thanks :)

from shaderc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.