summaryrefslogtreecommitdiff
path: root/tools/gfx/d3d12
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2024-10-29 14:49:26 +0800
committerGitHub <noreply@github.com>2024-10-29 14:49:26 +0800
commitf65d756bff8d4c5cbc15bd0322a2ae8e6b896a21 (patch)
treeea1d61342cd29368e19135000ec2948813096205 /tools/gfx/d3d12
parenta729c15e9dce9f5116a38afc66329ab2ca4cea54 (diff)
format
* format * Minor test fixes * enable checking cpp format in ci
Diffstat (limited to 'tools/gfx/d3d12')
-rw-r--r--tools/gfx/d3d12/d3d12-base.h73
-rw-r--r--tools/gfx/d3d12/d3d12-buffer.cpp12
-rw-r--r--tools/gfx/d3d12/d3d12-buffer.h7
-rw-r--r--tools/gfx/d3d12/d3d12-command-buffer.cpp13
-rw-r--r--tools/gfx/d3d12/d3d12-command-buffer.h27
-rw-r--r--tools/gfx/d3d12/d3d12-command-encoder.cpp418
-rw-r--r--tools/gfx/d3d12/d3d12-command-encoder.h73
-rw-r--r--tools/gfx/d3d12/d3d12-command-queue.cpp19
-rw-r--r--tools/gfx/d3d12/d3d12-command-queue.h10
-rw-r--r--tools/gfx/d3d12/d3d12-descriptor-heap.cpp26
-rw-r--r--tools/gfx/d3d12/d3d12-descriptor-heap.h182
-rw-r--r--tools/gfx/d3d12/d3d12-device.cpp772
-rw-r--r--tools/gfx/d3d12/d3d12-device.h74
-rw-r--r--tools/gfx/d3d12/d3d12-fence.cpp6
-rw-r--r--tools/gfx/d3d12/d3d12-fence.h2
-rw-r--r--tools/gfx/d3d12/d3d12-helper-functions.cpp390
-rw-r--r--tools/gfx/d3d12/d3d12-helper-functions.h14
-rw-r--r--tools/gfx/d3d12/d3d12-pipeline-state-stream.h432
-rw-r--r--tools/gfx/d3d12/d3d12-pipeline-state.cpp129
-rw-r--r--tools/gfx/d3d12/d3d12-pipeline-state.h3
-rw-r--r--tools/gfx/d3d12/d3d12-posix-synchapi.cpp136
-rw-r--r--tools/gfx/d3d12/d3d12-posix-synchapi.h24
-rw-r--r--tools/gfx/d3d12/d3d12-query.cpp18
-rw-r--r--tools/gfx/d3d12/d3d12-query.h8
-rw-r--r--tools/gfx/d3d12/d3d12-resource-views.cpp177
-rw-r--r--tools/gfx/d3d12/d3d12-resource-views.h10
-rw-r--r--tools/gfx/d3d12/d3d12-resource.cpp123
-rw-r--r--tools/gfx/d3d12/d3d12-resource.h176
-rw-r--r--tools/gfx/d3d12/d3d12-sal-defs.h128
-rw-r--r--tools/gfx/d3d12/d3d12-sampler.cpp5
-rw-r--r--tools/gfx/d3d12/d3d12-shader-object-layout.cpp288
-rw-r--r--tools/gfx/d3d12/d3d12-shader-object-layout.h30
-rw-r--r--tools/gfx/d3d12/d3d12-shader-object.cpp226
-rw-r--r--tools/gfx/d3d12/d3d12-shader-object.h29
-rw-r--r--tools/gfx/d3d12/d3d12-shader-program.cpp3
-rw-r--r--tools/gfx/d3d12/d3d12-shader-program.h3
-rw-r--r--tools/gfx/d3d12/d3d12-shader-table.cpp10
-rw-r--r--tools/gfx/d3d12/d3d12-submitter.cpp22
-rw-r--r--tools/gfx/d3d12/d3d12-submitter.h25
-rw-r--r--tools/gfx/d3d12/d3d12-swap-chain.cpp16
-rw-r--r--tools/gfx/d3d12/d3d12-texture.cpp12
-rw-r--r--tools/gfx/d3d12/d3d12-texture.h2
-rw-r--r--tools/gfx/d3d12/d3d12-transient-heap.cpp10
-rw-r--r--tools/gfx/d3d12/d3d12-transient-heap.h10
44 files changed, 2348 insertions, 1825 deletions
diff --git a/tools/gfx/d3d12/d3d12-base.h b/tools/gfx/d3d12/d3d12-base.h
index 0e648f9c4..e67a7226c 100644
--- a/tools/gfx/d3d12/d3d12-base.h
+++ b/tools/gfx/d3d12/d3d12-base.h
@@ -12,8 +12,8 @@
#include "core/slang-blob.h"
#include "core/slang-chunked-list.h"
#include "d3d12-descriptor-heap.h"
-#include "d3d12-resource.h"
#include "d3d12-posix-synchapi.h"
+#include "d3d12-resource.h"
#pragma push_macro("WIN32_LEAN_AND_MEAN")
#pragma push_macro("NOMINMAX")
@@ -35,47 +35,48 @@
#ifndef __ID3D12GraphicsCommandList1_FWD_DEFINED__
// If can't find a definition of CommandList1, just use an empty definition
struct ID3D12GraphicsCommandList1
-{};
+{
+};
#endif
namespace gfx
{
namespace d3d12
{
- class DeviceImpl;
- class BufferResourceImpl;
- class TextureResourceImpl;
- class CommandBufferImpl;
- class PipelineCommandEncoder;
- class ResourceCommandEncoderImpl;
- class ComputeCommandEncoderImpl;
- class RenderCommandEncoderImpl;
- class CommandQueueImpl;
- class FenceImpl;
- class FramebufferLayoutImpl;
- class FramebufferImpl;
- class QueryPoolImpl;
- class PlainBufferProxyQueryPoolImpl;
- class PipelineStateImpl;
- class RenderPassLayoutImpl;
- class ResourceViewInternalImpl;
- class ResourceViewImpl;
- class AccelerationStructureImpl;
- class SamplerStateImpl;
- class ShaderObjectImpl;
- class RootShaderObjectImpl;
- class MutableRootShaderObjectImpl;
- class ShaderObjectLayoutImpl;
- class RootShaderObjectLayoutImpl;
- class ShaderProgramImpl;
- class ShaderTableImpl;
- class SwapChainImpl;
- class TransientResourceHeapImpl;
- class InputLayoutImpl;
+class DeviceImpl;
+class BufferResourceImpl;
+class TextureResourceImpl;
+class CommandBufferImpl;
+class PipelineCommandEncoder;
+class ResourceCommandEncoderImpl;
+class ComputeCommandEncoderImpl;
+class RenderCommandEncoderImpl;
+class CommandQueueImpl;
+class FenceImpl;
+class FramebufferLayoutImpl;
+class FramebufferImpl;
+class QueryPoolImpl;
+class PlainBufferProxyQueryPoolImpl;
+class PipelineStateImpl;
+class RenderPassLayoutImpl;
+class ResourceViewInternalImpl;
+class ResourceViewImpl;
+class AccelerationStructureImpl;
+class SamplerStateImpl;
+class ShaderObjectImpl;
+class RootShaderObjectImpl;
+class MutableRootShaderObjectImpl;
+class ShaderObjectLayoutImpl;
+class RootShaderObjectLayoutImpl;
+class ShaderProgramImpl;
+class ShaderTableImpl;
+class SwapChainImpl;
+class TransientResourceHeapImpl;
+class InputLayoutImpl;
#if SLANG_GFX_HAS_DXR_SUPPORT
- class RayTracingCommandEncoderImpl;
- class RayTracingPipelineStateImpl;
+class RayTracingCommandEncoderImpl;
+class RayTracingPipelineStateImpl;
#endif
-}
-}
+} // namespace d3d12
+} // namespace gfx
diff --git a/tools/gfx/d3d12/d3d12-buffer.cpp b/tools/gfx/d3d12/d3d12-buffer.cpp
index 7d3376607..ee078bb3d 100644
--- a/tools/gfx/d3d12/d3d12-buffer.cpp
+++ b/tools/gfx/d3d12/d3d12-buffer.cpp
@@ -9,9 +9,9 @@ namespace d3d12
using namespace Slang;
BufferResourceImpl::BufferResourceImpl(const Desc& desc)
- : Parent(desc)
- , m_defaultState(D3DUtil::getResourceState(desc.defaultState))
-{}
+ : Parent(desc), m_defaultState(D3DUtil::getResourceState(desc.defaultState))
+{
+}
BufferResourceImpl::~BufferResourceImpl()
{
@@ -50,7 +50,11 @@ Result BufferResourceImpl::getSharedHandle(InteropHandle* outHandle)
auto pResource = m_resource.getResource();
pResource->GetDevice(IID_PPV_ARGS(pDevice.writeRef()));
SLANG_RETURN_ON_FAIL(pDevice->CreateSharedHandle(
- pResource, NULL, GENERIC_ALL, nullptr, (HANDLE*)&outHandle->handleValue));
+ pResource,
+ NULL,
+ GENERIC_ALL,
+ nullptr,
+ (HANDLE*)&outHandle->handleValue));
outHandle->api = InteropHandleAPI::D3D12;
sharedHandle = *outHandle;
return SLANG_OK;
diff --git a/tools/gfx/d3d12/d3d12-buffer.h b/tools/gfx/d3d12/d3d12-buffer.h
index 272969b07..b58426af6 100644
--- a/tools/gfx/d3d12/d3d12-buffer.h
+++ b/tools/gfx/d3d12/d3d12-buffer.h
@@ -20,19 +20,19 @@ public:
~BufferResourceImpl();
D3D12Resource m_resource; ///< The resource in gpu memory, allocated on the correct heap
- ///< relative to the cpu access flag
+ ///< relative to the cpu access flag
D3D12_RESOURCE_STATES m_defaultState;
virtual SLANG_NO_THROW DeviceAddress SLANG_MCALL getDeviceAddress() override;
virtual SLANG_NO_THROW Result SLANG_MCALL
- getNativeResourceHandle(InteropHandle* outHandle) override;
+ getNativeResourceHandle(InteropHandle* outHandle) override;
virtual SLANG_NO_THROW Result SLANG_MCALL getSharedHandle(InteropHandle* outHandle) override;
virtual SLANG_NO_THROW Result SLANG_MCALL
- map(MemoryRange* rangeToRead, void** outPointer) override;
+ map(MemoryRange* rangeToRead, void** outPointer) override;
virtual SLANG_NO_THROW Result SLANG_MCALL unmap(MemoryRange* writtenRange) override;
@@ -41,4 +41,3 @@ public:
} // namespace d3d12
} // namespace gfx
-
diff --git a/tools/gfx/d3d12/d3d12-command-buffer.cpp b/tools/gfx/d3d12/d3d12-command-buffer.cpp
index fb979d3b9..641234a63 100644
--- a/tools/gfx/d3d12/d3d12-command-buffer.cpp
+++ b/tools/gfx/d3d12/d3d12-command-buffer.cpp
@@ -60,7 +60,7 @@ void CommandBufferImpl::init(
reinit();
m_cmdList->QueryInterface<ID3D12GraphicsCommandList6>(m_cmdList6.writeRef());
-if (m_cmdList6)
+ if (m_cmdList6)
{
m_cmdList4 = m_cmdList6;
m_cmdList1 = m_cmdList6;
@@ -84,7 +84,9 @@ void CommandBufferImpl::encodeResourceCommands(IResourceCommandEncoder** outEnco
}
void CommandBufferImpl::encodeRenderCommands(
- IRenderPassLayout* renderPass, IFramebuffer* framebuffer, IRenderCommandEncoder** outEncoder)
+ IRenderPassLayout* renderPass,
+ IFramebuffer* framebuffer,
+ IRenderCommandEncoder** outEncoder)
{
m_renderCommandEncoder.init(
m_renderer,
@@ -107,11 +109,14 @@ void CommandBufferImpl::encodeRayTracingCommands(IRayTracingCommandEncoder** out
m_rayTracingCommandEncoder.init(this);
*outEncoder = &m_rayTracingCommandEncoder;
#else
- * outEncoder = nullptr;
+ *outEncoder = nullptr;
#endif
}
-void CommandBufferImpl::close() { m_cmdList->Close(); }
+void CommandBufferImpl::close()
+{
+ m_cmdList->Close();
+}
} // namespace d3d12
} // namespace gfx
diff --git a/tools/gfx/d3d12/d3d12-command-buffer.h b/tools/gfx/d3d12/d3d12-command-buffer.h
index 1cc6e8850..192be9e2b 100644
--- a/tools/gfx/d3d12/d3d12-command-buffer.h
+++ b/tools/gfx/d3d12/d3d12-command-buffer.h
@@ -2,13 +2,14 @@
#pragma once
#include "d3d12-base.h"
-#include "d3d12-shader-object.h"
#include "d3d12-command-encoder.h"
+#include "d3d12-shader-object.h"
#ifndef __ID3D12GraphicsCommandList1_FWD_DEFINED__
// If can't find a definition of CommandList1, just use an empty definition
struct ID3D12GraphicsCommandList1
-{};
+{
+};
#endif
namespace gfx
@@ -18,9 +19,7 @@ namespace d3d12
using namespace Slang;
-class CommandBufferImpl
- : public ICommandBufferD3D12
- , public ComObject
+class CommandBufferImpl : public ICommandBufferD3D12, public ComObject
{
public:
// There are a pair of cyclic references between a `TransientResourceHeap` and
@@ -28,7 +27,7 @@ public:
// the public reference count of a command buffer dropping to 0.
SLANG_COM_OBJECT_IUNKNOWN_ALL
- ICommandBufferD3D12* getInterface(const Guid& guid);
+ ICommandBufferD3D12* getInterface(const Guid& guid);
virtual void comFree() override { m_transientHeap.breakStrongReference(); }
virtual SLANG_NO_THROW Result SLANG_MCALL getNativeHandle(InteropHandle* handle) override;
@@ -49,8 +48,14 @@ public:
void bindDescriptorHeaps();
- virtual SLANG_NO_THROW void SLANG_MCALL invalidateDescriptorHeapBinding() override { m_descriptorHeapsBound = false; }
- virtual SLANG_NO_THROW void SLANG_MCALL ensureInternalDescriptorHeapsBound() override { bindDescriptorHeaps(); }
+ virtual SLANG_NO_THROW void SLANG_MCALL invalidateDescriptorHeapBinding() override
+ {
+ m_descriptorHeapsBound = false;
+ }
+ virtual SLANG_NO_THROW void SLANG_MCALL ensureInternalDescriptorHeapsBound() override
+ {
+ bindDescriptorHeaps();
+ }
void reinit();
@@ -62,7 +67,7 @@ public:
ResourceCommandEncoderImpl m_resourceCommandEncoder;
virtual SLANG_NO_THROW void SLANG_MCALL
- encodeResourceCommands(IResourceCommandEncoder** outEncoder) override;
+ encodeResourceCommands(IResourceCommandEncoder** outEncoder) override;
RenderCommandEncoderImpl m_renderCommandEncoder;
virtual SLANG_NO_THROW void SLANG_MCALL encodeRenderCommands(
@@ -72,13 +77,13 @@ public:
ComputeCommandEncoderImpl m_computeCommandEncoder;
virtual SLANG_NO_THROW void SLANG_MCALL
- encodeComputeCommands(IComputeCommandEncoder** outEncoder) override;
+ encodeComputeCommands(IComputeCommandEncoder** outEncoder) override;
#if SLANG_GFX_HAS_DXR_SUPPORT
RayTracingCommandEncoderImpl m_rayTracingCommandEncoder;
#endif
virtual SLANG_NO_THROW void SLANG_MCALL
- encodeRayTracingCommands(IRayTracingCommandEncoder** outEncoder) override;
+ encodeRayTracingCommands(IRayTracingCommandEncoder** outEncoder) override;
virtual SLANG_NO_THROW void SLANG_MCALL close() override;
};
diff --git a/tools/gfx/d3d12/d3d12-command-encoder.cpp b/tools/gfx/d3d12/d3d12-command-encoder.cpp
index 892c792fb..f0b4b0dfc 100644
--- a/tools/gfx/d3d12/d3d12-command-encoder.cpp
+++ b/tools/gfx/d3d12/d3d12-command-encoder.cpp
@@ -3,17 +3,16 @@
#include "d3d12-command-buffer.h"
#include "d3d12-device.h"
+#include "d3d12-helper-functions.h"
#include "d3d12-pipeline-state.h"
#include "d3d12-query.h"
#include "d3d12-shader-object.h"
#include "d3d12-shader-program.h"
#include "d3d12-shader-table.h"
-#include "d3d12-transient-heap.h"
#include "d3d12-texture.h"
+#include "d3d12-transient-heap.h"
#include "d3d12-vertex-layout.h"
-#include "d3d12-helper-functions.h"
-
namespace gfx
{
namespace d3d12
@@ -25,15 +24,10 @@ int PipelineCommandEncoder::getBindPointIndex(PipelineType type)
{
switch (type)
{
- case PipelineType::Graphics:
- return 0;
- case PipelineType::Compute:
- return 1;
- case PipelineType::RayTracing:
- return 2;
- default:
- assert(!"unknown pipeline type.");
- return -1;
+ case PipelineType::Graphics: return 0;
+ case PipelineType::Compute: return 1;
+ case PipelineType::RayTracing: return 2;
+ default: assert(!"unknown pipeline type."); return -1;
}
}
@@ -48,7 +42,8 @@ void PipelineCommandEncoder::init(CommandBufferImpl* commandBuffer)
}
Result PipelineCommandEncoder::bindPipelineImpl(
- IPipelineState* pipelineState, IShaderObject** outRootObject)
+ IPipelineState* pipelineState,
+ IShaderObject** outRootObject)
{
m_currentPipeline = static_cast<PipelineStateBase*>(pipelineState);
auto rootObject = &m_commandBuffer->m_rootShaderObject;
@@ -63,7 +58,8 @@ Result PipelineCommandEncoder::bindPipelineImpl(
}
Result PipelineCommandEncoder::bindPipelineWithRootObjectImpl(
- IPipelineState* pipelineState, IShaderObject* rootObject)
+ IPipelineState* pipelineState,
+ IShaderObject* rootObject)
{
m_currentPipeline = static_cast<PipelineStateBase*>(pipelineState);
m_commandBuffer->m_mutableRootShaderObject =
@@ -73,11 +69,12 @@ Result PipelineCommandEncoder::bindPipelineWithRootObjectImpl(
}
Result PipelineCommandEncoder::_bindRenderState(
- Submitter* submitter, RefPtr<PipelineStateBase>& newPipeline)
+ Submitter* submitter,
+ RefPtr<PipelineStateBase>& newPipeline)
{
RootShaderObjectImpl* rootObjectImpl = m_commandBuffer->m_mutableRootShaderObject
- ? m_commandBuffer->m_mutableRootShaderObject.Ptr()
- : &m_commandBuffer->m_rootShaderObject;
+ ? m_commandBuffer->m_mutableRootShaderObject.Ptr()
+ : &m_commandBuffer->m_rootShaderObject;
SLANG_RETURN_ON_FAIL(
m_renderer->maybeSpecializePipeline(m_currentPipeline, rootObjectImpl, newPipeline));
PipelineStateBase* newPipelineImpl = static_cast<PipelineStateBase*>(newPipeline.Ptr());
@@ -127,9 +124,7 @@ Result PipelineCommandEncoder::_bindRenderState(
d3dheap = m_transientHeap->getCurrentSamplerHeap().getHeap();
m_commandBuffer->bindDescriptorHeaps();
break;
- default:
- assert(!"shouldn't be here");
- return SLANG_FAIL;
+ default: assert(!"shouldn't be here"); return SLANG_FAIL;
}
// Try again.
@@ -140,7 +135,10 @@ Result PipelineCommandEncoder::_bindRenderState(
}
void ResourceCommandEncoderImpl::bufferBarrier(
- GfxCount count, IBufferResource* const* buffers, ResourceState src, ResourceState dst)
+ GfxCount count,
+ IBufferResource* const* buffers,
+ ResourceState src,
+ ResourceState dst)
{
ShortList<D3D12_RESOURCE_BARRIER, 16> barriers;
for (GfxIndex i = 0; i < count; i++)
@@ -150,8 +148,8 @@ void ResourceCommandEncoderImpl::bufferBarrier(
D3D12_RESOURCE_BARRIER barrier = {};
// If the src == dst, it must be a UAV barrier.
barrier.Type = (src == dst && dst == ResourceState::UnorderedAccess)
- ? D3D12_RESOURCE_BARRIER_TYPE_UAV
- : D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
+ ? D3D12_RESOURCE_BARRIER_TYPE_UAV
+ : D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
barrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
if (barrier.Type == D3D12_RESOURCE_BARRIER_TYPE_UAV)
@@ -172,7 +170,8 @@ void ResourceCommandEncoderImpl::bufferBarrier(
if (barriers.getCount())
{
m_commandBuffer->m_cmdList4->ResourceBarrier(
- (UINT)barriers.getCount(), barriers.getArrayView().getBuffer());
+ (UINT)barriers.getCount(),
+ barriers.getArrayView().getBuffer());
}
}
@@ -199,7 +198,8 @@ void ResourceCommandEncoderImpl::copyTexture(
srcSubresource.layerCount == 0 && srcSubresource.mipLevelCount == 0)
{
m_commandBuffer->m_cmdList->CopyResource(
- dstTexture->m_resource.getResource(), srcTexture->m_resource.getResource());
+ dstTexture->m_resource.getResource(),
+ srcTexture->m_resource.getResource());
return;
}
@@ -246,7 +246,12 @@ void ResourceCommandEncoderImpl::copyTexture(
srcBox.back = srcBox.front + extent.depth;
m_commandBuffer->m_cmdList->CopyTextureRegion(
- &dstRegion, dstOffset.x, dstOffset.y, dstOffset.z, &srcRegion, &srcBox);
+ &dstRegion,
+ dstOffset.x,
+ dstOffset.y,
+ dstOffset.z,
+ &srcRegion,
+ &srcBox);
}
}
}
@@ -314,7 +319,7 @@ void ResourceCommandEncoderImpl::uploadTextureData(
footprint.Footprint.Depth = Math::Max(1, (textureSize.depth >> mipLevel)) - offset.z;
}
auto rowSize = (footprint.Footprint.Width + formatInfo.blockWidth - 1) /
- formatInfo.blockWidth * formatInfo.blockSizeInBytes;
+ formatInfo.blockWidth * formatInfo.blockSizeInBytes;
auto rowCount =
(footprint.Footprint.Height + formatInfo.blockHeight - 1) / formatInfo.blockHeight;
footprint.Footprint.RowPitch =
@@ -325,11 +330,15 @@ void ResourceCommandEncoderImpl::uploadTextureData(
IBufferResource* stagingBuffer;
Offset stagingBufferOffset = 0;
m_commandBuffer->m_transientHeap->allocateStagingBuffer(
- bufferSize, stagingBuffer, stagingBufferOffset, MemoryType::Upload, true);
+ bufferSize,
+ stagingBuffer,
+ stagingBufferOffset,
+ MemoryType::Upload,
+ true);
assert(stagingBufferOffset == 0);
BufferResourceImpl* bufferImpl = static_cast<BufferResourceImpl*>(stagingBuffer);
uint8_t* bufferData = nullptr;
- D3D12_RANGE mapRange = { 0, 0 };
+ D3D12_RANGE mapRange = {0, 0};
bufferImpl->m_resource.getResource()->Map(0, &mapRange, (void**)&bufferData);
for (uint32_t z = 0; z < footprint.Footprint.Depth; z++)
{
@@ -345,13 +354,15 @@ void ResourceCommandEncoderImpl::uploadTextureData(
}
bufferImpl->m_resource.getResource()->Unmap(0, nullptr);
srcRegion.pResource = bufferImpl->m_resource.getResource();
- m_commandBuffer->m_cmdList->CopyTextureRegion(
- &dstRegion, offset.x, offset.y, offset.z, &srcRegion, nullptr);
+ m_commandBuffer->m_cmdList
+ ->CopyTextureRegion(&dstRegion, offset.x, offset.y, offset.z, &srcRegion, nullptr);
}
}
void ResourceCommandEncoderImpl::clearResourceView(
- IResourceView* view, ClearValue* clearValue, ClearResourceViewFlags::Enum flags)
+ IResourceView* view,
+ ClearValue* clearValue,
+ ClearResourceViewFlags::Enum flags)
{
auto viewImpl = static_cast<ResourceViewImpl*>(view);
m_commandBuffer->bindDescriptorHeaps();
@@ -359,86 +370,93 @@ void ResourceCommandEncoderImpl::clearResourceView(
{
case IResourceView::Type::RenderTarget:
m_commandBuffer->m_cmdList->ClearRenderTargetView(
- viewImpl->m_descriptor.cpuHandle, clearValue->color.floatValues, 0, nullptr);
- break;
- case IResourceView::Type::DepthStencil:
- {
- D3D12_CLEAR_FLAGS clearFlags = (D3D12_CLEAR_FLAGS)0;
- if (flags & ClearResourceViewFlags::ClearDepth)
- {
- clearFlags |= D3D12_CLEAR_FLAG_DEPTH;
- }
- if (flags & ClearResourceViewFlags::ClearStencil)
- {
- clearFlags |= D3D12_CLEAR_FLAG_STENCIL;
- }
- m_commandBuffer->m_cmdList->ClearDepthStencilView(
viewImpl->m_descriptor.cpuHandle,
- clearFlags,
- clearValue->depthStencil.depth,
- (UINT8)clearValue->depthStencil.stencil,
+ clearValue->color.floatValues,
0,
nullptr);
break;
- }
- case IResourceView::Type::UnorderedAccess:
- {
- ID3D12Resource* d3dResource = nullptr;
- D3D12Descriptor descriptor = viewImpl->m_descriptor;
- switch (viewImpl->m_resource->getType())
- {
- case IResource::Type::Buffer:
- d3dResource = static_cast<BufferResourceImpl*>(viewImpl->m_resource.Ptr())
- ->m_resource.getResource();
- // D3D12 requires a UAV descriptor with zero buffer stride for calling ClearUnorderedAccessViewUint/Float.
- viewImpl->getBufferDescriptorForBinding(m_commandBuffer->m_renderer, viewImpl, 0, descriptor);
- break;
- default:
- d3dResource = static_cast<TextureResourceImpl*>(viewImpl->m_resource.Ptr())
- ->m_resource.getResource();
- break;
- }
- auto gpuHandleIndex =
- m_commandBuffer->m_transientHeap->getCurrentViewHeap().allocate(1);
- if (gpuHandleIndex == -1)
- {
- m_commandBuffer->m_transientHeap->allocateNewViewDescriptorHeap(
- m_commandBuffer->m_renderer);
- gpuHandleIndex = m_commandBuffer->m_transientHeap->getCurrentViewHeap().allocate(1);
- m_commandBuffer->bindDescriptorHeaps();
- }
- this->m_commandBuffer->m_renderer->m_device->CopyDescriptorsSimple(
- 1,
- m_commandBuffer->m_transientHeap->getCurrentViewHeap().getCpuHandle(gpuHandleIndex),
- descriptor.cpuHandle,
- D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
-
- if (flags & ClearResourceViewFlags::FloatClearValues)
+ case IResourceView::Type::DepthStencil:
{
- m_commandBuffer->m_cmdList->ClearUnorderedAccessViewFloat(
- m_commandBuffer->m_transientHeap->getCurrentViewHeap().getGpuHandle(
- gpuHandleIndex),
- descriptor.cpuHandle,
- d3dResource,
- clearValue->color.floatValues,
+ D3D12_CLEAR_FLAGS clearFlags = (D3D12_CLEAR_FLAGS)0;
+ if (flags & ClearResourceViewFlags::ClearDepth)
+ {
+ clearFlags |= D3D12_CLEAR_FLAG_DEPTH;
+ }
+ if (flags & ClearResourceViewFlags::ClearStencil)
+ {
+ clearFlags |= D3D12_CLEAR_FLAG_STENCIL;
+ }
+ m_commandBuffer->m_cmdList->ClearDepthStencilView(
+ viewImpl->m_descriptor.cpuHandle,
+ clearFlags,
+ clearValue->depthStencil.depth,
+ (UINT8)clearValue->depthStencil.stencil,
0,
nullptr);
+ break;
}
- else
+ case IResourceView::Type::UnorderedAccess:
{
- m_commandBuffer->m_cmdList->ClearUnorderedAccessViewUint(
- m_commandBuffer->m_transientHeap->getCurrentViewHeap().getGpuHandle(
- gpuHandleIndex),
+ ID3D12Resource* d3dResource = nullptr;
+ D3D12Descriptor descriptor = viewImpl->m_descriptor;
+ switch (viewImpl->m_resource->getType())
+ {
+ case IResource::Type::Buffer:
+ d3dResource = static_cast<BufferResourceImpl*>(viewImpl->m_resource.Ptr())
+ ->m_resource.getResource();
+ // D3D12 requires a UAV descriptor with zero buffer stride for calling
+ // ClearUnorderedAccessViewUint/Float.
+ viewImpl->getBufferDescriptorForBinding(
+ m_commandBuffer->m_renderer,
+ viewImpl,
+ 0,
+ descriptor);
+ break;
+ default:
+ d3dResource = static_cast<TextureResourceImpl*>(viewImpl->m_resource.Ptr())
+ ->m_resource.getResource();
+ break;
+ }
+ auto gpuHandleIndex =
+ m_commandBuffer->m_transientHeap->getCurrentViewHeap().allocate(1);
+ if (gpuHandleIndex == -1)
+ {
+ m_commandBuffer->m_transientHeap->allocateNewViewDescriptorHeap(
+ m_commandBuffer->m_renderer);
+ gpuHandleIndex = m_commandBuffer->m_transientHeap->getCurrentViewHeap().allocate(1);
+ m_commandBuffer->bindDescriptorHeaps();
+ }
+ this->m_commandBuffer->m_renderer->m_device->CopyDescriptorsSimple(
+ 1,
+ m_commandBuffer->m_transientHeap->getCurrentViewHeap().getCpuHandle(gpuHandleIndex),
descriptor.cpuHandle,
- d3dResource,
- clearValue->color.uintValues,
- 0,
- nullptr);
+ D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
+
+ if (flags & ClearResourceViewFlags::FloatClearValues)
+ {
+ m_commandBuffer->m_cmdList->ClearUnorderedAccessViewFloat(
+ m_commandBuffer->m_transientHeap->getCurrentViewHeap().getGpuHandle(
+ gpuHandleIndex),
+ descriptor.cpuHandle,
+ d3dResource,
+ clearValue->color.floatValues,
+ 0,
+ nullptr);
+ }
+ else
+ {
+ m_commandBuffer->m_cmdList->ClearUnorderedAccessViewUint(
+ m_commandBuffer->m_transientHeap->getCurrentViewHeap().getGpuHandle(
+ gpuHandleIndex),
+ descriptor.cpuHandle,
+ d3dResource,
+ clearValue->color.uintValues,
+ 0,
+ nullptr);
+ }
+ break;
}
- break;
- }
- default:
- break;
+ default: break;
}
}
@@ -485,7 +503,11 @@ void ResourceCommandEncoderImpl::resolveResource(
}
void ResourceCommandEncoderImpl::resolveQuery(
- IQueryPool* queryPool, GfxIndex index, GfxCount count, IBufferResource* buffer, Offset offset)
+ IQueryPool* queryPool,
+ GfxIndex index,
+ GfxCount count,
+ IBufferResource* buffer,
+ Offset offset)
{
auto queryBase = static_cast<QueryPoolBase*>(queryPool);
switch (queryBase->m_desc.type)
@@ -493,45 +515,45 @@ void ResourceCommandEncoderImpl::resolveQuery(
case QueryType::AccelerationStructureCompactedSize:
case QueryType::AccelerationStructureCurrentSize:
case QueryType::AccelerationStructureSerializedSize:
- {
- auto queryPoolImpl = static_cast<PlainBufferProxyQueryPoolImpl*>(queryPool);
- auto bufferImpl = static_cast<BufferResourceImpl*>(buffer);
- auto srcQueryBuffer = queryPoolImpl->m_bufferResource->m_resource.getResource();
+ {
+ auto queryPoolImpl = static_cast<PlainBufferProxyQueryPoolImpl*>(queryPool);
+ auto bufferImpl = static_cast<BufferResourceImpl*>(buffer);
+ auto srcQueryBuffer = queryPoolImpl->m_bufferResource->m_resource.getResource();
- D3D12_RESOURCE_BARRIER barrier = {};
- barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
- barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
- barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_COPY_SOURCE;
- barrier.Transition.pResource = srcQueryBuffer;
- m_commandBuffer->m_cmdList->ResourceBarrier(1, &barrier);
-
- m_commandBuffer->m_cmdList->CopyBufferRegion(
- bufferImpl->m_resource.getResource(),
- (uint64_t)offset,
- srcQueryBuffer,
- index * sizeof(uint64_t),
- count * sizeof(uint64_t));
+ D3D12_RESOURCE_BARRIER barrier = {};
+ barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
+ barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
+ barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_COPY_SOURCE;
+ barrier.Transition.pResource = srcQueryBuffer;
+ m_commandBuffer->m_cmdList->ResourceBarrier(1, &barrier);
+
+ m_commandBuffer->m_cmdList->CopyBufferRegion(
+ bufferImpl->m_resource.getResource(),
+ (uint64_t)offset,
+ srcQueryBuffer,
+ index * sizeof(uint64_t),
+ count * sizeof(uint64_t));
- barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
- barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_COPY_SOURCE;
- barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
- barrier.Transition.pResource = srcQueryBuffer;
- m_commandBuffer->m_cmdList->ResourceBarrier(1, &barrier);
- }
- break;
+ barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
+ barrier.Transition.StateBefore = D3D12_RESOURCE_STATE_COPY_SOURCE;
+ barrier.Transition.StateAfter = D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
+ barrier.Transition.pResource = srcQueryBuffer;
+ m_commandBuffer->m_cmdList->ResourceBarrier(1, &barrier);
+ }
+ break;
default:
- {
- auto queryPoolImpl = static_cast<QueryPoolImpl*>(queryPool);
- auto bufferImpl = static_cast<BufferResourceImpl*>(buffer);
- m_commandBuffer->m_cmdList->ResolveQueryData(
- queryPoolImpl->m_queryHeap.get(),
- queryPoolImpl->m_queryType,
- index,
- count,
- bufferImpl->m_resource.getResource(),
- offset);
- }
- break;
+ {
+ auto queryPoolImpl = static_cast<QueryPoolImpl*>(queryPool);
+ auto bufferImpl = static_cast<BufferResourceImpl*>(buffer);
+ m_commandBuffer->m_cmdList->ResolveQueryData(
+ queryPoolImpl->m_queryHeap.get(),
+ queryPoolImpl->m_queryType,
+ index,
+ count,
+ bufferImpl->m_resource.getResource(),
+ offset);
+ }
+ break;
}
}
@@ -680,7 +702,8 @@ void ResourceCommandEncoderImpl::textureSubresourceBarrier(
}
}
m_commandBuffer->m_cmdList->ResourceBarrier(
- (UINT)barriers.getCount(), barriers.getArrayView().getBuffer());
+ (UINT)barriers.getCount(),
+ barriers.getArrayView().getBuffer());
}
void ResourceCommandEncoderImpl::beginDebugEvent(const char* name, float rgbColor[3])
@@ -691,7 +714,7 @@ void ResourceCommandEncoderImpl::beginDebugEvent(const char* name, float rgbColo
beginEvent(
m_commandBuffer->m_cmdList,
0xff000000 | (uint8_t(rgbColor[0] * 255.0f) << 16) |
- (uint8_t(rgbColor[1] * 255.0f) << 8) | uint8_t(rgbColor[2] * 255.0f),
+ (uint8_t(rgbColor[1] * 255.0f) << 8) | uint8_t(rgbColor[2] * 255.0f),
name);
}
}
@@ -706,7 +729,11 @@ void ResourceCommandEncoderImpl::endDebugEvent()
}
void ResourceCommandEncoderImpl::copyBuffer(
- IBufferResource* dst, Offset dstOffset, IBufferResource* src, Offset srcOffset, Size size)
+ IBufferResource* dst,
+ Offset dstOffset,
+ IBufferResource* src,
+ Offset srcOffset,
+ Size size)
{
auto dstBuffer = static_cast<BufferResourceImpl*>(dst);
auto srcBuffer = static_cast<BufferResourceImpl*>(src);
@@ -720,7 +747,10 @@ void ResourceCommandEncoderImpl::copyBuffer(
}
void ResourceCommandEncoderImpl::uploadBufferData(
- IBufferResource* dst, Offset offset, Size size, void* data)
+ IBufferResource* dst,
+ Offset offset,
+ Size size,
+ void* data)
{
uploadBufferDataImpl(
m_commandBuffer->m_renderer->m_device,
@@ -733,7 +763,10 @@ void ResourceCommandEncoderImpl::uploadBufferData(
}
void ResourceCommandEncoderImpl::textureBarrier(
- GfxCount count, ITextureResource* const* textures, ResourceState src, ResourceState dst)
+ GfxCount count,
+ ITextureResource* const* textures,
+ ResourceState src,
+ ResourceState dst)
{
ShortList<D3D12_RESOURCE_BARRIER> barriers;
@@ -769,7 +802,8 @@ void ResourceCommandEncoderImpl::textureBarrier(
if (barriers.getCount())
{
m_commandBuffer->m_cmdList->ResourceBarrier(
- (UINT)barriers.getCount(), barriers.getArrayView().getBuffer());
+ (UINT)barriers.getCount(),
+ barriers.getArrayView().getBuffer());
}
}
@@ -832,7 +866,9 @@ void RenderCommandEncoderImpl::init(
initialState = D3DUtil::getResourceState(access.initialState);
}
textureResource->m_resource.transition(
- initialState, D3D12_RESOURCE_STATE_RENDER_TARGET, submitter);
+ initialState,
+ D3D12_RESOURCE_STATE_RENDER_TARGET,
+ submitter);
}
}
}
@@ -866,7 +902,9 @@ void RenderCommandEncoderImpl::init(
D3DUtil::getResourceState(renderPass->m_depthStencilAccess.initialState);
}
textureResource->m_resource.transition(
- initialState, D3D12_RESOURCE_STATE_DEPTH_WRITE, submitter);
+ initialState,
+ D3D12_RESOURCE_STATE_DEPTH_WRITE,
+ submitter);
}
// Clear.
uint32_t clearFlags = 0;
@@ -898,7 +936,8 @@ Result RenderCommandEncoderImpl::bindPipeline(IPipelineState* state, IShaderObje
}
Result RenderCommandEncoderImpl::bindPipelineWithRootObject(
- IPipelineState* state, IShaderObject* rootObject)
+ IPipelineState* state,
+ IShaderObject* rootObject)
{
return bindPipelineWithRootObjectImpl(state, rootObject);
}
@@ -972,7 +1011,9 @@ void RenderCommandEncoderImpl::setVertexBuffers(
}
void RenderCommandEncoderImpl::setIndexBuffer(
- IBufferResource* buffer, Format indexFormat, Offset offset)
+ IBufferResource* buffer,
+ Format indexFormat,
+ Offset offset)
{
m_boundIndexBuffer = (BufferResourceImpl*)buffer;
m_boundIndexFormat = D3DUtil::getMapFormat(indexFormat);
@@ -1045,10 +1086,17 @@ Result RenderCommandEncoderImpl::draw(GfxCount vertexCount, GfxIndex startVertex
}
Result RenderCommandEncoderImpl::drawIndexed(
- GfxCount indexCount, GfxIndex startIndex, GfxIndex baseVertex)
+ GfxCount indexCount,
+ GfxIndex startIndex,
+ GfxIndex baseVertex)
{
SLANG_RETURN_ON_FAIL(prepareDraw());
- m_d3dCmdList->DrawIndexedInstanced((uint32_t)indexCount, 1, (uint32_t)startIndex, (uint32_t)baseVertex, 0);
+ m_d3dCmdList->DrawIndexedInstanced(
+ (uint32_t)indexCount,
+ 1,
+ (uint32_t)startIndex,
+ (uint32_t)baseVertex,
+ 0);
return SLANG_OK;
}
@@ -1146,12 +1194,16 @@ Result RenderCommandEncoderImpl::drawIndexedIndirect(
}
Result RenderCommandEncoderImpl::setSamplePositions(
- GfxCount samplesPerPixel, GfxCount pixelCount, const SamplePosition* samplePositions)
+ GfxCount samplesPerPixel,
+ GfxCount pixelCount,
+ const SamplePosition* samplePositions)
{
if (m_commandBuffer->m_cmdList1)
{
m_commandBuffer->m_cmdList1->SetSamplePositions(
- (uint32_t)samplesPerPixel, (uint32_t)pixelCount, (D3D12_SAMPLE_POSITION*)samplePositions);
+ (uint32_t)samplesPerPixel,
+ (uint32_t)pixelCount,
+ (D3D12_SAMPLE_POSITION*)samplePositions);
return SLANG_OK;
}
return SLANG_E_NOT_AVAILABLE;
@@ -1196,10 +1248,15 @@ Result RenderCommandEncoderImpl::drawMeshTasks(int x, int y, int z)
return SLANG_OK;
}
-void ComputeCommandEncoderImpl::endEncoding() { PipelineCommandEncoder::endEncodingImpl(); }
+void ComputeCommandEncoderImpl::endEncoding()
+{
+ PipelineCommandEncoder::endEncodingImpl();
+}
void ComputeCommandEncoderImpl::init(
- DeviceImpl* renderer, TransientResourceHeapImpl* transientHeap, CommandBufferImpl* cmdBuffer)
+ DeviceImpl* renderer,
+ TransientResourceHeapImpl* transientHeap,
+ CommandBufferImpl* cmdBuffer)
{
PipelineCommandEncoder::init(cmdBuffer);
m_preCmdList = nullptr;
@@ -1213,7 +1270,8 @@ Result ComputeCommandEncoderImpl::bindPipeline(IPipelineState* state, IShaderObj
}
Result ComputeCommandEncoderImpl::bindPipelineWithRootObject(
- IPipelineState* state, IShaderObject* rootObject)
+ IPipelineState* state,
+ IShaderObject* rootObject)
{
return bindPipelineWithRootObjectImpl(state, rootObject);
}
@@ -1241,7 +1299,12 @@ Result ComputeCommandEncoderImpl::dispatchComputeIndirect(IBufferResource* argBu
auto argBufferImpl = static_cast<BufferResourceImpl*>(argBuffer);
m_d3dCmdList->ExecuteIndirect(
- m_renderer->dispatchIndirectCmdSignature, 1, argBufferImpl->m_resource, (uint64_t)offset, nullptr, 0);
+ m_renderer->dispatchIndirectCmdSignature,
+ 1,
+ argBufferImpl->m_resource,
+ (uint64_t)offset,
+ nullptr,
+ 0);
return SLANG_OK;
}
@@ -1278,11 +1341,15 @@ void RayTracingCommandEncoderImpl::buildAccelerationStructure(
List<D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC> postBuildInfoDescs;
translatePostBuildInfoDescs(propertyQueryCount, queryDescs, postBuildInfoDescs);
m_commandBuffer->m_cmdList4->BuildRaytracingAccelerationStructure(
- &buildDesc, (UINT)propertyQueryCount, postBuildInfoDescs.getBuffer());
+ &buildDesc,
+ (UINT)propertyQueryCount,
+ postBuildInfoDescs.getBuffer());
}
void RayTracingCommandEncoderImpl::copyAccelerationStructure(
- IAccelerationStructure* dest, IAccelerationStructure* src, AccelerationStructureCopyMode mode)
+ IAccelerationStructure* dest,
+ IAccelerationStructure* src,
+ AccelerationStructureCopyMode mode)
{
auto destASImpl = static_cast<AccelerationStructureImpl*>(dest);
auto srcASImpl = static_cast<AccelerationStructureImpl*>(src);
@@ -1303,7 +1370,9 @@ void RayTracingCommandEncoderImpl::copyAccelerationStructure(
return;
}
m_commandBuffer->m_cmdList4->CopyRaytracingAccelerationStructure(
- destASImpl->getDeviceAddress(), srcASImpl->getDeviceAddress(), copyMode);
+ destASImpl->getDeviceAddress(),
+ srcASImpl->getDeviceAddress(),
+ copyMode);
}
void RayTracingCommandEncoderImpl::queryAccelerationStructureProperties(
@@ -1319,11 +1388,14 @@ void RayTracingCommandEncoderImpl::queryAccelerationStructureProperties(
asAddresses[i] = accelerationStructures[i]->getDeviceAddress();
translatePostBuildInfoDescs(queryCount, queryDescs, postBuildInfoDescs);
m_commandBuffer->m_cmdList4->EmitRaytracingAccelerationStructurePostbuildInfo(
- postBuildInfoDescs.getBuffer(), (UINT)accelerationStructureCount, asAddresses.getBuffer());
+ postBuildInfoDescs.getBuffer(),
+ (UINT)accelerationStructureCount,
+ asAddresses.getBuffer());
}
void RayTracingCommandEncoderImpl::serializeAccelerationStructure(
- DeviceAddress dest, IAccelerationStructure* src)
+ DeviceAddress dest,
+ IAccelerationStructure* src)
{
auto srcASImpl = static_cast<AccelerationStructureImpl*>(src);
m_commandBuffer->m_cmdList4->CopyRaytracingAccelerationStructure(
@@ -1333,7 +1405,8 @@ void RayTracingCommandEncoderImpl::serializeAccelerationStructure(
}
void RayTracingCommandEncoderImpl::deserializeAccelerationStructure(
- IAccelerationStructure* dest, DeviceAddress source)
+ IAccelerationStructure* dest,
+ DeviceAddress source)
{
auto destASImpl = static_cast<AccelerationStructureImpl*>(dest);
m_commandBuffer->m_cmdList4->CopyRaytracingAccelerationStructure(
@@ -1343,7 +1416,8 @@ void RayTracingCommandEncoderImpl::deserializeAccelerationStructure(
}
Result RayTracingCommandEncoderImpl::bindPipeline(
- IPipelineState* state, IShaderObject** outRootObject)
+ IPipelineState* state,
+ IShaderObject** outRootObject)
{
return bindPipelineImpl(state, outRootObject);
}
@@ -1362,9 +1436,9 @@ Result RayTracingCommandEncoderImpl::dispatchRays(
{
ID3D12GraphicsCommandList4* m_cmdList4;
RayTracingSubmitter(ID3D12GraphicsCommandList4* cmdList4)
- : ComputeSubmitter(cmdList4)
- , m_cmdList4(cmdList4)
- {}
+ : ComputeSubmitter(cmdList4), m_cmdList4(cmdList4)
+ {
+ }
virtual void setPipelineState(PipelineStateBase* pipeline) override
{
auto pipelineImpl = static_cast<RayTracingPipelineStateImpl*>(pipeline);
@@ -1380,15 +1454,17 @@ Result RayTracingCommandEncoderImpl::dispatchRays(
auto shaderTableImpl = static_cast<ShaderTableImpl*>(shaderTable);
- auto shaderTableBuffer =
- shaderTableImpl->getOrCreateBuffer(pipelineImpl, m_transientHeap, static_cast<ResourceCommandEncoderImpl*>(this));
+ auto shaderTableBuffer = shaderTableImpl->getOrCreateBuffer(
+ pipelineImpl,
+ m_transientHeap,
+ static_cast<ResourceCommandEncoderImpl*>(this));
auto shaderTableAddr = shaderTableBuffer->getDeviceAddress();
D3D12_DISPATCH_RAYS_DESC dispatchDesc = {};
- dispatchDesc.RayGenerationShaderRecord.StartAddress =
- shaderTableAddr + shaderTableImpl->m_rayGenTableOffset +
- rayGenShaderIndex * kRayGenRecordSize;
+ dispatchDesc.RayGenerationShaderRecord.StartAddress = shaderTableAddr +
+ shaderTableImpl->m_rayGenTableOffset +
+ rayGenShaderIndex * kRayGenRecordSize;
dispatchDesc.RayGenerationShaderRecord.SizeInBytes = D3D12_SHADER_IDENTIFIER_SIZE_IN_BYTES;
if (shaderTableImpl->m_missShaderCount > 0)
diff --git a/tools/gfx/d3d12/d3d12-command-encoder.h b/tools/gfx/d3d12/d3d12-command-encoder.h
index 034749946..513c7c994 100644
--- a/tools/gfx/d3d12/d3d12-command-encoder.h
+++ b/tools/gfx/d3d12/d3d12-command-encoder.h
@@ -48,9 +48,7 @@ public:
Result _bindRenderState(Submitter* submitter, RefPtr<PipelineStateBase>& newPipeline);
};
-class ResourceCommandEncoderImpl
- : public IResourceCommandEncoder
- , public PipelineCommandEncoder
+class ResourceCommandEncoderImpl : public IResourceCommandEncoder, public PipelineCommandEncoder
{
public:
virtual void* getInterface(SlangUUID const& uuid)
@@ -60,7 +58,7 @@ public:
return nullptr;
}
virtual SLANG_NO_THROW SlangResult SLANG_MCALL
- queryInterface(SlangUUID const& uuid, void** outObject) override
+ queryInterface(SlangUUID const& uuid, void** outObject) override
{
if (auto ptr = getInterface(uuid))
{
@@ -79,7 +77,7 @@ public:
Offset srcOffset,
Size size) override;
virtual SLANG_NO_THROW void SLANG_MCALL
- uploadBufferData(IBufferResource* dst, Offset offset, Size size, void* data) override;
+ uploadBufferData(IBufferResource* dst, Offset offset, Size size, void* data) override;
virtual SLANG_NO_THROW void SLANG_MCALL textureBarrier(
GfxCount count,
ITextureResource* const* textures,
@@ -92,7 +90,7 @@ public:
ResourceState dst) override;
virtual SLANG_NO_THROW void SLANG_MCALL endEncoding() override {}
virtual SLANG_NO_THROW void SLANG_MCALL
- writeTimestamp(IQueryPool* pool, GfxIndex index) override;
+ writeTimestamp(IQueryPool* pool, GfxIndex index) override;
virtual SLANG_NO_THROW void SLANG_MCALL copyTexture(
ITextureResource* dst,
ResourceState dstState,
@@ -113,7 +111,9 @@ public:
GfxCount subResourceDataCount) override;
virtual SLANG_NO_THROW void SLANG_MCALL clearResourceView(
- IResourceView* view, ClearValue* clearValue, ClearResourceViewFlags::Enum flags) override;
+ IResourceView* view,
+ ClearValue* clearValue,
+ ClearResourceViewFlags::Enum flags) override;
virtual SLANG_NO_THROW void SLANG_MCALL resolveResource(
ITextureResource* source,
@@ -148,19 +148,18 @@ public:
ResourceState dst) override;
virtual SLANG_NO_THROW void SLANG_MCALL
- beginDebugEvent(const char* name, float rgbColor[3]) override;
+ beginDebugEvent(const char* name, float rgbColor[3]) override;
virtual SLANG_NO_THROW void SLANG_MCALL endDebugEvent() override;
};
-class ComputeCommandEncoderImpl
- : public IComputeCommandEncoder
- , public ResourceCommandEncoderImpl
+class ComputeCommandEncoderImpl : public IComputeCommandEncoder, public ResourceCommandEncoderImpl
{
public:
SLANG_GFX_FORWARD_RESOURCE_COMMAND_ENCODER_IMPL(ResourceCommandEncoderImpl)
virtual void* getInterface(SlangUUID const& uuid) override
{
- if (uuid == GfxGUID::IID_IComputeCommandEncoder || uuid == GfxGUID::IID_IResourceCommandEncoder || uuid == ISlangUnknown::getTypeGuid())
+ if (uuid == GfxGUID::IID_IComputeCommandEncoder ||
+ uuid == GfxGUID::IID_IResourceCommandEncoder || uuid == ISlangUnknown::getTypeGuid())
return this;
return nullptr;
}
@@ -173,15 +172,15 @@ public:
CommandBufferImpl* cmdBuffer);
virtual SLANG_NO_THROW Result SLANG_MCALL
- bindPipeline(IPipelineState* state, IShaderObject** outRootObject) override;
+ bindPipeline(IPipelineState* state, IShaderObject** outRootObject) override;
virtual SLANG_NO_THROW Result SLANG_MCALL
- bindPipelineWithRootObject(IPipelineState* state, IShaderObject* rootObject) override;
+ bindPipelineWithRootObject(IPipelineState* state, IShaderObject* rootObject) override;
virtual SLANG_NO_THROW Result SLANG_MCALL dispatchCompute(int x, int y, int z) override;
virtual SLANG_NO_THROW Result SLANG_MCALL
- dispatchComputeIndirect(IBufferResource* argBuffer, Offset offset) override;
+ dispatchComputeIndirect(IBufferResource* argBuffer, Offset offset) override;
};
struct BoundVertexBuffer
@@ -190,15 +189,14 @@ struct BoundVertexBuffer
int m_offset;
};
-class RenderCommandEncoderImpl
- : public IRenderCommandEncoder
- , public ResourceCommandEncoderImpl
+class RenderCommandEncoderImpl : public IRenderCommandEncoder, public ResourceCommandEncoderImpl
{
public:
SLANG_GFX_FORWARD_RESOURCE_COMMAND_ENCODER_IMPL(ResourceCommandEncoderImpl)
virtual void* getInterface(SlangUUID const& uuid) override
{
- if (uuid == GfxGUID::IID_IRenderCommandEncoder || uuid == GfxGUID::IID_IResourceCommandEncoder || uuid == ISlangUnknown::getTypeGuid())
+ if (uuid == GfxGUID::IID_IRenderCommandEncoder ||
+ uuid == GfxGUID::IID_IResourceCommandEncoder || uuid == ISlangUnknown::getTypeGuid())
return this;
return nullptr;
}
@@ -228,19 +226,19 @@ public:
FramebufferImpl* framebuffer);
virtual SLANG_NO_THROW Result SLANG_MCALL
- bindPipeline(IPipelineState* state, IShaderObject** outRootObject) override;
+ bindPipeline(IPipelineState* state, IShaderObject** outRootObject) override;
virtual SLANG_NO_THROW Result SLANG_MCALL
- bindPipelineWithRootObject(IPipelineState* state, IShaderObject* rootObject) override;
+ bindPipelineWithRootObject(IPipelineState* state, IShaderObject* rootObject) override;
virtual SLANG_NO_THROW void SLANG_MCALL
- setViewports(GfxCount count, const Viewport* viewports) override;
+ setViewports(GfxCount count, const Viewport* viewports) override;
virtual SLANG_NO_THROW void SLANG_MCALL
- setScissorRects(GfxCount count, const ScissorRect* rects) override;
+ setScissorRects(GfxCount count, const ScissorRect* rects) override;
virtual SLANG_NO_THROW void SLANG_MCALL
- setPrimitiveTopology(PrimitiveTopology topology) override;
+ setPrimitiveTopology(PrimitiveTopology topology) override;
virtual SLANG_NO_THROW void SLANG_MCALL setVertexBuffers(
GfxIndex startSlot,
@@ -249,13 +247,13 @@ public:
const Offset* offsets) override;
virtual SLANG_NO_THROW void SLANG_MCALL
- setIndexBuffer(IBufferResource* buffer, Format indexFormat, Offset offset = 0) override;
+ setIndexBuffer(IBufferResource* buffer, Format indexFormat, Offset offset = 0) override;
Result prepareDraw();
virtual SLANG_NO_THROW Result SLANG_MCALL
- draw(GfxCount vertexCount, GfxIndex startVertex = 0) override;
+ draw(GfxCount vertexCount, GfxIndex startVertex = 0) override;
virtual SLANG_NO_THROW Result SLANG_MCALL
- drawIndexed(GfxCount indexCount, GfxIndex startIndex = 0, GfxIndex baseVertex = 0) override;
+ drawIndexed(GfxCount indexCount, GfxIndex startIndex = 0, GfxIndex baseVertex = 0) override;
virtual SLANG_NO_THROW void SLANG_MCALL endEncoding() override;
virtual SLANG_NO_THROW void SLANG_MCALL setStencilReference(uint32_t referenceValue) override;
@@ -292,20 +290,19 @@ public:
GfxIndex baseVertexLocation,
GfxIndex startInstanceLocation) override;
- virtual SLANG_NO_THROW Result SLANG_MCALL
- drawMeshTasks(int x, int y, int z) override;
+ virtual SLANG_NO_THROW Result SLANG_MCALL drawMeshTasks(int x, int y, int z) override;
};
#if SLANG_GFX_HAS_DXR_SUPPORT
-class RayTracingCommandEncoderImpl
- : public IRayTracingCommandEncoder
- , public ResourceCommandEncoderImpl
+class RayTracingCommandEncoderImpl : public IRayTracingCommandEncoder,
+ public ResourceCommandEncoderImpl
{
public:
SLANG_GFX_FORWARD_RESOURCE_COMMAND_ENCODER_IMPL(ResourceCommandEncoderImpl)
virtual void* getInterface(SlangUUID const& uuid) override
{
- if (uuid == GfxGUID::IID_IRayTracingCommandEncoder || uuid == GfxGUID::IID_IResourceCommandEncoder || uuid == ISlangUnknown::getTypeGuid())
+ if (uuid == GfxGUID::IID_IRayTracingCommandEncoder ||
+ uuid == GfxGUID::IID_IResourceCommandEncoder || uuid == ISlangUnknown::getTypeGuid())
return this;
return nullptr;
}
@@ -325,13 +322,13 @@ public:
GfxCount queryCount,
AccelerationStructureQueryDesc* queryDescs) override;
virtual SLANG_NO_THROW void SLANG_MCALL
- serializeAccelerationStructure(DeviceAddress dest, IAccelerationStructure* source) override;
- virtual SLANG_NO_THROW void SLANG_MCALL deserializeAccelerationStructure(
- IAccelerationStructure* dest, DeviceAddress source) override;
+ serializeAccelerationStructure(DeviceAddress dest, IAccelerationStructure* source) override;
+ virtual SLANG_NO_THROW void SLANG_MCALL
+ deserializeAccelerationStructure(IAccelerationStructure* dest, DeviceAddress source) override;
virtual SLANG_NO_THROW Result SLANG_MCALL
- bindPipeline(IPipelineState* state, IShaderObject** outRootObject) override;
+ bindPipeline(IPipelineState* state, IShaderObject** outRootObject) override;
virtual SLANG_NO_THROW Result SLANG_MCALL
- bindPipelineWithRootObject(IPipelineState* state, IShaderObject* rootObject) override
+ bindPipelineWithRootObject(IPipelineState* state, IShaderObject* rootObject) override
{
return bindPipelineWithRootObjectImpl(state, rootObject);
}
diff --git a/tools/gfx/d3d12/d3d12-command-queue.cpp b/tools/gfx/d3d12/d3d12-command-queue.cpp
index d0c567b13..a856c0633 100644
--- a/tools/gfx/d3d12/d3d12-command-queue.cpp
+++ b/tools/gfx/d3d12/d3d12-command-queue.cpp
@@ -24,7 +24,10 @@ Result CommandQueueImpl::init(DeviceImpl* device, uint32_t queueIndex)
SLANG_RETURN_ON_FAIL(
m_device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(m_fence.writeRef())));
globalWaitHandle = CreateEventEx(
- nullptr, nullptr, CREATE_EVENT_INITIAL_SET | CREATE_EVENT_MANUAL_RESET, EVENT_ALL_ACCESS);
+ nullptr,
+ nullptr,
+ CREATE_EVENT_INITIAL_SET | CREATE_EVENT_MANUAL_RESET,
+ EVENT_ALL_ACCESS);
return SLANG_OK;
}
@@ -36,7 +39,10 @@ CommandQueueImpl::~CommandQueueImpl()
}
void CommandQueueImpl::executeCommandBuffers(
- GfxCount count, ICommandBuffer* const* commandBuffers, IFence* fence, uint64_t valueToSignal)
+ GfxCount count,
+ ICommandBuffer* const* commandBuffers,
+ IFence* fence,
+ uint64_t valueToSignal)
{
ShortList<ID3D12CommandList*> commandLists;
for (GfxCount i = 0; i < count; i++)
@@ -80,7 +86,9 @@ void CommandQueueImpl::waitOnHost()
}
Result CommandQueueImpl::waitForFenceValuesOnDevice(
- GfxCount fenceCount, IFence** fences, uint64_t* waitValues)
+ GfxCount fenceCount,
+ IFence** fences,
+ uint64_t* waitValues)
{
for (GfxCount i = 0; i < fenceCount; ++i)
{
@@ -90,7 +98,10 @@ Result CommandQueueImpl::waitForFenceValuesOnDevice(
return SLANG_OK;
}
-const CommandQueueImpl::Desc& CommandQueueImpl::getDesc() { return m_desc; }
+const CommandQueueImpl::Desc& CommandQueueImpl::getDesc()
+{
+ return m_desc;
+}
ICommandQueue* CommandQueueImpl::getInterface(const Guid& guid)
{
diff --git a/tools/gfx/d3d12/d3d12-command-queue.h b/tools/gfx/d3d12/d3d12-command-queue.h
index f11df5894..dadb85d17 100644
--- a/tools/gfx/d3d12/d3d12-command-queue.h
+++ b/tools/gfx/d3d12/d3d12-command-queue.h
@@ -10,13 +10,11 @@ namespace d3d12
using namespace Slang;
-class CommandQueueImpl
- : public ICommandQueue
- , public ComObject
+class CommandQueueImpl : public ICommandQueue, public ComObject
{
public:
SLANG_COM_OBJECT_IUNKNOWN_ALL
- ICommandQueue* getInterface(const Guid& guid);
+ ICommandQueue* getInterface(const Guid& guid);
void breakStrongReferenceToDevice() { m_renderer.breakStrongReference(); }
virtual SLANG_NO_THROW Result SLANG_MCALL getNativeHandle(InteropHandle* handle) override;
@@ -43,8 +41,8 @@ public:
virtual SLANG_NO_THROW void SLANG_MCALL waitOnHost() override;
- virtual SLANG_NO_THROW Result SLANG_MCALL waitForFenceValuesOnDevice(
- GfxCount fenceCount, IFence** fences, uint64_t* waitValues) override;
+ virtual SLANG_NO_THROW Result SLANG_MCALL
+ waitForFenceValuesOnDevice(GfxCount fenceCount, IFence** fences, uint64_t* waitValues) override;
};
} // namespace d3d12
diff --git a/tools/gfx/d3d12/d3d12-descriptor-heap.cpp b/tools/gfx/d3d12/d3d12-descriptor-heap.cpp
index b9c0d28ba..d975727f9 100644
--- a/tools/gfx/d3d12/d3d12-descriptor-heap.cpp
+++ b/tools/gfx/d3d12/d3d12-descriptor-heap.cpp
@@ -1,17 +1,20 @@
#include "d3d12-descriptor-heap.h"
-namespace gfx {
+namespace gfx
+{
using namespace Slang;
-D3D12DescriptorHeap::D3D12DescriptorHeap():
- m_totalSize(0),
- m_currentIndex(0),
- m_descriptorSize(0)
+D3D12DescriptorHeap::D3D12DescriptorHeap()
+ : m_totalSize(0), m_currentIndex(0), m_descriptorSize(0)
{
}
-Result D3D12DescriptorHeap::init(ID3D12Device* device, int size, D3D12_DESCRIPTOR_HEAP_TYPE type, D3D12_DESCRIPTOR_HEAP_FLAGS flags)
+Result D3D12DescriptorHeap::init(
+ ID3D12Device* device,
+ int size,
+ D3D12_DESCRIPTOR_HEAP_TYPE type,
+ D3D12_DESCRIPTOR_HEAP_FLAGS flags)
{
m_device = device;
@@ -19,7 +22,8 @@ Result D3D12DescriptorHeap::init(ID3D12Device* device, int size, D3D12_DESCRIPTO
srvHeapDesc.NumDescriptors = size;
srvHeapDesc.Flags = flags;
srvHeapDesc.Type = type;
- SLANG_RETURN_ON_FAIL(device->CreateDescriptorHeap(&srvHeapDesc, IID_PPV_ARGS(m_heap.writeRef())));
+ SLANG_RETURN_ON_FAIL(
+ device->CreateDescriptorHeap(&srvHeapDesc, IID_PPV_ARGS(m_heap.writeRef())));
m_descriptorSize = device->GetDescriptorHandleIncrementSize(type);
m_totalSize = size;
@@ -28,7 +32,12 @@ Result D3D12DescriptorHeap::init(ID3D12Device* device, int size, D3D12_DESCRIPTO
return SLANG_OK;
}
-Result D3D12DescriptorHeap::init(ID3D12Device* device, const D3D12_CPU_DESCRIPTOR_HANDLE* handles, int numHandles, D3D12_DESCRIPTOR_HEAP_TYPE type, D3D12_DESCRIPTOR_HEAP_FLAGS flags)
+Result D3D12DescriptorHeap::init(
+ ID3D12Device* device,
+ const D3D12_CPU_DESCRIPTOR_HANDLE* handles,
+ int numHandles,
+ D3D12_DESCRIPTOR_HEAP_TYPE type,
+ D3D12_DESCRIPTOR_HEAP_FLAGS flags)
{
SLANG_RETURN_ON_FAIL(init(device, numHandles, type, flags));
D3D12_CPU_DESCRIPTOR_HANDLE dst = m_heap->GetCPUDescriptorHandleForHeapStart();
@@ -47,4 +56,3 @@ Result D3D12DescriptorHeap::init(ID3D12Device* device, const D3D12_CPU_DESCRIPTO
}
} // namespace gfx
-
diff --git a/tools/gfx/d3d12/d3d12-descriptor-heap.h b/tools/gfx/d3d12/d3d12-descriptor-heap.h
index 6f82a3f42..44d03b5b0 100644
--- a/tools/gfx/d3d12/d3d12-descriptor-heap.h
+++ b/tools/gfx/d3d12/d3d12-descriptor-heap.h
@@ -1,68 +1,86 @@
#pragma once
-#include <dxgi.h>
-#include <d3d12.h>
-
-#include "slang-com-ptr.h"
-#include "core/slang-virtual-object-pool.h"
-#include "core/slang-short-list.h"
#include "core/slang-basic.h"
+#include "core/slang-short-list.h"
+#include "core/slang-virtual-object-pool.h"
+#include "slang-com-ptr.h"
-namespace gfx {
+#include <d3d12.h>
+#include <dxgi.h>
-/*! \brief A simple class to manage an underlying Dx12 Descriptor Heap. Allocations are made linearly in order. It is not possible to free
-individual allocations, but all allocations can be deallocated with 'deallocateAll'. */
+namespace gfx
+{
+
+/*! \brief A simple class to manage an underlying Dx12 Descriptor Heap. Allocations are made
+linearly in order. It is not possible to free individual allocations, but all allocations can be
+deallocated with 'deallocateAll'. */
class D3D12DescriptorHeap
{
public:
typedef D3D12DescriptorHeap ThisType;
- /// Initialize
- Slang::Result init(ID3D12Device* device, int size, D3D12_DESCRIPTOR_HEAP_TYPE type, D3D12_DESCRIPTOR_HEAP_FLAGS flags);
- /// Initialize with an array of handles copying over the representation
- Slang::Result init(ID3D12Device* device, const D3D12_CPU_DESCRIPTOR_HANDLE* handles, int numHandles, D3D12_DESCRIPTOR_HEAP_TYPE type, D3D12_DESCRIPTOR_HEAP_FLAGS flags);
+ /// Initialize
+ Slang::Result init(
+ ID3D12Device* device,
+ int size,
+ D3D12_DESCRIPTOR_HEAP_TYPE type,
+ D3D12_DESCRIPTOR_HEAP_FLAGS flags);
+ /// Initialize with an array of handles copying over the representation
+ Slang::Result init(
+ ID3D12Device* device,
+ const D3D12_CPU_DESCRIPTOR_HANDLE* handles,
+ int numHandles,
+ D3D12_DESCRIPTOR_HEAP_TYPE type,
+ D3D12_DESCRIPTOR_HEAP_FLAGS flags);
- /// Returns the number of slots that have been used
+ /// Returns the number of slots that have been used
SLANG_FORCE_INLINE int getUsedSize() const { return m_currentIndex; }
- /// Get the total amount of descriptors possible on the heap
+ /// Get the total amount of descriptors possible on the heap
SLANG_FORCE_INLINE int getTotalSize() const { return m_totalSize; }
- /// Allocate a descriptor. Returns the index, or -1 if none left.
+ /// Allocate a descriptor. Returns the index, or -1 if none left.
SLANG_FORCE_INLINE int allocate();
- /// Allocate a number of descriptors. Returns the start index (or -1 if not possible)
+ /// Allocate a number of descriptors. Returns the start index (or -1 if not possible)
SLANG_FORCE_INLINE int allocate(int numDescriptors);
- ///
+ ///
SLANG_FORCE_INLINE int placeAt(int index);
- /// Deallocates all allocations, and starts allocation from the start of the underlying heap again
+ /// Deallocates all allocations, and starts allocation from the start of the underlying heap
+ /// again
SLANG_FORCE_INLINE void deallocateAll() { m_currentIndex = 0; }
- /// Get the size of each
+ /// Get the size of each
SLANG_FORCE_INLINE int getDescriptorSize() const { return m_descriptorSize; }
- /// Get the GPU heap start
- SLANG_FORCE_INLINE D3D12_GPU_DESCRIPTOR_HANDLE getGpuStart() const { return m_heap->GetGPUDescriptorHandleForHeapStart(); }
- /// Get the CPU heap start
- SLANG_FORCE_INLINE D3D12_CPU_DESCRIPTOR_HANDLE getCpuStart() const { return m_heap->GetCPUDescriptorHandleForHeapStart(); }
+ /// Get the GPU heap start
+ SLANG_FORCE_INLINE D3D12_GPU_DESCRIPTOR_HANDLE getGpuStart() const
+ {
+ return m_heap->GetGPUDescriptorHandleForHeapStart();
+ }
+ /// Get the CPU heap start
+ SLANG_FORCE_INLINE D3D12_CPU_DESCRIPTOR_HANDLE getCpuStart() const
+ {
+ return m_heap->GetCPUDescriptorHandleForHeapStart();
+ }
- /// Get the GPU handle at the specified index
+ /// Get the GPU handle at the specified index
SLANG_FORCE_INLINE D3D12_GPU_DESCRIPTOR_HANDLE getGpuHandle(int index) const;
- /// Get the CPU handle at the specified index
+ /// Get the CPU handle at the specified index
SLANG_FORCE_INLINE D3D12_CPU_DESCRIPTOR_HANDLE getCpuHandle(int index) const;
- /// Get the underlying heap
+ /// Get the underlying heap
SLANG_FORCE_INLINE ID3D12DescriptorHeap* getHeap() const { return m_heap; }
- /// Ctor
+ /// Ctor
D3D12DescriptorHeap();
protected:
Slang::ComPtr<ID3D12Device> m_device;
- Slang::ComPtr<ID3D12DescriptorHeap> m_heap; ///< The underlying heap being allocated from
- int m_totalSize; ///< Total amount of allocations available on the heap
- int m_currentIndex; ///< The current descriptor
+ Slang::ComPtr<ID3D12DescriptorHeap> m_heap; ///< The underlying heap being allocated from
+ int m_totalSize; ///< Total amount of allocations available on the heap
+ int m_currentIndex; ///< The current descriptor
int m_descriptorSize; ///< The size of each descriptor
D3D12_DESCRIPTOR_HEAP_FLAGS m_heapFlags; ///< The flags of the heap
};
@@ -83,17 +101,21 @@ struct D3D12Descriptor
///
class D3D12GeneralDescriptorHeap : public Slang::RefObject
{
- ID3D12Device* m_device;
- int m_chunkSize;
- D3D12_DESCRIPTOR_HEAP_TYPE m_type;
+ ID3D12Device* m_device;
+ int m_chunkSize;
+ D3D12_DESCRIPTOR_HEAP_TYPE m_type;
- D3D12DescriptorHeap m_heap;
+ D3D12DescriptorHeap m_heap;
Slang::VirtualObjectPool m_allocator;
public:
int getSize() { return m_chunkSize; }
- Slang::Result init(ID3D12Device* device, int chunkSize, D3D12_DESCRIPTOR_HEAP_TYPE type, D3D12_DESCRIPTOR_HEAP_FLAGS flag)
+ Slang::Result init(
+ ID3D12Device* device,
+ int chunkSize,
+ D3D12_DESCRIPTOR_HEAP_TYPE type,
+ D3D12_DESCRIPTOR_HEAP_FLAGS flag)
{
m_device = device;
m_chunkSize = chunkSize;
@@ -114,17 +136,14 @@ public:
return m_heap.getGpuHandle(index);
}
- int allocate(int count)
- {
- return m_allocator.alloc(count);
- }
+ int allocate(int count) { return m_allocator.alloc(count); }
Slang::Result allocate(D3D12Descriptor* outDescriptor)
{
// TODO: this allocator would take some work to make thread-safe
int index = m_allocator.alloc(1);
- if(index < 0)
+ if (index < 0)
{
assert(!"descriptor allocation failed");
return SLANG_FAIL;
@@ -137,10 +156,7 @@ public:
return SLANG_OK;
}
- void free(int index, int count)
- {
- m_allocator.free(index, count);
- }
+ void free(int index, int count) { m_allocator.free(index, count); }
void free(D3D12Descriptor descriptor)
{
@@ -167,7 +183,8 @@ public:
m_subHeaps.add(subHeap);
if (m_subHeapStartingIndex.getCount())
{
- m_subHeapStartingIndex.add(m_subHeapStartingIndex.getLast() + m_subHeaps.getLast()->getSize());
+ m_subHeapStartingIndex.add(
+ m_subHeapStartingIndex.getLast() + m_subHeaps.getLast()->getSize());
}
else
{
@@ -268,7 +285,6 @@ public:
break;
}
}
-
}
}
};
@@ -344,7 +360,10 @@ struct DescriptorHeapReference
{
enum class Type
{
- Linear, General, ExpandingGeneral, ExpandingLinear
+ Linear,
+ General,
+ ExpandingGeneral,
+ ExpandingLinear
};
union Ptr
{
@@ -380,44 +399,31 @@ struct DescriptorHeapReference
{
switch (type)
{
- case Type::Linear:
- return ptr.linearHeap->getCpuHandle(index);
- case Type::General:
- return ptr.generalHeap->getCpuHandle(index);
- case Type::ExpandingGeneral:
- return ptr.generalExpandingHeap->getCpuHandle(index);
- case Type::ExpandingLinear:
- return ptr.linearExpandingHeap->getCpuHandle(index);
- default:
- return D3D12_CPU_DESCRIPTOR_HANDLE();
+ case Type::Linear: return ptr.linearHeap->getCpuHandle(index);
+ case Type::General: return ptr.generalHeap->getCpuHandle(index);
+ case Type::ExpandingGeneral: return ptr.generalExpandingHeap->getCpuHandle(index);
+ case Type::ExpandingLinear: return ptr.linearExpandingHeap->getCpuHandle(index);
+ default: return D3D12_CPU_DESCRIPTOR_HANDLE();
}
}
D3D12_GPU_DESCRIPTOR_HANDLE getGpuHandle(int index) const
{
switch (type)
{
- case Type::Linear:
- return ptr.linearHeap->getGpuHandle(index);
- case Type::General:
- return ptr.generalHeap->getGpuHandle(index);
- case Type::ExpandingGeneral:
- return ptr.generalExpandingHeap->getGpuHandle(index);
- default:
- return D3D12_GPU_DESCRIPTOR_HANDLE();
+ case Type::Linear: return ptr.linearHeap->getGpuHandle(index);
+ case Type::General: return ptr.generalHeap->getGpuHandle(index);
+ case Type::ExpandingGeneral: return ptr.generalExpandingHeap->getGpuHandle(index);
+ default: return D3D12_GPU_DESCRIPTOR_HANDLE();
}
}
int allocate(int numDescriptors)
{
switch (type)
{
- case Type::Linear:
- return ptr.linearHeap->allocate(numDescriptors);
- case Type::General:
- return ptr.generalHeap->allocate(numDescriptors);
- case Type::ExpandingGeneral:
- return ptr.generalExpandingHeap->allocate(numDescriptors);
- default:
- return ptr.linearExpandingHeap->allocate(numDescriptors);
+ case Type::Linear: return ptr.linearHeap->allocate(numDescriptors);
+ case Type::General: return ptr.generalHeap->allocate(numDescriptors);
+ case Type::ExpandingGeneral: return ptr.generalExpandingHeap->allocate(numDescriptors);
+ default: return ptr.linearExpandingHeap->allocate(numDescriptors);
}
}
void free(int index, int count)
@@ -425,33 +431,28 @@ struct DescriptorHeapReference
switch (type)
{
default:
- case Type::Linear:
- SLANG_ASSERT(!"Linear heap does not support free().");
- break;
- case Type::General:
- return ptr.generalHeap->free(index, count);
- case Type::ExpandingGeneral:
- return ptr.generalExpandingHeap->free(index, count);
+ case Type::Linear: SLANG_ASSERT(!"Linear heap does not support free()."); break;
+ case Type::General: return ptr.generalHeap->free(index, count);
+ case Type::ExpandingGeneral: return ptr.generalExpandingHeap->free(index, count);
}
}
void freeIfSupported(int index, int count)
{
switch (type)
{
- case Type::Linear:
- return;
- case Type::General:
- return ptr.generalHeap->free(index, count);
- case Type::ExpandingGeneral:
- return ptr.generalExpandingHeap->free(index, count);
- default:
- break;
+ case Type::Linear: return;
+ case Type::General: return ptr.generalHeap->free(index, count);
+ case Type::ExpandingGeneral: return ptr.generalExpandingHeap->free(index, count);
+ default: break;
}
}
};
// ---------------------------------------------------------------------------
-int D3D12DescriptorHeap::allocate() { return allocate(1); }
+int D3D12DescriptorHeap::allocate()
+{
+ return allocate(1);
+}
// ---------------------------------------------------------------------------
int D3D12DescriptorHeap::allocate(int numDescriptors)
{
@@ -511,4 +512,3 @@ SLANG_FORCE_INLINE D3D12_GPU_DESCRIPTOR_HANDLE D3D12DescriptorHeap::getGpuHandle
}
} // namespace gfx
-
diff --git a/tools/gfx/d3d12/d3d12-device.cpp b/tools/gfx/d3d12/d3d12-device.cpp
index 09a789ff0..f2b24ab5f 100644
--- a/tools/gfx/d3d12/d3d12-device.cpp
+++ b/tools/gfx/d3d12/d3d12-device.cpp
@@ -5,6 +5,7 @@
#include "d3d12-buffer.h"
#include "d3d12-fence.h"
#include "d3d12-framebuffer.h"
+#include "d3d12-helper-functions.h"
#include "d3d12-pipeline-state.h"
#include "d3d12-query.h"
#include "d3d12-render-pass.h"
@@ -16,22 +17,20 @@
#include "d3d12-swap-chain.h"
#include "d3d12-vertex-layout.h"
-#include "d3d12-helper-functions.h"
-
#ifdef _DEBUG
-# define ENABLE_DEBUG_LAYER 1
+#define ENABLE_DEBUG_LAYER 1
#else
-# define ENABLE_DEBUG_LAYER 0
+#define ENABLE_DEBUG_LAYER 0
#endif
#ifdef GFX_NVAPI
-# include "../nvapi/nvapi-include.h"
+#include "../nvapi/nvapi-include.h"
#endif
#ifdef GFX_NV_AFTERMATH
-# include "GFSDK_Aftermath.h"
-# include "GFSDK_Aftermath_Defines.h"
-# include "GFSDK_Aftermath_GpuCrashDump.h"
+#include "GFSDK_Aftermath.h"
+#include "GFSDK_Aftermath_Defines.h"
+#include "GFSDK_Aftermath_GpuCrashDump.h"
#endif
namespace gfx
@@ -45,9 +44,9 @@ static const uint32_t D3D_FEATURE_LEVEL_12_2 = 0xc200;
#if GFX_NV_AFTERMATH
-/* static */const bool DeviceImpl::g_isAftermathEnabled = true;
+/* static */ const bool DeviceImpl::g_isAftermathEnabled = true;
#else
-/* static */const bool DeviceImpl::g_isAftermathEnabled = false;
+/* static */ const bool DeviceImpl::g_isAftermathEnabled = false;
#endif
struct ShaderModelInfo
@@ -58,10 +57,16 @@ struct ShaderModelInfo
};
// List of shader models. Do not change oldest to newest order.
static ShaderModelInfo kKnownShaderModels[] = {
-#define SHADER_MODEL_INFO_DXBC(major, minor) {D3D_SHADER_MODEL_##major##_##minor, SLANG_DXBC, "sm_" #major "_" #minor }
+#define SHADER_MODEL_INFO_DXBC(major, minor) \
+ { \
+ D3D_SHADER_MODEL_##major##_##minor, SLANG_DXBC, "sm_" #major "_" #minor \
+ }
SHADER_MODEL_INFO_DXBC(5, 1),
#undef SHADER_MODEL_INFO_DXBC
-#define SHADER_MODEL_INFO_DXIL(major, minor) {(D3D_SHADER_MODEL)0x##major##minor, SLANG_DXIL, "sm_" #major "_" #minor }
+#define SHADER_MODEL_INFO_DXIL(major, minor) \
+ { \
+ (D3D_SHADER_MODEL)0x##major##minor, SLANG_DXIL, "sm_" #major "_" #minor \
+ }
SHADER_MODEL_INFO_DXIL(6, 0),
SHADER_MODEL_INFO_DXIL(6, 1),
SHADER_MODEL_INFO_DXIL(6, 2),
@@ -119,8 +124,7 @@ Result DeviceImpl::createBuffer(
if (initialState != D3D12_RESOURCE_STATE_RAYTRACING_ACCELERATION_STRUCTURE)
initialState = D3D12_RESOURCE_STATE_COMMON;
break;
- default:
- return SLANG_FAIL;
+ default: return SLANG_FAIL;
}
// Create the resource.
@@ -166,8 +170,8 @@ Result DeviceImpl::createBuffer(
if (memoryType == MemoryType::DeviceLocal)
{
auto encodeInfo = encodeResourceCommands();
- encodeInfo.d3dCommandList->CopyBufferRegion(
- resourceOut, 0, uploadResourceRef, 0, bufferSize);
+ encodeInfo.d3dCommandList
+ ->CopyBufferRegion(resourceOut, 0, uploadResourceRef, 0, bufferSize);
submitResourceCommandsAndWait(encodeInfo);
}
}
@@ -269,7 +273,7 @@ Result DeviceImpl::captureTextureToSurface(
ID3D12Resource* dxResource = stagingResource;
UINT8* data;
- D3D12_RANGE readRange = { 0, bufferSize };
+ D3D12_RANGE readRange = {0, bufferSize};
SLANG_RETURN_ON_FAIL(dxResource->Map(0, &readRange, reinterpret_cast<void**>(&data)));
@@ -320,7 +324,7 @@ Result DeviceImpl::_createDevice(
{
IDXGIAdapter* dxgiAdapter = dxgiAdapters[i];
if (SLANG_SUCCEEDED(
- m_D3D12CreateDevice(dxgiAdapter, featureLevel, IID_PPV_ARGS(device.writeRef()))))
+ m_D3D12CreateDevice(dxgiAdapter, featureLevel, IID_PPV_ARGS(device.writeRef()))))
{
adapter = dxgiAdapter;
break;
@@ -357,7 +361,9 @@ Result DeviceImpl::_createDevice(
D3D12_FEATURE_DATA_SHADER_MODEL featureShaderModel;
featureShaderModel.HighestShaderModel = D3D_SHADER_MODEL_6_3;
SLANG_SUCCEEDED(device->CheckFeatureSupport(
- D3D12_FEATURE_SHADER_MODEL, &featureShaderModel, sizeof(featureShaderModel)));
+ D3D12_FEATURE_SHADER_MODEL,
+ &featureShaderModel,
+ sizeof(featureShaderModel)));
if (featureShaderModel.HighestShaderModel >= D3D_SHADER_MODEL_6_3)
{
@@ -373,7 +379,7 @@ Result DeviceImpl::_createDevice(
};
// We filter INFO messages because they are way too many
- D3D12_MESSAGE_SEVERITY severities[] = { D3D12_MESSAGE_SEVERITY_INFO };
+ D3D12_MESSAGE_SEVERITY severities[] = {D3D12_MESSAGE_SEVERITY_INFO};
D3D12_INFO_QUEUE_FILTER infoQueueFilter = {};
infoQueueFilter.DenyList.NumSeverities = SLANG_COUNT_OF(severities);
@@ -392,23 +398,28 @@ Result DeviceImpl::_createDevice(
if ((deviceCheckFlags & DeviceCheckFlag::UseDebug) && g_isAftermathEnabled)
{
// Initialize Nsight Aftermath for this device.
- // This combination of flags is not necessarily appropraite for real world usage
- const uint32_t aftermathFlags =
- GFSDK_Aftermath_FeatureFlags_EnableMarkers | // Enable event marker tracking.
- GFSDK_Aftermath_FeatureFlags_CallStackCapturing | // Enable automatic call stack event markers.
- GFSDK_Aftermath_FeatureFlags_EnableResourceTracking | // Enable tracking of resources.
- GFSDK_Aftermath_FeatureFlags_GenerateShaderDebugInfo | // Generate debug information for shaders.
- GFSDK_Aftermath_FeatureFlags_EnableShaderErrorReporting; // Enable additional runtime shader error reporting.
-
+ // This combination of flags is not necessarily appropraite for real world usage
+ const uint32_t aftermathFlags =
+ GFSDK_Aftermath_FeatureFlags_EnableMarkers | // Enable event marker tracking.
+ GFSDK_Aftermath_FeatureFlags_CallStackCapturing | // Enable automatic call stack
+ // event markers.
+ GFSDK_Aftermath_FeatureFlags_EnableResourceTracking | // Enable tracking of
+ // resources.
+ GFSDK_Aftermath_FeatureFlags_GenerateShaderDebugInfo | // Generate debug information
+ // for shaders.
+ GFSDK_Aftermath_FeatureFlags_EnableShaderErrorReporting; // Enable additional
+ // runtime shader error
+ // reporting.
+
auto initResult = GFSDK_Aftermath_DX12_Initialize(
GFSDK_Aftermath_Version_API,
aftermathFlags,
device);
-
- if ( initResult != GFSDK_Aftermath_Result_Success)
+
+ if (initResult != GFSDK_Aftermath_Result_Success)
{
SLANG_ASSERT_FAILURE("Unable to initialize aftermath");
- // Unable to initialize
+ // Unable to initialize
return SLANG_FAIL;
}
}
@@ -456,7 +467,9 @@ Result DeviceImpl::initialize(const Desc& desc)
if (SLANG_FAILED(SharedLibrary::load(libName, d3dModule)))
{
getDebugCallback()->handleMessage(
- DebugMessageType::Error, DebugMessageSource::Layer, "error: failed load 'd3d12.dll'\n");
+ DebugMessageType::Error,
+ DebugMessageSource::Layer,
+ "error: failed load 'd3d12.dll'\n");
return SLANG_FAIL;
}
@@ -465,7 +478,7 @@ Result DeviceImpl::initialize(const Desc& desc)
{
StructType stype;
memcpy(&stype, desc.extendedDescs[i], sizeof(stype));
- switch (stype )
+ switch (stype)
{
case StructType::D3D12DeviceExtendedDesc:
memcpy(&m_extendedDesc, desc.extendedDescs[i], sizeof(m_extendedDesc));
@@ -486,7 +499,7 @@ Result DeviceImpl::initialize(const Desc& desc)
m_info.bindingStyle = BindingStyle::DirectX;
m_info.projectionStyle = ProjectionStyle::DirectX;
m_info.apiName = "Direct3D 12";
- static const float kIdentity[] = { 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1 };
+ static const float kIdentity[] = {1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1};
::memcpy(m_info.identityProjectionMatrix, kIdentity, sizeof(kIdentity));
}
@@ -498,8 +511,9 @@ Result DeviceImpl::initialize(const Desc& desc)
return SLANG_FAIL;
}
- m_D3D12SerializeVersionedRootSignature =
- (PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE)loadProc(d3dModule, "D3D12SerializeVersionedRootSignature");
+ m_D3D12SerializeVersionedRootSignature = (PFN_D3D12_SERIALIZE_VERSIONED_ROOT_SIGNATURE)loadProc(
+ d3dModule,
+ "D3D12SerializeVersionedRootSignature");
if (!m_D3D12SerializeVersionedRootSignature)
{
return SLANG_FAIL;
@@ -526,7 +540,7 @@ Result DeviceImpl::initialize(const Desc& desc)
{
if (SLANG_SUCCEEDED(m_D3D12GetDebugInterface(IID_PPV_ARGS(m_dxDebug.writeRef()))))
{
-# if 0
+#if 0
// Can enable for extra validation. NOTE! That d3d12 warns if you do....
// D3D12 MESSAGE : Device Debug Layer Startup Options : GPU - Based Validation is enabled(disabled by default).
// This results in new validation not possible during API calls on the CPU, by creating patched shaders that have validation
@@ -539,7 +553,7 @@ Result DeviceImpl::initialize(const Desc& desc)
{
debug1->SetEnableGPUBasedValidation(true);
}
-# endif
+#endif
}
}
}
@@ -559,7 +573,8 @@ Result DeviceImpl::initialize(const Desc& desc)
if (ENABLE_DEBUG_LAYER || isGfxDebugLayerEnabled())
{
combiner.add(
- DeviceCheckFlag::UseDebug, ChangeType::OnOff); ///< First try debug then non debug
+ DeviceCheckFlag::UseDebug,
+ ChangeType::OnOff); ///< First try debug then non debug
}
else
{
@@ -570,8 +585,7 @@ Result DeviceImpl::initialize(const Desc& desc)
ChangeType::OnOff); ///< First try hardware, then reference
- const D3D_FEATURE_LEVEL featureLevels[] =
- {
+ const D3D_FEATURE_LEVEL featureLevels[] = {
(D3D_FEATURE_LEVEL)D3D_FEATURE_LEVEL_12_2,
D3D_FEATURE_LEVEL_12_1,
D3D_FEATURE_LEVEL_12_0,
@@ -581,24 +595,23 @@ Result DeviceImpl::initialize(const Desc& desc)
D3D_FEATURE_LEVEL_10_0,
D3D_FEATURE_LEVEL_9_3,
D3D_FEATURE_LEVEL_9_2,
- D3D_FEATURE_LEVEL_9_1
- };
+ D3D_FEATURE_LEVEL_9_1};
for (auto featureLevel : featureLevels)
{
const int numCombinations = combiner.getNumCombinations();
for (int i = 0; i < numCombinations; ++i)
{
if (SLANG_SUCCEEDED(_createDevice(
- combiner.getCombination(i),
- desc.adapterLUID,
- featureLevel,
- m_deviceInfo)))
+ combiner.getCombination(i),
+ desc.adapterLUID,
+ featureLevel,
+ m_deviceInfo)))
{
goto succ;
}
}
}
- succ:
+ succ:
if (!m_deviceInfo.m_adapter)
{
// Couldn't find an adapter
@@ -669,9 +682,10 @@ Result DeviceImpl::initialize(const Desc& desc)
SLANG_COMPILE_TIME_ASSERT(D3D_SHADER_MODEL_6_0 == 0x60);
{
- // CheckFeatureSupport(D3D12_FEATURE_SHADER_MODEL) can fail if the runtime/driver does not yet know the
- // specified highest shader model. Therefore we assemble a list of shader models to check and
- // walk it from highest to lowest to find the supported shader model.
+ // CheckFeatureSupport(D3D12_FEATURE_SHADER_MODEL) can fail if the runtime/driver does
+ // not yet know the specified highest shader model. Therefore we assemble a list of
+ // shader models to check and walk it from highest to lowest to find the supported
+ // shader model.
Slang::ShortList<D3D_SHADER_MODEL> shaderModels;
if (m_extendedDesc.highestShaderModel != 0)
shaderModels.add((D3D_SHADER_MODEL)m_extendedDesc.highestShaderModel);
@@ -680,12 +694,16 @@ Result DeviceImpl::initialize(const Desc& desc)
for (D3D_SHADER_MODEL shaderModel : shaderModels)
{
shaderModelData.HighestShaderModel = shaderModel;
- if (SLANG_SUCCEEDED(m_device->CheckFeatureSupport(D3D12_FEATURE_SHADER_MODEL, &shaderModelData, sizeof(shaderModelData))))
+ if (SLANG_SUCCEEDED(m_device->CheckFeatureSupport(
+ D3D12_FEATURE_SHADER_MODEL,
+ &shaderModelData,
+ sizeof(shaderModelData))))
break;
}
// TODO: Currently warp causes a crash when using half, so disable for now
- if (m_deviceInfo.m_isWarp == false && shaderModelData.HighestShaderModel >= D3D_SHADER_MODEL_6_2)
+ if (m_deviceInfo.m_isWarp == false &&
+ shaderModelData.HighestShaderModel >= D3D_SHADER_MODEL_6_2)
{
// With sm_6_2 we have half
m_features.add("half");
@@ -694,7 +712,9 @@ Result DeviceImpl::initialize(const Desc& desc)
{
D3D12_FEATURE_DATA_D3D12_OPTIONS options;
if (SLANG_SUCCEEDED(m_device->CheckFeatureSupport(
- D3D12_FEATURE_D3D12_OPTIONS, &options, sizeof(options))))
+ D3D12_FEATURE_D3D12_OPTIONS,
+ &options,
+ sizeof(options))))
{
// Check double precision support
if (options.DoublePrecisionFloatShaderOps)
@@ -728,7 +748,9 @@ Result DeviceImpl::initialize(const Desc& desc)
{
D3D12_FEATURE_DATA_D3D12_OPTIONS1 options;
if (SLANG_SUCCEEDED(m_device->CheckFeatureSupport(
- D3D12_FEATURE_D3D12_OPTIONS1, &options, sizeof(options))))
+ D3D12_FEATURE_D3D12_OPTIONS1,
+ &options,
+ sizeof(options))))
{
// Check wave operations support
if (options.WaveOps)
@@ -738,7 +760,9 @@ Result DeviceImpl::initialize(const Desc& desc)
{
D3D12_FEATURE_DATA_D3D12_OPTIONS2 options;
if (SLANG_SUCCEEDED(m_device->CheckFeatureSupport(
- D3D12_FEATURE_D3D12_OPTIONS2, &options, sizeof(options))))
+ D3D12_FEATURE_D3D12_OPTIONS2,
+ &options,
+ sizeof(options))))
{
// Check programmable sample positions support
switch (options.ProgrammableSamplePositionsTier)
@@ -750,15 +774,16 @@ Result DeviceImpl::initialize(const Desc& desc)
case D3D12_PROGRAMMABLE_SAMPLE_POSITIONS_TIER_1:
m_features.add("programmable-sample-positions-1");
break;
- default:
- break;
+ default: break;
}
}
}
{
D3D12_FEATURE_DATA_D3D12_OPTIONS3 options;
if (SLANG_SUCCEEDED(m_device->CheckFeatureSupport(
- D3D12_FEATURE_D3D12_OPTIONS3, &options, sizeof(options))))
+ D3D12_FEATURE_D3D12_OPTIONS3,
+ &options,
+ sizeof(options))))
{
// Check barycentrics support
if (options.BarycentricsSupported)
@@ -771,7 +796,9 @@ Result DeviceImpl::initialize(const Desc& desc)
{
D3D12_FEATURE_DATA_D3D12_OPTIONS5 options;
if (SLANG_SUCCEEDED(m_device->CheckFeatureSupport(
- D3D12_FEATURE_D3D12_OPTIONS5, &options, sizeof(options))))
+ D3D12_FEATURE_D3D12_OPTIONS5,
+ &options,
+ sizeof(options))))
{
if (options.RaytracingTier != D3D12_RAYTRACING_TIER_NOT_SUPPORTED)
{
@@ -787,7 +814,9 @@ Result DeviceImpl::initialize(const Desc& desc)
{
D3D12_FEATURE_DATA_D3D12_OPTIONS7 options;
if (SLANG_SUCCEEDED(m_device->CheckFeatureSupport(
- D3D12_FEATURE_D3D12_OPTIONS7, &options, sizeof(options))))
+ D3D12_FEATURE_D3D12_OPTIONS7,
+ &options,
+ sizeof(options))))
{
if (options.MeshShaderTier >= D3D12_MESH_SHADER_TIER_1)
{
@@ -825,9 +854,12 @@ Result DeviceImpl::initialize(const Desc& desc)
limits.maxComputeThreadGroupSize[0] = D3D12_CS_THREAD_GROUP_MAX_X;
limits.maxComputeThreadGroupSize[1] = D3D12_CS_THREAD_GROUP_MAX_Y;
limits.maxComputeThreadGroupSize[2] = D3D12_CS_THREAD_GROUP_MAX_Z;
- limits.maxComputeDispatchThreadGroups[0] = D3D12_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION;
- limits.maxComputeDispatchThreadGroups[1] = D3D12_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION;
- limits.maxComputeDispatchThreadGroups[2] = D3D12_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION;
+ limits.maxComputeDispatchThreadGroups[0] =
+ D3D12_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION;
+ limits.maxComputeDispatchThreadGroups[1] =
+ D3D12_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION;
+ limits.maxComputeDispatchThreadGroups[2] =
+ D3D12_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION;
limits.maxViewports = D3D12_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE;
limits.maxViewportDimensions[0] = D3D12_VIEWPORT_BOUNDS_MAX;
@@ -859,14 +891,23 @@ Result DeviceImpl::initialize(const Desc& desc)
D3D12_DESCRIPTOR_HEAP_FLAG_NONE));
m_cpuSamplerHeap = new D3D12GeneralExpandingDescriptorHeap();
SLANG_RETURN_ON_FAIL(m_cpuSamplerHeap->init(
- m_device, 2048, D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER, D3D12_DESCRIPTOR_HEAP_FLAG_NONE));
+ m_device,
+ 2048,
+ D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER,
+ D3D12_DESCRIPTOR_HEAP_FLAG_NONE));
m_rtvAllocator = new D3D12GeneralExpandingDescriptorHeap();
SLANG_RETURN_ON_FAIL(m_rtvAllocator->init(
- m_device, 16 * 1024, D3D12_DESCRIPTOR_HEAP_TYPE_RTV, D3D12_DESCRIPTOR_HEAP_FLAG_NONE));
+ m_device,
+ 16 * 1024,
+ D3D12_DESCRIPTOR_HEAP_TYPE_RTV,
+ D3D12_DESCRIPTOR_HEAP_FLAG_NONE));
m_dsvAllocator = new D3D12GeneralExpandingDescriptorHeap();
SLANG_RETURN_ON_FAIL(m_dsvAllocator->init(
- m_device, 1024, D3D12_DESCRIPTOR_HEAP_TYPE_DSV, D3D12_DESCRIPTOR_HEAP_FLAG_NONE));
+ m_device,
+ 1024,
+ D3D12_DESCRIPTOR_HEAP_TYPE_DSV,
+ D3D12_DESCRIPTOR_HEAP_FLAG_NONE));
ComPtr<IDXGIDevice> dxgiDevice;
if (m_deviceInfo.m_adapter)
@@ -914,7 +955,7 @@ Result DeviceImpl::initialize(const Desc& desc)
desc.extendedDescs,
compileTarget,
profileName,
- makeArray(slang::PreprocessorMacroDesc{ "__D3D12__", "1" }).getView()));
+ makeArray(slang::PreprocessorMacroDesc{"__D3D12__", "1"}).getView()));
// Allocate a D3D12 "command signature" object that matches the behavior
// of a D3D11-style `DrawInstancedIndirect` operation.
@@ -929,7 +970,9 @@ Result DeviceImpl::initialize(const Desc& desc)
desc.NodeMask = 0;
SLANG_RETURN_ON_FAIL(m_device->CreateCommandSignature(
- &desc, nullptr, IID_PPV_ARGS(drawIndirectCmdSignature.writeRef())));
+ &desc,
+ nullptr,
+ IID_PPV_ARGS(drawIndirectCmdSignature.writeRef())));
}
// Allocate a D3D12 "command signature" object that matches the behavior
@@ -945,7 +988,9 @@ Result DeviceImpl::initialize(const Desc& desc)
desc.NodeMask = 0;
SLANG_RETURN_ON_FAIL(m_device->CreateCommandSignature(
- &desc, nullptr, IID_PPV_ARGS(drawIndexedIndirectCmdSignature.writeRef())));
+ &desc,
+ nullptr,
+ IID_PPV_ARGS(drawIndexedIndirectCmdSignature.writeRef())));
}
// Allocate a D3D12 "command signature" object that matches the behavior
@@ -961,14 +1006,17 @@ Result DeviceImpl::initialize(const Desc& desc)
desc.NodeMask = 0;
SLANG_RETURN_ON_FAIL(m_device->CreateCommandSignature(
- &desc, nullptr, IID_PPV_ARGS(dispatchIndirectCmdSignature.writeRef())));
+ &desc,
+ nullptr,
+ IID_PPV_ARGS(dispatchIndirectCmdSignature.writeRef())));
}
m_isInitialized = true;
return SLANG_OK;
}
Result DeviceImpl::createTransientResourceHeap(
- const ITransientResourceHeap::Desc& desc, ITransientResourceHeap** outHeap)
+ const ITransientResourceHeap::Desc& desc,
+ ITransientResourceHeap** outHeap)
{
RefPtr<TransientResourceHeapImpl> heap;
SLANG_RETURN_ON_FAIL(createTransientResourceHeapImpl(
@@ -990,7 +1038,9 @@ Result DeviceImpl::createCommandQueue(const ICommandQueue::Desc& desc, ICommandQ
}
Result DeviceImpl::createSwapchain(
- const ISwapchain::Desc& desc, WindowHandle window, ISwapchain** outSwapchain)
+ const ISwapchain::Desc& desc,
+ WindowHandle window,
+ ISwapchain** outSwapchain)
{
RefPtr<SwapchainImpl> swapchain = new SwapchainImpl();
SLANG_RETURN_ON_FAIL(swapchain->init(this, desc, window));
@@ -1006,11 +1056,17 @@ SlangResult DeviceImpl::readTextureResource(
Size* outPixelSize)
{
return captureTextureToSurface(
- static_cast<TextureResourceImpl*>(resource), state, outBlob, outRowPitch, outPixelSize);
+ static_cast<TextureResourceImpl*>(resource),
+ state,
+ outBlob,
+ outRowPitch,
+ outPixelSize);
}
Result DeviceImpl::getTextureAllocationInfo(
- const ITextureResource::Desc& desc, Size* outSize, Size* outAlignment)
+ const ITextureResource::Desc& desc,
+ Size* outSize,
+ Size* outAlignment)
{
TextureResource::Desc srcDesc = fixupTextureDesc(desc);
D3D12_RESOURCE_DESC resourceDesc = {};
@@ -1069,7 +1125,7 @@ Result DeviceImpl::createTextureResource(
clearValuePtr = &clearValue;
}
if ((resourceDesc.Flags & (D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET |
- D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL)) == 0)
+ D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL)) == 0)
{
clearValuePtr = nullptr;
}
@@ -1194,8 +1250,8 @@ Result DeviceImpl::createTextureResource(
const uint8_t* srcRow = srcLayer;
uint8_t* dstRow = dstLayer;
int j = gfxIsCompressedFormat(descIn.format)
- ? 4
- : 1; // BC compressed formats are organized into 4x4 blocks
+ ? 4
+ : 1; // BC compressed formats are organized into 4x4 blocks
for (int k = 0; k < mipSize.height; k += j)
{
::memcpy(dstRow, srcRow, (Size)mipRowSize);
@@ -1240,7 +1296,9 @@ Result DeviceImpl::createTextureResource(
{
D3D12BarrierSubmitter submitter(encodeInfo.d3dCommandList);
texture->m_resource.transition(
- D3D12_RESOURCE_STATE_COPY_DEST, texture->m_defaultState, submitter);
+ D3D12_RESOURCE_STATE_COPY_DEST,
+ texture->m_defaultState,
+ submitter);
}
submitResourceCommandsAndWait(encodeInfo);
}
@@ -1250,7 +1308,9 @@ Result DeviceImpl::createTextureResource(
}
Result DeviceImpl::createTextureFromNativeHandle(
- InteropHandle handle, const ITextureResource::Desc& srcDesc, ITextureResource** outResource)
+ InteropHandle handle,
+ const ITextureResource::Desc& srcDesc,
+ ITextureResource** outResource)
{
RefPtr<TextureResourceImpl> texture(new TextureResourceImpl(srcDesc));
@@ -1268,7 +1328,9 @@ Result DeviceImpl::createTextureFromNativeHandle(
}
Result DeviceImpl::createBufferResource(
- const IBufferResource::Desc& descIn, const void* initData, IBufferResource** outResource)
+ const IBufferResource::Desc& descIn,
+ const void* initData,
+ IBufferResource** outResource)
{
BufferResource::Desc srcDesc = fixupBufferDesc(descIn);
@@ -1294,7 +1356,9 @@ Result DeviceImpl::createBufferResource(
}
Result DeviceImpl::createBufferFromNativeHandle(
- InteropHandle handle, const IBufferResource::Desc& srcDesc, IBufferResource** outResource)
+ InteropHandle handle,
+ const IBufferResource::Desc& srcDesc,
+ IBufferResource** outResource)
{
RefPtr<BufferResourceImpl> buffer(new BufferResourceImpl(srcDesc));
@@ -1359,7 +1423,9 @@ Result DeviceImpl::createSamplerState(ISamplerState::Desc const& desc, ISamplerS
}
Result DeviceImpl::createTextureView(
- ITextureResource* texture, IResourceView::Desc const& desc, IResourceView** outView)
+ ITextureResource* texture,
+ IResourceView::Desc const& desc,
+ IResourceView** outView)
{
auto resourceImpl = (TextureResourceImpl*)texture;
@@ -1370,242 +1436,246 @@ Result DeviceImpl::createTextureView(
bool isMultiSample = resourceImpl ? resourceImpl->getDesc()->sampleDesc.numSamples > 1 : false;
switch (desc.type)
{
- default:
- return SLANG_FAIL;
+ default: return SLANG_FAIL;
case IResourceView::Type::RenderTarget:
- {
- SLANG_RETURN_ON_FAIL(m_rtvAllocator->allocate(&viewImpl->m_descriptor));
- viewImpl->m_allocator = m_rtvAllocator;
- D3D12_RENDER_TARGET_VIEW_DESC rtvDesc = {};
- rtvDesc.Format = D3DUtil::getMapFormat(desc.format);
- switch (desc.renderTarget.shape)
{
- case IResource::Type::Texture1D:
- rtvDesc.ViewDimension = isArray ? D3D12_RTV_DIMENSION_TEXTURE1DARRAY : D3D12_RTV_DIMENSION_TEXTURE1D;
- if(isArray)
- {
- rtvDesc.Texture1DArray.MipSlice = desc.subresourceRange.mipLevel;
- rtvDesc.Texture1DArray.FirstArraySlice = desc.subresourceRange.baseArrayLayer;
- rtvDesc.Texture1DArray.ArraySize = desc.subresourceRange.layerCount;
- }
- else
- {
- rtvDesc.Texture1D.MipSlice = desc.subresourceRange.mipLevel;
- }
-
- break;
- case IResource::Type::Texture2D:
- if (isMultiSample)
+ SLANG_RETURN_ON_FAIL(m_rtvAllocator->allocate(&viewImpl->m_descriptor));
+ viewImpl->m_allocator = m_rtvAllocator;
+ D3D12_RENDER_TARGET_VIEW_DESC rtvDesc = {};
+ rtvDesc.Format = D3DUtil::getMapFormat(desc.format);
+ switch (desc.renderTarget.shape)
{
- rtvDesc.ViewDimension = isArray ? D3D12_RTV_DIMENSION_TEXTURE2DMSARRAY
- : D3D12_RTV_DIMENSION_TEXTURE2DMS;
- rtvDesc.Texture2DMSArray.ArraySize = desc.subresourceRange.layerCount;
- rtvDesc.Texture2DMSArray.FirstArraySlice = desc.subresourceRange.baseArrayLayer;
- }
- else
- {
- rtvDesc.ViewDimension = isArray ? D3D12_RTV_DIMENSION_TEXTURE2DARRAY
- : D3D12_RTV_DIMENSION_TEXTURE2D;
- if(isArray)
+ case IResource::Type::Texture1D:
+ rtvDesc.ViewDimension =
+ isArray ? D3D12_RTV_DIMENSION_TEXTURE1DARRAY : D3D12_RTV_DIMENSION_TEXTURE1D;
+ if (isArray)
{
- rtvDesc.Texture2DArray.MipSlice = desc.subresourceRange.mipLevel;
- rtvDesc.Texture2DArray.ArraySize = desc.subresourceRange.layerCount;
- rtvDesc.Texture2DArray.FirstArraySlice = desc.subresourceRange.baseArrayLayer;
- rtvDesc.Texture2DArray.PlaneSlice =
- resourceImpl ? D3DUtil::getPlaneSlice(
- D3DUtil::getMapFormat(resourceImpl->getDesc()->format),
- desc.subresourceRange.aspectMask)
- : 0;
+ rtvDesc.Texture1DArray.MipSlice = desc.subresourceRange.mipLevel;
+ rtvDesc.Texture1DArray.FirstArraySlice = desc.subresourceRange.baseArrayLayer;
+ rtvDesc.Texture1DArray.ArraySize = desc.subresourceRange.layerCount;
}
else
{
- rtvDesc.Texture2D.MipSlice = desc.subresourceRange.mipLevel;
- rtvDesc.Texture2D.PlaneSlice =
- resourceImpl ? D3DUtil::getPlaneSlice(
- D3DUtil::getMapFormat(resourceImpl->getDesc()->format),
- desc.subresourceRange.aspectMask)
- : 0;
+ rtvDesc.Texture1D.MipSlice = desc.subresourceRange.mipLevel;
+ }
+
+ break;
+ case IResource::Type::Texture2D:
+ if (isMultiSample)
+ {
+ rtvDesc.ViewDimension = isArray ? D3D12_RTV_DIMENSION_TEXTURE2DMSARRAY
+ : D3D12_RTV_DIMENSION_TEXTURE2DMS;
+ rtvDesc.Texture2DMSArray.ArraySize = desc.subresourceRange.layerCount;
+ rtvDesc.Texture2DMSArray.FirstArraySlice = desc.subresourceRange.baseArrayLayer;
}
+ else
+ {
+ rtvDesc.ViewDimension = isArray ? D3D12_RTV_DIMENSION_TEXTURE2DARRAY
+ : D3D12_RTV_DIMENSION_TEXTURE2D;
+ if (isArray)
+ {
+ rtvDesc.Texture2DArray.MipSlice = desc.subresourceRange.mipLevel;
+ rtvDesc.Texture2DArray.ArraySize = desc.subresourceRange.layerCount;
+ rtvDesc.Texture2DArray.FirstArraySlice =
+ desc.subresourceRange.baseArrayLayer;
+ rtvDesc.Texture2DArray.PlaneSlice =
+ resourceImpl
+ ? D3DUtil::getPlaneSlice(
+ D3DUtil::getMapFormat(resourceImpl->getDesc()->format),
+ desc.subresourceRange.aspectMask)
+ : 0;
+ }
+ else
+ {
+ rtvDesc.Texture2D.MipSlice = desc.subresourceRange.mipLevel;
+ rtvDesc.Texture2D.PlaneSlice =
+ resourceImpl
+ ? D3DUtil::getPlaneSlice(
+ D3DUtil::getMapFormat(resourceImpl->getDesc()->format),
+ desc.subresourceRange.aspectMask)
+ : 0;
+ }
+ }
+ break;
+ case IResource::Type::TextureCube:
+ rtvDesc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2DARRAY;
+ rtvDesc.Texture2DArray.MipSlice = desc.subresourceRange.mipLevel;
+ rtvDesc.Texture2DArray.ArraySize = desc.subresourceRange.layerCount;
+ rtvDesc.Texture2DArray.FirstArraySlice = desc.subresourceRange.baseArrayLayer;
+ rtvDesc.Texture2DArray.PlaneSlice =
+ resourceImpl ? D3DUtil::getPlaneSlice(
+ D3DUtil::getMapFormat(resourceImpl->getDesc()->format),
+ desc.subresourceRange.aspectMask)
+ : 0;
+ break;
+ case IResource::Type::Texture3D:
+ rtvDesc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE3D;
+ rtvDesc.Texture3D.MipSlice = desc.subresourceRange.mipLevel;
+ rtvDesc.Texture3D.FirstWSlice = desc.subresourceRange.baseArrayLayer;
+ rtvDesc.Texture3D.WSize =
+ (desc.subresourceRange.layerCount == 0) ? -1 : desc.subresourceRange.layerCount;
+ break;
+ case IResource::Type::Buffer: rtvDesc.ViewDimension = D3D12_RTV_DIMENSION_BUFFER; break;
+ default: return SLANG_FAIL;
}
- break;
- case IResource::Type::TextureCube:
- rtvDesc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE2DARRAY;
- rtvDesc.Texture2DArray.MipSlice = desc.subresourceRange.mipLevel;
- rtvDesc.Texture2DArray.ArraySize = desc.subresourceRange.layerCount;
- rtvDesc.Texture2DArray.FirstArraySlice = desc.subresourceRange.baseArrayLayer;
- rtvDesc.Texture2DArray.PlaneSlice =
- resourceImpl
- ? D3DUtil::getPlaneSlice(D3DUtil::getMapFormat(resourceImpl->getDesc()->format), desc.subresourceRange.aspectMask)
- : 0;
- break;
- case IResource::Type::Texture3D:
- rtvDesc.ViewDimension = D3D12_RTV_DIMENSION_TEXTURE3D;
- rtvDesc.Texture3D.MipSlice = desc.subresourceRange.mipLevel;
- rtvDesc.Texture3D.FirstWSlice = desc.subresourceRange.baseArrayLayer;
- rtvDesc.Texture3D.WSize = (desc.subresourceRange.layerCount == 0) ? -1 : desc.subresourceRange.layerCount;
- break;
- case IResource::Type::Buffer:
- rtvDesc.ViewDimension = D3D12_RTV_DIMENSION_BUFFER;
- break;
- default:
- return SLANG_FAIL;
+ m_device->CreateRenderTargetView(
+ resourceImpl ? resourceImpl->m_resource.getResource() : nullptr,
+ &rtvDesc,
+ viewImpl->m_descriptor.cpuHandle);
}
- m_device->CreateRenderTargetView(
- resourceImpl ? resourceImpl->m_resource.getResource() : nullptr,
- &rtvDesc,
- viewImpl->m_descriptor.cpuHandle);
- }
- break;
+ break;
case IResourceView::Type::DepthStencil:
- {
- SLANG_RETURN_ON_FAIL(m_dsvAllocator->allocate(&viewImpl->m_descriptor));
- viewImpl->m_allocator = m_dsvAllocator;
- D3D12_DEPTH_STENCIL_VIEW_DESC dsvDesc = {};
- dsvDesc.Format = D3DUtil::getMapFormat(desc.format);
- switch (desc.renderTarget.shape)
{
- case IResource::Type::Texture1D:
- dsvDesc.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE1D;
- dsvDesc.Texture1D.MipSlice = desc.subresourceRange.mipLevel;
- break;
- case IResource::Type::Texture2D:
- if (isMultiSample)
- {
- dsvDesc.ViewDimension = isArray ? D3D12_DSV_DIMENSION_TEXTURE2DMSARRAY
- : D3D12_DSV_DIMENSION_TEXTURE2DMS;
- dsvDesc.Texture2DMSArray.ArraySize = desc.subresourceRange.layerCount;
- dsvDesc.Texture2DMSArray.FirstArraySlice = desc.subresourceRange.baseArrayLayer;
- }
- else
+ SLANG_RETURN_ON_FAIL(m_dsvAllocator->allocate(&viewImpl->m_descriptor));
+ viewImpl->m_allocator = m_dsvAllocator;
+ D3D12_DEPTH_STENCIL_VIEW_DESC dsvDesc = {};
+ dsvDesc.Format = D3DUtil::getMapFormat(desc.format);
+ switch (desc.renderTarget.shape)
{
- dsvDesc.ViewDimension = isArray ? D3D12_DSV_DIMENSION_TEXTURE2DARRAY
- : D3D12_DSV_DIMENSION_TEXTURE2D;
+ case IResource::Type::Texture1D:
+ dsvDesc.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE1D;
+ dsvDesc.Texture1D.MipSlice = desc.subresourceRange.mipLevel;
+ break;
+ case IResource::Type::Texture2D:
+ if (isMultiSample)
+ {
+ dsvDesc.ViewDimension = isArray ? D3D12_DSV_DIMENSION_TEXTURE2DMSARRAY
+ : D3D12_DSV_DIMENSION_TEXTURE2DMS;
+ dsvDesc.Texture2DMSArray.ArraySize = desc.subresourceRange.layerCount;
+ dsvDesc.Texture2DMSArray.FirstArraySlice = desc.subresourceRange.baseArrayLayer;
+ }
+ else
+ {
+ dsvDesc.ViewDimension = isArray ? D3D12_DSV_DIMENSION_TEXTURE2DARRAY
+ : D3D12_DSV_DIMENSION_TEXTURE2D;
+ dsvDesc.Texture2DArray.MipSlice = desc.subresourceRange.mipLevel;
+ dsvDesc.Texture2DArray.ArraySize = desc.subresourceRange.layerCount;
+ dsvDesc.Texture2DArray.FirstArraySlice = desc.subresourceRange.baseArrayLayer;
+ }
+ break;
+ case IResource::Type::TextureCube:
+ dsvDesc.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2DARRAY;
dsvDesc.Texture2DArray.MipSlice = desc.subresourceRange.mipLevel;
dsvDesc.Texture2DArray.ArraySize = desc.subresourceRange.layerCount;
dsvDesc.Texture2DArray.FirstArraySlice = desc.subresourceRange.baseArrayLayer;
+ break;
+ default: return SLANG_FAIL;
}
- break;
- case IResource::Type::TextureCube:
- dsvDesc.ViewDimension = D3D12_DSV_DIMENSION_TEXTURE2DARRAY;
- dsvDesc.Texture2DArray.MipSlice = desc.subresourceRange.mipLevel;
- dsvDesc.Texture2DArray.ArraySize = desc.subresourceRange.layerCount;
- dsvDesc.Texture2DArray.FirstArraySlice = desc.subresourceRange.baseArrayLayer;
- break;
- default:
- return SLANG_FAIL;
+ m_device->CreateDepthStencilView(
+ resourceImpl ? resourceImpl->m_resource.getResource() : nullptr,
+ &dsvDesc,
+ viewImpl->m_descriptor.cpuHandle);
}
- m_device->CreateDepthStencilView(
- resourceImpl ? resourceImpl->m_resource.getResource() : nullptr,
- &dsvDesc,
- viewImpl->m_descriptor.cpuHandle);
- }
- break;
+ break;
case IResourceView::Type::UnorderedAccess:
- {
- // TODO: need to support the separate "counter resource" for the case
- // of append/consume buffers with attached counters.
-
- SLANG_RETURN_ON_FAIL(m_cpuViewHeap->allocate(&viewImpl->m_descriptor));
- viewImpl->m_allocator = m_cpuViewHeap;
- D3D12_UNORDERED_ACCESS_VIEW_DESC d3d12desc = {};
- auto& resourceDesc = *resourceImpl->getDesc();
- d3d12desc.Format = gfxIsTypelessFormat(texture->getDesc()->format)
- ? D3DUtil::getMapFormat(desc.format)
- : D3DUtil::getMapFormat(texture->getDesc()->format);
- switch (resourceImpl->getDesc()->type)
{
- case IResource::Type::Texture1D:
- d3d12desc.ViewDimension = isArray
- ? D3D12_UAV_DIMENSION_TEXTURE1DARRAY
- : D3D12_UAV_DIMENSION_TEXTURE1D;
- if(isArray)
- {
- d3d12desc.Texture1DArray.MipSlice = desc.subresourceRange.mipLevel;
- d3d12desc.Texture1DArray.ArraySize = desc.subresourceRange.layerCount == 0
- ? resourceDesc.arraySize
- : desc.subresourceRange.layerCount;
- d3d12desc.Texture1DArray.FirstArraySlice = desc.subresourceRange.baseArrayLayer;
- }
- else
- {
- d3d12desc.Texture1D.MipSlice = desc.subresourceRange.mipLevel;
- }
- break;
- case IResource::Type::Texture2D:
- d3d12desc.ViewDimension = isArray
- ? D3D12_UAV_DIMENSION_TEXTURE2DARRAY
- : D3D12_UAV_DIMENSION_TEXTURE2D;
- if(isArray)
+ // TODO: need to support the separate "counter resource" for the case
+ // of append/consume buffers with attached counters.
+
+ SLANG_RETURN_ON_FAIL(m_cpuViewHeap->allocate(&viewImpl->m_descriptor));
+ viewImpl->m_allocator = m_cpuViewHeap;
+ D3D12_UNORDERED_ACCESS_VIEW_DESC d3d12desc = {};
+ auto& resourceDesc = *resourceImpl->getDesc();
+ d3d12desc.Format = gfxIsTypelessFormat(texture->getDesc()->format)
+ ? D3DUtil::getMapFormat(desc.format)
+ : D3DUtil::getMapFormat(texture->getDesc()->format);
+ switch (resourceImpl->getDesc()->type)
{
+ case IResource::Type::Texture1D:
+ d3d12desc.ViewDimension =
+ isArray ? D3D12_UAV_DIMENSION_TEXTURE1DARRAY : D3D12_UAV_DIMENSION_TEXTURE1D;
+ if (isArray)
+ {
+ d3d12desc.Texture1DArray.MipSlice = desc.subresourceRange.mipLevel;
+ d3d12desc.Texture1DArray.ArraySize = desc.subresourceRange.layerCount == 0
+ ? resourceDesc.arraySize
+ : desc.subresourceRange.layerCount;
+ d3d12desc.Texture1DArray.FirstArraySlice = desc.subresourceRange.baseArrayLayer;
+ }
+ else
+ {
+ d3d12desc.Texture1D.MipSlice = desc.subresourceRange.mipLevel;
+ }
+ break;
+ case IResource::Type::Texture2D:
+ d3d12desc.ViewDimension =
+ isArray ? D3D12_UAV_DIMENSION_TEXTURE2DARRAY : D3D12_UAV_DIMENSION_TEXTURE2D;
+ if (isArray)
+ {
+ d3d12desc.Texture2DArray.MipSlice = desc.subresourceRange.mipLevel;
+ d3d12desc.Texture2DArray.ArraySize = desc.subresourceRange.layerCount == 0
+ ? resourceDesc.arraySize
+ : desc.subresourceRange.layerCount;
+ d3d12desc.Texture2DArray.FirstArraySlice = desc.subresourceRange.baseArrayLayer;
+ d3d12desc.Texture2DArray.PlaneSlice =
+ D3DUtil::getPlaneSlice(d3d12desc.Format, desc.subresourceRange.aspectMask);
+ }
+ else
+ {
+ d3d12desc.Texture2D.MipSlice = desc.subresourceRange.mipLevel;
+ d3d12desc.Texture2D.PlaneSlice =
+ D3DUtil::getPlaneSlice(d3d12desc.Format, desc.subresourceRange.aspectMask);
+ }
+ break;
+ case IResource::Type::TextureCube:
+ d3d12desc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2DARRAY;
d3d12desc.Texture2DArray.MipSlice = desc.subresourceRange.mipLevel;
d3d12desc.Texture2DArray.ArraySize = desc.subresourceRange.layerCount == 0
- ? resourceDesc.arraySize
- : desc.subresourceRange.layerCount;
+ ? resourceDesc.arraySize
+ : desc.subresourceRange.layerCount;
d3d12desc.Texture2DArray.FirstArraySlice = desc.subresourceRange.baseArrayLayer;
d3d12desc.Texture2DArray.PlaneSlice =
D3DUtil::getPlaneSlice(d3d12desc.Format, desc.subresourceRange.aspectMask);
+ break;
+ case IResource::Type::Texture3D:
+ d3d12desc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE3D;
+ d3d12desc.Texture3D.MipSlice = desc.subresourceRange.mipLevel;
+ d3d12desc.Texture3D.FirstWSlice = desc.subresourceRange.baseArrayLayer;
+ d3d12desc.Texture3D.WSize =
+ resourceDesc.size.depth >> desc.subresourceRange.mipLevel;
+ break;
+ default: return SLANG_FAIL;
}
- else
- {
- d3d12desc.Texture2D.MipSlice = desc.subresourceRange.mipLevel;
- d3d12desc.Texture2D.PlaneSlice =
- D3DUtil::getPlaneSlice(d3d12desc.Format, desc.subresourceRange.aspectMask);
- }
- break;
- case IResource::Type::TextureCube:
- d3d12desc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2DARRAY;
- d3d12desc.Texture2DArray.MipSlice = desc.subresourceRange.mipLevel;
- d3d12desc.Texture2DArray.ArraySize = desc.subresourceRange.layerCount == 0
- ? resourceDesc.arraySize
- : desc.subresourceRange.layerCount;
- d3d12desc.Texture2DArray.FirstArraySlice = desc.subresourceRange.baseArrayLayer;
- d3d12desc.Texture2DArray.PlaneSlice =
- D3DUtil::getPlaneSlice(d3d12desc.Format, desc.subresourceRange.aspectMask);
- break;
- case IResource::Type::Texture3D:
- d3d12desc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE3D;
- d3d12desc.Texture3D.MipSlice = desc.subresourceRange.mipLevel;
- d3d12desc.Texture3D.FirstWSlice = desc.subresourceRange.baseArrayLayer;
- d3d12desc.Texture3D.WSize = resourceDesc.size.depth >> desc.subresourceRange.mipLevel;
- break;
- default:
- return SLANG_FAIL;
+ m_device->CreateUnorderedAccessView(
+ resourceImpl->m_resource,
+ nullptr,
+ &d3d12desc,
+ viewImpl->m_descriptor.cpuHandle);
}
- m_device->CreateUnorderedAccessView(
- resourceImpl->m_resource, nullptr, &d3d12desc, viewImpl->m_descriptor.cpuHandle);
- }
- break;
+ break;
case IResourceView::Type::ShaderResource:
- {
- SLANG_RETURN_ON_FAIL(m_cpuViewHeap->allocate(&viewImpl->m_descriptor));
- viewImpl->m_allocator = m_cpuViewHeap;
-
- // Need to construct the D3D12_SHADER_RESOURCE_VIEW_DESC because otherwise TextureCube
- // is not accessed appropriately (rather than just passing nullptr to
- // CreateShaderResourceView)
- const D3D12_RESOURCE_DESC resourceDesc =
- resourceImpl->m_resource.getResource()->GetDesc();
- const DXGI_FORMAT pixelFormat = desc.format == Format::Unknown
- ? resourceDesc.Format
- : D3DUtil::getMapFormat(desc.format);
-
- D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc;
- initSrvDesc(
- resourceImpl->getType(),
- *resourceImpl->getDesc(),
- resourceDesc,
- pixelFormat,
- desc.subresourceRange,
- srvDesc);
-
- m_device->CreateShaderResourceView(
- resourceImpl->m_resource, &srvDesc, viewImpl->m_descriptor.cpuHandle);
- }
- break;
+ {
+ SLANG_RETURN_ON_FAIL(m_cpuViewHeap->allocate(&viewImpl->m_descriptor));
+ viewImpl->m_allocator = m_cpuViewHeap;
+
+ // Need to construct the D3D12_SHADER_RESOURCE_VIEW_DESC because otherwise TextureCube
+ // is not accessed appropriately (rather than just passing nullptr to
+ // CreateShaderResourceView)
+ const D3D12_RESOURCE_DESC resourceDesc =
+ resourceImpl->m_resource.getResource()->GetDesc();
+ const DXGI_FORMAT pixelFormat = desc.format == Format::Unknown
+ ? resourceDesc.Format
+ : D3DUtil::getMapFormat(desc.format);
+
+ D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc;
+ initSrvDesc(
+ resourceImpl->getType(),
+ *resourceImpl->getDesc(),
+ resourceDesc,
+ pixelFormat,
+ desc.subresourceRange,
+ srvDesc);
+
+ m_device->CreateShaderResourceView(
+ resourceImpl->m_resource,
+ &srvDesc,
+ viewImpl->m_descriptor.cpuHandle);
+ }
+ break;
}
returnComPtr(outView, viewImpl);
@@ -1677,7 +1747,7 @@ Result DeviceImpl::createBufferView(
// Buffer view descriptors are created on demand.
viewImpl->m_descriptor = {0};
viewImpl->m_allocator = m_cpuViewHeap.get();
-
+
returnComPtr(outView, viewImpl);
return SLANG_OK;
}
@@ -1699,11 +1769,14 @@ Result DeviceImpl::createFramebuffer(IFramebuffer::Desc const& desc, IFramebuffe
auto clearValue =
static_cast<TextureResourceImpl*>(
static_cast<ResourceViewImpl*>(desc.renderTargetViews[i])->m_resource.Ptr())
- ->getDesc()
- ->optimalClearValue;
+ ->getDesc()
+ ->optimalClearValue;
if (clearValue)
{
- memcpy(&framebuffer->renderTargetClearValues[i], &clearValue->color, sizeof(ColorClearValue));
+ memcpy(
+ &framebuffer->renderTargetClearValues[i],
+ &clearValue->color,
+ sizeof(ColorClearValue));
}
}
else
@@ -1714,10 +1787,11 @@ Result DeviceImpl::createFramebuffer(IFramebuffer::Desc const& desc, IFramebuffe
framebuffer->depthStencilView = static_cast<ResourceViewImpl*>(desc.depthStencilView);
if (desc.depthStencilView)
{
- auto clearValue = static_cast<TextureResourceImpl*>(
- static_cast<ResourceViewImpl*>(desc.depthStencilView)->m_resource.Ptr())
- ->getDesc()
- ->optimalClearValue;
+ auto clearValue =
+ static_cast<TextureResourceImpl*>(
+ static_cast<ResourceViewImpl*>(desc.depthStencilView)->m_resource.Ptr())
+ ->getDesc()
+ ->optimalClearValue;
if (clearValue)
{
@@ -1735,7 +1809,8 @@ Result DeviceImpl::createFramebuffer(IFramebuffer::Desc const& desc, IFramebuffe
}
Result DeviceImpl::createFramebufferLayout(
- IFramebufferLayout::Desc const& desc, IFramebufferLayout** outLayout)
+ IFramebufferLayout::Desc const& desc,
+ IFramebufferLayout** outLayout)
{
RefPtr<FramebufferLayoutImpl> layout = new FramebufferLayoutImpl();
layout->m_renderTargets.setCount(desc.renderTargetCount);
@@ -1758,7 +1833,8 @@ Result DeviceImpl::createFramebufferLayout(
}
Result DeviceImpl::createRenderPassLayout(
- const IRenderPassLayout::Desc& desc, IRenderPassLayout** outRenderPassLayout)
+ const IRenderPassLayout::Desc& desc,
+ IRenderPassLayout** outRenderPassLayout)
{
RefPtr<RenderPassLayoutImpl> result = new RenderPassLayoutImpl();
result->init(desc);
@@ -1824,10 +1900,16 @@ Result DeviceImpl::createInputLayout(IInputLayout::Desc const& desc, IInputLayou
return SLANG_OK;
}
-const gfx::DeviceInfo& DeviceImpl::getDeviceInfo() const { return m_info; }
+const gfx::DeviceInfo& DeviceImpl::getDeviceInfo() const
+{
+ return m_info;
+}
Result DeviceImpl::readBufferResource(
- IBufferResource* bufferIn, Offset offset, Size size, ISlangBlob** outBlob)
+ IBufferResource* bufferIn,
+ Offset offset,
+ Size size,
+ ISlangBlob** outBlob)
{
BufferResourceImpl* buffer = static_cast<BufferResourceImpl*>(bufferIn);
@@ -1876,7 +1958,7 @@ Result DeviceImpl::readBufferResource(
List<uint8_t> blobData;
{
UINT8* data;
- D3D12_RANGE readRange = { 0, size };
+ D3D12_RANGE readRange = {0, size};
SLANG_RETURN_ON_FAIL(
stageBufRef.getResource()->Map(0, &readRange, reinterpret_cast<void**>(&data)));
@@ -1893,7 +1975,9 @@ Result DeviceImpl::readBufferResource(
}
Result DeviceImpl::createProgram(
- const IShaderProgram::Desc& desc, IShaderProgram** outProgram, ISlangBlob** outDiagnosticBlob)
+ const IShaderProgram::Desc& desc,
+ IShaderProgram** outProgram,
+ ISlangBlob** outDiagnosticBlob)
{
RefPtr<ShaderProgramImpl> shaderProgram = new ShaderProgramImpl();
shaderProgram->init(desc);
@@ -1941,13 +2025,16 @@ Result DeviceImpl::createShaderObject(ShaderObjectLayoutBase* layout, IShaderObj
{
RefPtr<ShaderObjectImpl> shaderObject;
SLANG_RETURN_ON_FAIL(ShaderObjectImpl::create(
- this, reinterpret_cast<ShaderObjectLayoutImpl*>(layout), shaderObject.writeRef()));
+ this,
+ reinterpret_cast<ShaderObjectLayoutImpl*>(layout),
+ shaderObject.writeRef()));
returnComPtr(outObject, shaderObject);
return SLANG_OK;
}
Result DeviceImpl::createMutableShaderObject(
- ShaderObjectLayoutBase* layout, IShaderObject** outObject)
+ ShaderObjectLayoutBase* layout,
+ IShaderObject** outObject)
{
auto result = createShaderObject(layout, outObject);
SLANG_RETURN_ON_FAIL(result);
@@ -1961,7 +2048,11 @@ Result DeviceImpl::createMutableRootShaderObject(IShaderProgram* program, IShade
result->init(this);
auto programImpl = static_cast<ShaderProgramImpl*>(program);
result->resetImpl(
- this, programImpl->m_rootObjectLayout, m_cpuViewHeap.Ptr(), m_cpuSamplerHeap.Ptr(), true);
+ this,
+ programImpl->m_rootObjectLayout,
+ m_cpuViewHeap.Ptr(),
+ m_cpuSamplerHeap.Ptr(),
+ true);
returnComPtr(outObject, result);
return SLANG_OK;
}
@@ -1976,7 +2067,8 @@ Result DeviceImpl::createShaderTable(const IShaderTable::Desc& desc, IShaderTabl
}
Result DeviceImpl::createGraphicsPipelineState(
- const GraphicsPipelineStateDesc& desc, IPipelineState** outState)
+ const GraphicsPipelineStateDesc& desc,
+ IPipelineState** outState)
{
RefPtr<PipelineStateImpl> pipelineStateImpl = new PipelineStateImpl(this);
pipelineStateImpl->init(desc);
@@ -1985,7 +2077,8 @@ Result DeviceImpl::createGraphicsPipelineState(
}
Result DeviceImpl::createComputePipelineState(
- const ComputePipelineStateDesc& desc, IPipelineState** outState)
+ const ComputePipelineStateDesc& desc,
+ IPipelineState** outState)
{
RefPtr<PipelineStateImpl> pipelineStateImpl = new PipelineStateImpl(this);
pipelineStateImpl->init(desc);
@@ -2011,17 +2104,17 @@ void DeviceImpl::submitResourceCommandsAndWait(const DeviceImpl::ResourceCommand
void DeviceImpl::processExperimentalFeaturesDesc(SharedLibrary::Handle d3dModule, void* inDesc)
{
- typedef HRESULT(WINAPI* PFN_D3D12_ENABLE_EXPERIMENTAL_FEATURES)(
- UINT NumFeatures,
+ typedef HRESULT(WINAPI * PFN_D3D12_ENABLE_EXPERIMENTAL_FEATURES)(
+ UINT NumFeatures,
const IID* pIIDs,
void* pConfigurationStructs,
- UINT* pConfigurationStructSizes
- );
+ UINT* pConfigurationStructSizes);
D3D12ExperimentalFeaturesDesc desc = {};
memcpy(&desc, inDesc, sizeof(desc));
- auto enableExperimentalFeaturesFunc =
- (PFN_D3D12_ENABLE_EXPERIMENTAL_FEATURES)loadProc(d3dModule, "D3D12EnableExperimentalFeatures");
+ auto enableExperimentalFeaturesFunc = (PFN_D3D12_ENABLE_EXPERIMENTAL_FEATURES)loadProc(
+ d3dModule,
+ "D3D12EnableExperimentalFeatures");
if (!enableExperimentalFeaturesFunc)
{
getDebugCallback()->handleMessage(
@@ -2031,7 +2124,11 @@ void DeviceImpl::processExperimentalFeaturesDesc(SharedLibrary::Handle d3dModule
"not found.");
return;
}
- if (!SLANG_SUCCEEDED(enableExperimentalFeaturesFunc(desc.numFeatures, (IID*)desc.featureIIDs, desc.configurationStructs, desc.configurationStructSizes)))
+ if (!SLANG_SUCCEEDED(enableExperimentalFeaturesFunc(
+ desc.numFeatures,
+ (IID*)desc.featureIIDs,
+ desc.configurationStructs,
+ desc.configurationStructSizes)))
{
getDebugCallback()->handleMessage(
gfx::DebugMessageType::Warning,
@@ -2049,23 +2146,23 @@ Result DeviceImpl::createQueryPool(const IQueryPool::Desc& desc, IQueryPool** ou
case QueryType::AccelerationStructureCompactedSize:
case QueryType::AccelerationStructureSerializedSize:
case QueryType::AccelerationStructureCurrentSize:
- {
- RefPtr<PlainBufferProxyQueryPoolImpl> queryPoolImpl =
- new PlainBufferProxyQueryPoolImpl();
- uint32_t stride = 8;
- if (desc.type == QueryType::AccelerationStructureSerializedSize)
- stride = 16;
- SLANG_RETURN_ON_FAIL(queryPoolImpl->init(desc, this, stride));
- returnComPtr(outState, queryPoolImpl);
- return SLANG_OK;
- }
+ {
+ RefPtr<PlainBufferProxyQueryPoolImpl> queryPoolImpl =
+ new PlainBufferProxyQueryPoolImpl();
+ uint32_t stride = 8;
+ if (desc.type == QueryType::AccelerationStructureSerializedSize)
+ stride = 16;
+ SLANG_RETURN_ON_FAIL(queryPoolImpl->init(desc, this, stride));
+ returnComPtr(outState, queryPoolImpl);
+ return SLANG_OK;
+ }
default:
- {
- RefPtr<QueryPoolImpl> queryPoolImpl = new QueryPoolImpl();
- SLANG_RETURN_ON_FAIL(queryPoolImpl->init(desc, this));
- returnComPtr(outState, queryPoolImpl);
- return SLANG_OK;
- }
+ {
+ RefPtr<QueryPoolImpl> queryPoolImpl = new QueryPoolImpl();
+ SLANG_RETURN_ON_FAIL(queryPoolImpl->init(desc, this));
+ returnComPtr(outState, queryPoolImpl);
+ return SLANG_OK;
+ }
}
}
@@ -2078,7 +2175,11 @@ Result DeviceImpl::createFence(const IFence::Desc& desc, IFence** outFence)
}
Result DeviceImpl::waitForFences(
- GfxCount fenceCount, IFence** fences, uint64_t* fenceValues, bool waitForAll, uint64_t timeout)
+ GfxCount fenceCount,
+ IFence** fences,
+ uint64_t* fenceValues,
+ bool waitForAll,
+ uint64_t timeout)
{
ShortList<HANDLE> waitHandles;
for (GfxCount i = 0; i < fenceCount; ++i)
@@ -2118,7 +2219,8 @@ Result DeviceImpl::getAccelerationStructurePrebuildInfo(
}
Result DeviceImpl::createAccelerationStructure(
- const IAccelerationStructure::CreateDesc& desc, IAccelerationStructure** outAS)
+ const IAccelerationStructure::CreateDesc& desc,
+ IAccelerationStructure** outAS)
{
#if SLANG_GFX_HAS_DXR_SUPPORT
RefPtr<AccelerationStructureImpl> result = new AccelerationStructureImpl();
@@ -2139,13 +2241,14 @@ Result DeviceImpl::createAccelerationStructure(
returnComPtr(outAS, result);
return SLANG_OK;
#else
- * outAS = nullptr;
+ *outAS = nullptr;
return SLANG_FAIL;
#endif
}
Result DeviceImpl::createRayTracingPipelineState(
- const RayTracingPipelineStateDesc& inDesc, IPipelineState** outState)
+ const RayTracingPipelineStateDesc& inDesc,
+ IPipelineState** outState)
{
if (!m_device5)
{
@@ -2203,7 +2306,10 @@ void* DeviceImpl::loadProc(SharedLibrary::Handle module, char const* name)
return proc;
}
-DeviceImpl::~DeviceImpl() { m_shaderObjectLayoutCache = decltype(m_shaderObjectLayoutCache)(); }
+DeviceImpl::~DeviceImpl()
+{
+ m_shaderObjectLayoutCache = decltype(m_shaderObjectLayoutCache)();
+}
} // namespace d3d12
diff --git a/tools/gfx/d3d12/d3d12-device.h b/tools/gfx/d3d12/d3d12-device.h
index a38e3c68e..31756d3e9 100644
--- a/tools/gfx/d3d12/d3d12-device.h
+++ b/tools/gfx/d3d12/d3d12-device.h
@@ -2,8 +2,8 @@
#pragma once
#include "d3d12-command-buffer.h"
#include "d3d12-command-queue.h"
-#include "d3d12-transient-heap.h"
#include "d3d12-texture.h"
+#include "d3d12-transient-heap.h"
#include <d3d12.h>
#include <d3d12sdklayers.h>
@@ -17,7 +17,9 @@ using namespace Slang;
// Define function pointer types for PIX library.
typedef HRESULT(WINAPI* PFN_BeginEventOnCommandList)(
- ID3D12GraphicsCommandList* commandList, UINT64 color, PCSTR formatString);
+ ID3D12GraphicsCommandList* commandList,
+ UINT64 color,
+ PCSTR formatString);
typedef HRESULT(WINAPI* PFN_EndEventOnCommandList)(ID3D12GraphicsCommandList* commandList);
struct D3D12DeviceInfo
@@ -74,7 +76,7 @@ public:
// around CPU-visible heaps for storing shader-objects' descriptors in a format
// that is ready for copying into the GPU-visible heaps as needed.
//
- RefPtr<D3D12GeneralExpandingDescriptorHeap> m_cpuViewHeap; ///< Cbv, Srv, Uav
+ RefPtr<D3D12GeneralExpandingDescriptorHeap> m_cpuViewHeap; ///< Cbv, Srv, Uav
RefPtr<D3D12GeneralExpandingDescriptorHeap> m_cpuSamplerHeap; ///< Heap for samplers
// Dll entry points
@@ -97,17 +99,22 @@ public:
public:
virtual SLANG_NO_THROW SlangResult SLANG_MCALL initialize(const Desc& desc) override;
virtual SLANG_NO_THROW Result SLANG_MCALL
- getFormatSupportedResourceStates(Format format, ResourceStateSet* outStates) override;
+ getFormatSupportedResourceStates(Format format, ResourceStateSet* outStates) override;
virtual SLANG_NO_THROW Result SLANG_MCALL
- createCommandQueue(const ICommandQueue::Desc& desc, ICommandQueue** outQueue) override;
+ createCommandQueue(const ICommandQueue::Desc& desc, ICommandQueue** outQueue) override;
virtual SLANG_NO_THROW Result SLANG_MCALL createTransientResourceHeap(
- const ITransientResourceHeap::Desc& desc, ITransientResourceHeap** outHeap) override;
+ const ITransientResourceHeap::Desc& desc,
+ ITransientResourceHeap** outHeap) override;
virtual SLANG_NO_THROW Result SLANG_MCALL createSwapchain(
- const ISwapchain::Desc& desc, WindowHandle window, ISwapchain** outSwapchain) override;
+ const ISwapchain::Desc& desc,
+ WindowHandle window,
+ ISwapchain** outSwapchain) override;
virtual SLANG_NO_THROW Result SLANG_MCALL getTextureAllocationInfo(
- const ITextureResource::Desc& desc, Size* outSize, Size* outAlignment) override;
+ const ITextureResource::Desc& desc,
+ Size* outSize,
+ Size* outAlignment) override;
virtual SLANG_NO_THROW Result SLANG_MCALL getTextureRowAlignment(Size* outAlignment) override;
virtual SLANG_NO_THROW Result SLANG_MCALL createTextureResource(
const ITextureResource::Desc& desc,
@@ -127,7 +134,7 @@ public:
IBufferResource** outResource) override;
virtual SLANG_NO_THROW Result SLANG_MCALL
- createSamplerState(ISamplerState::Desc const& desc, ISamplerState** outSampler) override;
+ createSamplerState(ISamplerState::Desc const& desc, ISamplerState** outSampler) override;
virtual SLANG_NO_THROW Result SLANG_MCALL createTextureView(
ITextureResource* texture,
@@ -140,42 +147,49 @@ public:
IResourceView** outView) override;
virtual SLANG_NO_THROW Result SLANG_MCALL
- createFramebuffer(IFramebuffer::Desc const& desc, IFramebuffer** outFrameBuffer) override;
+ createFramebuffer(IFramebuffer::Desc const& desc, IFramebuffer** outFrameBuffer) override;
virtual SLANG_NO_THROW Result SLANG_MCALL createFramebufferLayout(
- IFramebufferLayout::Desc const& desc, IFramebufferLayout** outLayout) override;
+ IFramebufferLayout::Desc const& desc,
+ IFramebufferLayout** outLayout) override;
virtual SLANG_NO_THROW Result SLANG_MCALL createRenderPassLayout(
- const IRenderPassLayout::Desc& desc, IRenderPassLayout** outRenderPassLayout) override;
+ const IRenderPassLayout::Desc& desc,
+ IRenderPassLayout** outRenderPassLayout) override;
virtual SLANG_NO_THROW Result SLANG_MCALL
- createInputLayout(IInputLayout::Desc const& desc, IInputLayout** outLayout) override;
+ createInputLayout(IInputLayout::Desc const& desc, IInputLayout** outLayout) override;
virtual Result createShaderObjectLayout(
- slang::ISession* session, slang::TypeLayoutReflection* typeLayout, ShaderObjectLayoutBase** outLayout) override;
- virtual Result createShaderObject(
- ShaderObjectLayoutBase* layout, IShaderObject** outObject) override;
+ slang::ISession* session,
+ slang::TypeLayoutReflection* typeLayout,
+ ShaderObjectLayoutBase** outLayout) override;
+ virtual Result createShaderObject(ShaderObjectLayoutBase* layout, IShaderObject** outObject)
+ override;
virtual Result createMutableShaderObject(
- ShaderObjectLayoutBase* layout, IShaderObject** outObject) override;
+ ShaderObjectLayoutBase* layout,
+ IShaderObject** outObject) override;
virtual SLANG_NO_THROW Result SLANG_MCALL
- createMutableRootShaderObject(IShaderProgram* program, IShaderObject** outObject) override;
+ createMutableRootShaderObject(IShaderProgram* program, IShaderObject** outObject) override;
virtual SLANG_NO_THROW Result SLANG_MCALL
- createShaderTable(const IShaderTable::Desc& desc, IShaderTable** outShaderTable) override;
+ createShaderTable(const IShaderTable::Desc& desc, IShaderTable** outShaderTable) override;
virtual SLANG_NO_THROW Result SLANG_MCALL createProgram(
const IShaderProgram::Desc& desc,
IShaderProgram** outProgram,
ISlangBlob** outDiagnostics) override;
virtual SLANG_NO_THROW Result SLANG_MCALL createGraphicsPipelineState(
- const GraphicsPipelineStateDesc& desc, IPipelineState** outState) override;
+ const GraphicsPipelineStateDesc& desc,
+ IPipelineState** outState) override;
virtual SLANG_NO_THROW Result SLANG_MCALL createComputePipelineState(
- const ComputePipelineStateDesc& desc, IPipelineState** outState) override;
+ const ComputePipelineStateDesc& desc,
+ IPipelineState** outState) override;
virtual SLANG_NO_THROW Result SLANG_MCALL
- createQueryPool(const IQueryPool::Desc& desc, IQueryPool** outState) override;
+ createQueryPool(const IQueryPool::Desc& desc, IQueryPool** outState) override;
virtual SLANG_NO_THROW Result SLANG_MCALL
- createFence(const IFence::Desc& desc, IFence** outFence) override;
+ createFence(const IFence::Desc& desc, IFence** outFence) override;
virtual SLANG_NO_THROW Result SLANG_MCALL waitForFences(
GfxCount fenceCount,
@@ -192,12 +206,15 @@ public:
Size* outPixelSize) override;
virtual SLANG_NO_THROW SlangResult SLANG_MCALL readBufferResource(
- IBufferResource* resource, Offset offset, Size size, ISlangBlob** outBlob) override;
+ IBufferResource* resource,
+ Offset offset,
+ Size size,
+ ISlangBlob** outBlob) override;
virtual SLANG_NO_THROW const gfx::DeviceInfo& SLANG_MCALL getDeviceInfo() const override;
virtual SLANG_NO_THROW Result SLANG_MCALL
- getNativeDeviceHandles(InteropHandles* outHandles) override;
+ getNativeDeviceHandles(InteropHandles* outHandles) override;
~DeviceImpl();
@@ -205,9 +222,11 @@ public:
const IAccelerationStructure::BuildInputs& buildInputs,
IAccelerationStructure::PrebuildInfo* outPrebuildInfo) override;
virtual SLANG_NO_THROW Result SLANG_MCALL createAccelerationStructure(
- const IAccelerationStructure::CreateDesc& desc, IAccelerationStructure** outView) override;
+ const IAccelerationStructure::CreateDesc& desc,
+ IAccelerationStructure** outView) override;
virtual SLANG_NO_THROW Result SLANG_MCALL createRayTracingPipelineState(
- const RayTracingPipelineStateDesc& desc, IPipelineState** outState) override;
+ const RayTracingPipelineStateDesc& desc,
+ IPipelineState** outState) override;
public:
static void* loadProc(SharedLibrary::Handle module, char const* name);
@@ -250,6 +269,7 @@ public:
};
ResourceCommandRecordInfo encodeResourceCommands();
void submitResourceCommandsAndWait(const ResourceCommandRecordInfo& info);
+
private:
void processExperimentalFeaturesDesc(SharedLibrary::Handle d3dModule, void* desc);
};
diff --git a/tools/gfx/d3d12/d3d12-fence.cpp b/tools/gfx/d3d12/d3d12-fence.cpp
index 124d9354c..8b7d47440 100644
--- a/tools/gfx/d3d12/d3d12-fence.cpp
+++ b/tools/gfx/d3d12/d3d12-fence.cpp
@@ -60,7 +60,11 @@ Result FenceImpl::getSharedHandle(InteropHandle* outHandle)
ComPtr<ID3D12Device> devicePtr;
m_fence->GetDevice(IID_PPV_ARGS(devicePtr.writeRef()));
SLANG_RETURN_ON_FAIL(devicePtr->CreateSharedHandle(
- m_fence, NULL, GENERIC_ALL, nullptr, (HANDLE*)&outHandle->handleValue));
+ m_fence,
+ NULL,
+ GENERIC_ALL,
+ nullptr,
+ (HANDLE*)&outHandle->handleValue));
outHandle->api = InteropHandleAPI::D3D12;
sharedHandle = *outHandle;
return SLANG_OK;
diff --git a/tools/gfx/d3d12/d3d12-fence.h b/tools/gfx/d3d12/d3d12-fence.h
index 9a109ae65..3e735ef78 100644
--- a/tools/gfx/d3d12/d3d12-fence.h
+++ b/tools/gfx/d3d12/d3d12-fence.h
@@ -30,7 +30,7 @@ public:
virtual SLANG_NO_THROW Result SLANG_MCALL getSharedHandle(InteropHandle* outHandle) override;
virtual SLANG_NO_THROW Result SLANG_MCALL
- getNativeHandle(InteropHandle* outNativeHandle) override;
+ getNativeHandle(InteropHandle* outNativeHandle) override;
};
} // namespace d3d12
diff --git a/tools/gfx/d3d12/d3d12-helper-functions.cpp b/tools/gfx/d3d12/d3d12-helper-functions.cpp
index 077645b95..3ce9b872e 100644
--- a/tools/gfx/d3d12/d3d12-helper-functions.cpp
+++ b/tools/gfx/d3d12/d3d12-helper-functions.cpp
@@ -2,18 +2,18 @@
#include "d3d12-helper-functions.h"
#ifdef GFX_NVAPI
-# include "../nvapi/nvapi-include.h"
+#include "../nvapi/nvapi-include.h"
#endif
#include "../nvapi/nvapi-util.h"
#include "d3d12-buffer.h"
-#include "d3d12-transient-heap.h"
#include "d3d12-query.h"
+#include "d3d12-transient-heap.h"
#ifdef _DEBUG
-# define ENABLE_DEBUG_LAYER 1
+#define ENABLE_DEBUG_LAYER 1
#else
-# define ENABLE_DEBUG_LAYER 0
+#define ENABLE_DEBUG_LAYER 0
#endif
namespace gfx
@@ -42,16 +42,12 @@ D3D12_RESOURCE_FLAGS calcResourceFlag(ResourceState state)
{
switch (state)
{
- case ResourceState::RenderTarget:
- return D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET;
+ case ResourceState::RenderTarget: return D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET;
case ResourceState::DepthRead:
- case ResourceState::DepthWrite:
- return D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL;
+ case ResourceState::DepthWrite: return D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL;
case ResourceState::UnorderedAccess:
- case ResourceState::AccelerationStructure:
- return D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
- default:
- return D3D12_RESOURCE_FLAG_NONE;
+ case ResourceState::AccelerationStructure: return D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
+ default: return D3D12_RESOURCE_FLAG_NONE;
}
}
@@ -71,19 +67,15 @@ D3D12_RESOURCE_DIMENSION calcResourceDimension(IResource::Type type)
{
switch (type)
{
- case IResource::Type::Buffer:
- return D3D12_RESOURCE_DIMENSION_BUFFER;
- case IResource::Type::Texture1D:
- return D3D12_RESOURCE_DIMENSION_TEXTURE1D;
+ case IResource::Type::Buffer: return D3D12_RESOURCE_DIMENSION_BUFFER;
+ case IResource::Type::Texture1D: return D3D12_RESOURCE_DIMENSION_TEXTURE1D;
case IResource::Type::TextureCube:
case IResource::Type::Texture2D:
- {
- return D3D12_RESOURCE_DIMENSION_TEXTURE2D;
- }
- case IResource::Type::Texture3D:
- return D3D12_RESOURCE_DIMENSION_TEXTURE3D;
- default:
- return D3D12_RESOURCE_DIMENSION_UNKNOWN;
+ {
+ return D3D12_RESOURCE_DIMENSION_TEXTURE2D;
+ }
+ case IResource::Type::Texture3D: return D3D12_RESOURCE_DIMENSION_TEXTURE3D;
+ default: return D3D12_RESOURCE_DIMENSION_UNKNOWN;
}
}
@@ -91,16 +83,12 @@ DXGI_FORMAT getTypelessFormatFromDepthFormat(Format format)
{
switch (format)
{
- case Format::D16_UNORM:
- return DXGI_FORMAT_R16_TYPELESS;
- case Format::D32_FLOAT:
- return DXGI_FORMAT_R32_TYPELESS;
- case Format::D32_FLOAT_S8_UINT:
- return DXGI_FORMAT_R32G8X24_TYPELESS;
- //case Format::D24_UNORM_S8_UINT:
- // return DXGI_FORMAT_R24G8_TYPELESS;
- default:
- return D3DUtil::getMapFormat(format);
+ case Format::D16_UNORM: return DXGI_FORMAT_R16_TYPELESS;
+ case Format::D32_FLOAT: return DXGI_FORMAT_R32_TYPELESS;
+ case Format::D32_FLOAT_S8_UINT: return DXGI_FORMAT_R32G8X24_TYPELESS;
+ // case Format::D24_UNORM_S8_UINT:
+ // return DXGI_FORMAT_R24G8_TYPELESS;
+ default: return D3DUtil::getMapFormat(format);
}
}
@@ -111,10 +99,8 @@ bool isTypelessDepthFormat(DXGI_FORMAT format)
case DXGI_FORMAT_R16_TYPELESS:
case DXGI_FORMAT_R32_TYPELESS:
case DXGI_FORMAT_R32G8X24_TYPELESS:
- case DXGI_FORMAT_R24G8_TYPELESS:
- return true;
- default:
- return false;
+ case DXGI_FORMAT_R24G8_TYPELESS: return true;
+ default: return false;
}
}
@@ -122,12 +108,10 @@ D3D12_FILTER_TYPE translateFilterMode(TextureFilteringMode mode)
{
switch (mode)
{
- default:
- return D3D12_FILTER_TYPE(0);
+ default: return D3D12_FILTER_TYPE(0);
-#define CASE(SRC, DST) \
- case TextureFilteringMode::SRC: \
- return D3D12_FILTER_TYPE_##DST
+#define CASE(SRC, DST) \
+ case TextureFilteringMode::SRC: return D3D12_FILTER_TYPE_##DST
CASE(Point, POINT);
CASE(Linear, LINEAR);
@@ -140,12 +124,10 @@ D3D12_FILTER_REDUCTION_TYPE translateFilterReduction(TextureReductionOp op)
{
switch (op)
{
- default:
- return D3D12_FILTER_REDUCTION_TYPE(0);
+ default: return D3D12_FILTER_REDUCTION_TYPE(0);
-#define CASE(SRC, DST) \
- case TextureReductionOp::SRC: \
- return D3D12_FILTER_REDUCTION_TYPE_##DST
+#define CASE(SRC, DST) \
+ case TextureReductionOp::SRC: return D3D12_FILTER_REDUCTION_TYPE_##DST
CASE(Average, STANDARD);
CASE(Comparison, COMPARISON);
@@ -160,12 +142,10 @@ D3D12_TEXTURE_ADDRESS_MODE translateAddressingMode(TextureAddressingMode mode)
{
switch (mode)
{
- default:
- return D3D12_TEXTURE_ADDRESS_MODE(0);
+ default: return D3D12_TEXTURE_ADDRESS_MODE(0);
-#define CASE(SRC, DST) \
- case TextureAddressingMode::SRC: \
- return D3D12_TEXTURE_ADDRESS_MODE_##DST
+#define CASE(SRC, DST) \
+ case TextureAddressingMode::SRC: return D3D12_TEXTURE_ADDRESS_MODE_##DST
CASE(Wrap, WRAP);
CASE(ClampToEdge, CLAMP);
@@ -185,9 +165,8 @@ D3D12_COMPARISON_FUNC translateComparisonFunc(ComparisonFunc func)
// TODO: need to report failures
return D3D12_COMPARISON_FUNC_ALWAYS;
-#define CASE(FROM, TO) \
- case ComparisonFunc::FROM: \
- return D3D12_COMPARISON_FUNC_##TO
+#define CASE(FROM, TO) \
+ case ComparisonFunc::FROM: return D3D12_COMPARISON_FUNC_##TO
CASE(Never, NEVER);
CASE(Less, LESS);
@@ -224,8 +203,8 @@ void initSrvDesc(
descOut = D3D12_SHADER_RESOURCE_VIEW_DESC();
descOut.Format = (pixelFormat == DXGI_FORMAT_UNKNOWN)
- ? D3DUtil::calcFormat(D3DUtil::USAGE_SRV, desc.Format)
- : pixelFormat;
+ ? D3DUtil::calcFormat(D3DUtil::USAGE_SRV, desc.Format)
+ : pixelFormat;
descOut.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
if (desc.DepthOrArraySize == 1)
{
@@ -234,29 +213,30 @@ void initSrvDesc(
case D3D12_RESOURCE_DIMENSION_TEXTURE1D:
descOut.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE1D;
descOut.Texture1D.MipLevels = subresourceRange.mipLevelCount == 0
- ? desc.MipLevels - subresourceRange.mipLevel
- : subresourceRange.mipLevelCount;
+ ? desc.MipLevels - subresourceRange.mipLevel
+ : subresourceRange.mipLevelCount;
descOut.Texture1D.MostDetailedMip = subresourceRange.mipLevel;
break;
case D3D12_RESOURCE_DIMENSION_TEXTURE2D:
- descOut.ViewDimension = textureDesc.sampleDesc.numSamples > 1 ? D3D12_SRV_DIMENSION_TEXTURE2DMS : D3D12_SRV_DIMENSION_TEXTURE2D;
+ descOut.ViewDimension = textureDesc.sampleDesc.numSamples > 1
+ ? D3D12_SRV_DIMENSION_TEXTURE2DMS
+ : D3D12_SRV_DIMENSION_TEXTURE2D;
descOut.Texture2D.PlaneSlice =
D3DUtil::getPlaneSlice(descOut.Format, subresourceRange.aspectMask);
descOut.Texture2D.ResourceMinLODClamp = 0.0f;
descOut.Texture2D.MipLevels = subresourceRange.mipLevelCount == 0
- ? desc.MipLevels - subresourceRange.mipLevel
- : subresourceRange.mipLevelCount;
+ ? desc.MipLevels - subresourceRange.mipLevel
+ : subresourceRange.mipLevelCount;
descOut.Texture2D.MostDetailedMip = subresourceRange.mipLevel;
break;
case D3D12_RESOURCE_DIMENSION_TEXTURE3D:
descOut.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE3D;
descOut.Texture3D.MipLevels = subresourceRange.mipLevelCount == 0
- ? desc.MipLevels - subresourceRange.mipLevel
- : subresourceRange.mipLevelCount;
+ ? desc.MipLevels - subresourceRange.mipLevel
+ : subresourceRange.mipLevelCount;
descOut.Texture3D.MostDetailedMip = subresourceRange.mipLevel;
break;
- default:
- assert(!"Unknown dimension");
+ default: assert(!"Unknown dimension");
}
}
else if (resourceType == IResource::Type::TextureCube)
@@ -266,12 +246,12 @@ void initSrvDesc(
descOut.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBEARRAY;
descOut.TextureCubeArray.NumCubes = subresourceRange.layerCount == 0
- ? textureDesc.arraySize
- : subresourceRange.layerCount / 6;
+ ? textureDesc.arraySize
+ : subresourceRange.layerCount / 6;
descOut.TextureCubeArray.First2DArrayFace = subresourceRange.baseArrayLayer;
descOut.TextureCubeArray.MipLevels = subresourceRange.mipLevelCount == 0
- ? desc.MipLevels - subresourceRange.mipLevel
- : subresourceRange.mipLevelCount;
+ ? desc.MipLevels - subresourceRange.mipLevel
+ : subresourceRange.mipLevelCount;
descOut.TextureCubeArray.MostDetailedMip = subresourceRange.mipLevel;
descOut.TextureCubeArray.ResourceMinLODClamp = 0;
}
@@ -280,8 +260,8 @@ void initSrvDesc(
descOut.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBE;
descOut.TextureCube.MipLevels = subresourceRange.mipLevelCount == 0
- ? desc.MipLevels - subresourceRange.mipLevel
- : subresourceRange.mipLevelCount;
+ ? desc.MipLevels - subresourceRange.mipLevel
+ : subresourceRange.mipLevelCount;
descOut.TextureCube.MostDetailedMip = subresourceRange.mipLevel;
descOut.TextureCube.ResourceMinLODClamp = 0;
}
@@ -296,60 +276,62 @@ void initSrvDesc(
descOut.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE1DARRAY;
descOut.Texture1D.MostDetailedMip = subresourceRange.mipLevel;
descOut.Texture1D.MipLevels = subresourceRange.mipLevelCount == 0
- ? desc.MipLevels
- : subresourceRange.mipLevelCount;
+ ? desc.MipLevels
+ : subresourceRange.mipLevelCount;
descOut.Texture1DArray.ArraySize = subresourceRange.layerCount == 0
- ? desc.DepthOrArraySize
- : subresourceRange.layerCount;
+ ? desc.DepthOrArraySize
+ : subresourceRange.layerCount;
descOut.Texture1DArray.FirstArraySlice = subresourceRange.baseArrayLayer;
descOut.Texture1DArray.ResourceMinLODClamp = 0;
descOut.Texture1DArray.MostDetailedMip = subresourceRange.mipLevel;
descOut.Texture1DArray.MipLevels = subresourceRange.mipLevelCount == 0
- ? desc.MipLevels - subresourceRange.mipLevel
- : subresourceRange.mipLevelCount;
+ ? desc.MipLevels - subresourceRange.mipLevel
+ : subresourceRange.mipLevelCount;
break;
case D3D12_RESOURCE_DIMENSION_TEXTURE2D:
- descOut.ViewDimension = textureDesc.sampleDesc.numSamples > 1 ? D3D12_SRV_DIMENSION_TEXTURE2DMSARRAY : D3D12_SRV_DIMENSION_TEXTURE2DARRAY;
- if(descOut.ViewDimension == D3D12_SRV_DIMENSION_TEXTURE2DARRAY)
+ descOut.ViewDimension = textureDesc.sampleDesc.numSamples > 1
+ ? D3D12_SRV_DIMENSION_TEXTURE2DMSARRAY
+ : D3D12_SRV_DIMENSION_TEXTURE2DARRAY;
+ if (descOut.ViewDimension == D3D12_SRV_DIMENSION_TEXTURE2DARRAY)
{
descOut.Texture2DArray.ArraySize = subresourceRange.layerCount == 0
- ? desc.DepthOrArraySize
- : subresourceRange.layerCount;
+ ? desc.DepthOrArraySize
+ : subresourceRange.layerCount;
descOut.Texture2DArray.FirstArraySlice = subresourceRange.baseArrayLayer;
descOut.Texture2DArray.PlaneSlice =
D3DUtil::getPlaneSlice(descOut.Format, subresourceRange.aspectMask);
descOut.Texture2DArray.ResourceMinLODClamp = 0;
descOut.Texture2DArray.MostDetailedMip = subresourceRange.mipLevel;
descOut.Texture2DArray.MipLevels = subresourceRange.mipLevelCount == 0
- ? desc.MipLevels - subresourceRange.mipLevel
- : subresourceRange.mipLevelCount;
+ ? desc.MipLevels - subresourceRange.mipLevel
+ : subresourceRange.mipLevelCount;
}
else
{
assert(descOut.ViewDimension == D3D12_SRV_DIMENSION_TEXTURE2DMSARRAY);
descOut.Texture2DMSArray.FirstArraySlice = subresourceRange.baseArrayLayer;
descOut.Texture2DMSArray.ArraySize = subresourceRange.layerCount == 0
- ? desc.DepthOrArraySize
- : subresourceRange.layerCount;
+ ? desc.DepthOrArraySize
+ : subresourceRange.layerCount;
}
-
+
break;
case D3D12_RESOURCE_DIMENSION_TEXTURE3D:
descOut.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE3D;
descOut.Texture3D.MostDetailedMip = subresourceRange.mipLevel;
descOut.Texture3D.MipLevels = subresourceRange.mipLevelCount == 0
- ? desc.MipLevels
- : subresourceRange.mipLevelCount;
+ ? desc.MipLevels
+ : subresourceRange.mipLevelCount;
break;
- default:
- assert(!"Unknown dimension");
+ default: assert(!"Unknown dimension");
}
}
}
Result initTextureResourceDesc(
- D3D12_RESOURCE_DESC& resourceDesc, const ITextureResource::Desc& srcDesc)
+ D3D12_RESOURCE_DESC& resourceDesc,
+ const ITextureResource::Desc& srcDesc)
{
const DXGI_FORMAT pixelFormat = D3DUtil::getMapFormat(srcDesc.format);
if (pixelFormat == DXGI_FORMAT_UNKNOWN)
@@ -385,7 +367,7 @@ Result initTextureResourceDesc(
if (isDepthFormat(srcDesc.format) &&
(srcDesc.allowedStates.contains(ResourceState::ShaderResource) ||
- srcDesc.allowedStates.contains(ResourceState::UnorderedAccess)))
+ srcDesc.allowedStates.contains(ResourceState::UnorderedAccess)))
{
resourceDesc.Format = getTypelessFormatFromDepthFormat(srcDesc.format);
}
@@ -424,7 +406,10 @@ Result uploadBufferDataImpl(
if (buffer->getDesc()->memoryType != MemoryType::Upload)
{
SLANG_RETURN_ON_FAIL(transientHeap->allocateStagingBuffer(
- size, uploadResource, uploadResourceOffset, MemoryType::Upload));
+ size,
+ uploadResource,
+ uploadResourceOffset,
+ MemoryType::Upload));
}
else
{
@@ -432,8 +417,8 @@ Result uploadBufferDataImpl(
}
D3D12Resource& uploadResourceRef =
(buffer->getDesc()->memoryType == MemoryType::Upload)
- ? buffer->m_resource
- : static_cast<BufferResourceImpl*>(uploadResource)->m_resource;
+ ? buffer->m_resource
+ : static_cast<BufferResourceImpl*>(uploadResource)->m_resource;
D3D12_RANGE readRange = {};
readRange.Begin = 0;
@@ -468,122 +453,105 @@ Result createNullDescriptor(
switch (bindingRange.bindingType)
{
case slang::BindingType::ConstantBuffer:
- {
- D3D12_CONSTANT_BUFFER_VIEW_DESC cbvDesc = {};
- cbvDesc.BufferLocation = 0;
- cbvDesc.SizeInBytes = 0;
- d3dDevice->CreateConstantBufferView(&cbvDesc, destDescriptor);
- }
- break;
+ {
+ D3D12_CONSTANT_BUFFER_VIEW_DESC cbvDesc = {};
+ cbvDesc.BufferLocation = 0;
+ cbvDesc.SizeInBytes = 0;
+ d3dDevice->CreateConstantBufferView(&cbvDesc, destDescriptor);
+ }
+ break;
case slang::BindingType::MutableRawBuffer:
- {
- D3D12_UNORDERED_ACCESS_VIEW_DESC uavDesc = {};
- uavDesc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER;
- uavDesc.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_RAW;
- uavDesc.Format = DXGI_FORMAT_R32_TYPELESS;
- d3dDevice->CreateUnorderedAccessView(nullptr, nullptr, &uavDesc, destDescriptor);
- }
- break;
+ {
+ D3D12_UNORDERED_ACCESS_VIEW_DESC uavDesc = {};
+ uavDesc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER;
+ uavDesc.Buffer.Flags = D3D12_BUFFER_UAV_FLAG_RAW;
+ uavDesc.Format = DXGI_FORMAT_R32_TYPELESS;
+ d3dDevice->CreateUnorderedAccessView(nullptr, nullptr, &uavDesc, destDescriptor);
+ }
+ break;
case slang::BindingType::MutableTypedBuffer:
- {
- D3D12_UNORDERED_ACCESS_VIEW_DESC uavDesc = {};
- uavDesc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER;
- uavDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
- d3dDevice->CreateUnorderedAccessView(nullptr, nullptr, &uavDesc, destDescriptor);
- }
- break;
+ {
+ D3D12_UNORDERED_ACCESS_VIEW_DESC uavDesc = {};
+ uavDesc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER;
+ uavDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+ d3dDevice->CreateUnorderedAccessView(nullptr, nullptr, &uavDesc, destDescriptor);
+ }
+ break;
case slang::BindingType::RawBuffer:
- {
- D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
- srvDesc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER;
- srvDesc.Buffer.Flags = D3D12_BUFFER_SRV_FLAG_RAW;
- srvDesc.Format = DXGI_FORMAT_R32_TYPELESS;
- srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
- d3dDevice->CreateShaderResourceView(nullptr, &srvDesc, destDescriptor);
- }
- break;
+ {
+ D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
+ srvDesc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER;
+ srvDesc.Buffer.Flags = D3D12_BUFFER_SRV_FLAG_RAW;
+ srvDesc.Format = DXGI_FORMAT_R32_TYPELESS;
+ srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
+ d3dDevice->CreateShaderResourceView(nullptr, &srvDesc, destDescriptor);
+ }
+ break;
case slang::BindingType::TypedBuffer:
- {
- D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
- srvDesc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER;
- srvDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
- srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
- d3dDevice->CreateShaderResourceView(nullptr, &srvDesc, destDescriptor);
- }
- break;
+ {
+ D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
+ srvDesc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER;
+ srvDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+ srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
+ d3dDevice->CreateShaderResourceView(nullptr, &srvDesc, destDescriptor);
+ }
+ break;
case slang::BindingType::Texture:
- {
- D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
- srvDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
- srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
- switch (bindingRange.resourceShape)
{
- case SLANG_TEXTURE_1D:
- srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE1D;
- break;
- case SLANG_TEXTURE_1D_ARRAY:
- srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE1DARRAY;
- break;
- case SLANG_TEXTURE_2D:
- srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
- break;
- case SLANG_TEXTURE_2D_ARRAY:
- srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DARRAY;
- break;
- case SLANG_TEXTURE_3D:
- srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE3D;
- break;
- case SLANG_TEXTURE_CUBE:
- srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBE;
- break;
- case SLANG_TEXTURE_CUBE_ARRAY:
- srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBEARRAY;
- break;
- case SLANG_TEXTURE_2D_MULTISAMPLE:
- srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DMS;
- break;
- case SLANG_TEXTURE_2D_MULTISAMPLE_ARRAY:
- srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DMSARRAY;
- break;
- default:
- return SLANG_OK;
+ D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
+ srvDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+ srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
+ switch (bindingRange.resourceShape)
+ {
+ case SLANG_TEXTURE_1D: srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE1D; break;
+ case SLANG_TEXTURE_1D_ARRAY:
+ srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE1DARRAY;
+ break;
+ case SLANG_TEXTURE_2D: srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D; break;
+ case SLANG_TEXTURE_2D_ARRAY:
+ srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DARRAY;
+ break;
+ case SLANG_TEXTURE_3D: srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE3D; break;
+ case SLANG_TEXTURE_CUBE: srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBE; break;
+ case SLANG_TEXTURE_CUBE_ARRAY:
+ srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBEARRAY;
+ break;
+ case SLANG_TEXTURE_2D_MULTISAMPLE:
+ srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DMS;
+ break;
+ case SLANG_TEXTURE_2D_MULTISAMPLE_ARRAY:
+ srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DMSARRAY;
+ break;
+ default: return SLANG_OK;
+ }
+ d3dDevice->CreateShaderResourceView(nullptr, &srvDesc, destDescriptor);
}
- d3dDevice->CreateShaderResourceView(nullptr, &srvDesc, destDescriptor);
- }
- break;
+ break;
case slang::BindingType::MutableTexture:
- {
- D3D12_UNORDERED_ACCESS_VIEW_DESC uavDesc = {};
- uavDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
- switch (bindingRange.resourceShape)
{
- case SLANG_TEXTURE_1D:
- uavDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE1D;
- break;
- case SLANG_TEXTURE_1D_ARRAY:
- uavDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE1DARRAY;
- break;
- case SLANG_TEXTURE_2D:
- uavDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2D;
- break;
- case SLANG_TEXTURE_2D_ARRAY:
- uavDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2DARRAY;
- break;
- case SLANG_TEXTURE_3D:
- uavDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE3D;
- break;
- case SLANG_TEXTURE_CUBE:
- case SLANG_TEXTURE_CUBE_ARRAY:
- case SLANG_TEXTURE_2D_MULTISAMPLE:
- case SLANG_TEXTURE_2D_MULTISAMPLE_ARRAY:
- default:
- return SLANG_OK;
+ D3D12_UNORDERED_ACCESS_VIEW_DESC uavDesc = {};
+ uavDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
+ switch (bindingRange.resourceShape)
+ {
+ case SLANG_TEXTURE_1D: uavDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE1D; break;
+ case SLANG_TEXTURE_1D_ARRAY:
+ uavDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE1DARRAY;
+ break;
+ case SLANG_TEXTURE_2D: uavDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2D; break;
+ case SLANG_TEXTURE_2D_ARRAY:
+ uavDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE2DARRAY;
+ break;
+ case SLANG_TEXTURE_3D: uavDesc.ViewDimension = D3D12_UAV_DIMENSION_TEXTURE3D; break;
+ case SLANG_TEXTURE_CUBE:
+ case SLANG_TEXTURE_CUBE_ARRAY:
+ case SLANG_TEXTURE_2D_MULTISAMPLE:
+ case SLANG_TEXTURE_2D_MULTISAMPLE_ARRAY:
+ default: return SLANG_OK;
+ }
+ d3dDevice->CreateUnorderedAccessView(nullptr, nullptr, &uavDesc, destDescriptor);
}
- d3dDevice->CreateUnorderedAccessView(nullptr, nullptr, &uavDesc, destDescriptor);
- }
- break;
- default:
break;
+ default: break;
}
return SLANG_OK;
}
@@ -603,27 +571,27 @@ void translatePostBuildInfoDescs(
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_COMPACTED_SIZE;
postBuildInfoDescs[i].DestBuffer =
static_cast<PlainBufferProxyQueryPoolImpl*>(queryDescs[i].queryPool)
- ->m_bufferResource->getDeviceAddress() +
+ ->m_bufferResource->getDeviceAddress() +
sizeof(D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_COMPACTED_SIZE_DESC) *
- queryDescs[i].firstQueryIndex;
+ queryDescs[i].firstQueryIndex;
break;
case QueryType::AccelerationStructureCurrentSize:
postBuildInfoDescs[i].InfoType =
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_CURRENT_SIZE;
postBuildInfoDescs[i].DestBuffer =
static_cast<PlainBufferProxyQueryPoolImpl*>(queryDescs[i].queryPool)
- ->m_bufferResource->getDeviceAddress() +
+ ->m_bufferResource->getDeviceAddress() +
sizeof(D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_COMPACTED_SIZE_DESC) *
- queryDescs[i].firstQueryIndex;
+ queryDescs[i].firstQueryIndex;
break;
case QueryType::AccelerationStructureSerializedSize:
postBuildInfoDescs[i].InfoType =
D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_SERIALIZATION;
postBuildInfoDescs[i].DestBuffer =
static_cast<PlainBufferProxyQueryPoolImpl*>(queryDescs[i].queryPool)
- ->m_bufferResource->getDeviceAddress() +
+ ->m_bufferResource->getDeviceAddress() +
sizeof(D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_SERIALIZATION_DESC) *
- queryDescs[i].firstQueryIndex;
+ queryDescs[i].firstQueryIndex;
break;
}
}
@@ -634,7 +602,8 @@ void translatePostBuildInfoDescs(
Result SLANG_MCALL getD3D12Adapters(List<AdapterInfo>& outAdapters)
{
List<ComPtr<IDXGIAdapter>> dxgiAdapters;
- SLANG_RETURN_ON_FAIL(D3DUtil::findAdapters(DeviceCheckFlag::UseHardwareDevice, nullptr, dxgiAdapters));
+ SLANG_RETURN_ON_FAIL(
+ D3DUtil::findAdapters(DeviceCheckFlag::UseHardwareDevice, nullptr, dxgiAdapters));
outAdapters.clear();
for (const auto& dxgiAdapter : dxgiAdapters)
@@ -643,7 +612,10 @@ Result SLANG_MCALL getD3D12Adapters(List<AdapterInfo>& outAdapters)
dxgiAdapter->GetDesc(&desc);
AdapterInfo info = {};
auto name = String::fromWString(desc.Description);
- memcpy(info.name, name.getBuffer(), Math::Min(name.getLength(), (Index)sizeof(AdapterInfo::name) - 1));
+ memcpy(
+ info.name,
+ name.getBuffer(),
+ Math::Min(name.getLength(), (Index)sizeof(AdapterInfo::name) - 1));
info.vendorID = desc.VendorId;
info.deviceID = desc.DeviceId;
info.luid = D3DUtil::getAdapterLUID(dxgiAdapter);
diff --git a/tools/gfx/d3d12/d3d12-helper-functions.h b/tools/gfx/d3d12/d3d12-helper-functions.h
index 52b587529..e9eeb4c8f 100644
--- a/tools/gfx/d3d12/d3d12-helper-functions.h
+++ b/tools/gfx/d3d12/d3d12-helper-functions.h
@@ -1,17 +1,18 @@
// d3d12-helper-functions.h
#pragma once
-#include "slang-gfx.h"
+#include "../../../source/core/slang-list.h"
+#include "../../../source/core/slang-short-list.h"
#include "d3d12-base.h"
#include "d3d12-shader-object-layout.h"
#include "d3d12-submitter.h"
-#include "../../../source/core/slang-short-list.h"
-#include "../../../source/core/slang-list.h"
+#include "slang-gfx.h"
#ifndef __ID3D12GraphicsCommandList1_FWD_DEFINED__
// If can't find a definition of CommandList1, just use an empty definition
struct ID3D12GraphicsCommandList1
-{};
+{
+};
#endif
namespace gfx
@@ -35,7 +36,7 @@ struct BindingContext
TransientResourceHeapImpl* transientHeap;
DeviceImpl* device;
D3D12_DESCRIPTOR_HEAP_TYPE
- outOfMemoryHeap; // The type of descriptor heap that is OOM during binding.
+ outOfMemoryHeap; // The type of descriptor heap that is OOM during binding.
ShortList<PendingDescriptorTableBinding>* pendingTableBindings;
};
@@ -62,7 +63,8 @@ void initSrvDesc(
SubresourceRange subresourceRange,
D3D12_SHADER_RESOURCE_VIEW_DESC& descOut);
Result initTextureResourceDesc(
- D3D12_RESOURCE_DESC& resourceDesc, const ITextureResource::Desc& srcDesc);
+ D3D12_RESOURCE_DESC& resourceDesc,
+ const ITextureResource::Desc& srcDesc);
void initBufferResourceDesc(Size bufferSize, D3D12_RESOURCE_DESC& out);
Result uploadBufferDataImpl(
ID3D12Device* device,
diff --git a/tools/gfx/d3d12/d3d12-pipeline-state-stream.h b/tools/gfx/d3d12/d3d12-pipeline-state-stream.h
index 9848e96f9..db1f85d28 100644
--- a/tools/gfx/d3d12/d3d12-pipeline-state-stream.h
+++ b/tools/gfx/d3d12/d3d12-pipeline-state-stream.h
@@ -5,22 +5,25 @@
// `d3dx12_pipeline_state_stream.h`. Attribution Microsoft.
//
+#include "d3d12-sal-defs.h"
+
#include <climits>
#include <d3d12.h>
#include <dxgi1_4.h>
-#include "d3d12-sal-defs.h"
-
-struct CD3DX12_DEFAULT {};
+struct CD3DX12_DEFAULT
+{
+};
//------------------------------------------------------------------------------------------------
struct CD3DX12_DEPTH_STENCIL_DESC : public D3D12_DEPTH_STENCIL_DESC
{
CD3DX12_DEPTH_STENCIL_DESC() = default;
- explicit CD3DX12_DEPTH_STENCIL_DESC( const D3D12_DEPTH_STENCIL_DESC& o ) noexcept :
- D3D12_DEPTH_STENCIL_DESC( o )
- {}
- explicit CD3DX12_DEPTH_STENCIL_DESC( CD3DX12_DEFAULT ) noexcept
+ explicit CD3DX12_DEPTH_STENCIL_DESC(const D3D12_DEPTH_STENCIL_DESC& o) noexcept
+ : D3D12_DEPTH_STENCIL_DESC(o)
+ {
+ }
+ explicit CD3DX12_DEPTH_STENCIL_DESC(CD3DX12_DEFAULT) noexcept
{
DepthEnable = TRUE;
DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ALL;
@@ -28,8 +31,11 @@ struct CD3DX12_DEPTH_STENCIL_DESC : public D3D12_DEPTH_STENCIL_DESC
StencilEnable = FALSE;
StencilReadMask = D3D12_DEFAULT_STENCIL_READ_MASK;
StencilWriteMask = D3D12_DEFAULT_STENCIL_WRITE_MASK;
- const D3D12_DEPTH_STENCILOP_DESC defaultStencilOp =
- { D3D12_STENCIL_OP_KEEP, D3D12_STENCIL_OP_KEEP, D3D12_STENCIL_OP_KEEP, D3D12_COMPARISON_FUNC_ALWAYS };
+ const D3D12_DEPTH_STENCILOP_DESC defaultStencilOp = {
+ D3D12_STENCIL_OP_KEEP,
+ D3D12_STENCIL_OP_KEEP,
+ D3D12_STENCIL_OP_KEEP,
+ D3D12_COMPARISON_FUNC_ALWAYS};
FrontFace = defaultStencilOp;
BackFace = defaultStencilOp;
}
@@ -47,7 +53,7 @@ struct CD3DX12_DEPTH_STENCIL_DESC : public D3D12_DEPTH_STENCIL_DESC
D3D12_STENCIL_OP backStencilFailOp,
D3D12_STENCIL_OP backStencilDepthFailOp,
D3D12_STENCIL_OP backStencilPassOp,
- D3D12_COMPARISON_FUNC backStencilFunc ) noexcept
+ D3D12_COMPARISON_FUNC backStencilFunc) noexcept
{
DepthEnable = depthEnable;
DepthWriteMask = depthWriteMask;
@@ -70,28 +76,29 @@ struct CD3DX12_DEPTH_STENCIL_DESC : public D3D12_DEPTH_STENCIL_DESC
struct CD3DX12_DEPTH_STENCIL_DESC1 : public D3D12_DEPTH_STENCIL_DESC1
{
CD3DX12_DEPTH_STENCIL_DESC1() = default;
- explicit CD3DX12_DEPTH_STENCIL_DESC1( const D3D12_DEPTH_STENCIL_DESC1& o ) noexcept :
- D3D12_DEPTH_STENCIL_DESC1( o )
- {}
- explicit CD3DX12_DEPTH_STENCIL_DESC1( const D3D12_DEPTH_STENCIL_DESC& o ) noexcept
+ explicit CD3DX12_DEPTH_STENCIL_DESC1(const D3D12_DEPTH_STENCIL_DESC1& o) noexcept
+ : D3D12_DEPTH_STENCIL_DESC1(o)
+ {
+ }
+ explicit CD3DX12_DEPTH_STENCIL_DESC1(const D3D12_DEPTH_STENCIL_DESC& o) noexcept
{
- DepthEnable = o.DepthEnable;
- DepthWriteMask = o.DepthWriteMask;
- DepthFunc = o.DepthFunc;
- StencilEnable = o.StencilEnable;
- StencilReadMask = o.StencilReadMask;
- StencilWriteMask = o.StencilWriteMask;
- FrontFace.StencilFailOp = o.FrontFace.StencilFailOp;
+ DepthEnable = o.DepthEnable;
+ DepthWriteMask = o.DepthWriteMask;
+ DepthFunc = o.DepthFunc;
+ StencilEnable = o.StencilEnable;
+ StencilReadMask = o.StencilReadMask;
+ StencilWriteMask = o.StencilWriteMask;
+ FrontFace.StencilFailOp = o.FrontFace.StencilFailOp;
FrontFace.StencilDepthFailOp = o.FrontFace.StencilDepthFailOp;
- FrontFace.StencilPassOp = o.FrontFace.StencilPassOp;
- FrontFace.StencilFunc = o.FrontFace.StencilFunc;
- BackFace.StencilFailOp = o.BackFace.StencilFailOp;
- BackFace.StencilDepthFailOp = o.BackFace.StencilDepthFailOp;
- BackFace.StencilPassOp = o.BackFace.StencilPassOp;
- BackFace.StencilFunc = o.BackFace.StencilFunc;
- DepthBoundsTestEnable = FALSE;
+ FrontFace.StencilPassOp = o.FrontFace.StencilPassOp;
+ FrontFace.StencilFunc = o.FrontFace.StencilFunc;
+ BackFace.StencilFailOp = o.BackFace.StencilFailOp;
+ BackFace.StencilDepthFailOp = o.BackFace.StencilDepthFailOp;
+ BackFace.StencilPassOp = o.BackFace.StencilPassOp;
+ BackFace.StencilFunc = o.BackFace.StencilFunc;
+ DepthBoundsTestEnable = FALSE;
}
- explicit CD3DX12_DEPTH_STENCIL_DESC1( CD3DX12_DEFAULT ) noexcept
+ explicit CD3DX12_DEPTH_STENCIL_DESC1(CD3DX12_DEFAULT) noexcept
{
DepthEnable = TRUE;
DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ALL;
@@ -99,8 +106,11 @@ struct CD3DX12_DEPTH_STENCIL_DESC1 : public D3D12_DEPTH_STENCIL_DESC1
StencilEnable = FALSE;
StencilReadMask = D3D12_DEFAULT_STENCIL_READ_MASK;
StencilWriteMask = D3D12_DEFAULT_STENCIL_WRITE_MASK;
- const D3D12_DEPTH_STENCILOP_DESC defaultStencilOp =
- { D3D12_STENCIL_OP_KEEP, D3D12_STENCIL_OP_KEEP, D3D12_STENCIL_OP_KEEP, D3D12_COMPARISON_FUNC_ALWAYS };
+ const D3D12_DEPTH_STENCILOP_DESC defaultStencilOp = {
+ D3D12_STENCIL_OP_KEEP,
+ D3D12_STENCIL_OP_KEEP,
+ D3D12_STENCIL_OP_KEEP,
+ D3D12_COMPARISON_FUNC_ALWAYS};
FrontFace = defaultStencilOp;
BackFace = defaultStencilOp;
DepthBoundsTestEnable = FALSE;
@@ -120,7 +130,7 @@ struct CD3DX12_DEPTH_STENCIL_DESC1 : public D3D12_DEPTH_STENCIL_DESC1
D3D12_STENCIL_OP backStencilDepthFailOp,
D3D12_STENCIL_OP backStencilPassOp,
D3D12_COMPARISON_FUNC backStencilFunc,
- BOOL depthBoundsTestEnable ) noexcept
+ BOOL depthBoundsTestEnable) noexcept
{
DepthEnable = depthEnable;
DepthWriteMask = depthWriteMask;
@@ -141,20 +151,20 @@ struct CD3DX12_DEPTH_STENCIL_DESC1 : public D3D12_DEPTH_STENCIL_DESC1
operator D3D12_DEPTH_STENCIL_DESC() const noexcept
{
D3D12_DEPTH_STENCIL_DESC D;
- D.DepthEnable = DepthEnable;
- D.DepthWriteMask = DepthWriteMask;
- D.DepthFunc = DepthFunc;
- D.StencilEnable = StencilEnable;
- D.StencilReadMask = StencilReadMask;
- D.StencilWriteMask = StencilWriteMask;
- D.FrontFace.StencilFailOp = FrontFace.StencilFailOp;
+ D.DepthEnable = DepthEnable;
+ D.DepthWriteMask = DepthWriteMask;
+ D.DepthFunc = DepthFunc;
+ D.StencilEnable = StencilEnable;
+ D.StencilReadMask = StencilReadMask;
+ D.StencilWriteMask = StencilWriteMask;
+ D.FrontFace.StencilFailOp = FrontFace.StencilFailOp;
D.FrontFace.StencilDepthFailOp = FrontFace.StencilDepthFailOp;
- D.FrontFace.StencilPassOp = FrontFace.StencilPassOp;
- D.FrontFace.StencilFunc = FrontFace.StencilFunc;
- D.BackFace.StencilFailOp = BackFace.StencilFailOp;
- D.BackFace.StencilDepthFailOp = BackFace.StencilDepthFailOp;
- D.BackFace.StencilPassOp = BackFace.StencilPassOp;
- D.BackFace.StencilFunc = BackFace.StencilFunc;
+ D.FrontFace.StencilPassOp = FrontFace.StencilPassOp;
+ D.FrontFace.StencilFunc = FrontFace.StencilFunc;
+ D.BackFace.StencilFailOp = BackFace.StencilFailOp;
+ D.BackFace.StencilDepthFailOp = BackFace.StencilDepthFailOp;
+ D.BackFace.StencilPassOp = BackFace.StencilPassOp;
+ D.BackFace.StencilFunc = BackFace.StencilFunc;
return D;
}
};
@@ -163,23 +173,28 @@ struct CD3DX12_DEPTH_STENCIL_DESC1 : public D3D12_DEPTH_STENCIL_DESC1
struct CD3DX12_BLEND_DESC : public D3D12_BLEND_DESC
{
CD3DX12_BLEND_DESC() = default;
- explicit CD3DX12_BLEND_DESC( const D3D12_BLEND_DESC& o ) noexcept :
- D3D12_BLEND_DESC( o )
- {}
- explicit CD3DX12_BLEND_DESC( CD3DX12_DEFAULT ) noexcept
+ explicit CD3DX12_BLEND_DESC(const D3D12_BLEND_DESC& o) noexcept
+ : D3D12_BLEND_DESC(o)
+ {
+ }
+ explicit CD3DX12_BLEND_DESC(CD3DX12_DEFAULT) noexcept
{
AlphaToCoverageEnable = FALSE;
IndependentBlendEnable = FALSE;
- const D3D12_RENDER_TARGET_BLEND_DESC defaultRenderTargetBlendDesc =
- {
- FALSE,FALSE,
- D3D12_BLEND_ONE, D3D12_BLEND_ZERO, D3D12_BLEND_OP_ADD,
- D3D12_BLEND_ONE, D3D12_BLEND_ZERO, D3D12_BLEND_OP_ADD,
+ const D3D12_RENDER_TARGET_BLEND_DESC defaultRenderTargetBlendDesc = {
+ FALSE,
+ FALSE,
+ D3D12_BLEND_ONE,
+ D3D12_BLEND_ZERO,
+ D3D12_BLEND_OP_ADD,
+ D3D12_BLEND_ONE,
+ D3D12_BLEND_ZERO,
+ D3D12_BLEND_OP_ADD,
D3D12_LOGIC_OP_NOOP,
D3D12_COLOR_WRITE_ENABLE_ALL,
};
for (UINT i = 0; i < D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
- RenderTarget[ i ] = defaultRenderTargetBlendDesc;
+ RenderTarget[i] = defaultRenderTargetBlendDesc;
}
};
@@ -187,10 +202,11 @@ struct CD3DX12_BLEND_DESC : public D3D12_BLEND_DESC
struct CD3DX12_RASTERIZER_DESC : public D3D12_RASTERIZER_DESC
{
CD3DX12_RASTERIZER_DESC() = default;
- explicit CD3DX12_RASTERIZER_DESC( const D3D12_RASTERIZER_DESC& o ) noexcept :
- D3D12_RASTERIZER_DESC( o )
- {}
- explicit CD3DX12_RASTERIZER_DESC( CD3DX12_DEFAULT ) noexcept
+ explicit CD3DX12_RASTERIZER_DESC(const D3D12_RASTERIZER_DESC& o) noexcept
+ : D3D12_RASTERIZER_DESC(o)
+ {
+ }
+ explicit CD3DX12_RASTERIZER_DESC(CD3DX12_DEFAULT) noexcept
{
FillMode = D3D12_FILL_MODE_SOLID;
CullMode = D3D12_CULL_MODE_BACK;
@@ -235,10 +251,11 @@ struct CD3DX12_RASTERIZER_DESC : public D3D12_RASTERIZER_DESC
struct CD3DX12_VIEW_INSTANCING_DESC : public D3D12_VIEW_INSTANCING_DESC
{
CD3DX12_VIEW_INSTANCING_DESC() = default;
- explicit CD3DX12_VIEW_INSTANCING_DESC( const D3D12_VIEW_INSTANCING_DESC& o ) noexcept :
- D3D12_VIEW_INSTANCING_DESC( o )
- {}
- explicit CD3DX12_VIEW_INSTANCING_DESC( CD3DX12_DEFAULT ) noexcept
+ explicit CD3DX12_VIEW_INSTANCING_DESC(const D3D12_VIEW_INSTANCING_DESC& o) noexcept
+ : D3D12_VIEW_INSTANCING_DESC(o)
+ {
+ }
+ explicit CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT) noexcept
{
ViewInstanceCount = 0;
pViewInstanceLocations = nullptr;
@@ -261,8 +278,11 @@ struct CD3DX12_RT_FORMAT_ARRAY : public D3D12_RT_FORMAT_ARRAY
CD3DX12_RT_FORMAT_ARRAY() = default;
explicit CD3DX12_RT_FORMAT_ARRAY(const D3D12_RT_FORMAT_ARRAY& o) noexcept
: D3D12_RT_FORMAT_ARRAY(o)
- {}
- explicit CD3DX12_RT_FORMAT_ARRAY(_In_reads_(NumFormats) const DXGI_FORMAT* pFormats, UINT NumFormats) noexcept
+ {
+ }
+ explicit CD3DX12_RT_FORMAT_ARRAY(
+ _In_reads_(NumFormats) const DXGI_FORMAT* pFormats,
+ UINT NumFormats) noexcept
{
NumRenderTargets = NumFormats;
memcpy(RTFormats, pFormats, sizeof(RTFormats));
@@ -274,103 +294,203 @@ struct CD3DX12_RT_FORMAT_ARRAY : public D3D12_RT_FORMAT_ARRAY
struct CD3DX12_SHADER_BYTECODE : public D3D12_SHADER_BYTECODE
{
CD3DX12_SHADER_BYTECODE() = default;
- explicit CD3DX12_SHADER_BYTECODE(const D3D12_SHADER_BYTECODE &o) noexcept :
- D3D12_SHADER_BYTECODE(o)
- {}
- CD3DX12_SHADER_BYTECODE(
- _In_ ID3DBlob* pShaderBlob ) noexcept
+ explicit CD3DX12_SHADER_BYTECODE(const D3D12_SHADER_BYTECODE& o) noexcept
+ : D3D12_SHADER_BYTECODE(o)
+ {
+ }
+ CD3DX12_SHADER_BYTECODE(_In_ ID3DBlob* pShaderBlob) noexcept
{
pShaderBytecode = pShaderBlob->GetBufferPointer();
BytecodeLength = pShaderBlob->GetBufferSize();
}
- CD3DX12_SHADER_BYTECODE(
- const void* _pShaderBytecode,
- SIZE_T bytecodeLength ) noexcept
+ CD3DX12_SHADER_BYTECODE(const void* _pShaderBytecode, SIZE_T bytecodeLength) noexcept
{
pShaderBytecode = _pShaderBytecode;
BytecodeLength = bytecodeLength;
}
};
-struct DefaultSampleMask { operator UINT() noexcept { return UINT_MAX; } };
-struct DefaultSampleDesc { operator DXGI_SAMPLE_DESC() noexcept { return DXGI_SAMPLE_DESC{1, 0}; } };
+struct DefaultSampleMask
+{
+ operator UINT() noexcept { return UINT_MAX; }
+};
+struct DefaultSampleDesc
+{
+ operator DXGI_SAMPLE_DESC() noexcept { return DXGI_SAMPLE_DESC{1, 0}; }
+};
#ifdef _MSC_VER
-# pragma warning(push)
-# pragma warning(disable : 4324)
+#pragma warning(push)
+#pragma warning(disable : 4324)
#endif
-template <typename InnerStructType, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE Type, typename DefaultArg = InnerStructType>
+template<
+ typename InnerStructType,
+ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE Type,
+ typename DefaultArg = InnerStructType>
class alignas(void*) CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT
{
private:
D3D12_PIPELINE_STATE_SUBOBJECT_TYPE pssType;
InnerStructType pssInner;
+
public:
- CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT() noexcept : pssType(Type), pssInner(DefaultArg()) {}
- CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT(InnerStructType const& i) noexcept : pssType(Type), pssInner(i) {}
- CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT& operator=(InnerStructType const& i) noexcept { pssType = Type; pssInner = i; return *this; }
+ CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT() noexcept
+ : pssType(Type), pssInner(DefaultArg())
+ {
+ }
+ CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT(InnerStructType const& i) noexcept
+ : pssType(Type), pssInner(i)
+ {
+ }
+ CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT& operator=(InnerStructType const& i) noexcept
+ {
+ pssType = Type;
+ pssInner = i;
+ return *this;
+ }
operator InnerStructType const&() const noexcept { return pssInner; }
operator InnerStructType&() noexcept { return pssInner; }
InnerStructType* operator&() noexcept { return &pssInner; }
InnerStructType const* operator&() const noexcept { return &pssInner; }
};
#ifdef _MSC_VER
-# pragma warning(pop)
+#pragma warning(pop)
#endif
-typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_PIPELINE_STATE_FLAGS, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_FLAGS> CD3DX12_PIPELINE_STATE_STREAM_FLAGS;
-typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< UINT, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_NODE_MASK> CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK;
-typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< ID3D12RootSignature*, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_ROOT_SIGNATURE> CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE;
-typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_INPUT_LAYOUT_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_INPUT_LAYOUT> CD3DX12_PIPELINE_STATE_STREAM_INPUT_LAYOUT;
-typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_INDEX_BUFFER_STRIP_CUT_VALUE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_IB_STRIP_CUT_VALUE> CD3DX12_PIPELINE_STATE_STREAM_IB_STRIP_CUT_VALUE;
-typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_PRIMITIVE_TOPOLOGY_TYPE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PRIMITIVE_TOPOLOGY> CD3DX12_PIPELINE_STATE_STREAM_PRIMITIVE_TOPOLOGY;
-typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VS> CD3DX12_PIPELINE_STATE_STREAM_VS;
-typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_GS> CD3DX12_PIPELINE_STATE_STREAM_GS;
-typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_STREAM_OUTPUT_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_STREAM_OUTPUT> CD3DX12_PIPELINE_STATE_STREAM_STREAM_OUTPUT;
-typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_HS> CD3DX12_PIPELINE_STATE_STREAM_HS;
-typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DS> CD3DX12_PIPELINE_STATE_STREAM_DS;
-typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PS> CD3DX12_PIPELINE_STATE_STREAM_PS;
-typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_AS> CD3DX12_PIPELINE_STATE_STREAM_AS;
-typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MS> CD3DX12_PIPELINE_STATE_STREAM_MS;
-typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_SHADER_BYTECODE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CS> CD3DX12_PIPELINE_STATE_STREAM_CS;
-typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_BLEND_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_BLEND, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC;
-typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_DEPTH_STENCIL_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL;
-typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_DEPTH_STENCIL_DESC1, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL1;
-typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< DXGI_FORMAT, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL_FORMAT> CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT;
-typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_RASTERIZER_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER;
-typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_RT_FORMAT_ARRAY, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RENDER_TARGET_FORMATS> CD3DX12_PIPELINE_STATE_STREAM_RENDER_TARGET_FORMATS;
-typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< DXGI_SAMPLE_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_DESC, DefaultSampleDesc> CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_DESC;
-typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< UINT, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_MASK, DefaultSampleMask> CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_MASK;
-typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< D3D12_CACHED_PIPELINE_STATE, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CACHED_PSO> CD3DX12_PIPELINE_STATE_STREAM_CACHED_PSO;
-typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT< CD3DX12_VIEW_INSTANCING_DESC, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VIEW_INSTANCING, CD3DX12_DEFAULT> CD3DX12_PIPELINE_STATE_STREAM_VIEW_INSTANCING;
+typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT<
+ D3D12_PIPELINE_STATE_FLAGS,
+ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_FLAGS>
+ CD3DX12_PIPELINE_STATE_STREAM_FLAGS;
+typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT<UINT, D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_NODE_MASK>
+ CD3DX12_PIPELINE_STATE_STREAM_NODE_MASK;
+typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT<
+ ID3D12RootSignature*,
+ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_ROOT_SIGNATURE>
+ CD3DX12_PIPELINE_STATE_STREAM_ROOT_SIGNATURE;
+typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT<
+ D3D12_INPUT_LAYOUT_DESC,
+ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_INPUT_LAYOUT>
+ CD3DX12_PIPELINE_STATE_STREAM_INPUT_LAYOUT;
+typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT<
+ D3D12_INDEX_BUFFER_STRIP_CUT_VALUE,
+ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_IB_STRIP_CUT_VALUE>
+ CD3DX12_PIPELINE_STATE_STREAM_IB_STRIP_CUT_VALUE;
+typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT<
+ D3D12_PRIMITIVE_TOPOLOGY_TYPE,
+ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PRIMITIVE_TOPOLOGY>
+ CD3DX12_PIPELINE_STATE_STREAM_PRIMITIVE_TOPOLOGY;
+typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT<
+ D3D12_SHADER_BYTECODE,
+ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VS>
+ CD3DX12_PIPELINE_STATE_STREAM_VS;
+typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT<
+ D3D12_SHADER_BYTECODE,
+ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_GS>
+ CD3DX12_PIPELINE_STATE_STREAM_GS;
+typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT<
+ D3D12_STREAM_OUTPUT_DESC,
+ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_STREAM_OUTPUT>
+ CD3DX12_PIPELINE_STATE_STREAM_STREAM_OUTPUT;
+typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT<
+ D3D12_SHADER_BYTECODE,
+ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_HS>
+ CD3DX12_PIPELINE_STATE_STREAM_HS;
+typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT<
+ D3D12_SHADER_BYTECODE,
+ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DS>
+ CD3DX12_PIPELINE_STATE_STREAM_DS;
+typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT<
+ D3D12_SHADER_BYTECODE,
+ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_PS>
+ CD3DX12_PIPELINE_STATE_STREAM_PS;
+typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT<
+ D3D12_SHADER_BYTECODE,
+ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_AS>
+ CD3DX12_PIPELINE_STATE_STREAM_AS;
+typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT<
+ D3D12_SHADER_BYTECODE,
+ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_MS>
+ CD3DX12_PIPELINE_STATE_STREAM_MS;
+typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT<
+ D3D12_SHADER_BYTECODE,
+ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CS>
+ CD3DX12_PIPELINE_STATE_STREAM_CS;
+typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT<
+ CD3DX12_BLEND_DESC,
+ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_BLEND,
+ CD3DX12_DEFAULT>
+ CD3DX12_PIPELINE_STATE_STREAM_BLEND_DESC;
+typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT<
+ CD3DX12_DEPTH_STENCIL_DESC,
+ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL,
+ CD3DX12_DEFAULT>
+ CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL;
+typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT<
+ CD3DX12_DEPTH_STENCIL_DESC1,
+ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL1,
+ CD3DX12_DEFAULT>
+ CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL1;
+typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT<
+ DXGI_FORMAT,
+ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_DEPTH_STENCIL_FORMAT>
+ CD3DX12_PIPELINE_STATE_STREAM_DEPTH_STENCIL_FORMAT;
+typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT<
+ CD3DX12_RASTERIZER_DESC,
+ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RASTERIZER,
+ CD3DX12_DEFAULT>
+ CD3DX12_PIPELINE_STATE_STREAM_RASTERIZER;
+typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT<
+ D3D12_RT_FORMAT_ARRAY,
+ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_RENDER_TARGET_FORMATS>
+ CD3DX12_PIPELINE_STATE_STREAM_RENDER_TARGET_FORMATS;
+typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT<
+ DXGI_SAMPLE_DESC,
+ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_DESC,
+ DefaultSampleDesc>
+ CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_DESC;
+typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT<
+ UINT,
+ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_SAMPLE_MASK,
+ DefaultSampleMask>
+ CD3DX12_PIPELINE_STATE_STREAM_SAMPLE_MASK;
+typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT<
+ D3D12_CACHED_PIPELINE_STATE,
+ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_CACHED_PSO>
+ CD3DX12_PIPELINE_STATE_STREAM_CACHED_PSO;
+typedef CD3DX12_PIPELINE_STATE_STREAM_SUBOBJECT<
+ CD3DX12_VIEW_INSTANCING_DESC,
+ D3D12_PIPELINE_STATE_SUBOBJECT_TYPE_VIEW_INSTANCING,
+ CD3DX12_DEFAULT>
+ CD3DX12_PIPELINE_STATE_STREAM_VIEW_INSTANCING;
struct D3DX12_MESH_SHADER_PIPELINE_STATE_DESC
{
- ID3D12RootSignature* pRootSignature;
- D3D12_SHADER_BYTECODE AS;
- D3D12_SHADER_BYTECODE MS;
- D3D12_SHADER_BYTECODE PS;
- D3D12_BLEND_DESC BlendState;
- UINT SampleMask;
- D3D12_RASTERIZER_DESC RasterizerState;
- D3D12_DEPTH_STENCIL_DESC DepthStencilState;
+ ID3D12RootSignature* pRootSignature;
+ D3D12_SHADER_BYTECODE AS;
+ D3D12_SHADER_BYTECODE MS;
+ D3D12_SHADER_BYTECODE PS;
+ D3D12_BLEND_DESC BlendState;
+ UINT SampleMask;
+ D3D12_RASTERIZER_DESC RasterizerState;
+ D3D12_DEPTH_STENCIL_DESC DepthStencilState;
D3D12_PRIMITIVE_TOPOLOGY_TYPE PrimitiveTopologyType;
- UINT NumRenderTargets;
- DXGI_FORMAT RTVFormats[ D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT ];
- DXGI_FORMAT DSVFormat;
- DXGI_SAMPLE_DESC SampleDesc;
- UINT NodeMask;
- D3D12_CACHED_PIPELINE_STATE CachedPSO;
- D3D12_PIPELINE_STATE_FLAGS Flags;
+ UINT NumRenderTargets;
+ DXGI_FORMAT RTVFormats[D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT];
+ DXGI_FORMAT DSVFormat;
+ DXGI_SAMPLE_DESC SampleDesc;
+ UINT NodeMask;
+ D3D12_CACHED_PIPELINE_STATE CachedPSO;
+ D3D12_PIPELINE_STATE_FLAGS Flags;
};
-// CD3DX12_PIPELINE_STATE_STREAM2 Works on OS Build 19041+ (where there is a new mesh shader pipeline).
-// Use CD3DX12_PIPELINE_STATE_STREAM1 for OS Build 16299+ (where there is a new view instancing subobject).
-// Use CD3DX12_PIPELINE_STATE_STREAM for OS Build 15063+ support.
+// CD3DX12_PIPELINE_STATE_STREAM2 Works on OS Build 19041+ (where there is a new mesh shader
+// pipeline). Use CD3DX12_PIPELINE_STATE_STREAM1 for OS Build 16299+ (where there is a new view
+// instancing subobject). Use CD3DX12_PIPELINE_STATE_STREAM for OS Build 15063+ support.
struct CD3DX12_PIPELINE_STATE_STREAM2
{
CD3DX12_PIPELINE_STATE_STREAM2() = default;
- // Mesh and amplification shaders must be set manually, since they do not have representation in D3D12_GRAPHICS_PIPELINE_STATE_DESC
+ // Mesh and amplification shaders must be set manually, since they do not have representation in
+ // D3D12_GRAPHICS_PIPELINE_STATE_DESC
CD3DX12_PIPELINE_STATE_STREAM2(const D3D12_GRAPHICS_PIPELINE_STATE_DESC& Desc) noexcept
: Flags(Desc.Flags)
, NodeMask(Desc.NodeMask)
@@ -393,7 +513,8 @@ struct CD3DX12_PIPELINE_STATE_STREAM2
, SampleMask(Desc.SampleMask)
, CachedPSO(Desc.CachedPSO)
, ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT()))
- {}
+ {
+ }
CD3DX12_PIPELINE_STATE_STREAM2(const D3DX12_MESH_SHADER_PIPELINE_STATE_DESC& Desc) noexcept
: Flags(Desc.Flags)
, NodeMask(Desc.NodeMask)
@@ -411,7 +532,8 @@ struct CD3DX12_PIPELINE_STATE_STREAM2
, SampleMask(Desc.SampleMask)
, CachedPSO(Desc.CachedPSO)
, ViewInstancingDesc(CD3DX12_VIEW_INSTANCING_DESC(CD3DX12_DEFAULT()))
- {}
+ {
+ }
CD3DX12_PIPELINE_STATE_STREAM2(const D3D12_COMPUTE_PIPELINE_STATE_DESC& Desc) noexcept
: Flags(Desc.Flags)
, NodeMask(Desc.NodeMask)
@@ -448,37 +570,41 @@ struct CD3DX12_PIPELINE_STATE_STREAM2
D3D12_GRAPHICS_PIPELINE_STATE_DESC GraphicsDescV0() const noexcept
{
D3D12_GRAPHICS_PIPELINE_STATE_DESC D;
- D.Flags = this->Flags;
- D.NodeMask = this->NodeMask;
- D.pRootSignature = this->pRootSignature;
- D.InputLayout = this->InputLayout;
- D.IBStripCutValue = this->IBStripCutValue;
+ D.Flags = this->Flags;
+ D.NodeMask = this->NodeMask;
+ D.pRootSignature = this->pRootSignature;
+ D.InputLayout = this->InputLayout;
+ D.IBStripCutValue = this->IBStripCutValue;
D.PrimitiveTopologyType = this->PrimitiveTopologyType;
- D.VS = this->VS;
- D.GS = this->GS;
- D.StreamOutput = this->StreamOutput;
- D.HS = this->HS;
- D.DS = this->DS;
- D.PS = this->PS;
- D.BlendState = this->BlendState;
- D.DepthStencilState = CD3DX12_DEPTH_STENCIL_DESC1(D3D12_DEPTH_STENCIL_DESC1(this->DepthStencilState));
- D.DSVFormat = this->DSVFormat;
- D.RasterizerState = this->RasterizerState;
- D.NumRenderTargets = D3D12_RT_FORMAT_ARRAY(this->RTVFormats).NumRenderTargets;
- memcpy(D.RTVFormats, D3D12_RT_FORMAT_ARRAY(this->RTVFormats).RTFormats, sizeof(D.RTVFormats));
- D.SampleDesc = this->SampleDesc;
- D.SampleMask = this->SampleMask;
- D.CachedPSO = this->CachedPSO;
+ D.VS = this->VS;
+ D.GS = this->GS;
+ D.StreamOutput = this->StreamOutput;
+ D.HS = this->HS;
+ D.DS = this->DS;
+ D.PS = this->PS;
+ D.BlendState = this->BlendState;
+ D.DepthStencilState =
+ CD3DX12_DEPTH_STENCIL_DESC1(D3D12_DEPTH_STENCIL_DESC1(this->DepthStencilState));
+ D.DSVFormat = this->DSVFormat;
+ D.RasterizerState = this->RasterizerState;
+ D.NumRenderTargets = D3D12_RT_FORMAT_ARRAY(this->RTVFormats).NumRenderTargets;
+ memcpy(
+ D.RTVFormats,
+ D3D12_RT_FORMAT_ARRAY(this->RTVFormats).RTFormats,
+ sizeof(D.RTVFormats));
+ D.SampleDesc = this->SampleDesc;
+ D.SampleMask = this->SampleMask;
+ D.CachedPSO = this->CachedPSO;
return D;
}
D3D12_COMPUTE_PIPELINE_STATE_DESC ComputeDescV0() const noexcept
{
D3D12_COMPUTE_PIPELINE_STATE_DESC D;
- D.Flags = this->Flags;
- D.NodeMask = this->NodeMask;
- D.pRootSignature = this->pRootSignature;
- D.CS = this->CS;
- D.CachedPSO = this->CachedPSO;
+ D.Flags = this->Flags;
+ D.NodeMask = this->NodeMask;
+ D.pRootSignature = this->pRootSignature;
+ D.CS = this->CS;
+ D.CachedPSO = this->CachedPSO;
return D;
}
};
diff --git a/tools/gfx/d3d12/d3d12-pipeline-state.cpp b/tools/gfx/d3d12/d3d12-pipeline-state.cpp
index fc54b3884..df830960f 100644
--- a/tools/gfx/d3d12/d3d12-pipeline-state.cpp
+++ b/tools/gfx/d3d12/d3d12-pipeline-state.cpp
@@ -2,15 +2,15 @@
#include "d3d12-pipeline-state.h"
#ifdef GFX_NVAPI
-# include "../nvapi/nvapi-include.h"
+#include "../nvapi/nvapi-include.h"
#endif
#include "../nvapi/nvapi-util.h"
#include "d3d12-device.h"
#include "d3d12-framebuffer.h"
+#include "d3d12-pipeline-state-stream.h"
#include "d3d12-shader-program.h"
#include "d3d12-vertex-layout.h"
-#include "d3d12-pipeline-state-stream.h"
#include <climits>
@@ -61,7 +61,8 @@ Result PipelineStateImpl::ensureAPIPipelineStateCreated()
auto inputLayoutImpl = (InputLayoutImpl*)desc.graphics.inputLayout;
// A helper to fill common fields between graphics and mesh pipeline descs
- const auto fillCommonGraphicsState = [&](auto& psoDesc){
+ const auto fillCommonGraphicsState = [&](auto& psoDesc)
+ {
psoDesc.pRootSignature = programImpl->m_rootObjectLayout->m_rootSignature;
psoDesc.PrimitiveTopologyType = D3DUtil::getPrimitiveType(desc.graphics.primitiveType);
@@ -73,7 +74,8 @@ Result PipelineStateImpl::ensureAPIPipelineStateCreated()
if (framebufferLayout->m_hasDepthStencil)
{
- psoDesc.DSVFormat = D3DUtil::getMapFormat(framebufferLayout->m_depthStencil.format);
+ psoDesc.DSVFormat =
+ D3DUtil::getMapFormat(framebufferLayout->m_depthStencil.format);
psoDesc.SampleDesc.Count = framebufferLayout->m_depthStencil.sampleCount;
}
else
@@ -81,7 +83,8 @@ Result PipelineStateImpl::ensureAPIPipelineStateCreated()
psoDesc.DSVFormat = DXGI_FORMAT_UNKNOWN;
if (framebufferLayout->m_renderTargets.getCount())
{
- psoDesc.SampleDesc.Count = framebufferLayout->m_renderTargets[0].sampleCount;
+ psoDesc.SampleDesc.Count =
+ framebufferLayout->m_renderTargets[0].sampleCount;
}
}
psoDesc.NumRenderTargets = numRenderTargets;
@@ -100,8 +103,9 @@ Result PipelineStateImpl::ensureAPIPipelineStateCreated()
rs.FillMode = D3DUtil::getFillMode(desc.graphics.rasterizer.fillMode);
rs.CullMode = D3DUtil::getCullMode(desc.graphics.rasterizer.cullMode);
rs.FrontCounterClockwise =
- desc.graphics.rasterizer.frontFace == gfx::FrontFaceMode::CounterClockwise ? TRUE
- : FALSE;
+ desc.graphics.rasterizer.frontFace == gfx::FrontFaceMode::CounterClockwise
+ ? TRUE
+ : FALSE;
rs.DepthBias = desc.graphics.rasterizer.depthBias;
rs.DepthBiasClamp = desc.graphics.rasterizer.depthBiasClamp;
rs.SlopeScaledDepthBias = desc.graphics.rasterizer.slopeScaledDepthBias;
@@ -111,21 +115,24 @@ Result PipelineStateImpl::ensureAPIPipelineStateCreated()
desc.graphics.rasterizer.antialiasedLineEnable ? TRUE : FALSE;
rs.ForcedSampleCount = desc.graphics.rasterizer.forcedSampleCount;
rs.ConservativeRaster = desc.graphics.rasterizer.enableConservativeRasterization
- ? D3D12_CONSERVATIVE_RASTERIZATION_MODE_ON
- : D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF;
+ ? D3D12_CONSERVATIVE_RASTERIZATION_MODE_ON
+ : D3D12_CONSERVATIVE_RASTERIZATION_MODE_OFF;
}
{
D3D12_BLEND_DESC& blend = psoDesc.BlendState;
blend.IndependentBlendEnable = FALSE;
- blend.AlphaToCoverageEnable = desc.graphics.blend.alphaToCoverageEnable ? TRUE : FALSE;
- blend.RenderTarget[0].RenderTargetWriteMask = (uint8_t)RenderTargetWriteMask::EnableAll;
+ blend.AlphaToCoverageEnable =
+ desc.graphics.blend.alphaToCoverageEnable ? TRUE : FALSE;
+ blend.RenderTarget[0].RenderTargetWriteMask =
+ (uint8_t)RenderTargetWriteMask::EnableAll;
for (GfxIndex i = 0; i < desc.graphics.blend.targetCount; i++)
{
auto& d3dDesc = blend.RenderTarget[i];
d3dDesc.BlendEnable = desc.graphics.blend.targets[i].enableBlend ? TRUE : FALSE;
d3dDesc.BlendOp = D3DUtil::getBlendOp(desc.graphics.blend.targets[i].color.op);
- d3dDesc.BlendOpAlpha = D3DUtil::getBlendOp(desc.graphics.blend.targets[i].alpha.op);
+ d3dDesc.BlendOpAlpha =
+ D3DUtil::getBlendOp(desc.graphics.blend.targets[i].alpha.op);
d3dDesc.DestBlend =
D3DUtil::getBlendFactor(desc.graphics.blend.targets[i].color.dstFactor);
d3dDesc.DestBlendAlpha =
@@ -141,17 +148,17 @@ Result PipelineStateImpl::ensureAPIPipelineStateCreated()
for (GfxIndex i = 1; i < desc.graphics.blend.targetCount; i++)
{
if (memcmp(
- &desc.graphics.blend.targets[i],
- &desc.graphics.blend.targets[0],
- sizeof(desc.graphics.blend.targets[0])) != 0)
+ &desc.graphics.blend.targets[i],
+ &desc.graphics.blend.targets[0],
+ sizeof(desc.graphics.blend.targets[0])) != 0)
{
blend.IndependentBlendEnable = TRUE;
break;
}
}
for (uint32_t i = (uint32_t)desc.graphics.blend.targetCount;
- i < D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT;
- ++i)
+ i < D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT;
+ ++i)
{
blend.RenderTarget[i] = blend.RenderTarget[0];
}
@@ -162,21 +169,21 @@ Result PipelineStateImpl::ensureAPIPipelineStateCreated()
ds.DepthEnable = desc.graphics.depthStencil.depthTestEnable;
ds.DepthWriteMask = desc.graphics.depthStencil.depthWriteEnable
- ? D3D12_DEPTH_WRITE_MASK_ALL
- : D3D12_DEPTH_WRITE_MASK_ZERO;
+ ? D3D12_DEPTH_WRITE_MASK_ALL
+ : D3D12_DEPTH_WRITE_MASK_ZERO;
ds.DepthFunc = D3DUtil::getComparisonFunc(desc.graphics.depthStencil.depthFunc);
ds.StencilEnable = desc.graphics.depthStencil.stencilEnable;
ds.StencilReadMask = (UINT8)desc.graphics.depthStencil.stencilReadMask;
ds.StencilWriteMask = (UINT8)desc.graphics.depthStencil.stencilWriteMask;
- ds.FrontFace = D3DUtil::translateStencilOpDesc(desc.graphics.depthStencil.frontFace);
+ ds.FrontFace =
+ D3DUtil::translateStencilOpDesc(desc.graphics.depthStencil.frontFace);
ds.BackFace = D3DUtil::translateStencilOpDesc(desc.graphics.depthStencil.backFace);
}
psoDesc.PrimitiveTopologyType = D3DUtil::getPrimitiveType(desc.graphics.primitiveType);
-
};
- if(m_program->isMeshShaderProgram())
+ if (m_program->isMeshShaderProgram())
{
D3DX12_MESH_SHADER_PIPELINE_STATE_DESC meshDesc = {};
for (auto& shaderBin : programImpl->m_shaders)
@@ -184,13 +191,13 @@ Result PipelineStateImpl::ensureAPIPipelineStateCreated()
switch (shaderBin.stage)
{
case SLANG_STAGE_FRAGMENT:
- meshDesc.PS = { shaderBin.code.getBuffer(), SIZE_T(shaderBin.code.getCount()) };
+ meshDesc.PS = {shaderBin.code.getBuffer(), SIZE_T(shaderBin.code.getCount())};
break;
case SLANG_STAGE_AMPLIFICATION:
- meshDesc.AS = { shaderBin.code.getBuffer(), SIZE_T(shaderBin.code.getCount()) };
+ meshDesc.AS = {shaderBin.code.getBuffer(), SIZE_T(shaderBin.code.getCount())};
break;
case SLANG_STAGE_MESH:
- meshDesc.MS = { shaderBin.code.getBuffer(), SIZE_T(shaderBin.code.getCount()) };
+ meshDesc.MS = {shaderBin.code.getBuffer(), SIZE_T(shaderBin.code.getCount())};
break;
default:
getDebugCallback()->handleMessage(
@@ -213,10 +220,13 @@ Result PipelineStateImpl::ensureAPIPipelineStateCreated()
else
{
CD3DX12_PIPELINE_STATE_STREAM2 meshStateStream{meshDesc};
- D3D12_PIPELINE_STATE_STREAM_DESC streamDesc{sizeof(meshStateStream), &meshStateStream};
+ D3D12_PIPELINE_STATE_STREAM_DESC streamDesc{
+ sizeof(meshStateStream),
+ &meshStateStream};
SLANG_RETURN_ON_FAIL(m_device->m_device5->CreatePipelineState(
- &streamDesc, IID_PPV_ARGS(m_pipelineState.writeRef())));
+ &streamDesc,
+ IID_PPV_ARGS(m_pipelineState.writeRef())));
}
}
else
@@ -227,19 +237,29 @@ Result PipelineStateImpl::ensureAPIPipelineStateCreated()
switch (shaderBin.stage)
{
case SLANG_STAGE_VERTEX:
- graphicsDesc.VS = { shaderBin.code.getBuffer(), SIZE_T(shaderBin.code.getCount()) };
+ graphicsDesc.VS = {
+ shaderBin.code.getBuffer(),
+ SIZE_T(shaderBin.code.getCount())};
break;
case SLANG_STAGE_FRAGMENT:
- graphicsDesc.PS = { shaderBin.code.getBuffer(), SIZE_T(shaderBin.code.getCount()) };
+ graphicsDesc.PS = {
+ shaderBin.code.getBuffer(),
+ SIZE_T(shaderBin.code.getCount())};
break;
case SLANG_STAGE_DOMAIN:
- graphicsDesc.DS = { shaderBin.code.getBuffer(), SIZE_T(shaderBin.code.getCount()) };
+ graphicsDesc.DS = {
+ shaderBin.code.getBuffer(),
+ SIZE_T(shaderBin.code.getCount())};
break;
case SLANG_STAGE_HULL:
- graphicsDesc.HS = { shaderBin.code.getBuffer(), SIZE_T(shaderBin.code.getCount()) };
+ graphicsDesc.HS = {
+ shaderBin.code.getBuffer(),
+ SIZE_T(shaderBin.code.getCount())};
break;
case SLANG_STAGE_GEOMETRY:
- graphicsDesc.GS = { shaderBin.code.getBuffer(), SIZE_T(shaderBin.code.getCount()) };
+ graphicsDesc.GS = {
+ shaderBin.code.getBuffer(),
+ SIZE_T(shaderBin.code.getCount())};
break;
default:
getDebugCallback()->handleMessage(
@@ -254,7 +274,7 @@ Result PipelineStateImpl::ensureAPIPipelineStateCreated()
{
graphicsDesc.InputLayout = {
inputLayoutImpl->m_elements.getBuffer(),
- UINT(inputLayoutImpl->m_elements.getCount()) };
+ UINT(inputLayoutImpl->m_elements.getCount())};
}
fillCommonGraphicsState(graphicsDesc);
@@ -271,7 +291,8 @@ Result PipelineStateImpl::ensureAPIPipelineStateCreated()
else
{
SLANG_RETURN_ON_FAIL(m_device->m_device->CreateGraphicsPipelineState(
- &graphicsDesc, IID_PPV_ARGS(m_pipelineState.writeRef())));
+ &graphicsDesc,
+ IID_PPV_ARGS(m_pipelineState.writeRef())));
}
}
}
@@ -286,11 +307,11 @@ Result PipelineStateImpl::ensureAPIPipelineStateCreated()
D3D12_COMPUTE_PIPELINE_STATE_DESC computeDesc = {};
computeDesc.pRootSignature =
desc.compute.d3d12RootSignatureOverride
- ? static_cast<ID3D12RootSignature*>(desc.compute.d3d12RootSignatureOverride)
- : programImpl->m_rootObjectLayout->m_rootSignature;
+ ? static_cast<ID3D12RootSignature*>(desc.compute.d3d12RootSignatureOverride)
+ : programImpl->m_rootObjectLayout->m_rootSignature;
computeDesc.CS = {
programImpl->m_shaders[0].code.getBuffer(),
- SIZE_T(programImpl->m_shaders[0].code.getCount()) };
+ SIZE_T(programImpl->m_shaders[0].code.getCount())};
#ifdef GFX_NVAPI
if (m_device->m_nvapi)
@@ -307,7 +328,7 @@ Result PipelineStateImpl::ensureAPIPipelineStateCreated()
// Put the pointer to the extension into an array - there can be multiple extensions
// enabled at once.
- const NVAPI_D3D12_PSO_EXTENSION_DESC* extensions[] = { &extensionDesc };
+ const NVAPI_D3D12_PSO_EXTENSION_DESC* extensions[] = {&extensionDesc};
// Now create the PSO.
const NvAPI_Status nvapiStatus = NvAPI_D3D12_CreateComputePipelineState(
@@ -337,7 +358,8 @@ Result PipelineStateImpl::ensureAPIPipelineStateCreated()
else
{
SLANG_RETURN_ON_FAIL(m_device->m_device->CreateComputePipelineState(
- &computeDesc, IID_PPV_ARGS(m_pipelineState.writeRef())));
+ &computeDesc,
+ IID_PPV_ARGS(m_pipelineState.writeRef())));
}
}
}
@@ -350,7 +372,8 @@ Result PipelineStateImpl::ensureAPIPipelineStateCreated()
RayTracingPipelineStateImpl::RayTracingPipelineStateImpl(DeviceImpl* device)
: m_device(device)
-{}
+{
+}
void RayTracingPipelineStateImpl::init(const RayTracingPipelineStateDesc& inDesc)
{
@@ -405,12 +428,16 @@ Result RayTracingPipelineStateImpl::ensureAPIPipelineStateCreated()
subObjects.add(pipelineConfigSubobject);
auto compileShader = [&](slang::EntryPointLayout* entryPointInfo,
- slang::IComponentType* component,
- SlangInt entryPointIndex)
+ slang::IComponentType* component,
+ SlangInt entryPointIndex)
{
ComPtr<ISlangBlob> codeBlob;
- auto compileResult = m_device->getEntryPointCodeFromShaderCache(component,
- entryPointIndex, 0, codeBlob.writeRef(), diagnostics.writeRef());
+ auto compileResult = m_device->getEntryPointCodeFromShaderCache(
+ component,
+ entryPointIndex,
+ 0,
+ codeBlob.writeRef(),
+ diagnostics.writeRef());
if (diagnostics.get())
{
getDebugCallback()->handleMessage(
@@ -441,7 +468,9 @@ Result RayTracingPipelineStateImpl::ensureAPIPipelineStateCreated()
for (SlangUInt i = 0; i < programLayout->getEntryPointCount(); i++)
{
SLANG_RETURN_ON_FAIL(compileShader(
- programLayout->getEntryPointByIndex(i), program->linkedProgram, (SlangInt)i));
+ programLayout->getEntryPointByIndex(i),
+ program->linkedProgram,
+ (SlangInt)i));
}
}
else
@@ -458,8 +487,8 @@ Result RayTracingPipelineStateImpl::ensureAPIPipelineStateCreated()
auto& hitGroup = desc.rayTracing.hitGroups[i];
D3D12_HIT_GROUP_DESC hitGroupDesc = {};
hitGroupDesc.Type = hitGroup.intersectionEntryPoint.getLength() == 0
- ? D3D12_HIT_GROUP_TYPE_TRIANGLES
- : D3D12_HIT_GROUP_TYPE_PROCEDURAL_PRIMITIVE;
+ ? D3D12_HIT_GROUP_TYPE_TRIANGLES
+ : D3D12_HIT_GROUP_TYPE_PROCEDURAL_PRIMITIVE;
if (hitGroup.anyHitEntryPoint.getLength())
{
@@ -503,7 +532,8 @@ Result RayTracingPipelineStateImpl::ensureAPIPipelineStateCreated()
if (m_device->m_pipelineCreationAPIDispatcher)
{
m_device->m_pipelineCreationAPIDispatcher->beforeCreateRayTracingState(
- m_device, slangGlobalScope);
+ m_device,
+ slangGlobalScope);
}
D3D12_STATE_OBJECT_DESC rtpsoDesc = {};
@@ -516,7 +546,8 @@ Result RayTracingPipelineStateImpl::ensureAPIPipelineStateCreated()
if (m_device->m_pipelineCreationAPIDispatcher)
{
m_device->m_pipelineCreationAPIDispatcher->afterCreateRayTracingState(
- m_device, slangGlobalScope);
+ m_device,
+ slangGlobalScope);
}
return SLANG_OK;
}
diff --git a/tools/gfx/d3d12/d3d12-pipeline-state.h b/tools/gfx/d3d12/d3d12-pipeline-state.h
index a22e04a05..21645642a 100644
--- a/tools/gfx/d3d12/d3d12-pipeline-state.h
+++ b/tools/gfx/d3d12/d3d12-pipeline-state.h
@@ -15,7 +15,8 @@ class PipelineStateImpl : public PipelineStateBase
public:
PipelineStateImpl(DeviceImpl* device)
: m_device(device)
- {}
+ {
+ }
DeviceImpl* m_device;
ComPtr<ID3D12PipelineState> m_pipelineState;
void init(const GraphicsPipelineStateDesc& inDesc);
diff --git a/tools/gfx/d3d12/d3d12-posix-synchapi.cpp b/tools/gfx/d3d12/d3d12-posix-synchapi.cpp
index b979bb3cc..292f692d6 100644
--- a/tools/gfx/d3d12/d3d12-posix-synchapi.cpp
+++ b/tools/gfx/d3d12/d3d12-posix-synchapi.cpp
@@ -6,6 +6,7 @@
#include "core/slang-common.h"
+#include <cerrno>
#include <fcntl.h>
#include <sys/epoll.h>
#include <sys/eventfd.h>
@@ -13,8 +14,6 @@
#include <sys/timerfd.h>
#include <unistd.h>
-#include <cerrno>
-
// To keep aligned with the d3d12 API, we store file descriptors in the low 32
// bits of HANDLEs.
static int _handleToFD(HANDLE h)
@@ -41,16 +40,16 @@ static HANDLE _fdToHandle(int fd, int flags)
HANDLE CreateEventEx(
LPSECURITY_ATTRIBUTES lpEventAttributes,
- LPCSTR lpName,
- DWORD dwFlags,
- DWORD dwDesiredAccess)
+ LPCSTR lpName,
+ DWORD dwFlags,
+ DWORD dwDesiredAccess)
{
int fd = ::eventfd(dwFlags & CREATE_EVENT_INITIAL_SET ? 1 : 0, EFD_CLOEXEC | EFD_NONBLOCK);
// Make sure not to return a zero handle, duplicate the fd if necessary
- if(fd == 0)
+ if (fd == 0)
{
int nextFd = fcntl(fd, F_DUPFD_CLOEXEC, 0);
- if(fcntl(nextFd, F_SETFL, O_NONBLOCK) == -1)
+ if (fcntl(nextFd, F_SETFL, O_NONBLOCK) == -1)
{
close(nextFd);
nextFd = -1;
@@ -63,7 +62,7 @@ HANDLE CreateEventEx(
BOOL CloseHandle(HANDLE h)
{
- if(h == 0)
+ if (h == 0)
{
return 1;
}
@@ -79,22 +78,22 @@ BOOL ResetEvent(HANDLE h)
uint64_t x;
int r = 0;
int nEvents = poll(&pfd, 1, 0);
- if(pfd.revents != POLLIN)
+ if (pfd.revents != POLLIN)
{
// Nothing to read, already reset
return 1;
}
- if(nEvents != 1)
+ if (nEvents != 1)
{
return 0;
}
r = read(fd, &x, sizeof(x));
- if(r == sizeof(x))
+ if (r == sizeof(x))
{
// We reset it
return 1;
}
- if(r == -1 && errno == EAGAIN)
+ if (r == -1 && errno == EAGAIN)
{
// Something else reset it
return 1;
@@ -106,18 +105,18 @@ BOOL SetEvent(HANDLE h)
{
int fd = _handleToFD(h);
pollfd pfd{fd, POLLOUT, 0};
- for(;;)
+ for (;;)
{
int nEvents = poll(&pfd, 1, -1);
SLANG_ASSERT(nEvents != -1);
SLANG_ASSERT(nEvents != 0); // shouldn't have timed out
const uint64_t one = 1;
int w = ::write(fd, &one, sizeof(one));
- if(w == sizeof(one))
+ if (w == sizeof(one))
{
return 1;
}
- if(errno != EAGAIN)
+ if (errno != EAGAIN)
{
return 0;
}
@@ -137,11 +136,11 @@ DWORD WaitForSingleObject(const HANDLE h, const DWORD ms)
const bool isInfinite = ms == INFINITE;
const DWORD fiveSeconds = 5000;
int nEvents = poll(&pfd, 1, isInfinite ? fiveSeconds : ms);
- if(pfd.revents != POLLIN)
+ if (pfd.revents != POLLIN)
{
return WAIT_FAILED;
}
- if(nEvents == -1)
+ if (nEvents == -1)
{
return WAIT_FAILED;
}
@@ -149,29 +148,25 @@ DWORD WaitForSingleObject(const HANDLE h, const DWORD ms)
{
return isInfinite ? WAIT_FAILED : WAIT_TIMEOUT;
}
- if(manualReset)
+ if (manualReset)
{
return WAIT_OBJECT_0;
}
r = read(fd, &x, sizeof(x));
- if(r == sizeof(x))
+ if (r == sizeof(x))
{
return WAIT_OBJECT_0;
}
- if(r == -1 && errno == EAGAIN)
+ if (r == -1 && errno == EAGAIN)
{
return isInfinite ? WAIT_FAILED : WAIT_TIMEOUT;
}
return WAIT_FAILED;
}
-DWORD WaitForMultipleObjects(
- DWORD n,
- const HANDLE *hs,
- BOOL bWaitAll,
- DWORD requestedMs)
+DWORD WaitForMultipleObjects(DWORD n, const HANDLE* hs, BOOL bWaitAll, DWORD requestedMs)
{
- if(n == 0)
+ if (n == 0)
{
return bWaitAll ? WAIT_OBJECT_0 : WAIT_FAILED;
}
@@ -185,22 +180,22 @@ DWORD WaitForMultipleObjects(
DWORD res;
int fds[n];
int flagss[n];
- epoll_event evs[n+1]; // +1 for our timer
+ epoll_event evs[n + 1]; // +1 for our timer
int ufd = -1;
int epfd = epoll_create1(EPOLL_CLOEXEC);
- if(epfd == -1)
+ if (epfd == -1)
{
goto fail;
}
- for(int i = 0; i < n; ++i)
+ for (int i = 0; i < n; ++i)
{
fds[i] = _handleToFD(hs[i]);
flagss[i] = _handleToFlags(hs[i]);
epoll_event ev;
ev.data.fd = fds[i];
ev.events = EPOLLIN | EPOLLONESHOT;
- if(epoll_ctl(epfd, EPOLL_CTL_ADD, fds[i], &ev) == -1)
+ if (epoll_ctl(epfd, EPOLL_CTL_ADD, fds[i], &ev) == -1)
{
goto fail;
}
@@ -214,13 +209,13 @@ DWORD WaitForMultipleObjects(
// after the other, and put the values back if we can't claim them all, it
// sucks.
//
- if(bWaitAll)
+ if (bWaitAll)
{
// Use a timer to easily know for sure when we've timed out
- if(dwMilliseconds != INFINITE)
+ if (dwMilliseconds != INFINITE)
{
ufd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);
- if(ufd == -1)
+ if (ufd == -1)
{
goto fail;
}
@@ -229,13 +224,13 @@ DWORD WaitForMultipleObjects(
spec.it_interval.tv_nsec = 0;
spec.it_value.tv_sec = 0;
spec.it_value.tv_nsec = 1000000 * dwMilliseconds;
- if(timerfd_settime(ufd, 0, &spec, nullptr) == -1)
+ if (timerfd_settime(ufd, 0, &spec, nullptr) == -1)
{
goto fail;
}
evs[n].data.fd = ufd;
evs[n].events = EPOLLIN | EPOLLONESHOT;
- if(epoll_ctl(epfd, EPOLL_CTL_ADD, ufd, &evs[n]) == -1)
+ if (epoll_ctl(epfd, EPOLL_CTL_ADD, ufd, &evs[n]) == -1)
{
goto fail;
}
@@ -250,29 +245,29 @@ DWORD WaitForMultipleObjects(
do
{
// Wait until epoll tells us they're all available, or the timer is
- const int nEvents = epoll_wait(epfd, evs, n+1, -1);
+ const int nEvents = epoll_wait(epfd, evs, n + 1, -1);
// We didn't specify a timeout, so 0 results is abnormal
- if(nEvents < 1)
+ if (nEvents < 1)
{
goto fail;
}
// Process all the returned fds
- for(int i = 0; i < nEvents; ++i)
+ for (int i = 0; i < nEvents; ++i)
{
- if(!(evs[i].events & EPOLLIN))
+ if (!(evs[i].events & EPOLLIN))
{
// Something exceptional happened on the fd
// Possibly we could just continue and hope it doesn't
// happen again?
goto fail;
}
- if(evs[i].data.fd == ufd)
+ if (evs[i].data.fd == ufd)
{
// We're out of time, make this the last loop
uint64_t x;
int r = read(ufd, &x, sizeof(x));
- if(r == sizeof(x))
+ if (r == sizeof(x))
{
timesUp = true;
}
@@ -287,11 +282,10 @@ DWORD WaitForMultipleObjects(
++nSeenEvents;
}
}
- }
- while(!(timesUp || nSeenEvents == n));
+ } while (!(timesUp || nSeenEvents == n));
// If we got here without seeing enough events, we must have timed out
- if(nSeenEvents < n)
+ if (nSeenEvents < n)
{
res = isInfinite ? WAIT_FAILED : WAIT_TIMEOUT;
goto end;
@@ -303,51 +297,52 @@ DWORD WaitForMultipleObjects(
// makes the code a bit cleaner.
// Put all the events back in our epoll instance and see if they're
// all readable.
- for(int i = 0; i < n; ++i)
+ for (int i = 0; i < n; ++i)
{
epoll_event modEv;
modEv.data.fd = fds[i];
modEv.events = EPOLLIN | EPOLLONESHOT;
- if(epoll_ctl(epfd, EPOLL_CTL_MOD, fds[i], &modEv) == -1)
+ if (epoll_ctl(epfd, EPOLL_CTL_MOD, fds[i], &modEv) == -1)
{
goto fail;
}
}
// Remove the timer if we're using it
- if(dwMilliseconds != INFINITE && epoll_ctl(epfd, EPOLL_CTL_DEL, ufd, nullptr) == -1)
+ if (dwMilliseconds != INFINITE && epoll_ctl(epfd, EPOLL_CTL_DEL, ufd, nullptr) == -1)
{
goto fail;
}
int nEvents = epoll_wait(epfd, evs, n, 0);
- if(nEvents < 0)
+ if (nEvents < 0)
{
goto fail;
}
- else if(nEvents < n)
+ else if (nEvents < n)
{
// They're not all still available :(
// Put our timer back in and try again from the top
- if(dwMilliseconds != INFINITE && epoll_ctl(epfd, EPOLL_CTL_ADD, ufd, &evs[n]) == -1)
+ if (dwMilliseconds != INFINITE &&
+ epoll_ctl(epfd, EPOLL_CTL_ADD, ufd, &evs[n]) == -1)
{
goto fail;
}
// Put back the any fds which did trigger
- for(int i = 0; i < nEvents; ++i)
+ for (int i = 0; i < nEvents; ++i)
{
epoll_event modEv = evs[i];
modEv.events = EPOLLIN | EPOLLONESHOT;
- if(epoll_ctl(epfd, EPOLL_CTL_MOD, modEv.data.fd, &modEv) == -1)
+ if (epoll_ctl(epfd, EPOLL_CTL_MOD, modEv.data.fd, &modEv) == -1)
{
goto fail;
}
}
continue;
}
- else if(nEvents == n)
+ else if (nEvents == n)
{
- for(int i = 0; i < nEvents; ++i)
+ for (int i = 0; i < nEvents; ++i)
{
- if(!(evs->events & EPOLLIN))
+ if (!(evs->events & EPOLLIN))
{
goto fail;
}
@@ -358,19 +353,19 @@ DWORD WaitForMultipleObjects(
uint64_t vs[n];
int i;
bool failure = false;
- for(i = 0; i < n; ++i)
+ for (i = 0; i < n; ++i)
{
- if(flagss[i] & CREATE_EVENT_MANUAL_RESET)
+ if (flagss[i] & CREATE_EVENT_MANUAL_RESET)
{
// We don't need to read this to unset it
continue;
}
int r = read(fds[i], &vs[i], sizeof(vs[i]));
- if(r == sizeof(vs[i]))
+ if (r == sizeof(vs[i]))
{
continue;
}
- else if(r == -1 && errno == EAGAIN)
+ else if (r == -1 && errno == EAGAIN)
{
// contention, put things back and try again
break;
@@ -385,9 +380,9 @@ DWORD WaitForMultipleObjects(
if (i < n)
{
// contention or failure
- for(int j = 0; j < i; ++j)
+ for (int j = 0; j < i; ++j)
{
- if(flagss[i] & CREATE_EVENT_MANUAL_RESET)
+ if (flagss[i] & CREATE_EVENT_MANUAL_RESET)
{
// We didn't read, so we shouldn't write
continue;
@@ -401,7 +396,7 @@ DWORD WaitForMultipleObjects(
int w = write(fds[j], &vs[j], sizeof(vs[j]));
SLANG_ASSERT(w == sizeof(vs[j]));
}
- if(failure)
+ if (failure)
{
goto fail;
}
@@ -413,28 +408,29 @@ DWORD WaitForMultipleObjects(
goto end;
}
- // If we get here then we've got some contention, go back to the top and try again (or timeout)
- }
- while(!timesUp);
+ // If we get here then we've got some contention, go back to the top and try again (or
+ // timeout)
+ } while (!timesUp);
}
else
{
// Wait any
- const int nEvents = epoll_wait(epfd, evs, n, dwMilliseconds == INFINITE ? -1 : dwMilliseconds);
- if(nEvents == -1)
+ const int nEvents =
+ epoll_wait(epfd, evs, n, dwMilliseconds == INFINITE ? -1 : dwMilliseconds);
+ if (nEvents == -1)
{
goto fail;
}
- if(nEvents == 0)
+ if (nEvents == 0)
{
res = isInfinite ? WAIT_FAILED : WAIT_TIMEOUT;
goto end;
}
// Try reads until we get one
- for(int i = 0; i < nEvents; ++i)
+ for (int i = 0; i < nEvents; ++i)
{
uint64_t x;
- if(!evs[i].events & EPOLLIN)
+ if (!evs[i].events & EPOLLIN)
{
continue;
}
diff --git a/tools/gfx/d3d12/d3d12-posix-synchapi.h b/tools/gfx/d3d12/d3d12-posix-synchapi.h
index ba5a15b0a..15aef9418 100644
--- a/tools/gfx/d3d12/d3d12-posix-synchapi.h
+++ b/tools/gfx/d3d12/d3d12-posix-synchapi.h
@@ -33,20 +33,20 @@
#define WAIT_FAILED 0xffffffff
#define WAIT_OBJECT_0 0
-typedef struct _SECURITY_ATTRIBUTES *LPSECURITY_ATTRIBUTES;
+typedef struct _SECURITY_ATTRIBUTES* LPSECURITY_ATTRIBUTES;
#define CREATE_EVENT_MANUAL_RESET 1
-#define CREATE_EVENT_INITIAL_SET 2
+#define CREATE_EVENT_INITIAL_SET 2
-#define SYNCHRONIZE 0x00100000
-#define STANDARD_RIGHTS_REQUIRED 0x000f0000
-#define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED|SYNCHRONIZE|0x3)
+#define SYNCHRONIZE 0x00100000
+#define STANDARD_RIGHTS_REQUIRED 0x000f0000
+#define EVENT_ALL_ACCESS (STANDARD_RIGHTS_REQUIRED | SYNCHRONIZE | 0x3)
HANDLE CreateEventEx(
LPSECURITY_ATTRIBUTES lpEventAttributes,
- LPCSTR lpName,
- DWORD dwFlags,
- DWORD dwDesiredAccess);
+ LPCSTR lpName,
+ DWORD dwFlags,
+ DWORD dwDesiredAccess);
BOOL CloseHandle(HANDLE h);
@@ -57,9 +57,9 @@ BOOL SetEvent(HANDLE h);
DWORD WaitForSingleObject(HANDLE h, DWORD ms);
DWORD WaitForMultipleObjects(
- DWORD nHandles,
- const HANDLE *handles,
- BOOL bWaitAll,
- DWORD dwMilliseconds);
+ DWORD nHandles,
+ const HANDLE* handles,
+ BOOL bWaitAll,
+ DWORD dwMilliseconds);
#endif // SLANG_LINUX_FAMILY
diff --git a/tools/gfx/d3d12/d3d12-query.cpp b/tools/gfx/d3d12/d3d12-query.cpp
index 6b2e92980..d0191e349 100644
--- a/tools/gfx/d3d12/d3d12-query.cpp
+++ b/tools/gfx/d3d12/d3d12-query.cpp
@@ -2,7 +2,6 @@
#include "d3d12-query.h"
#include "d3d12-command-queue.h"
-
#include "d3d12-helper-functions.h"
namespace gfx
@@ -26,8 +25,7 @@ Result QueryPoolImpl::init(const IQueryPool::Desc& desc, DeviceImpl* device)
heapDesc.Type = D3D12_QUERY_HEAP_TYPE_TIMESTAMP;
m_queryType = D3D12_QUERY_TYPE_TIMESTAMP;
break;
- default:
- return SLANG_E_INVALID_ARG;
+ default: return SLANG_E_INVALID_ARG;
}
// Create query heap.
@@ -54,7 +52,8 @@ Result QueryPoolImpl::init(const IQueryPool::Desc& desc, DeviceImpl* device)
// Create command allocator.
SLANG_RETURN_ON_FAIL(d3dDevice->CreateCommandAllocator(
- D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(m_commandAllocator.writeRef())));
+ D3D12_COMMAND_LIST_TYPE_DIRECT,
+ IID_PPV_ARGS(m_commandAllocator.writeRef())));
// Create command list.
SLANG_RETURN_ON_FAIL(d3dDevice->CreateCommandList(
@@ -99,7 +98,8 @@ Result QueryPoolImpl::getResult(GfxIndex queryIndex, GfxCount count, uint64_t* d
int8_t* mappedData = nullptr;
D3D12_RANGE readRange = {
- sizeof(uint64_t) * queryIndex, sizeof(uint64_t) * (queryIndex + count) };
+ sizeof(uint64_t) * queryIndex,
+ sizeof(uint64_t) * (queryIndex + count)};
m_readBackBuffer.getResource()->Map(0, &readRange, (void**)&mappedData);
memcpy(data, mappedData + sizeof(uint64_t) * queryIndex, sizeof(uint64_t) * count);
m_readBackBuffer.getResource()->Unmap(0, nullptr);
@@ -119,7 +119,9 @@ IQueryPool* PlainBufferProxyQueryPoolImpl::getInterface(const Guid& guid)
}
Result PlainBufferProxyQueryPoolImpl::init(
- const IQueryPool::Desc& desc, DeviceImpl* device, uint32_t stride)
+ const IQueryPool::Desc& desc,
+ DeviceImpl* device,
+ uint32_t stride)
{
ComPtr<IBufferResource> bufferResource;
IBufferResource::Desc bufferDesc = {};
@@ -187,8 +189,8 @@ Result PlainBufferProxyQueryPoolImpl::getResult(GfxIndex queryIndex, GfxCount co
D3D12_RESOURCE_STATE_COPY_DEST,
nullptr));
- encodeInfo.d3dCommandList->CopyBufferRegion(
- stageBuf, 0, m_bufferResource->m_resource.getResource(), 0, size);
+ encodeInfo.d3dCommandList
+ ->CopyBufferRegion(stageBuf, 0, m_bufferResource->m_resource.getResource(), 0, size);
m_device->submitResourceCommandsAndWait(encodeInfo);
void* ptr = nullptr;
stageBuf.getResource()->Map(0, nullptr, &ptr);
diff --git a/tools/gfx/d3d12/d3d12-query.h b/tools/gfx/d3d12/d3d12-query.h
index 770990e81..dff3fbd21 100644
--- a/tools/gfx/d3d12/d3d12-query.h
+++ b/tools/gfx/d3d12/d3d12-query.h
@@ -2,8 +2,8 @@
#pragma once
#include "d3d12-base.h"
-#include "d3d12-device.h"
#include "d3d12-buffer.h"
+#include "d3d12-device.h"
namespace gfx
{
@@ -18,7 +18,7 @@ public:
Result init(const IQueryPool::Desc& desc, DeviceImpl* device);
virtual SLANG_NO_THROW Result SLANG_MCALL
- getResult(GfxIndex queryIndex, GfxCount count, uint64_t* data) override;
+ getResult(GfxIndex queryIndex, GfxCount count, uint64_t* data) override;
void writeTimestamp(ID3D12GraphicsCommandList* cmdList, GfxIndex index);
@@ -41,14 +41,14 @@ class PlainBufferProxyQueryPoolImpl : public QueryPoolBase
{
public:
SLANG_COM_OBJECT_IUNKNOWN_ALL
- IQueryPool* getInterface(const Guid& guid);
+ IQueryPool* getInterface(const Guid& guid);
public:
Result init(const IQueryPool::Desc& desc, DeviceImpl* device, uint32_t stride);
virtual SLANG_NO_THROW Result SLANG_MCALL reset() override;
virtual SLANG_NO_THROW Result SLANG_MCALL
- getResult(GfxIndex queryIndex, GfxCount count, uint64_t* data) override;
+ getResult(GfxIndex queryIndex, GfxCount count, uint64_t* data) override;
public:
QueryType m_queryType;
diff --git a/tools/gfx/d3d12/d3d12-resource-views.cpp b/tools/gfx/d3d12/d3d12-resource-views.cpp
index b156f6ab6..a760caef8 100644
--- a/tools/gfx/d3d12/d3d12-resource-views.cpp
+++ b/tools/gfx/d3d12/d3d12-resource-views.cpp
@@ -1,5 +1,6 @@
// d3d12-resource-views.cpp
#include "d3d12-resource-views.h"
+
#include "d3d12-device.h"
namespace gfx
@@ -34,104 +35,106 @@ SlangResult createD3D12BufferDescriptor(
const auto counterResourceImpl = static_cast<BufferResourceImpl*>(counterBuffer);
uint64_t offset = desc.bufferRange.offset;
- uint64_t size = desc.bufferRange.size == 0 ? buffer->getDesc()->sizeInBytes - offset : desc.bufferRange.size;
+ uint64_t size = desc.bufferRange.size == 0 ? buffer->getDesc()->sizeInBytes - offset
+ : desc.bufferRange.size;
switch (desc.type)
{
- default:
- return SLANG_FAIL;
+ default: return SLANG_FAIL;
case IResourceView::Type::UnorderedAccess:
- {
- D3D12_UNORDERED_ACCESS_VIEW_DESC uavDesc = {};
- uavDesc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER;
- uavDesc.Format = D3DUtil::getMapFormat(desc.format);
- if (bufferStride)
- {
- uavDesc.Buffer.FirstElement = offset / bufferStride;
- uavDesc.Buffer.NumElements = UINT(size / bufferStride);
- uavDesc.Buffer.StructureByteStride = bufferStride;
- }
- else if (desc.format == Format::Unknown)
- {
- uavDesc.Format = DXGI_FORMAT_R32_TYPELESS;
- uavDesc.Buffer.FirstElement = offset / 4;
- uavDesc.Buffer.NumElements = UINT(size / 4);
- uavDesc.Buffer.Flags |= D3D12_BUFFER_UAV_FLAG_RAW;
- }
- else
{
- FormatInfo sizeInfo;
- gfxGetFormatInfo(desc.format, &sizeInfo);
- assert(sizeInfo.pixelsPerBlock == 1);
- uavDesc.Buffer.FirstElement = offset / sizeInfo.blockSizeInBytes;
- uavDesc.Buffer.NumElements = UINT(size / sizeInfo.blockSizeInBytes);
+ D3D12_UNORDERED_ACCESS_VIEW_DESC uavDesc = {};
+ uavDesc.ViewDimension = D3D12_UAV_DIMENSION_BUFFER;
+ uavDesc.Format = D3DUtil::getMapFormat(desc.format);
+ if (bufferStride)
+ {
+ uavDesc.Buffer.FirstElement = offset / bufferStride;
+ uavDesc.Buffer.NumElements = UINT(size / bufferStride);
+ uavDesc.Buffer.StructureByteStride = bufferStride;
+ }
+ else if (desc.format == Format::Unknown)
+ {
+ uavDesc.Format = DXGI_FORMAT_R32_TYPELESS;
+ uavDesc.Buffer.FirstElement = offset / 4;
+ uavDesc.Buffer.NumElements = UINT(size / 4);
+ uavDesc.Buffer.Flags |= D3D12_BUFFER_UAV_FLAG_RAW;
+ }
+ else
+ {
+ FormatInfo sizeInfo;
+ gfxGetFormatInfo(desc.format, &sizeInfo);
+ assert(sizeInfo.pixelsPerBlock == 1);
+ uavDesc.Buffer.FirstElement = offset / sizeInfo.blockSizeInBytes;
+ uavDesc.Buffer.NumElements = UINT(size / sizeInfo.blockSizeInBytes);
+ }
+
+ if (size >= (1ull << 32) - 8)
+ {
+ // D3D12 does not support view descriptors that has size near 4GB.
+ // We will not create actual SRV/UAVs for such large buffers.
+ // However, a buffer this large can still be bound as root parameter.
+ // So instead of failing, we quietly ignore descriptor creation.
+ outDescriptor->cpuHandle.ptr = 0;
+ }
+ else
+ {
+ SLANG_RETURN_ON_FAIL(descriptorHeap->allocate(outDescriptor));
+ device->m_device->CreateUnorderedAccessView(
+ resourceImpl->m_resource,
+ counterResourceImpl ? counterResourceImpl->m_resource.getResource() : nullptr,
+ &uavDesc,
+ outDescriptor->cpuHandle);
+ }
}
-
- if (size >= (1ull << 32) - 8)
- {
- // D3D12 does not support view descriptors that has size near 4GB.
- // We will not create actual SRV/UAVs for such large buffers.
- // However, a buffer this large can still be bound as root parameter.
- // So instead of failing, we quietly ignore descriptor creation.
- outDescriptor->cpuHandle.ptr = 0;
- }
- else
- {
- SLANG_RETURN_ON_FAIL(descriptorHeap->allocate(outDescriptor));
- device->m_device->CreateUnorderedAccessView(
- resourceImpl->m_resource,
- counterResourceImpl ? counterResourceImpl->m_resource.getResource() : nullptr,
- &uavDesc,
- outDescriptor->cpuHandle);
- }
- }
- break;
+ break;
case IResourceView::Type::ShaderResource:
- {
- D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
- srvDesc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER;
- srvDesc.Format = D3DUtil::getMapFormat(desc.format);
- srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
- if (bufferStride)
- {
- srvDesc.Buffer.FirstElement = offset / bufferStride;
- srvDesc.Buffer.NumElements = UINT(size / bufferStride);
- srvDesc.Buffer.StructureByteStride = bufferStride;
- }
- else if (desc.format == Format::Unknown)
{
- srvDesc.Format = DXGI_FORMAT_R32_TYPELESS;
- srvDesc.Buffer.FirstElement = offset / 4;
- srvDesc.Buffer.NumElements = UINT(size / 4);
- srvDesc.Buffer.Flags |= D3D12_BUFFER_SRV_FLAG_RAW;
+ D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
+ srvDesc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER;
+ srvDesc.Format = D3DUtil::getMapFormat(desc.format);
+ srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
+ if (bufferStride)
+ {
+ srvDesc.Buffer.FirstElement = offset / bufferStride;
+ srvDesc.Buffer.NumElements = UINT(size / bufferStride);
+ srvDesc.Buffer.StructureByteStride = bufferStride;
+ }
+ else if (desc.format == Format::Unknown)
+ {
+ srvDesc.Format = DXGI_FORMAT_R32_TYPELESS;
+ srvDesc.Buffer.FirstElement = offset / 4;
+ srvDesc.Buffer.NumElements = UINT(size / 4);
+ srvDesc.Buffer.Flags |= D3D12_BUFFER_SRV_FLAG_RAW;
+ }
+ else
+ {
+ FormatInfo sizeInfo;
+ gfxGetFormatInfo(desc.format, &sizeInfo);
+ assert(sizeInfo.pixelsPerBlock == 1);
+ srvDesc.Buffer.FirstElement = offset / sizeInfo.blockSizeInBytes;
+ srvDesc.Buffer.NumElements = UINT(size / sizeInfo.blockSizeInBytes);
+ }
+
+ if (size >= (1ull << 32) - 8)
+ {
+ // D3D12 does not support view descriptors that has size near 4GB.
+ // We will not create actual SRV/UAVs for such large buffers.
+ // However, a buffer this large can still be bound as root parameter.
+ // So instead of failing, we quietly ignore descriptor creation.
+ outDescriptor->cpuHandle.ptr = 0;
+ }
+ else
+ {
+ SLANG_RETURN_ON_FAIL(descriptorHeap->allocate(outDescriptor));
+ device->m_device->CreateShaderResourceView(
+ resourceImpl->m_resource,
+ &srvDesc,
+ outDescriptor->cpuHandle);
+ }
}
- else
- {
- FormatInfo sizeInfo;
- gfxGetFormatInfo(desc.format, &sizeInfo);
- assert(sizeInfo.pixelsPerBlock == 1);
- srvDesc.Buffer.FirstElement = offset / sizeInfo.blockSizeInBytes;
- srvDesc.Buffer.NumElements = UINT(size / sizeInfo.blockSizeInBytes);
- }
-
- if (size >= (1ull << 32) - 8)
- {
- // D3D12 does not support view descriptors that has size near 4GB.
- // We will not create actual SRV/UAVs for such large buffers.
- // However, a buffer this large can still be bound as root parameter.
- // So instead of failing, we quietly ignore descriptor creation.
- outDescriptor->cpuHandle.ptr = 0;
- }
- else
- {
- SLANG_RETURN_ON_FAIL(descriptorHeap->allocate(outDescriptor));
- device->m_device->CreateShaderResourceView(
- resourceImpl->m_resource, &srvDesc, outDescriptor->cpuHandle);
- }
- }
- break;
+ break;
}
return SLANG_OK;
}
diff --git a/tools/gfx/d3d12/d3d12-resource-views.h b/tools/gfx/d3d12/d3d12-resource-views.h
index ac80a9368..379aaa7aa 100644
--- a/tools/gfx/d3d12/d3d12-resource-views.h
+++ b/tools/gfx/d3d12/d3d12-resource-views.h
@@ -1,8 +1,8 @@
// d3d12-resource-views.h
#pragma once
-#include "d3d12-base.h"
#include "../d3d/d3d-util.h"
+#include "d3d12-base.h"
#include "d3d12-buffer.h"
namespace gfx
@@ -44,9 +44,7 @@ SlangResult createD3D12BufferDescriptor(
D3D12GeneralExpandingDescriptorHeap* descriptorHeap,
D3D12Descriptor* outDescriptor);
-class ResourceViewImpl
- : public ResourceViewBase
- , public ResourceViewInternalImpl
+class ResourceViewImpl : public ResourceViewBase, public ResourceViewInternalImpl
{
public:
Slang::RefPtr<Resource> m_resource;
@@ -57,9 +55,7 @@ public:
#if SLANG_GFX_HAS_DXR_SUPPORT
-class AccelerationStructureImpl
- : public AccelerationStructureBase
- , public ResourceViewInternalImpl
+class AccelerationStructureImpl : public AccelerationStructureBase, public ResourceViewInternalImpl
{
public:
RefPtr<BufferResourceImpl> m_buffer;
diff --git a/tools/gfx/d3d12/d3d12-resource.cpp b/tools/gfx/d3d12/d3d12-resource.cpp
index 8975f5825..273e14f29 100644
--- a/tools/gfx/d3d12/d3d12-resource.cpp
+++ b/tools/gfx/d3d12/d3d12-resource.cpp
@@ -1,29 +1,34 @@
// d3d12-resource.cpp
#include "d3d12-resource.h"
-namespace gfx {
+namespace gfx
+{
using namespace Slang;
-/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! D3D12BarrierSubmitter !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
+/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! D3D12BarrierSubmitter
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
void D3D12BarrierSubmitter::_flush()
{
- assert(m_numBarriers > 0);
+ assert(m_numBarriers > 0);
- if (m_commandList)
- {
- m_commandList->ResourceBarrier(UINT(m_numBarriers), m_barriers);
- }
- m_numBarriers = 0;
+ if (m_commandList)
+ {
+ m_commandList->ResourceBarrier(UINT(m_numBarriers), m_barriers);
+ }
+ m_numBarriers = 0;
}
D3D12_RESOURCE_BARRIER& D3D12BarrierSubmitter::_expandOne()
{
- _flush();
- return m_barriers[m_numBarriers++];
+ _flush();
+ return m_barriers[m_numBarriers++];
}
-void D3D12BarrierSubmitter::transition(ID3D12Resource* resource, D3D12_RESOURCE_STATES prevState, D3D12_RESOURCE_STATES nextState)
+void D3D12BarrierSubmitter::transition(
+ ID3D12Resource* resource,
+ D3D12_RESOURCE_STATES prevState,
+ D3D12_RESOURCE_STATES nextState)
{
if (nextState != prevState)
{
@@ -53,11 +58,13 @@ void D3D12BarrierSubmitter::transition(ID3D12Resource* resource, D3D12_RESOURCE_
}
}
-/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! D3D12ResourceBase !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
+/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! D3D12ResourceBase
+ * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
-/* static */DXGI_FORMAT D3D12ResourceBase::calcFormat(D3DUtil::UsageType usage, ID3D12Resource* resource)
+/* static */ DXGI_FORMAT
+D3D12ResourceBase::calcFormat(D3DUtil::UsageType usage, ID3D12Resource* resource)
{
- return resource ? D3DUtil::calcFormat(usage, resource->GetDesc().Format) : DXGI_FORMAT_UNKNOWN;
+ return resource ? D3DUtil::calcFormat(usage, resource->GetDesc().Format) : DXGI_FORMAT_UNKNOWN;
}
void D3D12ResourceBase::transition(
@@ -65,16 +72,16 @@ void D3D12ResourceBase::transition(
D3D12_RESOURCE_STATES nextState,
D3D12BarrierSubmitter& submitter)
{
- // Transition only if there is a resource
+ // Transition only if there is a resource
if (m_resource && oldState != nextState)
- {
+ {
submitter.transition(m_resource, oldState, nextState);
}
}
/* !!!!!!!!!!!!!!!!!!!!!!!!! D3D12Resource !!!!!!!!!!!!!!!!!!!!!!!! */
-/* static */void D3D12Resource::setDebugName(ID3D12Resource* resource, const char* name)
+/* static */ void D3D12Resource::setDebugName(ID3D12Resource* resource, const char* name)
{
if (resource)
{
@@ -84,63 +91,75 @@ void D3D12ResourceBase::transition(
void D3D12Resource::setDebugName(const char* name)
{
- setDebugName(m_resource, name);
+ setDebugName(m_resource, name);
}
void D3D12Resource::setDebugName(const wchar_t* name)
{
- if (m_resource)
- {
- m_resource->SetName(name);
- }
+ if (m_resource)
+ {
+ m_resource->SetName(name);
+ }
}
void D3D12Resource::setResource(ID3D12Resource* resource)
{
- if (resource != m_resource)
- {
- if (resource)
- {
- resource->AddRef();
- }
- if (m_resource)
- {
- m_resource->Release();
- }
- m_resource = resource;
- }
+ if (resource != m_resource)
+ {
+ if (resource)
+ {
+ resource->AddRef();
+ }
+ if (m_resource)
+ {
+ m_resource->Release();
+ }
+ m_resource = resource;
+ }
}
void D3D12Resource::setResourceNull()
{
- if (m_resource)
- {
- m_resource->Release();
- m_resource = nullptr;
- }
+ if (m_resource)
+ {
+ m_resource->Release();
+ m_resource = nullptr;
+ }
}
-Result D3D12Resource::initCommitted(ID3D12Device* device, const D3D12_HEAP_PROPERTIES& heapProps, D3D12_HEAP_FLAGS heapFlags, const D3D12_RESOURCE_DESC& resourceDesc, D3D12_RESOURCE_STATES initState, const D3D12_CLEAR_VALUE * clearValue)
+Result D3D12Resource::initCommitted(
+ ID3D12Device* device,
+ const D3D12_HEAP_PROPERTIES& heapProps,
+ D3D12_HEAP_FLAGS heapFlags,
+ const D3D12_RESOURCE_DESC& resourceDesc,
+ D3D12_RESOURCE_STATES initState,
+ const D3D12_CLEAR_VALUE* clearValue)
{
- setResourceNull();
- ComPtr<ID3D12Resource> resource;
- SLANG_RETURN_ON_FAIL(device->CreateCommittedResource(&heapProps, heapFlags, &resourceDesc, initState, clearValue, IID_PPV_ARGS(resource.writeRef())));
- setResource(resource);
- return SLANG_OK;
+ setResourceNull();
+ ComPtr<ID3D12Resource> resource;
+ SLANG_RETURN_ON_FAIL(device->CreateCommittedResource(
+ &heapProps,
+ heapFlags,
+ &resourceDesc,
+ initState,
+ clearValue,
+ IID_PPV_ARGS(resource.writeRef())));
+ setResource(resource);
+ return SLANG_OK;
}
ID3D12Resource* D3D12Resource::detach()
{
- ID3D12Resource* resource = m_resource;
- m_resource = nullptr;
- return resource;
+ ID3D12Resource* resource = m_resource;
+ m_resource = nullptr;
+ return resource;
}
void D3D12Resource::swap(ComPtr<ID3D12Resource>& resourceInOut)
{
- ID3D12Resource* tmp = m_resource;
- m_resource = resourceInOut.detach();
- resourceInOut.attach(tmp);
+ ID3D12Resource* tmp = m_resource;
+ m_resource = resourceInOut.detach();
+ resourceInOut.attach(tmp);
}
-} // renderer_test
+} // namespace gfx
diff --git a/tools/gfx/d3d12/d3d12-resource.h b/tools/gfx/d3d12/d3d12-resource.h
index cd56793cc..cbf47ed66 100644
--- a/tools/gfx/d3d12/d3d12-resource.h
+++ b/tools/gfx/d3d12/d3d12-resource.h
@@ -11,13 +11,14 @@
#pragma pop_macro("NOMINMAX")
#pragma pop_macro("WIN32_LEAN_AND_MEAN")
-#include <dxgi1_4.h>
-#include <d3d12.h>
-
-#include "slang-com-ptr.h"
#include "../d3d/d3d-util.h"
+#include "slang-com-ptr.h"
-namespace gfx {
+#include <d3d12.h>
+#include <dxgi1_4.h>
+
+namespace gfx
+{
// Enables more conservative barriers - restoring the state of resources after they are used.
// Should not need to be enabled in normal builds, as the barriers should correctly sync resources
@@ -26,95 +27,120 @@ namespace gfx {
struct D3D12BarrierSubmitter
{
- enum { MAX_BARRIERS = 8 };
-
- /// Expand one space to hold a barrier
- SLANG_FORCE_INLINE D3D12_RESOURCE_BARRIER& expandOne() { return (m_numBarriers < MAX_BARRIERS) ? m_barriers[m_numBarriers++] : _expandOne(); }
- /// Flush barriers to command list
- SLANG_FORCE_INLINE void flush() { if (m_numBarriers > 0) _flush(); }
-
- /// Transition resource from prevState to nextState
- void transition(ID3D12Resource* resource, D3D12_RESOURCE_STATES prevState, D3D12_RESOURCE_STATES nextState);
-
- /// Ctor
- SLANG_FORCE_INLINE D3D12BarrierSubmitter(ID3D12GraphicsCommandList* commandList) : m_numBarriers(0), m_commandList(commandList) { }
- /// Dtor
- SLANG_FORCE_INLINE ~D3D12BarrierSubmitter() { flush(); }
+ enum
+ {
+ MAX_BARRIERS = 8
+ };
+
+ /// Expand one space to hold a barrier
+ SLANG_FORCE_INLINE D3D12_RESOURCE_BARRIER& expandOne()
+ {
+ return (m_numBarriers < MAX_BARRIERS) ? m_barriers[m_numBarriers++] : _expandOne();
+ }
+ /// Flush barriers to command list
+ SLANG_FORCE_INLINE void flush()
+ {
+ if (m_numBarriers > 0)
+ _flush();
+ }
+
+ /// Transition resource from prevState to nextState
+ void transition(
+ ID3D12Resource* resource,
+ D3D12_RESOURCE_STATES prevState,
+ D3D12_RESOURCE_STATES nextState);
+
+ /// Ctor
+ SLANG_FORCE_INLINE D3D12BarrierSubmitter(ID3D12GraphicsCommandList* commandList)
+ : m_numBarriers(0), m_commandList(commandList)
+ {
+ }
+ /// Dtor
+ SLANG_FORCE_INLINE ~D3D12BarrierSubmitter() { flush(); }
protected:
- D3D12_RESOURCE_BARRIER& _expandOne();
- void _flush();
+ D3D12_RESOURCE_BARRIER& _expandOne();
+ void _flush();
- ID3D12GraphicsCommandList* m_commandList;
- int m_numBarriers;
- D3D12_RESOURCE_BARRIER m_barriers[MAX_BARRIERS];
+ ID3D12GraphicsCommandList* m_commandList;
+ int m_numBarriers;
+ D3D12_RESOURCE_BARRIER m_barriers[MAX_BARRIERS];
};
-/** The base class for resource types allows for tracking of state. It does not allow for setting of the resource though, such that
-an interface can return a D3D12ResourceBase, and a client cant manipulate it's state, but it cannot replace/change the actual resource */
+/** The base class for resource types allows for tracking of state. It does not allow for setting of
+the resource though, such that an interface can return a D3D12ResourceBase, and a client cant
+manipulate it's state, but it cannot replace/change the actual resource */
struct D3D12ResourceBase
{
- /// Add a transition if necessary to the list
+ /// Add a transition if necessary to the list
void transition(
- D3D12_RESOURCE_STATES currentState,
- D3D12_RESOURCE_STATES nextState,
- D3D12BarrierSubmitter& submitter);
- /// Get the associated resource
- SLANG_FORCE_INLINE ID3D12Resource* getResource() const { return m_resource; }
+ D3D12_RESOURCE_STATES currentState,
+ D3D12_RESOURCE_STATES nextState,
+ D3D12BarrierSubmitter& submitter);
+ /// Get the associated resource
+ SLANG_FORCE_INLINE ID3D12Resource* getResource() const { return m_resource; }
- /// True if a resource is set
- SLANG_FORCE_INLINE bool isSet() const { return m_resource != nullptr; }
+ /// True if a resource is set
+ SLANG_FORCE_INLINE bool isSet() const { return m_resource != nullptr; }
- /// Coercible into ID3D12Resource
- SLANG_FORCE_INLINE operator ID3D12Resource*() const { return m_resource; }
+ /// Coercible into ID3D12Resource
+ SLANG_FORCE_INLINE operator ID3D12Resource*() const { return m_resource; }
- /// Given the usage, flags, and format will return the most suitable format. Will return DXGI_UNKNOWN if combination is not possible
- static DXGI_FORMAT calcFormat(D3DUtil::UsageType usage, ID3D12Resource* resource);
+ /// Given the usage, flags, and format will return the most suitable format. Will return
+ /// DXGI_UNKNOWN if combination is not possible
+ static DXGI_FORMAT calcFormat(D3DUtil::UsageType usage, ID3D12Resource* resource);
- /// Ctor
- SLANG_FORCE_INLINE D3D12ResourceBase() :
- m_resource(nullptr)
- {}
+ /// Ctor
+ SLANG_FORCE_INLINE D3D12ResourceBase()
+ : m_resource(nullptr)
+ {
+ }
protected:
- /// This is protected so as clients cannot slice the class, and so state tracking is lost
- ~D3D12ResourceBase() {}
+ /// This is protected so as clients cannot slice the class, and so state tracking is lost
+ ~D3D12ResourceBase() {}
- ID3D12Resource* m_resource; ///< The resource (ref counted)
+ ID3D12Resource* m_resource; ///< The resource (ref counted)
};
struct D3D12Resource : public D3D12ResourceBase
{
- /// Dtor
- ~D3D12Resource()
- {
- if (m_resource)
- {
- m_resource->Release();
- }
- }
-
- /// Initialize as committed resource
- Slang::Result initCommitted(ID3D12Device* device, const D3D12_HEAP_PROPERTIES& heapProps, D3D12_HEAP_FLAGS heapFlags, const D3D12_RESOURCE_DESC& resourceDesc, D3D12_RESOURCE_STATES initState, const D3D12_CLEAR_VALUE * clearValue);
-
- /// Set a resource.
- void setResource(ID3D12Resource* resource);
- /// Make the resource null
- void setResourceNull();
- /// Returns the attached resource (with any ref counts) and sets to nullptr on this.
- ID3D12Resource* detach();
-
- /// Swaps the resource contents with the contents of the smart pointer
- void swap(Slang::ComPtr<ID3D12Resource>& resourceInOut);
-
- /// Set the debug name on a resource
- static void setDebugName(ID3D12Resource* resource, const char* name);
-
- /// Set the the debug name on the resource
- void setDebugName(const wchar_t* name);
- /// Set the debug name
- void setDebugName(const char* name);
+ /// Dtor
+ ~D3D12Resource()
+ {
+ if (m_resource)
+ {
+ m_resource->Release();
+ }
+ }
+
+ /// Initialize as committed resource
+ Slang::Result initCommitted(
+ ID3D12Device* device,
+ const D3D12_HEAP_PROPERTIES& heapProps,
+ D3D12_HEAP_FLAGS heapFlags,
+ const D3D12_RESOURCE_DESC& resourceDesc,
+ D3D12_RESOURCE_STATES initState,
+ const D3D12_CLEAR_VALUE* clearValue);
+
+ /// Set a resource.
+ void setResource(ID3D12Resource* resource);
+ /// Make the resource null
+ void setResourceNull();
+ /// Returns the attached resource (with any ref counts) and sets to nullptr on this.
+ ID3D12Resource* detach();
+
+ /// Swaps the resource contents with the contents of the smart pointer
+ void swap(Slang::ComPtr<ID3D12Resource>& resourceInOut);
+
+ /// Set the debug name on a resource
+ static void setDebugName(ID3D12Resource* resource, const char* name);
+
+ /// Set the the debug name on the resource
+ void setDebugName(const wchar_t* name);
+ /// Set the debug name
+ void setDebugName(const char* name);
};
-} // renderer_test
+} // namespace gfx
diff --git a/tools/gfx/d3d12/d3d12-sal-defs.h b/tools/gfx/d3d12/d3d12-sal-defs.h
index 058fbb14c..26df704d9 100644
--- a/tools/gfx/d3d12/d3d12-sal-defs.h
+++ b/tools/gfx/d3d12/d3d12-sal-defs.h
@@ -6,194 +6,194 @@
//
#if !defined(_In_)
-# define _In_
+#define _In_
#endif
#if !defined(_Out_)
-# define _Out_
+#define _Out_
#endif
#if !defined(_Inout_)
-# define _Inout_
+#define _Inout_
#endif
#if !defined(_In_z_)
-# define _In_z_
+#define _In_z_
#endif
#if !defined(_Inout_z_)
-# define _Inout_z_
+#define _Inout_z_
#endif
#if !defined(_In_reads_)
-# define _In_reads_(s)
+#define _In_reads_(s)
#endif
#if !defined(_In_reads_z_)
-# define _In_reads_z_(s)
+#define _In_reads_z_(s)
#endif
#if !defined(_In_reads_or_z_)
-# define _In_reads_or_z_(s)
+#define _In_reads_or_z_(s)
#endif
#if !defined(_Out_writes_)
-# define _Out_writes_(s)
+#define _Out_writes_(s)
#endif
#if !defined(_Out_writes_z_)
-# define _Out_writes_z_(s)
+#define _Out_writes_z_(s)
#endif
#if !defined(_Inout_updates_)
-# define _Inout_updates_(s)
+#define _Inout_updates_(s)
#endif
#if !defined(_Inout_updates_z_)
-# define _Inout_updates_z_(s)
+#define _Inout_updates_z_(s)
#endif
#if !defined(_Out_writes_to_)
-# define _Out_writes_to_(s,c)
+#define _Out_writes_to_(s, c)
#endif
#if !defined(_Inout_updates_to_)
-# define _Inout_updates_to_(s,c)
+#define _Inout_updates_to_(s, c)
#endif
#if !defined(_Inout_updates_all_)
-# define _Inout_updates_all_(s)
+#define _Inout_updates_all_(s)
#endif
#if !defined(_In_reads_to_ptr_)
-# define _In_reads_to_ptr_(p)
+#define _In_reads_to_ptr_(p)
#endif
#if !defined(_In_reads_to_ptr_z_)
-# define _In_reads_to_ptr_z_(p)
+#define _In_reads_to_ptr_z_(p)
#endif
#if !defined(_Out_writes_to_ptr_)
-# define _Out_writes_to_ptr_(p)
+#define _Out_writes_to_ptr_(p)
#endif
#if !defined(_Out_writes_to_ptr_z_)
-# define _Out_writes_to_ptr_z_(p)
+#define _Out_writes_to_ptr_z_(p)
#endif
#if !defined(_Outptr_)
-# define _Outptr_
+#define _Outptr_
#endif
#if !defined(_Outptr_opt_)
-# define _Outptr_opt_
+#define _Outptr_opt_
#endif
#if !defined(_Outptr_result_maybenull_)
-# define _Outptr_result_maybenull_
+#define _Outptr_result_maybenull_
#endif
#if !defined(_Outptr_opt_result_maybenull_)
-# define _Outptr_opt_result_maybenull_
+#define _Outptr_opt_result_maybenull_
#endif
#if !defined(_Outptr_result_z_)
-# define _Outptr_result_z_
+#define _Outptr_result_z_
#endif
#if !defined(_COM_Outptr_)
-# define _COM_Outptr_
+#define _COM_Outptr_
#endif
#if !defined(_Outptr_result_buffer_)
-# define _Outptr_result_buffer_(s)
+#define _Outptr_result_buffer_(s)
#endif
#if !defined(_Outptr_result_buffer_to_)
-# define _Outptr_result_buffer_to_(s, c)
+#define _Outptr_result_buffer_to_(s, c)
#endif
#if !defined(_Result_nullonfailure_)
-# define _Result_nullonfailure_
+#define _Result_nullonfailure_
#endif
#if !defined(_Result_zeroonfailure_)
-# define _Result_zeroonfailure_
+#define _Result_zeroonfailure_
#endif
#if !defined(_Outptr_result_nullonfailure_)
-# define _Outptr_result_nullonfailure_
+#define _Outptr_result_nullonfailure_
#endif
#if !defined(_Outptr_opt_result_nullonfailure_)
-# define _Outptr_opt_result_nullonfailure_
+#define _Outptr_opt_result_nullonfailure_
#endif
#if !defined(_Outref_result_nullonfailure_)
-# define _Outref_result_nullonfailure_
+#define _Outref_result_nullonfailure_
#endif
#if !defined(_Outref_)
-# define _Outref_
+#define _Outref_
#endif
#if !defined(_Outref_result_maybenull_)
-# define _Outref_result_maybenull_
+#define _Outref_result_maybenull_
#endif
#if !defined(_Outref_result_buffer_)
-# define _Outref_result_buffer_(s)
+#define _Outref_result_buffer_(s)
#endif
#if !defined(_Outref_result_bytebuffer_)
-# define _Outref_result_bytebuffer_(s)
+#define _Outref_result_bytebuffer_(s)
#endif
#if !defined(_Outref_result_buffer_to_)
-# define _Outref_result_buffer_to_(s, c)
+#define _Outref_result_buffer_to_(s, c)
#endif
#if !defined(_Outref_result_bytebuffer_to_)
-# define _Outref_result_bytebuffer_to_(s, c)
+#define _Outref_result_bytebuffer_to_(s, c)
#endif
#if !defined(_Outref_result_buffer_all_)
-# define _Outref_result_buffer_all_(s)
+#define _Outref_result_buffer_all_(s)
#endif
#if !defined(_Outref_result_bytebuffer_all_)
-# define _Outref_result_bytebuffer_all_(s)
+#define _Outref_result_bytebuffer_all_(s)
#endif
#if !defined(_Outref_result_buffer_maybenull_)
-# define _Outref_result_buffer_maybenull_(s)
+#define _Outref_result_buffer_maybenull_(s)
#endif
#if !defined(_Outref_result_bytebuffer_maybenull_)
-# define _Outref_result_bytebuffer_maybenull_(s)
+#define _Outref_result_bytebuffer_maybenull_(s)
#endif
#if !defined(_Outref_result_buffer_to_maybenull_)
-# define _Outref_result_buffer_to_maybenull_(s, c)
+#define _Outref_result_buffer_to_maybenull_(s, c)
#endif
#if !defined(_Outref_result_bytebuffer_to_maybenull_)
-# define _Outref_result_bytebuffer_to_maybenull_(s,c)
+#define _Outref_result_bytebuffer_to_maybenull_(s, c)
#endif
#if !defined(_Outref_result_buffer_all_maybenull_)
-# define _Outref_result_buffer_all_maybenull_(s)
+#define _Outref_result_buffer_all_maybenull_(s)
#endif
#if !defined(_Outref_result_bytebuffer_all_maybenull_)
-# define _Outref_result_bytebuffer_all_maybenull_(s)
+#define _Outref_result_bytebuffer_all_maybenull_(s)
#endif
#if !defined(_Printf_format_string_)
-# define _Printf_format_string_
+#define _Printf_format_string_
#endif
#if !defined(_Scanf_format_string_)
-# define _Scanf_format_string_
+#define _Scanf_format_string_
#endif
#if !defined(_Scanf_s_format_string_)
-# define _Scanf_s_format_string_
+#define _Scanf_s_format_string_
#endif
#if !defined(_In_range_)
-# define _In_range_(low, hi)
+#define _In_range_(low, hi)
#endif
#if !defined(_Pre_equal_to_)
-# define _Pre_equal_to_(expr)
+#define _Pre_equal_to_(expr)
#endif
#if !defined(_Struct_size_bytes_)
-# define _Struct_size_bytes_(size)
+#define _Struct_size_bytes_(size)
#endif
#if !defined(_Called_from_function_class_)
-# define _Called_from_function_class_(name)
+#define _Called_from_function_class_(name)
#endif
#if !defined(_Check_return_)
-# define _Check_return_
+#define _Check_return_
#endif
#if !defined(_Function_class_)
-# define _Function_class_(name)
+#define _Function_class_(name)
#endif
#if !defined(_Raises_SEH_exception_)
-# define _Raises_SEH_exception_
+#define _Raises_SEH_exception_
#endif
#if !defined(_Maybe_raises_SEH_exception_)
-# define _Maybe_raises_SEH_exception_
+#define _Maybe_raises_SEH_exception_
#endif
#if !defined(_Must_inspect_result_)
-# define _Must_inspect_result_
+#define _Must_inspect_result_
#endif
#if !defined(_Use_decl_annotations_)
-# define _Use_decl_annotations_
+#define _Use_decl_annotations_
#endif
#if !defined(_Always_)
-# define _Always_(anno_list)
+#define _Always_(anno_list)
#endif
#if !defined(_On_failure_)
-# define _On_failure_(anno_list)
+#define _On_failure_(anno_list)
#endif
#if !defined(_Return_type_success_)
-# define _Return_type_success_(expr)
+#define _Return_type_success_(expr)
#endif
#if !defined(_Success_)
-# define _Success_(expr)
+#define _Success_(expr)
#endif
#if !defined(__analysis_assume)
-# define __analysis_assume(expr)
+#define __analysis_assume(expr)
#endif
diff --git a/tools/gfx/d3d12/d3d12-sampler.cpp b/tools/gfx/d3d12/d3d12-sampler.cpp
index b96fb4c90..9f739a268 100644
--- a/tools/gfx/d3d12/d3d12-sampler.cpp
+++ b/tools/gfx/d3d12/d3d12-sampler.cpp
@@ -8,7 +8,10 @@ namespace d3d12
using namespace Slang;
-SamplerStateImpl::~SamplerStateImpl() { m_allocator->free(m_descriptor); }
+SamplerStateImpl::~SamplerStateImpl()
+{
+ m_allocator->free(m_descriptor);
+}
Result SamplerStateImpl::getNativeHandle(InteropHandle* outHandle)
{
diff --git a/tools/gfx/d3d12/d3d12-shader-object-layout.cpp b/tools/gfx/d3d12/d3d12-shader-object-layout.cpp
index c93ddf2cd..ad60fb12d 100644
--- a/tools/gfx/d3d12/d3d12-shader-object-layout.cpp
+++ b/tools/gfx/d3d12/d3d12-shader-object-layout.cpp
@@ -63,7 +63,7 @@ Result ShaderObjectLayoutImpl::init(Builder* builder)
{
auto renderer = builder->m_renderer;
- initBase(renderer, builder->m_session, builder->m_elementTypeLayout);
+ initBase(renderer, builder->m_session, builder->m_elementTypeLayout);
m_containerType = builder->m_containerType;
@@ -116,7 +116,7 @@ Result ShaderObjectLayoutImpl::Builder::setElementTypeLayout(
uint32_t count = (uint32_t)typeLayout->getBindingRangeBindingCount(r);
slang::TypeLayoutReflection* slangLeafTypeLayout =
typeLayout->getBindingRangeLeafTypeLayout(r);
-
+
BindingRangeInfo bindingRangeInfo = {};
bindingRangeInfo.bindingType = slangBindingType;
bindingRangeInfo.resourceShape = slangLeafTypeLayout->getResourceShape();
@@ -198,8 +198,7 @@ Result ShaderObjectLayoutImpl::Builder::setElementTypeLayout(
break;
case slang::BindingType::VaryingInput:
- case slang::BindingType::VaryingOutput:
- break;
+ case slang::BindingType::VaryingOutput: break;
default:
bindingRangeInfo.baseIndex = m_ownCounts.resource;
@@ -240,7 +239,11 @@ Result ShaderObjectLayoutImpl::Builder::setElementTypeLayout(
{
if (auto pendingTypeLayout = slangLeafTypeLayout->getPendingDataTypeLayout())
{
- createForElementType(m_renderer, m_session, pendingTypeLayout, subObjectLayout.writeRef());
+ createForElementType(
+ m_renderer,
+ m_session,
+ pendingTypeLayout,
+ subObjectLayout.writeRef());
}
}
else
@@ -294,53 +297,53 @@ Result ShaderObjectLayoutImpl::Builder::setElementTypeLayout(
switch (slangBindingType)
{
default:
- {
- // We only treat buffers of interface types as actual sub-object binding
- // range.
- auto bindingRangeTypeLayout =
- typeLayout->getBindingRangeLeafTypeLayout(bindingRangeIndex);
- if (!bindingRangeTypeLayout)
- continue;
- auto elementType = typeLayout->getBindingRangeLeafTypeLayout(bindingRangeIndex)
- ->getElementTypeLayout();
- if (!elementType)
- continue;
- if (elementType->getKind() != slang::TypeReflection::Kind::Interface)
{
- continue;
+ // We only treat buffers of interface types as actual sub-object binding
+ // range.
+ auto bindingRangeTypeLayout =
+ typeLayout->getBindingRangeLeafTypeLayout(bindingRangeIndex);
+ if (!bindingRangeTypeLayout)
+ continue;
+ auto elementType = typeLayout->getBindingRangeLeafTypeLayout(bindingRangeIndex)
+ ->getElementTypeLayout();
+ if (!elementType)
+ continue;
+ if (elementType->getKind() != slang::TypeReflection::Kind::Interface)
+ {
+ continue;
+ }
}
- }
- break;
+ break;
case slang::BindingType::ConstantBuffer:
- {
- SLANG_ASSERT(subObjectLayout);
+ {
+ SLANG_ASSERT(subObjectLayout);
- // The resource and sampler descriptors of a nested
- // constant buffer will "leak" into those of the
- // parent type, and we need to account for them
- // whenever we allocate storage.
- //
- objectCounts.resource = subObjectLayout->getTotalResourceDescriptorCount();
- objectCounts.sampler = subObjectLayout->getTotalSamplerDescriptorCount();
- objectCounts.rootParam = subObjectRange.layout->getChildRootParameterCount();
- }
- break;
+ // The resource and sampler descriptors of a nested
+ // constant buffer will "leak" into those of the
+ // parent type, and we need to account for them
+ // whenever we allocate storage.
+ //
+ objectCounts.resource = subObjectLayout->getTotalResourceDescriptorCount();
+ objectCounts.sampler = subObjectLayout->getTotalSamplerDescriptorCount();
+ objectCounts.rootParam = subObjectRange.layout->getChildRootParameterCount();
+ }
+ break;
case slang::BindingType::ParameterBlock:
- {
- SLANG_ASSERT(subObjectLayout);
+ {
+ SLANG_ASSERT(subObjectLayout);
- // In contrast to a constant buffer, a parameter block can hide
- // the resource and sampler descriptor allocation it uses (since they
- // are allocated into the tables that make up the parameter block.
- //
- // The only resource usage that leaks into the surrounding context
- // is the number of root parameters consumed.
- //
- objectCounts.rootParam = subObjectRange.layout->getTotalRootTableParameterCount();
- }
- break;
+ // In contrast to a constant buffer, a parameter block can hide
+ // the resource and sampler descriptor allocation it uses (since they
+ // are allocated into the tables that make up the parameter block.
+ //
+ // The only resource usage that leaks into the surrounding context
+ // is the number of root parameters consumed.
+ //
+ objectCounts.rootParam = subObjectRange.layout->getTotalRootTableParameterCount();
+ }
+ break;
case slang::BindingType::ExistentialValue:
// An unspecialized existential/interface value cannot consume any resources
@@ -446,7 +449,8 @@ void RootShaderObjectLayoutImpl::Builder::addGlobalParams(
}
void RootShaderObjectLayoutImpl::Builder::addEntryPoint(
- SlangStage stage, ShaderObjectLayoutImpl* entryPointLayout)
+ SlangStage stage,
+ ShaderObjectLayoutImpl* entryPointLayout)
{
EntryPointInfo info;
info.layout = entryPointLayout;
@@ -465,7 +469,8 @@ void RootShaderObjectLayoutImpl::Builder::addEntryPoint(
}
Result RootShaderObjectLayoutImpl::RootSignatureDescBuilder::translateDescriptorRangeType(
- slang::BindingType c, D3D12_DESCRIPTOR_RANGE_TYPE* outType)
+ slang::BindingType c,
+ D3D12_DESCRIPTOR_RANGE_TYPE* outType)
{
switch (c)
{
@@ -486,8 +491,7 @@ Result RootShaderObjectLayoutImpl::RootSignatureDescBuilder::translateDescriptor
case slang::BindingType::Sampler:
*outType = D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER;
return SLANG_OK;
- default:
- return SLANG_FAIL;
+ default: return SLANG_FAIL;
}
}
@@ -592,11 +596,14 @@ Result RootShaderObjectLayoutImpl::RootSignatureDescBuilder::addDescriptorRange(
bool isRootParameter)
{
auto bindingType = typeLayout->getDescriptorSetDescriptorRangeType(
- logicalDescriptorSetIndex, descriptorRangeIndex);
+ logicalDescriptorSetIndex,
+ descriptorRangeIndex);
auto count = typeLayout->getDescriptorSetDescriptorRangeDescriptorCount(
- logicalDescriptorSetIndex, descriptorRangeIndex);
+ logicalDescriptorSetIndex,
+ descriptorRangeIndex);
auto index = typeLayout->getDescriptorSetDescriptorRangeIndexOffset(
- logicalDescriptorSetIndex, descriptorRangeIndex);
+ logicalDescriptorSetIndex,
+ descriptorRangeIndex);
auto space = typeLayout->getDescriptorSetSpaceOffset(logicalDescriptorSetIndex);
D3D12_DESCRIPTOR_RANGE_TYPE rangeType;
@@ -662,7 +669,8 @@ void RootShaderObjectLayoutImpl::RootSignatureDescBuilder::addBindingRange(
}
void RootShaderObjectLayoutImpl::RootSignatureDescBuilder::addAsValue(
- slang::VariableLayoutReflection* varLayout, Index physicalDescriptorSetIndex)
+ slang::VariableLayoutReflection* varLayout,
+ Index physicalDescriptorSetIndex)
{
BindingRegisterOffsetPair offset(varLayout);
auto elementOffset = offset;
@@ -697,7 +705,8 @@ void RootShaderObjectLayoutImpl::RootSignatureDescBuilder::addAsConstantBuffer(
if (typeLayout->getSize(SLANG_PARAMETER_CATEGORY_UNIFORM) != 0)
{
auto descriptorRangeType = D3D12_DESCRIPTOR_RANGE_TYPE_CBV;
- auto& offsetForRangeType = offsetForOrdinaryChildren.primary.offsetForRangeType[descriptorRangeType];
+ auto& offsetForRangeType =
+ offsetForOrdinaryChildren.primary.offsetForRangeType[descriptorRangeType];
addDescriptorRange(
physicalDescriptorSetIndex,
descriptorRangeType,
@@ -708,7 +717,11 @@ void RootShaderObjectLayoutImpl::RootSignatureDescBuilder::addAsConstantBuffer(
offsetForRangeType++;
}
- addAsValue(typeLayout, physicalDescriptorSetIndex, offsetForChildrenThatNeedNewSpace, offsetForOrdinaryChildren);
+ addAsValue(
+ typeLayout,
+ physicalDescriptorSetIndex,
+ offsetForChildrenThatNeedNewSpace,
+ offsetForOrdinaryChildren);
}
void RootShaderObjectLayoutImpl::RootSignatureDescBuilder::addAsValue(
@@ -735,11 +748,9 @@ void RootShaderObjectLayoutImpl::RootSignatureDescBuilder::addAsValue(
{
case slang::BindingType::ConstantBuffer:
case slang::BindingType::ParameterBlock:
- case slang::BindingType::ExistentialValue:
- continue;
+ case slang::BindingType::ExistentialValue: continue;
- default:
- break;
+ default: break;
}
// For binding ranges that don't represent sub-objects, we will add
@@ -756,7 +767,7 @@ void RootShaderObjectLayoutImpl::RootSignatureDescBuilder::addAsValue(
// Next we need to recursively include everything bound via sub-objects
Index subObjectRangeCount = typeLayout->getSubObjectRangeCount();
for (Index subObjectRangeIndex = 0; subObjectRangeIndex < subObjectRangeCount;
- subObjectRangeIndex++)
+ subObjectRangeIndex++)
{
auto bindingRangeIndex =
typeLayout->getSubObjectRangeBindingRangeIndex(subObjectRangeIndex);
@@ -776,86 +787,90 @@ void RootShaderObjectLayoutImpl::RootSignatureDescBuilder::addAsValue(
switch (bindingType)
{
case slang::BindingType::ConstantBuffer:
- {
- auto containerVarLayout = subObjectTypeLayout->getContainerVarLayout();
- SLANG_ASSERT(containerVarLayout);
+ {
+ auto containerVarLayout = subObjectTypeLayout->getContainerVarLayout();
+ SLANG_ASSERT(containerVarLayout);
- auto elementVarLayout = subObjectTypeLayout->getElementVarLayout();
- SLANG_ASSERT(elementVarLayout);
+ auto elementVarLayout = subObjectTypeLayout->getElementVarLayout();
+ SLANG_ASSERT(elementVarLayout);
- auto elementTypeLayout = elementVarLayout->getTypeLayout();
- SLANG_ASSERT(elementTypeLayout);
+ auto elementTypeLayout = elementVarLayout->getTypeLayout();
+ SLANG_ASSERT(elementTypeLayout);
- BindingRegisterOffsetPair containerOffset = subObjectRangeContainerOffset;
- containerOffset += BindingRegisterOffsetPair(containerVarLayout);
+ BindingRegisterOffsetPair containerOffset = subObjectRangeContainerOffset;
+ containerOffset += BindingRegisterOffsetPair(containerVarLayout);
- BindingRegisterOffsetPair elementOffset = subObjectRangeElementOffset;
- elementOffset += BindingRegisterOffsetPair(elementVarLayout);
+ BindingRegisterOffsetPair elementOffset = subObjectRangeElementOffset;
+ elementOffset += BindingRegisterOffsetPair(elementVarLayout);
- addAsConstantBuffer(
- elementTypeLayout, physicalDescriptorSetIndex, containerOffset, elementOffset);
- }
- break;
+ addAsConstantBuffer(
+ elementTypeLayout,
+ physicalDescriptorSetIndex,
+ containerOffset,
+ elementOffset);
+ }
+ break;
case slang::BindingType::ParameterBlock:
- {
- auto containerVarLayout = subObjectTypeLayout->getContainerVarLayout();
- SLANG_ASSERT(containerVarLayout);
-
- auto elementVarLayout = subObjectTypeLayout->getElementVarLayout();
- SLANG_ASSERT(elementVarLayout);
-
- auto elementTypeLayout = elementVarLayout->getTypeLayout();
- SLANG_ASSERT(elementTypeLayout);
-
- BindingRegisterOffsetPair subDescriptorSetOffset;
- subDescriptorSetOffset.primary.spaceOffset =
- subObjectRangeContainerOffset.primary.spaceOffset;
- subDescriptorSetOffset.pending.spaceOffset =
- subObjectRangeContainerOffset.pending.spaceOffset;
-
- auto subPhysicalDescriptorSetIndex = addDescriptorSet();
-
- // We recursively call `addAsConstantBuffer` to actually generate
- // the root signature bindings for children in the parameter block.
- // We must compute `containerOffset`, which include a space offset
- // that any sub ParameterBlocks should start from, and `elementOffset`
- // that encodes the space offset of the current parameter block.
- // The space offset of the current parameter block can be obtained from the
- // `containerVarLayout`, and the space offset of any sub ParameterBlocks
- // are obatined from `elementVarLayout`.
- BindingRegisterOffsetPair offsetForChildrenThatNeedNewSpace = subDescriptorSetOffset;
- offsetForChildrenThatNeedNewSpace += BindingRegisterOffsetPair(elementVarLayout);
- BindingRegisterOffsetPair offsetForOrindaryChildren = subDescriptorSetOffset;
- offsetForOrindaryChildren += BindingRegisterOffsetPair(containerVarLayout);
-
- addAsConstantBuffer(
- elementTypeLayout,
- subPhysicalDescriptorSetIndex,
- offsetForChildrenThatNeedNewSpace,
- offsetForOrindaryChildren);
- }
- break;
+ {
+ auto containerVarLayout = subObjectTypeLayout->getContainerVarLayout();
+ SLANG_ASSERT(containerVarLayout);
+
+ auto elementVarLayout = subObjectTypeLayout->getElementVarLayout();
+ SLANG_ASSERT(elementVarLayout);
+
+ auto elementTypeLayout = elementVarLayout->getTypeLayout();
+ SLANG_ASSERT(elementTypeLayout);
+
+ BindingRegisterOffsetPair subDescriptorSetOffset;
+ subDescriptorSetOffset.primary.spaceOffset =
+ subObjectRangeContainerOffset.primary.spaceOffset;
+ subDescriptorSetOffset.pending.spaceOffset =
+ subObjectRangeContainerOffset.pending.spaceOffset;
+
+ auto subPhysicalDescriptorSetIndex = addDescriptorSet();
+
+ // We recursively call `addAsConstantBuffer` to actually generate
+ // the root signature bindings for children in the parameter block.
+ // We must compute `containerOffset`, which include a space offset
+ // that any sub ParameterBlocks should start from, and `elementOffset`
+ // that encodes the space offset of the current parameter block.
+ // The space offset of the current parameter block can be obtained from the
+ // `containerVarLayout`, and the space offset of any sub ParameterBlocks
+ // are obatined from `elementVarLayout`.
+ BindingRegisterOffsetPair offsetForChildrenThatNeedNewSpace =
+ subDescriptorSetOffset;
+ offsetForChildrenThatNeedNewSpace += BindingRegisterOffsetPair(elementVarLayout);
+ BindingRegisterOffsetPair offsetForOrindaryChildren = subDescriptorSetOffset;
+ offsetForOrindaryChildren += BindingRegisterOffsetPair(containerVarLayout);
+
+ addAsConstantBuffer(
+ elementTypeLayout,
+ subPhysicalDescriptorSetIndex,
+ offsetForChildrenThatNeedNewSpace,
+ offsetForOrindaryChildren);
+ }
+ break;
case slang::BindingType::ExistentialValue:
- {
- // Any nested binding ranges in the sub-object will "leak" into the
- // binding ranges for the surrounding context.
- //
- auto specializedTypeLayout = subObjectTypeLayout->getPendingDataTypeLayout();
- if (specializedTypeLayout)
{
- BindingRegisterOffsetPair pendingOffset;
- pendingOffset.primary = subObjectRangeElementOffset.pending;
-
- addAsValue(
- specializedTypeLayout,
- physicalDescriptorSetIndex,
- pendingOffset,
- pendingOffset);
+ // Any nested binding ranges in the sub-object will "leak" into the
+ // binding ranges for the surrounding context.
+ //
+ auto specializedTypeLayout = subObjectTypeLayout->getPendingDataTypeLayout();
+ if (specializedTypeLayout)
+ {
+ BindingRegisterOffsetPair pendingOffset;
+ pendingOffset.primary = subObjectRangeElementOffset.pending;
+
+ addAsValue(
+ specializedTypeLayout,
+ physicalDescriptorSetIndex,
+ pendingOffset,
+ pendingOffset);
+ }
}
- }
- break;
+ break;
}
}
}
@@ -957,9 +972,9 @@ Result RootShaderObjectLayoutImpl::createRootSignatureFromSlang(
ComPtr<ID3DBlob> signature;
ComPtr<ID3DBlob> error;
if (SLANG_FAILED(device->m_D3D12SerializeVersionedRootSignature(
- &versionedDesc,
- signature.writeRef(),
- error.writeRef())))
+ &versionedDesc,
+ signature.writeRef(),
+ error.writeRef())))
{
getDebugCallback()->handleMessage(
DebugMessageType::Error,
@@ -1001,7 +1016,10 @@ Result RootShaderObjectLayoutImpl::create(
auto slangEntryPoint = programLayout->getEntryPointByIndex(e);
RefPtr<ShaderObjectLayoutImpl> entryPointLayout;
SLANG_RETURN_ON_FAIL(ShaderObjectLayoutImpl::createForElementType(
- device, program->getSession(), slangEntryPoint->getTypeLayout(), entryPointLayout.writeRef()));
+ device,
+ program->getSession(),
+ slangEntryPoint->getTypeLayout(),
+ entryPointLayout.writeRef()));
builder.addEntryPoint(slangEntryPoint->getStage(), entryPointLayout);
}
@@ -1017,7 +1035,11 @@ Result RootShaderObjectLayoutImpl::create(
// We build out this array along with root signature construction and store
// it in `m_gpuDescriptorSetInfos`.
SLANG_RETURN_ON_FAIL(createRootSignatureFromSlang(
- device, layout, program, layout->m_rootSignature.writeRef(), outError));
+ device,
+ layout,
+ program,
+ layout->m_rootSignature.writeRef(),
+ outError));
}
*outLayout = layout.detach();
diff --git a/tools/gfx/d3d12/d3d12-shader-object-layout.h b/tools/gfx/d3d12/d3d12-shader-object-layout.h
index 2b27a1d98..c6219d1a2 100644
--- a/tools/gfx/d3d12/d3d12-shader-object-layout.h
+++ b/tools/gfx/d3d12/d3d12-shader-object-layout.h
@@ -71,7 +71,8 @@ public:
bool isRootParameter;
- /// Is this binding range represent a specialization point, such as an existential value, or a `ParameterBlock<IFoo>`.
+ /// Is this binding range represent a specialization point, such as an existential value, or
+ /// a `ParameterBlock<IFoo>`.
bool isSpecializable;
};
@@ -129,7 +130,8 @@ public:
public:
Builder(RendererBase* renderer, slang::ISession* session)
: m_renderer(renderer), m_session(session)
- {}
+ {
+ }
RendererBase* m_renderer;
slang::ISession* m_session;
@@ -246,7 +248,8 @@ public:
: Super::Builder(renderer, program->getSession())
, m_program(program)
, m_programLayout(programLayout)
- {}
+ {
+ }
Result build(RootShaderObjectLayoutImpl** outLayout);
@@ -277,7 +280,8 @@ public:
RootSignatureDescBuilder(DeviceImpl* device)
: m_device(device)
- {}
+ {
+ }
// We will use one descriptor set for the global scope and one additional
// descriptor set for each `ParameterBlock` binding range in the shader object
@@ -289,7 +293,8 @@ public:
D3D12_ROOT_SIGNATURE_DESC1 m_rootSignatureDesc = {};
static Result translateDescriptorRangeType(
- slang::BindingType c, D3D12_DESCRIPTOR_RANGE_TYPE* outType);
+ slang::BindingType c,
+ D3D12_DESCRIPTOR_RANGE_TYPE* outType);
/// Stores offset information to apply to the reflected register/space for a descriptor
/// range.
@@ -309,7 +314,7 @@ public:
/// Note that the `D3D12_DESCRIPTOR_RANGE_TYPE` enumeration has
/// values between 0 and 3, inclusive.
///
- uint32_t offsetForRangeType[kRangeTypeCount] = { 0, 0, 0, 0 };
+ uint32_t offsetForRangeType[kRangeTypeCount] = {0, 0, 0, 0};
uint32_t& operator[](D3D12_DESCRIPTOR_RANGE_TYPE type)
{
@@ -327,8 +332,8 @@ public:
{
if (varLayout)
{
- spaceOffset =
- (UINT)varLayout->getOffset(SLANG_PARAMETER_CATEGORY_SUB_ELEMENT_REGISTER_SPACE);
+ spaceOffset = (UINT)varLayout->getOffset(
+ SLANG_PARAMETER_CATEGORY_SUB_ELEMENT_REGISTER_SPACE);
offsetForRangeType[D3D12_DESCRIPTOR_RANGE_TYPE_CBV] =
(UINT)varLayout->getOffset(SLANG_PARAMETER_CATEGORY_CONSTANT_BUFFER);
offsetForRangeType[D3D12_DESCRIPTOR_RANGE_TYPE_SRV] =
@@ -358,9 +363,9 @@ public:
BindingRegisterOffsetPair() {}
BindingRegisterOffsetPair(slang::VariableLayoutReflection* varLayout)
- : primary(varLayout)
- , pending(varLayout->getPendingDataLayout())
- {}
+ : primary(varLayout), pending(varLayout->getPendingDataLayout())
+ {
+ }
void operator+=(BindingRegisterOffsetPair const& other)
{
@@ -433,7 +438,8 @@ public:
Index bindingRangeIndex);
void addAsValue(
- slang::VariableLayoutReflection* varLayout, Index physicalDescriptorSetIndex);
+ slang::VariableLayoutReflection* varLayout,
+ Index physicalDescriptorSetIndex);
/// Add binding ranges and parameter blocks to the root signature.
///
diff --git a/tools/gfx/d3d12/d3d12-shader-object.cpp b/tools/gfx/d3d12/d3d12-shader-object.cpp
index beb88b636..77d3553ba 100644
--- a/tools/gfx/d3d12/d3d12-shader-object.cpp
+++ b/tools/gfx/d3d12/d3d12-shader-object.cpp
@@ -4,13 +4,12 @@
#include "d3d12-buffer.h"
#include "d3d12-command-encoder.h"
#include "d3d12-device.h"
+#include "d3d12-helper-functions.h"
#include "d3d12-resource-views.h"
#include "d3d12-sampler.h"
#include "d3d12-shader-object-layout.h"
#include "d3d12-transient-heap.h"
-#include "d3d12-helper-functions.h"
-
namespace gfx
{
namespace d3d12
@@ -18,7 +17,10 @@ namespace d3d12
using namespace Slang;
-GfxCount ShaderObjectImpl::getEntryPointCount() { return 0; }
+GfxCount ShaderObjectImpl::getEntryPointCount()
+{
+ return 0;
+}
Result ShaderObjectImpl::getEntryPoint(GfxIndex index, IShaderObject** outEntryPoint)
{
@@ -26,9 +28,15 @@ Result ShaderObjectImpl::getEntryPoint(GfxIndex index, IShaderObject** outEntryP
return SLANG_OK;
}
-const void* ShaderObjectImpl::getRawData() { return m_data.getBuffer(); }
+const void* ShaderObjectImpl::getRawData()
+{
+ return m_data.getBuffer();
+}
-Size ShaderObjectImpl::getSize() { return (Size)m_data.getCount(); }
+Size ShaderObjectImpl::getSize()
+{
+ return (Size)m_data.getCount();
+}
// TODO: Change Index to Offset/Size?
Result ShaderObjectImpl::setData(ShaderOffset const& inOffset, void const* data, size_t inSize)
@@ -97,7 +105,9 @@ Result ShaderObjectImpl::setSampler(ShaderOffset const& offset, ISamplerState* s
}
Result ShaderObjectImpl::setCombinedTextureSampler(
- ShaderOffset const& offset, IResourceView* textureView, ISamplerState* sampler)
+ ShaderOffset const& offset,
+ IResourceView* textureView,
+ ISamplerState* sampler)
{
#if 0
if (offset.bindingRangeIndex < 0)
@@ -182,7 +192,7 @@ Result ShaderObjectImpl::init(
// freed while the object is still live.
//
// The doubling here is because any buffer resource could
- // have a counter buffer associated with it, which we
+ // have a counter buffer associated with it, which we
// also need to ensure isn't destroyed prematurely.
m_boundResources.setCount(resourceCount);
m_boundCounterResources.setCount(resourceCount);
@@ -354,7 +364,8 @@ bool ShaderObjectImpl::shouldAllocateConstantBuffer(TransientResourceHeapImpl* t
/// Ensure that the `m_ordinaryDataBuffer` has been created, if it is needed
Result ShaderObjectImpl::_ensureOrdinaryDataBufferCreatedIfNeeded(
- PipelineCommandEncoder* encoder, ShaderObjectLayoutImpl* specializedLayout)
+ PipelineCommandEncoder* encoder,
+ ShaderObjectLayoutImpl* specializedLayout)
{
// If data has been changed since last allocation/filling of constant buffer,
// we will need to allocate a new one.
@@ -385,7 +396,9 @@ Result ShaderObjectImpl::_ensureOrdinaryDataBufferCreatedIfNeeded(
//
auto alignedConstantBufferSize = D3DUtil::calcAligned(m_constantBufferSize, 256);
SLANG_RETURN_ON_FAIL(encoder->m_commandBuffer->m_transientHeap->allocateConstantBuffer(
- alignedConstantBufferSize, m_constantBufferWeakPtr, m_constantBufferOffset));
+ alignedConstantBufferSize,
+ m_constantBufferWeakPtr,
+ m_constantBufferOffset));
// Once the buffer is allocated, we can use `_writeOrdinaryData` to fill it in.
//
@@ -410,9 +423,9 @@ Result ShaderObjectImpl::_ensureOrdinaryDataBufferCreatedIfNeeded(
auto descriptorTable = m_descriptorSet.resourceTable;
D3D12_CONSTANT_BUFFER_VIEW_DESC viewDesc = {};
viewDesc.BufferLocation = static_cast<BufferResourceImpl*>(m_constantBufferWeakPtr)
- ->m_resource.getResource()
- ->GetGPUVirtualAddress() +
- m_constantBufferOffset;
+ ->m_resource.getResource()
+ ->GetGPUVirtualAddress() +
+ m_constantBufferOffset;
viewDesc.SizeInBytes = (UINT)alignedConstantBufferSize;
encoder->m_device->CreateConstantBufferView(&viewDesc, descriptorTable.getCpuHandle());
}
@@ -426,21 +439,22 @@ void ShaderObjectImpl::updateSubObjectsRecursive()
return;
auto& subObjectRanges = getLayout()->getSubObjectRanges();
for (Slang::Index subObjectRangeIndex = 0; subObjectRangeIndex < subObjectRanges.getCount();
- subObjectRangeIndex++)
+ subObjectRangeIndex++)
{
auto const& subObjectRange = subObjectRanges[subObjectRangeIndex];
auto const& bindingRange = getLayout()->getBindingRange(subObjectRange.bindingRangeIndex);
Slang::Index count = bindingRange.count;
for (Slang::Index subObjectIndexInRange = 0; subObjectIndexInRange < count;
- subObjectIndexInRange++)
+ subObjectIndexInRange++)
{
Slang::Index objectIndex = bindingRange.subObjectIndex + subObjectIndexInRange;
auto subObject = m_objects[objectIndex].Ptr();
if (!subObject)
continue;
subObject->updateSubObjectsRecursive();
- if (m_subObjectVersions.getCount() > objectIndex && m_subObjectVersions[objectIndex] != m_objects[objectIndex]->m_version)
+ if (m_subObjectVersions.getCount() > objectIndex &&
+ m_subObjectVersions[objectIndex] != m_objects[objectIndex]->m_version)
{
ShaderOffset offset;
offset.bindingRangeIndex = (GfxIndex)subObjectRange.bindingRangeIndex;
@@ -516,7 +530,8 @@ Result ShaderObjectImpl::prepareToBindAsParameterBlock(
// root parameter.
//
auto tableRootParamIndex = rootParamIndex++;
- context->pendingTableBindings->add(PendingDescriptorTableBinding{ tableRootParamIndex, table.getGpuHandle() });
+ context->pendingTableBindings->add(
+ PendingDescriptorTableBinding{tableRootParamIndex, table.getGpuHandle()});
}
if (auto descriptorCount = specializedLayout->getTotalSamplerDescriptorCount())
{
@@ -539,7 +554,8 @@ Result ShaderObjectImpl::prepareToBindAsParameterBlock(
// root parameter.
//
auto tableRootParamIndex = rootParamIndex++;
- context->pendingTableBindings->add(PendingDescriptorTableBinding{ tableRootParamIndex, table.getGpuHandle() });
+ context->pendingTableBindings->add(
+ PendingDescriptorTableBinding{tableRootParamIndex, table.getGpuHandle()});
}
return SLANG_OK;
@@ -553,16 +569,16 @@ bool ShaderObjectImpl::checkIfCachedDescriptorSetIsValidRecursive(BindingContext
return false;
if (m_cachedGPUDescriptorSet.resourceTable.getDescriptorCount() != 0 &&
m_cachedGPUDescriptorSet.resourceTable.m_heap.ptr.linearHeap->getHeap() !=
- m_cachedTransientHeap->getCurrentViewHeap().getHeap())
+ m_cachedTransientHeap->getCurrentViewHeap().getHeap())
return false;
if (m_cachedGPUDescriptorSet.samplerTable.getDescriptorCount() != 0 &&
m_cachedGPUDescriptorSet.samplerTable.m_heap.ptr.linearHeap->getHeap() !=
- m_cachedTransientHeap->getCurrentSamplerHeap().getHeap())
+ m_cachedTransientHeap->getCurrentSamplerHeap().getHeap())
return false;
auto& subObjectRanges = getLayout()->getSubObjectRanges();
for (Slang::Index subObjectRangeIndex = 0; subObjectRangeIndex < subObjectRanges.getCount();
- subObjectRangeIndex++)
+ subObjectRangeIndex++)
{
auto const& subObjectRange = subObjectRanges[subObjectRangeIndex];
auto const& bindingRange = getLayout()->getBindingRange(subObjectRange.bindingRangeIndex);
@@ -571,7 +587,7 @@ bool ShaderObjectImpl::checkIfCachedDescriptorSetIsValidRecursive(BindingContext
Slang::Index count = bindingRange.count;
for (Slang::Index subObjectIndexInRange = 0; subObjectIndexInRange < count;
- subObjectIndexInRange++)
+ subObjectIndexInRange++)
{
Slang::Index objectIndex = bindingRange.subObjectIndex + subObjectIndexInRange;
auto subObject = m_objects[objectIndex].Ptr();
@@ -587,7 +603,9 @@ bool ShaderObjectImpl::checkIfCachedDescriptorSetIsValidRecursive(BindingContext
/// Bind this object as a `ParameterBlock<X>`
Result ShaderObjectImpl::bindAsParameterBlock(
- BindingContext* context, BindingOffset const& offset, ShaderObjectLayoutImpl* specializedLayout)
+ BindingContext* context,
+ BindingOffset const& offset,
+ ShaderObjectLayoutImpl* specializedLayout)
{
if (checkIfCachedDescriptorSetIsValidRecursive(context))
{
@@ -598,13 +616,15 @@ Result ShaderObjectImpl::bindAsParameterBlock(
{
auto tableRootParamIndex = rootParamIndex++;
context->submitter->setRootDescriptorTable(
- tableRootParamIndex, m_cachedGPUDescriptorSet.resourceTable.getGpuHandle());
+ tableRootParamIndex,
+ m_cachedGPUDescriptorSet.resourceTable.getGpuHandle());
}
if (m_cachedGPUDescriptorSet.samplerTable.getDescriptorCount())
{
auto tableRootParamIndex = rootParamIndex++;
context->submitter->setRootDescriptorTable(
- tableRootParamIndex, m_cachedGPUDescriptorSet.samplerTable.getGpuHandle());
+ tableRootParamIndex,
+ m_cachedGPUDescriptorSet.samplerTable.getGpuHandle());
}
return SLANG_OK;
}
@@ -619,7 +639,10 @@ Result ShaderObjectImpl::bindAsParameterBlock(
context->pendingTableBindings = &pendingTableBindings;
SLANG_RETURN_ON_FAIL(prepareToBindAsParameterBlock(
- context, /* inout */ subOffset, specializedLayout, m_cachedGPUDescriptorSet));
+ context,
+ /* inout */ subOffset,
+ specializedLayout,
+ m_cachedGPUDescriptorSet));
// Next we bind the object into that descriptor set as if it were being used
// as a `ConstantBuffer<X>`.
@@ -766,30 +789,33 @@ Result ShaderObjectImpl::_bindImpl(
switch (bindingRange.bindingType)
{
case slang::BindingType::ConstantBuffer:
- {
- auto objOffset = rangeOffset;
- for (uint32_t j = 0; j < bindingRange.count; j++)
{
- auto& object = m_objects[subObjectIndex + j];
- SLANG_RETURN_ON_FAIL(object->bindAsConstantBuffer(
- context, descriptorSet, objOffset, subObjectLayout));
- objOffset += rangeStride;
+ auto objOffset = rangeOffset;
+ for (uint32_t j = 0; j < bindingRange.count; j++)
+ {
+ auto& object = m_objects[subObjectIndex + j];
+ SLANG_RETURN_ON_FAIL(object->bindAsConstantBuffer(
+ context,
+ descriptorSet,
+ objOffset,
+ subObjectLayout));
+ objOffset += rangeStride;
+ }
}
- }
- break;
+ break;
case slang::BindingType::ParameterBlock:
- {
- auto objOffset = rangeOffset;
- for (uint32_t j = 0; j < bindingRange.count; j++)
{
- auto& object = m_objects[subObjectIndex + j];
- SLANG_RETURN_ON_FAIL(
- object->bindAsParameterBlock(context, objOffset, subObjectLayout));
- objOffset += rangeStride;
+ auto objOffset = rangeOffset;
+ for (uint32_t j = 0; j < bindingRange.count; j++)
+ {
+ auto& object = m_objects[subObjectIndex + j];
+ SLANG_RETURN_ON_FAIL(
+ object->bindAsParameterBlock(context, objOffset, subObjectLayout));
+ objOffset += rangeStride;
+ }
}
- }
- break;
+ break;
case slang::BindingType::ExistentialValue:
if (subObjectLayout)
@@ -824,8 +850,7 @@ Result ShaderObjectImpl::bindRootArguments(BindingContext* context, uint32_t& in
case IResourceView::Type::UnorderedAccess:
context->submitter->setRootUAV(index, m_rootArguments[i]);
break;
- default:
- continue;
+ default: continue;
}
index++;
}
@@ -897,31 +922,31 @@ Result ShaderObjectImpl::setResource(ShaderOffset const& offset, IResourceView*
switch (resourceView->getViewDesc()->type)
{
case IResourceView::Type::AccelerationStructure:
- {
- auto resourceViewImpl = static_cast<AccelerationStructureImpl*>(resourceView);
- rootArg = resourceViewImpl->getDeviceAddress();
- }
- break;
- case IResourceView::Type::ShaderResource:
- case IResourceView::Type::UnorderedAccess:
- {
- auto resourceViewImpl = static_cast<ResourceViewImpl*>(resourceView);
- if (resourceViewImpl->m_resource->isBuffer())
{
- rootArg = static_cast<BufferResourceImpl*>(resourceViewImpl->m_resource.Ptr())
- ->getDeviceAddress();
+ auto resourceViewImpl = static_cast<AccelerationStructureImpl*>(resourceView);
+ rootArg = resourceViewImpl->getDeviceAddress();
}
- else
+ break;
+ case IResourceView::Type::ShaderResource:
+ case IResourceView::Type::UnorderedAccess:
{
- getDebugCallback()->handleMessage(
- DebugMessageType::Error,
- DebugMessageSource::Layer,
- "The shader parameter at the specified offset is a root parameter, and "
- "therefore can only be a buffer view.");
- return SLANG_FAIL;
+ auto resourceViewImpl = static_cast<ResourceViewImpl*>(resourceView);
+ if (resourceViewImpl->m_resource->isBuffer())
+ {
+ rootArg = static_cast<BufferResourceImpl*>(resourceViewImpl->m_resource.Ptr())
+ ->getDeviceAddress();
+ }
+ else
+ {
+ getDebugCallback()->handleMessage(
+ DebugMessageType::Error,
+ DebugMessageSource::Layer,
+ "The shader parameter at the specified offset is a root parameter, and "
+ "therefore can only be a buffer view.");
+ return SLANG_FAIL;
+ }
}
- }
- break;
+ break;
}
return SLANG_OK;
}
@@ -945,23 +970,23 @@ Result ShaderObjectImpl::setResource(ShaderOffset const& offset, IResourceView*
{
#if SLANG_GFX_HAS_DXR_SUPPORT
case IResourceView::Type::AccelerationStructure:
- {
- auto asImpl = static_cast<AccelerationStructureImpl*>(resourceView);
- // Hold a reference to the resource to prevent its destruction.
- m_boundResources[bindingRange.baseIndex + offset.bindingArrayIndex] = asImpl->m_buffer;
- internalResourceView = asImpl;
- }
- break;
+ {
+ auto asImpl = static_cast<AccelerationStructureImpl*>(resourceView);
+ // Hold a reference to the resource to prevent its destruction.
+ m_boundResources[bindingRange.baseIndex + offset.bindingArrayIndex] = asImpl->m_buffer;
+ internalResourceView = asImpl;
+ }
+ break;
#endif
default:
- {
- // Hold a reference to the resource to prevent its destruction.
- const auto resourceOffset = bindingRange.baseIndex + offset.bindingArrayIndex;
- m_boundResources[resourceOffset] = resourceViewImpl->m_resource;
- m_boundCounterResources[resourceOffset] = resourceViewImpl->m_counterResource;
- internalResourceView = resourceViewImpl;
- }
- break;
+ {
+ // Hold a reference to the resource to prevent its destruction.
+ const auto resourceOffset = bindingRange.baseIndex + offset.bindingArrayIndex;
+ m_boundResources[resourceOffset] = resourceViewImpl->m_resource;
+ m_boundCounterResources[resourceOffset] = resourceViewImpl->m_counterResource;
+ internalResourceView = resourceViewImpl;
+ }
+ break;
}
auto descriptorSlotIndex = bindingRange.baseIndex + (int32_t)offset.bindingArrayIndex;
@@ -999,7 +1024,9 @@ Result ShaderObjectImpl::setResource(ShaderOffset const& offset, IResourceView*
}
Result ShaderObjectImpl::create(
- DeviceImpl* device, ShaderObjectLayoutImpl* layout, ShaderObjectImpl** outShaderObject)
+ DeviceImpl* device,
+ ShaderObjectLayoutImpl* layout,
+ ShaderObjectImpl** outShaderObject)
{
auto object = RefPtr<ShaderObjectImpl>(new ShaderObjectImpl());
SLANG_RETURN_ON_FAIL(
@@ -1008,14 +1035,20 @@ Result ShaderObjectImpl::create(
return SLANG_OK;
}
-ShaderObjectImpl::~ShaderObjectImpl() { m_descriptorSet.freeIfSupported(); }
+ShaderObjectImpl::~ShaderObjectImpl()
+{
+ m_descriptorSet.freeIfSupported();
+}
RootShaderObjectLayoutImpl* RootShaderObjectImpl::getLayout()
{
return static_cast<RootShaderObjectLayoutImpl*>(m_layout.Ptr());
}
-GfxCount RootShaderObjectImpl::getEntryPointCount() { return (GfxCount)m_entryPoints.getCount(); }
+GfxCount RootShaderObjectImpl::getEntryPointCount()
+{
+ return (GfxCount)m_entryPoints.getCount();
+}
SlangResult RootShaderObjectImpl::getEntryPoint(GfxIndex index, IShaderObject** outEntryPoint)
{
@@ -1141,7 +1174,8 @@ Result RootShaderObjectImpl::copyFrom(IShaderObject* object, ITransientResourceH
}
Result RootShaderObjectImpl::bindAsRoot(
- BindingContext* context, RootShaderObjectLayoutImpl* specializedLayout)
+ BindingContext* context,
+ RootShaderObjectLayoutImpl* specializedLayout)
{
// Pull updates from sub-objects when this is a mutable root shader object.
updateSubObjectsRecursive();
@@ -1159,13 +1193,16 @@ Result RootShaderObjectImpl::bindAsRoot(
context->pendingTableBindings = &pendingTableBindings;
BindingOffset rootOffset;
-
+
// Bind all root parameters first.
Super::bindRootArguments(context, rootOffset.rootParam);
DescriptorSet descriptorSet;
SLANG_RETURN_ON_FAIL(prepareToBindAsParameterBlock(
- context, /* inout */ rootOffset, specializedLayout, descriptorSet));
+ context,
+ /* inout */ rootOffset,
+ specializedLayout,
+ descriptorSet));
SLANG_RETURN_ON_FAIL(
Super::bindAsConstantBuffer(context, descriptorSet, rootOffset, specializedLayout));
@@ -1182,7 +1219,10 @@ Result RootShaderObjectImpl::bindAsRoot(
entryPoint->updateSubObjectsRecursive();
SLANG_RETURN_ON_FAIL(entryPoint->bindAsConstantBuffer(
- context, descriptorSet, entryPointOffset, entryPointInfo.layout));
+ context,
+ descriptorSet,
+ entryPointOffset,
+ entryPointInfo.layout));
}
bindPendingTables(context);
@@ -1214,10 +1254,16 @@ Result RootShaderObjectImpl::resetImpl(
}
Result RootShaderObjectImpl::reset(
- DeviceImpl* device, RootShaderObjectLayoutImpl* layout, TransientResourceHeapImpl* heap)
+ DeviceImpl* device,
+ RootShaderObjectLayoutImpl* layout,
+ TransientResourceHeapImpl* heap)
{
return resetImpl(
- device, layout, &heap->m_stagingCpuViewHeap, &heap->m_stagingCpuSamplerHeap, false);
+ device,
+ layout,
+ &heap->m_stagingCpuViewHeap,
+ &heap->m_stagingCpuSamplerHeap,
+ false);
}
} // namespace d3d12
diff --git a/tools/gfx/d3d12/d3d12-shader-object.h b/tools/gfx/d3d12/d3d12-shader-object.h
index 6251a970c..f0276fa7f 100644
--- a/tools/gfx/d3d12/d3d12-shader-object.h
+++ b/tools/gfx/d3d12/d3d12-shader-object.h
@@ -88,7 +88,9 @@ class ShaderObjectImpl
public:
static Result create(
- DeviceImpl* device, ShaderObjectLayoutImpl* layout, ShaderObjectImpl** outShaderObject);
+ DeviceImpl* device,
+ ShaderObjectLayoutImpl* layout,
+ ShaderObjectImpl** outShaderObject);
~ShaderObjectImpl();
@@ -97,7 +99,7 @@ public:
virtual SLANG_NO_THROW GfxCount SLANG_MCALL getEntryPointCount() override;
virtual SLANG_NO_THROW Result SLANG_MCALL
- getEntryPoint(GfxIndex index, IShaderObject** outEntryPoint) override;
+ getEntryPoint(GfxIndex index, IShaderObject** outEntryPoint) override;
virtual SLANG_NO_THROW const void* SLANG_MCALL getRawData() override;
@@ -105,18 +107,20 @@ public:
// TODO: What to do with size_t?
virtual SLANG_NO_THROW Result SLANG_MCALL
- setData(ShaderOffset const& inOffset, void const* data, size_t inSize) override;
+ setData(ShaderOffset const& inOffset, void const* data, size_t inSize) override;
virtual SLANG_NO_THROW Result SLANG_MCALL
- setObject(ShaderOffset const& offset, IShaderObject* object) override;
+ setObject(ShaderOffset const& offset, IShaderObject* object) override;
virtual SLANG_NO_THROW Result SLANG_MCALL
- setResource(ShaderOffset const& offset, IResourceView* resourceView) override;
+ setResource(ShaderOffset const& offset, IResourceView* resourceView) override;
virtual SLANG_NO_THROW Result SLANG_MCALL
- setSampler(ShaderOffset const& offset, ISamplerState* sampler) override;
+ setSampler(ShaderOffset const& offset, ISamplerState* sampler) override;
virtual SLANG_NO_THROW Result SLANG_MCALL setCombinedTextureSampler(
- ShaderOffset const& offset, IResourceView* textureView, ISamplerState* sampler) override;
+ ShaderOffset const& offset,
+ IResourceView* textureView,
+ ISamplerState* sampler) override;
protected:
Result init(
@@ -138,7 +142,8 @@ protected:
/// Ensure that the `m_ordinaryDataBuffer` has been created, if it is needed
Result _ensureOrdinaryDataBufferCreatedIfNeeded(
- PipelineCommandEncoder* encoder, ShaderObjectLayoutImpl* specializedLayout);
+ PipelineCommandEncoder* encoder,
+ ShaderObjectLayoutImpl* specializedLayout);
public:
void updateSubObjectsRecursive();
@@ -255,10 +260,10 @@ public:
virtual SLANG_NO_THROW GfxCount SLANG_MCALL getEntryPointCount() override;
virtual SLANG_NO_THROW SlangResult SLANG_MCALL
- getEntryPoint(GfxIndex index, IShaderObject** outEntryPoint) override;
+ getEntryPoint(GfxIndex index, IShaderObject** outEntryPoint) override;
virtual Result collectSpecializationArgs(ExtendedShaderObjectTypeList& args) override;
virtual SLANG_NO_THROW Result SLANG_MCALL
- copyFrom(IShaderObject* object, ITransientResourceHeap* transientHeap) override;
+ copyFrom(IShaderObject* object, ITransientResourceHeap* transientHeap) override;
public:
Result bindAsRoot(BindingContext* context, RootShaderObjectLayoutImpl* specializedLayout);
@@ -274,7 +279,9 @@ public:
bool isMutable);
Result reset(
- DeviceImpl* device, RootShaderObjectLayoutImpl* layout, TransientResourceHeapImpl* heap);
+ DeviceImpl* device,
+ RootShaderObjectLayoutImpl* layout,
+ TransientResourceHeapImpl* heap);
protected:
virtual Result _createSpecializedLayout(ShaderObjectLayoutImpl** outLayout) override;
diff --git a/tools/gfx/d3d12/d3d12-shader-program.cpp b/tools/gfx/d3d12/d3d12-shader-program.cpp
index f2476232c..a39f20465 100644
--- a/tools/gfx/d3d12/d3d12-shader-program.cpp
+++ b/tools/gfx/d3d12/d3d12-shader-program.cpp
@@ -9,7 +9,8 @@ namespace d3d12
using namespace Slang;
Result ShaderProgramImpl::createShaderModule(
- slang::EntryPointReflection* entryPointInfo, ComPtr<ISlangBlob> kernelCode)
+ slang::EntryPointReflection* entryPointInfo,
+ ComPtr<ISlangBlob> kernelCode)
{
ShaderBinary shaderBin;
shaderBin.stage = entryPointInfo->getStage();
diff --git a/tools/gfx/d3d12/d3d12-shader-program.h b/tools/gfx/d3d12/d3d12-shader-program.h
index eafa898fe..669bce960 100644
--- a/tools/gfx/d3d12/d3d12-shader-program.h
+++ b/tools/gfx/d3d12/d3d12-shader-program.h
@@ -26,7 +26,8 @@ public:
List<ShaderBinary> m_shaders;
virtual Result createShaderModule(
- slang::EntryPointReflection* entryPointInfo, ComPtr<ISlangBlob> kernelCode) override;
+ slang::EntryPointReflection* entryPointInfo,
+ ComPtr<ISlangBlob> kernelCode) override;
};
} // namespace d3d12
diff --git a/tools/gfx/d3d12/d3d12-shader-table.cpp b/tools/gfx/d3d12/d3d12-shader-table.cpp
index f54b7c5e9..be537c737 100644
--- a/tools/gfx/d3d12/d3d12-shader-table.cpp
+++ b/tools/gfx/d3d12/d3d12-shader-table.cpp
@@ -24,9 +24,11 @@ RefPtr<BufferResource> ShaderTableImpl::createDeviceBuffer(
m_rayGenTableOffset = 0;
m_missTableOffset = raygenTableSize;
m_hitGroupTableOffset = (uint32_t)D3DUtil::calcAligned(
- m_missTableOffset + missTableSize, D3D12_RAYTRACING_SHADER_TABLE_BYTE_ALIGNMENT);
+ m_missTableOffset + missTableSize,
+ D3D12_RAYTRACING_SHADER_TABLE_BYTE_ALIGNMENT);
m_callableTableOffset = (uint32_t)D3DUtil::calcAligned(
- m_hitGroupTableOffset + hitgroupTableSize, D3D12_RAYTRACING_SHADER_TABLE_BYTE_ALIGNMENT);
+ m_hitGroupTableOffset + hitgroupTableSize,
+ D3D12_RAYTRACING_SHADER_TABLE_BYTE_ALIGNMENT);
uint32_t tableSize = m_callableTableOffset + callableTableSize;
auto pipelineImpl = static_cast<RayTracingPipelineStateImpl*>(pipeline);
@@ -47,8 +49,8 @@ RefPtr<BufferResource> ShaderTableImpl::createDeviceBuffer(
IBufferResource* stagingBuffer = nullptr;
Offset stagingBufferOffset = 0;
- transientHeapImpl->allocateStagingBuffer(
- tableSize, stagingBuffer, stagingBufferOffset, MemoryType::Upload);
+ transientHeapImpl
+ ->allocateStagingBuffer(tableSize, stagingBuffer, stagingBufferOffset, MemoryType::Upload);
assert(stagingBuffer);
void* stagingPtr = nullptr;
diff --git a/tools/gfx/d3d12/d3d12-submitter.cpp b/tools/gfx/d3d12/d3d12-submitter.cpp
index 0abd21d70..2870d8836 100644
--- a/tools/gfx/d3d12/d3d12-submitter.cpp
+++ b/tools/gfx/d3d12/d3d12-submitter.cpp
@@ -11,7 +11,8 @@ namespace d3d12
using namespace Slang;
void GraphicsSubmitter::setRootConstantBufferView(
- int index, D3D12_GPU_VIRTUAL_ADDRESS gpuBufferLocation)
+ int index,
+ D3D12_GPU_VIRTUAL_ADDRESS gpuBufferLocation)
{
m_commandList->SetGraphicsRootConstantBufferView(index, gpuBufferLocation);
}
@@ -27,7 +28,8 @@ void GraphicsSubmitter::setRootSRV(int index, D3D12_GPU_VIRTUAL_ADDRESS gpuBuffe
}
void GraphicsSubmitter::setRootDescriptorTable(
- int index, D3D12_GPU_DESCRIPTOR_HANDLE baseDescriptor)
+ int index,
+ D3D12_GPU_DESCRIPTOR_HANDLE baseDescriptor)
{
m_commandList->SetGraphicsRootDescriptorTable(index, baseDescriptor);
}
@@ -44,7 +46,10 @@ void GraphicsSubmitter::setRootConstants(
void const* srcData)
{
m_commandList->SetGraphicsRoot32BitConstants(
- UINT(rootParamIndex), UINT(countOf32BitValues), srcData, UINT(dstOffsetIn32BitValues));
+ UINT(rootParamIndex),
+ UINT(countOf32BitValues),
+ srcData,
+ UINT(dstOffsetIn32BitValues));
}
void GraphicsSubmitter::setPipelineState(PipelineStateBase* pipeline)
@@ -54,7 +59,8 @@ void GraphicsSubmitter::setPipelineState(PipelineStateBase* pipeline)
}
void ComputeSubmitter::setRootConstantBufferView(
- int index, D3D12_GPU_VIRTUAL_ADDRESS gpuBufferLocation)
+ int index,
+ D3D12_GPU_VIRTUAL_ADDRESS gpuBufferLocation)
{
m_commandList->SetComputeRootConstantBufferView(index, gpuBufferLocation);
}
@@ -69,8 +75,7 @@ void ComputeSubmitter::setRootSRV(int index, D3D12_GPU_VIRTUAL_ADDRESS gpuBuffer
m_commandList->SetComputeRootShaderResourceView(index, gpuBufferLocation);
}
-void ComputeSubmitter::setRootDescriptorTable(
- int index, D3D12_GPU_DESCRIPTOR_HANDLE baseDescriptor)
+void ComputeSubmitter::setRootDescriptorTable(int index, D3D12_GPU_DESCRIPTOR_HANDLE baseDescriptor)
{
m_commandList->SetComputeRootDescriptorTable(index, baseDescriptor);
}
@@ -87,7 +92,10 @@ void ComputeSubmitter::setRootConstants(
void const* srcData)
{
m_commandList->SetComputeRoot32BitConstants(
- UINT(rootParamIndex), UINT(countOf32BitValues), srcData, UINT(dstOffsetIn32BitValues));
+ UINT(rootParamIndex),
+ UINT(countOf32BitValues),
+ srcData,
+ UINT(dstOffsetIn32BitValues));
}
void ComputeSubmitter::setPipelineState(PipelineStateBase* pipeline)
diff --git a/tools/gfx/d3d12/d3d12-submitter.h b/tools/gfx/d3d12/d3d12-submitter.h
index 77c3f8c0d..3c605ad17 100644
--- a/tools/gfx/d3d12/d3d12-submitter.h
+++ b/tools/gfx/d3d12/d3d12-submitter.h
@@ -13,7 +13,8 @@ using namespace Slang;
struct Submitter
{
virtual void setRootConstantBufferView(
- int index, D3D12_GPU_VIRTUAL_ADDRESS gpuBufferLocation) = 0;
+ int index,
+ D3D12_GPU_VIRTUAL_ADDRESS gpuBufferLocation) = 0;
virtual void setRootUAV(int index, D3D12_GPU_VIRTUAL_ADDRESS gpuBufferLocation) = 0;
virtual void setRootSRV(int index, D3D12_GPU_VIRTUAL_ADDRESS gpuBufferLocation) = 0;
virtual void setRootDescriptorTable(int index, D3D12_GPU_DESCRIPTOR_HANDLE BaseDescriptor) = 0;
@@ -28,12 +29,12 @@ struct Submitter
struct GraphicsSubmitter : public Submitter
{
- virtual void setRootConstantBufferView(
- int index, D3D12_GPU_VIRTUAL_ADDRESS gpuBufferLocation) override;
+ virtual void setRootConstantBufferView(int index, D3D12_GPU_VIRTUAL_ADDRESS gpuBufferLocation)
+ override;
virtual void setRootUAV(int index, D3D12_GPU_VIRTUAL_ADDRESS gpuBufferLocation) override;
virtual void setRootSRV(int index, D3D12_GPU_VIRTUAL_ADDRESS gpuBufferLocation) override;
- virtual void setRootDescriptorTable(
- int index, D3D12_GPU_DESCRIPTOR_HANDLE baseDescriptor) override;
+ virtual void setRootDescriptorTable(int index, D3D12_GPU_DESCRIPTOR_HANDLE baseDescriptor)
+ override;
virtual void setRootSignature(ID3D12RootSignature* rootSignature) override;
virtual void setRootConstants(
Index rootParamIndex,
@@ -44,19 +45,20 @@ struct GraphicsSubmitter : public Submitter
GraphicsSubmitter(ID3D12GraphicsCommandList* commandList)
: m_commandList(commandList)
- {}
+ {
+ }
ID3D12GraphicsCommandList* m_commandList;
};
struct ComputeSubmitter : public Submitter
{
- virtual void setRootConstantBufferView(
- int index, D3D12_GPU_VIRTUAL_ADDRESS gpuBufferLocation) override;
+ virtual void setRootConstantBufferView(int index, D3D12_GPU_VIRTUAL_ADDRESS gpuBufferLocation)
+ override;
virtual void setRootUAV(int index, D3D12_GPU_VIRTUAL_ADDRESS gpuBufferLocation) override;
virtual void setRootSRV(int index, D3D12_GPU_VIRTUAL_ADDRESS gpuBufferLocation) override;
- virtual void setRootDescriptorTable(
- int index, D3D12_GPU_DESCRIPTOR_HANDLE baseDescriptor) override;
+ virtual void setRootDescriptorTable(int index, D3D12_GPU_DESCRIPTOR_HANDLE baseDescriptor)
+ override;
virtual void setRootSignature(ID3D12RootSignature* rootSignature) override;
virtual void setRootConstants(
Index rootParamIndex,
@@ -66,7 +68,8 @@ struct ComputeSubmitter : public Submitter
virtual void setPipelineState(PipelineStateBase* pipeline) override;
ComputeSubmitter(ID3D12GraphicsCommandList* commandList)
: m_commandList(commandList)
- {}
+ {
+ }
ID3D12GraphicsCommandList* m_commandList;
};
diff --git a/tools/gfx/d3d12/d3d12-swap-chain.cpp b/tools/gfx/d3d12/d3d12-swap-chain.cpp
index 8d4e723ea..098156c90 100644
--- a/tools/gfx/d3d12/d3d12-swap-chain.cpp
+++ b/tools/gfx/d3d12/d3d12-swap-chain.cpp
@@ -13,13 +13,18 @@ namespace d3d12
using namespace Slang;
Result SwapchainImpl::init(
- DeviceImpl* renderer, const ISwapchain::Desc& swapchainDesc, WindowHandle window)
+ DeviceImpl* renderer,
+ const ISwapchain::Desc& swapchainDesc,
+ WindowHandle window)
{
m_queue = static_cast<CommandQueueImpl*>(swapchainDesc.queue)->m_d3dQueue;
m_dxgiFactory = renderer->m_deviceInfo.m_dxgiFactory;
SLANG_RETURN_ON_FAIL(
D3DSwapchainBase::init(swapchainDesc, window, DXGI_SWAP_EFFECT_FLIP_DISCARD));
- SLANG_RETURN_ON_FAIL(renderer->m_device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(m_fence.writeRef())));
+ SLANG_RETURN_ON_FAIL(renderer->m_device->CreateFence(
+ 0,
+ D3D12_FENCE_FLAG_NONE,
+ IID_PPV_ARGS(m_fence.writeRef())));
SLANG_RETURN_ON_FAIL(m_swapChain->QueryInterface(m_swapChain3.writeRef()));
for (GfxIndex i = 0; i < swapchainDesc.imageCount; i++)
@@ -51,7 +56,9 @@ void SwapchainImpl::createSwapchainBufferImages()
m_swapChain->GetBuffer(i, IID_PPV_ARGS(d3dResource.writeRef()));
ITextureResource::Desc imageDesc = {};
imageDesc.allowedStates = ResourceStateSet(
- ResourceState::Present, ResourceState::RenderTarget, ResourceState::CopyDestination);
+ ResourceState::Present,
+ ResourceState::RenderTarget,
+ ResourceState::CopyDestination);
imageDesc.type = IResource::Type::Texture2D;
imageDesc.arraySize = 0;
imageDesc.format = m_desc.format;
@@ -80,7 +87,8 @@ int SwapchainImpl::acquireNextImage()
Result SwapchainImpl::present()
{
m_fence->SetEventOnCompletion(
- fenceValue, m_frameEvents[m_swapChain3->GetCurrentBackBufferIndex()]);
+ fenceValue,
+ m_frameEvents[m_swapChain3->GetCurrentBackBufferIndex()]);
SLANG_RETURN_ON_FAIL(D3DSwapchainBase::present());
fenceValue++;
m_queue->Signal(m_fence, fenceValue);
diff --git a/tools/gfx/d3d12/d3d12-texture.cpp b/tools/gfx/d3d12/d3d12-texture.cpp
index 9f47760e5..fdd9aab1b 100644
--- a/tools/gfx/d3d12/d3d12-texture.cpp
+++ b/tools/gfx/d3d12/d3d12-texture.cpp
@@ -9,9 +9,9 @@ namespace d3d12
using namespace Slang;
TextureResourceImpl::TextureResourceImpl(const Desc& desc)
- : Parent(desc)
- , m_defaultState(D3DUtil::getResourceState(desc.defaultState))
-{}
+ : Parent(desc), m_defaultState(D3DUtil::getResourceState(desc.defaultState))
+{
+}
TextureResourceImpl::~TextureResourceImpl()
{
@@ -45,7 +45,11 @@ Result TextureResourceImpl::getSharedHandle(InteropHandle* outHandle)
auto pResource = m_resource.getResource();
pResource->GetDevice(IID_PPV_ARGS(pDevice.writeRef()));
SLANG_RETURN_ON_FAIL(pDevice->CreateSharedHandle(
- pResource, NULL, GENERIC_ALL, nullptr, (HANDLE*)&outHandle->handleValue));
+ pResource,
+ NULL,
+ GENERIC_ALL,
+ nullptr,
+ (HANDLE*)&outHandle->handleValue));
outHandle->api = InteropHandleAPI::D3D12;
return SLANG_OK;
#endif
diff --git a/tools/gfx/d3d12/d3d12-texture.h b/tools/gfx/d3d12/d3d12-texture.h
index 3f6ed398b..e8bc4aa66 100644
--- a/tools/gfx/d3d12/d3d12-texture.h
+++ b/tools/gfx/d3d12/d3d12-texture.h
@@ -23,7 +23,7 @@ public:
D3D12_RESOURCE_STATES m_defaultState;
virtual SLANG_NO_THROW Result SLANG_MCALL
- getNativeResourceHandle(InteropHandle* outHandle) override;
+ getNativeResourceHandle(InteropHandle* outHandle) override;
virtual SLANG_NO_THROW Result SLANG_MCALL getSharedHandle(InteropHandle* outHandle) override;
diff --git a/tools/gfx/d3d12/d3d12-transient-heap.cpp b/tools/gfx/d3d12/d3d12-transient-heap.cpp
index 60f40cc66..92b4de544 100644
--- a/tools/gfx/d3d12/d3d12-transient-heap.cpp
+++ b/tools/gfx/d3d12/d3d12-transient-heap.cpp
@@ -1,9 +1,9 @@
// d3d12-transient-heap.cpp
#include "d3d12-transient-heap.h"
-#include "d3d12-device.h"
#include "d3d12-buffer.h"
#include "d3d12-command-buffer.h"
+#include "d3d12-device.h"
namespace gfx
{
@@ -15,7 +15,10 @@ using namespace Slang;
Result TransientResourceHeapImpl::synchronize()
{
WaitForMultipleObjects(
- (DWORD)m_waitHandles.getCount(), m_waitHandles.getArrayView().getBuffer(), TRUE, INFINITE);
+ (DWORD)m_waitHandles.getCount(),
+ m_waitHandles.getArrayView().getBuffer(),
+ TRUE,
+ INFINITE);
m_waitHandles.clear();
return SLANG_OK;
}
@@ -139,7 +142,8 @@ Result TransientResourceHeapImpl::init(
auto d3dDevice = device->m_device;
SLANG_RETURN_ON_FAIL(d3dDevice->CreateCommandAllocator(
- D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(m_commandAllocator.writeRef())));
+ D3D12_COMMAND_LIST_TYPE_DIRECT,
+ IID_PPV_ARGS(m_commandAllocator.writeRef())));
allocateNewViewDescriptorHeap(device);
allocateNewSamplerDescriptorHeap(device);
diff --git a/tools/gfx/d3d12/d3d12-transient-heap.h b/tools/gfx/d3d12/d3d12-transient-heap.h
index 6b05367e8..1986d6326 100644
--- a/tools/gfx/d3d12/d3d12-transient-heap.h
+++ b/tools/gfx/d3d12/d3d12-transient-heap.h
@@ -11,8 +11,8 @@ namespace d3d12
using namespace Slang;
class TransientResourceHeapImpl
- : public TransientResourceHeapBaseImpl<DeviceImpl, BufferResourceImpl>
- , public ITransientResourceHeapD3D12
+ : public TransientResourceHeapBaseImpl<DeviceImpl, BufferResourceImpl>,
+ public ITransientResourceHeapD3D12
{
private:
typedef TransientResourceHeapBaseImpl<DeviceImpl, BufferResourceImpl> Super;
@@ -39,7 +39,7 @@ public:
//
// We will thus keep a single heap of each type that we hope will hold
// all the descriptors that actually get needed in a frame.
- ShortList<D3D12DescriptorHeap, 4> m_viewHeaps; // Cbv, Srv, Uav
+ ShortList<D3D12DescriptorHeap, 4> m_viewHeaps; // Cbv, Srv, Uav
ShortList<D3D12DescriptorHeap, 4> m_samplerHeaps; // Heap for samplers
int32_t m_currentViewHeapIndex = -1;
int32_t m_currentSamplerHeapIndex = -1;
@@ -55,7 +55,7 @@ public:
D3D12LinearExpandingDescriptorHeap m_stagingCpuSamplerHeap;
virtual SLANG_NO_THROW Result SLANG_MCALL
- queryInterface(SlangUUID const& uuid, void** outObject) override;
+ queryInterface(SlangUUID const& uuid, void** outObject) override;
virtual SLANG_NO_THROW uint32_t SLANG_MCALL addRef() override { return Super::addRef(); }
virtual SLANG_NO_THROW uint32_t SLANG_MCALL release() override { return Super::release(); }
@@ -81,7 +81,7 @@ public:
Result allocateNewSamplerDescriptorHeap(DeviceImpl* device);
virtual SLANG_NO_THROW Result SLANG_MCALL
- createCommandBuffer(ICommandBuffer** outCommandBuffer) override;
+ createCommandBuffer(ICommandBuffer** outCommandBuffer) override;
Result synchronize();