Comments (3)
For cross-compilation, the reflection data should be the same as for HLSL, so you don't have to care about what it would translate to in GLSL.
For the raw GLSL case, it is going to reflect as a buffer with an array in it, yeah. I would assume the user would bind things just as they would for an array in a cbuffer
today.
from slang.
A bit of follow-up on this (mostly for my own benefit). Part of the question here is about a convention that Falcor can use to have hand-written GLSL that appear "the same" to its reflection system as a StructuredBuffer<T>
. That is an interesting problem, but out of scope for Slang to solve. Slang's job would be to report the global-scope buffer
block to you as accurately as possible (I'm not sure how I do on that right now...).
There actual Slang issue is what to do with a StructureBuffer<T>
type when used in Slang code.
Given a global-scope declaration like you show:
struct Foo { float3 bar; };
StructuredBufer<Foo> gFoo;
There are two big issues:
- What to do with the actual global-scope shader parameter declaration
- What to do with uses of
StructuredBuffer<Foo>
at other locations (e.g., as a function parameter)
For (1) the ideal answer is a translation like Nir shows above (with a bit of name-change sleight-of-hand):
struct Foo { vec3 var; };
layout(..) buffer SLANG_buffer_gFoo {
Foo gFoo[];
};
In this case, the name gFoo
does not refer to the whole buffer
, but to the array member inside it. Simple expressions like gFoo[i]
in HLSL translate naturally over to GLSL.
The tricky bit, then, is that when the type StructuredBuffer<Foo>
appears in any other context, we need to translate it as Foo[]
- an unsized array of Foo
s. This should make it semantically okay to pass gFoo
as a parameter to a function.
The big problem with that last bit is that the GLSL semantics for function calls are pass-by-value-result, which means we would technically copy the whole array, which might not even be legal. So thinking about it further, this would probably rely on an implementation that can specialize the callee function based on the known identity of resource parameters passed in. That is something we'll need to get to eventually on Slang, but isn't at the top of my to-do list any time soon.
from slang.
The IR-based code generator has an initial implementation of this conversion, so I think we can close this specific issue.
StructureBuffer
variables declared as global shader parameters should work when cross-compiled to GLSL. We currently don't do a correct conversion when a StructuredBuffer<X>
type is used for a function parameter (or a type passed as part of a function parameter), so that would still leave more work...
from slang.
Related Issues (20)
- Tests: Vk Validation Layer errors: `tests\metal\texture.slang`
- AD Cleanup: Remove array & pair-specific logic for `dadd` and `dzero` methods.
- IR: emitVectorReshape fails if param `type` is a vector whilst param `value` is a scalar
- Support HLSL swizzle operations
- Post-op multiplication results in ambiguous call HOT 1
- Allow casting of `float4` to `float2x2` and vice versa
- Slang stdlib: Remove `__intrinsic_asm "<invalid intrinsic*>"` in favor of `static_assert`
- Document COM API more fully
- Capabilities System: Rework all uses of Profile to just be an alias/wrapper of a CapabilitySet
- Capabilities System: Check if set capabilities are incompatible with the current target/stage, error if not compatible
- Cpature/Replay: Design a unique file name mechanism when trying to dump the shader files
- For `HLSL` targets, `select()` is emitted as `?:`, which is no longer supported for vector types in HLSL 2021 (default in DXC 1.7+)
- Feature Request: Reflection API for functions
- Missing support for `Texture2DMSArray`
- `tbuffer` use causes silent failure due to layout rules HOT 2
- Question: How does Slang handle forward declaration of functions
- Function param input modifiers `out` and `inout` are unexpectedly strict HOT 2
- Latest macOS release x64 build is actually an ARM64 build
- `and` intrinsic does not support vector arguments HOT 1
- SPIRV and Metal `TextureBufferType` support HOT 4
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.