Giter Club home page Giter Club logo

Comments (5)

csyonghe avatar csyonghe commented on June 20, 2024 1

I updated the documentation. Removed out of date doc on the API. Please check the user guide for the compilation and reflection API.

from slang.

csyonghe avatar csyonghe commented on June 20, 2024 1

You are right, it should be SUB_ELEMENT_REGISTER_SPACE. I have updated the documentation here: https://shader-slang.com/slang/user-guide/reflection.html

You are right that the "binding" for ordinary uniforms are byte offsets for that uniform in the constant buffer. All global uniforms are placed in a default constant buffer that has the same binding. You can query the binding with getGlobalConstantBufferBinding.

from slang.

Jebbly avatar Jebbly commented on June 20, 2024

When I add more parameters as follows:

uniform float a;
uniform float b;
ParameterBlock<Buffers> buffers;
ParameterBlock<Buffers> buffers2;

The GLSL is again what I'd expect (with a and b being located in the default set 0 now, and the parameter blocks occupying sets 1 and 2 respectively. However, again using the same loop as before, I see the following being printed:

set 0, binding 0: float a                                                                                               
set 0, binding 4: float b                                                                                               
set 0, binding 1: ParameterBlock buffers                                                                                
set 0, binding 2: ParameterBlock buffers2      

For some more context, I'm directly using Slang as a submodule (at the latest commit as of right now), and I'm using this as the target description:

slang::TargetDesc target_info = {
    .format = SLANG_SPIRV,
    .profile = global_session_->findProfile("glsl_450"),
    .flags = SLANG_TARGET_FLAG_GENERATE_SPIRV_DIRECTLY,
};

from slang.

csyonghe avatar csyonghe commented on June 20, 2024

You also need to add the result from calling variable->getOffset(SLANG_PARAMETER_CATEGORY_REGISTER_SPACE).

from slang.

Jebbly avatar Jebbly commented on June 20, 2024

Thank you for the quick response! I found that SLANG_PARAMETER_CATEGORY_SUB_ELEMENT_REGISTER_SPACE seems to provide the expected result over SLANG_PARAMETER_CATEGORY_REGISTER_SPACE. Or is it necessary to add both of them together?

In both cases, I'm still seeing the uniform float b having an index of 4 even though I'd expect it to have an index of 1 in the default set. Is there also an offset I should be adding to the index as well?

EDIT: I see the documentation mentions that the index is actually the byte offset in its parent if the type is a Uniform. Will all "ordinary" resources be bound to the same uniform?

from slang.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.