Split D3D12 struct serialisers separately&serialise interfaces directly

* Interface objects are serialised by type as their ResourceId - see the
  D3D11 code that does the same thing for more explanation.
This commit is contained in:
baldurk
2017-10-30 10:45:51 +00:00
parent b7cc721db3
commit c2a8e19d07
13 changed files with 1257 additions and 1188 deletions
File diff suppressed because it is too large Load Diff
+132 -63
View File
@@ -297,70 +297,139 @@ struct D3D12CommandSignature
ret func; \
bool CONCAT(Serialise_, func);
template <>
void Serialiser::Serialise(const char *name, D3D12_RESOURCE_DESC &el);
template <>
void Serialiser::Serialise(const char *name, D3D12_COMMAND_QUEUE_DESC &el);
template <>
void Serialiser::Serialise(const char *name, D3D12_SHADER_BYTECODE &el);
template <>
void Serialiser::Serialise(const char *name, D3D12_GRAPHICS_PIPELINE_STATE_DESC &el);
template <>
void Serialiser::Deserialise(const D3D12_GRAPHICS_PIPELINE_STATE_DESC *const el) const;
template <>
void Serialiser::Serialise(const char *name, D3D12_COMPUTE_PIPELINE_STATE_DESC &el);
template <>
void Serialiser::Deserialise(const D3D12_COMPUTE_PIPELINE_STATE_DESC *const el) const;
template <>
void Serialiser::Serialise(const char *name, D3D12_INDEX_BUFFER_VIEW &el);
template <>
void Serialiser::Serialise(const char *name, D3D12_VERTEX_BUFFER_VIEW &el);
template <>
void Serialiser::Serialise(const char *name, D3D12_STREAM_OUTPUT_BUFFER_VIEW &el);
template <>
void Serialiser::Serialise(const char *name, D3D12_RESOURCE_BARRIER &el);
template <>
void Serialiser::Serialise(const char *name, D3D12_HEAP_PROPERTIES &el);
template <>
void Serialiser::Serialise(const char *name, D3D12_HEAP_DESC &el);
template <>
void Serialiser::Serialise(const char *name, D3D12_DESCRIPTOR_HEAP_DESC &el);
template <>
void Serialiser::Serialise(const char *name, D3D12_INDIRECT_ARGUMENT_DESC &el);
template <>
void Serialiser::Serialise(const char *name, D3D12_COMMAND_SIGNATURE_DESC &el);
template <>
void Serialiser::Deserialise(const D3D12_COMMAND_SIGNATURE_DESC *const el) const;
template <>
void Serialiser::Serialise(const char *name, D3D12_QUERY_HEAP_DESC &el);
template <>
void Serialiser::Serialise(const char *name, D3D12_SAMPLER_DESC &el);
template <>
void Serialiser::Serialise(const char *name, D3D12_CONSTANT_BUFFER_VIEW_DESC &el);
template <>
void Serialiser::Serialise(const char *name, D3D12_SHADER_RESOURCE_VIEW_DESC &el);
template <>
void Serialiser::Serialise(const char *name, D3D12_RENDER_TARGET_VIEW_DESC &el);
template <>
void Serialiser::Serialise(const char *name, D3D12_DEPTH_STENCIL_VIEW_DESC &el);
template <>
void Serialiser::Serialise(const char *name, D3D12_UNORDERED_ACCESS_VIEW_DESC &el);
template <>
void Serialiser::Serialise(const char *name, D3D12_CLEAR_VALUE &el);
template <>
void Serialiser::Serialise(const char *name, D3D12_TEXTURE_COPY_LOCATION &el);
template <>
void Serialiser::Serialise(const char *name, D3D12_TILED_RESOURCE_COORDINATE &el);
template <>
void Serialiser::Serialise(const char *name, D3D12_TILE_REGION_SIZE &el);
template <>
void Serialiser::Serialise(const char *name, D3D12_DISCARD_REGION &el);
template <>
void Serialiser::Deserialise(const D3D12_DISCARD_REGION *const el) const;
// this is special - these serialise overloads will fetch the ID during capture, serialise the ID
// directly as-if it were the original type, then on replay load up the resource if available.
// Really this is only one type of serialisation, but we declare a couple of overloads to account
// for resources being accessed through different interfaces in different functions
#define SERIALISE_D3D_INTERFACES() \
SERIALISE_INTERFACE(ID3D12Object); \
SERIALISE_INTERFACE(ID3D12DeviceChild); \
SERIALISE_INTERFACE(ID3D12Pageable); \
SERIALISE_INTERFACE(ID3D12CommandList); \
SERIALISE_INTERFACE(ID3D12GraphicsCommandList); \
SERIALISE_INTERFACE(ID3D12RootSignature); \
SERIALISE_INTERFACE(ID3D12Resource); \
SERIALISE_INTERFACE(ID3D12QueryHeap); \
SERIALISE_INTERFACE(ID3D12PipelineState); \
SERIALISE_INTERFACE(ID3D12Heap); \
SERIALISE_INTERFACE(ID3D12Fence); \
SERIALISE_INTERFACE(ID3D12DescriptorHeap); \
SERIALISE_INTERFACE(ID3D12CommandSignature); \
SERIALISE_INTERFACE(ID3D12CommandQueue); \
SERIALISE_INTERFACE(ID3D12CommandAllocator);
struct D3D12Descriptor;
template <>
void Serialiser::Serialise(const char *name, D3D12Descriptor &el);
#define SERIALISE_INTERFACE(iface) DECLARE_REFLECTION_STRUCT(iface *)
SERIALISE_D3D_INTERFACES();
// a thin utility wrapper around a UINT64, that serialises a BufferLocation as an Id + Offset.
struct D3D12BufferLocation
{
D3D12BufferLocation(UINT64 l) : Location(l) {}
operator UINT64() const { return Location; }
UINT64 Location;
};
DECLARE_REFLECTION_STRUCT(D3D12BufferLocation);
DECLARE_REFLECTION_STRUCT(D3D12_CPU_DESCRIPTOR_HANDLE);
DECLARE_REFLECTION_STRUCT(D3D12_GPU_DESCRIPTOR_HANDLE);
DECLARE_REFLECTION_ENUM(D3D12_COMMAND_LIST_TYPE);
DECLARE_REFLECTION_ENUM(D3D12_HEAP_TYPE);
DECLARE_REFLECTION_ENUM(D3D12_CPU_PAGE_PROPERTY);
DECLARE_REFLECTION_ENUM(D3D12_MEMORY_POOL);
DECLARE_REFLECTION_ENUM(D3D12_QUERY_TYPE);
DECLARE_REFLECTION_ENUM(D3D12_QUERY_HEAP_TYPE);
DECLARE_REFLECTION_ENUM(D3D12_DESCRIPTOR_HEAP_TYPE);
DECLARE_REFLECTION_ENUM(D3D12_DESCRIPTOR_HEAP_FLAGS);
DECLARE_REFLECTION_ENUM(D3D12_PREDICATION_OP);
DECLARE_REFLECTION_ENUM(D3D12_CLEAR_FLAGS);
DECLARE_REFLECTION_ENUM(D3D12_DSV_DIMENSION);
DECLARE_REFLECTION_ENUM(D3D12_UAV_DIMENSION);
DECLARE_REFLECTION_ENUM(D3D12_SRV_DIMENSION);
DECLARE_REFLECTION_ENUM(D3D12_RTV_DIMENSION);
DECLARE_REFLECTION_ENUM(D3D12_DSV_FLAGS);
DECLARE_REFLECTION_ENUM(D3D12_BUFFER_SRV_FLAGS);
DECLARE_REFLECTION_ENUM(D3D12_BUFFER_UAV_FLAGS);
DECLARE_REFLECTION_ENUM(D3D12_RESOURCE_STATES);
DECLARE_REFLECTION_ENUM(D3D12_HEAP_FLAGS);
DECLARE_REFLECTION_ENUM(D3D12_FENCE_FLAGS);
DECLARE_REFLECTION_ENUM(D3D12_PRIMITIVE_TOPOLOGY_TYPE);
DECLARE_REFLECTION_ENUM(D3D12_PRIMITIVE_TOPOLOGY);
DECLARE_REFLECTION_ENUM(D3D12_INDIRECT_ARGUMENT_TYPE);
DECLARE_REFLECTION_ENUM(D3D12_PIPELINE_STATE_FLAGS);
DECLARE_REFLECTION_ENUM(D3D12_RESOURCE_BARRIER_TYPE);
DECLARE_REFLECTION_ENUM(D3D12_RESOURCE_BARRIER_FLAGS);
DECLARE_REFLECTION_ENUM(D3D12_INPUT_CLASSIFICATION);
DECLARE_REFLECTION_ENUM(D3D12_INDEX_BUFFER_STRIP_CUT_VALUE);
DECLARE_REFLECTION_ENUM(D3D12_RESOURCE_DIMENSION);
DECLARE_REFLECTION_ENUM(D3D12_TEXTURE_LAYOUT);
DECLARE_REFLECTION_ENUM(D3D12_RESOURCE_FLAGS);
DECLARE_REFLECTION_ENUM(D3D12_COMMAND_QUEUE_FLAGS);
DECLARE_REFLECTION_ENUM(D3D12_TEXTURE_COPY_TYPE);
DECLARE_REFLECTION_ENUM(D3D12_FILL_MODE);
DECLARE_REFLECTION_ENUM(D3D12_CULL_MODE);
DECLARE_REFLECTION_ENUM(D3D12_FILTER);
DECLARE_REFLECTION_ENUM(D3D12_COMPARISON_FUNC);
DECLARE_REFLECTION_ENUM(D3D12_TEXTURE_ADDRESS_MODE);
DECLARE_REFLECTION_ENUM(D3D12_CONSERVATIVE_RASTERIZATION_MODE);
DECLARE_REFLECTION_ENUM(D3D12_LOGIC_OP);
DECLARE_REFLECTION_ENUM(D3D12_BLEND);
DECLARE_REFLECTION_ENUM(D3D12_BLEND_OP);
DECLARE_REFLECTION_ENUM(D3D12_STENCIL_OP);
DECLARE_REFLECTION_ENUM(D3D12_COLOR_WRITE_ENABLE);
DECLARE_REFLECTION_ENUM(D3D12_DEPTH_WRITE_MASK);
DECLARE_REFLECTION_STRUCT(D3D12_RESOURCE_DESC);
DECLARE_REFLECTION_STRUCT(D3D12_COMMAND_QUEUE_DESC);
DECLARE_REFLECTION_STRUCT(D3D12_SHADER_BYTECODE);
DECLARE_REFLECTION_STRUCT(D3D12_SO_DECLARATION_ENTRY);
DECLARE_REFLECTION_STRUCT(D3D12_STREAM_OUTPUT_DESC);
DECLARE_REFLECTION_STRUCT(D3D12_RASTERIZER_DESC);
DECLARE_REFLECTION_STRUCT(D3D12_DEPTH_STENCILOP_DESC);
DECLARE_REFLECTION_STRUCT(D3D12_DEPTH_STENCIL_DESC);
DECLARE_REFLECTION_STRUCT(D3D12_INPUT_ELEMENT_DESC);
DECLARE_REFLECTION_STRUCT(D3D12_INPUT_LAYOUT_DESC);
DECLARE_REFLECTION_STRUCT(D3D12_RENDER_TARGET_BLEND_DESC);
DECLARE_REFLECTION_STRUCT(D3D12_BLEND_DESC);
DECLARE_REFLECTION_STRUCT(D3D12_GRAPHICS_PIPELINE_STATE_DESC);
DECLARE_REFLECTION_STRUCT(D3D12_COMPUTE_PIPELINE_STATE_DESC);
DECLARE_REFLECTION_STRUCT(D3D12_INDEX_BUFFER_VIEW);
DECLARE_REFLECTION_STRUCT(D3D12_VERTEX_BUFFER_VIEW);
DECLARE_REFLECTION_STRUCT(D3D12_STREAM_OUTPUT_BUFFER_VIEW);
DECLARE_REFLECTION_STRUCT(D3D12_RESOURCE_TRANSITION_BARRIER);
DECLARE_REFLECTION_STRUCT(D3D12_RESOURCE_ALIASING_BARRIER);
DECLARE_REFLECTION_STRUCT(D3D12_RESOURCE_UAV_BARRIER);
DECLARE_REFLECTION_STRUCT(D3D12_RESOURCE_BARRIER);
DECLARE_REFLECTION_STRUCT(D3D12_HEAP_PROPERTIES);
DECLARE_REFLECTION_STRUCT(D3D12_HEAP_DESC);
DECLARE_REFLECTION_STRUCT(D3D12_DESCRIPTOR_HEAP_DESC);
DECLARE_REFLECTION_STRUCT(D3D12_INDIRECT_ARGUMENT_DESC);
DECLARE_REFLECTION_STRUCT(D3D12_COMMAND_SIGNATURE_DESC);
DECLARE_REFLECTION_STRUCT(D3D12_QUERY_HEAP_DESC);
DECLARE_REFLECTION_STRUCT(D3D12_SAMPLER_DESC);
DECLARE_REFLECTION_STRUCT(D3D12_CONSTANT_BUFFER_VIEW_DESC);
DECLARE_REFLECTION_STRUCT(D3D12_SHADER_RESOURCE_VIEW_DESC);
DECLARE_REFLECTION_STRUCT(D3D12_RENDER_TARGET_VIEW_DESC);
DECLARE_REFLECTION_STRUCT(D3D12_DEPTH_STENCIL_VIEW_DESC);
DECLARE_REFLECTION_STRUCT(D3D12_UNORDERED_ACCESS_VIEW_DESC);
DECLARE_REFLECTION_STRUCT(D3D12_DEPTH_STENCIL_VALUE);
DECLARE_REFLECTION_STRUCT(D3D12_CLEAR_VALUE);
DECLARE_REFLECTION_STRUCT(D3D12_SUBRESOURCE_FOOTPRINT);
DECLARE_REFLECTION_STRUCT(D3D12_TEXTURE_COPY_LOCATION);
DECLARE_REFLECTION_STRUCT(D3D12_TILED_RESOURCE_COORDINATE);
DECLARE_REFLECTION_STRUCT(D3D12_TILE_REGION_SIZE);
DECLARE_REFLECTION_STRUCT(D3D12_DISCARD_REGION);
DECLARE_REFLECTION_STRUCT(D3D12_RANGE);
DECLARE_REFLECTION_STRUCT(D3D12_RECT);
DECLARE_REFLECTION_STRUCT(D3D12_BOX);
DECLARE_REFLECTION_STRUCT(D3D12_VIEWPORT);
DECLARE_DESERIALISE_TYPE(D3D12_DISCARD_REGION);
DECLARE_DESERIALISE_TYPE(D3D12_GRAPHICS_PIPELINE_STATE_DESC);
DECLARE_DESERIALISE_TYPE(D3D12_COMPUTE_PIPELINE_STATE_DESC);
DECLARE_DESERIALISE_TYPE(D3D12_COMMAND_SIGNATURE_DESC);
enum class D3D12Chunk : uint32_t
{
+1 -1
View File
@@ -656,7 +656,7 @@ bool WrappedID3D12Device::Serialise_DynamicDescriptorWrite(Serialiser *localSeri
{
// safe to pass an invalid heap type to Create() as these descriptors will by definition not
// be undefined
RDCASSERT(desc.GetType() != D3D12Descriptor::TypeUndefined);
RDCASSERT(desc.GetType() != D3D12DescriptorType::Undefined);
desc.Create(D3D12_DESCRIPTOR_HEAP_TYPE_NUM_TYPES, this, *handle);
}
}
+20 -20
View File
@@ -39,7 +39,7 @@ void D3D12Descriptor::Init(const D3D12_SAMPLER_DESC *pDesc)
void D3D12Descriptor::Init(const D3D12_CONSTANT_BUFFER_VIEW_DESC *pDesc)
{
nonsamp.type = TypeCBV;
nonsamp.type = D3D12DescriptorType::CBV;
nonsamp.resource = NULL;
if(pDesc)
nonsamp.cbv = *pDesc;
@@ -49,7 +49,7 @@ void D3D12Descriptor::Init(const D3D12_CONSTANT_BUFFER_VIEW_DESC *pDesc)
void D3D12Descriptor::Init(ID3D12Resource *pResource, const D3D12_SHADER_RESOURCE_VIEW_DESC *pDesc)
{
nonsamp.type = TypeSRV;
nonsamp.type = D3D12DescriptorType::SRV;
nonsamp.resource = pResource;
if(pDesc)
nonsamp.srv = *pDesc;
@@ -60,7 +60,7 @@ void D3D12Descriptor::Init(ID3D12Resource *pResource, const D3D12_SHADER_RESOURC
void D3D12Descriptor::Init(ID3D12Resource *pResource, ID3D12Resource *pCounterResource,
const D3D12_UNORDERED_ACCESS_VIEW_DESC *pDesc)
{
nonsamp.type = TypeUAV;
nonsamp.type = D3D12DescriptorType::UAV;
nonsamp.resource = pResource;
nonsamp.uav.counterResource = pCounterResource;
if(pDesc)
@@ -71,7 +71,7 @@ void D3D12Descriptor::Init(ID3D12Resource *pResource, ID3D12Resource *pCounterRe
void D3D12Descriptor::Init(ID3D12Resource *pResource, const D3D12_RENDER_TARGET_VIEW_DESC *pDesc)
{
nonsamp.type = TypeRTV;
nonsamp.type = D3D12DescriptorType::RTV;
nonsamp.resource = pResource;
if(pDesc)
nonsamp.rtv = *pDesc;
@@ -81,7 +81,7 @@ void D3D12Descriptor::Init(ID3D12Resource *pResource, const D3D12_RENDER_TARGET_
void D3D12Descriptor::Init(ID3D12Resource *pResource, const D3D12_DEPTH_STENCIL_VIEW_DESC *pDesc)
{
nonsamp.type = TypeDSV;
nonsamp.type = D3D12DescriptorType::DSV;
nonsamp.resource = pResource;
if(pDesc)
nonsamp.dsv = *pDesc;
@@ -127,21 +127,21 @@ static D3D12_UNORDERED_ACCESS_VIEW_DESC *defaultUAV()
void D3D12Descriptor::Create(D3D12_DESCRIPTOR_HEAP_TYPE heapType, WrappedID3D12Device *dev,
D3D12_CPU_DESCRIPTOR_HANDLE handle)
{
D3D12Descriptor::DescriptorType type = GetType();
D3D12DescriptorType type = GetType();
switch(type)
{
case D3D12Descriptor::TypeSampler:
case D3D12DescriptorType::Sampler:
{
dev->CreateSampler(&samp.desc, handle);
break;
}
case D3D12Descriptor::TypeCBV:
case D3D12DescriptorType::CBV:
{
dev->CreateConstantBufferView(&nonsamp.cbv, handle);
break;
}
case D3D12Descriptor::TypeSRV:
case D3D12DescriptorType::SRV:
{
D3D12_SHADER_RESOURCE_VIEW_DESC *desc = &nonsamp.srv;
if(desc->ViewDimension == D3D12_SRV_DIMENSION_UNKNOWN)
@@ -264,7 +264,7 @@ void D3D12Descriptor::Create(D3D12_DESCRIPTOR_HEAP_TYPE heapType, WrappedID3D12D
dev->CreateShaderResourceView(nonsamp.resource, desc, handle);
break;
}
case D3D12Descriptor::TypeRTV:
case D3D12DescriptorType::RTV:
{
D3D12_RENDER_TARGET_VIEW_DESC *desc = &nonsamp.rtv;
if(desc->ViewDimension == D3D12_RTV_DIMENSION_UNKNOWN)
@@ -366,7 +366,7 @@ void D3D12Descriptor::Create(D3D12_DESCRIPTOR_HEAP_TYPE heapType, WrappedID3D12D
dev->CreateRenderTargetView(nonsamp.resource, desc, handle);
break;
}
case D3D12Descriptor::TypeDSV:
case D3D12DescriptorType::DSV:
{
D3D12_DEPTH_STENCIL_VIEW_DESC *desc = &nonsamp.dsv;
if(desc->ViewDimension == D3D12_DSV_DIMENSION_UNKNOWN)
@@ -410,7 +410,7 @@ void D3D12Descriptor::Create(D3D12_DESCRIPTOR_HEAP_TYPE heapType, WrappedID3D12D
dev->CreateDepthStencilView(nonsamp.resource, desc, handle);
break;
}
case D3D12Descriptor::TypeUAV:
case D3D12DescriptorType::UAV:
{
D3D12_UNORDERED_ACCESS_VIEW_DESC uavdesc = nonsamp.uav.desc.AsDesc();
@@ -524,7 +524,7 @@ void D3D12Descriptor::Create(D3D12_DESCRIPTOR_HEAP_TYPE heapType, WrappedID3D12D
dev->CreateUnorderedAccessView(nonsamp.resource, counter, desc, handle);
break;
}
case D3D12Descriptor::TypeUndefined:
case D3D12DescriptorType::Undefined:
{
// initially descriptors are undefined. This way we just init with
// a null descriptor so it's valid to copy around etc but is no
@@ -562,19 +562,19 @@ void D3D12Descriptor::GetRefIDs(ResourceId &id, ResourceId &id2, FrameRefType &r
switch(GetType())
{
case D3D12Descriptor::TypeUndefined:
case D3D12Descriptor::TypeSampler:
case D3D12DescriptorType::Undefined:
case D3D12DescriptorType::Sampler:
// nothing to do - no resource here
break;
case D3D12Descriptor::TypeCBV:
case D3D12DescriptorType::CBV:
id = WrappedID3D12Resource::GetResIDFromAddr(nonsamp.cbv.BufferLocation);
break;
case D3D12Descriptor::TypeSRV: id = GetResID(nonsamp.resource); break;
case D3D12Descriptor::TypeUAV:
case D3D12DescriptorType::SRV: id = GetResID(nonsamp.resource); break;
case D3D12DescriptorType::UAV:
id2 = GetResID(nonsamp.uav.counterResource);
// deliberate fall-through
case D3D12Descriptor::TypeRTV:
case D3D12Descriptor::TypeDSV:
case D3D12DescriptorType::RTV:
case D3D12DescriptorType::DSV:
ref = eFrameRef_Write;
id = GetResID(nonsamp.resource);
break;
+27 -17
View File
@@ -50,6 +50,8 @@ enum D3D12ResourceType
Resource_PipelineLibrary,
};
DECLARE_REFLECTION_ENUM(D3D12ResourceType);
class WrappedID3D12DescriptorHeap;
// squeeze the descriptor a bit so that the below struct fits in 64 bytes
@@ -117,27 +119,29 @@ struct D3D12_UNORDERED_ACCESS_VIEW_DESC_SQUEEZED
}
};
enum class D3D12DescriptorType
{
// we start at 0x1000 since this element will alias with the filter
// in the sampler, to save space
Sampler,
CBV = 0x1000,
SRV,
UAV,
RTV,
DSV,
Undefined,
};
DECLARE_REFLECTION_ENUM(D3D12DescriptorType);
struct D3D12Descriptor
{
enum DescriptorType
{
// we start at 0x1000 since this element will alias with the filter
// in the sampler, to save space
TypeSampler,
TypeCBV = 0x1000,
TypeSRV,
TypeUAV,
TypeRTV,
TypeDSV,
TypeUndefined,
};
DescriptorType GetType() const
D3D12DescriptorType GetType() const
{
RDCCOMPILE_ASSERT(sizeof(D3D12Descriptor) <= 64, "D3D12Descriptor has gotten larger");
if(nonsamp.type < TypeCBV)
return TypeSampler;
if(nonsamp.type < D3D12DescriptorType::CBV)
return D3D12DescriptorType::Sampler;
return nonsamp.type;
}
@@ -189,7 +193,7 @@ struct D3D12Descriptor
// this element overlaps with the D3D12_FILTER in D3D12_SAMPLER_DESC,
// with values that are invalid for filter
DescriptorType type;
D3D12DescriptorType type;
ID3D12Resource *resource;
@@ -209,6 +213,8 @@ struct D3D12Descriptor
};
};
DECLARE_REFLECTION_STRUCT(D3D12Descriptor);
inline D3D12Descriptor *GetWrapped(D3D12_CPU_DESCRIPTOR_HANDLE handle)
{
return (D3D12Descriptor *)handle.ptr;
@@ -233,6 +239,8 @@ struct PortableHandle
uint32_t index;
};
DECLARE_REFLECTION_STRUCT(PortableHandle);
class D3D12ResourceManager;
PortableHandle ToPortableHandle(D3D12Descriptor *handle);
@@ -264,6 +272,8 @@ struct DynamicDescriptorCopy
D3D12_DESCRIPTOR_HEAP_TYPE type;
};
DECLARE_REFLECTION_STRUCT(DynamicDescriptorCopy);
struct D3D12ResourceRecord;
struct CmdListRecordingInfo
+8 -8
View File
@@ -324,7 +324,7 @@ void D3D12Replay::FillResourceView(D3D12Pipe::View &view, D3D12Descriptor *desc)
{
D3D12ResourceManager *rm = m_pDevice->GetResourceManager();
if(desc->GetType() == D3D12Descriptor::TypeSampler || desc->GetType() == D3D12Descriptor::TypeCBV)
if(desc->GetType() == D3D12DescriptorType::Sampler || desc->GetType() == D3D12DescriptorType::CBV)
{
return;
}
@@ -339,11 +339,11 @@ void D3D12Replay::FillResourceView(D3D12Pipe::View &view, D3D12Descriptor *desc)
{
DXGI_FORMAT fmt = DXGI_FORMAT_UNKNOWN;
if(desc->GetType() == D3D12Descriptor::TypeRTV)
if(desc->GetType() == D3D12DescriptorType::RTV)
fmt = desc->nonsamp.rtv.Format;
else if(desc->GetType() == D3D12Descriptor::TypeSRV)
else if(desc->GetType() == D3D12DescriptorType::SRV)
fmt = desc->nonsamp.srv.Format;
else if(desc->GetType() == D3D12Descriptor::TypeUAV)
else if(desc->GetType() == D3D12DescriptorType::UAV)
fmt = (DXGI_FORMAT)desc->nonsamp.uav.desc.Format;
if(fmt == DXGI_FORMAT_UNKNOWN)
@@ -353,7 +353,7 @@ void D3D12Replay::FillResourceView(D3D12Pipe::View &view, D3D12Descriptor *desc)
view.Format = MakeResourceFormat(fmt);
if(desc->GetType() == D3D12Descriptor::TypeRTV)
if(desc->GetType() == D3D12DescriptorType::RTV)
{
view.Type = MakeTextureDim(desc->nonsamp.rtv.ViewDimension);
@@ -397,7 +397,7 @@ void D3D12Replay::FillResourceView(D3D12Pipe::View &view, D3D12Descriptor *desc)
view.HighestMip = desc->nonsamp.rtv.Texture3D.MipSlice;
}
}
else if(desc->GetType() == D3D12Descriptor::TypeDSV)
else if(desc->GetType() == D3D12DescriptorType::DSV)
{
view.Type = MakeTextureDim(desc->nonsamp.dsv.ViewDimension);
@@ -430,7 +430,7 @@ void D3D12Replay::FillResourceView(D3D12Pipe::View &view, D3D12Descriptor *desc)
view.FirstArraySlice = desc->nonsamp.dsv.Texture2DArray.FirstArraySlice;
}
}
else if(desc->GetType() == D3D12Descriptor::TypeSRV)
else if(desc->GetType() == D3D12DescriptorType::SRV)
{
view.Type = MakeTextureDim(desc->nonsamp.srv.ViewDimension);
@@ -495,7 +495,7 @@ void D3D12Replay::FillResourceView(D3D12Pipe::View &view, D3D12Descriptor *desc)
view.MinLODClamp = desc->nonsamp.srv.Texture3D.ResourceMinLODClamp;
}
}
else if(desc->GetType() == D3D12Descriptor::TypeUAV)
else if(desc->GetType() == D3D12DescriptorType::UAV)
{
D3D12_UNORDERED_ACCESS_VIEW_DESC uav = desc->nonsamp.uav.desc.AsDesc();
+32 -9
View File
@@ -147,7 +147,7 @@ ALL_D3D12_TYPES;
WRAPPED_POOL_INST(WrappedID3D12Shader);
D3D12ResourceType IdentifyTypeByPtr(ID3D12DeviceChild *ptr)
D3D12ResourceType IdentifyTypeByPtr(ID3D12Object *ptr)
{
if(ptr == NULL)
return Resource_Unknown;
@@ -169,7 +169,7 @@ D3D12ResourceType IdentifyTypeByPtr(ID3D12DeviceChild *ptr)
return Resource_Unknown;
}
TrackedResource12 *GetTracked(ID3D12DeviceChild *ptr)
TrackedResource12 *GetTracked(ID3D12Object *ptr)
{
if(ptr == NULL)
return NULL;
@@ -188,7 +188,7 @@ TrackedResource12 *GetTracked(ID3D12DeviceChild *ptr)
}
template <>
ID3D12DeviceChild *Unwrap(ID3D12DeviceChild *ptr)
ID3D12Object *Unwrap(ID3D12Object *ptr)
{
if(ptr == NULL)
return NULL;
@@ -196,14 +196,14 @@ ID3D12DeviceChild *Unwrap(ID3D12DeviceChild *ptr)
#undef D3D12_TYPE_MACRO
#define D3D12_TYPE_MACRO(iface) \
if(UnwrapHelper<iface>::IsAlloc(ptr)) \
return (ID3D12DeviceChild *)GetWrapped((iface *)ptr)->GetReal();
return (ID3D12Object *)GetWrapped((iface *)ptr)->GetReal();
ALL_D3D12_TYPES;
if(WrappedID3D12GraphicsCommandList::IsAlloc(ptr))
return (ID3D12DeviceChild *)(((WrappedID3D12GraphicsCommandList *)ptr)->GetReal());
return (ID3D12Object *)(((WrappedID3D12GraphicsCommandList *)ptr)->GetReal());
if(WrappedID3D12CommandQueue::IsAlloc(ptr))
return (ID3D12DeviceChild *)(((WrappedID3D12CommandQueue *)ptr)->GetReal());
return (ID3D12Object *)(((WrappedID3D12CommandQueue *)ptr)->GetReal());
RDCERR("Unknown type of ptr 0x%p", ptr);
@@ -211,7 +211,7 @@ ID3D12DeviceChild *Unwrap(ID3D12DeviceChild *ptr)
}
template <>
ResourceId GetResID(ID3D12DeviceChild *ptr)
ResourceId GetResID(ID3D12Object *ptr)
{
if(ptr == NULL)
return ResourceId();
@@ -234,7 +234,7 @@ ResourceId GetResID(ID3D12DeviceChild *ptr)
}
template <>
D3D12ResourceRecord *GetRecord(ID3D12DeviceChild *ptr)
D3D12ResourceRecord *GetRecord(ID3D12Object *ptr)
{
if(ptr == NULL)
return NULL;
@@ -256,6 +256,29 @@ D3D12ResourceRecord *GetRecord(ID3D12DeviceChild *ptr)
return res->GetResourceRecord();
}
template <>
ResourceId GetResID(ID3D12DeviceChild *ptr)
{
return GetResID((ID3D12Object *)ptr);
}
template <>
ResourceId GetResID(ID3D12Pageable *ptr)
{
return GetResID((ID3D12Object *)ptr);
}
template <>
D3D12ResourceRecord *GetRecord(ID3D12DeviceChild *ptr)
{
return GetRecord((ID3D12Object *)ptr);
}
template <>
ID3D12DeviceChild *Unwrap(ID3D12DeviceChild *ptr)
{
return (ID3D12DeviceChild *)Unwrap((ID3D12Object *)ptr);
}
WrappedID3D12Resource::~WrappedID3D12Resource()
{
// perform an implicit unmap on release
@@ -450,7 +473,7 @@ WrappedID3D12DescriptorHeap::WrappedID3D12DescriptorHeap(ID3D12DescriptorHeap *r
// initially descriptors are undefined. This way we just fill them with
// some null SRV descriptor so it's safe to copy around etc but is no
// less undefined for the application to use
descriptors[i].nonsamp.type = D3D12Descriptor::TypeUndefined;
descriptors[i].nonsamp.type = D3D12DescriptorType::Undefined;
}
}
+17 -1
View File
@@ -963,7 +963,7 @@ struct UnwrapHelper
ALL_D3D12_TYPES;
D3D12ResourceType IdentifyTypeByPtr(ID3D12DeviceChild *ptr);
D3D12ResourceType IdentifyTypeByPtr(ID3D12Object *ptr);
#define WRAPPING_DEBUG 0
@@ -1014,9 +1014,25 @@ D3D12ResourceRecord *GetRecord(ifaceptr obj)
}
// specialisations that use the IsAlloc() function to identify the real type
template <>
ResourceId GetResID(ID3D12Object *ptr);
template <>
ID3D12Object *Unwrap(ID3D12Object *ptr);
template <>
D3D12ResourceRecord *GetRecord(ID3D12Object *ptr);
template <>
ResourceId GetResID(ID3D12DeviceChild *ptr);
template <>
ResourceId GetResID(ID3D12Pageable *ptr);
template <>
ResourceId GetResID(ID3D12CommandList *ptr);
template <>
ResourceId GetResID(ID3D12GraphicsCommandList *ptr);
template <>
ResourceId GetResID(ID3D12CommandQueue *ptr);
template <>
ID3D12DeviceChild *Unwrap(ID3D12DeviceChild *ptr);
template <>
D3D12ResourceRecord *GetRecord(ID3D12DeviceChild *ptr);
File diff suppressed because it is too large Load Diff
+3 -3
View File
@@ -93,7 +93,7 @@ vector<ResourceId> D3D12RenderState::GetRTVIDs() const
for(UINT i = 0; i < rts.size(); i++)
{
RDCASSERT(descs[i].GetType() == D3D12Descriptor::TypeRTV);
RDCASSERT(descs[i].GetType() == D3D12DescriptorType::RTV);
ret.push_back(GetResID(descs[i].nonsamp.resource));
}
}
@@ -107,7 +107,7 @@ vector<ResourceId> D3D12RenderState::GetRTVIDs() const
const D3D12Descriptor &desc = heap->GetDescriptors()[rts[i].index];
RDCASSERT(desc.GetType() == D3D12Descriptor::TypeRTV);
RDCASSERT(desc.GetType() == D3D12DescriptorType::RTV);
ret.push_back(GetResID(desc.nonsamp.resource));
}
}
@@ -121,7 +121,7 @@ ResourceId D3D12RenderState::GetDSVID() const
{
const D3D12Descriptor *desc = DescriptorFromPortableHandle(GetResourceManager(), dsv);
RDCASSERT(desc->GetType() == D3D12Descriptor::TypeDSV);
RDCASSERT(desc->GetType() == D3D12DescriptorType::DSV);
return GetResID(desc->nonsamp.resource);
}
+9 -9
View File
@@ -164,19 +164,19 @@ std::string DoStringise(const D3D12Chunk &el)
}
template <>
std::string DoStringise(const D3D12Descriptor::DescriptorType &el)
std::string DoStringise(const D3D12DescriptorType &el)
{
if((uint32_t)el < D3D12Descriptor::TypeCBV)
if((uint32_t)el < (uint32_t)D3D12DescriptorType::CBV)
return "Sampler";
BEGIN_ENUM_STRINGISE(D3D12Descriptor::DescriptorType);
BEGIN_ENUM_STRINGISE(D3D12DescriptorType);
{
STRINGISE_ENUM_NAMED(D3D12Descriptor::TypeCBV, "CBV");
STRINGISE_ENUM_NAMED(D3D12Descriptor::TypeSRV, "SRV");
STRINGISE_ENUM_NAMED(D3D12Descriptor::TypeUAV, "UAV");
STRINGISE_ENUM_NAMED(D3D12Descriptor::TypeRTV, "RTV");
STRINGISE_ENUM_NAMED(D3D12Descriptor::TypeDSV, "DSV");
STRINGISE_ENUM_NAMED(D3D12Descriptor::TypeUndefined, "Undefined");
STRINGISE_ENUM_CLASS_NAMED(CBV, "CBV");
STRINGISE_ENUM_CLASS_NAMED(SRV, "SRV");
STRINGISE_ENUM_CLASS_NAMED(UAV, "UAV");
STRINGISE_ENUM_CLASS_NAMED(RTV, "RTV");
STRINGISE_ENUM_CLASS_NAMED(DSV, "DSV");
STRINGISE_ENUM_CLASS_NAMED(Undefined, "Undefined");
}
END_ENUM_STRINGISE();
}
@@ -111,6 +111,7 @@
<ClCompile Include="d3d12_manager.cpp" />
<ClCompile Include="d3d12_replay.cpp" />
<ClCompile Include="d3d12_resources.cpp" />
<ClCompile Include="d3d12_serialise.cpp" />
<ClCompile Include="d3d12_state.cpp" />
<ClCompile Include="d3d12_stringise.cpp" />
<ClCompile Include="precompiled.cpp">
@@ -113,5 +113,8 @@
<ClCompile Include="d3d12_initstate.cpp">
<Filter>Util</Filter>
</ClCompile>
<ClCompile Include="d3d12_serialise.cpp">
<Filter>Util</Filter>
</ClCompile>
</ItemGroup>
</Project>