Git Product home page Git Product logo

hcc's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hcc's Issues

Returning values from a function

I have a function (in GLSL) :

bool solve_cubic(out vec3 out_roots, vec4 coeffs)
{
....
}

where I am returning multiple values as out parameter.

In the second example I want to apply a function to some data:

void some_function(float* data, int size) {

}

My understanding is that pointers are not supported in hcc. What is the recommended
way of doing this in hcc?

Thanks.

Addressing some of the TODO list points

Hey, I'm also working on a C to Vulkan SPIR-V compiler which can be found at https://gitlab.com/nanokatze/cg2c/. Here are a bunch of example shaders:
https://gitlab.com/nanokatze/cg2c/-/blob/master/test/hello/fft_shader.c
https://gitlab.com/nanokatze/cg2c/-/blob/master/test/hello/llama_shader.c
https://gitlab.com/nanokatze/cg2c/-/blob/master/test/hello/llama2_shader.c

Yes, it does actually work.

Perhaps you will find it useful as a reference.

My compiler seems to build on stricter assumptions from those yours is built upon. For example, we don't do logical pointers here. Generic addressing 4 life! It outright requires certain features like bufferDeviceAddress and shaderInt8. This would preclude it from being translatable to current HLSL/DXIL as there's no equivalents to these features. Opaque types like images are eschewed as well, instead hidden behind some ordinary data (integer handles), which makes bindless images a prerequisite.

Anyway, to address entries from your TODO list:

goto statement

As you should've already noticed, SPIR-V doesn't allow you to branch to any random block, requiring you to explicitly say loops and ifs. One reason to do this is to maintain convergence information, i.e. so that subgroup ops or "wave intrinsics" if you prefer have sensible behavior in certain constructs. E.g. consider the following GLSL snippet

int invocationsWithSameValue(int x) {
 int y;
 for (;;) {
  if (x == subgroupBroadcastFirst(x)) {
   y = subgroupAdd(1);
   break;
  }
 }
 return y;
}

if you only have control flow graph alone, without explicit merge points like SPIR-V, this isn't distinguishable from

int invocationsWithSameValue(int x) {
 int y;
 for (;;) {
  if (x == subgroupBroadcastFirst(x)) {
   break;
  }
 }
 y = subgroupAdd(1);
 return y;
}

(please draw the CFGs by yourself)

This is to say, goto is possibly implementable with some effort. Loops formed with goto will be varying degrees of bad: unspecified tangles (sets of invocations) for subgroup ops/wave intrinsics, etc. Forward goto (i.e. equivalent of multibreak) would be perfectly fine though.

thin gpu emulator

Use lavapipe

vectors and matrix extensions

These are only important as syntactic conveniences. Don't worry about not making use of OpTypeVector or especially OpTypeMatrix. All drivers in Mesa for example share the compiler which destructs matrix types and ops into corresponding vector ops as SPIR-V is being ingested, and then vector ops are exploded into scalar ops, because working with vectors is kinda bad.

For load/stores in particular, vector types can help but you could also likely achieve an equivalent effect by specifying stricter alignment for your loads and stores, and loading and storing the compound types at once.

Roadmap?

Cool project.

Is there a tentative roadmap for this project in terms of new features?

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.