tests/shader_runner_metal: Implement clears.

This commit is contained in:
Feifan He 2024-11-27 22:28:06 +08:00 committed by Henri Verbeet
parent 004a6d3055
commit b7203b0bbe
Notes: Henri Verbeet 2024-11-30 14:35:45 +01:00
Approved-by: Henri Verbeet (@hverbeet)
Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/1286

View File

@ -318,7 +318,42 @@ static bool metal_runner_dispatch(struct shader_runner *r, unsigned int x, unsig
static void metal_runner_clear(struct shader_runner *r, struct resource *res, const struct vec4 *clear_value)
{
return;
struct metal_resource *resource = metal_resource(res);
struct metal_runner *runner = metal_runner(r);
id<MTLRenderCommandEncoder> encoder;
id<MTLCommandBuffer> command_buffer;
MTLRenderPassDescriptor *descriptor;
@autoreleasepool
{
descriptor = [MTLRenderPassDescriptor renderPassDescriptor];
command_buffer = [runner->queue commandBuffer];
switch (resource->r.desc.type)
{
case RESOURCE_TYPE_RENDER_TARGET:
descriptor.colorAttachments[0].texture = resource->texture;
descriptor.colorAttachments[0].loadAction = MTLLoadActionClear;
descriptor.colorAttachments[0].storeAction = MTLStoreActionStore;
descriptor.colorAttachments[0].clearColor =
MTLClearColorMake(clear_value->x, clear_value->y, clear_value->z, clear_value->w);
break;
case RESOURCE_TYPE_DEPTH_STENCIL:
descriptor.depthAttachment.texture = resource->texture;
descriptor.depthAttachment.loadAction = MTLLoadActionClear;
descriptor.depthAttachment.storeAction = MTLStoreActionStore;
descriptor.depthAttachment.clearDepth = clear_value->x;
break;
default:
fatal_error("Clears are not implemented for resource type %#x.\n", resource->r.desc.type);
}
encoder = [command_buffer renderCommandEncoderWithDescriptor:descriptor];
[encoder endEncoding];
[command_buffer commit];
[command_buffer waitUntilCompleted];
}
}
static bool metal_runner_draw(struct shader_runner *r, D3D_PRIMITIVE_TOPOLOGY topology,