froxel: make froxel buffer size consistent (#8437)
The definition of the froxel buffer sizes were spread across multiple places and for different use cases (including allocating the buffer, setting to a descriptor set, and adjusting the relevant spec constant). In this commit, we try to unify the size definitions into Froxelizer::getFroxelBufferByteCount(). We also remove the vulkan-only special case for froxel buffer UBO. This case was introduced because spec constant couldn't be used to size arrays for some drivers in the past, but we introduced a workaround that replaced spec constants with constants.
This commit is contained in:
@@ -295,35 +295,12 @@ utils::io::sstream& CodeGenerator::generateCommonProlog(utils::io::sstream& out,
|
||||
generateSpecializationConstant(out, "BACKEND_FEATURE_LEVEL",
|
||||
+ReservedSpecializationConstants::BACKEND_FEATURE_LEVEL, 1);
|
||||
|
||||
if (mTargetApi == TargetApi::VULKAN) {
|
||||
// Note: This is a hack for a hack.
|
||||
//
|
||||
// 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);
|
||||
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);
|
||||
}
|
||||
// the default of 1024 (16KiB) is needed for 32% of Android devices
|
||||
generateSpecializationConstant(out, "CONFIG_FROXEL_BUFFER_HEIGHT",
|
||||
+ReservedSpecializationConstants::CONFIG_FROXEL_BUFFER_HEIGHT, 1024);
|
||||
|
||||
// directional shadowmap visualization
|
||||
generateSpecializationConstant(out, "CONFIG_DEBUG_DIRECTIONAL_SHADOWMAP",
|
||||
|
||||
Reference in New Issue
Block a user