https://github.com/shader-slang/slang
Revision 788556aaaab1b5767e24cf86dc2f71fd285c06f5 authored by Tim Foley on 19 February 2020, 22:36:44 UTC, committed by GitHub on 19 February 2020, 22:36:44 UTC
When a shader only uses `ParameterBlock`s plus a single buffer for root constants:

```hlsl
ParameterBlock<A> a;
ParameterBlock<B> b;

[[vk::push_constant]] cbuffer Stuff { ... }
```

we expect the push-constant buffer should not affect the `space` allocated to the parameter blocks (so `a` should get `space=0`).

This behavior wasn't being implemented correctly in `slang-parameter-binding.cpp`. There was logic to ignore certain resource kinds in entry-point parameter lists when computing whether a default space is needed, but the equivalent logic for the global scope only considered parameters that consuem whole register spaces/sets.

This change shuffles the code around and makes sure it considers a global push-constant buffer as *not* needing a default space/set.

Note that this change will have no impact on D3D targets, where `Stuff` above would always get put in `space0` because for D3D targets a push-constant buffer is no different from any other constant buffer in terms of register/space allocation.

One unrelated point that this change brings to mind is the `[[vk::push_constant]]` should ideally also be allowed to apply to an entry point (where it would modify the default/implicit constant buffer). In fact, it could be argued that push-constant allocation should be the *default* for (non-RT) entry point `uniform` parameters (while `[[vk::shader_record]]` should be the default for RT entry point `uniform` parameters).
1 parent 9603fde
History
Tip revision: 788556aaaab1b5767e24cf86dc2f71fd285c06f5 authored by Tim Foley on 19 February 2020, 22:36:44 UTC
Don't allocate a default space for a VK push-constant buffer (#1231)
Tip revision: 788556a
File Mode Size
docs
examples
external
prelude
source
tests
tools
.editorconfig -rw-r--r-- 937 bytes
.gitattributes -rw-r--r-- 95 bytes
.gitignore -rw-r--r-- 480 bytes
.gitmodules -rw-r--r-- 774 bytes
.travis.yml -rw-r--r-- 1.7 KB
CODE_OF_CONDUCT.md -rw-r--r-- 3.1 KB
LICENSE -rw-r--r-- 1.1 KB
README.md -rw-r--r-- 7.1 KB
appveyor.yml -rw-r--r-- 4.0 KB
premake5.lua -rw-r--r-- 29.4 KB
slang-com-helper.h -rw-r--r-- 4.8 KB
slang-com-ptr.h -rw-r--r-- 4.8 KB
slang-tag-version.h -rw-r--r-- 36 bytes
slang.h -rw-r--r-- 126.9 KB
slang.sln -rw-r--r-- 10.8 KB
test.bat -rw-r--r-- 1.4 KB
travis_build.sh -rw-r--r-- 460 bytes
travis_test.sh -rw-r--r-- 435 bytes

README.md

back to top