Skip to content

Commit

Permalink
rename pipeline state -> pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
skallweitNV committed Aug 31, 2024
1 parent 81ae4bc commit 470ca17
Show file tree
Hide file tree
Showing 91 changed files with 616 additions and 627 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
- rename IPipelineState -> IPipeline
- rename IDevice::createRayTracingPipelineState -> IDevice::createRayTracingPipeline
- rename IDevice::createComputePipelineState -> IDevice::createComputePipeline
- rename IDevice::createGraphicsPipelineState -> IDevice::createRenderPipeline
- rename RayTracingPipelineStateDesc -> RayTracingPipelineDesc
- rename ComputePipelineStateDesc -> ComputePipelineDesc
- rename GraphicsPipelineStateDesc -> RenderPipelineDesc
- remove SampleDesc and instead add sampleCount and sampleQuality to TextureDesc
- rename ISamplerState -> ISampler
- rename ISamplerState::Desc -> SamlerDesc
Expand Down
50 changes: 24 additions & 26 deletions include/slang-rhi.h
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ class IFramebufferLayout : public ISlangUnknown
};
};

struct GraphicsPipelineStateDesc
struct RenderPipelineDesc
{
IShaderProgram* program = nullptr;

Expand All @@ -1301,7 +1301,7 @@ struct GraphicsPipelineStateDesc
BlendDesc blend;
};

struct ComputePipelineStateDesc
struct ComputePipelineDesc
{
IShaderProgram* program = nullptr;
void* d3d12RootSignatureOverride = nullptr;
Expand All @@ -1325,7 +1325,7 @@ struct HitGroupDesc
const char* intersectionEntryPoint = nullptr;
};

struct RayTracingPipelineStateDesc
struct RayTracingPipelineDesc
{
IShaderProgram* program = nullptr;
GfxCount hitGroupCount = 0;
Expand Down Expand Up @@ -1371,7 +1371,7 @@ class IShaderTable : public ISlangUnknown
};
};

