From 38d5ef4764e9271ce2360f42b0759a236cddd9fe Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Mon, 2 Apr 2018 19:59:33 -0400 Subject: Feature/dx12 (#469) * Fix signed/unsigned comparison warning. * Split out d3d functions that will work across dx11 and 12. * Improve slang-test/README.md around command line options. * Make Guid comparison honor alignment for comparisons, such that mechanism work on architectures that can only do aligned accesses. * Initial setup of D3D12 Renderer, with presentFrame and clearFrame. * More support for D3D12 * Added FreeList * Added D3D12CircularResourceHeap * First attempt at createBuffer * First pass at map/unmap. * First pass binding vertex/constant buffers, and setting up InputLayout. Note that memory is not kept in scope on binding yet. * First pass of D3DDescriptorHeap * Small tidy up in render-d3d11. Added D3DDescriptorHeap to project. * First pass at D3D12 bind state. * Fix typos in D3D12Resource * Tidy up Dx11 render binding a little to match more with Dx12 style. * First pass at Dx12 BindingState * Handling of the command list d3d12. Support for submitGpuWork and waitForGpu. * First attempt at Dx12 capture of backbuffer to file. * First attempt at D3D12 binding for graphics. * D3D12 setup viewport etc - does now render triangle in render0.hlsl. * First pass at support for compute on D3D12Renderer * Use spaces over tabs in D3DUtil * Tabs to spaces in D3D12DescriptorHeap * Convert tab->spaces on render-d3d12.cpp --- source/core/slang-com-ptr.h | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'source/core/slang-com-ptr.h') diff --git a/source/core/slang-com-ptr.h b/source/core/slang-com-ptr.h index 729b6b266..9f6651306 100644 --- a/source/core/slang-com-ptr.h +++ b/source/core/slang-com-ptr.h @@ -51,21 +51,18 @@ struct Guid SLANG_FORCE_INLINE bool operator==(const Guid& aIn, const Guid& bIn) { + // Use the largest type the honors the alignment of Guid + typedef uint32_t CmpType; struct GuidCompare { - enum { kNum = sizeof(Guid) / sizeof(size_t) }; Guid guid; - size_t data[kNum]; + CmpType data[sizeof(Guid) / sizeof(CmpType)]; }; - const GuidCompare& a = reinterpret_cast(aIn); - const GuidCompare& b = reinterpret_cast(bIn); - - switch (GuidCompare::kNum) - { - case 2: return ((a.data[0] ^ b.data[0]) | (a.data[1] ^ b.data[1])) == 0; - case 4: return ((a.data[0] ^ b.data[0]) | (a.data[1] ^ b.data[1]) | (a.data[2] ^ b.data[2]) | (a.data[3] ^ b.data[3]) ) == 0; - default: return false; - } + // Type pun - so compiler can 'see' the pun and not break aliasing rules + const CmpType* a = reinterpret_cast(aIn).data; + const CmpType* b = reinterpret_cast(bIn).data; + // Make the guid comparison a single branch, by not using short circuit + return ((a[0] ^ b[0]) | (a[1] ^ b[1]) | (a[2] ^ b[2]) | (a[3] ^ b[3])) == 0; } SLANG_FORCE_INLINE bool operator!=(const Guid& a, const Guid& b) -- cgit v1.2.3