I am trying to get ANGLE to work in C # using P / Invoke. Basically, I create a simple two-dimensional surface and then pass it to skia (using SkiaSharp). Everything works and all that, but I have a problem with sorting PropertySetunmanaged code.
This bit works fine:
var props = new PropertySet();
props.Add("EGLNativeWindowTypeProperty", swapChainPanel);
int[] surfaceAttrs = {
EGL_ANGLE_SURFACE_RENDER_TO_BACK_BUFFER, EGL_TRUE,
EGL_NONE
};
surface = eglCreateWindowSurface(eglDisplay, eglConfig, props, surfaceAttrs);
My import is as follows:
[DllImport("libEGL.dll")]
public static extern IntPtr eglCreateWindowSurface(
IntPtr dpy,
IntPtr config,
[MarshalAs(UnmanagedType.IInspectable)] object win,
int[] attrib_list);
The problem occurs when I try to adjust the scaling for high resolution screens. This "should" work:
var scale = PropertyValue.CreateSingle(2);
props.Add("EGLRenderResolutionScaleProperty", scale);
It works when using C ++, but not in C #. I think I realized that the actual value is not sorted correctly. This is because when debugging ANGLE code, it dies here:
ComPtr<ABI::Windows::Foundation::IPropertyValue> propertyValue;
ABI::Windows::Foundation::PropertyType propertyType;
result = propertyValue->get_Type(&propertyType);
https://github.com/Microsoft/angle/blob/54b1fd01f7fddcd7011d5a04e9259edace8a13da/src/libANGLE/renderer/d3d/d3d11/winrt/InspectableNativeWindow.cpp#L242
:
# 0 - ESP . , , , .
?
: https://gist.github.com/mattleibow/eacb9c9e87f306b218d99c713c532a82
ANGLE: https://github.com/Microsoft/angle/issues/89
, - PropertyValue # ++ ( Runtime Windows).
:
static PropertySet^ CreateSurface(SwapChainPanel^ panel, float scale)
{
PropertySet^ surfaceCreationProperties = ref new PropertySet();
surfaceCreationProperties->Insert(L"EGLNativeWindowTypeProperty", panel);
Object^ scaleVal = PropertyValue::CreateSingle(scale);
surfaceCreationProperties->Insert(L"EGLRenderResolutionScaleProperty", scaleVal);
return surfaceCreationProperties;
}
PropertySet ++ #. , ANGLE .
, , PropertyValue::CreateSingle(scale) , . PropertyValue.CreateSingle(scale) # ++, , .
, #:
0x09f10ba4 <Information not available, no symbols loaded for coreclr.dll>
Platform::Object ^
++, :
0x019162e8 2.00000000
Platform::Object ^ {WinTypes.dll!Windows::Foundation::Value<Windows::Foundation::ValueScalar<float> >}
, ? , , .
2 .