Closed ghost closed 6 years ago
Defining node-0 inside of labels
within the main function yields the correct code. However, defining the nodes this way forces recompilation of every node even when only one changes as the whole of the main function needs to be recompiled.
Recent changes in master have broken this feature. I'll fix this now.
The original node-0
function would need to take the data variable as an argument. Uniforms do not propagate to other functions automatically.
I have fixed the bug I mentioned an hour ago.
Next I compiled this code
(uiop:define-package :moo
(:use :cl :cepl :vari))
(in-package :moo)
(defstruct-g my-data
(foo (:int 1000)))
(defun-g a-helper ((x my-data))
(let ((foo (my-data-foo x)))
(aref foo 0)))
(defun-g my-stage (&uniform (y my-data :ssbo))
(declare (local-size :x 1 :y 1 :z 1))
(a-helper y) ;; ← here we pass the ssbo to the function
(values))
(defpipeline-g some-compute-dodad ()
:compute my-stage)
and then called (map-g #'some-compute-dodad nil)
to make sure it
built the pipeline and then ran (pull-g #'some-compute-dodad)
and
got:
("// compute-stage
#version 450
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(std140) buffer _SSBO_Y
{
int[1000] FOO;
} Y;
int A_HELPER0();
int A_HELPER0()
{
int[1000] FOO0 = Y.FOO;
return FOO0[0];
}
void main()
{
A_HELPER0();
return;
}
")
Notice that Varjo knows that the SSBO cant be passed like a value in GLSL so it makes a special version of your function that doesnt take the argument.
So that is how it's supposed to work. I was looking at some examples in regular glsl and couldn't figure out how to tell what I meant to varjo. Add to that a little bug and I got confused. Thank you.
@tsili you're doing great work. thanks for all the input
I'm still trying to get the node functions to work outside of the main function. Maybe you could help me with figuring how to get around this one. As you know the models I'm developing are constructed from nodes and from the point of view of both cepl and varjo, those are both functions. Nodes being regular gpu functions and model being the main function in the pipeline.
Below I have an example code for a simple node that fails to build because of an undefined variable data. This is expected as that variable is not defined in the node, but in the model as ssbo.
Copying this definition into the node function does pass the initial check.
(defun-g node (&uniform (data model :ssbo)) rest-of-the-function)
However, when the model itself is defined as below.I get an interesting error.
As far as I think I know, the first definition of the
node-0
would be translatable to valid glsl when the definitions from the model-shader are taken into account. And in the case where the definitions are provided as in the modified definition of node-0, there should be no problem at all. There is the possibility that the ssbo that the node-0 needs access to is defined incorrectly in the function definition of node-0, but I can't see what I'm doing wrong here.For completeness, let me give definitions for the model struct as well.
and the expected glsl as the result from varjo