Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Mar 30, 2019. It is now read-only.
/SharpDXPublic archive

Commit9d7b926

Browse files
committed
[Direct3D12] Simplify marshaling for PR#773 (issue#667)
1 parent54d0f17 commit9d7b926

File tree

3 files changed

+13
-43
lines changed

3 files changed

+13
-43
lines changed

‎Source/SharpDX.Direct3D12/Mapping.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@
314314

315315
<removefunction=".*_Stub"/>
316316
<removefunction=".*_Proxy"/>
317-
<removemethod="ID3D12RootSignatureDeserializer::GetRootSignatureDesc"/>
317+
<mapmethod="ID3D12RootSignatureDeserializer::GetRootSignatureDesc"type="void"property="false"visibility="private"/>
318318
<mapfunction="D3D12(.+)"name-tmp="$1" />
319319
<mapfunction="D3D12.*"dll='"d3d12.dll"'group="SharpDX.Direct3D12.D3D12" />
320320
<mapparam="D3D12CreateDevice::ppDevice"type="ID3D12Device"attribute="out fast" />

‎Source/SharpDX.Direct3D12/RootSignatureDescription.cs‎

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ private unsafe Result Serialize(out Blob result, out string errorText)
166166

167167
privateunsafevoidDeserialize(IntPtrpNativePtr)
168168
{
169+
if(pNativePtr==IntPtr.Zero)
170+
{
171+
return;
172+
}
173+
169174
__Native*pNative=(__Native*)pNativePtr;
170175

171176
if(pNative->ParameterCount>0)
@@ -184,47 +189,23 @@ private unsafe void Deserialize(IntPtr pNativePtr)
184189
if(rangeCount>0)
185190
{
186191
ranges=newDescriptorRange[rangeCount];
187-
fixed(DescriptorRange*pCurRange=ranges)
188-
{
189-
DescriptorRange*pSourceDescRange=(DescriptorRange*)rpn[i].Union.DescriptorTable.DescriptorRangesPointer;
190-
DescriptorRange*pSourceDescRangeEnd=pSourceDescRange+rpn[i].Union.DescriptorTable.DescriptorRangeCount;
191-
DescriptorRange*pTargetDescRange=pCurRange;
192-
while(pTargetDescRange<pSourceDescRangeEnd)
193-
{
194-
*pTargetDescRange=*pSourceDescRange;
195-
pTargetDescRange++;
196-
pSourceDescRange++;
197-
}
198-
199-
}
192+
Utilities.Read(rpn[i].Union.DescriptorTable.DescriptorRangesPointer,ranges,0,ranges.Length);
200193
}
201194

202195
Parameters[i]=newRootParameter(rpn[i].ShaderVisibility,ranges);
203196
}
204197
else
205198
{
206199
// No need to marshal them when RootParameter don't contain DescriptorTable - simple copy as-is
207-
Parameters[i]=newRootParameter();
208-
Parameters[i].native=*rpn;
200+
Parameters[i]=newRootParameter{native=*rpn};
209201
}
210202
}
211203
}
212204

213205
if(pNative->StaticSamplerCount>0)
214206
{
215207
StaticSamplers=newStaticSamplerDescription[pNative->StaticSamplerCount];
216-
fixed(StaticSamplerDescription*pSamplerDesc=StaticSamplers)
217-
{
218-
StaticSamplerDescription*pTargetSamplerDesc=pSamplerDesc;
219-
StaticSamplerDescription*pSourceSamplerDesc=(StaticSamplerDescription*)pNative->StaticSamplerPointer;
220-
StaticSamplerDescription*pSourceSamplerDescEnd=pSourceSamplerDesc+pNative->StaticSamplerCount;
221-
while(pSamplerDesc<pSourceSamplerDescEnd)
222-
{
223-
*pTargetSamplerDesc=*pSourceSamplerDesc;
224-
pTargetSamplerDesc++;
225-
pSourceSamplerDesc++;
226-
}
227-
}
208+
Utilities.Read(pNative->StaticSamplerPointer,StaticSamplers,0,StaticSamplers.Length);
228209
}
229210
}
230211

‎Source/SharpDX.Direct3D12/RootSignatureDeserializer.cs‎

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,7 @@ public partial class RootSignatureDeserializer
1717
/// <unmanaged>GetRootSignatureDesc</unmanaged>
1818
/// <unmanaged-short>GetRootSignatureDesc</unmanaged-short>
1919
/// <unmanaged>const D3D12_ROOT_SIGNATURE_DESC* ID3D12RootSignatureDeserializer::GetRootSignatureDesc()</unmanaged>
20-
publicSharpDX.Direct3D12.RootSignatureDescriptionRootSignatureDescription
21-
{
22-
get{returnGetRootSignatureDescription();}
23-
}
24-
25-
[UnmanagedFunctionPointer(CallingConvention.StdCall)]
26-
internaldelegateIntPtrGetRootSignatureDescDelegate(IntPtrpThis);
20+
publicSharpDX.Direct3D12.RootSignatureDescriptionRootSignatureDescription=>GetRootSignatureDescription2();
2721

2822
/// <summary>
2923
/// <p> Gets the layout of the root signature. </p>
@@ -33,15 +27,10 @@ public SharpDX.Direct3D12.RootSignatureDescription RootSignatureDescription
3327
/// <msdn-id>dn986887</msdn-id>
3428
/// <unmanaged>const D3D12_ROOT_SIGNATURE_DESC* ID3D12RootSignatureDeserializer::GetRootSignatureDesc()</unmanaged>
3529
/// <unmanaged-short>ID3D12RootSignatureDeserializer::GetRootSignatureDesc</unmanaged-short>
36-
internalSharpDX.Direct3D12.RootSignatureDescriptionGetRootSignatureDescription()
30+
internalSharpDX.Direct3D12.RootSignatureDescriptionGetRootSignatureDescription2()
3731
{
38-
unsafe
39-
{
40-
void*target=((void**)(*(void**)_nativePointer))[3];
41-
GetRootSignatureDescDelegate getRootSignatureDescMethod=Marshal.GetDelegateForFunctionPointer<GetRootSignatureDescDelegate>(newIntPtr(target));
42-
IntPtr pDesc=getRootSignatureDescMethod(newIntPtr(_nativePointer));
43-
returnnew RootSignatureDescription(pDesc);
44-
}
32+
varpDesc=this.GetRootSignatureDescription();
33+
returnnewRootSignatureDescription(pDesc);
4534
}
4635
}
4736
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp