1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
// cuda-command-encoder.h
#pragma once
#include "cuda-base.h"
namespace gfx
{
#ifdef GFX_ENABLE_CUDA
using namespace Slang;
namespace cuda
{
class ResourceCommandEncoderImpl : public IResourceCommandEncoder
{
public:
CommandWriter* m_writer;
virtual void* getInterface(SlangUUID const& uuid)
{
if (uuid == GfxGUID::IID_IResourceCommandEncoder || uuid == ISlangUnknown::getTypeGuid())
return this;
return nullptr;
}
virtual SLANG_NO_THROW SlangResult SLANG_MCALL
queryInterface(SlangUUID const& uuid, void** outObject) override
{
if (auto ptr = getInterface(uuid))
{
*outObject = ptr;
return SLANG_OK;
}
return SLANG_E_NO_INTERFACE;
}
virtual SLANG_NO_THROW uint32_t SLANG_MCALL addRef() override { return 1; }
virtual SLANG_NO_THROW uint32_t SLANG_MCALL release() override { return 1; }
void init(CommandBufferImpl* cmdBuffer);
virtual SLANG_NO_THROW void SLANG_MCALL endEncoding() override {}
virtual SLANG_NO_THROW void SLANG_MCALL copyBuffer(
IBufferResource* dst,
Offset dstOffset,
IBufferResource* src,
Offset srcOffset,
Size size) override;
virtual SLANG_NO_THROW void SLANG_MCALL textureBarrier(
GfxCount count,
ITextureResource* const* textures,
ResourceState src,
ResourceState dst) override
{
}
virtual SLANG_NO_THROW void SLANG_MCALL bufferBarrier(
GfxCount count,
IBufferResource* const* buffers,
ResourceState src,
ResourceState dst) override
{
}
virtual SLANG_NO_THROW void SLANG_MCALL
uploadBufferData(IBufferResource* dst, Offset offset, Size size, void* data) override;
virtual SLANG_NO_THROW void SLANG_MCALL
writeTimestamp(IQueryPool* pool, GfxIndex index) override;
virtual SLANG_NO_THROW void SLANG_MCALL copyTexture(
ITextureResource* dst,
ResourceState dstState,
SubresourceRange dstSubresource,
ITextureResource::Offset3D dstOffset,
ITextureResource* src,
ResourceState srcState,
SubresourceRange srcSubresource,
ITextureResource::Offset3D srcOffset,
ITextureResource::Extents extent) override;
virtual SLANG_NO_THROW void SLANG_MCALL uploadTextureData(
ITextureResource* dst,
SubresourceRange subResourceRange,
ITextureResource::Offset3D offset,
ITextureResource::Extents extent,
ITextureResource::SubresourceData* subResourceData,
GfxCount subResourceDataCount) override;
virtual SLANG_NO_THROW void SLANG_MCALL clearResourceView(
IResourceView* view,
ClearValue* clearValue,
ClearResourceViewFlags::Enum flags) override;
virtual SLANG_NO_THROW void SLANG_MCALL resolveResource(
ITextureResource* source,
ResourceState sourceState,
SubresourceRange sourceRange,
ITextureResource* dest,
ResourceState destState,
SubresourceRange destRange) override;
virtual SLANG_NO_THROW void SLANG_MCALL resolveQuery(
IQueryPool* queryPool,
GfxIndex index,
GfxCount count,
IBufferResource* buffer,
Offset offset) override;
virtual SLANG_NO_THROW void SLANG_MCALL copyTextureToBuffer(
IBufferResource* dst,
Offset dstOffset,
Size dstSize,
Size dstRowStride,
ITextureResource* src,
ResourceState srcState,
SubresourceRange srcSubresource,
ITextureResource::Offset3D srcOffset,
ITextureResource::Extents extent) override;
virtual SLANG_NO_THROW void SLANG_MCALL textureSubresourceBarrier(
ITextureResource* texture,
SubresourceRange subresourceRange,
ResourceState src,
ResourceState dst) override;
virtual SLANG_NO_THROW void SLANG_MCALL
beginDebugEvent(const char* name, float rgbColor[3]) override;
virtual SLANG_NO_THROW void SLANG_MCALL endDebugEvent() override {}
};
class ComputeCommandEncoderImpl : public IComputeCommandEncoder, public ResourceCommandEncoderImpl
{
public:
SLANG_GFX_FORWARD_RESOURCE_COMMAND_ENCODER_IMPL(ResourceCommandEncoderImpl)
virtual void* getInterface(SlangUUID const& uuid) override
{
if (uuid == GfxGUID::IID_IResourceCommandEncoder ||
uuid == GfxGUID::IID_IComputeCommandEncoder || uuid == ISlangUnknown::getTypeGuid())
return this;
return nullptr;
}
public:
CommandWriter* m_writer;
CommandBufferImpl* m_commandBuffer;
RefPtr<ShaderObjectBase> m_rootObject;
virtual SLANG_NO_THROW void SLANG_MCALL endEncoding() override {}
void init(CommandBufferImpl* cmdBuffer);
virtual SLANG_NO_THROW Result SLANG_MCALL
bindPipeline(IPipelineState* state, IShaderObject** outRootObject) override;
virtual SLANG_NO_THROW Result SLANG_MCALL
bindPipelineWithRootObject(IPipelineState* state, IShaderObject* rootObject) override;
virtual SLANG_NO_THROW Result SLANG_MCALL dispatchCompute(int x, int y, int z) override;
virtual SLANG_NO_THROW Result SLANG_MCALL
dispatchComputeIndirect(IBufferResource* argBuffer, Offset offset) override;
};
} // namespace cuda
#endif
} // namespace gfx
|