Skip to content

Commit

Permalink
Ensure NativeMemory.Copy passes parameters in the correct order
Browse files Browse the repository at this point in the history
  • Loading branch information
tannergooding committed Jan 19, 2024
1 parent f4a375d commit 0ca0baa
Show file tree
Hide file tree
Showing 11 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ public unsafe partial struct D3D12_RT_FORMAT_ARRAY
public D3D12_RT_FORMAT_ARRAY([NativeTypeName("const DXGI_FORMAT *")] DXGI_FORMAT* pFormats, uint NumFormats)
{
NumRenderTargets = NumFormats;
NativeMemory.Copy(Unsafe.AsPointer(ref RTFormats), pFormats, (uint)(sizeof(DXGI_FORMAT)));

fixed (DXGI_FORMAT* pRTFormats = &RTFormats[0])
{
NativeMemory.Copy(pFormats, pRTFormats, sizeof(DXGI_FORMAT));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public readonly D3DX12_MESH_SHADER_PIPELINE_STATE_DESC MeshShaderDescV0()

fixed (DXGI_FORMAT* pFormat = &RTVFormats.pssInner.RTFormats[0])
{
NativeMemory.Copy(&D.RTVFormats[0], pFormat, 8 * sizeof(DXGI_FORMAT));
NativeMemory.Copy(pFormat, &D.RTVFormats[0], 8 * sizeof(DXGI_FORMAT));
}

return D;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public readonly D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0()

fixed (DXGI_FORMAT* pFormat = &RTVFormats.pssInner.RTFormats[0])
{
NativeMemory.Copy(&D.RTVFormats[0], pFormat, 8 * sizeof(DXGI_FORMAT));
NativeMemory.Copy(pFormat, &D.RTVFormats[0], 8 * sizeof(DXGI_FORMAT));
}

return D;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public readonly D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0()

fixed (DXGI_FORMAT* pFormat = &RTVFormats.pssInner.RTFormats[0])
{
NativeMemory.Copy(&D.RTVFormats[0], pFormat, 8 * sizeof(DXGI_FORMAT));
NativeMemory.Copy(pFormat, &D.RTVFormats[0], 8 * sizeof(DXGI_FORMAT));
}

return D;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public readonly D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0()

fixed (DXGI_FORMAT* pFormat = &RTVFormats.pssInner.RTFormats[0])
{
NativeMemory.Copy(&D.RTVFormats[0], pFormat, 8 * sizeof(DXGI_FORMAT));
NativeMemory.Copy(pFormat, &D.RTVFormats[0], 8 * sizeof(DXGI_FORMAT));
}

return D;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public readonly D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0()

fixed (DXGI_FORMAT* pFormat = &RTVFormats.pssInner.RTFormats[0])
{
NativeMemory.Copy(&D.RTVFormats[0], pFormat, 8 * sizeof(DXGI_FORMAT));
NativeMemory.Copy(pFormat, &D.RTVFormats[0], 8 * sizeof(DXGI_FORMAT));
}

return D;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public readonly D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0()

fixed (DXGI_FORMAT* pFormat = &RTVFormats.pssInner.RTFormats[0])
{
NativeMemory.Copy(&D.RTVFormats[0], pFormat, 8 * sizeof(DXGI_FORMAT));
NativeMemory.Copy(pFormat, &D.RTVFormats[0], 8 * sizeof(DXGI_FORMAT));
}

return D;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public readonly D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0()

fixed (DXGI_FORMAT* pFormat = &RTVFormats.pssInner.RTFormats[0])
{
NativeMemory.Copy(&D.RTVFormats[0], pFormat, 8 * sizeof(DXGI_FORMAT));
NativeMemory.Copy(pFormat, &D.RTVFormats[0], 8 * sizeof(DXGI_FORMAT));
}

return D;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static void MemcpySubresource([NativeTypeName("const D3D12_MEMCPY_DEST *"

for (uint y = 0; y < NumRows; ++y)
{
NativeMemory.Copy(pDestSlice + pDest->RowPitch * y, unchecked(pSrcSlice + pSrc->RowPitch * (nint)(y)), RowSizeInBytes);
NativeMemory.Copy(unchecked(pSrcSlice + pSrc->RowPitch * (nint)(y)), pDestSlice + pDest->RowPitch * y, RowSizeInBytes);
}
}
}
Expand All @@ -35,7 +35,7 @@ public static void MemcpySubresource([NativeTypeName("const D3D12_MEMCPY_DEST *"

for (uint y = 0; y < NumRows; ++y)
{
NativeMemory.Copy(pDestSlice + pDest->RowPitch * y, pSrcSlice + pSrc->RowPitch * (nuint)(y), RowSizeInBytes);
NativeMemory.Copy(pSrcSlice + pSrc->RowPitch * (nuint)(y), pDestSlice + pDest->RowPitch * y, RowSizeInBytes);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public static HRESULT D3DX12SerializeVersionedRootSignature([NativeTypeName("con
break;
}

NativeMemory.Copy(pStaticSamplers + n, desc_1_2->pStaticSamplers + n, (uint)(sizeof(D3D12_STATIC_SAMPLER_DESC)));
NativeMemory.Copy(desc_1_2->pStaticSamplers + n, pStaticSamplers + n, (uint)(sizeof(D3D12_STATIC_SAMPLER_DESC)));
}
}
}
Expand Down Expand Up @@ -216,7 +216,7 @@ public static HRESULT D3DX12SerializeVersionedRootSignature([NativeTypeName("con
break;
}

NativeMemory.Copy(pStaticSamplers + n, desc_1_2->pStaticSamplers + n, (uint)(sizeof(D3D12_STATIC_SAMPLER_DESC)));
NativeMemory.Copy(desc_1_2->pStaticSamplers + n, pStaticSamplers + n, (uint)(sizeof(D3D12_STATIC_SAMPLER_DESC)));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion sources/Interop/Windows/Windows/um/winioctl/Windows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static void DeviceDsmInitializeInput([NativeTypeName("PDEVICE_DSM_DEFINIT
goto Cleanup;
}

NativeMemory.Copy((DeviceDsmParameterBlock(Input)), (Parameters), (Input->ParameterBlockLength));
NativeMemory.Copy((Parameters), (DeviceDsmParameterBlock(Input)), (Input->ParameterBlockLength));
Cleanup:
return;
}
Expand Down

0 comments on commit 0ca0baa

Please sign in to comment.