class IPipelineState : public ISlangUnknown
class IPipeline : public ISlangUnknown
{
SLANG_COM_INTERFACE(0x2ad83bfc, 0x581d, 0x4b88, {0x81, 0x3c, 0x0c, 0x0e, 0xaf, 0x04, 0x0a, 0x00});

Expand Down Expand Up @@ -1651,9 +1651,8 @@ class IRenderCommandEncoder : public IResourceCommandEncoder
// sub-shader-objects bound to it. The user must be responsible for ensuring that any
// resources or shader objects that is set into `outRootShaderObject` stays alive during
// the execution of the command buffer.
virtual SLANG_NO_THROW Result SLANG_MCALL
bindPipeline(IPipelineState* state, IShaderObject** outRootShaderObject) = 0;
inline IShaderObject* bindPipeline(IPipelineState* state)
virtual SLANG_NO_THROW Result SLANG_MCALL bindPipeline(IPipeline* state, IShaderObject** outRootShaderObject) = 0;
inline IShaderObject* bindPipeline(IPipeline* state)
{
IShaderObject* rootObject = nullptr;
SLANG_RETURN_NULL_ON_FAIL(bindPipeline(state, &rootObject));
Expand All @@ -1662,7 +1661,7 @@ class IRenderCommandEncoder : public IResourceCommandEncoder

// Sets the current pipeline state along with a pre-created mutable root shader object.
virtual SLANG_NO_THROW Result SLANG_MCALL
bindPipelineWithRootObject(IPipelineState* state, IShaderObject* rootObject) = 0;
bindPipelineWithRootObject(IPipeline* state, IShaderObject* rootObject) = 0;

virtual SLANG_NO_THROW void SLANG_MCALL setViewports(GfxCount count, const Viewport* viewports) = 0;
virtual SLANG_NO_THROW void SLANG_MCALL setScissorRects(GfxCount count, const ScissorRect* scissors) = 0;
Expand Down Expand Up @@ -1732,17 +1731,16 @@ class IComputeCommandEncoder : public IResourceCommandEncoder
// sub-shader-objects bound to it. The user must be responsible for ensuring that any
// resources or shader objects that is set into `outRooShaderObject` stays alive during
// the execution of the command buffer.
virtual SLANG_NO_THROW Result SLANG_MCALL
bindPipeline(IPipelineState* state, IShaderObject** outRootShaderObject) = 0;
inline IShaderObject* bindPipeline(IPipelineState* state)
virtual SLANG_NO_THROW Result SLANG_MCALL bindPipeline(IPipeline* state, IShaderObject** outRootShaderObject) = 0;
inline IShaderObject* bindPipeline(IPipeline* state)
{
IShaderObject* rootObject = nullptr;
SLANG_RETURN_NULL_ON_FAIL(bindPipeline(state, &rootObject));
return rootObject;
}
// Sets the current pipeline state along with a pre-created mutable root shader object.
virtual SLANG_NO_THROW Result SLANG_MCALL
bindPipelineWithRootObject(IPipelineState* state, IShaderObject* rootObject) = 0;
bindPipelineWithRootObject(IPipeline* state, IShaderObject* rootObject) = 0;
virtual SLANG_NO_THROW Result SLANG_MCALL dispatchCompute(int x, int y, int z) = 0;
virtual SLANG_NO_THROW Result SLANG_MCALL dispatchComputeIndirect(IBuffer* cmdBuffer, Offset offset) = 0;
};
Expand Down Expand Up @@ -1788,10 +1786,10 @@ class IRayTracingCommandEncoder : public IResourceCommandEncoder
virtual SLANG_NO_THROW void SLANG_MCALL
deserializeAccelerationStructure(IAccelerationStructure* dest, DeviceAddress source) = 0;

virtual SLANG_NO_THROW Result SLANG_MCALL bindPipeline(IPipelineState* state, IShaderObject** outRootObject) = 0;
virtual SLANG_NO_THROW Result SLANG_MCALL bindPipeline(IPipeline* state, IShaderObject** outRootObject) = 0;
// Sets the current pipeline state along with a pre-created mutable root shader object.
virtual SLANG_NO_THROW Result SLANG_MCALL
bindPipelineWithRootObject(IPipelineState* state, IShaderObject* rootObject) = 0;
bindPipelineWithRootObject(IPipeline* state, IShaderObject* rootObject) = 0;

/// Issues a dispatch command to start ray tracing workload with a ray tracing pipeline.
/// `rayGenShaderIndex` specifies the index into the shader table that identifies the ray generation shader.
Expand Down Expand Up @@ -2449,27 +2447,27 @@ class IDevice : public ISlangUnknown
) = 0;

virtual SLANG_NO_THROW Result SLANG_MCALL
createGraphicsPipelineState(const GraphicsPipelineStateDesc& desc, IPipelineState** outState) = 0;
createRenderPipeline(const RenderPipelineDesc& desc, IPipeline** outPipeline) = 0;

inline ComPtr<IPipelineState> createGraphicsPipelineState(const GraphicsPipelineStateDesc& desc)
inline ComPtr<IPipeline> createRenderPipeline(const RenderPipelineDesc& desc)
{
ComPtr<IPipelineState> state;
SLANG_RETURN_NULL_ON_FAIL(createGraphicsPipelineState(desc, state.writeRef()));
ComPtr<IPipeline> state;
SLANG_RETURN_NULL_ON_FAIL(createRenderPipeline(desc, state.writeRef()));
return state;
}

virtual SLANG_NO_THROW Result SLANG_MCALL
createComputePipelineState(const ComputePipelineStateDesc& desc, IPipelineState** outState) = 0;
createComputePipeline(const ComputePipelineDesc& desc, IPipeline** outPipeline) = 0;

