KhronosGroup / Vulkan-Samples

One stop solution for all Vulkan samples
Apache License 2.0
4.3k stars 639 forks source link

Is there an implicit difference between VK_PRIMITIVE_TOPOLOGY_POINT_LIST and VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST? #539

Closed Valhally closed 1 year ago

Valhally commented 2 years ago
void GeometrySubpass::prepare_pipeline_state(CommandBuffer &command_buffer, VkFrontFace front_face, bool double_sided_material)
{
    RasterizationState rasterization_state = base_rasterization_state;
    rasterization_state.front_face         = front_face;

    if (double_sided_material)
    {
        rasterization_state.cull_mode = VK_CULL_MODE_NONE;
    }

    command_buffer.set_rasterization_state(rasterization_state);

    MultisampleState multisample_state{};
    multisample_state.rasterization_samples = sample_count;
    command_buffer.set_multisample_state(multisample_state);

    InputAssemblyState input_assembly_state{};
    input_assembly_state.topology = VK_PRIMITIVE_TOPOLOGY_POINT_LIST;
    command_buffer.set_input_assembly_state(input_assembly_state);
}

The last three lines of code in the method are the ones I added, then I compile and run the "wait_idle" sample. On my desktop(R7 3700X and RTX 2070) it renders some points properly 屏幕截图 2022-10-21 210147 But on my laptop(R7 6800H, no discrete graphics card), nothing is displayed R86F K6XLC@5EZMYP$ V6E I can't figure out if it's the difference between the hardware or the difference between POINT_LIST and TRIANGLE_LIST that's causing this problem, or maybe it's something else.

Both computers have the latest Win11 system, VulkanSDK and graphics card drivers installed

Thanks

SaschaWillems commented 2 years ago

Your assumption is correct, but if you draw points you must write the built-in pointSize output in your vertex shader. So unless you also changed the vertex shader used in this example, this is undefined behavior. The fact that one implementation is displaying something and the other isn't is then mostly purely random.

So try explicitly setting gl_PointSize in the vertex shader of that sample and see if it then also displays correct on AMD.

P.S. : It's advised to run samples with validation layers in such cases, cause they'll hint at such problems.

Valhally commented 1 year ago

That's exactly the reason thank you very much