Skip to content

Commit

Permalink
Kernel: Disable GPU fencing for VirtIOGPU operations
Browse files Browse the repository at this point in the history
These fences should not be needed, since we force the use of
synchronous operations through synchronous_virtio_gpu_command. The use
of these fences also causes severe lag when SERENITY_GL is enabled.
  • Loading branch information
ccapitalK authored and alimpfard committed Mar 9, 2022
1 parent fd6a536 commit a2887dc
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions Kernel/Graphics/VirtIOGPU/GraphicsAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ void GraphicsAdapter::query_display_information()
VERIFY(m_operation_lock.is_locked());
auto writer = create_scratchspace_writer();
auto& request = writer.append_structure<Protocol::ControlHeader>();
populate_virtio_gpu_request_header(request, Protocol::CommandType::VIRTIO_GPU_CMD_GET_DISPLAY_INFO, VIRTIO_GPU_FLAG_FENCE);
populate_virtio_gpu_request_header(request, Protocol::CommandType::VIRTIO_GPU_CMD_GET_DISPLAY_INFO, 0);
auto& response = writer.append_structure<Protocol::DisplayInfoResponse>();

synchronous_virtio_gpu_command(start_of_scratch_space(), sizeof(request), sizeof(response));
Expand Down Expand Up @@ -231,7 +231,7 @@ auto GraphicsAdapter::query_edid(u32 scanout_id) -> ErrorOr<Optional<EDID::Parse
auto& request = writer.append_structure<Protocol::GetEDID>();
auto& response = writer.append_structure<Protocol::GetEDIDResponse>();

populate_virtio_gpu_request_header(request.header, Protocol::CommandType::VIRTIO_GPU_CMD_GET_EDID, VIRTIO_GPU_FLAG_FENCE);
populate_virtio_gpu_request_header(request.header, Protocol::CommandType::VIRTIO_GPU_CMD_GET_EDID, 0);

request.scanout_id = scanout_id;
request.padding = 0;
Expand All @@ -256,7 +256,7 @@ ResourceID GraphicsAdapter::create_2d_resource(Protocol::Rect rect)
auto& request = writer.append_structure<Protocol::ResourceCreate2D>();
auto& response = writer.append_structure<Protocol::ControlHeader>();

populate_virtio_gpu_request_header(request.header, Protocol::CommandType::VIRTIO_GPU_CMD_RESOURCE_CREATE_2D, VIRTIO_GPU_FLAG_FENCE);
populate_virtio_gpu_request_header(request.header, Protocol::CommandType::VIRTIO_GPU_CMD_RESOURCE_CREATE_2D, 0);

