Skip to content

Commit

Permalink
Metal: fix static texture target on more devices (#8022)
Browse files Browse the repository at this point in the history
  • Loading branch information
bejado committed Aug 8, 2024
1 parent 1c0370d commit 8ba20eb
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion filament/backend/include/backend/DriverEnums.h
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,7 @@ enum class Workaround : uint16_t {
ADRENO_UNIFORM_ARRAY_CRASH,
// Workaround a Metal pipeline compilation error with the message:
// "Could not statically determine the target of a texture". See light_indirect.fs
A8X_STATIC_TEXTURE_TARGET_ERROR,
METAL_STATIC_TEXTURE_TARGET_ERROR,
// Adreno drivers sometimes aren't able to blit into a layer of a texture array.
DISABLE_BLIT_INTO_TEXTURE_ARRAY,
// Multiple workarounds needed for PowerVR GPUs
Expand Down
2 changes: 1 addition & 1 deletion filament/backend/src/metal/MetalContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct MetalContext {
} highestSupportedGpuFamily;

struct {
bool a8xStaticTextureTargetError;
bool staticTextureTargetError;
} bugs;

// sampleCountLookup[requestedSamples] gives a <= sample count supported by the device.
Expand Down
10 changes: 6 additions & 4 deletions filament/backend/src/metal/MetalDriver.mm
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,10 @@
sc[s] = [mContext->device supportsTextureSampleCount:s] ? s : sc[s - 1];
}

mContext->bugs.a8xStaticTextureTargetError =
[mContext->device.name containsString:@"Apple A8X GPU"];
mContext->bugs.staticTextureTargetError =
[mContext->device.name containsString:@"Apple A8X GPU"] ||
[mContext->device.name containsString:@"Apple A8 GPU"] ||
[mContext->device.name containsString:@"Apple A7 GPU"];

mContext->commandQueue = mPlatform.createCommandQueue(mContext->device);
mContext->pipelineStateCache.setDevice(mContext->device);
Expand Down Expand Up @@ -840,8 +842,8 @@
return true;
case Workaround::ADRENO_UNIFORM_ARRAY_CRASH:
return false;
case Workaround::A8X_STATIC_TEXTURE_TARGET_ERROR:
return mContext->bugs.a8xStaticTextureTargetError;
case Workaround::METAL_STATIC_TEXTURE_TARGET_ERROR:
return mContext->bugs.staticTextureTargetError;
case Workaround::DISABLE_BLIT_INTO_TEXTURE_ARRAY:
return false;
default:
Expand Down
2 changes: 1 addition & 1 deletion filament/src/details/Material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ void FMaterial::processSpecializationConstants(FEngine& engine, Material::Builde
engine.getDriverApi().getMaxUniformBufferSize() / 16u);

bool const staticTextureWorkaround =
engine.getDriverApi().isWorkaroundNeeded(Workaround::A8X_STATIC_TEXTURE_TARGET_ERROR);
engine.getDriverApi().isWorkaroundNeeded(Workaround::METAL_STATIC_TEXTURE_TARGET_ERROR);

bool const powerVrShaderWorkarounds =
engine.getDriverApi().isWorkaroundNeeded(Workaround::POWER_VR_SHADER_WORKAROUNDS);
Expand Down
2 changes: 1 addition & 1 deletion shaders/src/light_indirect.fs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ vec3 Irradiance_RoughnessOne(const vec3 n) {
//------------------------------------------------------------------------------

vec3 diffuseIrradiance(const vec3 n) {
// On Metal devices with an A8X chipset, this light_iblSpecular texture sample must be pulled
// On Metal devices with certain chipsets, this light_iblSpecular texture sample must be pulled
// outside the frameUniforms.iblSH check. This is to avoid a Metal pipeline compilation error
// with the message: "Could not statically determine the target of a texture".
// The reason for this is unknown, and is possibly a bug that exhibits only on these devices.
Expand Down

0 comments on commit 8ba20eb

Please sign in to comment.