yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f65d756bf
master
1// cuda-command-encoder.cpp 2#include "cuda-command-encoder.h" 3 4#include "cuda-command-buffer.h" 5#include "cuda-device.h" 6 7namespace gfx 8{ 9#ifdef GFX_ENABLE_CUDA 10using namespace Slang ; 11 12namespace cuda 13{ 14 15void ResourceCommandEncoderImpl ::init (CommandBufferImpl * cmdBuffer ) 16{ 17m_writer = cmdBuffer ; 18} 19 20SLANG_NO_THROW void SLANG_MCALL ResourceCommandEncoderImpl ::copyBuffer ( 21IBufferResource * dst , 22Offset dstOffset , 23IBufferResource * src , 24Offset srcOffset , 25Size size ) 26{ 27m_writer -> copyBuffer (dst ,dstOffset ,src ,srcOffset ,size ); 28} 29 30SLANG_NO_THROW void SLANG_MCALL ResourceCommandEncoderImpl ::uploadBufferData ( 31IBufferResource * dst , 32Offset offset , 33Size size , 34void * data ) 35{ 36m_writer -> uploadBufferData (dst ,offset ,size ,data ); 37} 38 39SLANG_NO_THROW void SLANG_MCALL 40ResourceCommandEncoderImpl ::writeTimestamp (IQueryPool * pool ,GfxIndex index ) 41{ 42m_writer -> writeTimestamp (pool ,index ); 43} 44 45SLANG_NO_THROW void SLANG_MCALL ResourceCommandEncoderImpl ::copyTexture ( 46ITextureResource * dst , 47ResourceState dstState , 48SubresourceRange dstSubresource , 49ITextureResource ::Offset3D dstOffset , 50ITextureResource * src , 51ResourceState srcState , 52SubresourceRange srcSubresource , 53ITextureResource ::Offset3D srcOffset , 54ITextureResource ::Extents extent ) 55{ 56SLANG_UNUSED (dst ); 57SLANG_UNUSED (dstState ); 58SLANG_UNUSED (dstSubresource ); 59SLANG_UNUSED (dstOffset ); 60SLANG_UNUSED (src ); 61SLANG_UNUSED (srcState ); 62SLANG_UNUSED (srcSubresource ); 63SLANG_UNUSED (srcOffset ); 64SLANG_UNUSED (extent ); 65SLANG_UNIMPLEMENTED_X ("copyTexture" ); 66} 67 68SLANG_NO_THROW void SLANG_MCALL ResourceCommandEncoderImpl ::uploadTextureData ( 69ITextureResource * dst , 70SubresourceRange subResourceRange , 71ITextureResource ::Offset3D offset , 72ITextureResource ::Extents extent , 73ITextureResource ::SubresourceData * subResourceData , 74GfxCount subResourceDataCount ) 75{ 76SLANG_UNUSED (dst ); 77SLANG_UNUSED (subResourceRange ); 78SLANG_UNUSED (offset ); 79SLANG_UNUSED (extent ); 80SLANG_UNUSED (subResourceData ); 81SLANG_UNUSED (subResourceDataCount ); 82SLANG_UNIMPLEMENTED_X ("uploadTextureData" ); 83} 84 85SLANG_NO_THROW void SLANG_MCALL ResourceCommandEncoderImpl ::clearResourceView ( 86IResourceView * view , 87ClearValue * clearValue , 88ClearResourceViewFlags ::Enum flags ) 89{ 90SLANG_UNUSED (view ); 91SLANG_UNUSED (clearValue ); 92SLANG_UNUSED (flags ); 93SLANG_UNIMPLEMENTED_X ("clearResourceView" ); 94} 95 96SLANG_NO_THROW void SLANG_MCALL ResourceCommandEncoderImpl ::resolveResource ( 97ITextureResource * source , 98ResourceState sourceState , 99SubresourceRange sourceRange , 100ITextureResource * dest , 101ResourceState destState , 102SubresourceRange destRange ) 103{ 104SLANG_UNUSED (source ); 105SLANG_UNUSED (sourceState ); 106SLANG_UNUSED (sourceRange ); 107SLANG_UNUSED (dest ); 108SLANG_UNUSED (destState ); 109SLANG_UNUSED (destRange ); 110SLANG_UNIMPLEMENTED_X ("resolveResource" ); 111} 112 113SLANG_NO_THROW void SLANG_MCALL ResourceCommandEncoderImpl ::resolveQuery ( 114IQueryPool * queryPool , 115GfxIndex index , 116GfxCount count , 117IBufferResource * buffer , 118Offset offset ) 119{ 120SLANG_UNUSED (queryPool ); 121SLANG_UNUSED (index ); 122SLANG_UNUSED (count ); 123SLANG_UNUSED (buffer ); 124SLANG_UNUSED (offset ); 125SLANG_UNIMPLEMENTED_X ("resolveQuery" ); 126} 127 128SLANG_NO_THROW void SLANG_MCALL ResourceCommandEncoderImpl ::copyTextureToBuffer ( 129IBufferResource * dst , 130Offset dstOffset , 131Size dstSize , 132Size dstRowStride , 133ITextureResource * src , 134ResourceState srcState , 135SubresourceRange srcSubresource , 136ITextureResource ::Offset3D srcOffset , 137ITextureResource ::Extents extent ) 138{ 139SLANG_UNUSED (dst ); 140SLANG_UNUSED (dstOffset ); 141SLANG_UNUSED (dstSize ); 142SLANG_UNUSED (dstRowStride ); 143SLANG_UNUSED (src ); 144SLANG_UNUSED (srcState ); 145SLANG_UNUSED (srcSubresource ); 146SLANG_UNUSED (srcOffset ); 147SLANG_UNUSED (extent ); 148SLANG_UNIMPLEMENTED_X ("copyTextureToBuffer" ); 149} 150 151SLANG_NO_THROW void SLANG_MCALL ResourceCommandEncoderImpl ::textureSubresourceBarrier ( 152ITextureResource * texture , 153SubresourceRange subresourceRange , 154ResourceState src , 155ResourceState dst ) 156{ 157SLANG_UNUSED (texture ); 158SLANG_UNUSED (subresourceRange ); 159SLANG_UNUSED (src ); 160SLANG_UNUSED (dst ); 161SLANG_UNIMPLEMENTED_X ("textureSubresourceBarrier" ); 162} 163 164SLANG_NO_THROW void SLANG_MCALL 165ResourceCommandEncoderImpl ::beginDebugEvent (const char * name ,float rgbColor [3 ]) 166{ 167SLANG_UNUSED (name ); 168SLANG_UNUSED (rgbColor ); 169} 170 171void ComputeCommandEncoderImpl ::init (CommandBufferImpl * cmdBuffer ) 172{ 173m_writer = cmdBuffer ; 174m_commandBuffer = cmdBuffer ; 175} 176 177SLANG_NO_THROW Result SLANG_MCALL 178ComputeCommandEncoderImpl ::bindPipeline (IPipelineState * state ,IShaderObject ** outRootObject ) 179{ 180m_writer -> setPipelineState (state ); 181PipelineStateBase * pipelineImpl = static_cast < PipelineStateBase *> (state ); 182SLANG_RETURN_ON_FAIL (m_commandBuffer -> m_device -> createRootShaderObject ( 183pipelineImpl -> m_program , 184m_rootObject .writeRef ())); 185returnComPtr (outRootObject ,m_rootObject ); 186return SLANG_OK ; 187} 188 189SLANG_NO_THROW Result SLANG_MCALL ComputeCommandEncoderImpl ::bindPipelineWithRootObject ( 190IPipelineState * state , 191IShaderObject * rootObject ) 192{ 193m_writer -> setPipelineState (state ); 194PipelineStateBase * pipelineImpl = static_cast < PipelineStateBase *> (state ); 195SLANG_RETURN_ON_FAIL (m_commandBuffer -> m_device -> createRootShaderObject ( 196pipelineImpl -> m_program , 197m_rootObject .writeRef ())); 198m_rootObject -> copyFrom (rootObject ,m_commandBuffer -> m_transientHeap ); 199return SLANG_OK ; 200} 201 202SLANG_NO_THROW Result SLANG_MCALL ComputeCommandEncoderImpl ::dispatchCompute (int x ,int y ,int z ) 203{ 204m_writer -> bindRootShaderObject (m_rootObject ); 205m_writer -> dispatchCompute (x ,y ,z ); 206return SLANG_OK ; 207} 208 209SLANG_NO_THROW Result SLANG_MCALL 210ComputeCommandEncoderImpl ::dispatchComputeIndirect (IBufferResource * argBuffer ,Offset offset ) 211{ 212SLANG_UNIMPLEMENTED_X ("dispatchComputeIndirect" ); 213} 214 215}// namespace cuda 216#endif 217}// namespace gfx