Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes to allow msvc /premissive- #28

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/Allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Licensed under the MIT License.
#pragma once

#include "BlockAllocators.h"

namespace D3D12TranslationLayer
{
class HeapSuballocationBlock : public BlockAllocators::CGenericBlock<UINT64>
Expand Down
2 changes: 1 addition & 1 deletion include/BlockAllocators.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class CPooledBlockAllocator
// Required Allocator functions
_BlockType Allocate(_SizeType size);
void Deallocate(const _BlockType &block);
bool IsOwner(const _BlockType &block) const { return block.GetSize() == blockSize; }
bool IsOwner(const _BlockType &block) const { return block.GetSize() == m_blockSize; }
void Reset();
};

Expand Down
5 changes: 3 additions & 2 deletions include/DeviceChild.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ namespace D3D12TranslationLayer
template <typename TIface>
void AddToDeferredDeletionQueue(unique_comptr<TIface>& spObject, COMMAND_LIST_TYPE CommandListType)
{
AddToDeferredDeletionQueue(spObject, CommandListType, m_pParent->GetCommandListID(CommandListType));
AddToDeferredDeletionQueue(spObject, CommandListType, GetCommandListID(CommandListType));
}

void SwapIdentities(DeviceChild& Other)
Expand All @@ -78,6 +78,7 @@ namespace D3D12TranslationLayer
}

void AddToDeferredDeletionQueue(ID3D12Object* pObject);
UINT64 GetCommandListID(COMMAND_LIST_TYPE CommandListType) const;
};

template <typename TIface>
Expand All @@ -100,7 +101,7 @@ namespace D3D12TranslationLayer
}
TIface* GetForUse(COMMAND_LIST_TYPE CommandListType)
{
return GetForUse(CommandListType, m_pParent->GetCommandListID(CommandListType));
return GetForUse(CommandListType, GetCommandListID(CommandListType));
}
TIface* GetForImmediateUse() { return m_spIface.get(); }

Expand Down
16 changes: 13 additions & 3 deletions include/ImmediateContext.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,16 @@
// Licensed under the MIT License.
#pragma once

#include "Allocator.h"
#include "Resource.hpp"
#include "Util.hpp"

namespace D3D12TranslationLayer
{
class Resource;
class CommandListManager;
class Resource;
class ResourceCache;
class ViewBase;

struct TranslationLayerCallbacks
{
Expand Down Expand Up @@ -38,7 +44,7 @@ class CFencePool
TResourceType RetrieveFromPool(UINT64 CurrentFenceValue, PFNCreateNew pfnCreateNew, const CreationArgType&... CreationArgs) noexcept(false)
{
auto lock = m_pLock ? std::unique_lock(*m_pLock) : std::unique_lock<std::mutex>();
TPool::iterator Head = m_Pool.begin();
auto Head = m_Pool.begin();
if (Head == m_Pool.end() || (CurrentFenceValue < Head->first))
{
return std::move(pfnCreateNew(CreationArgs...)); // throw( _com_error )
Expand All @@ -54,7 +60,7 @@ class CFencePool
{
auto lock = m_pLock ? std::unique_lock(*m_pLock) : std::unique_lock<std::mutex>();

TPool::iterator Head = m_Pool.begin();
auto Head = m_Pool.begin();

if (Head == m_Pool.end() || (CurrentFenceValue < Head->first))
{
Expand Down Expand Up @@ -586,7 +592,11 @@ enum EDirtyBits : UINT64
e_ReassertOnNewCommandList = e_GraphicsStateDirty | e_ComputeStateDirty,
};

class Fence;
class HeapSuballocationBlock;
class ImmediateContext;
struct DeferredWait;
struct ResidencyManagedObjectWrapper;

struct RetiredObject
{
Expand Down
70 changes: 35 additions & 35 deletions include/ImmediateContext.inl
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ inline bool CViewBoundState<TBindable, NumBindSlots>::IsDirty(TDeclVector const&

if (!bDirty)
{
bDirty = DirtyBitsUpTo(static_cast<UINT>(New.size()));
bDirty = this->DirtyBitsUpTo(static_cast<UINT>(New.size()));
}

if (bDirty)
Expand Down Expand Up @@ -944,6 +944,40 @@ template<> struct SRVBindIndices<e_HS> { static const UINT c_TableIndex = 10; };
template<> struct SRVBindIndices<e_DS> { static const UINT c_TableIndex = 13; };
template<> struct SRVBindIndices<e_CS> { static const UINT c_TableIndex = 1; };

//----------------------------------------------------------------------------------------------------------------------------------
template<EShaderStage eShader> struct CBBindIndices;
template<> struct CBBindIndices<e_PS> { static const UINT c_TableIndex = 0; };
template<> struct CBBindIndices<e_VS> { static const UINT c_TableIndex = 3; };
template<> struct CBBindIndices<e_GS> { static const UINT c_TableIndex = 6; };
template<> struct CBBindIndices<e_HS> { static const UINT c_TableIndex = 9; };
template<> struct CBBindIndices<e_DS> { static const UINT c_TableIndex = 12; };
template<> struct CBBindIndices<e_CS> { static const UINT c_TableIndex = 0; };

//----------------------------------------------------------------------------------------------------------------------------------
template<EShaderStage eShader> struct SamplerBindIndices;
template<> struct SamplerBindIndices<e_PS> { static const UINT c_TableIndex = 2; };
template<> struct SamplerBindIndices<e_VS> { static const UINT c_TableIndex = 5; };
template<> struct SamplerBindIndices<e_GS> { static const UINT c_TableIndex = 8; };
template<> struct SamplerBindIndices<e_HS> { static const UINT c_TableIndex = 11; };
template<> struct SamplerBindIndices<e_DS> { static const UINT c_TableIndex = 14; };
template<> struct SamplerBindIndices<e_CS> { static const UINT c_TableIndex = 2; };

//----------------------------------------------------------------------------------------------------------------------------------
template<EShaderStage eShader> struct DescriptorBindFuncs
{
static decltype(&ID3D12GraphicsCommandList::SetGraphicsRootDescriptorTable) GetBindFunc()
{
return &ID3D12GraphicsCommandList::SetGraphicsRootDescriptorTable;
}
};
template<> struct DescriptorBindFuncs<e_CS>
{
static decltype(&ID3D12GraphicsCommandList::SetComputeRootDescriptorTable) GetBindFunc()
{
return &ID3D12GraphicsCommandList::SetComputeRootDescriptorTable;
}
};

template<EShaderStage eShader>
inline void ImmediateContext::ApplyShaderResourcesHelper() noexcept
{
Expand All @@ -959,15 +993,6 @@ inline void ImmediateContext::ApplyShaderResourcesHelper() noexcept
CurrentState.m_SRVTableBase);
}

//----------------------------------------------------------------------------------------------------------------------------------
template<EShaderStage eShader> struct CBBindIndices;
template<> struct CBBindIndices<e_PS> { static const UINT c_TableIndex = 0; };
template<> struct CBBindIndices<e_VS> { static const UINT c_TableIndex = 3; };
template<> struct CBBindIndices<e_GS> { static const UINT c_TableIndex = 6; };
template<> struct CBBindIndices<e_HS> { static const UINT c_TableIndex = 9; };
template<> struct CBBindIndices<e_DS> { static const UINT c_TableIndex = 12; };
template<> struct CBBindIndices<e_CS> { static const UINT c_TableIndex = 0; };

template<EShaderStage eShader>
inline void ImmediateContext::ApplyConstantBuffersHelper() noexcept
{
Expand All @@ -983,15 +1008,6 @@ inline void ImmediateContext::ApplyConstantBuffersHelper() noexcept
CurrentState.m_CBTableBase);
}

//----------------------------------------------------------------------------------------------------------------------------------
template<EShaderStage eShader> struct SamplerBindIndices;
template<> struct SamplerBindIndices<e_PS> { static const UINT c_TableIndex = 2; };
template<> struct SamplerBindIndices<e_VS> { static const UINT c_TableIndex = 5; };
template<> struct SamplerBindIndices<e_GS> { static const UINT c_TableIndex = 8; };
template<> struct SamplerBindIndices<e_HS> { static const UINT c_TableIndex = 11; };
template<> struct SamplerBindIndices<e_DS> { static const UINT c_TableIndex = 14; };
template<> struct SamplerBindIndices<e_CS> { static const UINT c_TableIndex = 2; };

template<EShaderStage eShader>
inline void ImmediateContext::ApplySamplersHelper() noexcept
{
Expand All @@ -1007,22 +1023,6 @@ inline void ImmediateContext::ApplySamplersHelper() noexcept
CurrentState.m_SamplerTableBase);
}

//----------------------------------------------------------------------------------------------------------------------------------
template<EShaderStage eShader> struct DescriptorBindFuncs
{
static decltype(&ID3D12GraphicsCommandList::SetGraphicsRootDescriptorTable) GetBindFunc()
{
return &ID3D12GraphicsCommandList::SetGraphicsRootDescriptorTable;
}
};
template<> struct DescriptorBindFuncs<e_CS>
{
static decltype(&ID3D12GraphicsCommandList::SetComputeRootDescriptorTable) GetBindFunc()
{
return &ID3D12GraphicsCommandList::SetComputeRootDescriptorTable;
}
};

//----------------------------------------------------------------------------------------------------------------------------------
inline void TRANSLATION_API ImmediateContext::Dispatch(UINT x, UINT y, UINT z)
{
Expand Down
9 changes: 9 additions & 0 deletions include/Resource.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@
// Licensed under the MIT License.
#pragma once

#include "ResourceState.hpp"

namespace D3D12TranslationLayer
{
enum class ShaderResourceViewType;
enum class RenderTargetViewType;
enum class DepthStencilViewType;
enum class UnorderedAccessViewType;
enum class VideoDecoderOutputViewType;
enum class VideoProcessorInputViewType;
enum class VideoProcessorOutputViewType;

// The same as D3D11
enum RESOURCE_USAGE
Expand Down
5 changes: 4 additions & 1 deletion include/ResourceBinding.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
// Licensed under the MIT License.
#pragma once

#include "Sampler.hpp"
#include "Shader.hpp"

namespace D3D12TranslationLayer
{
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -243,7 +246,7 @@ namespace D3D12TranslationLayer
CViewBoundState() noexcept(false)
: CBoundState()
{
m_ShaderData.reserve(NumBindings); // throw( bad_alloc )
m_ShaderData.reserve(this->NumBindings); // throw( bad_alloc )
}

bool UpdateBinding(_In_range_(0, NumBindings - 1) UINT slot, _In_opt_ TBindable* pBindable, EShaderStage stage) noexcept;
Expand Down
3 changes: 3 additions & 0 deletions include/ResourceState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
// Licensed under the MIT License.
#pragma once

#include "ResourceBinding.hpp"

namespace D3D12TranslationLayer
{
class CommandListManager;
class Fence;

// These are defined in the private d3d12 header
#define UNKNOWN_RESOURCE_STATE (D3D12_RESOURCE_STATES)0x8000u
Expand Down
2 changes: 2 additions & 0 deletions include/Sampler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Licensed under the MIT License.
#pragma once

#include "DeviceChild.hpp"

namespace D3D12TranslationLayer
{
//==================================================================================================================================
Expand Down
2 changes: 2 additions & 0 deletions include/Shader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Licensed under the MIT License.
#pragma once

#include "DeviceChild.hpp"

namespace D3D12TranslationLayer
{
enum class RESOURCE_DIMENSION
Expand Down
10 changes: 5 additions & 5 deletions include/Util.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,11 @@ namespace D3D12TranslationLayer
return reinterpret_cast<T*const*>(this);
}

using unique_ptr::release;
using unique_ptr::get;
using unique_ptr::operator->;
using unique_ptr::operator*;
using unique_ptr::operator bool;
using std::unique_ptr<T, Deleter>::release;
using std::unique_ptr<T, Deleter>::get;
using std::unique_ptr<T, Deleter>::operator->;
using std::unique_ptr<T, Deleter>::operator*;
using std::unique_ptr<T, Deleter>::operator bool;

private:
unique_comptr& operator=(unique_comptr const&) = delete;
Expand Down
2 changes: 1 addition & 1 deletion include/View.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ namespace D3D12TranslationLayer

const TDesc12& GetDesc12() noexcept;

bool IsUpToDate() const noexcept { return m_pResource->GetUniqueness<TIface>() == m_ViewUniqueness; }
bool IsUpToDate() const noexcept;
HRESULT RefreshUnderlying() noexcept;
D3D12_CPU_DESCRIPTOR_HANDLE GetRefreshedDescriptorHandle()
{
Expand Down
Loading