Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HLSL: Struct/class members #535

Closed
xen2 opened this issue Oct 3, 2016 · 4 comments
Closed

HLSL: Struct/class members #535

xen2 opened this issue Oct 3, 2016 · 4 comments

Comments

@xen2
Copy link

xen2 commented Oct 3, 2016

Didn't see this mentionned in #362:

  • Struct members are not supported (such as Test.T1() in the next example)
  • Optional: class keyword doesn't work (I think class and struct are the same thing?)
struct Test
{
    float4 T;
    float4 T1(float4 a)
    {
        return T + a;
    }
};

float4 PSMain() : SV_Target0 {
   Test test;
   test.T = 3.0f;
   return test.T1(5.0f);
}
ERROR: test.frag:4: ',' : Expected
ERROR: test.frag:4: 'struct member declarations' : Expected
test.frag(4): error at column 14, HLSL parsing failed.
@johnkslang
Copy link
Member

Agreed these are not supported, will add to the list, thank you.

@johnkslang
Copy link
Member

Issue #362 now points to this one.

@johnkslang
Copy link
Member

Basic functionality like this is generating correct-looking SPIR-V, so I think this is done, minus having more specific detail on what's not working that needs to work. If you can help test, that would be great, thanks.

@johnkslang
Copy link
Member

@gwihlidal the following appears to work:


struct type1
{
    void setmem(float4 m) { memVar = m; }
    void seti(int si) { i = si; }
    float4 memVar;
    float4 memFun(float4 a) : SV_Position
    {
        return i * a + memVar;
    }
    int memFun(int a) : SV_Position
    {
        return i + a - memVar.z;
    }
    int i;
};

static float2 j = i;

struct type2
{
    float2 memFun() { return i; }
};

float4 main() : SV_Target0
{
   type1 test;
   test.setmem(float4(2.0,2.0,2.0,2.0));
   test.seti(17);
   float4 f4 = float4(1.0,1.0,1.0,1.0);
   f4 += test.memFun(float4(5.0f,5.0f,5.0f,5.0f));
   f4 += test.memFun(7);
   return f4;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants