yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Ellie Hermaszewskaformatf65d756bf

master
2.9 KiB94 linesraw
1// d3d12-helper-functions.h
2#pragma once
3
4#include "../../../source/core/slang-list.h"
5#include "../../../source/core/slang-short-list.h"
6#include "d3d12-base.h"
7#include "d3d12-shader-object-layout.h"
8#include "d3d12-submitter.h"
9#include "slang-gfx.h"
10
11#ifndef __ID3D12GraphicsCommandList1_FWD_DEFINED__
12// If can't find a definition of CommandList1, just use an empty definition
13struct ID3D12GraphicsCommandList1
14{
15};
16#endif
17
18namespace gfx
19{
20
21using namespace Slang;
22
23namespace d3d12
24{
25struct PendingDescriptorTableBinding
26{
27    uint32_t rootIndex;
28    D3D12_GPU_DESCRIPTOR_HANDLE handle;
29};
30
31/// Contextual data and operations required when binding shader objects to the pipeline state
32struct BindingContext
33{
34    PipelineCommandEncoder* encoder;
35    Submitter* submitter;
36    TransientResourceHeapImpl* transientHeap;
37    DeviceImpl* device;
38    D3D12_DESCRIPTOR_HEAP_TYPE
39    outOfMemoryHeap; // The type of descriptor heap that is OOM during binding.
40    ShortList<PendingDescriptorTableBinding>* pendingTableBindings;
41};
42
43bool isSupportedNVAPIOp(ID3D12Device* dev, uint32_t op);
44
45D3D12_RESOURCE_FLAGS calcResourceFlag(ResourceState state);
46D3D12_RESOURCE_FLAGS calcResourceFlags(ResourceStateSet states);
47D3D12_RESOURCE_DIMENSION calcResourceDimension(IResource::Type type);
48
49DXGI_FORMAT getTypelessFormatFromDepthFormat(Format format);
50bool isTypelessDepthFormat(DXGI_FORMAT format);
51
52D3D12_FILTER_TYPE translateFilterMode(TextureFilteringMode mode);
53D3D12_FILTER_REDUCTION_TYPE translateFilterReduction(TextureReductionOp op);
54D3D12_TEXTURE_ADDRESS_MODE translateAddressingMode(TextureAddressingMode mode);
55D3D12_COMPARISON_FUNC translateComparisonFunc(ComparisonFunc func);
56
57uint32_t getViewDescriptorCount(const ITransientResourceHeap::Desc& desc);
58void initSrvDesc(
59    IResource::Type resourceType,
60    const ITextureResource::Desc& textureDesc,
61    const D3D12_RESOURCE_DESC& desc,
62    DXGI_FORMAT pixelFormat,
63    SubresourceRange subresourceRange,
64    D3D12_SHADER_RESOURCE_VIEW_DESC& descOut);
65Result initTextureResourceDesc(
66    D3D12_RESOURCE_DESC& resourceDesc,
67    const ITextureResource::Desc& srcDesc);
68void initBufferResourceDesc(Size bufferSize, D3D12_RESOURCE_DESC& out);
69Result uploadBufferDataImpl(
70    ID3D12Device* device,
71    ID3D12GraphicsCommandList* cmdList,
72    TransientResourceHeapImpl* transientHeap,
73    BufferResourceImpl* buffer,
74    Offset offset,
75    Size size,
76    void* data);
77
78Result createNullDescriptor(
79    ID3D12Device* d3dDevice,
80    D3D12_CPU_DESCRIPTOR_HANDLE destDescriptor,
81    const ShaderObjectLayoutImpl::BindingRangeInfo& bindingRange);
82
83void translatePostBuildInfoDescs(
84    int propertyQueryCount,
85    AccelerationStructureQueryDesc* queryDescs,
86    List<D3D12_RAYTRACING_ACCELERATION_STRUCTURE_POSTBUILD_INFO_DESC>& postBuildInfoDescs);
87
88} // namespace d3d12
89
90Result SLANG_MCALL getD3D12Adapters(List<AdapterInfo>& outAdapters);
91
92Result SLANG_MCALL createD3D12Device(const IDevice::Desc* desc, IDevice** outDevice);
93
94} // namespace gfx