Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
maroider opened this issue Oct 13, 2019 · 7 comments

Comments

@maroider
Copy link

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.

@zakarumych
Copy link
Member

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.

@maroider
Copy link
Author

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

@zakarumych
Copy link
Member

zakarumych commented Oct 20, 2019

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

@maroider
Copy link
Author

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").

@zakarumych
Copy link
Member

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

maroider added a commit to maroider/glium_tutorial_but_its_rendy that referenced this issue Dec 27, 2019
If anything, the troubles I had getting this working should serve as a
reminder that I should always read examples and documentation properly
instead of skimming through it.

There were two problems that managed to cripple my progress on porting
this tutorial.

1: Shader reflection doesn't seem to remember that there's a uniform in
the vertex shader once I add uniforms to the fragment shader
(amethyst/rendy#220). This is remedied by specifying the uniform
bindings manually.

2: The image I was trying to render onto the triangle wouldn't upload
properly, leaving me with an entirely transparent black texture. The
root cause of this issue was that I forgot to call `factory.maintain()`
before running the graph (or at all, really).
@maroider
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants