Skip to content

Commit

Permalink
cleanup (#39)
Browse files Browse the repository at this point in the history
* rename SamplerBase -> Sampler

* rename AccelerationStructureBase -> AccelerationStructure

* rename PipelineBase -> Pipeline

* rename InputLayoutBase -> InputLayout

* rename QueryPoolBase -> QueryPool

* rename TransientResourceHeapBase -> TransientResourceHeap

* rename ShaderTableBase -> ShaderTable

* rename ShaderObjectLayoutBase -> ShaderObjectLayout

* rename ShaderProgramBase -> ShaderProgram

* rename RendererBase -> Device

* rename FenceBase -> Fence

* format code

* rename getRenderer() -> getDevice()

* cleanup

* rename ImmediateRendererBase -> ImmediateDevice

* rename renderer.cpp -> rhi.cpp, renderer-shared -> rhi-shared

* rename renderer -> device

* rename m_renderer -> m_device
  • Loading branch information
skallweitNV authored Sep 17, 2024
1 parent a9a8448 commit 9de0d94
Show file tree
Hide file tree
Showing 145 changed files with 641 additions and 662 deletions.
4 changes: 2 additions & 2 deletions include/slang-rhi.h
Original file line number Diff line number Diff line change
Expand Up @@ -2182,7 +2182,7 @@ class IDevice : public ISlangUnknown

virtual SLANG_NO_THROW bool SLANG_MCALL hasFeature(const char* feature) = 0;

/// Returns a list of features supported by the renderer.
/// Returns a list of features supported by the device.
virtual SLANG_NO_THROW Result SLANG_MCALL
getFeatures(const char** outFeatures, Size bufferSize, GfxCount* outFeatureCount) = 0;

Expand Down Expand Up @@ -2426,7 +2426,7 @@ class IDevice : public ISlangUnknown
virtual SLANG_NO_THROW SlangResult SLANG_MCALL
readBuffer(IBuffer* buffer, Offset offset, Size size, ISlangBlob** outBlob) = 0;

/// Get the type of this renderer
/// Get information about the device.
virtual SLANG_NO_THROW const DeviceInfo& SLANG_MCALL getDeviceInfo() const = 0;

virtual SLANG_NO_THROW Result SLANG_MCALL createQueryPool(const QueryPoolDesc& desc, IQueryPool** outPool) = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/command-writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <slang-rhi.h>

#include "renderer-shared.h"
#include "rhi-shared.h"

#include "core/common.h"

Expand Down Expand Up @@ -129,7 +129,7 @@ class CommandWriter

void setPipeline(IPipeline* state)
{
auto offset = encodeObject(static_cast<PipelineBase*>(state));
auto offset = encodeObject(static_cast<Pipeline*>(state));
m_commands.push_back(Command(CommandName::SetPipeline, (uint32_t)offset));
}

Expand Down Expand Up @@ -301,7 +301,7 @@ class CommandWriter

void writeTimestamp(IQueryPool* pool, GfxIndex index)
{
auto poolOffset = encodeObject(static_cast<QueryPoolBase*>(pool));
auto poolOffset = encodeObject(static_cast<QueryPool*>(pool));
m_commands.push_back(Command(CommandName::WriteTimestamp, (uint32_t)poolOffset, (uint32_t)index));
m_hasWriteTimestamps = true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/cpu/cpu-base.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "../immediate-renderer-base.h"
#include "../immediate-device.h"
#include "../mutable-shader-object.h"
#include "../slang-context.h"
#define SLANG_PRELUDE_NAMESPACE slang_prelude
Expand Down
2 changes: 1 addition & 1 deletion src/cpu/cpu-buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace rhi::cpu {
class BufferImpl : public Buffer
{
public:
BufferImpl(RendererBase* device, const BufferDesc& desc)
BufferImpl(Device* device, const BufferDesc& desc)
: Buffer(device, desc)
{
}
Expand Down
10 changes: 5 additions & 5 deletions src/cpu/cpu-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Result DeviceImpl::initialize(const Desc& desc)
make_array(slang::PreprocessorMacroDesc{"__CPU__", "1"})
));

SLANG_RETURN_ON_FAIL(RendererBase::initialize(desc));
SLANG_RETURN_ON_FAIL(Device::initialize(desc));

// Initialize DeviceInfo
{
Expand Down Expand Up @@ -88,7 +88,7 @@ Result DeviceImpl::createTextureView(ITexture* texture, const TextureViewDesc& d
Result DeviceImpl::createShaderObjectLayout(
slang::ISession* session,
slang::TypeLayoutReflection* typeLayout,
ShaderObjectLayoutBase** outLayout
ShaderObjectLayout** outLayout
)
{
RefPtr<ShaderObjectLayoutImpl> cpuLayout = new ShaderObjectLayoutImpl(this, session, typeLayout);
Expand All @@ -97,7 +97,7 @@ Result DeviceImpl::createShaderObjectLayout(
return SLANG_OK;
}

Result DeviceImpl::createShaderObject(ShaderObjectLayoutBase* layout, IShaderObject** outObject)
Result DeviceImpl::createShaderObject(ShaderObjectLayout* layout, IShaderObject** outObject)
{
auto cpuLayout = static_cast<ShaderObjectLayoutImpl*>(layout);

Expand All @@ -108,7 +108,7 @@ Result DeviceImpl::createShaderObject(ShaderObjectLayoutBase* layout, IShaderObj
return SLANG_OK;
}

Result DeviceImpl::createMutableShaderObject(ShaderObjectLayoutBase* layout, IShaderObject** outObject)
Result DeviceImpl::createMutableShaderObject(ShaderObjectLayout* layout, IShaderObject** outObject)
{
auto cpuLayout = static_cast<ShaderObjectLayoutImpl*>(layout);

Expand Down Expand Up @@ -220,7 +220,7 @@ void DeviceImpl::dispatchCompute(int x, int y, int z)
int targetIndex = 0;

// Specialize the compute kernel based on the shader object bindings.
RefPtr<PipelineBase> newPipeline;
RefPtr<Pipeline> newPipeline;
maybeSpecializePipeline(m_currentPipeline, m_currentRootObject, newPipeline);
m_currentPipeline = static_cast<PipelineImpl*>(newPipeline.Ptr());

Expand Down
6 changes: 3 additions & 3 deletions src/cpu/cpu-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ class DeviceImpl : public ImmediateComputeDeviceBase
virtual Result createShaderObjectLayout(
slang::ISession* session,
slang::TypeLayoutReflection* typeLayout,
ShaderObjectLayoutBase** outLayout
ShaderObjectLayout** outLayout
) override;

virtual Result createShaderObject(ShaderObjectLayoutBase* layout, IShaderObject** outObject) override;
virtual Result createShaderObject(ShaderObjectLayout* layout, IShaderObject** outObject) override;

virtual Result createMutableShaderObject(ShaderObjectLayoutBase* layout, IShaderObject** outObject) override;
virtual Result createMutableShaderObject(ShaderObjectLayout* layout, IShaderObject** outObject) override;

virtual Result createRootShaderObject(IShaderProgram* program, ShaderObjectBase** outObject) override;

Expand Down
2 changes: 1 addition & 1 deletion src/cpu/cpu-pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace rhi::cpu {

class PipelineImpl : public PipelineBase
class PipelineImpl : public Pipeline
{
public:
ShaderProgramImpl* getProgram();
Expand Down
2 changes: 1 addition & 1 deletion src/cpu/cpu-query.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace rhi::cpu {

class QueryPoolImpl : public QueryPoolBase
class QueryPoolImpl : public QueryPool
{
public:
std::vector<uint64_t> m_queries;
Expand Down
13 changes: 6 additions & 7 deletions src/cpu/cpu-shader-object-layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
namespace rhi::cpu {

ShaderObjectLayoutImpl::ShaderObjectLayoutImpl(
RendererBase* renderer,
Device* device,
slang::ISession* session,
slang::TypeLayoutReflection* layout
)
{
initBase(renderer, session, layout);
initBase(device, session, layout);

m_subObjectCount = 0;
m_resourceCount = 0;
Expand Down Expand Up @@ -102,7 +102,7 @@ ShaderObjectLayoutImpl::ShaderObjectLayoutImpl(
if (slangBindingType != slang::BindingType::ExistentialValue)
{
subObjectLayout =
new ShaderObjectLayoutImpl(renderer, m_slangSession, slangLeafTypeLayout->getElementTypeLayout());
new ShaderObjectLayoutImpl(device, m_slangSession, slangLeafTypeLayout->getElementTypeLayout());
}

SubObjectRangeInfo subObjectRange;
Expand Down Expand Up @@ -144,17 +144,16 @@ const char* EntryPointLayoutImpl::getEntryPointName()
}

RootShaderObjectLayoutImpl::RootShaderObjectLayoutImpl(
RendererBase* renderer,
Device* device,
slang::ISession* session,
slang::ProgramLayout* programLayout
)
: ShaderObjectLayoutImpl(renderer, session, programLayout->getGlobalParamsTypeLayout())
: ShaderObjectLayoutImpl(device, session, programLayout->getGlobalParamsTypeLayout())
, m_programLayout(programLayout)
{
for (UInt i = 0; i < programLayout->getEntryPointCount(); i++)
{
m_entryPointLayouts.push_back(
new EntryPointLayoutImpl(renderer, session, programLayout->getEntryPointByIndex(i))
m_entryPointLayouts.push_back(new EntryPointLayoutImpl(device, session, programLayout->getEntryPointByIndex(i))
);
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/cpu/cpu-shader-object-layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct SubObjectRangeInfo
Index bindingRangeIndex;
};

class ShaderObjectLayoutImpl : public ShaderObjectLayoutBase
class ShaderObjectLayoutImpl : public ShaderObjectLayout
{
public:
// TODO: Once memory lifetime stuff is handled, there is
Expand All @@ -49,7 +49,7 @@ class ShaderObjectLayoutImpl : public ShaderObjectLayoutBase
Index m_subObjectCount = 0;
Index m_resourceCount = 0;

ShaderObjectLayoutImpl(RendererBase* renderer, slang::ISession* session, slang::TypeLayoutReflection* layout);
ShaderObjectLayoutImpl(Device* device, slang::ISession* session, slang::TypeLayoutReflection* layout);

size_t getSize();
Index getResourceCount() const;
Expand All @@ -65,8 +65,8 @@ class EntryPointLayoutImpl : public ShaderObjectLayoutImpl
slang::EntryPointLayout* m_entryPointLayout = nullptr;

public:
EntryPointLayoutImpl(RendererBase* renderer, slang::ISession* session, slang::EntryPointLayout* entryPointLayout)
: ShaderObjectLayoutImpl(renderer, session, entryPointLayout->getTypeLayout())
EntryPointLayoutImpl(Device* device, slang::ISession* session, slang::EntryPointLayout* entryPointLayout)
: ShaderObjectLayoutImpl(device, session, entryPointLayout->getTypeLayout())
, m_entryPointLayout(entryPointLayout)
{
}
Expand All @@ -80,7 +80,7 @@ class RootShaderObjectLayoutImpl : public ShaderObjectLayoutImpl
slang::ProgramLayout* m_programLayout = nullptr;
std::vector<RefPtr<EntryPointLayoutImpl>> m_entryPointLayouts;

RootShaderObjectLayoutImpl(RendererBase* renderer, slang::ISession* session, slang::ProgramLayout* programLayout);
RootShaderObjectLayoutImpl(Device* device, slang::ISession* session, slang::ProgramLayout* programLayout);

int getKernelIndex(std::string_view kernelName);
void getKernelThreadGroupSize(int kernelIndex, UInt* threadGroupSizes);
Expand Down
2 changes: 1 addition & 1 deletion src/cpu/cpu-shader-object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ CPUShaderObjectData::~CPUShaderObjectData()
/// Returns a StructuredBuffer resource view for GPU access into the buffer content.
/// Creates a StructuredBuffer resource if it has not been created.
Buffer* CPUShaderObjectData::getBufferResource(
RendererBase* device,
Device* device,
slang::TypeLayoutReflection* elementLayout,
slang::BindingType bindingType
)
Expand Down
2 changes: 1 addition & 1 deletion src/cpu/cpu-shader-object.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CPUShaderObjectData
/// Returns a StructuredBuffer resource view for GPU access into the buffer content.
/// Creates a StructuredBuffer resource if it has not been created.
Buffer* getBufferResource(
RendererBase* device,
Device* device,
slang::TypeLayoutReflection* elementLayout,
slang::BindingType bindingType
);
Expand Down
2 changes: 1 addition & 1 deletion src/cpu/cpu-shader-program.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace rhi::cpu {

class ShaderProgramImpl : public ShaderProgramBase
class ShaderProgramImpl : public ShaderProgram
{
public:
RefPtr<RootShaderObjectLayoutImpl> layout;
Expand Down
2 changes: 1 addition & 1 deletion src/cpu/cpu-texture-view.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace rhi::cpu {
class TextureViewImpl : public TextureView, public slang_prelude::IRWTexture
{
public:
TextureViewImpl(RendererBase* device, const TextureViewDesc& desc)
TextureViewImpl(Device* device, const TextureViewDesc& desc)
: TextureView(device, desc)
{
}
Expand Down
2 changes: 1 addition & 1 deletion src/cpu/cpu-texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class TextureImpl : public Texture
};

public:
TextureImpl(RendererBase* device, const TextureDesc& desc)
TextureImpl(Device* device, const TextureDesc& desc)
: Texture(device, desc)
{
}
Expand Down
2 changes: 1 addition & 1 deletion src/cuda/cuda-base.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "../command-encoder-com-forward.h"
#include "../command-writer.h"
#include "../mutable-shader-object.h"
#include "../renderer-shared.h"
#include "../rhi-shared.h"
#include "../simple-transient-resource-heap.h"
#include "../slang-context.h"

Expand Down
2 changes: 1 addition & 1 deletion src/cuda/cuda-buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace rhi::cuda {
class BufferImpl : public Buffer
{
public:
BufferImpl(RendererBase* device, const BufferDesc& desc)
BufferImpl(Device* device, const BufferDesc& desc)
: Buffer(device, desc)
{
}
Expand Down
2 changes: 1 addition & 1 deletion src/cuda/cuda-command-buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ ICommandBuffer* CommandBufferImpl::getInterface(const Guid& guid)
return nullptr;
}

void CommandBufferImpl::init(DeviceImpl* device, TransientResourceHeapBase* transientHeap)
void CommandBufferImpl::init(DeviceImpl* device, TransientResourceHeap* transientHeap)
{
m_device = device;
m_transientHeap = transientHeap;
Expand Down
4 changes: 2 additions & 2 deletions src/cuda/cuda-command-buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class CommandBufferImpl : public ICommandBuffer, public CommandWriter, public Co

public:
DeviceImpl* m_device;
TransientResourceHeapBase* m_transientHeap;
TransientResourceHeap* m_transientHeap;
ResourceCommandEncoderImpl m_resourceCommandEncoder;
ComputeCommandEncoderImpl m_computeCommandEncoder;

void init(DeviceImpl* device, TransientResourceHeapBase* transientHeap);
void init(DeviceImpl* device, TransientResourceHeap* transientHeap);

virtual SLANG_NO_THROW Result SLANG_MCALL encodeResourceCommands(IResourceCommandEncoder** outEncoder) override;
virtual SLANG_NO_THROW Result SLANG_MCALL
Expand Down
4 changes: 2 additions & 2 deletions src/cuda/cuda-command-encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ void ComputeCommandEncoderImpl::init(CommandBufferImpl* cmdBuffer)
Result ComputeCommandEncoderImpl::bindPipeline(IPipeline* state, IShaderObject** outRootObject)
{
m_writer->setPipeline(state);
PipelineBase* pipelineImpl = static_cast<PipelineBase*>(state);
Pipeline* pipelineImpl = static_cast<Pipeline*>(state);
SLANG_RETURN_ON_FAIL(
m_commandBuffer->m_device->createRootShaderObject(pipelineImpl->m_program, m_rootObject.writeRef())
);
Expand All @@ -210,7 +210,7 @@ Result ComputeCommandEncoderImpl::bindPipeline(IPipeline* state, IShaderObject**
Result ComputeCommandEncoderImpl::bindPipelineWithRootObject(IPipeline* state, IShaderObject* rootObject)
{
m_writer->setPipeline(state);
PipelineBase* pipelineImpl = static_cast<PipelineBase*>(state);
Pipeline* pipelineImpl = static_cast<Pipeline*>(state);
SLANG_RETURN_ON_FAIL(
m_commandBuffer->m_device->createRootShaderObject(pipelineImpl->m_program, m_rootObject.writeRef())
);
Expand Down
12 changes: 6 additions & 6 deletions src/cuda/cuda-command-queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ ICommandQueue* CommandQueueImpl::getInterface(const Guid& guid)
return nullptr;
}

void CommandQueueImpl::init(DeviceImpl* inRenderer)
void CommandQueueImpl::init(DeviceImpl* device)
{
renderer = inRenderer;
m_device = device;
m_desc.type = ICommandQueue::QueueType::Graphics;
cuStreamCreate(&stream, 0);
}
Expand Down Expand Up @@ -78,8 +78,8 @@ Result CommandQueueImpl::bindRootShaderObject(IShaderObject* object)
void CommandQueueImpl::dispatchCompute(int x, int y, int z)
{
// Specialize the compute kernel based on the shader object bindings.
RefPtr<PipelineBase> newPipeline;
renderer->maybeSpecializePipeline(currentPipeline, currentRootObject, newPipeline);
RefPtr<Pipeline> newPipeline;
m_device->maybeSpecializePipeline(currentPipeline, currentRootObject, newPipeline);
currentPipeline = static_cast<ComputePipelineImpl*>(newPipeline.Ptr());

// Find out thread group size from program reflection.
Expand Down Expand Up @@ -169,7 +169,7 @@ void CommandQueueImpl::execute(CommandBufferImpl* commandBuffer)
switch (cmd.name)
{
case CommandName::SetPipeline:
setPipeline(commandBuffer->getObject<PipelineBase>(cmd.operands[0]));
setPipeline(commandBuffer->getObject<Pipeline>(cmd.operands[0]));
break;
case CommandName::BindRootShaderObject:
bindRootShaderObject(commandBuffer->getObject<ShaderObjectBase>(cmd.operands[0]));
Expand All @@ -195,7 +195,7 @@ void CommandQueueImpl::execute(CommandBufferImpl* commandBuffer)
);
break;
case CommandName::WriteTimestamp:
writeTimestamp(commandBuffer->getObject<QueryPoolBase>(cmd.operands[0]), (SlangInt)cmd.operands[1]);
writeTimestamp(commandBuffer->getObject<QueryPool>(cmd.operands[0]), (SlangInt)cmd.operands[1]);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/cuda/cuda-command-queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CommandQueueImpl : public ICommandQueue, public ComObject

RefPtr<ComputePipelineImpl> currentPipeline;
RefPtr<RootShaderObjectImpl> currentRootObject;
RefPtr<DeviceImpl> renderer;
RefPtr<DeviceImpl> m_device;
CUstream stream;
Desc m_desc;

Expand Down
Loading

0 comments on commit 9de0d94

Please sign in to comment.