yum-mirror/slang

Making it easier to work with shaders

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

Ellie Hermaszewskaformatf65d756bf

master
3.0 KiB108 linesraw
1// d3d12-submitter.cpp
2#include "d3d12-submitter.h"
3
4#include "d3d12-pipeline-state.h"
5
6namespace gfx
7{
8namespace d3d12
9{
10
11using namespace Slang;
12
13void GraphicsSubmitter::setRootConstantBufferView(
14    int index,
15    D3D12_GPU_VIRTUAL_ADDRESS gpuBufferLocation)
16{
17    m_commandList->SetGraphicsRootConstantBufferView(index, gpuBufferLocation);
18}
19
20void GraphicsSubmitter::setRootUAV(int index, D3D12_GPU_VIRTUAL_ADDRESS gpuBufferLocation)
21{
22    m_commandList->SetGraphicsRootUnorderedAccessView(index, gpuBufferLocation);
23}
24
25void GraphicsSubmitter::setRootSRV(int index, D3D12_GPU_VIRTUAL_ADDRESS gpuBufferLocation)
26{
27    m_commandList->SetGraphicsRootShaderResourceView(index, gpuBufferLocation);
28}
29
30void GraphicsSubmitter::setRootDescriptorTable(
31    int index,
32    D3D12_GPU_DESCRIPTOR_HANDLE baseDescriptor)
33{
34    m_commandList->SetGraphicsRootDescriptorTable(index, baseDescriptor);
35}
36
37void GraphicsSubmitter::setRootSignature(ID3D12RootSignature* rootSignature)
38{
39    m_commandList->SetGraphicsRootSignature(rootSignature);
40}
41
42void GraphicsSubmitter::setRootConstants(
43    Index rootParamIndex,
44    Index dstOffsetIn32BitValues,
45    Index countOf32BitValues,
46    void const* srcData)
47{
48    m_commandList->SetGraphicsRoot32BitConstants(
49        UINT(rootParamIndex),
50        UINT(countOf32BitValues),
51        srcData,
52        UINT(dstOffsetIn32BitValues));
53}
54
55void GraphicsSubmitter::setPipelineState(PipelineStateBase* pipeline)
56{
57    auto pipelineImpl = static_cast<PipelineStateImpl*>(pipeline);
58    m_commandList->SetPipelineState(pipelineImpl->m_pipelineState.get());
59}
60
61void ComputeSubmitter::setRootConstantBufferView(
62    int index,
63    D3D12_GPU_VIRTUAL_ADDRESS gpuBufferLocation)
64{
65    m_commandList->SetComputeRootConstantBufferView(index, gpuBufferLocation);
66}
67
68void ComputeSubmitter::setRootUAV(int index, D3D12_GPU_VIRTUAL_ADDRESS gpuBufferLocation)
69{
70    m_commandList->SetComputeRootUnorderedAccessView(index, gpuBufferLocation);
71}
72
73void ComputeSubmitter::setRootSRV(int index, D3D12_GPU_VIRTUAL_ADDRESS gpuBufferLocation)
74{
75    m_commandList->SetComputeRootShaderResourceView(index, gpuBufferLocation);
76}
77
78void ComputeSubmitter::setRootDescriptorTable(int index, D3D12_GPU_DESCRIPTOR_HANDLE baseDescriptor)
79{
80    m_commandList->SetComputeRootDescriptorTable(index, baseDescriptor);
81}
82
83void ComputeSubmitter::setRootSignature(ID3D12RootSignature* rootSignature)
84{
85    m_commandList->SetComputeRootSignature(rootSignature);
86}
87
88void ComputeSubmitter::setRootConstants(
89    Index rootParamIndex,
90    Index dstOffsetIn32BitValues,
91    Index countOf32BitValues,
92    void const* srcData)
93{
94    m_commandList->SetComputeRoot32BitConstants(
95        UINT(rootParamIndex),
96        UINT(countOf32BitValues),
97        srcData,
98        UINT(dstOffsetIn32BitValues));
99}
100
101void ComputeSubmitter::setPipelineState(PipelineStateBase* pipeline)
102{
103    auto pipelineImpl = static_cast<PipelineStateImpl*>(pipeline);
104    m_commandList->SetPipelineState(pipelineImpl->m_pipelineState.get());
105}
106
107} // namespace d3d12
108} // namespace gfx