Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

command encoder renamings #66

Merged
merged 2 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
- rename ICommandEncoder -> IPassEncoder, ICommandEncoder::endEncoding -> IPassEncoder::end
- rename IResourceCommandEncoder -> IResourcePassEncoder, ICommandBuffer::encodeResourceCommands -> ICommandBuffer::beginResourcePass
- rename IRenderCommandEncoder -> IRenderPassEncoder, ICommandBuffer::encodeRenderCommands -> ICommandBuffer::beginRenderPass
- rename IComputeCommandEncoder -> IComputePassEncoder, ICommandBuffer::encodeComputeCommands -> ICommandBuffer::beginComputePass
- rename IRayTracingCommandEncoder -> IRayTracingPassEncoder, ICommandBuffer::encodeRayTracingCommands -> ICommandBuffer::beginRayTracingPass
- binding resources is now unified using the Binding struct that holds the type + resource of the binding
- make all resources implement the IResource interface (buffers, textures, samplers, acceleration structures, etc.)
- remove IResourceView and replace with ITextureView (for texture views)
Expand Down
35 changes: 14 additions & 21 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,19 @@
| `getResult` | yes | yes | yes | yes | yes | :x: | :x: |
| `reset` | yes | yes | yes | yes | yes | :x: | :x: |

## `ICommandEncoder` interface
## `IPassEncoder` interface

| API | CPU | CUDA | D3D11 | D3D12 | Vulkan | Metal | WGPU |
|------------------------------|-----|------|-------|-------|--------|-------|------|
| `endEncoding` | yes | yes | yes | yes | yes | yes | yes |
| `end` | yes | yes | yes | yes | yes | yes | yes |
| `setBufferState` | :x: | :x: | :x: | yes | yes | :x: | :x: |
| `setTextureState` | :x: | :x: | :x: | yes | yes | :x: | :x: |
| `setTextureSubresourceState` | :x: | :x: | :x: | yes | yes | :x: | :x: |
| `beginDebugEvent` | :x: | :x: | :x: | yes | yes | yes | :x: |
| `endDebugEvent` | :x: | :x: | :x: | yes | yes | yes | :x: |
| `writeTimestamp` | yes | yes | yes | yes | yes | yes | :x: |

## `IResourceCommandEncoder` interface
## `IResourcePassEncoder` interface

| API | CPU | CUDA | D3D11 | D3D12 | Vulkan | Metal | WGPU |
|-----------------------|-----|------|-------|-------|--------|-------|------|
Expand All @@ -115,7 +115,7 @@
| `clearTexture` | :x: | :x: | :x: | :x: | :x: | :x: | :x: |
| `resolveQuery` | :x: | :x: | :x: | yes | yes | yes | :x: |

## `IRenderCommandEncoder` interface
## `IRenderPassEncoder` interface

| API | CPU | CUDA | D3D11 | D3D12 | Vulkan | Metal | WGPU |
|------------------------------|-----|------|-------|-------|--------|-------|------|
Expand All @@ -135,7 +135,7 @@
| `drawIndexedInstanced` | :x: | :x: | yes | yes | yes | yes | yes |
| `drawMeshTasks` | :x: | :x: | :x: | yes | yes | :x: | :x: |

## `IComputeCommandEncoder` interface
## `IComputePassEncoder` interface

| API | CPU | CUDA | D3D11 | D3D12 | Vulkan | Metal | WGPU |
|------------------------------|-----|------|-------|-------|--------|-------|------|
Expand All @@ -144,7 +144,7 @@
| `dispatchCompute` | yes | yes | yes | yes | yes | yes | yes |
| `dispatchComputeIndirect` | :x: | :x: | :x: | yes | :x: | :x: | yes |

## `IRayTracingCommandEncoder` interface
## `IRayTracingPassEncoder` interface

| API | CPU | CUDA | D3D11 | D3D12 | Vulkan | Metal | WGPU |
|----------------------------------------|-----|------|-------|-------|--------|-------|------|
Expand All @@ -159,14 +159,14 @@

