Skip to content
This repository has been archived by the owner on Jun 12, 2022. It is now read-only.

Generated invalid constructor in geometry shader with arrays #8

Open
mika-f opened this issue Sep 5, 2021 · 0 comments
Open

Generated invalid constructor in geometry shader with arrays #8

mika-f opened this issue Sep 5, 2021 · 0 comments
Labels
category:backend-shaderlab Language Backend: ShaderLab

Comments

@mika-f
Copy link
Member

mika-f commented Sep 5, 2021

In C# source:

#if SHARPX_COMPILER

using NatsunekoLaboratory.SakuraShader.Avatars.Effects.Shader.Geometry;

using SharpX.Library.ShaderLab.Attributes;
using SharpX.Library.ShaderLab.Interfaces;
using SharpX.Library.ShaderLab.Predefined;
using SharpX.Library.ShaderLab.Primitives;
using SharpX.Library.ShaderLab.Statements;

namespace NatsunekoLaboratory.SakuraShader.Avatars.Effects.Shader
{
    [Export("geom")]
    internal class GeometryShader
    {
        [GeometryShader]
        [MaxVertexCount(32)]
        public static void GeometryMain([InputPrimitive(InputPrimitiveAttribute.InputPrimitives.Triangle)] Vertex2Geometry[] i, ref ITriangleStream<Geometry2Fragment> stream)
        {
            if (GlobalProperties.IsEnableVoxelization)
            {
                Voxelization.ApplyVoxelization(i, ref stream);
                return;
            }

            Compiler.AnnotatedStatement("unroll", () => {});
            for (SlInt j = 0; j < 3; j++)
            {
                var v2g = i[j];
                stream.Append(new Geometry2Fragment {
                    Position = UnityCg.UnityObjectToClipPos(v2g.Vertex),
                    Normal = v2g.Normal,
                    WorldPos = v2g.Vertex.XYZ,
                    LocalPos = Mul<SlFloat3>(UnityInjection.WorldToObject, v2g.Vertex),
                });
                stream.RestartStrip();
            }
        }
    }
}

transpiled as:

#ifndef  INCLUDE_GUARD_B09996429D9AD3DCAC2260282548146E
#define  INCLUDE_GUARD_B09996429D9AD3DCAC2260282548146E
#include "UnityCG.cginc"
#endif   // Auto-Generated Include Guard for UnityCG.cginc

// invalid signature
Geometry2Fragment internal_constructor_Geometry2Fragment_9(Vertex2Geometry v2g, int j, Vertex2Geometry i, TriangleStream<Geometry2Fragment> stream)
{
    Geometry2Fragment _auto_generated_initializer_ = (Geometry2Fragment) 0;
    _auto_generated_initializer_.Position = UnityObjectToClipPos(v2g.Vertex);
    _auto_generated_initializer_.Normal = v2g.Normal;
    _auto_generated_initializer_.WorldPos = v2g.Vertex.xyz;
    _auto_generated_initializer_.LocalPos = mul(unity_WorldToObject, v2g.Vertex);
    return _auto_generated_initializer_;
}

[maxvertexcount(32)]
void GeometryMain(triangle Vertex2Geometry i[3], inout TriangleStream<Geometry2Fragment> stream)
{
    if (IsEnableVoxelization)
    {
        ApplyVoxelization(i, stream);
        return;
    }
    [unroll]
    for (int j = 0; j < 3; j++)
    {
        Vertex2Geometry v2g = i[j];
        stream.Append(internal_constructor_Geometry2Fragment_9(v2g, j, i, stream));
        stream.RestartStrip();
    }
}

maybe require rewrite the generator of constructor

@mika-f mika-f added the category:backend-shaderlab Language Backend: ShaderLab label Sep 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
category:backend-shaderlab Language Backend: ShaderLab
Projects
None yet
Development

No branches or pull requests

1 participant