inline ComPtr<IPipelineState> createComputePipelineState(const ComputePipelineStateDesc& desc)
inline ComPtr<IPipeline> createComputePipeline(const ComputePipelineDesc& desc)
{
ComPtr<IPipelineState> state;
SLANG_RETURN_NULL_ON_FAIL(createComputePipelineState(desc, state.writeRef()));
ComPtr<IPipeline> state;
SLANG_RETURN_NULL_ON_FAIL(createComputePipeline(desc, state.writeRef()));
return state;
}

virtual SLANG_NO_THROW Result SLANG_MCALL
createRayTracingPipelineState(const RayTracingPipelineStateDesc& desc, IPipelineState** outState) = 0;
createRayTracingPipeline(const RayTracingPipelineDesc& desc, IPipeline** outPipeline) = 0;

/// Read back texture resource and stores the result in `outBlob`.
virtual SLANG_NO_THROW SlangResult SLANG_MCALL readTexture(
Expand Down Expand Up @@ -2537,19 +2535,19 @@ class IPipelineCreationAPIDispatcher : public ISlangUnknown
SLANG_COM_INTERFACE(0x8d7aa89d, 0x07f1, 0x4e21, {0xbc, 0xd2, 0x9a, 0x71, 0xc7, 0x95, 0xba, 0x91});

public:
virtual SLANG_NO_THROW Result SLANG_MCALL createComputePipelineState(
virtual SLANG_NO_THROW Result SLANG_MCALL createComputePipeline(
IDevice* device,
slang::IComponentType* program,
void* pipelineDesc,
void** outPipelineState
) = 0;
virtual SLANG_NO_THROW Result SLANG_MCALL createGraphicsPipelineState(
virtual SLANG_NO_THROW Result SLANG_MCALL createRenderPipeline(
IDevice* device,
slang::IComponentType* program,
void* pipelineDesc,
void** outPipelineState
) = 0;
virtual SLANG_NO_THROW Result SLANG_MCALL createMeshPipelineState(
virtual SLANG_NO_THROW Result SLANG_MCALL createMeshPipeline(
IDevice* device,
slang::IComponentType* program,
void* pipelineDesc,
Expand Down
8 changes: 4 additions & 4 deletions src/command-writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace rhi {

enum class CommandName
{
SetPipelineState,
SetPipeline,
BindRootShaderObject,
SetFramebuffer,
ClearFrame,
Expand Down Expand Up @@ -123,10 +123,10 @@ class CommandWriter
return reinterpret_cast<T*>(m_data.data() + offset);
}

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

void bindRootShaderObject(IShaderObject* object)
Expand Down
2 changes: 1 addition & 1 deletion src/cpu/cpu-base.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class MutableShaderObjectImpl;
class EntryPointShaderObjectImpl;
class RootShaderObjectImpl;
class ShaderProgramImpl;
class PipelineStateImpl;
class PipelineImpl;
class QueryPoolImpl;
class DeviceImpl;

Expand Down
14 changes: 7 additions & 7 deletions src/cpu/cpu-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@ DeviceImpl::createProgram(const IShaderProgram::Desc& desc, IShaderProgram** out
}

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

Expand Down Expand Up @@ -215,9 +215,9 @@ void DeviceImpl::unmap(IBuffer* buffer, size_t offsetWritten, size_t sizeWritten
SLANG_UNUSED(sizeWritten);
}

void DeviceImpl::setPipelineState(IPipelineState* state)
void DeviceImpl::setPipeline(IPipeline* state)
{
m_currentPipeline = static_cast<PipelineStateImpl*>(state);
m_currentPipeline = static_cast<PipelineImpl*>(state);
}

void DeviceImpl::bindRootShaderObject(IShaderObject* object)
Expand All @@ -231,9 +231,9 @@ void DeviceImpl::dispatchCompute(int x, int y, int z)
int targetIndex = 0;

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

auto program = m_currentPipeline->getProgram();
auto entryPointLayout = m_currentRootObject->getLayout()->getEntryPoint(entryPointIndex);
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 @@ -48,7 +48,7 @@ class DeviceImpl : public ImmediateComputeDeviceBase
) override;

virtual SLANG_NO_THROW Result SLANG_MCALL
createComputePipelineState(const ComputePipelineStateDesc& desc, IPipelineState** outState) override;
createComputePipeline(const ComputePipelineDesc& desc, IPipeline** outPipeline) override;

virtual SLANG_NO_THROW Result SLANG_MCALL
createQueryPool(const IQueryPool::Desc& desc, IQueryPool** outPool) override;
Expand All @@ -65,11 +65,11 @@ class DeviceImpl : public ImmediateComputeDeviceBase
virtual void unmap(IBuffer* buffer, size_t offsetWritten, size_t sizeWritten) override;

private:
RefPtr<PipelineStateImpl> m_currentPipeline = nullptr;
RefPtr<PipelineImpl> m_currentPipeline = nullptr;
RefPtr<RootShaderObjectImpl> m_currentRootObject = nullptr;
DeviceInfo m_info;

virtual void setPipelineState(IPipelineState* state) override;
virtual void setPipeline(IPipeline* state) override;

virtual void bindRootShaderObject(IShaderObject* object) override;

Expand Down
4 changes: 2 additions & 2 deletions src/cpu/cpu-pipeline-state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace rhi::cpu {

ShaderProgramImpl* PipelineStateImpl::getProgram()
ShaderProgramImpl* PipelineImpl::getProgram()
{
return static_cast<ShaderProgramImpl*>(m_program.Ptr());
}

void PipelineStateImpl::init(const ComputePipelineStateDesc& inDesc)
void PipelineImpl::init(const ComputePipelineDesc& inDesc)
{
PipelineStateDesc pipelineDesc;
pipelineDesc.type = PipelineType::Compute;
Expand Down
4 changes: 2 additions & 2 deletions src/cpu/cpu-pipeline-state.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

namespace rhi::cpu {

class PipelineStateImpl : public PipelineStateBase
class PipelineImpl : public PipelineBase
{
public:
ShaderProgramImpl* getProgram();

void init(const ComputePipelineStateDesc& inDesc);
void init(const ComputePipelineDesc& inDesc);
};

} // namespace rhi::cpu
2 changes: 1 addition & 1 deletion src/cuda/cuda-base.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class MutableShaderObjectImpl;
class EntryPointShaderObjectImpl;
class RootShaderObjectImpl;
class ShaderProgramImpl;
class PipelineStateImpl;
class PipelineImpl;
class QueryPoolImpl;
class DeviceImpl;
class CommandBufferImpl;
Expand Down
12 changes: 6 additions & 6 deletions src/cuda/cuda-command-encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ void ComputeCommandEncoderImpl::init(CommandBufferImpl* cmdBuffer)
}

SLANG_NO_THROW Result SLANG_MCALL
ComputeCommandEncoderImpl::bindPipeline(IPipelineState* state, IShaderObject** outRootObject)
ComputeCommandEncoderImpl::bindPipeline(IPipeline* state, IShaderObject** outRootObject)
{
m_writer->setPipelineState(state);
PipelineStateBase* pipelineImpl = static_cast<PipelineStateBase*>(state);
m_writer->setPipeline(state);
PipelineBase* pipelineImpl = static_cast<PipelineBase*>(state);
SLANG_RETURN_ON_FAIL(
m_commandBuffer->m_device->createRootShaderObject(pipelineImpl->m_program, m_rootObject.writeRef())
);
Expand All @@ -177,10 +177,10 @@ ComputeCommandEncoderImpl::bindPipeline(IPipelineState* state, IShaderObject** o
}

SLANG_NO_THROW Result SLANG_MCALL
ComputeCommandEncoderImpl::bindPipelineWithRootObject(IPipelineState* state, IShaderObject* rootObject)
ComputeCommandEncoderImpl::bindPipelineWithRootObject(IPipeline* state, IShaderObject* rootObject)
{
m_writer->setPipelineState(state);
PipelineStateBase* pipelineImpl = static_cast<PipelineStateBase*>(state);
m_writer->setPipeline(state);
PipelineBase* pipelineImpl = static_cast<PipelineBase*>(state);
SLANG_RETURN_ON_FAIL(
m_commandBuffer->m_device->createRootShaderObject(pipelineImpl->m_program, m_rootObject.writeRef())
);
Expand Down
5 changes: 2 additions & 3 deletions src/cuda/cuda-command-encoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,10 @@ class ComputeCommandEncoderImpl : public IComputeCommandEncoder, public Resource

void init(CommandBufferImpl* cmdBuffer);

virtual SLANG_NO_THROW Result SLANG_MCALL
bindPipeline(IPipelineState* state, IShaderObject** outRootObject) override;
virtual SLANG_NO_THROW Result SLANG_MCALL bindPipeline(IPipeline* state, IShaderObject** outRootObject) override;

virtual SLANG_NO_THROW Result SLANG_MCALL
bindPipelineWithRootObject(IPipelineState* state, IShaderObject* rootObject) override;
bindPipelineWithRootObject(IPipeline* state, IShaderObject* rootObject) override;

virtual SLANG_NO_THROW Result SLANG_MCALL dispatchCompute(int x, int y, int z) override;

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 @@ -62,9 +62,9 @@ SLANG_NO_THROW Result SLANG_MCALL CommandQueueImpl::getNativeHandle(InteropHandl
return SLANG_FAIL;
}

void CommandQueueImpl::setPipelineState(IPipelineState* state)
void CommandQueueImpl::setPipeline(IPipeline* state)
{
currentPipeline = dynamic_cast<ComputePipelineStateImpl*>(state);
currentPipeline = dynamic_cast<ComputePipelineImpl*>(state);
}

Result CommandQueueImpl::bindRootShaderObject(IShaderObject* object)
Expand All @@ -78,9 +78,9 @@ 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<PipelineStateBase> newPipeline;
RefPtr<PipelineBase> newPipeline;
renderer->maybeSpecializePipeline(currentPipeline, currentRootObject, newPipeline);
currentPipeline = static_cast<ComputePipelineStateImpl*>(newPipeline.Ptr());
currentPipeline = static_cast<ComputePipelineImpl*>(newPipeline.Ptr());

// Find out thread group size from program reflection.
auto& kernelName = currentPipeline->shaderProgram->kernelName;
Expand Down Expand Up @@ -168,8 +168,8 @@ void CommandQueueImpl::execute(CommandBufferImpl* commandBuffer)
{
switch (cmd.name)
{
case CommandName::SetPipelineState:
setPipelineState(commandBuffer->getObject<PipelineStateBase>(cmd.operands[0]));
case CommandName::SetPipeline:
setPipeline(commandBuffer->getObject<PipelineBase>(cmd.operands[0]));
break;
case CommandName::BindRootShaderObject:
bindRootShaderObject(commandBuffer->getObject<ShaderObjectBase>(cmd.operands[0]));
Expand Down
4 changes: 2 additions & 2 deletions src/cuda/cuda-command-queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CommandQueueImpl : public ICommandQueue, public ComObject

ICommandQueue* getInterface(const Guid& guid);

RefPtr<ComputePipelineStateImpl> currentPipeline;
RefPtr<ComputePipelineImpl> currentPipeline;
RefPtr<RootShaderObjectImpl> currentRootObject;
RefPtr<DeviceImpl> renderer;
CUstream stream;
Expand All @@ -37,7 +37,7 @@ class CommandQueueImpl : public ICommandQueue, public ComObject

virtual SLANG_NO_THROW Result SLANG_MCALL getNativeHandle(InteropHandle* outHandle) override;

void setPipelineState(IPipelineState* state);
void setPipeline(IPipeline* state);

Result bindRootShaderObject(IShaderObject* object);

Expand Down
Loading

0 comments on commit 470ca17

Please sign in to comment.