froxelizer doesn't use textures anymore (#6824)

* froxelizer doesn't use textures anymore

All data is stored in UBOs.
Additionally, the buffer size is no longer hardcoded at compile time.

This CL cuts in half the numbers of froxels to accommodate devices
limited to 16KiB,

* Use a specialization constant to adjust the size of froxel UBO

This really only affects OpenGL in practice because metal supports 256MB
minimum and only 3% of android devices support less than 32K, which is
what we need.
This commit is contained in:
Mathias Agopian
2023-05-22 13:56:13 -07:00
committed by GitHub
parent 1a83083651
commit edfd06eaef
21 changed files with 155 additions and 96 deletions
+21 -4
View File
@@ -194,15 +194,32 @@ utils::io::sstream& CodeGenerator::generateProlog(utils::io::sstream& out, Shade
if (mTargetApi == TargetApi::VULKAN) {
// Note: This is a hack for a hack.
// Vulkan doesn't fully support sizing arrays within a block with specialization constants,
// and since we only need to do this for a hack for WebGL, it's fine to replace it with
// regular constant here.
// We *could* leave it as a specialization constant, but this triggers a crashing bug with
//
// Vulkan doesn't support sizing arrays within a block with specialization constants,
// as per this paragraph of the ARB_spir_v specification:
// https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_gl_spirv.txt
//
// Arrays inside a block may be sized with a specialization constant,
// but the block will have a static layout. Changing the specialized size will
// not re-layout the block. In the absence of explicit offsets, the layout will be
// based on the default size of the array.
//
// CONFIG_MAX_INSTANCES is only needed for WebGL, so we can replace it with a constant.
// CONFIG_FROXEL_BUFFER_HEIGHT can be hardcoded to 2048 because only 3% of Android devices
// only support 16KiB buffer or less (1024 lines).
//
// We *could* leave these as a specialization constant, but this triggers a crashing bug with
// some Adreno drivers on Android. see: https://github.com/google/filament/issues/6444
//
out << "const int CONFIG_MAX_INSTANCES = " << (int)CONFIG_MAX_INSTANCES << ";\n";
out << "const int CONFIG_FROXEL_BUFFER_HEIGHT = 2048;\n";
} else {
generateSpecializationConstant(out, "CONFIG_MAX_INSTANCES",
+ReservedSpecializationConstants::CONFIG_MAX_INSTANCES, (int)CONFIG_MAX_INSTANCES);
// the default of 1024 (16KiB) is needed for 32% of Android devices
generateSpecializationConstant(out, "CONFIG_FROXEL_BUFFER_HEIGHT",
+ReservedSpecializationConstants::CONFIG_FROXEL_BUFFER_HEIGHT, 1024);
}
// Workaround a Metal pipeline compilation error with the message: