yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f65d756bf
master
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{ 27uint32_t rootIndex ; 28D3D12_GPU_DESCRIPTOR_HANDLE handle ; 29}; 30 31/// Contextual data and operations required when binding shader objects to the pipeline state 32struct BindingContext 33{ 34PipelineCommandEncoder * encoder ; 35Submitter * submitter ; 36TransientResourceHeapImpl * transientHeap ; 37DeviceImpl * device ; 38D3D12_DESCRIPTOR_HEAP_TYPE 39outOfMemoryHeap ;// The type of descriptor heap that is OOM during binding. 40ShortList < 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 ( 59IResource ::Type resourceType , 60const ITextureResource ::Desc & textureDesc , 61const D3D12_RESOURCE_DESC & desc , 62DXGI_FORMAT pixelFormat , 63SubresourceRange subresourceRange , 64D3D12_SHADER_RESOURCE_VIEW_DESC & descOut ); 65Result initTextureResourceDesc ( 66D3D12_RESOURCE_DESC & resourceDesc , 67const ITextureResource ::Desc & srcDesc ); 68void initBufferResourceDesc (Size bufferSize ,D3D12_RESOURCE_DESC & out ); 69Result uploadBufferDataImpl ( 70ID3D12Device * device , 71ID3D12GraphicsCommandList * cmdList , 72TransientResourceHeapImpl * transientHeap , 73BufferResourceImpl * buffer , 74Offset offset , 75Size size , 76void * data ); 77 78Result createNullDescriptor ( 79ID3D12Device * d3dDevice , 80D3D12_CPU_DESCRIPTOR_HANDLE destDescriptor , 81const ShaderObjectLayoutImpl ::BindingRangeInfo & bindingRange ); 82 83void translatePostBuildInfoDescs ( 84int propertyQueryCount , 85AccelerationStructureQueryDesc * queryDescs , 86List < 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