auto resource_id = allocate_resource_id();
request.resource_id = resource_id.value();
Expand All @@ -278,7 +278,7 @@ ResourceID GraphicsAdapter::create_3d_resource(Protocol::Resource3DSpecification
auto& request = writer.append_structure<Protocol::ResourceCreate3D>();
auto& response = writer.append_structure<Protocol::ControlHeader>();

populate_virtio_gpu_request_header(request.header, Protocol::CommandType::VIRTIO_GPU_CMD_RESOURCE_CREATE_3D, VIRTIO_GPU_FLAG_FENCE);
populate_virtio_gpu_request_header(request.header, Protocol::CommandType::VIRTIO_GPU_CMD_RESOURCE_CREATE_3D, 0);

auto resource_id = allocate_resource_id();
request.resource_id = resource_id.value();
Expand Down Expand Up @@ -306,7 +306,7 @@ void GraphicsAdapter::ensure_backing_storage(ResourceID resource_id, Memory::Reg
auto& request = writer.append_structure<Protocol::ResourceAttachBacking>();
const size_t header_block_size = sizeof(request) + num_mem_regions * sizeof(Protocol::MemoryEntry);

populate_virtio_gpu_request_header(request.header, Protocol::CommandType::VIRTIO_GPU_CMD_RESOURCE_ATTACH_BACKING, VIRTIO_GPU_FLAG_FENCE);
populate_virtio_gpu_request_header(request.header, Protocol::CommandType::VIRTIO_GPU_CMD_RESOURCE_ATTACH_BACKING, 0);
request.resource_id = resource_id.value();
request.num_entries = num_mem_regions;
for (size_t i = 0; i < num_mem_regions; ++i) {
Expand All @@ -330,7 +330,7 @@ void GraphicsAdapter::detach_backing_storage(ResourceID resource_id)
auto& request = writer.append_structure<Protocol::ResourceDetachBacking>();
auto& response = writer.append_structure<Protocol::ControlHeader>();

populate_virtio_gpu_request_header(request.header, Protocol::CommandType::VIRTIO_GPU_CMD_RESOURCE_DETACH_BACKING, VIRTIO_GPU_FLAG_FENCE);
populate_virtio_gpu_request_header(request.header, Protocol::CommandType::VIRTIO_GPU_CMD_RESOURCE_DETACH_BACKING, 0);
request.resource_id = resource_id.value();

synchronous_virtio_gpu_command(start_of_scratch_space(), sizeof(request), sizeof(response));
Expand All @@ -348,7 +348,7 @@ void GraphicsAdapter::set_scanout_resource(ScanoutID scanout, ResourceID resourc
auto& request = writer.append_structure<Protocol::SetScanOut>();
auto& response = writer.append_structure<Protocol::ControlHeader>();

populate_virtio_gpu_request_header(request.header, Protocol::CommandType::VIRTIO_GPU_CMD_SET_SCANOUT, VIRTIO_GPU_FLAG_FENCE);
populate_virtio_gpu_request_header(request.header, Protocol::CommandType::VIRTIO_GPU_CMD_SET_SCANOUT, 0);
request.resource_id = resource_id.value();
request.scanout_id = scanout.value();
request.rect = rect;
Expand All @@ -370,7 +370,7 @@ void GraphicsAdapter::transfer_framebuffer_data_to_host(ScanoutID scanout, Resou
auto& request = writer.append_structure<Protocol::TransferToHost2D>();
auto& response = writer.append_structure<Protocol::ControlHeader>();

populate_virtio_gpu_request_header(request.header, Protocol::CommandType::VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D, VIRTIO_GPU_FLAG_FENCE);
populate_virtio_gpu_request_header(request.header, Protocol::CommandType::VIRTIO_GPU_CMD_TRANSFER_TO_HOST_2D, 0);
request.offset = (dirty_rect.x + (dirty_rect.y * m_scanouts[scanout.value()].display_info.rect.width)) * sizeof(u32);
request.resource_id = resource_id.value();
request.rect = dirty_rect;
Expand All @@ -387,7 +387,7 @@ void GraphicsAdapter::flush_displayed_image(ResourceID resource_id, Protocol::Re
auto& request = writer.append_structure<Protocol::ResourceFlush>();
auto& response = writer.append_structure<Protocol::ControlHeader>();

populate_virtio_gpu_request_header(request.header, Protocol::CommandType::VIRTIO_GPU_CMD_RESOURCE_FLUSH, VIRTIO_GPU_FLAG_FENCE);
populate_virtio_gpu_request_header(request.header, Protocol::CommandType::VIRTIO_GPU_CMD_RESOURCE_FLUSH, 0);
request.resource_id = resource_id.value();
request.rect = dirty_rect;

Expand Down Expand Up @@ -450,7 +450,7 @@ void GraphicsAdapter::delete_resource(ResourceID resource_id)
auto& request = writer.append_structure<Protocol::ResourceUnref>();
auto& response = writer.append_structure<Protocol::ControlHeader>();

populate_virtio_gpu_request_header(request.header, Protocol::CommandType::VIRTIO_GPU_CMD_RESOURCE_UNREF, VIRTIO_GPU_FLAG_FENCE);
populate_virtio_gpu_request_header(request.header, Protocol::CommandType::VIRTIO_GPU_CMD_RESOURCE_UNREF, 0);
request.resource_id = resource_id.value();

synchronous_virtio_gpu_command(start_of_scratch_space(), sizeof(request), sizeof(response));
Expand All @@ -475,7 +475,7 @@ ContextID GraphicsAdapter::create_context()
auto& response = writer.append_structure<Protocol::ControlHeader>();

constexpr char const* region_name = "Serenity VirGL3D Context";
populate_virtio_gpu_request_header(request.header, Protocol::CommandType::VIRTIO_GPU_CMD_CTX_CREATE, VIRTIO_GPU_FLAG_FENCE);
populate_virtio_gpu_request_header(request.header, Protocol::CommandType::VIRTIO_GPU_CMD_CTX_CREATE, 0);
request.header.context_id = ctx_id.value();
request.name_length = strlen(region_name);
memset(request.debug_name.data(), 0, 64);
Expand All @@ -494,7 +494,7 @@ void GraphicsAdapter::submit_command_buffer(ContextID context_id, Function<size_
auto writer = create_scratchspace_writer();
auto& request = writer.append_structure<Protocol::CommandSubmit>();

populate_virtio_gpu_request_header(request.header, Protocol::CommandType::VIRTIO_GPU_CMD_SUBMIT_3D, VIRTIO_GPU_FLAG_FENCE);
populate_virtio_gpu_request_header(request.header, Protocol::CommandType::VIRTIO_GPU_CMD_SUBMIT_3D, 0);
request.header.context_id = context_id.value();

auto max_command_buffer_length = m_scratch_space->size() - sizeof(request) - sizeof(Protocol::ControlHeader);
Expand Down Expand Up @@ -524,7 +524,7 @@ void GraphicsAdapter::attach_resource_to_context(ResourceID resource_id, Context
auto writer = create_scratchspace_writer();
auto& request = writer.append_structure<Protocol::ContextAttachResource>();
auto& response = writer.append_structure<Protocol::ControlHeader>();
populate_virtio_gpu_request_header(request.header, Protocol::CommandType::VIRTIO_GPU_CMD_CTX_ATTACH_RESOURCE, VIRTIO_GPU_FLAG_FENCE);
populate_virtio_gpu_request_header(request.header, Protocol::CommandType::VIRTIO_GPU_CMD_CTX_ATTACH_RESOURCE, 0);
request.header.context_id = context_id.value();
request.resource_id = resource_id.value();

Expand Down

0 comments on commit a2887dc

Please sign in to comment.