Comments (4)
I suspect this change is a fallout of improving support in other areas where we discovered certain interop rules had to be honored, and this was an area where we weren't fully following the rules, causing failures in at least some cases.
I'll leave this active till we have a chance to confirm.
from cswin32.
having the same issue with D3D11 after updating from 0.3.49-beta to 0.3.106
from cswin32.
Same for me. It's actually a showstopper for upgrading nuget packages.
from cswin32.
It wasn't that hard to work around this issue. Just had to spend the month learning x64 ASM and how to reverse engineer Windows binaries. Then produced the following elegant and idiomatic C# code which is required to both retain managed and unmanaged copies of the same COM objects, and properly handle both of their lifetimes. My new favorite part of coding in C# with projections is all the time one gets to spend reading and writing assembly.
[Guid("94D99BDB-F1F8-4AB0-B236-7DA0170EDAB1"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), ComImport()]
internal interface IDXGISwapChain3Extra : IDXGISwapChain3
{
void _VtblGap_6();
unsafe void GetBufferRaw(uint Buffer, Guid* riid, void** ppSurface);
}
List<ID3D12Resource> gSurfaces = new List<ID3D12Resource>();
List<nint> gSurfacesRaw = new List<nint>();
// ...
guid = typeof(ID3D12Resource).GUID;
void* ppSurface;
gSwapChain.GetBufferRaw(i, &guid, &ppSurface);
gSurfacesRaw.Add((nint)ppSurface);
gSurfaces.Add((ID3D12Resource)Marshal.GetObjectForIUnknown((nint)ppSurface));
gDevice.CreateRenderTargetView(gSurfaces.Last(), null, rtvHandle);
// ...
ID3D12Resource_unmanaged* p = (ID3D12Resource_unmanaged*)gSurfacesRaw[(int)gFrameIndex];
D3D12_RESOURCE_BARRIER[] b = [
new() {
Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE,
Anonymous = new()
{
Transition = new()
{
pResource = p,
Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES,
StateBefore = D3D12_RESOURCE_STATE_PRESENT,
StateAfter = D3D12_RESOURCE_STATE_RENDER_TARGET,
}
}
}
];
gCommandList.ResourceBarrier(1, b);
// ...
void ResizeBuffers(nint lParam)
{
if (gSwapChain != null && gFence != null && gSurfaces.Count > 0)
{
WaitForPreviousFrame();
for (int i = 0; i < 2; i++)
{
Marshal.ReleaseComObject(gSurfaces[i]);
((ID3D12Resource_unmanaged*)gSurfacesRaw[(int)i])->Release();
}
gSurfaces.Clear();
gSurfacesRaw.Clear();
// ...
Guid guid = typeof(ID3D12Resource).GUID;
void* ppSurface;
gSwapChain!.GetBufferRaw(i, &guid, &ppSurface);
gSurfacesRaw.Add((nint)ppSurface);
gSurfaces.Add((ID3D12Resource)Marshal.GetObjectForIUnknown((nint)ppSurface));
gDevice.CreateRenderTargetView(gSurfaces.Last(), null, rtvHandle);
from cswin32.
Related Issues (20)
- APPBARDATA should compile on AnyCPU HOT 2
- CsWin32 should avoid Unsafe.SkipInit when it doesn't exist in the compilation HOT 1
- WlanOpenHandle doesn't support SafeHandle HOT 1
- The API "Gdi32" is ambiguous HOT 4
- Add `GET_WHEEL_DELTA_WPARAM` macro
- `TASKDIALOGCONFIG.pfCallback` should use associated enum for `msg` parameter
- Broken `VariableLengthInlineArray<T>` after upgrade from 0.3.49-beta to 0.3.106 HOT 8
- NetFramework - Unsafe.SkipInit(out T value) unavailable HOT 3
- Inconsistent const in parameters of RmRegisterResources HOT 9
- LocalExternFunctions should use `DefaultDllImportSearchPaths`
- Code Quality: Use `WinMdRoot` instead of `winmdroot` to supress CS8981 (type name is ASCII lowercase only) HOT 5
- `PCWSTR` is not marked with `[GeneratedCode]`
- Many Win32 structs (HDC, HMONITOR, etc.) lack the IntPtr conversion operator.
- "Pointers cannot reference marshaled structures. Use ByRef instead" caused by VariableLengthInlineArray
- Latest WDK metadata fails to create DEVPKEY field
- Daily nuget feed not updating HOT 1
- MFTEnumEx signature incorrect
- `VirtualFreeEx` missing HOT 1
- Missing NtCreateThread and NtCreateThreadEx functions HOT 1
- Add an analyzer to catch inadvertent ephemeral delegates HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cswin32.