Skip to content

Commit a1acd38

Browse files
authored
Merge pull request #95945 from stuartcarnie/sgc/metal_mobile_fix
Metal: Fix artefacts for mobile render method and disable multi-view
2 parents 568589c + bbc7962 commit a1acd38

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

drivers/metal/rendering_device_driver_metal.mm

+12-2
Original file line numberDiff line numberDiff line change
@@ -3091,12 +3091,22 @@ bool isArrayTexture(MTLTextureType p_type) {
30913091
}];
30923092
}
30933093

3094+
// Initialize an array of integers representing the indexes of p_specialization_constants
3095+
uint32_t *indexes = (uint32_t *)alloca(p_specialization_constants.size() * sizeof(uint32_t));
3096+
for (uint32_t i = 0; i < p_specialization_constants.size(); i++) {
3097+
indexes[i] = i;
3098+
}
3099+
// Sort the array of integers based on the values in p_specialization_constants
3100+
std::sort(indexes, &indexes[p_specialization_constants.size()], [&](int a, int b) {
3101+
return p_specialization_constants[a].constant_id < p_specialization_constants[b].constant_id;
3102+
});
3103+
30943104
MTLFunctionConstantValues *constantValues = [MTLFunctionConstantValues new];
30953105
uint32_t i = 0;
30963106
uint32_t j = 0;
30973107
while (i < constants.count && j < p_specialization_constants.size()) {
30983108
MTLFunctionConstant *curr = constants[i];
3099-
PipelineSpecializationConstant const &sc = p_specialization_constants[j];
3109+
PipelineSpecializationConstant const &sc = p_specialization_constants[indexes[j]];
31003110
if (curr.index == sc.constant_id) {
31013111
switch (curr.type) {
31023112
case MTLDataTypeBool:
@@ -3769,7 +3779,7 @@ bool isArrayTexture(MTLTextureType p_type) {
37693779
bool RenderingDeviceDriverMetal::has_feature(Features p_feature) {
37703780
switch (p_feature) {
37713781
case SUPPORTS_MULTIVIEW:
3772-
return true;
3782+
return false;
37733783
case SUPPORTS_FSR_HALF_FLOAT:
37743784
return true;
37753785
case SUPPORTS_ATTACHMENT_VRS:

0 commit comments

Comments
 (0)