summaryrefslogtreecommitdiff
path: root/tools/gfx/d3d11
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/d3d11
parenta729c15e9dce9f5116a38afc66329ab2ca4cea54 (diff)
format
* format * Minor test fixes * enable checking cpp format in ci
Diffstat (limited to 'tools/gfx/d3d11')
-rw-r--r--tools/gfx/d3d11/d3d11-base.h61
-rw-r--r--tools/gfx/d3d11/d3d11-buffer.cpp2
-rw-r--r--tools/gfx/d3d11/d3d11-buffer.h6
-rw-r--r--tools/gfx/d3d11/d3d11-device.cpp979
-rw-r--r--tools/gfx/d3d11/d3d11-device.h52
-rw-r--r--tools/gfx/d3d11/d3d11-helper-functions.cpp494
-rw-r--r--tools/gfx/d3d11/d3d11-helper-functions.h467
-rw-r--r--tools/gfx/d3d11/d3d11-pipeline-state.h12
-rw-r--r--tools/gfx/d3d11/d3d11-query.cpp21
-rw-r--r--tools/gfx/d3d11/d3d11-query.h23
-rw-r--r--tools/gfx/d3d11/d3d11-resource-views.h8
-rw-r--r--tools/gfx/d3d11/d3d11-scopeNVAPI.h5
-rw-r--r--tools/gfx/d3d11/d3d11-shader-object-layout.cpp60
-rw-r--r--tools/gfx/d3d11/d3d11-shader-object-layout.h107
-rw-r--r--tools/gfx/d3d11/d3d11-shader-object.cpp80
-rw-r--r--tools/gfx/d3d11/d3d11-shader-object.h115
-rw-r--r--tools/gfx/d3d11/d3d11-shader-program.cpp1
-rw-r--r--tools/gfx/d3d11/d3d11-swap-chain.cpp5
-rw-r--r--tools/gfx/d3d11/d3d11-texture.h1
-rw-r--r--tools/gfx/d3d11/d3d11-vertex-layout.h4
20 files changed, 1318 insertions, 1185 deletions
diff --git a/tools/gfx/d3d11/d3d11-base.h b/tools/gfx/d3d11/d3d11-base.h
index ce38bb174..084654991 100644
--- a/tools/gfx/d3d11/d3d11-base.h
+++ b/tools/gfx/d3d11/d3d11-base.h
@@ -2,16 +2,15 @@
// Shared header file for D3D11 implementation
#pragma once
-#include "../immediate-renderer-base.h"
-#include "../d3d/d3d-util.h"
#include "../d3d/d3d-swapchain.h"
-#include "../nvapi/nvapi-util.h"
+#include "../d3d/d3d-util.h"
+#include "../flag-combiner.h"
+#include "../immediate-renderer-base.h"
#include "../mutable-shader-object.h"
+#include "../nvapi/nvapi-util.h"
#include "core/slang-basic.h"
#include "core/slang-blob.h"
-
#include "slang-com-ptr.h"
-#include "../flag-combiner.h"
#pragma push_macro("WIN32_LEAN_AND_MEAN")
#pragma push_macro("NOMINMAX")
@@ -30,7 +29,7 @@
// NVAPI integration is described here
// https://developer.nvidia.com/unlocking-gpu-intrinsics-hlsl
-# include "../nvapi/nvapi-include.h"
+#include "../nvapi/nvapi-include.h"
#endif
// We will use the C standard library just for printing error messages.
@@ -47,28 +46,28 @@ namespace gfx
{
namespace d3d11
{
- class DeviceImpl;
- class ShaderProgramImpl;
- class BufferResourceImpl;
- class TextureResourceImpl;
- class SamplerStateImpl;
- class ResourceViewImpl;
- class ShaderResourceViewImpl;
- class UnorderedAccessViewImpl;
- class DepthStencilViewImpl;
- class RenderTargetViewImpl;
- class FramebufferLayoutImpl;
- class FramebufferImpl;
- class SwapchainImpl;
- class InputLayoutImpl;
- class QueryPoolImpl;
- class PipelineStateImpl;
- class GraphicsPipelineStateImpl;
- class ComputePipelineStateImpl;
- class ShaderObjectLayoutImpl;
- class RootShaderObjectLayoutImpl;
- class ShaderObjectImpl;
- class MutableShaderObjectImpl;
- class RootShaderObjectImpl;
-}
-}
+class DeviceImpl;
+class ShaderProgramImpl;
+class BufferResourceImpl;
+class TextureResourceImpl;
+class SamplerStateImpl;
+class ResourceViewImpl;
+class ShaderResourceViewImpl;
+class UnorderedAccessViewImpl;
+class DepthStencilViewImpl;
+class RenderTargetViewImpl;
+class FramebufferLayoutImpl;
+class FramebufferImpl;
+class SwapchainImpl;
+class InputLayoutImpl;
+class QueryPoolImpl;
+class PipelineStateImpl;
+class GraphicsPipelineStateImpl;
+class ComputePipelineStateImpl;
+class ShaderObjectLayoutImpl;
+class RootShaderObjectLayoutImpl;
+class ShaderObjectImpl;
+class MutableShaderObjectImpl;
+class RootShaderObjectImpl;
+} // namespace d3d11
+} // namespace gfx
diff --git a/tools/gfx/d3d11/d3d11-buffer.cpp b/tools/gfx/d3d11/d3d11-buffer.cpp
index aa51b999f..42c4c698c 100644
--- a/tools/gfx/d3d11/d3d11-buffer.cpp
+++ b/tools/gfx/d3d11/d3d11-buffer.cpp
@@ -15,7 +15,7 @@ SLANG_NO_THROW DeviceAddress SLANG_MCALL BufferResourceImpl::getDeviceAddress()
}
SLANG_NO_THROW Result SLANG_MCALL
- BufferResourceImpl::map(MemoryRange* rangeToRead, void** outPointer)
+BufferResourceImpl::map(MemoryRange* rangeToRead, void** outPointer)
{
SLANG_UNUSED(rangeToRead);
SLANG_UNUSED(outPointer);
diff --git a/tools/gfx/d3d11/d3d11-buffer.h b/tools/gfx/d3d11/d3d11-buffer.h
index f5462b029..237e33fd6 100644
--- a/tools/gfx/d3d11/d3d11-buffer.h
+++ b/tools/gfx/d3d11/d3d11-buffer.h
@@ -16,8 +16,8 @@ class BufferResourceImpl : public BufferResource
public:
typedef BufferResource Parent;
- BufferResourceImpl(const IBufferResource::Desc& desc) :
- Parent(desc)
+ BufferResourceImpl(const IBufferResource::Desc& desc)
+ : Parent(desc)
{
}
@@ -29,7 +29,7 @@ public:
virtual SLANG_NO_THROW DeviceAddress SLANG_MCALL getDeviceAddress() 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;
};
diff --git a/tools/gfx/d3d11/d3d11-device.cpp b/tools/gfx/d3d11/d3d11-device.cpp
index 148590831..8fe3bf589 100644
--- a/tools/gfx/d3d11/d3d11-device.cpp
+++ b/tools/gfx/d3d11/d3d11-device.cpp
@@ -3,23 +3,22 @@
#include "d3d11-device.h"
#include "d3d11-buffer.h"
+#include "d3d11-helper-functions.h"
#include "d3d11-query.h"
#include "d3d11-resource-views.h"
#include "d3d11-sampler.h"
#include "d3d11-scopeNVAPI.h"
-#include "d3d11-shader-object.h"
#include "d3d11-shader-object-layout.h"
+#include "d3d11-shader-object.h"
#include "d3d11-shader-program.h"
#include "d3d11-swap-chain.h"
#include "d3d11-texture.h"
#include "d3d11-vertex-layout.h"
-#include "d3d11-helper-functions.h"
-
#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
@@ -38,7 +37,7 @@ SlangResult DeviceImpl::initialize(const Desc& desc)
desc.extendedDescs,
SLANG_DXBC,
"sm_5_0",
- makeArray(slang::PreprocessorMacroDesc{ "__D3D11__", "1" }).getView()));
+ makeArray(slang::PreprocessorMacroDesc{"__D3D11__", "1"}).getView()));
SLANG_RETURN_ON_FAIL(RendererBase::initialize(desc));
@@ -48,7 +47,7 @@ SlangResult DeviceImpl::initialize(const Desc& desc)
m_info.bindingStyle = BindingStyle::DirectX;
m_info.projectionStyle = ProjectionStyle::DirectX;
m_info.apiName = "Direct3D 11";
- 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));
}
@@ -64,20 +63,20 @@ SlangResult DeviceImpl::initialize(const Desc& desc)
}
PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN D3D11CreateDeviceAndSwapChain_ =
- (PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN)SharedLibrary::findSymbolAddressByName(d3dModule, "D3D11CreateDeviceAndSwapChain");
+ (PFN_D3D11_CREATE_DEVICE_AND_SWAP_CHAIN)SharedLibrary::findSymbolAddressByName(
+ d3dModule,
+ "D3D11CreateDeviceAndSwapChain");
if (!D3D11CreateDeviceAndSwapChain_)
{
- fprintf(stderr,
- "error: failed load symbol 'D3D11CreateDeviceAndSwapChain'\n");
+ fprintf(stderr, "error: failed load symbol 'D3D11CreateDeviceAndSwapChain'\n");
return SLANG_FAIL;
}
- PFN_D3D11_CREATE_DEVICE D3D11CreateDevice_ =
- (PFN_D3D11_CREATE_DEVICE)SharedLibrary::findSymbolAddressByName(d3dModule, "D3D11CreateDevice");
+ PFN_D3D11_CREATE_DEVICE D3D11CreateDevice_ = (PFN_D3D11_CREATE_DEVICE)
+ SharedLibrary::findSymbolAddressByName(d3dModule, "D3D11CreateDevice");
if (!D3D11CreateDevice_)
{
- fprintf(stderr,
- "error: failed load symbol 'D3D11CreateDevice'\n");
+ fprintf(stderr, "error: failed load symbol 'D3D11CreateDevice'\n");
return SLANG_FAIL;
}
@@ -107,12 +106,18 @@ SlangResult DeviceImpl::initialize(const Desc& desc)
// up to each back-end to specify.
#if _DEBUG
- combiner.add(DeviceCheckFlag::UseDebug, ChangeType::OnOff); ///< First try debug then non debug
+ combiner.add(
+ DeviceCheckFlag::UseDebug,
+ ChangeType::OnOff); ///< First try debug then non debug
#else
- combiner.add(DeviceCheckFlag::UseDebug, ChangeType::Off); ///< Don't bother with debug
+ combiner.add(DeviceCheckFlag::UseDebug, ChangeType::Off); ///< Don't bother with debug
#endif
- combiner.add(DeviceCheckFlag::UseHardwareDevice, ChangeType::OnOff); ///< First try hardware, then reference
- combiner.add(DeviceCheckFlag::UseFullFeatureLevel, ChangeType::OnOff); ///< First try fully featured, then degrade features
+ combiner.add(
+ DeviceCheckFlag::UseHardwareDevice,
+ ChangeType::OnOff); ///< First try hardware, then reference
+ combiner.add(
+ DeviceCheckFlag::UseFullFeatureLevel,
+ ChangeType::OnOff); ///< First try fully featured, then degrade features
const int numCombinations = combiner.getNumCombinations();
@@ -127,7 +132,11 @@ SlangResult DeviceImpl::initialize(const Desc& desc)
if (desc.adapterLUID)
{
List<ComPtr<IDXGIAdapter>> dxgiAdapters;
- D3DUtil::findAdapters(deviceCheckFlags, desc.adapterLUID, m_dxgiFactory, dxgiAdapters);
+ D3DUtil::findAdapters(
+ deviceCheckFlags,
+ desc.adapterLUID,
+ m_dxgiFactory,
+ dxgiAdapters);
if (dxgiAdapters.getCount() == 0)
{
continue;
@@ -135,16 +144,21 @@ SlangResult DeviceImpl::initialize(const Desc& desc)
adapter = dxgiAdapters[0];
}
- // The adapter can be nullptr - that just means 'default', but when so we need to select the driver type
+ // The adapter can be nullptr - that just means 'default', but when so we need to select
+ // the driver type
D3D_DRIVER_TYPE driverType = D3D_DRIVER_TYPE_UNKNOWN;
if (adapter == nullptr)
{
// If we don't have an adapter, select directly
- driverType = (deviceCheckFlags & DeviceCheckFlag::UseHardwareDevice) ? D3D_DRIVER_TYPE_HARDWARE : D3D_DRIVER_TYPE_REFERENCE;
+ driverType = (deviceCheckFlags & DeviceCheckFlag::UseHardwareDevice)
+ ? D3D_DRIVER_TYPE_HARDWARE
+ : D3D_DRIVER_TYPE_REFERENCE;
}
- const int startFeatureIndex = (deviceCheckFlags & DeviceCheckFlag::UseFullFeatureLevel) ? 0 : 1;
- const UINT deviceFlags = (deviceCheckFlags & DeviceCheckFlag::UseDebug) ? D3D11_CREATE_DEVICE_DEBUG : 0;
+ const int startFeatureIndex =
+ (deviceCheckFlags & DeviceCheckFlag::UseFullFeatureLevel) ? 0 : 1;
+ const UINT deviceFlags =
+ (deviceCheckFlags & DeviceCheckFlag::UseDebug) ? D3D11_CREATE_DEVICE_DEBUG : 0;
res = D3D11CreateDevice_(
adapter,
@@ -161,16 +175,24 @@ SlangResult DeviceImpl::initialize(const Desc& desc)
#ifdef GFX_NV_AFTERMATH
if (SLANG_SUCCEEDED(res))
{
- if (deviceCheckFlags & DeviceCheckFlag::UseDebug)
+ if (deviceCheckFlags & DeviceCheckFlag::UseDebug)
{
// Initialize Nsight Aftermath for this device.
- // This combination of flags is not necessarily appropriate for real world usage
+ // This combination of flags is not necessarily appropriate 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.
+ 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_DX11_Initialize(
GFSDK_Aftermath_Version_API,
@@ -192,7 +214,6 @@ SlangResult DeviceImpl::initialize(const Desc& desc)
{
break;
}
-
}
// If res is failure, means all styles have have failed, and so initialization fails.
if (SLANG_FAILED(res))
@@ -250,8 +271,7 @@ SlangResult DeviceImpl::initialize(const Desc& desc)
// Create a TIMESTAMP_DISJOINT query object to query/update frequency info.
D3D11_QUERY_DESC disjointQueryDesc = {};
disjointQueryDesc.Query = D3D11_QUERY_TIMESTAMP_DISJOINT;
- SLANG_RETURN_ON_FAIL(m_device->CreateQuery(
- &disjointQueryDesc, m_disjointQuery.writeRef()));
+ SLANG_RETURN_ON_FAIL(m_device->CreateQuery(&disjointQueryDesc, m_disjointQuery.writeRef()));
m_immediateContext->Begin(m_disjointQuery);
m_immediateContext->End(m_disjointQuery);
D3D11_QUERY_DATA_TIMESTAMP_DISJOINT disjointData = {};
@@ -310,15 +330,17 @@ SlangResult DeviceImpl::initialize(const Desc& desc)
limits.maxVertexInputElements = maxInputElements;
limits.maxVertexInputElementOffset = 256; // TODO
- limits.maxVertexStreams = D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT ;
+ limits.maxVertexStreams = D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT;
limits.maxVertexStreamStride = D3D11_REQ_MULTI_ELEMENT_STRUCTURE_SIZE_IN_BYTES;
limits.maxComputeThreadsPerGroup = D3D11_CS_THREAD_GROUP_MAX_THREADS_PER_GROUP;
limits.maxComputeThreadGroupSize[0] = maxComputeThreadGroupSizeXY;
limits.maxComputeThreadGroupSize[1] = maxComputeThreadGroupSizeXY;
limits.maxComputeThreadGroupSize[2] = maxComputeThreadGroupSizeZ;
- limits.maxComputeDispatchThreadGroups[0] = D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION;
- limits.maxComputeDispatchThreadGroups[1] = D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION;
+ limits.maxComputeDispatchThreadGroups[0] =
+ D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION;
+ limits.maxComputeDispatchThreadGroups[1] =
+ D3D11_CS_DISPATCH_MAX_THREAD_GROUPS_PER_DIMENSION;
limits.maxComputeDispatchThreadGroups[2] = maxComputeDispatchThreadGroupsZ;
limits.maxViewports = D3D11_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE;
@@ -365,7 +387,9 @@ void DeviceImpl::clearFrame(uint32_t colorBufferMask, bool clearDepth, bool clea
}
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));
@@ -374,7 +398,8 @@ Result DeviceImpl::createSwapchain(
}
Result DeviceImpl::createFramebufferLayout(
- const IFramebufferLayout::Desc& desc, IFramebufferLayout** outLayout)
+ const IFramebufferLayout::Desc& desc,
+ IFramebufferLayout** outLayout)
{
RefPtr<FramebufferLayoutImpl> layout = new FramebufferLayoutImpl();
layout->m_renderTargets.setCount(desc.renderTargetCount);
@@ -396,19 +421,20 @@ Result DeviceImpl::createFramebufferLayout(
return SLANG_OK;
}
-Result DeviceImpl::createFramebuffer(
- const IFramebuffer::Desc& desc, IFramebuffer** outFramebuffer)
+Result DeviceImpl::createFramebuffer(const IFramebuffer::Desc& desc, IFramebuffer** outFramebuffer)
{
RefPtr<FramebufferImpl> framebuffer = new FramebufferImpl();
framebuffer->renderTargetViews.setCount(desc.renderTargetCount);
framebuffer->d3dRenderTargetViews.setCount(desc.renderTargetCount);
for (GfxIndex i = 0; i < desc.renderTargetCount; i++)
{
- framebuffer->renderTargetViews[i] = static_cast<RenderTargetViewImpl*>(desc.renderTargetViews[i]);
+ framebuffer->renderTargetViews[i] =
+ static_cast<RenderTargetViewImpl*>(desc.renderTargetViews[i]);
framebuffer->d3dRenderTargetViews[i] = framebuffer->renderTargetViews[i]->m_rtv;
}
framebuffer->depthStencilView = static_cast<DepthStencilViewImpl*>(desc.depthStencilView);
- framebuffer->d3dDepthStencilView = framebuffer->depthStencilView ? framebuffer->depthStencilView->m_dsv : nullptr;
+ framebuffer->d3dDepthStencilView =
+ framebuffer->depthStencilView ? framebuffer->depthStencilView->m_dsv : nullptr;
returnComPtr(outFramebuffer, framebuffer);
return SLANG_OK;
}
@@ -491,7 +517,8 @@ SlangResult DeviceImpl::readTextureResource(
// Now just read back texels from the staging textures
{
D3D11_MAPPED_SUBRESOURCE mappedResource;
- SLANG_RETURN_ON_FAIL(m_immediateContext->Map(stagingTexture, 0, D3D11_MAP_READ, 0, &mappedResource));
+ SLANG_RETURN_ON_FAIL(
+ m_immediateContext->Map(stagingTexture, 0, D3D11_MAP_READ, 0, &mappedResource));
List<uint8_t> data;
@@ -514,7 +541,10 @@ SlangResult DeviceImpl::readTextureResource(
}
}
-Result DeviceImpl::createTextureResource(const ITextureResource::Desc& descIn, const ITextureResource::SubresourceData* initData, ITextureResource** outResource)
+Result DeviceImpl::createTextureResource(
+ const ITextureResource::Desc& descIn,
+ const ITextureResource::SubresourceData* initData,
+ ITextureResource** outResource)
{
TextureResource::Desc srcDesc = fixupTextureDesc(descIn);
@@ -563,79 +593,84 @@ Result DeviceImpl::createTextureResource(const ITextureResource::Desc& descIn, c
switch (srcDesc.type)
{
case IResource::Type::Texture1D:
- {
- D3D11_TEXTURE1D_DESC desc = { 0 };
- desc.BindFlags = bindFlags;
- desc.CPUAccessFlags = accessFlags;
- desc.Format = format;
- desc.MiscFlags = 0;
- desc.MipLevels = srcDesc.numMipLevels;
- desc.ArraySize = effectiveArraySize;
- desc.Width = srcDesc.size.width;
- desc.Usage = D3D11_USAGE_DEFAULT;
-
- ComPtr<ID3D11Texture1D> texture1D;
- SLANG_RETURN_ON_FAIL(m_device->CreateTexture1D(&desc, subResourcesPtr, texture1D.writeRef()));
-
- texture->m_resource = texture1D;
- break;
- }
+ {
+ D3D11_TEXTURE1D_DESC desc = {0};
+ desc.BindFlags = bindFlags;
+ desc.CPUAccessFlags = accessFlags;
+ desc.Format = format;
+ desc.MiscFlags = 0;
+ desc.MipLevels = srcDesc.numMipLevels;
+ desc.ArraySize = effectiveArraySize;
+ desc.Width = srcDesc.size.width;
+ desc.Usage = D3D11_USAGE_DEFAULT;
+
+ ComPtr<ID3D11Texture1D> texture1D;
+ SLANG_RETURN_ON_FAIL(
+ m_device->CreateTexture1D(&desc, subResourcesPtr, texture1D.writeRef()));
+
+ texture->m_resource = texture1D;
+ break;
+ }
case IResource::Type::TextureCube:
case IResource::Type::Texture2D:
- {
- D3D11_TEXTURE2D_DESC desc = { 0 };
- desc.BindFlags = bindFlags;
- desc.CPUAccessFlags = accessFlags;
- desc.Format = format;
- desc.MiscFlags = 0;
- desc.MipLevels = srcDesc.numMipLevels;
- desc.ArraySize = effectiveArraySize;
-
- desc.Width = srcDesc.size.width;
- desc.Height = srcDesc.size.height;
- desc.Usage = D3D11_USAGE_DEFAULT;
- desc.SampleDesc.Count = srcDesc.sampleDesc.numSamples;
- desc.SampleDesc.Quality = srcDesc.sampleDesc.quality;
-
- if (srcDesc.type == IResource::Type::TextureCube)
{
- desc.MiscFlags |= D3D11_RESOURCE_MISC_TEXTURECUBE;
- }
+ D3D11_TEXTURE2D_DESC desc = {0};
+ desc.BindFlags = bindFlags;
+ desc.CPUAccessFlags = accessFlags;
+ desc.Format = format;
+ desc.MiscFlags = 0;
+ desc.MipLevels = srcDesc.numMipLevels;
+ desc.ArraySize = effectiveArraySize;
+
+ desc.Width = srcDesc.size.width;
+ desc.Height = srcDesc.size.height;
+ desc.Usage = D3D11_USAGE_DEFAULT;
+ desc.SampleDesc.Count = srcDesc.sampleDesc.numSamples;
+ desc.SampleDesc.Quality = srcDesc.sampleDesc.quality;
+
+ if (srcDesc.type == IResource::Type::TextureCube)
+ {
+ desc.MiscFlags |= D3D11_RESOURCE_MISC_TEXTURECUBE;
+ }
- ComPtr<ID3D11Texture2D> texture2D;
- SLANG_RETURN_ON_FAIL(m_device->CreateTexture2D(&desc, subResourcesPtr, texture2D.writeRef()));
+ ComPtr<ID3D11Texture2D> texture2D;
+ SLANG_RETURN_ON_FAIL(
+ m_device->CreateTexture2D(&desc, subResourcesPtr, texture2D.writeRef()));
- texture->m_resource = texture2D;
- break;
- }
+ texture->m_resource = texture2D;
+ break;
+ }
case IResource::Type::Texture3D:
- {
- D3D11_TEXTURE3D_DESC desc = { 0 };
- desc.BindFlags = bindFlags;
- desc.CPUAccessFlags = accessFlags;
- desc.Format = format;
- desc.MiscFlags = 0;
- desc.MipLevels = srcDesc.numMipLevels;
- desc.Width = srcDesc.size.width;
- desc.Height = srcDesc.size.height;
- desc.Depth = srcDesc.size.depth;
- desc.Usage = D3D11_USAGE_DEFAULT;
-
- ComPtr<ID3D11Texture3D> texture3D;
- SLANG_RETURN_ON_FAIL(m_device->CreateTexture3D(&desc, subResourcesPtr, texture3D.writeRef()));
-
- texture->m_resource = texture3D;
- break;
- }
- default:
- return SLANG_FAIL;
+ {
+ D3D11_TEXTURE3D_DESC desc = {0};
+ desc.BindFlags = bindFlags;
+ desc.CPUAccessFlags = accessFlags;
+ desc.Format = format;
+ desc.MiscFlags = 0;
+ desc.MipLevels = srcDesc.numMipLevels;
+ desc.Width = srcDesc.size.width;
+ desc.Height = srcDesc.size.height;
+ desc.Depth = srcDesc.size.depth;
+ desc.Usage = D3D11_USAGE_DEFAULT;
+
+ ComPtr<ID3D11Texture3D> texture3D;
+ SLANG_RETURN_ON_FAIL(
+ m_device->CreateTexture3D(&desc, subResourcesPtr, texture3D.writeRef()));
+
+ texture->m_resource = texture3D;
+ break;
+ }
+ default: return SLANG_FAIL;
}
returnComPtr(outResource, texture);
return SLANG_OK;
}
-Result DeviceImpl::createBufferResource(const IBufferResource::Desc& descIn, const void* initData, IBufferResource** outResource)
+Result DeviceImpl::createBufferResource(
+ const IBufferResource::Desc& descIn,
+ const void* initData,
+ IBufferResource** outResource)
{
IBufferResource::Desc srcDesc = fixupBufferDesc(descIn);
@@ -649,7 +684,8 @@ Result DeviceImpl::createBufferResource(const IBufferResource::Desc& descIn, con
alignedSizeInBytes = D3DUtil::calcAligned(alignedSizeInBytes, 256);
}
- // Hack to make the initialization never read from out of bounds memory, by copying into a buffer
+ // Hack to make the initialization never read from out of bounds memory, by copying into a
+ // buffer
List<uint8_t> initDataBuffer;
if (initData && alignedSizeInBytes > srcDesc.sizeInBytes)
{
@@ -658,7 +694,7 @@ Result DeviceImpl::createBufferResource(const IBufferResource::Desc& descIn, con
initData = initDataBuffer.getBuffer();
}
- D3D11_BUFFER_DESC bufferDesc = { 0 };
+ D3D11_BUFFER_DESC bufferDesc = {0};
bufferDesc.ByteWidth = UINT(alignedSizeInBytes);
bufferDesc.BindFlags = d3dBindFlags;
// For read we'll need to do some staging
@@ -681,17 +717,17 @@ Result DeviceImpl::createBufferResource(const IBufferResource::Desc& descIn, con
switch (descIn.defaultState)
{
case ResourceState::ConstantBuffer:
- {
- // We'll just assume ConstantBuffers are dynamic for now
- bufferDesc.Usage = D3D11_USAGE_DYNAMIC;
- break;
- }
+ {
+ // We'll just assume ConstantBuffers are dynamic for now
+ bufferDesc.Usage = D3D11_USAGE_DYNAMIC;
+ break;
+ }
default: break;
}
if (bufferDesc.BindFlags & (D3D11_BIND_UNORDERED_ACCESS | D3D11_BIND_SHADER_RESOURCE))
{
- //desc.BindFlags = D3D11_BIND_UNORDERED_ACCESS | D3D11_BIND_SHADER_RESOURCE;
+ // desc.BindFlags = D3D11_BIND_UNORDERED_ACCESS | D3D11_BIND_SHADER_RESOURCE;
if (srcDesc.elementSize != 0)
{
bufferDesc.StructureByteStride = (UINT)srcDesc.elementSize;
@@ -708,12 +744,15 @@ Result DeviceImpl::createBufferResource(const IBufferResource::Desc& descIn, con
bufferDesc.CPUAccessFlags |= D3D11_CPU_ACCESS_WRITE;
}
- D3D11_SUBRESOURCE_DATA subResourceData = { 0 };
+ D3D11_SUBRESOURCE_DATA subResourceData = {0};
subResourceData.pSysMem = initData;
RefPtr<BufferResourceImpl> buffer(new BufferResourceImpl(srcDesc));
- SLANG_RETURN_ON_FAIL(m_device->CreateBuffer(&bufferDesc, initData ? &subResourceData : nullptr, buffer->m_buffer.writeRef()));
+ SLANG_RETURN_ON_FAIL(m_device->CreateBuffer(
+ &bufferDesc,
+ initData ? &subResourceData : nullptr,
+ buffer->m_buffer.writeRef()));
buffer->m_d3dUsage = bufferDesc.Usage;
if (srcDesc.memoryType == MemoryType::ReadBack || bufferDesc.Usage != D3D11_USAGE_DYNAMIC)
@@ -724,7 +763,8 @@ Result DeviceImpl::createBufferResource(const IBufferResource::Desc& descIn, con
bufDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;
bufDesc.Usage = D3D11_USAGE_STAGING;
- SLANG_RETURN_ON_FAIL(m_device->CreateBuffer(&bufDesc, nullptr, buffer->m_staging.writeRef()));
+ SLANG_RETURN_ON_FAIL(
+ m_device->CreateBuffer(&bufDesc, nullptr, buffer->m_staging.writeRef()));
}
returnComPtr(outResource, buffer);
return SLANG_OK;
@@ -761,9 +801,7 @@ Result DeviceImpl::createSamplerState(ISamplerState::Desc const& desc, ISamplerS
dxDesc.MaxLOD = desc.maxLOD;
ComPtr<ID3D11SamplerState> sampler;
- SLANG_RETURN_ON_FAIL(m_device->CreateSamplerState(
- &dxDesc,
- sampler.writeRef()));
+ SLANG_RETURN_ON_FAIL(m_device->CreateSamplerState(&dxDesc, sampler.writeRef()));
RefPtr<SamplerStateImpl> samplerImpl = new SamplerStateImpl();
samplerImpl->m_sampler = sampler;
@@ -771,85 +809,103 @@ Result DeviceImpl::createSamplerState(ISamplerState::Desc const& desc, ISamplerS
return SLANG_OK;
}
-Result DeviceImpl::createTextureView(ITextureResource* texture, IResourceView::Desc const& desc, IResourceView** outView)
+Result DeviceImpl::createTextureView(
+ ITextureResource* texture,
+ IResourceView::Desc const& desc,
+ IResourceView** outView)
{
auto resourceImpl = (TextureResourceImpl*)texture;
switch (desc.type)
{
- default:
- return SLANG_FAIL;
+ default: return SLANG_FAIL;
case IResourceView::Type::RenderTarget:
- {
- ComPtr<ID3D11RenderTargetView> rtv;
- SLANG_RETURN_ON_FAIL(m_device->CreateRenderTargetView(resourceImpl->m_resource, nullptr, rtv.writeRef()));
-
- RefPtr<RenderTargetViewImpl> viewImpl = new RenderTargetViewImpl();
- viewImpl->m_type = ResourceViewImpl::Type::RTV;
- viewImpl->m_rtv = rtv;
- viewImpl->m_desc = desc;
- if (resourceImpl->getDesc()->optimalClearValue)
{
- memcpy(
- viewImpl->m_clearValue,
- &resourceImpl->getDesc()->optimalClearValue->color,
- sizeof(float) * 4);
+ ComPtr<ID3D11RenderTargetView> rtv;
+ SLANG_RETURN_ON_FAIL(m_device->CreateRenderTargetView(
+ resourceImpl->m_resource,
+ nullptr,
+ rtv.writeRef()));
+
+ RefPtr<RenderTargetViewImpl> viewImpl = new RenderTargetViewImpl();
+ viewImpl->m_type = ResourceViewImpl::Type::RTV;
+ viewImpl->m_rtv = rtv;
+ viewImpl->m_desc = desc;
+ if (resourceImpl->getDesc()->optimalClearValue)
+ {
+ memcpy(
+ viewImpl->m_clearValue,
+ &resourceImpl->getDesc()->optimalClearValue->color,
+ sizeof(float) * 4);
+ }
+ returnComPtr(outView, viewImpl);
+ return SLANG_OK;
}
- returnComPtr(outView, viewImpl);
- return SLANG_OK;
- }
- break;
+ break;
case IResourceView::Type::DepthStencil:
- {
- ComPtr<ID3D11DepthStencilView> dsv;
- SLANG_RETURN_ON_FAIL(m_device->CreateDepthStencilView(resourceImpl->m_resource, nullptr, dsv.writeRef()));
+ {
+ ComPtr<ID3D11DepthStencilView> dsv;
+ SLANG_RETURN_ON_FAIL(m_device->CreateDepthStencilView(
+ resourceImpl->m_resource,
+ nullptr,
+ dsv.writeRef()));
- RefPtr<DepthStencilViewImpl> viewImpl = new DepthStencilViewImpl();
- viewImpl->m_type = ResourceViewImpl::Type::DSV;
- viewImpl->m_dsv = dsv;
- if (resourceImpl->getDesc()->optimalClearValue)
- viewImpl->m_clearValue = resourceImpl->getDesc()->optimalClearValue->depthStencil;
- viewImpl->m_desc = desc;
+ RefPtr<DepthStencilViewImpl> viewImpl = new DepthStencilViewImpl();
+ viewImpl->m_type = ResourceViewImpl::Type::DSV;
+ viewImpl->m_dsv = dsv;
+ if (resourceImpl->getDesc()->optimalClearValue)
+ viewImpl->m_clearValue = resourceImpl->getDesc()->optimalClearValue->depthStencil;
+ viewImpl->m_desc = desc;
- returnComPtr(outView, viewImpl);
- return SLANG_OK;
- }
- break;
+ returnComPtr(outView, viewImpl);
+ return SLANG_OK;
+ }
+ break;
case IResourceView::Type::UnorderedAccess:
- {
- ComPtr<ID3D11UnorderedAccessView> uav;
- SLANG_RETURN_ON_FAIL(m_device->CreateUnorderedAccessView(resourceImpl->m_resource, nullptr, uav.writeRef()));
+ {
+ ComPtr<ID3D11UnorderedAccessView> uav;
+ SLANG_RETURN_ON_FAIL(m_device->CreateUnorderedAccessView(
+ resourceImpl->m_resource,
+ nullptr,
+ uav.writeRef()));
- RefPtr<UnorderedAccessViewImpl> viewImpl = new UnorderedAccessViewImpl();
- viewImpl->m_type = ResourceViewImpl::Type::UAV;
- viewImpl->m_uav = uav;
- viewImpl->m_desc = desc;
+ RefPtr<UnorderedAccessViewImpl> viewImpl = new UnorderedAccessViewImpl();
+ viewImpl->m_type = ResourceViewImpl::Type::UAV;
+ viewImpl->m_uav = uav;
+ viewImpl->m_desc = desc;
- returnComPtr(outView, viewImpl);
- return SLANG_OK;
- }
- break;
+ returnComPtr(outView, viewImpl);
+ return SLANG_OK;
+ }
+ break;
case IResourceView::Type::ShaderResource:
- {
- D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
- initSrvDesc(resourceImpl->getType(), *resourceImpl->getDesc(), D3DUtil::getMapFormat(desc.format), srvDesc);
-
- ComPtr<ID3D11ShaderResourceView> srv;
- SLANG_RETURN_ON_FAIL(m_device->CreateShaderResourceView(resourceImpl->m_resource, &srvDesc, srv.writeRef()));
-
- RefPtr<ShaderResourceViewImpl> viewImpl = new ShaderResourceViewImpl();
- viewImpl->m_type = ResourceViewImpl::Type::SRV;
- viewImpl->m_srv = srv;
- viewImpl->m_desc = desc;
-
- returnComPtr(outView, viewImpl);
- return SLANG_OK;
- }
- break;
+ {
+ D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
+ initSrvDesc(
+ resourceImpl->getType(),
+ *resourceImpl->getDesc(),
+ D3DUtil::getMapFormat(desc.format),
+ srvDesc);
+
+ ComPtr<ID3D11ShaderResourceView> srv;
+ SLANG_RETURN_ON_FAIL(m_device->CreateShaderResourceView(
+ resourceImpl->m_resource,
+ &srvDesc,
+ srv.writeRef()));
+
+ RefPtr<ShaderResourceViewImpl> viewImpl = new ShaderResourceViewImpl();
+ viewImpl->m_type = ResourceViewImpl::Type::SRV;
+ viewImpl->m_srv = srv;
+ viewImpl->m_desc = desc;
+
+ returnComPtr(outView, viewImpl);
+ return SLANG_OK;
+ }
+ break;
}
}
@@ -864,93 +920,104 @@ Result DeviceImpl::createBufferView(
switch (desc.type)
{
- default:
- return SLANG_FAIL;
+ default: return SLANG_FAIL;
case IResourceView::Type::UnorderedAccess:
- {
- D3D11_UNORDERED_ACCESS_VIEW_DESC uavDesc = {};
- uavDesc.ViewDimension = D3D11_UAV_DIMENSION_BUFFER;
- uavDesc.Format = D3DUtil::getMapFormat(desc.format);
- uavDesc.Buffer.FirstElement = 0;
-
- if (resourceDesc.elementSize)
{
- uavDesc.Buffer.NumElements = UINT(resourceDesc.sizeInBytes / resourceDesc.elementSize);
- }
- else if (desc.format == Format::Unknown)
- {
- uavDesc.Buffer.Flags |= D3D11_BUFFER_UAV_FLAG_RAW;
- uavDesc.Format = DXGI_FORMAT_R32_TYPELESS;
- uavDesc.Buffer.NumElements = UINT(resourceDesc.sizeInBytes / 4);
- }
- else
- {
- FormatInfo sizeInfo;
- gfxGetFormatInfo(desc.format, &sizeInfo);
- uavDesc.Buffer.NumElements = UINT(resourceDesc.sizeInBytes / (sizeInfo.blockSizeInBytes / sizeInfo.pixelsPerBlock));
- }
-
- ComPtr<ID3D11UnorderedAccessView> uav;
- SLANG_RETURN_ON_FAIL(m_device->CreateUnorderedAccessView(resourceImpl->m_buffer, &uavDesc, uav.writeRef()));
+ D3D11_UNORDERED_ACCESS_VIEW_DESC uavDesc = {};
+ uavDesc.ViewDimension = D3D11_UAV_DIMENSION_BUFFER;
+ uavDesc.Format = D3DUtil::getMapFormat(desc.format);
+ uavDesc.Buffer.FirstElement = 0;
- RefPtr<UnorderedAccessViewImpl> viewImpl = new UnorderedAccessViewImpl();
- viewImpl->m_type = ResourceViewImpl::Type::UAV;
- viewImpl->m_uav = uav;
- viewImpl->m_desc = desc;
+ if (resourceDesc.elementSize)
+ {
+ uavDesc.Buffer.NumElements =
+ UINT(resourceDesc.sizeInBytes / resourceDesc.elementSize);
+ }
+ else if (desc.format == Format::Unknown)
+ {
+ uavDesc.Buffer.Flags |= D3D11_BUFFER_UAV_FLAG_RAW;
+ uavDesc.Format = DXGI_FORMAT_R32_TYPELESS;
+ uavDesc.Buffer.NumElements = UINT(resourceDesc.sizeInBytes / 4);
+ }
+ else
+ {
+ FormatInfo sizeInfo;
+ gfxGetFormatInfo(desc.format, &sizeInfo);
+ uavDesc.Buffer.NumElements = UINT(
+ resourceDesc.sizeInBytes /
+ (sizeInfo.blockSizeInBytes / sizeInfo.pixelsPerBlock));
+ }
- returnComPtr(outView, viewImpl);
- return SLANG_OK;
- }
- break;
+ ComPtr<ID3D11UnorderedAccessView> uav;
+ SLANG_RETURN_ON_FAIL(m_device->CreateUnorderedAccessView(
+ resourceImpl->m_buffer,
+ &uavDesc,
+ uav.writeRef()));
- case IResourceView::Type::ShaderResource:
- {
- D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
- srvDesc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER;
- srvDesc.Format = D3DUtil::getMapFormat(desc.format);
- srvDesc.Buffer.FirstElement = 0;
+ RefPtr<UnorderedAccessViewImpl> viewImpl = new UnorderedAccessViewImpl();
+ viewImpl->m_type = ResourceViewImpl::Type::UAV;
+ viewImpl->m_uav = uav;
+ viewImpl->m_desc = desc;
- if (resourceDesc.elementSize)
- {
- srvDesc.Buffer.NumElements = UINT(resourceDesc.sizeInBytes / resourceDesc.elementSize);
+ returnComPtr(outView, viewImpl);
+ return SLANG_OK;
}
- else if (desc.format == Format::Unknown)
- {
- // We need to switch to a different member of the `union`,
- // so that we can set the `BufferEx.Flags` member.
- //
- srvDesc.ViewDimension = D3D11_SRV_DIMENSION_BUFFEREX;
-
- // Because we've switched, we need to re-set the `FirstElement`
- // field to be valid, since we can't count on all compilers
- // to respect that `Buffer.FirstElement` and `BufferEx.FirstElement`
- // alias in memory.
- //
- srvDesc.BufferEx.FirstElement = 0;
+ break;
- srvDesc.BufferEx.Flags = D3D11_BUFFEREX_SRV_FLAG_RAW;
- srvDesc.Format = DXGI_FORMAT_R32_TYPELESS;
- srvDesc.BufferEx.NumElements = UINT(resourceDesc.sizeInBytes / 4);
- }
- else
+ case IResourceView::Type::ShaderResource:
{
- FormatInfo sizeInfo;
- gfxGetFormatInfo(desc.format, &sizeInfo);
- srvDesc.Buffer.NumElements = UINT(resourceDesc.sizeInBytes / (sizeInfo.blockSizeInBytes / sizeInfo.pixelsPerBlock));
- }
+ D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
+ srvDesc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER;
+ srvDesc.Format = D3DUtil::getMapFormat(desc.format);
+ srvDesc.Buffer.FirstElement = 0;
- ComPtr<ID3D11ShaderResourceView> srv;
- SLANG_RETURN_ON_FAIL(m_device->CreateShaderResourceView(resourceImpl->m_buffer, &srvDesc, srv.writeRef()));
+ if (resourceDesc.elementSize)
+ {
+ srvDesc.Buffer.NumElements =
+ UINT(resourceDesc.sizeInBytes / resourceDesc.elementSize);
+ }
+ else if (desc.format == Format::Unknown)
+ {
+ // We need to switch to a different member of the `union`,
+ // so that we can set the `BufferEx.Flags` member.
+ //
+ srvDesc.ViewDimension = D3D11_SRV_DIMENSION_BUFFEREX;
+
+ // Because we've switched, we need to re-set the `FirstElement`
+ // field to be valid, since we can't count on all compilers
+ // to respect that `Buffer.FirstElement` and `BufferEx.FirstElement`
+ // alias in memory.
+ //
+ srvDesc.BufferEx.FirstElement = 0;
+
+ srvDesc.BufferEx.Flags = D3D11_BUFFEREX_SRV_FLAG_RAW;
+ srvDesc.Format = DXGI_FORMAT_R32_TYPELESS;
+ srvDesc.BufferEx.NumElements = UINT(resourceDesc.sizeInBytes / 4);
+ }
+ else
+ {
+ FormatInfo sizeInfo;
+ gfxGetFormatInfo(desc.format, &sizeInfo);
+ srvDesc.Buffer.NumElements = UINT(
+ resourceDesc.sizeInBytes /
+ (sizeInfo.blockSizeInBytes / sizeInfo.pixelsPerBlock));
+ }
- RefPtr<ShaderResourceViewImpl> viewImpl = new ShaderResourceViewImpl();
- viewImpl->m_type = ResourceViewImpl::Type::SRV;
- viewImpl->m_srv = srv;
- viewImpl->m_desc = desc;
- returnComPtr(outView, viewImpl);
- return SLANG_OK;
- }
- break;
+ ComPtr<ID3D11ShaderResourceView> srv;
+ SLANG_RETURN_ON_FAIL(m_device->CreateShaderResourceView(
+ resourceImpl->m_buffer,
+ &srvDesc,
+ srv.writeRef()));
+
+ RefPtr<ShaderResourceViewImpl> viewImpl = new ShaderResourceViewImpl();
+ viewImpl->m_type = ResourceViewImpl::Type::SRV;
+ viewImpl->m_srv = srv;
+ viewImpl->m_desc = desc;
+ returnComPtr(outView, viewImpl);
+ return SLANG_OK;
+ }
+ break;
}
}
@@ -975,8 +1042,9 @@ Result DeviceImpl::createInputLayout(IInputLayout::Desc const& desc, IInputLayou
inputElements[ii].Format = D3DUtil::getMapFormat(inputElementsIn[ii].format);
inputElements[ii].InputSlot = (UINT)vertexStreamIndex;
inputElements[ii].AlignedByteOffset = (UINT)inputElementsIn[ii].offset;
- inputElements[ii].InputSlotClass =
- (vertexStream.slotClass == InputSlotClass::PerInstance) ? D3D11_INPUT_PER_INSTANCE_DATA : D3D11_INPUT_PER_VERTEX_DATA;
+ inputElements[ii].InputSlotClass = (vertexStream.slotClass == InputSlotClass::PerInstance)
+ ? D3D11_INPUT_PER_INSTANCE_DATA
+ : D3D11_INPUT_PER_VERTEX_DATA;
inputElements[ii].InstanceDataStepRate = (UINT)vertexStream.instanceDataStepRate;
if (ii != 0)
@@ -988,23 +1056,16 @@ Result DeviceImpl::createInputLayout(IInputLayout::Desc const& desc, IInputLayou
switch (inputElementsIn[ii].format)
{
case Format::R32G32B32A32_FLOAT:
- case Format::R8G8B8A8_UNORM:
- typeName = "float4";
- break;
- case Format::R32G32B32_FLOAT:
- typeName = "float3";
- break;
- case Format::R32G32_FLOAT:
- typeName = "float2";
- break;
- case Format::R32_FLOAT:
- typeName = "float";
- break;
- default:
- return SLANG_FAIL;
+ case Format::R8G8B8A8_UNORM: typeName = "float4"; break;
+ case Format::R32G32B32_FLOAT: typeName = "float3"; break;
+ case Format::R32G32_FLOAT: typeName = "float2"; break;
+ case Format::R32_FLOAT: typeName = "float"; break;
+ default: return SLANG_FAIL;
}
- hlslCursor += sprintf(hlslCursor, "%s a%d : %s%d",
+ hlslCursor += sprintf(
+ hlslCursor,
+ "%s a%d : %s%d",
typeName,
(int)ii,
inputElementsIn[ii].semanticName,
@@ -1014,10 +1075,15 @@ Result DeviceImpl::createInputLayout(IInputLayout::Desc const& desc, IInputLayou
hlslCursor += sprintf(hlslCursor, "\n) : SV_Position { return 0; }");
ComPtr<ID3DBlob> vertexShaderBlob;
- SLANG_RETURN_ON_FAIL(D3DUtil::compileHLSLShader("inputLayout", hlslBuffer, "main", "vs_5_0", vertexShaderBlob));
+ SLANG_RETURN_ON_FAIL(
+ D3DUtil::compileHLSLShader("inputLayout", hlslBuffer, "main", "vs_5_0", vertexShaderBlob));
ComPtr<ID3D11InputLayout> inputLayout;
- SLANG_RETURN_ON_FAIL(m_device->CreateInputLayout(&inputElements[0], (UINT)inputElementCount, vertexShaderBlob->GetBufferPointer(), vertexShaderBlob->GetBufferSize(),
+ SLANG_RETURN_ON_FAIL(m_device->CreateInputLayout(
+ &inputElements[0],
+ (UINT)inputElementCount,
+ vertexShaderBlob->GetBufferPointer(),
+ vertexShaderBlob->GetBufferSize(),
inputLayout.writeRef()));
RefPtr<InputLayoutImpl> impl = new InputLayoutImpl;
@@ -1051,17 +1117,10 @@ void* DeviceImpl::map(IBufferResource* bufferIn, MapFlavor flavor)
switch (flavor)
{
- case MapFlavor::WriteDiscard:
- mapType = D3D11_MAP_WRITE_DISCARD;
- break;
- case MapFlavor::HostWrite:
- mapType = D3D11_MAP_WRITE_NO_OVERWRITE;
- break;
- case MapFlavor::HostRead:
- mapType = D3D11_MAP_READ;
- break;
- default:
- return nullptr;
+ case MapFlavor::WriteDiscard: mapType = D3D11_MAP_WRITE_DISCARD; break;
+ case MapFlavor::HostWrite: mapType = D3D11_MAP_WRITE_NO_OVERWRITE; break;
+ case MapFlavor::HostRead: mapType = D3D11_MAP_READ; break;
+ default: return nullptr;
}
bufferResource->m_mapFlavor = flavor;
@@ -1086,7 +1145,6 @@ void* DeviceImpl::map(IBufferResource* bufferIn, MapFlavor flavor)
// Okay copy the data over
m_immediateContext->CopyResource(buffer, bufferResource->m_buffer);
-
}
// We update our constant buffer per-frame, just for the purposes
@@ -1124,7 +1182,10 @@ void DeviceImpl::unmap(IBufferResource* bufferIn, size_t offsetWritten, size_t s
return;
}
}
- m_immediateContext->Unmap(bufferResource->m_mapFlavor == MapFlavor::HostRead ? bufferResource->m_staging : bufferResource->m_buffer, 0);
+ m_immediateContext->Unmap(
+ bufferResource->m_mapFlavor == MapFlavor::HostRead ? bufferResource->m_staging
+ : bufferResource->m_buffer,
+ 0);
}
#if 0
@@ -1148,7 +1209,8 @@ void DeviceImpl::setVertexBuffers(
{
static const int kMaxVertexBuffers = 16;
assert(slotCount <= kMaxVertexBuffers);
- assert(m_currentPipelineState); // The pipeline state should be created before setting vertex buffers.
+ assert(m_currentPipelineState); // The pipeline state should be created before setting vertex
+ // buffers.
UINT vertexStrides[kMaxVertexBuffers];
UINT vertexOffsets[kMaxVertexBuffers];
@@ -1164,13 +1226,21 @@ void DeviceImpl::setVertexBuffers(
dxBuffers[ii] = buffers[ii]->m_buffer;
}
- m_immediateContext->IASetVertexBuffers((UINT)startSlot, (UINT)slotCount, dxBuffers, &vertexStrides[0], &vertexOffsets[0]);
+ m_immediateContext->IASetVertexBuffers(
+ (UINT)startSlot,
+ (UINT)slotCount,
+ dxBuffers,
+ &vertexStrides[0],
+ &vertexOffsets[0]);
}
void DeviceImpl::setIndexBuffer(IBufferResource* buffer, Format indexFormat, Offset offset)
{
DXGI_FORMAT dxFormat = D3DUtil::getMapFormat(indexFormat);
- m_immediateContext->IASetIndexBuffer(((BufferResourceImpl*)buffer)->m_buffer, dxFormat, UINT(offset));
+ m_immediateContext->IASetIndexBuffer(
+ ((BufferResourceImpl*)buffer)->m_buffer,
+ dxFormat,
+ UINT(offset));
}
void DeviceImpl::setViewports(GfxCount count, Viewport const* viewports)
@@ -1222,66 +1292,69 @@ void DeviceImpl::setPipelineState(IPipelineState* state)
switch (pipelineType)
{
- default:
- break;
+ default: break;
case PipelineType::Graphics:
- {
- auto stateImpl = (GraphicsPipelineStateImpl*)state;
- auto programImpl = static_cast<ShaderProgramImpl*>(stateImpl->m_program.Ptr());
+ {
+ auto stateImpl = (GraphicsPipelineStateImpl*)state;
+ auto programImpl = static_cast<ShaderProgramImpl*>(stateImpl->m_program.Ptr());
- // TODO: We could conceivably do some lightweight state
- // differencing here (e.g., check if `programImpl` is the
- // same as the program that is currently bound).
- //
- // It isn't clear how much that would pay off given that
- // the D3D11 runtime seems to do its own state diffing.
+ // TODO: We could conceivably do some lightweight state
+ // differencing here (e.g., check if `programImpl` is the
+ // same as the program that is currently bound).
+ //
+ // It isn't clear how much that would pay off given that
+ // the D3D11 runtime seems to do its own state diffing.
- // IA
+ // IA
- m_immediateContext->IASetInputLayout(stateImpl->m_inputLayout->m_layout);
+ m_immediateContext->IASetInputLayout(stateImpl->m_inputLayout->m_layout);
- // VS
+ // VS
- // TODO(tfoley): Why the conditional here? If somebody is trying to disable the VS or PS, shouldn't we respect that?
- if (programImpl->m_vertexShader)
- m_immediateContext->VSSetShader(programImpl->m_vertexShader, nullptr, 0);
+ // TODO(tfoley): Why the conditional here? If somebody is trying to disable the VS or
+ // PS, shouldn't we respect that?
+ if (programImpl->m_vertexShader)
+ m_immediateContext->VSSetShader(programImpl->m_vertexShader, nullptr, 0);
- // HS
+ // HS
- // DS
+ // DS
- // GS
+ // GS
- // RS
+ // RS
- m_immediateContext->RSSetState(stateImpl->m_rasterizerState);
+ m_immediateContext->RSSetState(stateImpl->m_rasterizerState);
- // PS
- if (programImpl->m_pixelShader)
- m_immediateContext->PSSetShader(programImpl->m_pixelShader, nullptr, 0);
+ // PS
+ if (programImpl->m_pixelShader)
+ m_immediateContext->PSSetShader(programImpl->m_pixelShader, nullptr, 0);
- // OM
+ // OM
- m_immediateContext->OMSetBlendState(stateImpl->m_blendState, stateImpl->m_blendColor, stateImpl->m_sampleMask);
+ m_immediateContext->OMSetBlendState(
+ stateImpl->m_blendState,
+ stateImpl->m_blendColor,
+ stateImpl->m_sampleMask);
- m_currentPipelineState = stateImpl;
+ m_currentPipelineState = stateImpl;
- m_depthStencilStateDirty = true;
- }
- break;
+ m_depthStencilStateDirty = true;
+ }
+ break;
case PipelineType::Compute:
- {
- auto stateImpl = (ComputePipelineStateImpl*)state;
- auto programImpl = static_cast<ShaderProgramImpl*>(stateImpl->m_program.Ptr());
+ {
+ auto stateImpl = (ComputePipelineStateImpl*)state;
+ auto programImpl = static_cast<ShaderProgramImpl*>(stateImpl->m_program.Ptr());
- // CS
+ // CS
- m_immediateContext->CSSetShader(programImpl->m_computeShader, nullptr, 0);
- m_currentPipelineState = stateImpl;
- }
- break;
+ m_immediateContext->CSSetShader(programImpl->m_computeShader, nullptr, 0);
+ m_currentPipelineState = stateImpl;
+ }
+ break;
}
/// ...
@@ -1306,11 +1379,8 @@ void DeviceImpl::drawInstanced(
GfxIndex startInstanceLocation)
{
_flushGraphicsState();
- m_immediateContext->DrawInstanced(
- vertexCount,
- instanceCount,
- startVertex,
- startInstanceLocation);
+ m_immediateContext
+ ->DrawInstanced(vertexCount, instanceCount, startVertex, startInstanceLocation);
}
void DeviceImpl::drawIndexedInstanced(
@@ -1330,7 +1400,9 @@ void DeviceImpl::drawIndexedInstanced(
}
Result DeviceImpl::createProgram(
- const IShaderProgram::Desc& desc, IShaderProgram** outProgram, ISlangBlob** outDiagnosticBlob)
+ const IShaderProgram::Desc& desc,
+ IShaderProgram** outProgram,
+ ISlangBlob** outDiagnosticBlob)
{
SLANG_ASSERT(desc.slangGlobalScope);
@@ -1363,8 +1435,12 @@ Result DeviceImpl::createProgram(
ComPtr<ISlangBlob> kernelCode;
ComPtr<ISlangBlob> diagnostics;
- auto compileResult = getEntryPointCodeFromShaderCache(slangGlobalScope,
- (SlangInt)i, 0, kernelCode.writeRef(), diagnostics.writeRef());
+ auto compileResult = getEntryPointCodeFromShaderCache(
+ slangGlobalScope,
+ (SlangInt)i,
+ 0,
+ kernelCode.writeRef(),
+ diagnostics.writeRef());
if (diagnostics)
{
@@ -1406,8 +1482,7 @@ Result DeviceImpl::createProgram(
nullptr,
shaderProgram->m_pixelShader.writeRef()));
break;
- default:
- SLANG_ASSERT(!"pipeline stage not implemented");
+ default: SLANG_ASSERT(!"pipeline stage not implemented");
}
}
returnComPtr(outProgram, shaderProgram);
@@ -1420,8 +1495,8 @@ Result DeviceImpl::createShaderObjectLayout(
ShaderObjectLayoutBase** outLayout)
{
RefPtr<ShaderObjectLayoutImpl> layout;
- SLANG_RETURN_ON_FAIL(ShaderObjectLayoutImpl::createForElementType(
- this, session, typeLayout, layout.writeRef()));
+ SLANG_RETURN_ON_FAIL(
+ ShaderObjectLayoutImpl::createForElementType(this, session, typeLayout, layout.writeRef()));
returnRefPtrMove(outLayout, layout);
return SLANG_OK;
}
@@ -1429,8 +1504,10 @@ Result DeviceImpl::createShaderObjectLayout(
Result DeviceImpl::createShaderObject(ShaderObjectLayoutBase* layout, IShaderObject** outObject)
{
RefPtr<ShaderObjectImpl> shaderObject;
- SLANG_RETURN_ON_FAIL(ShaderObjectImpl::create(this,
- static_cast<ShaderObjectLayoutImpl*>(layout), shaderObject.writeRef()));
+ SLANG_RETURN_ON_FAIL(ShaderObjectImpl::create(
+ this,
+ static_cast<ShaderObjectLayoutImpl*>(layout),
+ shaderObject.writeRef()));
returnComPtr(outObject, shaderObject);
return SLANG_OK;
}
@@ -1454,9 +1531,12 @@ Result DeviceImpl::createRootShaderObject(IShaderProgram* program, ShaderObjectB
RefPtr<RootShaderObjectImpl> shaderObject;
RefPtr<RootShaderObjectLayoutImpl> rootLayout;
SLANG_RETURN_ON_FAIL(RootShaderObjectLayoutImpl::create(
- this, programImpl->slangGlobalScope, programImpl->slangGlobalScope->getLayout(), rootLayout.writeRef()));
- SLANG_RETURN_ON_FAIL(RootShaderObjectImpl::create(
- this, rootLayout.Ptr(), shaderObject.writeRef()));
+ this,
+ programImpl->slangGlobalScope,
+ programImpl->slangGlobalScope->getLayout(),
+ rootLayout.writeRef()));
+ SLANG_RETURN_ON_FAIL(
+ RootShaderObjectImpl::create(this, rootLayout.Ptr(), shaderObject.writeRef()));
returnRefPtrMove(outObject, shaderObject);
return SLANG_OK;
}
@@ -1466,9 +1546,11 @@ void DeviceImpl::bindRootShaderObject(IShaderObject* shaderObject)
RootShaderObjectImpl* rootShaderObjectImpl = static_cast<RootShaderObjectImpl*>(shaderObject);
RefPtr<PipelineStateBase> specializedPipeline;
// TODO: Do something less crappy than just asserting on failure here
- SLANG_ASSERT_VOID_ON_FAIL(maybeSpecializePipeline(m_currentPipelineState, rootShaderObjectImpl, specializedPipeline));
+ SLANG_ASSERT_VOID_ON_FAIL(
+ maybeSpecializePipeline(m_currentPipelineState, rootShaderObjectImpl, specializedPipeline));
maybeSpecializePipeline(m_currentPipelineState, rootShaderObjectImpl, specializedPipeline);
- PipelineStateImpl* specializedPipelineImpl = static_cast<PipelineStateImpl*>(specializedPipeline.Ptr());
+ PipelineStateImpl* specializedPipelineImpl =
+ static_cast<PipelineStateImpl*>(specializedPipeline.Ptr());
setPipelineState(specializedPipelineImpl);
// In order to bind the root object we must compute its specialized layout.
@@ -1478,7 +1560,8 @@ void DeviceImpl::bindRootShaderObject(IShaderObject* shaderObject)
//
RefPtr<ShaderObjectLayoutImpl> specializedRootLayout;
rootShaderObjectImpl->_getSpecializedLayout(specializedRootLayout.writeRef());
- RootShaderObjectLayoutImpl* specializedRootLayoutImpl = static_cast<RootShaderObjectLayoutImpl*>(specializedRootLayout.Ptr());
+ RootShaderObjectLayoutImpl* specializedRootLayoutImpl =
+ static_cast<RootShaderObjectLayoutImpl*>(specializedRootLayout.Ptr());
// Depending on whether we are binding a compute or a graphics/rasterization
// pipeline, we will need to bind any SRVs/UAVs/CBs/samplers using different
@@ -1488,76 +1571,79 @@ void DeviceImpl::bindRootShaderObject(IShaderObject* shaderObject)
switch (m_currentPipelineState->desc.type)
{
case PipelineType::Compute:
- {
- ComputeBindingContext context(this, m_immediateContext);
- rootShaderObjectImpl->bindAsRoot(&context, specializedRootLayoutImpl);
-
- // Because D3D11 requires all UAVs to be set at once, we did *not* issue
- // actual binding calls during the `bindAsRoot` step, and instead we
- // batch them up and set them here.
- //
- m_immediateContext->CSSetUnorderedAccessViews(0, context.uavCount, context.uavs, nullptr);
- }
- break;
+ {
+ ComputeBindingContext context(this, m_immediateContext);
+ rootShaderObjectImpl->bindAsRoot(&context, specializedRootLayoutImpl);
+
+ // Because D3D11 requires all UAVs to be set at once, we did *not* issue
+ // actual binding calls during the `bindAsRoot` step, and instead we
+ // batch them up and set them here.
+ //
+ m_immediateContext
+ ->CSSetUnorderedAccessViews(0, context.uavCount, context.uavs, nullptr);
+ }
+ break;
default:
- {
- GraphicsBindingContext context(this, m_immediateContext);
- rootShaderObjectImpl->bindAsRoot(&context, specializedRootLayoutImpl);
-
- // Similar to the compute case above, the rasteirzation case needs to
- // set the UAVs after the call to `bindAsRoot()` completes, but we
- // also have a few extra wrinkles here that are specific to the D3D 11.0
- // rasterization pipeline.
- //
- // In D3D 11.0, the RTV and UAV binding slots alias, so that a shader
- // that binds an RTV for `SV_Target0` cannot also bind a UAV for `u0`.
- // The Slang layout algorithm already accounts for this rule, and assigns
- // all UAVs to slots taht won't alias the RTVs it knows about.
- //
- // In order to account for the aliasing, we need to consider how many
- // RTVs are bound as part of the active framebuffer, and then adjust
- // the UAVs that we bind accordingly.
- //
- auto rtvCount = (UINT)m_currentFramebuffer->renderTargetViews.getCount();
- //
- // The `context` we are using will have computed the number of UAV registers
- // that might need to be bound, as a range from 0 to `context.uavCount`.
- // However we need to skip over the first `rtvCount` of those, so the
- // actual number of UAVs we wnat to bind is smaller:
- //
- // Note: As a result we expect that either there were no UAVs bound,
- // *or* the number of UAV slots bound is higher than the number of
- // RTVs so that there is something left to actually bind.
- //
- SLANG_ASSERT((context.uavCount == 0) || (context.uavCount >= rtvCount));
- auto bindableUAVCount = context.uavCount - rtvCount;
- //
- // Similarly, the actual UAVs we intend to bind will come after the first
- // `rtvCount` in the array.
- //
- auto bindableUAVs = context.uavs + rtvCount;
-
- // Once the offsetting is accounted for, we set all of the RTVs, DSV,
- // and UAVs with one call.
- //
- // TODO: We may want to use the capability for `OMSetRenderTargetsAnd...`
- // to only set the UAVs and leave the RTVs/UAVs alone, so that we don't
- // needlessly re-bind RTVs during a pass.
- //
- m_immediateContext->OMSetRenderTargetsAndUnorderedAccessViews(
- rtvCount,
- m_currentFramebuffer->d3dRenderTargetViews.getArrayView().getBuffer(),
- m_currentFramebuffer->d3dDepthStencilView,
- rtvCount,
- bindableUAVCount,
- bindableUAVs,
- nullptr);
- }
- break;
+ {
+ GraphicsBindingContext context(this, m_immediateContext);
+ rootShaderObjectImpl->bindAsRoot(&context, specializedRootLayoutImpl);
+
+ // Similar to the compute case above, the rasteirzation case needs to
+ // set the UAVs after the call to `bindAsRoot()` completes, but we
+ // also have a few extra wrinkles here that are specific to the D3D 11.0
+ // rasterization pipeline.
+ //
+ // In D3D 11.0, the RTV and UAV binding slots alias, so that a shader
+ // that binds an RTV for `SV_Target0` cannot also bind a UAV for `u0`.
+ // The Slang layout algorithm already accounts for this rule, and assigns
+ // all UAVs to slots taht won't alias the RTVs it knows about.
+ //
+ // In order to account for the aliasing, we need to consider how many
+ // RTVs are bound as part of the active framebuffer, and then adjust
+ // the UAVs that we bind accordingly.
+ //
+ auto rtvCount = (UINT)m_currentFramebuffer->renderTargetViews.getCount();
+ //
+ // The `context` we are using will have computed the number of UAV registers
+ // that might need to be bound, as a range from 0 to `context.uavCount`.
+ // However we need to skip over the first `rtvCount` of those, so the
+ // actual number of UAVs we wnat to bind is smaller:
+ //
+ // Note: As a result we expect that either there were no UAVs bound,
+ // *or* the number of UAV slots bound is higher than the number of
+ // RTVs so that there is something left to actually bind.
+ //
+ SLANG_ASSERT((context.uavCount == 0) || (context.uavCount >= rtvCount));
+ auto bindableUAVCount = context.uavCount - rtvCount;
+ //
+ // Similarly, the actual UAVs we intend to bind will come after the first
+ // `rtvCount` in the array.
+ //
+ auto bindableUAVs = context.uavs + rtvCount;
+
+ // Once the offsetting is accounted for, we set all of the RTVs, DSV,
+ // and UAVs with one call.
+ //
+ // TODO: We may want to use the capability for `OMSetRenderTargetsAnd...`
+ // to only set the UAVs and leave the RTVs/UAVs alone, so that we don't
+ // needlessly re-bind RTVs during a pass.
+ //
+ m_immediateContext->OMSetRenderTargetsAndUnorderedAccessViews(
+ rtvCount,
+ m_currentFramebuffer->d3dRenderTargetViews.getArrayView().getBuffer(),
+ m_currentFramebuffer->d3dDepthStencilView,
+ rtvCount,
+ bindableUAVCount,
+ bindableUAVs,
+ nullptr);
+ }
+ break;
}
}
-Result DeviceImpl::createGraphicsPipelineState(const GraphicsPipelineStateDesc& inDesc, IPipelineState** outState)
+Result DeviceImpl::createGraphicsPipelineState(
+ const GraphicsPipelineStateDesc& inDesc,
+ IPipelineState** outState)
{
GraphicsPipelineStateDesc desc = inDesc;
@@ -1567,25 +1653,25 @@ Result DeviceImpl::createGraphicsPipelineState(const GraphicsPipelineStateDesc&
{
D3D11_DEPTH_STENCIL_DESC dsDesc;
dsDesc.DepthEnable = desc.depthStencil.depthTestEnable;
- dsDesc.DepthWriteMask = desc.depthStencil.depthWriteEnable ? D3D11_DEPTH_WRITE_MASK_ALL : D3D11_DEPTH_WRITE_MASK_ZERO;
+ dsDesc.DepthWriteMask = desc.depthStencil.depthWriteEnable ? D3D11_DEPTH_WRITE_MASK_ALL
+ : D3D11_DEPTH_WRITE_MASK_ZERO;
dsDesc.DepthFunc = translateComparisonFunc(desc.depthStencil.depthFunc);
dsDesc.StencilEnable = desc.depthStencil.stencilEnable;
dsDesc.StencilReadMask = desc.depthStencil.stencilReadMask;
dsDesc.StencilWriteMask = desc.depthStencil.stencilWriteMask;
-#define FACE(DST, SRC) \
- dsDesc.DST.StencilFailOp = translateStencilOp( desc.depthStencil.SRC.stencilFailOp); \
- dsDesc.DST.StencilDepthFailOp = translateStencilOp( desc.depthStencil.SRC.stencilDepthFailOp); \
- dsDesc.DST.StencilPassOp = translateStencilOp( desc.depthStencil.SRC.stencilPassOp); \
- dsDesc.DST.StencilFunc = translateComparisonFunc(desc.depthStencil.SRC.stencilFunc); \
+#define FACE(DST, SRC) \
+ dsDesc.DST.StencilFailOp = translateStencilOp(desc.depthStencil.SRC.stencilFailOp); \
+ dsDesc.DST.StencilDepthFailOp = translateStencilOp(desc.depthStencil.SRC.stencilDepthFailOp); \
+ dsDesc.DST.StencilPassOp = translateStencilOp(desc.depthStencil.SRC.stencilPassOp); \
+ dsDesc.DST.StencilFunc = translateComparisonFunc(desc.depthStencil.SRC.stencilFunc); \
/* end */
FACE(FrontFace, frontFace);
FACE(BackFace, backFace);
- SLANG_RETURN_ON_FAIL(m_device->CreateDepthStencilState(
- &dsDesc,
- depthStencilState.writeRef()));
+ SLANG_RETURN_ON_FAIL(
+ m_device->CreateDepthStencilState(&dsDesc, depthStencilState.writeRef()));
}
ComPtr<ID3D11RasterizerState> rasterizerState;
@@ -1602,10 +1688,7 @@ Result DeviceImpl::createGraphicsPipelineState(const GraphicsPipelineStateDesc&
rsDesc.MultisampleEnable = desc.rasterizer.multisampleEnable;
rsDesc.AntialiasedLineEnable = desc.rasterizer.antialiasedLineEnable;
- SLANG_RETURN_ON_FAIL(m_device->CreateRasterizerState(
- &rsDesc,
- rasterizerState.writeRef()));
-
+ SLANG_RETURN_ON_FAIL(m_device->CreateRasterizerState(&rsDesc, rasterizerState.writeRef()));
}
ComPtr<ID3D11BlendState> blendState;
@@ -1616,7 +1699,8 @@ Result DeviceImpl::createGraphicsPipelineState(const GraphicsPipelineStateDesc&
TargetBlendDesc defaultTargetBlendDesc;
static const UInt kMaxTargets = D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT;
- if (srcDesc.targetCount > kMaxTargets) return SLANG_FAIL;
+ if (srcDesc.targetCount > kMaxTargets)
+ return SLANG_FAIL;
for (GfxIndex ii = 0; ii < kMaxTargets; ++ii)
{
@@ -1652,21 +1736,24 @@ Result DeviceImpl::createGraphicsPipelineState(const GraphicsPipelineStateDesc&
dstTargetBlendDesc.BlendEnable = true;
dstTargetBlendDesc.BlendOp = translateBlendOp(srcTargetBlendDesc.color.op);
dstTargetBlendDesc.BlendOpAlpha = translateBlendOp(srcTargetBlendDesc.alpha.op);
- dstTargetBlendDesc.SrcBlend = translateBlendFactor(srcTargetBlendDesc.color.srcFactor);
- dstTargetBlendDesc.SrcBlendAlpha = translateBlendFactor(srcTargetBlendDesc.alpha.srcFactor);
- dstTargetBlendDesc.DestBlend = translateBlendFactor(srcTargetBlendDesc.color.dstFactor);
- dstTargetBlendDesc.DestBlendAlpha = translateBlendFactor(srcTargetBlendDesc.alpha.dstFactor);
+ dstTargetBlendDesc.SrcBlend =
+ translateBlendFactor(srcTargetBlendDesc.color.srcFactor);
+ dstTargetBlendDesc.SrcBlendAlpha =
+ translateBlendFactor(srcTargetBlendDesc.alpha.srcFactor);
+ dstTargetBlendDesc.DestBlend =
+ translateBlendFactor(srcTargetBlendDesc.color.dstFactor);
+ dstTargetBlendDesc.DestBlendAlpha =
+ translateBlendFactor(srcTargetBlendDesc.alpha.dstFactor);
}
- dstTargetBlendDesc.RenderTargetWriteMask = translateRenderTargetWriteMask(srcTargetBlendDesc.writeMask);
+ dstTargetBlendDesc.RenderTargetWriteMask =
+ translateRenderTargetWriteMask(srcTargetBlendDesc.writeMask);
}
dstDesc.IndependentBlendEnable = srcDesc.targetCount > 1;
dstDesc.AlphaToCoverageEnable = srcDesc.alphaToCoverageEnable;
- SLANG_RETURN_ON_FAIL(m_device->CreateBlendState(
- &dstDesc,
- blendState.writeRef()));
+ SLANG_RETURN_ON_FAIL(m_device->CreateBlendState(&dstDesc, blendState.writeRef()));
}
RefPtr<GraphicsPipelineStateImpl> state = new GraphicsPipelineStateImpl();
@@ -1675,7 +1762,7 @@ Result DeviceImpl::createGraphicsPipelineState(const GraphicsPipelineStateDesc&
state->m_blendState = blendState;
state->m_inputLayout = static_cast<InputLayoutImpl*>(desc.inputLayout);
state->m_rtvCount = (UINT) static_cast<FramebufferLayoutImpl*>(desc.framebufferLayout)
- ->m_renderTargets.getCount();
+ ->m_renderTargets.getCount();
state->m_blendColor[0] = 0;
state->m_blendColor[1] = 0;
state->m_blendColor[2] = 0;
@@ -1686,7 +1773,9 @@ Result DeviceImpl::createGraphicsPipelineState(const GraphicsPipelineStateDesc&
return SLANG_OK;
}
-Result DeviceImpl::createComputePipelineState(const ComputePipelineStateDesc& inDesc, IPipelineState** outState)
+Result DeviceImpl::createComputePipelineState(
+ const ComputePipelineStateDesc& inDesc,
+ IPipelineState** outState)
{
ComputePipelineStateDesc desc = inDesc;
@@ -1710,7 +1799,14 @@ void DeviceImpl::copyBuffer(
srcBox.right = (UINT)(srcOffset + size);
srcBox.bottom = srcBox.back = 1;
m_immediateContext->CopySubresourceRegion(
- dstImpl->m_buffer, 0, (UINT)dstOffset, 0, 0, srcImpl->m_buffer, 0, &srcBox);
+ dstImpl->m_buffer,
+ 0,
+ (UINT)dstOffset,
+ 0,
+ 0,
+ srcImpl->m_buffer,
+ 0,
+ &srcBox);
}
void DeviceImpl::dispatchCompute(int x, int y, int z)
@@ -1725,7 +1821,8 @@ void DeviceImpl::_flushGraphicsState()
m_depthStencilStateDirty = false;
auto pipelineState = static_cast<GraphicsPipelineStateImpl*>(m_currentPipelineState.Ptr());
m_immediateContext->OMSetDepthStencilState(
- pipelineState->m_depthStencilState, m_stencilRef);
+ pipelineState->m_depthStencilState,
+ m_stencilRef);
}
}
diff --git a/tools/gfx/d3d11/d3d11-device.h b/tools/gfx/d3d11/d3d11-device.h
index 42fffa3c9..0f79e82a5 100644
--- a/tools/gfx/d3d11/d3d11-device.h
+++ b/tools/gfx/d3d11/d3d11-device.h
@@ -14,18 +14,20 @@ namespace d3d11
class DeviceImpl : public ImmediateRendererBase
{
public:
-
~DeviceImpl() {}
// Renderer implementation
virtual SLANG_NO_THROW Result SLANG_MCALL initialize(const Desc& desc) override;
virtual void clearFrame(uint32_t colorBufferMask, bool clearDepth, bool clearStencil) 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 createFramebufferLayout(
- const IFramebufferLayout::Desc& desc, IFramebufferLayout** outLayout) override;
+ const IFramebufferLayout::Desc& desc,
+ IFramebufferLayout** outLayout) override;
virtual SLANG_NO_THROW Result SLANG_MCALL
- createFramebuffer(const IFramebuffer::Desc& desc, IFramebuffer** outFramebuffer) override;
+ createFramebuffer(const IFramebuffer::Desc& desc, IFramebuffer** outFramebuffer) override;
virtual void setFramebuffer(IFramebuffer* frameBuffer) override;
virtual void setStencilReference(uint32_t referenceValue) override;
@@ -38,7 +40,7 @@ public:
const void* initData,
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,
@@ -51,12 +53,11 @@ public:
IResourceView::Desc const& desc,
IResourceView** outView) override;
- virtual SLANG_NO_THROW Result SLANG_MCALL createInputLayout(
- IInputLayout::Desc const& desc,
- IInputLayout** outLayout) override;
+ virtual SLANG_NO_THROW Result SLANG_MCALL
+ createInputLayout(IInputLayout::Desc const& desc, IInputLayout** outLayout) override;
- virtual SLANG_NO_THROW Result SLANG_MCALL createQueryPool(
- const IQueryPool::Desc& desc, IQueryPool** outPool) override;
+ virtual SLANG_NO_THROW Result SLANG_MCALL
+ createQueryPool(const IQueryPool::Desc& desc, IQueryPool** outPool) override;
virtual Result createShaderObjectLayout(
slang::ISession* session,
@@ -64,7 +65,9 @@ public:
ShaderObjectLayoutBase** outLayout) override;
virtual Result createShaderObject(ShaderObjectLayoutBase* layout, IShaderObject** outObject)
override;
- virtual Result createMutableShaderObject(ShaderObjectLayoutBase* layout, IShaderObject** outObject) override;
+ virtual Result createMutableShaderObject(
+ ShaderObjectLayoutBase* layout,
+ IShaderObject** outObject) override;
virtual Result createRootShaderObject(IShaderProgram* program, ShaderObjectBase** outObject)
override;
virtual void bindRootShaderObject(IShaderObject* shaderObject) override;
@@ -74,9 +77,11 @@ public:
IShaderProgram** outProgram,
ISlangBlob** outDiagnosticBlob) 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 void* map(IBufferResource* buffer, MapFlavor flavor) override;
virtual void unmap(IBufferResource* buffer, size_t offsetWritten, size_t sizeWritten) override;
@@ -87,7 +92,11 @@ public:
size_t srcOffset,
size_t size) override;
virtual SLANG_NO_THROW SlangResult SLANG_MCALL readTextureResource(
- ITextureResource* texture, ResourceState state, ISlangBlob** outBlob, size_t* outRowPitch, size_t* outPixelSize) override;
+ ITextureResource* texture,
+ ResourceState state,
+ ISlangBlob** outBlob,
+ size_t* outRowPitch,
+ size_t* outPixelSize) override;
virtual void setPrimitiveTopology(PrimitiveTopology topology) override;
@@ -96,14 +105,14 @@ public:
GfxCount slotCount,
IBufferResource* const* buffers,
const Offset* offsets) override;
- virtual void setIndexBuffer(
- IBufferResource* buffer, Format indexFormat, Offset offset) override;
+ virtual void setIndexBuffer(IBufferResource* buffer, Format indexFormat, Offset offset)
+ override;
virtual void setViewports(GfxCount count, Viewport const* viewports) override;
virtual void setScissorRects(GfxCount count, ScissorRect const* rects) override;
virtual void setPipelineState(IPipelineState* state) override;
virtual void draw(GfxCount vertexCount, GfxIndex startVertex) override;
- virtual void drawIndexed(
- GfxCount indexCount, GfxIndex startIndex, GfxIndex baseVertex) override;
+ virtual void drawIndexed(GfxCount indexCount, GfxIndex startIndex, GfxIndex baseVertex)
+ override;
virtual void drawInstanced(
GfxCount vertexCount,
GfxCount instanceCount,
@@ -117,10 +126,7 @@ public:
GfxIndex startInstanceLocation) override;
virtual void dispatchCompute(int x, int y, int z) override;
virtual void submitGpuWork() override {}
- virtual void waitForGpu() override
- {
-
- }
+ virtual void waitForGpu() override {}
virtual SLANG_NO_THROW const DeviceInfo& SLANG_MCALL getDeviceInfo() const override
{
return m_info;
@@ -153,7 +159,7 @@ public:
Desc m_desc;
- float m_clearColor[4] = { 0, 0, 0, 0 };
+ float m_clearColor[4] = {0, 0, 0, 0};
bool m_nvapi = false;
};
diff --git a/tools/gfx/d3d11/d3d11-helper-functions.cpp b/tools/gfx/d3d11/d3d11-helper-functions.cpp
index 6774b7d93..76b339880 100644
--- a/tools/gfx/d3d11/d3d11-helper-functions.cpp
+++ b/tools/gfx/d3d11/d3d11-helper-functions.cpp
@@ -10,345 +10,346 @@ using namespace Slang;
namespace d3d11
{
- bool isSupportedNVAPIOp(IUnknown* dev, uint32_t op)
- {
+bool isSupportedNVAPIOp(IUnknown* dev, uint32_t op)
+{
#ifdef GFX_NVAPI
- {
- bool isSupported;
- NvAPI_Status status = NvAPI_D3D11_IsNvShaderExtnOpCodeSupported(dev, NvU32(op), &isSupported);
- return status == NVAPI_OK && isSupported;
- }
+ {
+ bool isSupported;
+ NvAPI_Status status =
+ NvAPI_D3D11_IsNvShaderExtnOpCodeSupported(dev, NvU32(op), &isSupported);
+ return status == NVAPI_OK && isSupported;
+ }
#else
- return false;
+ return false;
#endif
- }
+}
- D3D11_BIND_FLAG calcResourceFlag(ResourceState state)
+D3D11_BIND_FLAG calcResourceFlag(ResourceState state)
+{
+ switch (state)
{
- switch (state)
- {
- case ResourceState::VertexBuffer:
- return D3D11_BIND_VERTEX_BUFFER;
- case ResourceState::IndexBuffer:
- return D3D11_BIND_INDEX_BUFFER;
- case ResourceState::ConstantBuffer:
- return D3D11_BIND_CONSTANT_BUFFER;
- case ResourceState::StreamOutput:
- return D3D11_BIND_STREAM_OUTPUT;
- case ResourceState::RenderTarget:
- return D3D11_BIND_RENDER_TARGET;
- case ResourceState::DepthRead:
- case ResourceState::DepthWrite:
- return D3D11_BIND_DEPTH_STENCIL;
- case ResourceState::UnorderedAccess:
- return D3D11_BIND_UNORDERED_ACCESS;
- case ResourceState::ShaderResource:
- case ResourceState::PixelShaderResource:
- case ResourceState::NonPixelShaderResource:
- return D3D11_BIND_SHADER_RESOURCE;
- default:
- return D3D11_BIND_FLAG(0);
- }
+ case ResourceState::VertexBuffer: return D3D11_BIND_VERTEX_BUFFER;
+ case ResourceState::IndexBuffer: return D3D11_BIND_INDEX_BUFFER;
+ case ResourceState::ConstantBuffer: return D3D11_BIND_CONSTANT_BUFFER;
+ case ResourceState::StreamOutput: return D3D11_BIND_STREAM_OUTPUT;
+ case ResourceState::RenderTarget: return D3D11_BIND_RENDER_TARGET;
+ case ResourceState::DepthRead:
+ case ResourceState::DepthWrite: return D3D11_BIND_DEPTH_STENCIL;
+ case ResourceState::UnorderedAccess: return D3D11_BIND_UNORDERED_ACCESS;
+ case ResourceState::ShaderResource:
+ case ResourceState::PixelShaderResource:
+ case ResourceState::NonPixelShaderResource: return D3D11_BIND_SHADER_RESOURCE;
+ default: return D3D11_BIND_FLAG(0);
}
+}
- int _calcResourceBindFlags(ResourceStateSet allowedStates)
+int _calcResourceBindFlags(ResourceStateSet allowedStates)
+{
+ int dstFlags = 0;
+ for (uint32_t i = 0; i < (uint32_t)ResourceState::_Count; i++)
{
- int dstFlags = 0;
- for (uint32_t i = 0; i < (uint32_t)ResourceState::_Count; i++)
- {
- auto state = (ResourceState)i;
- if (allowedStates.contains(state))
- dstFlags |= calcResourceFlag(state);
- }
- return dstFlags;
+ auto state = (ResourceState)i;
+ if (allowedStates.contains(state))
+ dstFlags |= calcResourceFlag(state);
}
+ return dstFlags;
+}
- int _calcResourceAccessFlags(MemoryType memType)
+int _calcResourceAccessFlags(MemoryType memType)
+{
+ switch (memType)
{
- switch (memType)
- {
- case MemoryType::DeviceLocal:
- return 0;
- case MemoryType::ReadBack:
- return D3D11_CPU_ACCESS_READ;
- case MemoryType::Upload:
- return D3D11_CPU_ACCESS_WRITE;
- default:
- assert(!"Invalid flags");
- return 0;
- }
+ case MemoryType::DeviceLocal: return 0;
+ case MemoryType::ReadBack: return D3D11_CPU_ACCESS_READ;
+ case MemoryType::Upload: return D3D11_CPU_ACCESS_WRITE;
+ default: assert(!"Invalid flags"); return 0;
}
+}
- D3D11_FILTER_TYPE translateFilterMode(TextureFilteringMode mode)
+D3D11_FILTER_TYPE translateFilterMode(TextureFilteringMode mode)
+{
+ switch (mode)
{
- switch (mode)
- {
- default:
- return D3D11_FILTER_TYPE(0);
+ default: return D3D11_FILTER_TYPE(0);
#define CASE(SRC, DST) \
case TextureFilteringMode::SRC: return D3D11_FILTER_TYPE_##DST
- CASE(Point, POINT);
- CASE(Linear, LINEAR);
+ CASE(Point, POINT);
+ CASE(Linear, LINEAR);
#undef CASE
- }
}
+}
- D3D11_FILTER_REDUCTION_TYPE translateFilterReduction(TextureReductionOp op)
+D3D11_FILTER_REDUCTION_TYPE translateFilterReduction(TextureReductionOp op)
+{
+ switch (op)
{
- switch (op)
- {
- default:
- return D3D11_FILTER_REDUCTION_TYPE(0);
+ default: return D3D11_FILTER_REDUCTION_TYPE(0);
#define CASE(SRC, DST) \
case TextureReductionOp::SRC: return D3D11_FILTER_REDUCTION_TYPE_##DST
- CASE(Average, STANDARD);
- CASE(Comparison, COMPARISON);
- CASE(Minimum, MINIMUM);
- CASE(Maximum, MAXIMUM);
+ CASE(Average, STANDARD);
+ CASE(Comparison, COMPARISON);
+ CASE(Minimum, MINIMUM);
+ CASE(Maximum, MAXIMUM);
#undef CASE
- }
}
+}
- D3D11_TEXTURE_ADDRESS_MODE translateAddressingMode(TextureAddressingMode mode)
+D3D11_TEXTURE_ADDRESS_MODE translateAddressingMode(TextureAddressingMode mode)
+{
+ switch (mode)
{
- switch (mode)
- {
- default:
- return D3D11_TEXTURE_ADDRESS_MODE(0);
+ default: return D3D11_TEXTURE_ADDRESS_MODE(0);
#define CASE(SRC, DST) \
case TextureAddressingMode::SRC: return D3D11_TEXTURE_ADDRESS_##DST
- CASE(Wrap, WRAP);
- CASE(ClampToEdge, CLAMP);
- CASE(ClampToBorder, BORDER);
- CASE(MirrorRepeat, MIRROR);
- CASE(MirrorOnce, MIRROR_ONCE);
+ CASE(Wrap, WRAP);
+ CASE(ClampToEdge, CLAMP);
+ CASE(ClampToBorder, BORDER);
+ CASE(MirrorRepeat, MIRROR);
+ CASE(MirrorOnce, MIRROR_ONCE);
#undef CASE
- }
}
+}
- D3D11_COMPARISON_FUNC translateComparisonFunc(ComparisonFunc func)
+D3D11_COMPARISON_FUNC translateComparisonFunc(ComparisonFunc func)
+{
+ switch (func)
{
- switch (func)
- {
- default:
- // TODO: need to report failures
- return D3D11_COMPARISON_ALWAYS;
+ default:
+ // TODO: need to report failures
+ return D3D11_COMPARISON_ALWAYS;
#define CASE(FROM, TO) \
case ComparisonFunc::FROM: return D3D11_COMPARISON_##TO
- CASE(Never, NEVER);
- CASE(Less, LESS);
- CASE(Equal, EQUAL);
- CASE(LessEqual, LESS_EQUAL);
- CASE(Greater, GREATER);
- CASE(NotEqual, NOT_EQUAL);
- CASE(GreaterEqual, GREATER_EQUAL);
- CASE(Always, ALWAYS);
+ CASE(Never, NEVER);
+ CASE(Less, LESS);
+ CASE(Equal, EQUAL);
+ CASE(LessEqual, LESS_EQUAL);
+ CASE(Greater, GREATER);
+ CASE(NotEqual, NOT_EQUAL);
+ CASE(GreaterEqual, GREATER_EQUAL);
+ CASE(Always, ALWAYS);
#undef CASE
- }
}
+}
- D3D11_STENCIL_OP translateStencilOp(StencilOp op)
+D3D11_STENCIL_OP translateStencilOp(StencilOp op)
+{
+ switch (op)
{
- switch (op)
- {
- default:
- // TODO: need to report failures
- return D3D11_STENCIL_OP_KEEP;
+ default:
+ // TODO: need to report failures
+ return D3D11_STENCIL_OP_KEEP;
#define CASE(FROM, TO) \
case StencilOp::FROM: return D3D11_STENCIL_OP_##TO
- CASE(Keep, KEEP);
- CASE(Zero, ZERO);
- CASE(Replace, REPLACE);
- CASE(IncrementSaturate, INCR_SAT);
- CASE(DecrementSaturate, DECR_SAT);
- CASE(Invert, INVERT);
- CASE(IncrementWrap, INCR);
- CASE(DecrementWrap, DECR);
+ CASE(Keep, KEEP);
+ CASE(Zero, ZERO);
+ CASE(Replace, REPLACE);
+ CASE(IncrementSaturate, INCR_SAT);
+ CASE(DecrementSaturate, DECR_SAT);
+ CASE(Invert, INVERT);
+ CASE(IncrementWrap, INCR);
+ CASE(DecrementWrap, DECR);
#undef CASE
-
- }
}
+}
- D3D11_FILL_MODE translateFillMode(FillMode mode)
+D3D11_FILL_MODE translateFillMode(FillMode mode)
+{
+ switch (mode)
{
- switch (mode)
- {
- default:
- // TODO: need to report failures
- return D3D11_FILL_SOLID;
+ default:
+ // TODO: need to report failures
+ return D3D11_FILL_SOLID;
- case FillMode::Solid: return D3D11_FILL_SOLID;
- case FillMode::Wireframe: return D3D11_FILL_WIREFRAME;
- }
+ case FillMode::Solid: return D3D11_FILL_SOLID;
+ case FillMode::Wireframe: return D3D11_FILL_WIREFRAME;
}
+}
- D3D11_CULL_MODE translateCullMode(CullMode mode)
+D3D11_CULL_MODE translateCullMode(CullMode mode)
+{
+ switch (mode)
{
- switch (mode)
- {
- default:
- // TODO: need to report failures
- return D3D11_CULL_NONE;
+ default:
+ // TODO: need to report failures
+ return D3D11_CULL_NONE;
- case CullMode::None: return D3D11_CULL_NONE;
- case CullMode::Back: return D3D11_CULL_BACK;
- case CullMode::Front: return D3D11_CULL_FRONT;
- }
+ case CullMode::None: return D3D11_CULL_NONE;
+ case CullMode::Back: return D3D11_CULL_BACK;
+ case CullMode::Front: return D3D11_CULL_FRONT;
}
+}
- bool isBlendDisabled(AspectBlendDesc const& desc)
- {
- return desc.op == BlendOp::Add
- && desc.srcFactor == BlendFactor::One
- && desc.dstFactor == BlendFactor::Zero;
- }
+bool isBlendDisabled(AspectBlendDesc const& desc)
+{
+ return desc.op == BlendOp::Add && desc.srcFactor == BlendFactor::One &&
+ desc.dstFactor == BlendFactor::Zero;
+}
- bool isBlendDisabled(TargetBlendDesc const& desc)
- {
- return isBlendDisabled(desc.color)
- && isBlendDisabled(desc.alpha);
- }
+bool isBlendDisabled(TargetBlendDesc const& desc)
+{
+ return isBlendDisabled(desc.color) && isBlendDisabled(desc.alpha);
+}
- D3D11_BLEND_OP translateBlendOp(BlendOp op)
+D3D11_BLEND_OP translateBlendOp(BlendOp op)
+{
+ switch (op)
{
- switch (op)
- {
- default:
- assert(!"unimplemented");
- return (D3D11_BLEND_OP)-1;
-
-#define CASE(FROM, TO) case BlendOp::FROM: return D3D11_BLEND_OP_##TO
- CASE(Add, ADD);
- CASE(Subtract, SUBTRACT);
- CASE(ReverseSubtract, REV_SUBTRACT);
- CASE(Min, MIN);
- CASE(Max, MAX);
+ default: assert(!"unimplemented"); return (D3D11_BLEND_OP)-1;
+
+#define CASE(FROM, TO) \
+ case BlendOp::FROM: return D3D11_BLEND_OP_##TO
+ CASE(Add, ADD);
+ CASE(Subtract, SUBTRACT);
+ CASE(ReverseSubtract, REV_SUBTRACT);
+ CASE(Min, MIN);
+ CASE(Max, MAX);
#undef CASE
- }
}
+}
- D3D11_BLEND translateBlendFactor(BlendFactor factor)
+D3D11_BLEND translateBlendFactor(BlendFactor factor)
+{
+ switch (factor)
{
- switch (factor)
- {
- default:
- assert(!"unimplemented");
- return (D3D11_BLEND)-1;
-
-#define CASE(FROM, TO) case BlendFactor::FROM: return D3D11_BLEND_##TO
- CASE(Zero, ZERO);
- CASE(One, ONE);
- CASE(SrcColor, SRC_COLOR);
- CASE(InvSrcColor, INV_SRC_COLOR);
- CASE(SrcAlpha, SRC_ALPHA);
- CASE(InvSrcAlpha, INV_SRC_ALPHA);
- CASE(DestAlpha, DEST_ALPHA);
- CASE(InvDestAlpha, INV_DEST_ALPHA);
- CASE(DestColor, DEST_COLOR);
- CASE(InvDestColor, INV_DEST_ALPHA);
- CASE(SrcAlphaSaturate, SRC_ALPHA_SAT);
- CASE(BlendColor, BLEND_FACTOR);
- CASE(InvBlendColor, INV_BLEND_FACTOR);
- CASE(SecondarySrcColor, SRC1_COLOR);
- CASE(InvSecondarySrcColor, INV_SRC1_COLOR);
- CASE(SecondarySrcAlpha, SRC1_ALPHA);
- CASE(InvSecondarySrcAlpha, INV_SRC1_ALPHA);
+ default: assert(!"unimplemented"); return (D3D11_BLEND)-1;
+
+#define CASE(FROM, TO) \
+ case BlendFactor::FROM: return D3D11_BLEND_##TO
+ CASE(Zero, ZERO);
+ CASE(One, ONE);
+ CASE(SrcColor, SRC_COLOR);
+ CASE(InvSrcColor, INV_SRC_COLOR);
+ CASE(SrcAlpha, SRC_ALPHA);
+ CASE(InvSrcAlpha, INV_SRC_ALPHA);
+ CASE(DestAlpha, DEST_ALPHA);
+ CASE(InvDestAlpha, INV_DEST_ALPHA);
+ CASE(DestColor, DEST_COLOR);
+ CASE(InvDestColor, INV_DEST_ALPHA);
+ CASE(SrcAlphaSaturate, SRC_ALPHA_SAT);
+ CASE(BlendColor, BLEND_FACTOR);
+ CASE(InvBlendColor, INV_BLEND_FACTOR);
+ CASE(SecondarySrcColor, SRC1_COLOR);
+ CASE(InvSecondarySrcColor, INV_SRC1_COLOR);
+ CASE(SecondarySrcAlpha, SRC1_ALPHA);
+ CASE(InvSecondarySrcAlpha, INV_SRC1_ALPHA);
#undef CASE
- }
}
+}
- D3D11_COLOR_WRITE_ENABLE translateRenderTargetWriteMask(RenderTargetWriteMaskT mask)
- {
- UINT result = 0;
-#define CASE(FROM, TO) if(mask & RenderTargetWriteMask::Enable##FROM) result |= D3D11_COLOR_WRITE_ENABLE_##TO
+D3D11_COLOR_WRITE_ENABLE translateRenderTargetWriteMask(RenderTargetWriteMaskT mask)
+{
+ UINT result = 0;
+#define CASE(FROM, TO) \
+ if (mask & RenderTargetWriteMask::Enable##FROM) \
+ result |= D3D11_COLOR_WRITE_ENABLE_##TO
- CASE(Red, RED);
- CASE(Green, GREEN);
- CASE(Blue, BLUE);
- CASE(Alpha, ALPHA);
+ CASE(Red, RED);
+ CASE(Green, GREEN);
+ CASE(Blue, BLUE);
+ CASE(Alpha, ALPHA);
#undef CASE
- return D3D11_COLOR_WRITE_ENABLE(result);
- }
+ return D3D11_COLOR_WRITE_ENABLE(result);
+}
- void initSrvDesc(IResource::Type resourceType, const ITextureResource::Desc& textureDesc, DXGI_FORMAT pixelFormat, D3D11_SHADER_RESOURCE_VIEW_DESC& descOut)
+void initSrvDesc(
+ IResource::Type resourceType,
+ const ITextureResource::Desc& textureDesc,
+ DXGI_FORMAT pixelFormat,
+ D3D11_SHADER_RESOURCE_VIEW_DESC& descOut)
+{
+ // create SRV
+ descOut = D3D11_SHADER_RESOURCE_VIEW_DESC();
+
+ descOut.Format =
+ (pixelFormat == DXGI_FORMAT_UNKNOWN)
+ ? D3DUtil::calcFormat(D3DUtil::USAGE_SRV, D3DUtil::getMapFormat(textureDesc.format))
+ : pixelFormat;
+ const int arraySize = calcEffectiveArraySize(textureDesc);
+ if (arraySize <= 1)
{
- // create SRV
- descOut = D3D11_SHADER_RESOURCE_VIEW_DESC();
-
- descOut.Format = (pixelFormat == DXGI_FORMAT_UNKNOWN) ? D3DUtil::calcFormat(D3DUtil::USAGE_SRV, D3DUtil::getMapFormat(textureDesc.format)) : pixelFormat;
- const int arraySize = calcEffectiveArraySize(textureDesc);
- if (arraySize <= 1)
+ switch (textureDesc.type)
{
- switch (textureDesc.type)
- {
- case IResource::Type::Texture1D: descOut.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1D; break;
- case IResource::Type::Texture2D: descOut.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D; break;
- case IResource::Type::Texture3D: descOut.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D; break;
- default: assert(!"Unknown dimension");
- }
-
- descOut.Texture2D.MipLevels = textureDesc.numMipLevels;
- descOut.Texture2D.MostDetailedMip = 0;
+ case IResource::Type::Texture1D:
+ descOut.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1D;
+ break;
+ case IResource::Type::Texture2D:
+ descOut.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
+ break;
+ case IResource::Type::Texture3D:
+ descOut.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D;
+ break;
+ default: assert(!"Unknown dimension");
}
- else if (resourceType == IResource::Type::TextureCube)
+
+ descOut.Texture2D.MipLevels = textureDesc.numMipLevels;
+ descOut.Texture2D.MostDetailedMip = 0;
+ }
+ else if (resourceType == IResource::Type::TextureCube)
+ {
+ if (textureDesc.arraySize > 1)
{
- if (textureDesc.arraySize > 1)
- {
- descOut.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBEARRAY;
-
- descOut.TextureCubeArray.NumCubes = textureDesc.arraySize;
- descOut.TextureCubeArray.First2DArrayFace = 0;
- descOut.TextureCubeArray.MipLevels = textureDesc.numMipLevels;
- descOut.TextureCubeArray.MostDetailedMip = 0;
- }
- else
- {
- descOut.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE;
-
- descOut.TextureCube.MipLevels = textureDesc.numMipLevels;
- descOut.TextureCube.MostDetailedMip = 0;
- }
+ descOut.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBEARRAY;
+
+ descOut.TextureCubeArray.NumCubes = textureDesc.arraySize;
+ descOut.TextureCubeArray.First2DArrayFace = 0;
+ descOut.TextureCubeArray.MipLevels = textureDesc.numMipLevels;
+ descOut.TextureCubeArray.MostDetailedMip = 0;
}
else
{
- assert(textureDesc.size.depth > 1 || arraySize > 1);
+ descOut.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE;
- switch (textureDesc.type)
- {
- case IResource::Type::Texture1D: descOut.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1DARRAY; break;
- case IResource::Type::Texture2D: descOut.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY; break;
- case IResource::Type::Texture3D: descOut.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D; break;
-
- default: assert(!"Unknown dimension");
- }
+ descOut.TextureCube.MipLevels = textureDesc.numMipLevels;
+ descOut.TextureCube.MostDetailedMip = 0;
+ }
+ }
+ else
+ {
+ assert(textureDesc.size.depth > 1 || arraySize > 1);
- descOut.Texture2DArray.ArraySize = std::max(textureDesc.size.depth, arraySize);
- descOut.Texture2DArray.MostDetailedMip = 0;
- descOut.Texture2DArray.MipLevels = textureDesc.numMipLevels;
- descOut.Texture2DArray.FirstArraySlice = 0;
+ switch (textureDesc.type)
+ {
+ case IResource::Type::Texture1D:
+ descOut.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1DARRAY;
+ break;
+ case IResource::Type::Texture2D:
+ descOut.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
+ break;
+ case IResource::Type::Texture3D:
+ descOut.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D;
+ break;
+
+ default: assert(!"Unknown dimension");
}
+
+ descOut.Texture2DArray.ArraySize = std::max(textureDesc.size.depth, arraySize);
+ descOut.Texture2DArray.MostDetailedMip = 0;
+ descOut.Texture2DArray.MipLevels = textureDesc.numMipLevels;
+ descOut.Texture2DArray.FirstArraySlice = 0;
}
+}
} // namespace d3d11
Result SLANG_MCALL getD3D11Adapters(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)
@@ -357,7 +358,10 @@ Result SLANG_MCALL getD3D11Adapters(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/d3d11/d3d11-helper-functions.h b/tools/gfx/d3d11/d3d11-helper-functions.h
index 9f115d88d..cca49de14 100644
--- a/tools/gfx/d3d11/d3d11-helper-functions.h
+++ b/tools/gfx/d3d11/d3d11-helper-functions.h
@@ -1,9 +1,9 @@
// d3d11-helper-functions.h
#pragma once
-#include "slang-gfx.h"
-#include "d3d11-base.h"
#include "../../../source/core/slang-list.h"
+#include "d3d11-base.h"
+#include "slang-gfx.h"
namespace gfx
{
@@ -12,274 +12,265 @@ using namespace Slang;
namespace d3d11
{
- /// Contextual data and operations required when binding shader objects to the pipeline state
- struct BindingContext
+/// Contextual data and operations required when binding shader objects to the pipeline state
+struct BindingContext
+{
+ // One key service that the `BindingContext` provides is abstracting over
+ // the difference between the D3D11 compute and graphics/rasteriation pipelines.
+ // D3D11 has distinct operations for, e.g., `CSSetShaderResources`
+ // for compute vs. `VSSetShaderResources` and `PSSetShaderResources`
+ // for rasterization.
+ //
+ // The context type provides simple operations for setting each class
+ // of resource/sampler, which will be overridden in derived types.
+ //
+ // TODO: These operations should really support binding multiple resources/samplers
+ // in one call, so that we can eventually make more efficient use of the API.
+ //
+ // TODO: We could reasonably also just store the bound resources into
+ // lcoal arrays like we are doing for UAVs, and remove the pipeline-specific
+ // virtual functions. However, doing so would seemingly eliminate any
+ // chance of avoiding redundant binding work when binding changes are
+ // made for a root shader object.
+ //
+ virtual void setCBV(UINT index, ID3D11Buffer* buffer) = 0;
+ virtual void setSRV(UINT index, ID3D11ShaderResourceView* srv) = 0;
+ virtual void setSampler(UINT index, ID3D11SamplerState* sampler) = 0;
+
+ // Unordered Access Views (UAVs) are a somewhat special case in that
+ // the D3D11 API requires them to all be set at once, rather than one
+ // at a time. To support this, we will keep a local array of the UAVs
+ // that have been bound (up to the maximum supported by D3D 11.0)
+ //
+ void setUAV(UINT index, ID3D11UnorderedAccessView* uav)
{
- // One key service that the `BindingContext` provides is abstracting over
- // the difference between the D3D11 compute and graphics/rasteriation pipelines.
- // D3D11 has distinct operations for, e.g., `CSSetShaderResources`
- // for compute vs. `VSSetShaderResources` and `PSSetShaderResources`
- // for rasterization.
- //
- // The context type provides simple operations for setting each class
- // of resource/sampler, which will be overridden in derived types.
- //
- // TODO: These operations should really support binding multiple resources/samplers
- // in one call, so that we can eventually make more efficient use of the API.
- //
- // TODO: We could reasonably also just store the bound resources into
- // lcoal arrays like we are doing for UAVs, and remove the pipeline-specific
- // virtual functions. However, doing so would seemingly eliminate any
- // chance of avoiding redundant binding work when binding changes are
- // made for a root shader object.
- //
- virtual void setCBV(UINT index, ID3D11Buffer* buffer) = 0;
- virtual void setSRV(UINT index, ID3D11ShaderResourceView* srv) = 0;
- virtual void setSampler(UINT index, ID3D11SamplerState* sampler) = 0;
-
- // Unordered Access Views (UAVs) are a somewhat special case in that
- // the D3D11 API requires them to all be set at once, rather than one
- // at a time. To support this, we will keep a local array of the UAVs
- // that have been bound (up to the maximum supported by D3D 11.0)
+ uavs[index] = uav;
+
+ // We will also track the total number of UAV slots that will
+ // need to be bound (including any gaps that might occur due
+ // to either explicit bindings or RTV bindings that conflict
+ // with the `u` registers for fragment shaders).
//
- void setUAV(UINT index, ID3D11UnorderedAccessView* uav)
+ if (uavCount <= index)
{
- uavs[index] = uav;
-
- // We will also track the total number of UAV slots that will
- // need to be bound (including any gaps that might occur due
- // to either explicit bindings or RTV bindings that conflict
- // with the `u` registers for fragment shaders).
- //
- if (uavCount <= index)
- {
- uavCount = index + 1;
- }
+ uavCount = index + 1;
}
+ }
- /// The values bound for any UAVs
- ID3D11UnorderedAccessView* uavs[D3D11_PS_CS_UAV_REGISTER_COUNT];
+ /// The values bound for any UAVs
+ ID3D11UnorderedAccessView* uavs[D3D11_PS_CS_UAV_REGISTER_COUNT];
- /// The number of entries in `uavs` that need to be considered when binding to the pipeline
- UINT uavCount = 0;
+ /// The number of entries in `uavs` that need to be considered when binding to the pipeline
+ UINT uavCount = 0;
- /// The D3D11 device that we are using for binding
- DeviceImpl* device = nullptr;
+ /// The D3D11 device that we are using for binding
+ DeviceImpl* device = nullptr;
- /// The D3D11 device context that we are using for binding
- ID3D11DeviceContext* context = nullptr;
+ /// The D3D11 device context that we are using for binding
+ ID3D11DeviceContext* context = nullptr;
- /// Initialize a binding context for binding to the given `device` and `context`
- BindingContext(
- DeviceImpl* device,
- ID3D11DeviceContext* context)
- : device(device)
- , context(context)
- {
- memset(uavs, 0, sizeof(uavs));
- }
- };
-
- /// A `BindingContext` for binding to the compute pipeline
- struct ComputeBindingContext : BindingContext
+ /// Initialize a binding context for binding to the given `device` and `context`
+ BindingContext(DeviceImpl* device, ID3D11DeviceContext* context)
+ : device(device), context(context)
{
- /// Initialize a binding context for binding to the given `device` and `context`
- ComputeBindingContext(
- DeviceImpl* device,
- ID3D11DeviceContext* context)
- : BindingContext(device, context)
- {}
-
- void setCBV(UINT index, ID3D11Buffer* buffer) SLANG_OVERRIDE
- {
- context->CSSetConstantBuffers(index, 1, &buffer);
- }
+ memset(uavs, 0, sizeof(uavs));
+ }
+};
- void setSRV(UINT index, ID3D11ShaderResourceView* srv) SLANG_OVERRIDE
- {
- context->CSSetShaderResources(index, 1, &srv);
- }
+/// A `BindingContext` for binding to the compute pipeline
+struct ComputeBindingContext : BindingContext
+{
+ /// Initialize a binding context for binding to the given `device` and `context`
+ ComputeBindingContext(DeviceImpl* device, ID3D11DeviceContext* context)
+ : BindingContext(device, context)
+ {
+ }
- void setSampler(UINT index, ID3D11SamplerState* sampler) SLANG_OVERRIDE
- {
- context->CSSetSamplers(index, 1, &sampler);
- }
- };
+ void setCBV(UINT index, ID3D11Buffer* buffer) SLANG_OVERRIDE
+ {
+ context->CSSetConstantBuffers(index, 1, &buffer);
+ }
- /// A `BindingContext` for binding to the graphics/rasterization pipeline
- struct GraphicsBindingContext : BindingContext
+ void setSRV(UINT index, ID3D11ShaderResourceView* srv) SLANG_OVERRIDE
{
- /// Initialize a binding context for binding to the given `device` and `context`
- GraphicsBindingContext(
- DeviceImpl* device,
- ID3D11DeviceContext* context)
- : BindingContext(device, context)
- {}
-
- // TODO: The operations here are only dealing with vertex and fragment
- // shaders for now. We should eventually extend them to handle HS/DS/GS
- // bindings. (We might want to skip those stages depending on whether
- // the associated program uses them at all).
- //
- // TODO: If we support cases where different stages might use distinct
- // entry-point parameters, we might need to support some modes where
- // a "stage mask" is passed in that applies to the bindings.
- //
- void setCBV(UINT index, ID3D11Buffer* buffer) SLANG_OVERRIDE
- {
- context->VSSetConstantBuffers(index, 1, &buffer);
- context->PSSetConstantBuffers(index, 1, &buffer);
- }
+ context->CSSetShaderResources(index, 1, &srv);
+ }
- void setSRV(UINT index, ID3D11ShaderResourceView* srv) SLANG_OVERRIDE
- {
- context->VSSetShaderResources(index, 1, &srv);
- context->PSSetShaderResources(index, 1, &srv);
- }
+ void setSampler(UINT index, ID3D11SamplerState* sampler) SLANG_OVERRIDE
+ {
+ context->CSSetSamplers(index, 1, &sampler);
+ }
+};
- void setSampler(UINT index, ID3D11SamplerState* sampler) SLANG_OVERRIDE
- {
- context->VSSetSamplers(index, 1, &sampler);
- context->PSSetSamplers(index, 1, &sampler);
- }
- };
+/// A `BindingContext` for binding to the graphics/rasterization pipeline
+struct GraphicsBindingContext : BindingContext
+{
+ /// Initialize a binding context for binding to the given `device` and `context`
+ GraphicsBindingContext(DeviceImpl* device, ID3D11DeviceContext* context)
+ : BindingContext(device, context)
+ {
+ }
- // In order to bind shader parameters to the correct locations, we need to
- // be able to describe those locations. Most shader parameters will
- // only consume a single type of D3D11-visible regsiter (e.g., a `t`
- // register for a txture, or an `s` register for a sampler), and scalar
- // integers suffice for these cases.
+ // TODO: The operations here are only dealing with vertex and fragment
+ // shaders for now. We should eventually extend them to handle HS/DS/GS
+ // bindings. (We might want to skip those stages depending on whether
+ // the associated program uses them at all).
+ //
+ // TODO: If we support cases where different stages might use distinct
+ // entry-point parameters, we might need to support some modes where
+ // a "stage mask" is passed in that applies to the bindings.
//
- // In more complex cases we might be binding an entire "sub-object" like
- // a parameter block, an entry point, etc. For the general case, we need
- // to be able to represent a composite offset that includes offsets for
- // each of the register classes known to D3D11.
+ void setCBV(UINT index, ID3D11Buffer* buffer) SLANG_OVERRIDE
+ {
+ context->VSSetConstantBuffers(index, 1, &buffer);
+ context->PSSetConstantBuffers(index, 1, &buffer);
+ }
- /// A "simple" binding offset that records an offset in CBV/SRV/UAV/Sampler slots
- struct SimpleBindingOffset
+ void setSRV(UINT index, ID3D11ShaderResourceView* srv) SLANG_OVERRIDE
{
- uint32_t cbv = 0;
- uint32_t srv = 0;
- uint32_t uav = 0;
- uint32_t sampler = 0;
+ context->VSSetShaderResources(index, 1, &srv);
+ context->PSSetShaderResources(index, 1, &srv);
+ }
- /// Create a default (zero) offset
- SimpleBindingOffset()
- {}
+ void setSampler(UINT index, ID3D11SamplerState* sampler) SLANG_OVERRIDE
+ {
+ context->VSSetSamplers(index, 1, &sampler);
+ context->PSSetSamplers(index, 1, &sampler);
+ }
+};
+
+// In order to bind shader parameters to the correct locations, we need to
+// be able to describe those locations. Most shader parameters will
+// only consume a single type of D3D11-visible regsiter (e.g., a `t`
+// register for a txture, or an `s` register for a sampler), and scalar
+// integers suffice for these cases.
+//
+// In more complex cases we might be binding an entire "sub-object" like
+// a parameter block, an entry point, etc. For the general case, we need
+// to be able to represent a composite offset that includes offsets for
+// each of the register classes known to D3D11.
+
+/// A "simple" binding offset that records an offset in CBV/SRV/UAV/Sampler slots
+struct SimpleBindingOffset
+{
+ uint32_t cbv = 0;
+ uint32_t srv = 0;
+ uint32_t uav = 0;
+ uint32_t sampler = 0;
- /// Create an offset based on offset information in the given Slang `varLayout`
- SimpleBindingOffset(slang::VariableLayoutReflection* varLayout)
- {
- if (varLayout)
- {
- cbv = (uint32_t)varLayout->getOffset(SLANG_PARAMETER_CATEGORY_CONSTANT_BUFFER);
- srv = (uint32_t)varLayout->getOffset(SLANG_PARAMETER_CATEGORY_SHADER_RESOURCE);
- uav = (uint32_t)varLayout->getOffset(SLANG_PARAMETER_CATEGORY_UNORDERED_ACCESS);
- sampler = (uint32_t)varLayout->getOffset(SLANG_PARAMETER_CATEGORY_SAMPLER_STATE);
- }
- }
+ /// Create a default (zero) offset
+ SimpleBindingOffset() {}
- /// Create an offset based on size/stride information in the given Slang `typeLayout`
- SimpleBindingOffset(slang::TypeLayoutReflection* typeLayout)
+ /// Create an offset based on offset information in the given Slang `varLayout`
+ SimpleBindingOffset(slang::VariableLayoutReflection* varLayout)
+ {
+ if (varLayout)
{
- if (typeLayout)
- {
- cbv = (uint32_t)typeLayout->getSize(SLANG_PARAMETER_CATEGORY_CONSTANT_BUFFER);
- srv = (uint32_t)typeLayout->getSize(SLANG_PARAMETER_CATEGORY_SHADER_RESOURCE);
- uav = (uint32_t)typeLayout->getSize(SLANG_PARAMETER_CATEGORY_UNORDERED_ACCESS);
- sampler = (uint32_t)typeLayout->getSize(SLANG_PARAMETER_CATEGORY_SAMPLER_STATE);
- }
+ cbv = (uint32_t)varLayout->getOffset(SLANG_PARAMETER_CATEGORY_CONSTANT_BUFFER);
+ srv = (uint32_t)varLayout->getOffset(SLANG_PARAMETER_CATEGORY_SHADER_RESOURCE);
+ uav = (uint32_t)varLayout->getOffset(SLANG_PARAMETER_CATEGORY_UNORDERED_ACCESS);
+ sampler = (uint32_t)varLayout->getOffset(SLANG_PARAMETER_CATEGORY_SAMPLER_STATE);
}
+ }
- /// Add any values in the given `offset`
- void operator+=(SimpleBindingOffset const& offset)
+ /// Create an offset based on size/stride information in the given Slang `typeLayout`
+ SimpleBindingOffset(slang::TypeLayoutReflection* typeLayout)
+ {
+ if (typeLayout)
{
- cbv += offset.cbv;
- srv += offset.srv;
- uav += offset.uav;
- sampler += offset.sampler;
+ cbv = (uint32_t)typeLayout->getSize(SLANG_PARAMETER_CATEGORY_CONSTANT_BUFFER);
+ srv = (uint32_t)typeLayout->getSize(SLANG_PARAMETER_CATEGORY_SHADER_RESOURCE);
+ uav = (uint32_t)typeLayout->getSize(SLANG_PARAMETER_CATEGORY_UNORDERED_ACCESS);
+ sampler = (uint32_t)typeLayout->getSize(SLANG_PARAMETER_CATEGORY_SAMPLER_STATE);
}
- };
+ }
- // While a "simple" binding offset representation will work in many cases,
- // once we need to deal with layout for programs with interface-type parameters
- // that have been statically specialized, we also need to track the offset
- // for where to bind any "pending" data that arises from the process of static
- // specialization.
- //
- // In order to conveniently track both the "primary" and "pending" offset information,
- // we will define a more complete `BindingOffset` type that combines simple
- // binding offsets for the primary and pending parts.
+ /// Add any values in the given `offset`
+ void operator+=(SimpleBindingOffset const& offset)
+ {
+ cbv += offset.cbv;
+ srv += offset.srv;
+ uav += offset.uav;
+ sampler += offset.sampler;
+ }
+};
+
+// While a "simple" binding offset representation will work in many cases,
+// once we need to deal with layout for programs with interface-type parameters
+// that have been statically specialized, we also need to track the offset
+// for where to bind any "pending" data that arises from the process of static
+// specialization.
+//
+// In order to conveniently track both the "primary" and "pending" offset information,
+// we will define a more complete `BindingOffset` type that combines simple
+// binding offsets for the primary and pending parts.
+
+/// A representation of the offset at which to bind a shader parameter or sub-object
+struct BindingOffset : SimpleBindingOffset
+{
+ // Offsets for "primary" data are stored directly in the `BindingOffset`
+ // via the inheritance from `SimpleBindingOffset`.
+
+ /// Offset for any "pending" data
+ SimpleBindingOffset pending;
- /// A representation of the offset at which to bind a shader parameter or sub-object
- struct BindingOffset : SimpleBindingOffset
+ /// Create a default (zero) offset
+ BindingOffset() {}
+
+ /// Create an offset from a simple offset
+ explicit BindingOffset(SimpleBindingOffset const& offset)
+ : SimpleBindingOffset(offset)
{
- // Offsets for "primary" data are stored directly in the `BindingOffset`
- // via the inheritance from `SimpleBindingOffset`.
-
- /// Offset for any "pending" data
- SimpleBindingOffset pending;
-
- /// Create a default (zero) offset
- BindingOffset()
- {}
-
- /// Create an offset from a simple offset
- explicit BindingOffset(SimpleBindingOffset const& offset)
- : SimpleBindingOffset(offset)
- {}
-
- /// Create an offset based on offset information in the given Slang `varLayout`
- BindingOffset(slang::VariableLayoutReflection* varLayout)
- : SimpleBindingOffset(varLayout)
- , pending(varLayout->getPendingDataLayout())
- {}
-
- /// Create an offset based on size/stride information in the given Slang `typeLayout`
- BindingOffset(slang::TypeLayoutReflection* typeLayout)
- : SimpleBindingOffset(typeLayout)
- , pending(typeLayout->getPendingDataTypeLayout())
- {}
-
- /// Add any values in the given `offset`
- void operator+=(SimpleBindingOffset const& offset)
- {
- SimpleBindingOffset::operator+=(offset);
- }
+ }
- /// Add any values in the given `offset`
- void operator+=(BindingOffset const& offset)
- {
- SimpleBindingOffset::operator+=(offset);
- pending += offset.pending;
- }
- };
-
- bool isSupportedNVAPIOp(IUnknown* dev, uint32_t op);
-
- D3D11_BIND_FLAG calcResourceFlag(ResourceState state);
- int _calcResourceBindFlags(ResourceStateSet allowedStates);
- int _calcResourceAccessFlags(MemoryType memType);
-
- D3D11_FILTER_TYPE translateFilterMode(TextureFilteringMode mode);
- D3D11_FILTER_REDUCTION_TYPE translateFilterReduction(TextureReductionOp op);
- D3D11_TEXTURE_ADDRESS_MODE translateAddressingMode(TextureAddressingMode mode);
- D3D11_COMPARISON_FUNC translateComparisonFunc(ComparisonFunc func);
-
- D3D11_STENCIL_OP translateStencilOp(StencilOp op);
- D3D11_FILL_MODE translateFillMode(FillMode mode);
- D3D11_CULL_MODE translateCullMode(CullMode mode);
- bool isBlendDisabled(AspectBlendDesc const& desc);
- bool isBlendDisabled(TargetBlendDesc const& desc);
- D3D11_BLEND_OP translateBlendOp(BlendOp op);
- D3D11_BLEND translateBlendFactor(BlendFactor factor);
- D3D11_COLOR_WRITE_ENABLE translateRenderTargetWriteMask(RenderTargetWriteMaskT mask);
-
- void initSrvDesc(
- IResource::Type resourceType,
- const ITextureResource::Desc& textureDesc,
- DXGI_FORMAT pixelFormat,
- D3D11_SHADER_RESOURCE_VIEW_DESC& descOut);
+ /// Create an offset based on offset information in the given Slang `varLayout`
+ BindingOffset(slang::VariableLayoutReflection* varLayout)
+ : SimpleBindingOffset(varLayout), pending(varLayout->getPendingDataLayout())
+ {
+ }
+
+ /// Create an offset based on size/stride information in the given Slang `typeLayout`
+ BindingOffset(slang::TypeLayoutReflection* typeLayout)
+ : SimpleBindingOffset(typeLayout), pending(typeLayout->getPendingDataTypeLayout())
+ {
+ }
+
+ /// Add any values in the given `offset`
+ void operator+=(SimpleBindingOffset const& offset) { SimpleBindingOffset::operator+=(offset); }
+
+ /// Add any values in the given `offset`
+ void operator+=(BindingOffset const& offset)
+ {
+ SimpleBindingOffset::operator+=(offset);
+ pending += offset.pending;
+ }
+};
+
+bool isSupportedNVAPIOp(IUnknown* dev, uint32_t op);
+
+D3D11_BIND_FLAG calcResourceFlag(ResourceState state);
+int _calcResourceBindFlags(ResourceStateSet allowedStates);
+int _calcResourceAccessFlags(MemoryType memType);
+
+D3D11_FILTER_TYPE translateFilterMode(TextureFilteringMode mode);
+D3D11_FILTER_REDUCTION_TYPE translateFilterReduction(TextureReductionOp op);
+D3D11_TEXTURE_ADDRESS_MODE translateAddressingMode(TextureAddressingMode mode);
+D3D11_COMPARISON_FUNC translateComparisonFunc(ComparisonFunc func);
+
+D3D11_STENCIL_OP translateStencilOp(StencilOp op);
+D3D11_FILL_MODE translateFillMode(FillMode mode);
+D3D11_CULL_MODE translateCullMode(CullMode mode);
+bool isBlendDisabled(AspectBlendDesc const& desc);
+bool isBlendDisabled(TargetBlendDesc const& desc);
+D3D11_BLEND_OP translateBlendOp(BlendOp op);
+D3D11_BLEND translateBlendFactor(BlendFactor factor);
+D3D11_COLOR_WRITE_ENABLE translateRenderTargetWriteMask(RenderTargetWriteMaskT mask);
+
+void initSrvDesc(
+ IResource::Type resourceType,
+ const ITextureResource::Desc& textureDesc,
+ DXGI_FORMAT pixelFormat,
+ D3D11_SHADER_RESOURCE_VIEW_DESC& descOut);
} // namespace d3d11
Result SLANG_MCALL getD3D11Adapters(List<AdapterInfo>& outAdapters);
diff --git a/tools/gfx/d3d11/d3d11-pipeline-state.h b/tools/gfx/d3d11/d3d11-pipeline-state.h
index 7ca812d1d..dec4ef285 100644
--- a/tools/gfx/d3d11/d3d11-pipeline-state.h
+++ b/tools/gfx/d3d11/d3d11-pipeline-state.h
@@ -19,15 +19,15 @@ public:
class GraphicsPipelineStateImpl : public PipelineStateImpl
{
public:
- UINT m_rtvCount;
+ UINT m_rtvCount;
- RefPtr<InputLayoutImpl> m_inputLayout;
+ RefPtr<InputLayoutImpl> m_inputLayout;
ComPtr<ID3D11DepthStencilState> m_depthStencilState;
- ComPtr<ID3D11RasterizerState> m_rasterizerState;
- ComPtr<ID3D11BlendState> m_blendState;
+ ComPtr<ID3D11RasterizerState> m_rasterizerState;
+ ComPtr<ID3D11BlendState> m_blendState;
- float m_blendColor[4];
- UINT m_sampleMask;
+ float m_blendColor[4];
+ UINT m_sampleMask;
void init(const GraphicsPipelineStateDesc& inDesc);
};
diff --git a/tools/gfx/d3d11/d3d11-query.cpp b/tools/gfx/d3d11/d3d11-query.cpp
index c917ccbca..1a1c27466 100644
--- a/tools/gfx/d3d11/d3d11-query.cpp
+++ b/tools/gfx/d3d11/d3d11-query.cpp
@@ -17,11 +17,8 @@ Result QueryPoolImpl::init(const IQueryPool::Desc& desc, DeviceImpl* device)
m_queryDesc.MiscFlags = 0;
switch (desc.type)
{
- case QueryType::Timestamp:
- m_queryDesc.Query = D3D11_QUERY_TIMESTAMP;
- break;
- default:
- return SLANG_E_INVALID_ARG;
+ case QueryType::Timestamp: m_queryDesc.Query = D3D11_QUERY_TIMESTAMP; break;
+ default: return SLANG_E_INVALID_ARG;
}
m_queries.setCount(desc.count);
return SLANG_OK;
@@ -34,12 +31,15 @@ ID3D11Query* QueryPoolImpl::getQuery(SlangInt index)
return m_queries[index].get();
}
-SLANG_NO_THROW Result SLANG_MCALL QueryPoolImpl::getResult(
- GfxIndex queryIndex, GfxCount count, uint64_t* data)
+SLANG_NO_THROW Result SLANG_MCALL
+QueryPoolImpl::getResult(GfxIndex queryIndex, GfxCount count, uint64_t* data)
{
D3D11_QUERY_DATA_TIMESTAMP_DISJOINT disjointData;
while (S_OK != m_device->m_immediateContext->GetData(
- m_device->m_disjointQuery, &disjointData, sizeof(D3D11_QUERY_DATA_TIMESTAMP_DISJOINT), 0))
+ m_device->m_disjointQuery,
+ &disjointData,
+ sizeof(D3D11_QUERY_DATA_TIMESTAMP_DISJOINT),
+ 0))
{
Process::sleepCurrentThread(1);
}
@@ -48,7 +48,10 @@ SLANG_NO_THROW Result SLANG_MCALL QueryPoolImpl::getResult(
for (SlangInt i = 0; i < count; i++)
{
SLANG_RETURN_ON_FAIL(m_device->m_immediateContext->GetData(
- m_queries[queryIndex + i], data + i, sizeof(uint64_t), 0));
+ m_queries[queryIndex + i],
+ data + i,
+ sizeof(uint64_t),
+ 0));
}
return SLANG_OK;
}
diff --git a/tools/gfx/d3d11/d3d11-query.h b/tools/gfx/d3d11/d3d11-query.h
index 393294c0a..63866d848 100644
--- a/tools/gfx/d3d11/d3d11-query.h
+++ b/tools/gfx/d3d11/d3d11-query.h
@@ -1,7 +1,6 @@
// d3d11-query.h
#pragma once
#include "d3d11-base.h"
-
#include "d3d11-device.h"
namespace gfx
@@ -12,18 +11,18 @@ using namespace Slang;
namespace d3d11
{
- class QueryPoolImpl : public QueryPoolBase
- {
- public:
- List<ComPtr<ID3D11Query>> m_queries;
- RefPtr<DeviceImpl> m_device;
- D3D11_QUERY_DESC m_queryDesc;
+class QueryPoolImpl : public QueryPoolBase
+{
+public:
+ List<ComPtr<ID3D11Query>> m_queries;
+ RefPtr<DeviceImpl> m_device;
+ D3D11_QUERY_DESC m_queryDesc;
- Result init(const IQueryPool::Desc& desc, DeviceImpl* device);
- ID3D11Query* getQuery(SlangInt index);
- virtual SLANG_NO_THROW Result SLANG_MCALL getResult(
- GfxIndex queryIndex, GfxCount count, uint64_t* data) override;
- };
+ Result init(const IQueryPool::Desc& desc, DeviceImpl* device);
+ ID3D11Query* getQuery(SlangInt index);
+ virtual SLANG_NO_THROW Result SLANG_MCALL
+ getResult(GfxIndex queryIndex, GfxCount count, uint64_t* data) override;
+};
} // namespace d3d11
} // namespace gfx
diff --git a/tools/gfx/d3d11/d3d11-resource-views.h b/tools/gfx/d3d11/d3d11-resource-views.h
index f76acd98b..1ce385f20 100644
--- a/tools/gfx/d3d11/d3d11-resource-views.h
+++ b/tools/gfx/d3d11/d3d11-resource-views.h
@@ -27,26 +27,26 @@ public:
class ShaderResourceViewImpl : public ResourceViewImpl
{
public:
- ComPtr<ID3D11ShaderResourceView> m_srv;
+ ComPtr<ID3D11ShaderResourceView> m_srv;
};
class UnorderedAccessViewImpl : public ResourceViewImpl
{
public:
- ComPtr<ID3D11UnorderedAccessView> m_uav;
+ ComPtr<ID3D11UnorderedAccessView> m_uav;
};
class DepthStencilViewImpl : public ResourceViewImpl
{
public:
- ComPtr<ID3D11DepthStencilView> m_dsv;
+ ComPtr<ID3D11DepthStencilView> m_dsv;
DepthStencilClearValue m_clearValue;
};
class RenderTargetViewImpl : public ResourceViewImpl
{
public:
- ComPtr<ID3D11RenderTargetView> m_rtv;
+ ComPtr<ID3D11RenderTargetView> m_rtv;
float m_clearValue[4];
};
diff --git a/tools/gfx/d3d11/d3d11-scopeNVAPI.h b/tools/gfx/d3d11/d3d11-scopeNVAPI.h
index 0de611ee0..1e49f2db8 100644
--- a/tools/gfx/d3d11/d3d11-scopeNVAPI.h
+++ b/tools/gfx/d3d11/d3d11-scopeNVAPI.h
@@ -14,7 +14,10 @@ namespace d3d11
class ScopeNVAPI
{
public:
- ScopeNVAPI() : m_renderer(nullptr) {}
+ ScopeNVAPI()
+ : m_renderer(nullptr)
+ {
+ }
SlangResult init(DeviceImpl* renderer, Index regIndex);
~ScopeNVAPI();
diff --git a/tools/gfx/d3d11/d3d11-shader-object-layout.cpp b/tools/gfx/d3d11/d3d11-shader-object-layout.cpp
index 70204e4c0..b2b851760 100644
--- a/tools/gfx/d3d11/d3d11-shader-object-layout.cpp
+++ b/tools/gfx/d3d11/d3d11-shader-object-layout.cpp
@@ -29,7 +29,8 @@ ShaderObjectLayoutImpl::SubObjectRangeStride::SubObjectRangeStride(
}
}
-Result ShaderObjectLayoutImpl::Builder::setElementTypeLayout(slang::TypeLayoutReflection* typeLayout)
+Result ShaderObjectLayoutImpl::Builder::setElementTypeLayout(
+ slang::TypeLayoutReflection* typeLayout)
{
typeLayout = _unwrapParameterGroups(typeLayout, m_containerType);
@@ -89,8 +90,7 @@ Result ShaderObjectLayoutImpl::Builder::setElementTypeLayout(slang::TypeLayoutRe
m_samplerRanges.add(r);
break;
- case slang::BindingType::CombinedTextureSampler:
- break;
+ case slang::BindingType::CombinedTextureSampler: break;
case slang::BindingType::MutableTexture:
case slang::BindingType::MutableTypedBuffer:
bindingRangeInfo.baseIndex = m_uavCount;
@@ -98,11 +98,9 @@ Result ShaderObjectLayoutImpl::Builder::setElementTypeLayout(slang::TypeLayoutRe
m_uavRanges.add(r);
break;
- case slang::BindingType::VaryingInput:
- break;
+ case slang::BindingType::VaryingInput: break;
- case slang::BindingType::VaryingOutput:
- break;
+ case slang::BindingType::VaryingOutput: break;
default:
bindingRangeInfo.baseIndex = m_srvCount;
@@ -138,7 +136,9 @@ Result ShaderObjectLayoutImpl::Builder::setElementTypeLayout(slang::TypeLayoutRe
SLANG_ASSERT(descriptorSetIndex == 0);
SlangInt descriptorRangeIndex = typeLayout->getBindingRangeFirstDescriptorRangeIndex(r);
- auto registerOffset = typeLayout->getDescriptorSetDescriptorRangeIndexOffset(descriptorSetIndex, descriptorRangeIndex);
+ auto registerOffset = typeLayout->getDescriptorSetDescriptorRangeIndexOffset(
+ descriptorSetIndex,
+ descriptorRangeIndex);
bindingRangeInfo.registerOffset = (uint32_t)registerOffset;
}
@@ -173,18 +173,18 @@ Result ShaderObjectLayoutImpl::Builder::setElementTypeLayout(slang::TypeLayoutRe
switch (slangBindingType)
{
default:
- {
- // In the case of `ConstantBuffer<X>` or `ParameterBlock<X>`
- // we can construct a layout from the element type directly.
- //
- auto elementTypeLayout = slangLeafTypeLayout->getElementTypeLayout();
- createForElementType(
- m_renderer,
- m_session,
- elementTypeLayout,
- subObjectLayout.writeRef());
- }
- break;
+ {
+ // In the case of `ConstantBuffer<X>` or `ParameterBlock<X>`
+ // we can construct a layout from the element type directly.
+ //
+ auto elementTypeLayout = slangLeafTypeLayout->getElementTypeLayout();
+ createForElementType(
+ m_renderer,
+ m_session,
+ elementTypeLayout,
+ subObjectLayout.writeRef());
+ }
+ break;
case slang::BindingType::ExistentialValue:
// In the case of an interface-type sub-object range, we can only
@@ -207,8 +207,9 @@ Result ShaderObjectLayoutImpl::Builder::setElementTypeLayout(slang::TypeLayoutRe
// increase the size of the ordinary data buffer we need to
// allocate for the parent object.
//
- uint32_t ordinaryDataEnd = subObjectRange.offset.pendingOrdinaryData
- + (uint32_t)bindingRange.count * subObjectRange.stride.pendingOrdinaryData;
+ uint32_t ordinaryDataEnd =
+ subObjectRange.offset.pendingOrdinaryData +
+ (uint32_t)bindingRange.count * subObjectRange.stride.pendingOrdinaryData;
if (ordinaryDataEnd > m_totalOrdinaryDataSize)
{
@@ -225,8 +226,7 @@ Result ShaderObjectLayoutImpl::Builder::setElementTypeLayout(slang::TypeLayoutRe
SlangResult ShaderObjectLayoutImpl::Builder::build(ShaderObjectLayoutImpl** outLayout)
{
- auto layout =
- RefPtr<ShaderObjectLayoutImpl>(new ShaderObjectLayoutImpl());
+ auto layout = RefPtr<ShaderObjectLayoutImpl>(new ShaderObjectLayoutImpl());
SLANG_RETURN_ON_FAIL(layout->_init(this));
returnRefPtrMove(outLayout, layout);
@@ -276,14 +276,17 @@ Result RootShaderObjectLayoutImpl::Builder::build(RootShaderObjectLayoutImpl** o
return SLANG_OK;
}
-void RootShaderObjectLayoutImpl::Builder::addGlobalParams(slang::VariableLayoutReflection* globalsLayout)
+void RootShaderObjectLayoutImpl::Builder::addGlobalParams(
+ slang::VariableLayoutReflection* globalsLayout)
{
setElementTypeLayout(globalsLayout->getTypeLayout());
m_pendingDataOffset = BindingOffset(globalsLayout).pending;
}
void RootShaderObjectLayoutImpl::Builder::addEntryPoint(
- SlangStage stage, ShaderObjectLayoutImpl* entryPointLayout, slang::EntryPointLayout* slangEntryPoint)
+ SlangStage stage,
+ ShaderObjectLayoutImpl* entryPointLayout,
+ slang::EntryPointLayout* slangEntryPoint)
{
EntryPointInfo info;
info.layout = entryPointLayout;
@@ -306,7 +309,10 @@ Result RootShaderObjectLayoutImpl::create(
auto slangEntryPoint = programLayout->getEntryPointByIndex(e);
RefPtr<ShaderObjectLayoutImpl> entryPointLayout;
SLANG_RETURN_ON_FAIL(ShaderObjectLayoutImpl::createForElementType(
- renderer, program->getSession(), slangEntryPoint->getTypeLayout(), entryPointLayout.writeRef()));
+ renderer,
+ program->getSession(),
+ slangEntryPoint->getTypeLayout(),
+ entryPointLayout.writeRef()));
builder.addEntryPoint(slangEntryPoint->getStage(), entryPointLayout, slangEntryPoint);
}
diff --git a/tools/gfx/d3d11/d3d11-shader-object-layout.h b/tools/gfx/d3d11/d3d11-shader-object-layout.h
index e18c91c2e..16cd6c714 100644
--- a/tools/gfx/d3d11/d3d11-shader-object-layout.h
+++ b/tools/gfx/d3d11/d3d11-shader-object-layout.h
@@ -29,31 +29,31 @@ public:
// API, and a shader object layout will store information about those
// ranges in a form that is usable for the D3D11 API:
- /// Information about a logical binding range as reported by Slang reflection
+ /// Information about a logical binding range as reported by Slang reflection
struct BindingRangeInfo
{
- /// The type of bindings in this range
+ /// The type of bindings in this range
slang::BindingType bindingType;
- /// The number of bindings in this range
+ /// The number of bindings in this range
Index count;
- /// The starting index for this range in the appropriate "flat" array in a shader object.
- /// E.g., for a shader resource view range, this would be an index into the `m_srvs` array.
+ /// The starting index for this range in the appropriate "flat" array in a shader object.
+ /// E.g., for a shader resource view range, this would be an index into the `m_srvs` array.
Index baseIndex;
- /// The offset of this binding range from the start of the sub-object
- /// in terms of whatever D3D11 register class it consumes. E.g., for
- /// a `Texture2D` binding range this will represent an offset in
- /// `t` registers.
- ///
+ /// The offset of this binding range from the start of the sub-object
+ /// in terms of whatever D3D11 register class it consumes. E.g., for
+ /// a `Texture2D` binding range this will represent an offset in
+ /// `t` registers.
+ ///
uint32_t registerOffset;
- /// An index into the sub-object array if this binding range is treated
- /// as a sub-object.
+ /// An index into the sub-object array if this binding range is treated
+ /// as a sub-object.
Index subObjectIndex;
- /// Is this binding range specializable, e.g. an existential value or ParameterBlock<IFoo>.
+ /// Is this binding range specializable, e.g. an existential value or ParameterBlock<IFoo>.
bool isSpecializable;
};
@@ -64,43 +64,41 @@ public:
// For that reason we also store pre-computed information about each
// sub-object range.
- /// Offset information for a sub-object range
+ /// Offset information for a sub-object range
struct SubObjectRangeOffset : BindingOffset
{
- SubObjectRangeOffset()
- {}
+ SubObjectRangeOffset() {}
SubObjectRangeOffset(slang::VariableLayoutReflection* varLayout);
- /// The offset for "pending" ordinary data related to this range
+ /// The offset for "pending" ordinary data related to this range
uint32_t pendingOrdinaryData = 0;
};
- /// Stride information for a sub-object range
+ /// Stride information for a sub-object range
struct SubObjectRangeStride : BindingOffset
{
- SubObjectRangeStride()
- {}
+ SubObjectRangeStride() {}
SubObjectRangeStride(slang::TypeLayoutReflection* typeLayout);
- /// The strid for "pending" ordinary data related to this range
+ /// The strid for "pending" ordinary data related to this range
uint32_t pendingOrdinaryData = 0;
};
- /// Information about a logical binding range as reported by Slang reflection
+ /// Information about a logical binding range as reported by Slang reflection
struct SubObjectRangeInfo
{
- /// The index of the binding range that corresponds to this sub-object range
+ /// The index of the binding range that corresponds to this sub-object range
Index bindingRangeIndex;
- /// The layout expected for objects bound to this range (if known)
+ /// The layout expected for objects bound to this range (if known)
RefPtr<ShaderObjectLayoutImpl> layout;
- /// The offset to use when binding the first object in this range
+ /// The offset to use when binding the first object in this range
SubObjectRangeOffset offset;
- /// Stride between consecutive objects in this range
+ /// Stride between consecutive objects in this range
SubObjectRangeStride stride;
};
@@ -109,7 +107,8 @@ public:
public:
Builder(RendererBase* renderer, slang::ISession* session)
: m_renderer(renderer), m_session(session)
- {}
+ {
+ }
RendererBase* m_renderer;
slang::ISession* m_session;
@@ -118,13 +117,13 @@ public:
List<BindingRangeInfo> m_bindingRanges;
List<SubObjectRangeInfo> m_subObjectRanges;
- /// The indices of the binding ranges that represent SRVs
+ /// The indices of the binding ranges that represent SRVs
List<Index> m_srvRanges;
- /// The indices of the binding ranges that represent UAVs
+ /// The indices of the binding ranges that represent UAVs
List<Index> m_uavRanges;
- /// The indices of the binding ranges that represent samplers
+ /// The indices of the binding ranges that represent samplers
List<Index> m_samplerRanges;
Index m_srvCount = 0;
@@ -133,10 +132,10 @@ public:
Index m_subObjectCount = 0;
uint32_t m_totalOrdinaryDataSize = 0;
-
- /// The container type of this shader object. When `m_containerType` is
- /// `StructuredBuffer` or `UnsizedArray`, this shader object represents a collection
- /// instead of a single object.
+
+ /// The container type of this shader object. When `m_containerType` is
+ /// `StructuredBuffer` or `UnsizedArray`, this shader object represents a collection
+ /// instead of a single object.
ShaderObjectContainerType m_containerType = ShaderObjectContainerType::None;
Result setElementTypeLayout(slang::TypeLayoutReflection* typeLayout);
@@ -166,18 +165,15 @@ public:
RendererBase* getRenderer() { return m_renderer; }
- slang::TypeReflection* getType()
- {
- return m_elementTypeLayout->getType();
- }
+ slang::TypeReflection* getType() { return m_elementTypeLayout->getType(); }
- /// Get the indices that represent all the SRV ranges in this type
+ /// Get the indices that represent all the SRV ranges in this type
List<Index> const& getSRVRanges() const { return m_srvRanges; }
- /// Get the indices that reprsent all the UAV ranges in this type
+ /// Get the indices that reprsent all the UAV ranges in this type
List<Index> const& getUAVRanges() const { return m_uavRanges; }
- /// Get the indices that represnet all the sampler ranges in this type
+ /// Get the indices that represnet all the sampler ranges in this type
List<Index> const& getSamplerRanges() const { return m_samplerRanges; }
uint32_t getTotalOrdinaryDataSize() const { return m_totalOrdinaryDataSize; }
@@ -206,10 +202,11 @@ class RootShaderObjectLayoutImpl : public ShaderObjectLayoutImpl
public:
struct EntryPointInfo
{
- RefPtr<ShaderObjectLayoutImpl> layout;
+ RefPtr<ShaderObjectLayoutImpl> layout;
- /// The offset for this entry point's parameters, relative to the starting offset for the program
- BindingOffset offset;
+ /// The offset for this entry point's parameters, relative to the starting offset for the
+ /// program
+ BindingOffset offset;
};
struct Builder : Super::Builder
@@ -221,16 +218,20 @@ public:
: Super::Builder(renderer, program->getSession())
, m_program(program)
, m_programLayout(programLayout)
- {}
+ {
+ }
Result build(RootShaderObjectLayoutImpl** outLayout);
void addGlobalParams(slang::VariableLayoutReflection* globalsLayout);
- void addEntryPoint(SlangStage stage, ShaderObjectLayoutImpl* entryPointLayout, slang::EntryPointLayout* slangEntryPoint);
-
- slang::IComponentType* m_program;
- slang::ProgramLayout* m_programLayout;
- List<EntryPointInfo> m_entryPoints;
- SimpleBindingOffset m_pendingDataOffset;
+ void addEntryPoint(
+ SlangStage stage,
+ ShaderObjectLayoutImpl* entryPointLayout,
+ slang::EntryPointLayout* slangEntryPoint);
+
+ slang::IComponentType* m_program;
+ slang::ProgramLayout* m_programLayout;
+ List<EntryPointInfo> m_entryPoints;
+ SimpleBindingOffset m_pendingDataOffset;
};
EntryPointInfo& getEntryPoint(Index index) { return m_entryPoints[index]; }
@@ -246,13 +247,13 @@ public:
slang::IComponentType* getSlangProgram() const { return m_program; }
slang::ProgramLayout* getSlangProgramLayout() const { return m_programLayout; }
- /// Get the offset at which "pending" shader parameters for this program start
+ /// Get the offset at which "pending" shader parameters for this program start
SimpleBindingOffset const& getPendingDataOffset() const { return m_pendingDataOffset; }
protected:
Result _init(Builder const* builder);
- ComPtr<slang::IComponentType> m_program;
+ ComPtr<slang::IComponentType> m_program;
slang::ProgramLayout* m_programLayout = nullptr;
List<EntryPointInfo> m_entryPoints;
diff --git a/tools/gfx/d3d11/d3d11-shader-object.cpp b/tools/gfx/d3d11/d3d11-shader-object.cpp
index a83b115fa..697d463fb 100644
--- a/tools/gfx/d3d11/d3d11-shader-object.cpp
+++ b/tools/gfx/d3d11/d3d11-shader-object.cpp
@@ -24,7 +24,7 @@ Result ShaderObjectImpl::create(
}
SLANG_NO_THROW Result SLANG_MCALL
- ShaderObjectImpl::setData(ShaderOffset const& inOffset, void const* data, size_t inSize)
+ShaderObjectImpl::setData(ShaderOffset const& inOffset, void const* data, size_t inSize)
{
Index offset = inOffset.uniformOffset;
Index size = inSize;
@@ -54,7 +54,7 @@ SLANG_NO_THROW Result SLANG_MCALL
}
SLANG_NO_THROW Result SLANG_MCALL
- ShaderObjectImpl::setResource(ShaderOffset const& offset, IResourceView* resourceView)
+ShaderObjectImpl::setResource(ShaderOffset const& offset, IResourceView* resourceView)
{
if (offset.bindingRangeIndex < 0)
return SLANG_E_INVALID_ARG;
@@ -67,17 +67,20 @@ SLANG_NO_THROW Result SLANG_MCALL
if (D3DUtil::isUAVBinding(bindingRange.bindingType))
{
SLANG_ASSERT(resourceViewImpl->m_type == ResourceViewImpl::Type::UAV);
- m_uavs[bindingRange.baseIndex + offset.bindingArrayIndex] = static_cast<UnorderedAccessViewImpl*>(resourceView);
+ m_uavs[bindingRange.baseIndex + offset.bindingArrayIndex] =
+ static_cast<UnorderedAccessViewImpl*>(resourceView);
}
else
{
SLANG_ASSERT(resourceViewImpl->m_type == ResourceViewImpl::Type::SRV);
- m_srvs[bindingRange.baseIndex + offset.bindingArrayIndex] = static_cast<ShaderResourceViewImpl*>(resourceView);
+ m_srvs[bindingRange.baseIndex + offset.bindingArrayIndex] =
+ static_cast<ShaderResourceViewImpl*>(resourceView);
}
return SLANG_OK;
}
-SLANG_NO_THROW Result SLANG_MCALL ShaderObjectImpl::setSampler(ShaderOffset const& offset, ISamplerState* sampler)
+SLANG_NO_THROW Result SLANG_MCALL
+ShaderObjectImpl::setSampler(ShaderOffset const& offset, ISamplerState* sampler)
{
if (offset.bindingRangeIndex < 0)
return SLANG_E_INVALID_ARG;
@@ -86,7 +89,8 @@ SLANG_NO_THROW Result SLANG_MCALL ShaderObjectImpl::setSampler(ShaderOffset cons
return SLANG_E_INVALID_ARG;
auto& bindingRange = layout->getBindingRange(offset.bindingRangeIndex);
- m_samplers[bindingRange.baseIndex + offset.bindingArrayIndex] = static_cast<SamplerStateImpl*>(sampler);
+ m_samplers[bindingRange.baseIndex + offset.bindingArrayIndex] =
+ static_cast<SamplerStateImpl*>(sampler);
return SLANG_OK;
}
@@ -152,7 +156,7 @@ Result ShaderObjectImpl::init(IDevice* device, ShaderObjectLayoutImpl* layout)
Result ShaderObjectImpl::_writeOrdinaryData(
void* dest,
- size_t destSize,
+ size_t destSize,
ShaderObjectLayoutImpl* specializedLayout)
{
// We start by simply writing in the ordinary data contained directly in this object.
@@ -180,7 +184,8 @@ Result ShaderObjectImpl::_writeOrdinaryData(
for (auto const& subObjectRangeInfo : specializedLayout->getSubObjectRanges())
{
Index subObjectRangeIndex = subObjectRangeCounter++;
- auto const& bindingRangeInfo = specializedLayout->getBindingRange(subObjectRangeInfo.bindingRangeIndex);
+ auto const& bindingRangeInfo =
+ specializedLayout->getBindingRange(subObjectRangeInfo.bindingRangeIndex);
// We only need to handle sub-object ranges for interface/existential-type fields,
// because fields of constant-buffer or parameter-block type are responsible for
@@ -234,11 +239,15 @@ Result ShaderObjectImpl::_writeOrdinaryData(
RefPtr<ShaderObjectLayoutImpl> subObjectLayout;
SLANG_RETURN_ON_FAIL(subObject->_getSpecializedLayout(subObjectLayout.writeRef()));
- auto subObjectOffset = subObjectRangePendingDataOffset + i * subObjectRangePendingDataStride;
+ auto subObjectOffset =
+ subObjectRangePendingDataOffset + i * subObjectRangePendingDataStride;
auto subObjectDest = (char*)dest + subObjectOffset;
- subObject->_writeOrdinaryData(subObjectDest, destSize - subObjectOffset, subObjectLayout);
+ subObject->_writeOrdinaryData(
+ subObjectDest,
+ destSize - subObjectOffset,
+ subObjectLayout);
}
}
@@ -280,7 +289,8 @@ Result ShaderObjectImpl::_ensureOrdinaryDataBufferCreatedIfNeeded(
//
auto ordinaryData = device->map(m_ordinaryDataBuffer, gfx::MapFlavor::WriteDiscard);
- auto result = _writeOrdinaryData(ordinaryData, specializedOrdinaryDataSize, specializedLayout);
+ auto result =
+ _writeOrdinaryData(ordinaryData, specializedOrdinaryDataSize, specializedLayout);
device->unmap(m_ordinaryDataBuffer, 0, specializedOrdinaryDataSize);
m_isConstantBufferDirty = false;
return result;
@@ -295,7 +305,8 @@ Result ShaderObjectImpl::_bindOrdinaryDataBufferIfNeeded(
{
// We start by ensuring that the buffer is created, if it is needed.
//
- SLANG_RETURN_ON_FAIL(_ensureOrdinaryDataBufferCreatedIfNeeded(context->device, specializedLayout));
+ SLANG_RETURN_ON_FAIL(
+ _ensureOrdinaryDataBufferCreatedIfNeeded(context->device, specializedLayout));
// If we did indeed need/create a buffer, then we must bind it
// into root binding state.
@@ -319,7 +330,8 @@ Result ShaderObjectImpl::bindAsConstantBuffer(
// resources and sub-objects.
//
BindingOffset offset = inOffset;
- SLANG_RETURN_ON_FAIL(_bindOrdinaryDataBufferIfNeeded(context, /*inout*/ offset, specializedLayout));
+ SLANG_RETURN_ON_FAIL(
+ _bindOrdinaryDataBufferIfNeeded(context, /*inout*/ offset, specializedLayout));
// Once the ordinary data buffer is bound, we can move on to binding
// the rest of the state, which can use logic shared with the case
@@ -403,7 +415,8 @@ Result ShaderObjectImpl::bindAsValue(
for (auto const& subObjectRange : specializedLayout->getSubObjectRanges())
{
auto subObjectLayout = subObjectRange.layout;
- auto const& bindingRange = specializedLayout->getBindingRange(subObjectRange.bindingRangeIndex);
+ auto const& bindingRange =
+ specializedLayout->getBindingRange(subObjectRange.bindingRangeIndex);
Index count = bindingRange.count;
Index subObjectIndex = bindingRange.subObjectIndex;
@@ -425,21 +438,21 @@ Result ShaderObjectImpl::bindAsValue(
//
case slang::BindingType::ConstantBuffer:
case slang::BindingType::ParameterBlock:
- {
- BindingOffset objOffset = rangeOffset;
- for (Index i = 0; i < count; ++i)
{
- auto subObject = m_objects[subObjectIndex + i];
+ BindingOffset objOffset = rangeOffset;
+ for (Index i = 0; i < count; ++i)
+ {
+ auto subObject = m_objects[subObjectIndex + i];
- // Unsurprisingly, we bind each object in the range as
- // a constant buffer.
- //
- subObject->bindAsConstantBuffer(context, objOffset, subObjectLayout);
+ // Unsurprisingly, we bind each object in the range as
+ // a constant buffer.
+ //
+ subObject->bindAsConstantBuffer(context, objOffset, subObjectLayout);
- objOffset += rangeStride;
+ objOffset += rangeStride;
+ }
}
- }
- break;
+ break;
case slang::BindingType::ExistentialValue:
// We can only bind information for existential-typed sub-object
@@ -465,8 +478,7 @@ Result ShaderObjectImpl::bindAsValue(
}
break;
- default:
- break;
+ default: break;
}
}
@@ -552,7 +564,10 @@ Result RootShaderObjectImpl::bindAsRoot(
// really be querying an appropriate absolute offset from `specializedLayout`.
//
BindingOffset ordinaryDataBufferOffset = offset;
- SLANG_RETURN_ON_FAIL(_bindOrdinaryDataBufferIfNeeded(context, /*inout*/ ordinaryDataBufferOffset, specializedLayout));
+ SLANG_RETURN_ON_FAIL(_bindOrdinaryDataBufferIfNeeded(
+ context,
+ /*inout*/ ordinaryDataBufferOffset,
+ specializedLayout));
SLANG_RETURN_ON_FAIL(bindAsValue(context, offset, specializedLayout));
// Once the state stored in the root shader object itself has been bound,
@@ -574,7 +589,8 @@ Result RootShaderObjectImpl::bindAsRoot(
// the absolute offsets as are used for the global scope do not apply
// (because entry points don't need to deal with explicit bindings).
//
- SLANG_RETURN_ON_FAIL(entryPoint->bindAsConstantBuffer(context, entryPointOffset, entryPointInfo.layout));
+ SLANG_RETURN_ON_FAIL(
+ entryPoint->bindAsConstantBuffer(context, entryPointOffset, entryPointInfo.layout));
}
return SLANG_OK;
@@ -652,7 +668,11 @@ Result RootShaderObjectImpl::_createSpecializedLayout(ShaderObjectLayoutImpl** o
auto slangSpecializedLayout = specializedComponentType->getLayout();
RefPtr<RootShaderObjectLayoutImpl> specializedLayout;
- RootShaderObjectLayoutImpl::create(getRenderer(), specializedComponentType, slangSpecializedLayout, specializedLayout.writeRef());
+ RootShaderObjectLayoutImpl::create(
+ getRenderer(),
+ specializedComponentType,
+ slangSpecializedLayout,
+ specializedLayout.writeRef());
// Note: Computing the layout for the specialized program will have also computed
// the layouts for the entry points, and we really need to attach that information
diff --git a/tools/gfx/d3d11/d3d11-shader-object.h b/tools/gfx/d3d11/d3d11-shader-object.h
index b4e43c3ee..62fb4cf62 100644
--- a/tools/gfx/d3d11/d3d11-shader-object.h
+++ b/tools/gfx/d3d11/d3d11-shader-object.h
@@ -1,14 +1,12 @@
// d3d11-shader-object.h
#pragma once
#include "d3d11-base.h"
-
#include "d3d11-buffer.h"
+#include "d3d11-helper-functions.h"
#include "d3d11-resource-views.h"
#include "d3d11-sampler.h"
#include "d3d11-shader-object-layout.h"
-#include "d3d11-helper-functions.h"
-
namespace gfx
{
@@ -18,10 +16,7 @@ namespace d3d11
{
class ShaderObjectImpl
- : public ShaderObjectBaseImpl<
- ShaderObjectImpl,
- ShaderObjectLayoutImpl,
- SimpleShaderObjectData>
+ : public ShaderObjectBaseImpl<ShaderObjectImpl, ShaderObjectLayoutImpl, SimpleShaderObjectData>
{
public:
static Result create(
@@ -51,67 +46,68 @@ public:
}
SLANG_NO_THROW Result SLANG_MCALL
- setData(ShaderOffset const& inOffset, void const* data, size_t inSize) SLANG_OVERRIDE;
+ setData(ShaderOffset const& inOffset, void const* data, size_t inSize) SLANG_OVERRIDE;
SLANG_NO_THROW Result SLANG_MCALL
- setResource(ShaderOffset const& offset, IResourceView* resourceView) SLANG_OVERRIDE;
+ setResource(ShaderOffset const& offset, IResourceView* resourceView) SLANG_OVERRIDE;
SLANG_NO_THROW Result SLANG_MCALL setSampler(ShaderOffset const& offset, ISamplerState* sampler)
SLANG_OVERRIDE;
SLANG_NO_THROW Result SLANG_MCALL setCombinedTextureSampler(
- ShaderOffset const& offset, IResourceView* textureView, ISamplerState* sampler) SLANG_OVERRIDE
+ ShaderOffset const& offset,
+ IResourceView* textureView,
+ ISamplerState* sampler) SLANG_OVERRIDE
{
return SLANG_E_NOT_IMPLEMENTED;
}
public:
-
-
protected:
friend class ProgramVars;
Result init(IDevice* device, ShaderObjectLayoutImpl* layout);
- /// Write the uniform/ordinary data of this object into the given `dest` buffer at the given `offset`
+ /// Write the uniform/ordinary data of this object into the given `dest` buffer at the given
+ /// `offset`
Result _writeOrdinaryData(
void* dest,
- size_t destSize,
+ size_t destSize,
ShaderObjectLayoutImpl* specializedLayout);
- /// Ensure that the `m_ordinaryDataBuffer` has been created, if it is needed
- ///
- /// The `specializedLayout` type must represent a specialized layout for this
- /// type that includes any "pending" data.
- ///
+ /// Ensure that the `m_ordinaryDataBuffer` has been created, if it is needed
+ ///
+ /// The `specializedLayout` type must represent a specialized layout for this
+ /// type that includes any "pending" data.
+ ///
Result _ensureOrdinaryDataBufferCreatedIfNeeded(
DeviceImpl* device,
ShaderObjectLayoutImpl* specializedLayout);
- /// Bind the buffer for ordinary/uniform data, if needed
- ///
- /// The `ioOffset` parameter will be updated to reflect the constant buffer
- /// register consumed by the ordinary data buffer, if one was bound.
- ///
+ /// Bind the buffer for ordinary/uniform data, if needed
+ ///
+ /// The `ioOffset` parameter will be updated to reflect the constant buffer
+ /// register consumed by the ordinary data buffer, if one was bound.
+ ///
Result _bindOrdinaryDataBufferIfNeeded(
BindingContext* context,
BindingOffset& ioOffset,
ShaderObjectLayoutImpl* specializedLayout);
public:
- /// Bind this object as if it was declared as a `ConstantBuffer<T>` in Slang
+ /// Bind this object as if it was declared as a `ConstantBuffer<T>` in Slang
Result bindAsConstantBuffer(
BindingContext* context,
BindingOffset const& inOffset,
ShaderObjectLayoutImpl* specializedLayout);
- /// Bind this object as a value that appears in the body of another object.
- ///
- /// This case is directly used when binding an object for an interface-type
- /// sub-object range when static specialization is used. It is also used
- /// indirectly when binding sub-objects to constant buffer or parameter
- /// block ranges.
- ///
+ /// Bind this object as a value that appears in the body of another object.
+ ///
+ /// This case is directly used when binding an object for an interface-type
+ /// sub-object range when static specialization is used. It is also used
+ /// indirectly when binding sub-objects to constant buffer or parameter
+ /// block ranges.
+ ///
Result bindAsValue(
BindingContext* context,
BindingOffset const& offset,
@@ -121,28 +117,28 @@ public:
// and organized as part of each shader object layout,
// the object itself can store its data in a small number
// of simple arrays.
- /// The shader resource views (SRVs) that are part of the state of this object
+ /// The shader resource views (SRVs) that are part of the state of this object
List<RefPtr<ShaderResourceViewImpl>> m_srvs;
- /// The unordered access views (UAVs) that are part of the state of this object
+ /// The unordered access views (UAVs) that are part of the state of this object
List<RefPtr<UnorderedAccessViewImpl>> m_uavs;
- /// The samplers that are part of the state of this object
+ /// The samplers that are part of the state of this object
List<RefPtr<SamplerStateImpl>> m_samplers;
- /// A constant buffer used to stored ordinary data for this object
- /// and existential-type sub-objects.
- ///
- /// Created on demand with `_createOrdinaryDataBufferIfNeeded()`
+ /// A constant buffer used to stored ordinary data for this object
+ /// and existential-type sub-objects.
+ ///
+ /// Created on demand with `_createOrdinaryDataBufferIfNeeded()`
RefPtr<BufferResourceImpl> m_ordinaryDataBuffer;
bool m_isConstantBufferDirty = true;
- /// Get the layout of this shader object with specialization arguments considered
- ///
- /// This operation should only be called after the shader object has been
- /// fully filled in and finalized.
- ///
+ /// Get the layout of this shader object with specialization arguments considered
+ ///
+ /// This operation should only be called after the shader object has been
+ /// fully filled in and finalized.
+ ///
Result _getSpecializedLayout(ShaderObjectLayoutImpl** outLayout);
/// Create the layout for this shader object with specialization arguments considered
@@ -155,10 +151,9 @@ public:
};
class MutableShaderObjectImpl
- : public MutableShaderObject<
- MutableShaderObjectImpl,
- ShaderObjectLayoutImpl>
-{};
+ : public MutableShaderObject<MutableShaderObjectImpl, ShaderObjectLayoutImpl>
+{
+};
class RootShaderObjectImpl : public ShaderObjectImpl
{
@@ -168,12 +163,22 @@ public:
virtual SLANG_NO_THROW uint32_t SLANG_MCALL addRef() override { return 1; }
virtual SLANG_NO_THROW uint32_t SLANG_MCALL release() override { return 1; }
- static Result create(IDevice* device, RootShaderObjectLayoutImpl* layout, RootShaderObjectImpl** outShaderObject);
+ static Result create(
+ IDevice* device,
+ RootShaderObjectLayoutImpl* layout,
+ RootShaderObjectImpl** outShaderObject);
- RootShaderObjectLayoutImpl* getLayout() { return static_cast<RootShaderObjectLayoutImpl*>(m_layout.Ptr()); }
+ RootShaderObjectLayoutImpl* getLayout()
+ {
+ return static_cast<RootShaderObjectLayoutImpl*>(m_layout.Ptr());
+ }
- GfxCount SLANG_MCALL getEntryPointCount() SLANG_OVERRIDE { return (GfxCount)m_entryPoints.getCount(); }
- SlangResult SLANG_MCALL getEntryPoint(GfxIndex index, IShaderObject** outEntryPoint) SLANG_OVERRIDE
+ GfxCount SLANG_MCALL getEntryPointCount() SLANG_OVERRIDE
+ {
+ return (GfxCount)m_entryPoints.getCount();
+ }
+ SlangResult SLANG_MCALL getEntryPoint(GfxIndex index, IShaderObject** outEntryPoint)
+ SLANG_OVERRIDE
{
returnComPtr(outEntryPoint, m_entryPoints[index]);
return SLANG_OK;
@@ -181,10 +186,8 @@ public:
virtual Result collectSpecializationArgs(ExtendedShaderObjectTypeList& args) override;
- /// Bind this object as a root shader object
- Result bindAsRoot(
- BindingContext* context,
- RootShaderObjectLayoutImpl* specializedLayout);
+ /// Bind this object as a root shader object
+ Result bindAsRoot(BindingContext* context, RootShaderObjectLayoutImpl* specializedLayout);
protected:
diff --git a/tools/gfx/d3d11/d3d11-shader-program.cpp b/tools/gfx/d3d11/d3d11-shader-program.cpp
index f957f6353..16f73c984 100644
--- a/tools/gfx/d3d11/d3d11-shader-program.cpp
+++ b/tools/gfx/d3d11/d3d11-shader-program.cpp
@@ -12,6 +12,5 @@ namespace d3d11
{
-
} // namespace d3d11
} // namespace gfx
diff --git a/tools/gfx/d3d11/d3d11-swap-chain.cpp b/tools/gfx/d3d11/d3d11-swap-chain.cpp
index 177fb89dd..8eb8d66d6 100644
--- a/tools/gfx/d3d11/d3d11-swap-chain.cpp
+++ b/tools/gfx/d3d11/d3d11-swap-chain.cpp
@@ -12,7 +12,10 @@ using namespace Slang;
namespace d3d11
{
-Result SwapchainImpl::init(DeviceImpl* renderer, const ISwapchain::Desc& swapchainDesc, WindowHandle window)
+Result SwapchainImpl::init(
+ DeviceImpl* renderer,
+ const ISwapchain::Desc& swapchainDesc,
+ WindowHandle window)
{
m_renderer = renderer;
m_device = renderer->m_device;
diff --git a/tools/gfx/d3d11/d3d11-texture.h b/tools/gfx/d3d11/d3d11-texture.h
index fb88d2b76..81e3b2a82 100644
--- a/tools/gfx/d3d11/d3d11-texture.h
+++ b/tools/gfx/d3d11/d3d11-texture.h
@@ -21,7 +21,6 @@ public:
{
}
ComPtr<ID3D11Resource> m_resource;
-
};
} // namespace d3d11
diff --git a/tools/gfx/d3d11/d3d11-vertex-layout.h b/tools/gfx/d3d11/d3d11-vertex-layout.h
index 9c3f1cd46..1908e8cce 100644
--- a/tools/gfx/d3d11/d3d11-vertex-layout.h
+++ b/tools/gfx/d3d11/d3d11-vertex-layout.h
@@ -11,10 +11,10 @@ using namespace Slang;
namespace d3d11
{
-class InputLayoutImpl: public InputLayoutBase
+class InputLayoutImpl : public InputLayoutBase
{
public:
- ComPtr<ID3D11InputLayout> m_layout;
+ ComPtr<ID3D11InputLayout> m_layout;
List<UINT> m_vertexStreamStrides;
};