amethyst/rendy

Uniform buffer in vertex shader "disappears" when adding uniforms to fragment shader

maroider opened this issue · 7 comments

I'm currently trying to "port" glium's incomplete tutorial to rendy by looking at rendy's examples and API docs. I've unfortunately hit a roadblock on part 6 "Uploading a texture". The uniform buffer I was already using successfully "dissapears" when I add uniform texture2D and uniform sampler colorsampler to the fragment shader. ShaderReflection.layout().unwrap() returns

Layout {
    sets: [
        SetLayout {
            bindings: [
                DescriptorSetLayoutBinding {
                    binding: 1,
                    ty: SampledImage,
                    count: 1,
                    stage_flags: FRAGMENT,
                    immutable_samplers: false,
                },
                DescriptorSetLayoutBinding {
                    binding: 2,
                    ty: Sampler,
                    count: 1,
                    stage_flags: FRAGMENT,
                    immutable_samplers: false,
                },
            ],
        },
    ],
    push_constants: [],
}

even though I haven't removed the uniform buffer that on its own is detected as

Layout {
    sets: [
        SetLayout {
            bindings: [
                DescriptorSetLayoutBinding {
                    binding: 0,
                    ty: UniformBuffer,
                    count: 1,
                    stage_flags: VERTEX,
                    immutable_samplers: false,
                },
            ],
        },
    ],
    push_constants: [],
}

It doesn't work properly when I set the descriptor layout manually either.
The relevant code can be found here along with the vertex and fragment shaders. The bits that make it break in various ways are commented out.

Sounds like a bug in reflection. But you're saying it doesn't work when you specify layout manually which is odd.
Try stick with manual layout for now and validate descriptor set is properly populated with RenderDoc.

The descriptor set seems fine when I specify the layout manually.
image

But you still read zeros in vertex shader instead of expected data?

I'm not sure what you mean by that, but the uniform buffer gets uploaded correctly to the vertex shader.

While poking around in RenderDoc, I also noticed that the texture doesn't get uploaded correctly. It lacks any color data and is completely transparent. This is likely what makes the triangle I'm trying to render invisible.

Annotation 2019-10-31 215445

What causes this isn't obvious to me and it doesn't help that RenderDoc doesn't emit any warnings now even though (I think) I haven't changed the code at all (there used to be "11 Errors and Warnings").

Can you share code that reproduces this bug?
It would be much more effective that way.

I've managed to resolve the issue that was causing the texture to not upload. I forgot to call factory.maintain(..) before running the graph. The issue with shader reflection still remains.