## `ICommandBuffer` interface

| API | CPU | CUDA | D3D11 | D3D12 | Vulkan | Metal | WGPU |
|----------------------------|-----|------|-------|-------|--------|-------|------|
| `encodeResourceCommands` | yes | yes | yes | yes | yes | yes | yes |
| `encodeRenderCommands` | :x: | :x: | yes | yes | yes | yes | yes |
| `encodeComputeCommands` | yes | yes | yes | yes | yes | :x: | yes |
| `encodeRayTracingCommands` | :x: | :x: | :x: | yes | yes | :x: | :x: |
| `close` | yes | yes | yes | yes | yes | yes | yes |
| `getNativeHandle` | :x: | :x: | :x: | yes | yes | yes | yes |
| API | CPU | CUDA | D3D11 | D3D12 | Vulkan | Metal | WGPU |
|-----------------------|-----|------|-------|-------|--------|-------|------|
| `beginResourcePass` | yes | yes | yes | yes | yes | yes | yes |
| `beginRenderPass` | :x: | :x: | yes | yes | yes | yes | yes |
| `beginComputePass` | yes | yes | yes | yes | yes | :x: | yes |
| `beginRayTracingPass` | :x: | :x: | :x: | yes | yes | :x: | :x: |
| `close` | yes | yes | yes | yes | yes | yes | yes |
| `getNativeHandle` | :x: | :x: | :x: | yes | yes | yes | yes |

## `ICommandQueue` interface

Expand All @@ -189,10 +189,3 @@
| `resize` | :x: | :x: | yes | yes | yes | yes | :x: |
| `isOccluded` | :x: | :x: | :x: | yes | :x: | :x: | :x: |
| `setFullScreenMode` | :x: | :x: | :x: | yes | :x: | :x: | :x: |




| API | CPU | CUDA | D3D11 | D3D12 | Vulkan | Metal | WGPU |
|---------------|-----|------|-------|-------|--------|-------|------|
| `endEncoding` | :x: | :x: | :x: | :x: | :x: | :x: | :x: |
54 changes: 27 additions & 27 deletions include/slang-rhi.h
Original file line number Diff line number Diff line change
Expand Up @@ -1535,12 +1535,12 @@ struct SamplePosition
int8_t y;
};

class ICommandEncoder : public ISlangUnknown
class IPassEncoder : public ISlangUnknown
{
SLANG_COM_INTERFACE(0xb7483513, 0x8939, 0x4bdf, {0x81, 0x2c, 0xc3, 0xe5, 0xb0, 0xde, 0xdc, 0x8e});

public:
virtual SLANG_NO_THROW void SLANG_MCALL endEncoding() = 0;
virtual SLANG_NO_THROW void SLANG_MCALL end() = 0;

virtual SLANG_NO_THROW void SLANG_MCALL setBufferState(IBuffer* buffer, ResourceState state) = 0;

Expand All @@ -1558,7 +1558,7 @@ class ICommandEncoder : public ISlangUnknown
virtual SLANG_NO_THROW void SLANG_MCALL writeTimestamp(IQueryPool* queryPool, GfxIndex queryIndex) = 0;
};

class IResourceCommandEncoder : public ICommandEncoder
class IResourcePassEncoder : public IPassEncoder
{
SLANG_COM_INTERFACE(0x9107510b, 0x75a7, 0x4e2f, {0x8d, 0x00, 0x58, 0xfd, 0x22, 0x48, 0xcd, 0x0d});

Expand Down Expand Up @@ -1622,7 +1622,7 @@ class IResourceCommandEncoder : public ICommandEncoder
resolveQuery(IQueryPool* queryPool, GfxIndex index, GfxCount count, IBuffer* buffer, Offset offset) = 0;
};

class IRenderCommandEncoder : public ICommandEncoder
class IRenderPassEncoder : public IPassEncoder
{
SLANG_COM_INTERFACE(0xa2be110e, 0xaed7, 0x43b6, {0x90, 0x01, 0x77, 0x79, 0x1f, 0xea, 0x1d, 0x40});

Expand Down Expand Up @@ -1714,7 +1714,7 @@ class IRenderCommandEncoder : public ICommandEncoder
virtual SLANG_NO_THROW Result SLANG_MCALL drawMeshTasks(int x, int y, int z) = 0;
};

