Skip to content

Conversation

iagoCL
Copy link
Contributor

@iagoCL iagoCL commented Oct 7, 2025

Description

Add a new sample to demonstrate the use of the extension Fragment Density Map(FDM). This new sample renders a glTF scene with and without FDM to show the benefits of this extension

Note

We made the following changes to the framework.

  • Added VkComponentMapping component_mapping() as a helper to initialize VkComponentMapping
  • Set render_pass = VK_NULL_HANDLE in api_vulkan_sample.h. Is best practice to initialize variables and this avoids trying to delete it when I overwrite the resize function.
  • Make Gui::show_stats public so that I can use it on my API sample.
  • Add support for VkPhysicalDeviceFragmentDensityMapFeaturesEXT in framework/vulkan_type_mapping.h

Testing

  • Run the new framework on Windows, the sample builds for Windows and Android.
  • I tested the new sample on Mali (Pixel 8 Pro) and Adreno (Samsung S21). I have no other GPUs that support the extension to test it

General Checklist:

Please ensure the following points are checked:

  • My code follows the coding style
  • I have reviewed file licenses
  • I have commented any added functions (in line with Doxygen)
  • I have commented any code that could be hard to understand
  • My changes do not add any new compiler warnings
  • My changes do not add any new validation layer errors or warnings
  • I have used existing framework/helper functions where possible
  • My changes do not add any regressions
  • I have tested every sample to ensure everything runs correctly
  • This PR describes the scope and expected impact of the changes I am making

Note: The Samples CI runs a number of checks including:

  • I have updated the header Copyright to reflect the current year (CI build will fail if Copyright is out of date)
  • My changes build on Windows, Linux, macOS and Android. Otherwise I have documented any exceptions

If this PR contains framework changes:

  • I did a full batch run using the batch command line argument to make sure all samples still work properly

Sample Checklist

If your PR contains a new or modified sample, these further checks must be carried out in addition to the General Checklist:

  • I have tested the sample on at least one compliant Vulkan implementation
  • If the sample is vendor-specific, I have tagged it appropriately
  • I have stated on what implementation the sample has been tested so that others can test on different implementations and platforms
  • Any dependent assets have been merged and published in downstream modules
  • For new samples, I have added a paragraph with a summary to the appropriate chapter in the readme of the folder that the sample belongs to e.g. api samples readme
  • For new samples, I have added a tutorial README.md file to guide users through what they need to know to implement code using this feature. For example, see conditional_rendering
  • For new samples, I have added a link to the Antora navigation so that the sample will be listed at the Vulkan documentation site

@iagoCL iagoCL changed the title Arm/iagocl/fdm New Fragment Density Map Sample Oct 7, 2025
@SaschaWillems
Copy link
Collaborator

SaschaWillems commented Oct 12, 2025

Build fails for me at GLSL compilation level. Sadly not getting any meaningful error to look for. Any ideas?

@iagoCL
Copy link
Contributor Author

iagoCL commented Oct 12, 2025

Build fails for me at GLSL compilation level. Sadly not getting any meaningful error to look for. Any ideas?

I just checked and I can recreate the spv on my machine.
I deleted the compiled shaders in fragment_density_map
rm -r shaders/fragment_density_map/*.spv
Recreate CMake (Delete Cache and Reconfigure) and recompile the project, which recreated my spv
When I generate the project CMake tells me I am using /VulkanSDK/1.4.313/Bin/glslc.exe
I also try deleting the shaders and compile for Android which seems to recreate the spv

Can you share more details? Sorry, no idea how to reproduce it.

@SaschaWillems
Copy link
Collaborator

I'm using the most recent SDK (1.4.328.1). I do not get any meaningful error other than the GLSL shader project for the new sample fails :/

Copy link
Contributor

@asuessenbach asuessenbach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, I have no HW supporting FDM. Thus I could not really test.


Below is a simple pipeline arrangement used on this sample.

1. The density map is computed once outside the render loop and reused each frame. This is done in a separate command-buffer, all the othe commands will go to the same command buffer. The sample also includes a UI option to update the fragment density map attachment every frame using `fragmentDensityMapDynamic`. If this option is selected, an additional pass at the beginning of the main command-buffer produces the fragment density map attachment.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: othe -> other

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

struct
{
ImageData image{};
VkExtent2D extend{32 * 32 * 4, 23 * 32 * 4};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo? 23 -> 32

Copy link
Contributor Author

@iagoCL iagoCL Oct 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It’s actually not used, so I reset it to 0. The actual value is calculated from the swap chain resolution.

Previously, it was intentionally set to 23. Interestingly, 23 × 32 × 4 = 2944, matches the resolution I observed on my test device.

if (!available_options.supports_fdm)
{
current_options.enable_fdm = false;
LOGW("Fragment density map is not supported");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be a LOGE?
The sample does not run without FDM support anyways.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, change to LOGE

@iagoCL
Copy link
Contributor Author

iagoCL commented Oct 13, 2025

I'm using the most recent SDK (1.4.328.1). I do not get any meaningful error other than the GLSL shader project for the new sample fails :/

Hi,
I updated my Vulkan SDK to version 1.4.328.1, and I can compile without any issues. @JoseEmilio-ARM can also compile the sample successfully.

I’m not very familiar with how the project compiles GLSL to SPV, but everything looks identical to other samples. I assume the Windows CI is also compiling the GLSL shaders, so any GLSL compilation problems should be caught there? Or are we avoiding compiling shaders on the CI?

I am unsure about next steps. Are you sure this isn’t an issue with your local setup?

@SaschaWillems
Copy link
Collaborator

Afaik the CI for non-desktop platforms doesn't compile shaders. If I'm the only one with that issue there is no need to further investigate.

Aside from that I can't really test the sample as I don't have a device that supports said extensions. It does compile fine and properly exits out with an error.

@asuessenbach
Copy link
Contributor

By code inspection, this looks good.
But I also don't have HW available to actually test it.

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

Successfully merging this pull request may close these issues.

3 participants