Closed vmx17 closed 11 months ago
I may get thread safe device context with
private IComObject<DirectN.ID3D11DeviceContext> m_deviceContext4TextMapping = m_device.GetImmediateContext();
"The parameter is incorrect" isn't a priori related to threading. If you enabled the DirectX debug layer in D3D and DXGI (seems you have), you should see more information output by DirectX in the debug output.
Thank you. Yes, it is not related threading. DirectX debug layer? I'll search it.
but in previous post, I was wrong.
private IComObject<DirectN.ID3D11DeviceContext> m_deviceContext4TextMapping = m_device.GetImmediateContext();
The call from other thread falls on issue #26 because it use m_device
. hmm...
I had already set graphic debug layer up and was using (was default).
OK, I've set DirectN(Core) as project referemce in Debug mode and look into error source. Then I find out ("ID3D11DeviceExtensions.cs" ---> "ID3D11Device.cs" ---> "HRESULT.cs") the error I got was just comming from Win32 API "CreateTexture2D". The HRESULT code is 0x80070057 in this page, "An invalid parameter was passed to the returning function.". This means no further information available. The "invalid parameter" may be in the D3D11_TEXTURE2D_DESC.
At last I get the reason of error. I just forget to specify ArraySize = 1,
in the D3D11_TEXTURE_2D
... orz
And now, I'm in the storm of issue #26. Map/Unmap is also the case. Everything I have to en-flatten to UI thread. Otherwise, I got the error "Unable to cast COM object of type 'System.__ComObject' to interface type 'DirectN.ID3D11DeviceContext'." As far as I use DispatcherQueue
or SynchronizationContext
it works but no ref, out data or structs are not allowed to pass over thread boundary.
Anyway, I'm sorry about this fuss.
Hi! It's me, again. I'm sorry my too much questions. Recently I hit same situation with issue #26. Because I'm using Microsoft.UI.Xaml.Controls.SwapChainPanel, I try to use DirectX resources in single thread. I'm making a string texture to show text on D3D11 space. The texture is made by CPU. Then, the first, I made font textures using Windows.Win32.PInvoke.GetGlyphOutline. It seems working. The second, I try to make Texture2D using the font bitmap with CreateTexture2D() method.
My code is as follows (using DirectNCore on .Net6);
Actually the parameters are in struct, I expand it to values above. On the other hand, there is iterating
Render()
method in main thread. Then I put thereThe issue is at the time
m_texture = m_device.CreateTexture2D(m_textTextureDesc, null);
executed, I got an error saying;"System.ComponentModel.Win32Exception: 'The parameter is incorrect.'" Do you have any idea about this?
The error seems just a simple parameter mismatch. The
MiscFlags
is meanless because I specifiedCPUAccessFlags
. (Because this error occurred in "Main Thread", the issue #26 seems to be avoided.) Even though I put the definitionm_textTextureDesc
in front ofm_texture = m_device.CreateTexture2D(m_textTextureDesc, null);
, I got same error.The ID3D11Device (
m_device
) is created with following code.ah... I realized the way current m_device should be modified if I use device context out of Main Thread. Are there any API to make second device context?
I defined the texture as
DYNAMIC
andD3D11_CPU_ACCESS_WRITE
, so I'll copy font bitmaps to them_texture
after. That's not smart at all.