class IComputeCommandEncoder : public ICommandEncoder
class IComputePassEncoder : public IPassEncoder
{
SLANG_COM_INTERFACE(0x46261132, 0xa7f6, 0x439b, {0x82, 0x6b, 0x1e, 0xaf, 0xf2, 0xae, 0xae, 0xa6});

Expand Down Expand Up @@ -1757,7 +1757,7 @@ struct AccelerationStructureQueryDesc
GfxIndex firstQueryIndex;
};

class IRayTracingCommandEncoder : public ICommandEncoder
class IRayTracingPassEncoder : public IPassEncoder
{
SLANG_COM_INTERFACE(0xef4f6545, 0x1f5d, 0x4b9a, {0x9e, 0x72, 0x4d, 0x03, 0x3f, 0xf0, 0x09, 0x1d});

Expand Down Expand Up @@ -1811,46 +1811,46 @@ class ICommandBuffer : public ISlangUnknown
SLANG_COM_INTERFACE(0x8ee39d55, 0x2b07, 0x4e61, {0x8f, 0x13, 0x1d, 0x6c, 0x01, 0xa9, 0x15, 0x43});

public:
// Only one encoder may be open at a time. User must call `ICommandEncoder::endEncoding`
// before calling other `encode*Commands` methods.
// Once `endEncoding` is called, the `ICommandEncoder` object becomes obsolete and is
// invalid for further use. To continue recording, the user must request a new encoder
// object by calling one of the `encode*Commands` methods again.
// Only one pass encoder may be open at a time. User must call `IPassEncoder::endEncoding`
// before calling other `begin*Pass` methods.
// Once `end` is called, the `IPassEncoder` object becomes obsolete and is
// invalid for further use. To continue recording, the user must request a new pass encoder
// object by calling one of the `begin*Pass` methods again.

virtual SLANG_NO_THROW Result SLANG_MCALL encodeResourceCommands(IResourceCommandEncoder** outEncoder) = 0;
virtual SLANG_NO_THROW Result SLANG_MCALL beginResourcePass(IResourcePassEncoder** outEncoder) = 0;

inline IResourceCommandEncoder* encodeResourceCommands()
inline IResourcePassEncoder* beginResourcePass()
{
IResourceCommandEncoder* encoder;
SLANG_RETURN_NULL_ON_FAIL(encodeResourceCommands(&encoder));
IResourcePassEncoder* encoder;
SLANG_RETURN_NULL_ON_FAIL(beginResourcePass(&encoder));
return encoder;
}

virtual SLANG_NO_THROW Result SLANG_MCALL
encodeRenderCommands(const RenderPassDesc& desc, IRenderCommandEncoder** outEncoder) = 0;
beginRenderPass(const RenderPassDesc& desc, IRenderPassEncoder** outEncoder) = 0;

inline IRenderCommandEncoder* encodeRenderCommands(const RenderPassDesc& desc)
inline IRenderPassEncoder* beginRenderPass(const RenderPassDesc& desc)
{
IRenderCommandEncoder* encoder;
SLANG_RETURN_NULL_ON_FAIL(encodeRenderCommands(desc, &encoder));
IRenderPassEncoder* encoder;
SLANG_RETURN_NULL_ON_FAIL(beginRenderPass(desc, &encoder));
return encoder;
}

virtual SLANG_NO_THROW Result SLANG_MCALL encodeComputeCommands(IComputeCommandEncoder** outEncoder) = 0;
virtual SLANG_NO_THROW Result SLANG_MCALL beginComputePass(IComputePassEncoder** outEncoder) = 0;

inline IComputeCommandEncoder* encodeComputeCommands()
inline IComputePassEncoder* beginComputePass()
{
IComputeCommandEncoder* encoder;
SLANG_RETURN_NULL_ON_FAIL(encodeComputeCommands(&encoder));
IComputePassEncoder* encoder;
SLANG_RETURN_NULL_ON_FAIL(beginComputePass(&encoder));
return encoder;
}

virtual SLANG_NO_THROW Result SLANG_MCALL encodeRayTracingCommands(IRayTracingCommandEncoder** outEncoder) = 0;
virtual SLANG_NO_THROW Result SLANG_MCALL beginRayTracingPass(IRayTracingPassEncoder** outEncoder) = 0;

inline IRayTracingCommandEncoder* encodeRayTracingCommands()
inline IRayTracingPassEncoder* beginRayTracingPass()
{
IRayTracingCommandEncoder* encoder;
SLANG_RETURN_NULL_ON_FAIL(encodeRayTracingCommands(&encoder));
IRayTracingPassEncoder* encoder;
SLANG_RETURN_NULL_ON_FAIL(beginRayTracingPass(&encoder));
return encoder;
}

Expand Down
8 changes: 4 additions & 4 deletions src/cuda/cuda-base.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "cuda-api.h"

#include "../command-encoder-com-forward.h"
#include "../pass-encoder-com-forward.h"
#include "../command-writer.h"
#include "../mutable-shader-object.h"
#include "../rhi-shared.h"
Expand Down Expand Up @@ -44,9 +44,9 @@ class PipelineImpl;
class QueryPoolImpl;
class DeviceImpl;
class CommandBufferImpl;
class CommandEncoderImpl;
class ResourceCommandEncoderImpl;
class ComputeCommandEncoderImpl;
class PassEncoderImpl;
class ResourcePassEncoderImpl;
class ComputePassEncoderImpl;
class CommandQueueImpl;

} // namespace rhi::cuda
16 changes: 8 additions & 8 deletions src/cuda/cuda-command-buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,28 @@ void CommandBufferImpl::init(DeviceImpl* device, TransientResourceHeap* transien
m_transientHeap = transientHeap;
}

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

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

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

