Skip to content

Geometry shader with transform feedbacks #348

@Giels

Description

@Giels

Geometry shaders seem to work.
Transform feedbacks seem to work.
But the combination of the two does not seem to generate viable code.
Consider the following:

   (defparameter vert-stream [...])
    (defparameter tf-arr
	  (make-gpu-array nil :element-type :vec3 :dimensions 3))
    (defparameter tf
	  (make-transform-feedback-stream tf-arr)))

With gpu programs:

(defun-g vert ((data :vec3))
 (values (v! data 1) data))

(defun-g geom ((data (:vec3 1)))
	 (declare (output-primitive :kind :triangle-strip :max-vertices 3))
 (emit () (v! (aref data 0) 1) (:feedback (aref data 0)))
 (emit () (v! (aref data 0) 1) (:feedback (aref data 0)))
 (emit () (v! (aref data 0) 1) (:feedback (aref data 0)))
 (end-primitive))

(defpipeline-g pp
 :vertex (vert :vec3)
 :geometry (geom (:vec3 1)))

During linking around something like

(with-transform-feedbacks (tf)
 (map-g #'pp vert-stream))

An error such as

Error Linking Program
error: Transform feedback varying _GEOMETRY_STAGE_OUT_0 undeclared.

Compiled-stages:

 // vertex-stage
#version 450

layout(location = 0)  in vec3 VERT;

out _FROM_VERTEX_STAGE_
{
     out vec3 _VERTEX_STAGE_OUT_1;
} v_out;

void main()
{
    v_out._VERTEX_STAGE_OUT_1 = VERT;
    gl_Position = vec4(VERT,1.0f);
    return;
}

 // geometry-stage
#version 450

layout (points) in;

in _FROM_VERTEX_STAGE_
{
     in vec3 _VERTEX_STAGE_OUT_1;
} v_in[1];

layout (triangle_strip, max_vertices = 3) out;

out _FROM_GEOMETRY_STAGE_
{
     out vec3 _GEOMETRY_STAGE_OUT_0;
} v_out;

void main()
{
                (gl_Position = v_in[0]._VERTEX_STAGE_OUT_1);
                v_out._GEOMETRY_STAGE_OUT_0 = vec4(v_in[0]._VERTEX_STAGE_OUT_1,1);
                EmitVertex();
    (gl_Position = v_in[0]._VERTEX_STAGE_OUT_1);
                v_out._GEOMETRY_STAGE_OUT_0 = vec4(v_in[0]._VERTEX_STAGE_OUT_1,1);
                EmitVertex();
    (gl_Position = v_in[0]._VERTEX_STAGE_OUT_1);
                v_out._GEOMETRY_STAGE_OUT_0 = vec4(v_in[0]._VERTEX_STAGE_OUT_1,1);
                EmitVertex();
            EndPrimitive();
    }
    return;
}

Appears. Modifying the program minimally to disable the feedbacks compiles and links correctly.
Caveat emptor: this is edited based on the real program which is too long. If needed, a real mwe will follow.
There's a high chance I mixed up the invocations somewhere or forgot a declaration to make this work, but there seems to be no example of the combination of geometry shaders and transform feedbacks with cepl anywhere...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions