Skip to content

Commit

Permalink
Immediately flush command buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminZehowlt committed Oct 21, 2024
1 parent 7bcfaa2 commit 27868d7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Dotnet/Overlay/OffScreenBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using SharpDX.Direct3D11;
using System;
using System.Threading;
using SharpDX.Direct3D;
using SharpDX.Mathematics.Interop;
using Range = CefSharp.Structs.Range;

Expand All @@ -19,6 +20,7 @@ namespace VRCX
public class OffScreenBrowser : ChromiumWebBrowser, IRenderHandler
{
private Device1 _device;
private DeviceMultithread _deviceMultithread;
private Query _query;
private Texture2D _renderTarget;

Expand Down Expand Up @@ -49,7 +51,12 @@ public OffScreenBrowser(string address, int width, int height)
public void UpdateRender(Device device, Texture2D renderTarget)
{
_device = device.QueryInterface<Device1>();
_deviceMultithread?.Dispose();
_deviceMultithread = device.QueryInterfaceOrNull<DeviceMultithread>();
_deviceMultithread?.SetMultithreadProtected(true);

_renderTarget = renderTarget;

_query?.Dispose();
_query = new Query(_device, new QueryDescription
{
Expand Down Expand Up @@ -91,10 +98,11 @@ void IRenderHandler.OnAcceleratedPaint(PaintElementType type, Rect dirtyRect, Ac

if (_device == null)
return;

using Texture2D cefTexture = _device.OpenSharedResource1<Texture2D>(paintInfo.SharedTextureHandle);
_device.ImmediateContext.CopyResource(cefTexture, _renderTarget);
_device.ImmediateContext.End(_query);
_device.ImmediateContext.Flush();

RawBool q = _device.ImmediateContext.GetData<RawBool>(_query, AsynchronousFlags.DoNotFlush);

Expand Down

0 comments on commit 27868d7

Please sign in to comment.