Comments (8)
This seems like a compiler issue; if I build your test shader with dxc, spirv-reflect finds both descriptor bindings as expected. With glslc or glslangValidator it behaves as you describe.
from spirv-reflect.
That really just means the trigger being looked for is different. We need a tighter clue about what is actually wrong. The SPIR-V looks correct, and works on drivers. Maybe we should discuss here, until we know?
What trigger is being looked for?
The glslang SPIR-V looks quite similar for the two buffers:
$Global:
Decorate 13($Global) Block
13($Global): TypeStruct 7(fvec4)
14: TypePointer Uniform 13($Global)
15: 14(ptr) Variable Uniform
u_test1:
Decorate 21 Block
21: TypeStruct 7(fvec4)
22: TypePointer Uniform 21(struct)
23: 22(ptr) Variable Uniform
from spirv-reflect.
Random note: neither fxc nor dxc will compile the original shader unless the cbuffer in b0 is given a name:
cbuffer MyConstants : register(b0)
glslc and glslangValidator accept it as written.
from spirv-reflect.
So @johnkslang, I took the following shader code:
uniform float4 u_test0;
cbuffer MyConstants : register(b0)
{
float4 u_test1;
float4 u_test2;
};
void main(out float4 fragColor : SV_TARGET0)
{
fragColor = u_test0 * u_test1 * u_test2;
}
[EDIT: I just noticed I added a second float to the named cbuffer compared to the original shader; that was for an unrelated test that I forgot to revert, but it should be harmless for the purposes of this issue.]
I compiled it with both compilers:
> glslc -fshader-stage=frag -fentry-point=main -o global_cbuffer_glslc.spv global_cbuffer.hlsl
> dxc -spirv -T ps_6_0 -E main -Fo global_cbuffer_dxc.spv global_cbuffer.hlsl
The disassembled SPIR-V for both cases is attached.
I am a total white-belt when it comes to reading SPIR-V, but I know that SPIRV-Reflect uses Binding
decorations to identify descriptor bindings. I see two Binding
decorators in the dxc output, and only one in the glslang output. So, that explains the mismatch; the question (which I am not remotely qualified to answer) is which side should be fixed?
global_cbuffer_dxc.spv.txt
global_cbuffer_glslang.spv.txt
from spirv-reflect.
How did dxc know where to bind? That seems a convention, and there are also ways to ask glslang to bind as well. For example, using --amb
.
Is there an agreed on convention about how to bind $Global? Is that convention from MS or Google?
from spirv-reflect.
IIRC, $Globals and $Params, using FXC, are assigned a register using what appears to be the next available register in #b with space0.
DXC/SPIR-V follows this same convention but assigns a binding in set 0, I believe. There is an attribute directive that permits you to force a binding number for $Globals. I can't recall what it is off the top of my head. @antiagainst will know.
from spirv-reflect.
+1 to what @chaoticbob said. We are following fxc behavior to use the next available binding in set 0 for the $Globals
cbuffer. There is no way to manually pick the binding number for it right now. An attribute like vk::globals_binding
was considered but haven't gotten implemented yet. One reason is not seeing real requests from developers; another reason is not sure about where to attach that attribute to. (Attaching to the entry point seems reasonable, but then we lose the ability to share the info among multiple entry points in the same file unless we attach all of them.)
from spirv-reflect.
Closing this since it's a compiler behavior and not that of SPIRV-Reflect.
from spirv-reflect.
Related Issues (20)
- Compiler warning for missing field initializers HOT 3
- Update the README.md file for extra dependency HOT 1
- Add runtime array info to SpvReflectBindingArrayTraits HOT 1
- Vertex Input structs don't have formats in members HOT 1
- No Vertex Input Location for structs HOT 1
- Getting error 20 code (SPV_REFLECT_RESULT_ERROR_SPIRV_INVALID_EXECUTION_MODE) when trying to use functions from extension GL_ARB_fragment_shader_interlock HOT 5
- Remove support for bazel builds HOT 2
- Decide how to handle array interfaces
- Handle buffer reference with arrays to themselves HOT 4
- Empty push constant block name after 56d6806 HOT 2
- resource type for COMBINED_IMAGE_SAMPLER HOT 3
- Geometry Array-of-BuiltIns doesn't label builtin correctly
- Reflecting capabilities used by a shader more finely HOT 8
- Add SECURITY.md HOT 1
- Null pointer dereference HOT 2
- Handle OpCopy* instructions
- Structure layout reuse does not enumerate structure member count HOT 2
- buffer_reference through push constant causing Assert/crash in spirv-reflect HOT 1
- Feature request: reflect referenced members of a ByteAddressBuffer HOT 8
- Reflect SPV_REFLECT_DESCRIPTOR_TYPE_SAMPLE_WEIGHT_IMAGE_QCOM when decoration_flag contains SPV_REFLECT_DECORATION_WEIGHT_TEXTURE 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 spirv-reflect.