Skip to content

Commit

Permalink
cleanup function definitions (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
skallweitNV authored Sep 16, 2024
1 parent b4fb4e4 commit a9a8448
Show file tree
Hide file tree
Showing 21 changed files with 121 additions and 138 deletions.
6 changes: 3 additions & 3 deletions src/cpu/cpu-buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ Result BufferImpl::setData(size_t offset, size_t size, void const* data)
return SLANG_OK;
}

SLANG_NO_THROW DeviceAddress SLANG_MCALL BufferImpl::getDeviceAddress()
DeviceAddress BufferImpl::getDeviceAddress()
{
return (DeviceAddress)m_data;
}

SLANG_NO_THROW Result SLANG_MCALL BufferImpl::map(MemoryRange* rangeToRead, void** outPointer)
Result BufferImpl::map(MemoryRange* rangeToRead, void** outPointer)
{
SLANG_UNUSED(rangeToRead);
if (outPointer)
*outPointer = m_data;
return SLANG_OK;
}

SLANG_NO_THROW Result SLANG_MCALL BufferImpl::unmap(MemoryRange* writtenRange)
Result BufferImpl::unmap(MemoryRange* writtenRange)
{
SLANG_UNUSED(writtenRange);
return SLANG_OK;
Expand Down
24 changes: 10 additions & 14 deletions src/cpu/cpu-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ DeviceImpl::~DeviceImpl()
m_currentRootObject = nullptr;
}

SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::initialize(const Desc& desc)
Result DeviceImpl::initialize(const Desc& desc)
{
SLANG_RETURN_ON_FAIL(slangContext.initialize(
desc.slang,
Expand Down Expand Up @@ -49,8 +49,7 @@ SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::initialize(const Desc& desc)
return SLANG_OK;
}

SLANG_NO_THROW Result SLANG_MCALL
DeviceImpl::createTexture(const TextureDesc& desc, const SubresourceData* initData, ITexture** outTexture)
Result DeviceImpl::createTexture(const TextureDesc& desc, const SubresourceData* initData, ITexture** outTexture)
{
TextureDesc srcDesc = fixupTextureDesc(desc);

Expand All @@ -62,8 +61,7 @@ DeviceImpl::createTexture(const TextureDesc& desc, const SubresourceData* initDa
return SLANG_OK;
}

SLANG_NO_THROW Result SLANG_MCALL
DeviceImpl::createBuffer(const BufferDesc& descIn, const void* initData, IBuffer** outBuffer)
Result DeviceImpl::createBuffer(const BufferDesc& descIn, const void* initData, IBuffer** outBuffer)
{
auto desc = fixupBufferDesc(descIn);
RefPtr<BufferImpl> buffer = new BufferImpl(this, desc);
Expand All @@ -76,8 +74,7 @@ DeviceImpl::createBuffer(const BufferDesc& descIn, const void* initData, IBuffer
return SLANG_OK;
}

SLANG_NO_THROW Result SLANG_MCALL
DeviceImpl::createTextureView(ITexture* texture, const TextureViewDesc& desc, ITextureView** outView)
Result DeviceImpl::createTextureView(ITexture* texture, const TextureViewDesc& desc, ITextureView** outView)
{
RefPtr<TextureViewImpl> view = new TextureViewImpl(this, desc);
view->m_texture = static_cast<TextureImpl*>(texture);
Expand Down Expand Up @@ -133,7 +130,7 @@ Result DeviceImpl::createRootShaderObject(IShaderProgram* program, ShaderObjectB
return SLANG_OK;
}

SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createShaderProgram(
Result DeviceImpl::createShaderProgram(
const ShaderProgramDesc& desc,
IShaderProgram** outProgram,
ISlangBlob** outDiagnosticBlob
Expand All @@ -159,16 +156,15 @@ SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createShaderProgram(
return SLANG_OK;
}

SLANG_NO_THROW Result SLANG_MCALL
DeviceImpl::createComputePipeline(const ComputePipelineDesc& desc, IPipeline** outPipeline)
Result DeviceImpl::createComputePipeline(const ComputePipelineDesc& desc, IPipeline** outPipeline)
{
RefPtr<PipelineImpl> state = new PipelineImpl();
state->init(desc);
returnComPtr(outPipeline, state);
return Result();
}

SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createQueryPool(const QueryPoolDesc& desc, IQueryPool** outPool)
Result DeviceImpl::createQueryPool(const QueryPoolDesc& desc, IQueryPool** outPool)
{
RefPtr<QueryPoolImpl> pool = new QueryPoolImpl();
pool->init(desc);
Expand All @@ -182,12 +178,12 @@ void DeviceImpl::writeTimestamp(IQueryPool* pool, GfxIndex index)
std::chrono::high_resolution_clock::now().time_since_epoch().count();
}

SLANG_NO_THROW const DeviceInfo& SLANG_MCALL DeviceImpl::getDeviceInfo() const
const DeviceInfo& DeviceImpl::getDeviceInfo() const
{
return m_info;
}

SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createSampler(SamplerDesc const& desc, ISampler** outSampler)
Result DeviceImpl::createSampler(SamplerDesc const& desc, ISampler** outSampler)
{
SLANG_UNUSED(desc);
*outSampler = nullptr;
Expand Down Expand Up @@ -276,7 +272,7 @@ void DeviceImpl::copyBuffer(IBuffer* dst, size_t dstOffset, IBuffer* src, size_t

namespace rhi {

Result SLANG_MCALL createCPUDevice(const IDevice::Desc* desc, IDevice** outDevice)
Result createCPUDevice(const IDevice::Desc* desc, IDevice** outDevice)
{
RefPtr<cpu::DeviceImpl> result = new cpu::DeviceImpl();
SLANG_RETURN_ON_FAIL(result->initialize(*desc));
Expand Down
2 changes: 1 addition & 1 deletion src/cpu/cpu-query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Result QueryPoolImpl::init(const QueryPoolDesc& desc)
return SLANG_OK;
}

SLANG_NO_THROW Result SLANG_MCALL QueryPoolImpl::getResult(GfxIndex queryIndex, GfxCount count, uint64_t* data)
Result QueryPoolImpl::getResult(GfxIndex queryIndex, GfxCount count, uint64_t* data)
{
for (GfxCount i = 0; i < count; i++)
{
Expand Down
22 changes: 11 additions & 11 deletions src/cpu/cpu-shader-object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,35 +111,35 @@ Result ShaderObjectImpl::init(IDevice* device, ShaderObjectLayoutImpl* typeLayou
return SLANG_OK;
}

SLANG_NO_THROW GfxCount SLANG_MCALL ShaderObjectImpl::getEntryPointCount()
GfxCount ShaderObjectImpl::getEntryPointCount()
{
return 0;
}

SLANG_NO_THROW Result SLANG_MCALL ShaderObjectImpl::getEntryPoint(GfxIndex index, IShaderObject** outEntryPoint)
Result ShaderObjectImpl::getEntryPoint(GfxIndex index, IShaderObject** outEntryPoint)
{
*outEntryPoint = nullptr;
return SLANG_OK;
}

SLANG_NO_THROW const void* SLANG_MCALL ShaderObjectImpl::getRawData()
const void* ShaderObjectImpl::getRawData()
{
return m_data.getBuffer();
}

SLANG_NO_THROW size_t SLANG_MCALL ShaderObjectImpl::getSize()
size_t ShaderObjectImpl::getSize()
{
return (size_t)m_data.getCount();
}

SLANG_NO_THROW Result SLANG_MCALL ShaderObjectImpl::setData(ShaderOffset const& offset, void const* data, size_t size)
Result ShaderObjectImpl::setData(ShaderOffset const& offset, void const* data, size_t size)
{
size = std::min(size, size_t(m_data.getCount() - offset.uniformOffset));
memcpy((char*)m_data.getBuffer() + offset.uniformOffset, data, size);
return SLANG_OK;
}

SLANG_NO_THROW Result SLANG_MCALL ShaderObjectImpl::setBinding(ShaderOffset const& offset, Binding binding)
Result ShaderObjectImpl::setBinding(ShaderOffset const& offset, Binding binding)
{
auto layout = getLayout();

Expand Down Expand Up @@ -202,7 +202,7 @@ SLANG_NO_THROW Result SLANG_MCALL ShaderObjectImpl::setBinding(ShaderOffset cons
return SLANG_OK;
}

SLANG_NO_THROW Result SLANG_MCALL ShaderObjectImpl::setObject(ShaderOffset const& offset, IShaderObject* object)
Result ShaderObjectImpl::setObject(ShaderOffset const& offset, IShaderObject* object)
{
SLANG_RETURN_ON_FAIL(Super::setObject(offset, object));

Expand Down Expand Up @@ -237,12 +237,12 @@ EntryPointLayoutImpl* EntryPointShaderObjectImpl::getLayout()
return static_cast<EntryPointLayoutImpl*>(m_layout.Ptr());
}

SLANG_NO_THROW uint32_t SLANG_MCALL RootShaderObjectImpl::addRef()
uint32_t RootShaderObjectImpl::addRef()
{
return 1;
}

SLANG_NO_THROW uint32_t SLANG_MCALL RootShaderObjectImpl::release()
uint32_t RootShaderObjectImpl::release()
{
return 1;
}
Expand All @@ -269,12 +269,12 @@ EntryPointShaderObjectImpl* RootShaderObjectImpl::getEntryPoint(Index index)
return m_entryPoints[index];
}

SLANG_NO_THROW GfxCount SLANG_MCALL RootShaderObjectImpl::getEntryPointCount()
GfxCount RootShaderObjectImpl::getEntryPointCount()
{
return (GfxCount)m_entryPoints.size();
}

SLANG_NO_THROW Result SLANG_MCALL RootShaderObjectImpl::getEntryPoint(GfxIndex index, IShaderObject** outEntryPoint)
Result RootShaderObjectImpl::getEntryPoint(GfxIndex index, IShaderObject** outEntryPoint)
{
returnComPtr(outEntryPoint, m_entryPoints[index]);
return SLANG_OK;
Expand Down
11 changes: 5 additions & 6 deletions src/cuda/cuda-command-buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,34 @@ void CommandBufferImpl::init(DeviceImpl* device, TransientResourceHeapBase* tran
m_transientHeap = transientHeap;
}

SLANG_NO_THROW Result SLANG_MCALL CommandBufferImpl::encodeResourceCommands(IResourceCommandEncoder** outEncoder)
Result CommandBufferImpl::encodeResourceCommands(IResourceCommandEncoder** outEncoder)
{
m_resourceCommandEncoder.init(this);
*outEncoder = &m_resourceCommandEncoder;
return SLANG_OK;
}

SLANG_NO_THROW Result SLANG_MCALL
CommandBufferImpl::encodeRenderCommands(const RenderPassDesc& desc, IRenderCommandEncoder** outEncoder)
Result CommandBufferImpl::encodeRenderCommands(const RenderPassDesc& desc, IRenderCommandEncoder** outEncoder)
{
SLANG_UNUSED(desc);
*outEncoder = nullptr;
return SLANG_E_NOT_AVAILABLE;
}

SLANG_NO_THROW Result SLANG_MCALL CommandBufferImpl::encodeComputeCommands(IComputeCommandEncoder** outEncoder)
Result CommandBufferImpl::encodeComputeCommands(IComputeCommandEncoder** outEncoder)
{
m_computeCommandEncoder.init(this);
*outEncoder = &m_computeCommandEncoder;
return SLANG_OK;
}

SLANG_NO_THROW Result SLANG_MCALL CommandBufferImpl::encodeRayTracingCommands(IRayTracingCommandEncoder** outEncoder)
Result CommandBufferImpl::encodeRayTracingCommands(IRayTracingCommandEncoder** outEncoder)
{
*outEncoder = nullptr;
return SLANG_E_NOT_AVAILABLE;
}

SLANG_NO_THROW Result SLANG_MCALL CommandBufferImpl::getNativeHandle(NativeHandle* outHandle)
Result CommandBufferImpl::getNativeHandle(NativeHandle* outHandle)
{
*outHandle = {};
return SLANG_E_NOT_AVAILABLE;
Expand Down
20 changes: 9 additions & 11 deletions src/cuda/cuda-command-encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void ResourceCommandEncoderImpl::uploadBufferData(IBuffer* dst, Offset offset, S
m_writer->uploadBufferData(dst, offset, size, data);
}

SLANG_NO_THROW void SLANG_MCALL ResourceCommandEncoderImpl::copyTexture(
void ResourceCommandEncoderImpl::copyTexture(
ITexture* dst,
ResourceState dstState,
SubresourceRange dstSubresource,
Expand All @@ -89,7 +89,7 @@ SLANG_NO_THROW void SLANG_MCALL ResourceCommandEncoderImpl::copyTexture(
SLANG_RHI_UNIMPLEMENTED("copyTexture");
}

SLANG_NO_THROW void SLANG_MCALL ResourceCommandEncoderImpl::uploadTextureData(
void ResourceCommandEncoderImpl::uploadTextureData(
ITexture* dst,
SubresourceRange subResourceRange,
Offset3D offset,
Expand Down Expand Up @@ -130,7 +130,7 @@ void ResourceCommandEncoderImpl::clearTexture(
SLANG_RHI_UNIMPLEMENTED("clearBuffer");
}

SLANG_NO_THROW void SLANG_MCALL ResourceCommandEncoderImpl::resolveResource(
void ResourceCommandEncoderImpl::resolveResource(
ITexture* source,
ResourceState sourceState,
SubresourceRange sourceRange,
Expand All @@ -148,7 +148,7 @@ SLANG_NO_THROW void SLANG_MCALL ResourceCommandEncoderImpl::resolveResource(
SLANG_RHI_UNIMPLEMENTED("resolveResource");
}

SLANG_NO_THROW void SLANG_MCALL ResourceCommandEncoderImpl::resolveQuery(
void ResourceCommandEncoderImpl::resolveQuery(
IQueryPool* queryPool,
GfxIndex index,
GfxCount count,
Expand All @@ -164,7 +164,7 @@ SLANG_NO_THROW void SLANG_MCALL ResourceCommandEncoderImpl::resolveQuery(
SLANG_RHI_UNIMPLEMENTED("resolveQuery");
}

SLANG_NO_THROW void SLANG_MCALL ResourceCommandEncoderImpl::copyTextureToBuffer(
void ResourceCommandEncoderImpl::copyTextureToBuffer(
IBuffer* dst,
Offset dstOffset,
Size dstSize,
Expand Down Expand Up @@ -196,8 +196,7 @@ void ComputeCommandEncoderImpl::init(CommandBufferImpl* cmdBuffer)
m_commandBuffer = cmdBuffer;
}

SLANG_NO_THROW Result SLANG_MCALL
ComputeCommandEncoderImpl::bindPipeline(IPipeline* state, IShaderObject** outRootObject)
Result ComputeCommandEncoderImpl::bindPipeline(IPipeline* state, IShaderObject** outRootObject)
{
m_writer->setPipeline(state);
PipelineBase* pipelineImpl = static_cast<PipelineBase*>(state);
Expand All @@ -208,8 +207,7 @@ ComputeCommandEncoderImpl::bindPipeline(IPipeline* state, IShaderObject** outRoo
return SLANG_OK;
}

SLANG_NO_THROW Result SLANG_MCALL
ComputeCommandEncoderImpl::bindPipelineWithRootObject(IPipeline* state, IShaderObject* rootObject)
Result ComputeCommandEncoderImpl::bindPipelineWithRootObject(IPipeline* state, IShaderObject* rootObject)
{
m_writer->setPipeline(state);
PipelineBase* pipelineImpl = static_cast<PipelineBase*>(state);
Expand All @@ -220,14 +218,14 @@ ComputeCommandEncoderImpl::bindPipelineWithRootObject(IPipeline* state, IShaderO
return SLANG_OK;
}

SLANG_NO_THROW Result SLANG_MCALL ComputeCommandEncoderImpl::dispatchCompute(int x, int y, int z)
Result ComputeCommandEncoderImpl::dispatchCompute(int x, int y, int z)
{
m_writer->bindRootShaderObject(m_rootObject);
m_writer->dispatchCompute(x, y, z);
return SLANG_OK;
}

SLANG_NO_THROW Result SLANG_MCALL ComputeCommandEncoderImpl::dispatchComputeIndirect(IBuffer* argBuffer, Offset offset)
Result ComputeCommandEncoderImpl::dispatchComputeIndirect(IBuffer* argBuffer, Offset offset)
{
SLANG_RHI_UNIMPLEMENTED("dispatchComputeIndirect");
}
Expand Down
9 changes: 4 additions & 5 deletions src/cuda/cuda-command-queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ CommandQueueImpl::~CommandQueueImpl()
currentRootObject = nullptr;
}

SLANG_NO_THROW void SLANG_MCALL CommandQueueImpl::executeCommandBuffers(
void CommandQueueImpl::executeCommandBuffers(
GfxCount count,
ICommandBuffer* const* commandBuffers,
IFence* fence,
Expand All @@ -44,20 +44,19 @@ SLANG_NO_THROW void SLANG_MCALL CommandQueueImpl::executeCommandBuffers(
}
}

SLANG_NO_THROW void SLANG_MCALL CommandQueueImpl::waitOnHost()
void CommandQueueImpl::waitOnHost()
{
auto resultCode = cuStreamSynchronize(stream);
if (resultCode != CUDA_SUCCESS)
SLANG_CUDA_HANDLE_ERROR(resultCode);
}

SLANG_NO_THROW Result SLANG_MCALL
CommandQueueImpl::waitForFenceValuesOnDevice(GfxCount fenceCount, IFence** fences, uint64_t* waitValues)
Result CommandQueueImpl::waitForFenceValuesOnDevice(GfxCount fenceCount, IFence** fences, uint64_t* waitValues)
{
return SLANG_FAIL;
}

SLANG_NO_THROW Result SLANG_MCALL CommandQueueImpl::getNativeHandle(NativeHandle* outHandle)
Result CommandQueueImpl::getNativeHandle(NativeHandle* outHandle)
{
*outHandle = {};
return SLANG_E_NOT_AVAILABLE;
Expand Down
Loading

0 comments on commit a9a8448

Please sign in to comment.