Metal: Add support for packed_float3 as storage buffers

Subdivision shaders currently fail to compile using Metal as it doesn't recognize
packed_float3 as an internal data type. This PR includes packed_float3 as an
internal data type.

Without this `blender --debug-gpu-compile-shaders` will fail as it includes a namespace.
```
ERROR (gpu.shader): subdiv_normals_accumulate Compute Shader:
      |
      | source/blender/gpu/metal/mtl_shader_generator.mm:971:9: Error: no type named 'packed_float3' in 'MTLShaderComputeImpl'; did you mean simply 'packed_float3'?
      |
      |         device MTLShaderComputeImpl::packed_float3* normals[[buffer(MTL_storage_buffer_base_index+4)]],
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |         packed_float3
      |
      | /System/Library/PrivateFrameworks/GPUCompiler.framework/Versions/32023/Libraries/lib/clang/32023.196/include/metal/metal_packed_vector:145:58: Note: 'packed_float3' declared here
      |
      | typedef __attribute__((__packed_vector_type__(3))) float packed_float3;
      |                                                          ^
```

Pull Request: https://projects.blender.org/blender/blender/pulls/134925
This commit is contained in:
Jeroen Bakker
2025-02-21 13:46:10 +01:00
parent 8be66a42c9
commit b34bc67f67
2 changed files with 4 additions and 0 deletions

View File

@@ -529,6 +529,7 @@ inline bool is_builtin_type(std::string type)
{"uchar4", MTL_DATATYPE_UCHAR4},
{"vec3_1010102_Unorm", MTL_DATATYPE_UINT1010102_NORM},
{"vec3_1010102_Inorm", MTL_DATATYPE_INT1010102_NORM},
{"packed_float3", MTL_DATATYPE_PACKED_FLOAT3},
};
return (glsl_builtin_types.find(type) != glsl_builtin_types.end());
}

View File

@@ -50,6 +50,7 @@ enum eMTLDataType {
MTL_DATATYPE_FLOAT2,
MTL_DATATYPE_FLOAT3,
MTL_DATATYPE_FLOAT4,
MTL_DATATYPE_PACKED_FLOAT3,
MTL_DATATYPE_LONG,
MTL_DATATYPE_LONG2,
@@ -128,6 +129,7 @@ inline uint mtl_get_data_type_size(eMTLDataType type)
return 8;
case MTL_DATATYPE_HALF3x2:
case MTL_DATATYPE_PACKED_FLOAT3:
return 12;
case MTL_DATATYPE_INT3:
@@ -229,6 +231,7 @@ inline uint mtl_get_data_type_alignment(eMTLDataType type)
case MTL_DATATYPE_UINT3:
case MTL_DATATYPE_UINT4:
case MTL_DATATYPE_FLOAT3:
case MTL_DATATYPE_PACKED_FLOAT3:
case MTL_DATATYPE_FLOAT4:
case MTL_DATATYPE_LONG2:
case MTL_DATATYPE_ULONG2: