Skip to content

Commit ed36a5a

Browse files
committed
Fix not setting graphics pipeline primitive type for Metal
This information is needed when a vertex shader outputs [[render_target_array_index]] for a 2D texture array. The GPU needs to know the primitive topology at pipeline compile time to determine which vertex's array index value to use when routing fragments to the indexed texture layer.
1 parent b3f4eba commit ed36a5a

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/gpu/metal/SDL_gpu_metal.m

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,24 @@ static void METAL_ReleaseGraphicsPipeline(
12211221
pipelineDescriptor.vertexDescriptor = vertexDescriptor;
12221222
}
12231223

1224+
// Primitive
1225+
1226+
switch (createinfo->primitive_type) {
1227+
case SDL_GPU_PRIMITIVETYPE_TRIANGLELIST:
1228+
case SDL_GPU_PRIMITIVETYPE_TRIANGLESTRIP:
1229+
pipelineDescriptor.inputPrimitiveTopology = MTLPrimitiveTopologyClassTriangle;
1230+
break;
1231+
case SDL_GPU_PRIMITIVETYPE_LINELIST:
1232+
case SDL_GPU_PRIMITIVETYPE_LINESTRIP:
1233+
pipelineDescriptor.inputPrimitiveTopology = MTLPrimitiveTopologyClassLine;
1234+
break;
1235+
case SDL_GPU_PRIMITIVETYPE_POINTLIST:
1236+
pipelineDescriptor.inputPrimitiveTopology = MTLPrimitiveTopologyClassPoint;
1237+
break;
1238+
}
1239+
1240+
// Props
1241+
12241242
if (renderer->debugMode && SDL_HasProperty(createinfo->props, SDL_PROP_GPU_GRAPHICSPIPELINE_CREATE_NAME_STRING)) {
12251243
const char *name = SDL_GetStringProperty(createinfo->props, SDL_PROP_GPU_GRAPHICSPIPELINE_CREATE_NAME_STRING, NULL);
12261244
pipelineDescriptor.label = @(name);

0 commit comments

Comments
 (0)