shader-slang / slang

Making it easier to work with shaders
MIT License
1.78k stars 159 forks source link

Use of base struct's resource member causes assert #4449

Open chaoticbob opened 1 week ago

chaoticbob commented 1 week ago

Shader below is hitting this assert in slang-ir-specialize-function-call.cpp::canSpecializeCall():

        for( auto param : func->getParams() )
        {
            UInt argIndex = argCounter++;
            SLANG_ASSERT(argIndex < call->getArgCount());
            auto arg = call->getArg(argIndex);

I can't say for sure if the struct definition and inheritance is correct for Slang, based on my understanding of the documentation it should be. But even if it's not, there should be an error instead of hitting the assert.

Shader

struct Base {
  ByteAddressBuffer buffer;
};

struct Child : Base {
  float load(in uint offset) {
    return asfloat(buffer.Load(offset));
  }
};

void main(out float target : SV_Target) {
  Child foo;
  target = foo.load(0);
}
csyonghe commented 1 week ago

Again, inheritance is not fully implemented or supported. We still need to decide whether or not to support inheritance in the language.

jkwak-work commented 2 days ago

@swoods-nv I think we should close this for now and keep track it as a long term task, "Implement inheritance".