Comments (16)
I would say a warning for now on binding attributes declared on uniform data.
from slang.
I was reading our user guide and it seems we don't explicitly support or don't support the behavior described in this issue, this should be changed as per discussion and issue
Binding information for Vulkan (and OpenGL) may be specified using [[vk::binding(...)]] attributes.
into
Binding information for Vulkan (and OpenGL) may be specified using [[vk::binding(...)]] attributes. It is highly recommended to use
ConstantBuffer<T>
instead ofuniform
withvk::binding
.
from slang.
@ArielG-NV I am using the c++ api,
DebugInformation SLANG_DEBUG_INFO_LEVEL_MAXIMAL
Optimization SLANG_OPTIMIZATION_LEVEL_NONE
GLSLForceScalarLayout 1
from slang.
edit: answered in another comment.
from slang.
Aliasing binding is allowed, but the code isn’t using the right syntax to define buffers. A buffer should be declared as StructuredBuffer, but the vk_binding in the provided code is declared directly on an ordinary data field that will be placed in the default constant buffer, the vk_binding will have no meaning in this case.
you probably want:
[vk::binding(0,0)] ConstantBuffer<uint[1000]> addresses;
[vk::binding(0,0)] ConstantBuffer<uint[1000]> addresses1;
which defines two constant buffer resources that maps to a same binding. Note that global ordinary iniform data cannot have a binding.
from slang.
Note that global ordinary uniform data cannot have a binding.
@csyonghe should this also produce a warning?
from slang.
or should we allow automatically mapping [[vk_binding(0,0)]]
to equivalent layout
syntax in this senario?
(or maybe do both?)
from slang.
@csyonghe ahh got you, didnt know ordinary uniforms couldnt have an explicit binding,
I tried out using ConstantBuffer, but I am getting a segfault
[[vk::binding(0, 0)]] uniform ConstantBuffer<uint64_t[1000]> addresses;
[[vk::binding(0, 0)]] uniform ConstantBuffer<uint64_t[1000]> addresses1;
[shader("compute")]
[numthreads(1, 1, 1)]
void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID, uint groupIndex: SV_GroupIndex) {
printf("\nfrom gpu: %llu", addresses1[0]);
printf("\nfrom gpu: %llu", addresses1[1]);
}
my usage should be correct now ?
I am using u64 to debug because those are VkDeviceAddresses.
In actuallity I want to use pointers, I was hoping that I could just have an array of void *, but that causes another set of problems in slang (issue #4674)
from slang.
I tried out using ConstantBuffer, but I am getting a segfault
What would be the compile command used if I may ask?
from slang.
Looks like it is the array directly inside a ConstantBuffer causing error. This works:
struct V {uint64_t a[1000];};
[[vk::binding(0, 0)]] uniform ConstantBuffer<V> addresses;
[[vk::binding(0, 0)]] uniform ConstantBuffer<V> addresses1;
[shader("compute")]
[numthreads(1, 1, 1)]
void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID, uint groupIndex: SV_GroupIndex) {
printf("\nfrom gpu: %llu", addresses.a[0]);
printf("\nfrom gpu: %llu", addresses1.a[1]);
}
from slang.
Looks like it is the array directly inside a ConstantBuffer causing error. This works:
struct V {uint64_t a[1000];}; [[vk::binding(0, 0)]] uniform ConstantBuffer<V> addresses; [[vk::binding(0, 0)]] uniform ConstantBuffer<V> addresses1; [shader("compute")] [numthreads(1, 1, 1)] void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID, uint groupIndex: SV_GroupIndex) { printf("\nfrom gpu: %llu", addresses.a[0]); printf("\nfrom gpu: %llu", addresses1.a[1]); }
it compiles now, but I am still getting a validation error while trying to create the shader module
Validation Error: [ UNASSIGNED-Debug-Printf ] | MessageID = 0x9472fbd3 | vkCreateShaderModule(): Error during shader instrumentation in spirv-opt: line 71: ID '50' decorated with Block multiple times is not allowed.
%V_natural = OpTypeStruct %_Array_natural_uint641000
if you are able to run it, may I know the commit you are on ?
from slang.
@ArielG-NV I am using the c++ api,
DebugInformation SLANG_DEBUG_INFO_LEVEL_MAXIMAL Optimization SLANG_OPTIMIZATION_LEVEL_NONE GLSLForceScalarLayout 1
I will look into why
[[vk::binding(0, 0)]] uniform ConstantBuffer<uint64_t[1000]> addresses;
[[vk::binding(0, 0)]] uniform ConstantBuffer<uint64_t[1000]> addresses1;
crashes.
(issue #4704)
from slang.
Update: #4704 has a PR out, uniform ConstantBuffer<uint64_t[1000]> addresses;
should work with the PR.
it compiles now, but I am still getting a validation error while trying to create the shader module
I will now checkout this issue.
from slang.
@sivansh11 I recommend updating your Vulkan SDK to the latest one. I seem to have no trouble compiling the suggested code with Vulkan SDK version 1.3.283.0
struct V {uint64_t a[1000];}; [[vk::binding(0, 0)]] uniform ConstantBuffer<V> addresses; [[vk::binding(0, 0)]] uniform ConstantBuffer<V> addresses1; [shader("compute")] [numthreads(1, 1, 1)] void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID, uint groupIndex: SV_GroupIndex) { printf("\nfrom gpu: %llu", addresses.a[0]); printf("\nfrom gpu: %llu", addresses1.a[1]); }
from slang.
@sivansh11 I recommend updating your Vulkan SDK to the latest one. I seem to have no trouble compiling the suggested code with Vulkan SDK version 1.3.283.0
struct V {uint64_t a[1000];}; [[vk::binding(0, 0)]] uniform ConstantBuffer<V> addresses; [[vk::binding(0, 0)]] uniform ConstantBuffer<V> addresses1; [shader("compute")] [numthreads(1, 1, 1)] void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID, uint groupIndex: SV_GroupIndex) { printf("\nfrom gpu: %llu", addresses.a[0]); printf("\nfrom gpu: %llu", addresses1.a[1]); }
Yes, I am on 1.3.283.0
again this is the error that I am getting while trying to run the suggested code.
Validation Error: [ UNASSIGNED-Debug-Printf ] | MessageID = 0x9472fbd3 | vkCreateShaderModule(): Error during shader instrumentation in spirv-opt: line 71: ID '50' decorated with Block multiple times is not allowed.
%V_natural = OpTypeStruct %_Array_natural_uint641000
from slang.
Try updating Slang to 2024.1.30
It looks like the Slang version being used is affected by a spirv-opt change which was solved by Slang in a later revision.
If this does-not fix your issue, please add a comment here so I can look into the problem further.
(note: issue was closed due to solving the original problem)
from slang.
Related Issues (20)
- Support sometimes aliasing unbound arrays (`T[]`) as `T[N]`
- `ConstantBuffer<T[...]>` struct member access causes a segfault HOT 4
- Prepare code integration plan for hybrid DXIL/IR module support
- Implement remaining part for the replayer consumer
- Missing public headers in our release package.
- Write up proposal for improved AST/IR (de)serialization HOT 1
- Slang build/release
- Slang Brownbag for Autodiff IR Passes
- Handle uninitialization warnings for target switches and intrinsic asm
- Flag for enforcing validation warnings HOT 1
- Slang fails to output a `static` variable in form that is optimized by downstream compiler
- read ms workgraphs spec - come up w/presentation and walk the team through it in brownbag session
- CI Strategy
- Deploy OV unit tests in CI
- Incorporate compile-time benchmarks into CI HOT 1
- Missing cuda prelude for `make_bool2(bool)`
- Enums should be allowed to cast to bool implicitly.
- Stop using SpvStorageClass enums as `AddressSpace` values during spirv legalization.
- Check if an Apple machine can be borrowed HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from slang.