Result CommandBufferImpl::encodeRayTracingCommands(IRayTracingCommandEncoder** outEncoder)
Result CommandBufferImpl::beginRayTracingPass(IRayTracingPassEncoder** outEncoder)
{
*outEncoder = nullptr;
return SLANG_E_NOT_AVAILABLE;
Expand Down
12 changes: 6 additions & 6 deletions src/cuda/cuda-command-buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ class CommandBufferImpl : public ICommandBuffer, public CommandWriter, public Co
public:
DeviceImpl* m_device;
TransientResourceHeap* m_transientHeap;
ResourceCommandEncoderImpl m_resourceCommandEncoder;
ComputeCommandEncoderImpl m_computeCommandEncoder;
ResourcePassEncoderImpl m_resourcePassEncoder;
ComputePassEncoderImpl m_computePassEncoder;

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

virtual SLANG_NO_THROW Result SLANG_MCALL encodeResourceCommands(IResourceCommandEncoder** outEncoder) override;
virtual SLANG_NO_THROW Result SLANG_MCALL beginResourcePass(IResourcePassEncoder** outEncoder) override;
virtual SLANG_NO_THROW Result SLANG_MCALL
encodeRenderCommands(const RenderPassDesc& desc, IRenderCommandEncoder** outEncoder) override;
virtual SLANG_NO_THROW Result SLANG_MCALL encodeComputeCommands(IComputeCommandEncoder** outEncoder) override;
virtual SLANG_NO_THROW Result SLANG_MCALL encodeRayTracingCommands(IRayTracingCommandEncoder** outEncoder) override;
beginRenderPass(const RenderPassDesc& desc, IRenderPassEncoder** outEncoder) override;
virtual SLANG_NO_THROW Result SLANG_MCALL beginComputePass(IComputePassEncoder** outEncoder) override;
virtual SLANG_NO_THROW Result SLANG_MCALL beginRayTracingPass(IRayTracingPassEncoder** outEncoder) override;

virtual SLANG_NO_THROW void SLANG_MCALL close() override {}

Expand Down
Loading