Skip to content

Commit

Permalink
rename IInputLayout::Desc -> InputLayoutDesc (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
skallweitNV authored Sep 5, 2024
1 parent 273a8cf commit b1a52c9
Show file tree
Hide file tree
Showing 22 changed files with 57 additions and 58 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- rename IInputLayout::Desc -> InputLayoutDesc
- introduce ICommandEncoder, which is the new base interface for all command encoders (encoders don't inherit the IResourceCommandEncoder anymore)
- remove IDevice::createProgram2
- rename IDevice::createProgram -> IDevice::createShaderProgram
Expand Down
73 changes: 36 additions & 37 deletions include/slang-rhi.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,31 +275,6 @@ enum class InputSlotClass
PerInstance
};

struct InputElementDesc
{
/// The name of the corresponding parameter in shader code.
char const* semanticName;
/// The index of the corresponding parameter in shader code. Only needed if multiple parameters share a semantic
/// name.
GfxIndex semanticIndex;
/// The format of the data being fetched for this element.
Format format;
/// The offset in bytes of this element from the start of the corresponding chunk of vertex stream data.
Offset offset;
/// The index of the vertex stream to fetch this element's data from.
GfxIndex bufferSlotIndex;
};

struct VertexStreamDesc
{
/// The stride in bytes for this vertex stream.
Size stride;
/// Whether the stream contains per-vertex or per-instance data.
InputSlotClass slotClass;
/// How many instances to draw per chunk of data.
GfxCount instanceDataStepRate;
};

enum class PrimitiveType
{
Point,
Expand Down Expand Up @@ -440,19 +415,43 @@ struct NativeHandle
operator bool() const { return type != NativeHandleType::Unknown; }
};

struct InputElementDesc
{
/// The name of the corresponding parameter in shader code.
char const* semanticName;
/// The index of the corresponding parameter in shader code. Only needed if multiple parameters share a semantic
/// name.
GfxIndex semanticIndex;
/// The format of the data being fetched for this element.
Format format;
/// The offset in bytes of this element from the start of the corresponding chunk of vertex stream data.
Offset offset;
/// The index of the vertex stream to fetch this element's data from.
GfxIndex bufferSlotIndex;
};

struct VertexStreamDesc
{
/// The stride in bytes for this vertex stream.
Size stride;
/// Whether the stream contains per-vertex or per-instance data.
InputSlotClass slotClass;
/// How many instances to draw per chunk of data.
GfxCount instanceDataStepRate;
};

struct InputLayoutDesc
{
InputElementDesc const* inputElements = nullptr;
GfxCount inputElementCount = 0;
VertexStreamDesc const* vertexStreams = nullptr;
GfxCount vertexStreamCount = 0;
};

// Declare opaque type
class IInputLayout : public ISlangUnknown
{
SLANG_COM_INTERFACE(0x8957d16c, 0xdbc6, 0x4bb4, {0xb9, 0xa4, 0x8e, 0x22, 0xa1, 0xe8, 0xcc, 0x72});

public:
struct Desc
{
InputElementDesc const* inputElements = nullptr;
GfxCount inputElementCount = 0;
VertexStreamDesc const* vertexStreams = nullptr;
GfxCount vertexStreamCount = 0;
};
};

class IResource : public ISlangUnknown
Expand Down Expand Up @@ -2290,9 +2289,9 @@ class IDevice : public ISlangUnknown
}

virtual SLANG_NO_THROW Result SLANG_MCALL
createInputLayout(IInputLayout::Desc const& desc, IInputLayout** outLayout) = 0;
createInputLayout(InputLayoutDesc const& desc, IInputLayout** outLayout) = 0;

inline ComPtr<IInputLayout> createInputLayout(IInputLayout::Desc const& desc)
inline ComPtr<IInputLayout> createInputLayout(InputLayoutDesc const& desc)
{
ComPtr<IInputLayout> layout;
SLANG_RETURN_NULL_ON_FAIL(createInputLayout(desc, layout.writeRef()));
Expand All @@ -2308,7 +2307,7 @@ class IDevice : public ISlangUnknown
{
VertexStreamDesc streamDesc = {vertexSize, InputSlotClass::PerVertex, 0};

IInputLayout::Desc inputLayoutDesc = {};
InputLayoutDesc inputLayoutDesc = {};
inputLayoutDesc.inputElementCount = inputElementCount;
inputLayoutDesc.inputElements = inputElements;
inputLayoutDesc.vertexStreamCount = 1;
Expand Down
3 changes: 1 addition & 2 deletions src/cuda/cuda-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1099,8 +1099,7 @@ SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createSampler(SamplerDesc const& d
return SLANG_OK;
}

SLANG_NO_THROW Result SLANG_MCALL
DeviceImpl::createInputLayout(IInputLayout::Desc const& desc, IInputLayout** outLayout)
SLANG_NO_THROW Result SLANG_MCALL DeviceImpl::createInputLayout(InputLayoutDesc const& desc, IInputLayout** outLayout)
{
SLANG_UNUSED(desc);
SLANG_UNUSED(outLayout);
Expand Down
2 changes: 1 addition & 1 deletion src/cuda/cuda-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ class DeviceImpl : public RendererBase
virtual SLANG_NO_THROW Result SLANG_MCALL createSampler(SamplerDesc const& desc, ISampler** outSampler) override;

virtual SLANG_NO_THROW Result SLANG_MCALL
createInputLayout(IInputLayout::Desc const& desc, IInputLayout** outLayout) override;
createInputLayout(InputLayoutDesc const& desc, IInputLayout** outLayout) override;

virtual SLANG_NO_THROW Result SLANG_MCALL
createRenderPipeline(const RenderPipelineDesc& desc, IPipeline** outPipeline) override;
Expand Down
2 changes: 1 addition & 1 deletion src/d3d11/d3d11-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ Result DeviceImpl::createBufferView(
}
}

Result DeviceImpl::createInputLayout(IInputLayout::Desc const& desc, IInputLayout** outLayout)
Result DeviceImpl::createInputLayout(InputLayoutDesc const& desc, IInputLayout** outLayout)
{
D3D11_INPUT_ELEMENT_DESC inputElements[16] = {};

Expand Down
2 changes: 1 addition & 1 deletion src/d3d11/d3d11-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DeviceImpl : public ImmediateRendererBase
override;

virtual SLANG_NO_THROW Result SLANG_MCALL
createInputLayout(IInputLayout::Desc const& desc, IInputLayout** outLayout) override;
createInputLayout(InputLayoutDesc const& desc, IInputLayout** outLayout) override;

virtual SLANG_NO_THROW Result SLANG_MCALL
createQueryPool(const IQueryPool::Desc& desc, IQueryPool** outPool) override;
Expand Down
2 changes: 1 addition & 1 deletion src/d3d12/d3d12-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1736,7 +1736,7 @@ Result DeviceImpl::createRenderPassLayout(const IRenderPassLayout::Desc& desc, I
return SLANG_OK;
}

Result DeviceImpl::createInputLayout(IInputLayout::Desc const& desc, IInputLayout** outLayout)
Result DeviceImpl::createInputLayout(InputLayoutDesc const& desc, IInputLayout** outLayout)
{
RefPtr<InputLayoutImpl> layout(new InputLayoutImpl);

Expand Down
2 changes: 1 addition & 1 deletion src/d3d12/d3d12-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class DeviceImpl : public RendererBase
createRenderPassLayout(const IRenderPassLayout::Desc& desc, IRenderPassLayout** outRenderPassLayout) override;

virtual SLANG_NO_THROW Result SLANG_MCALL
createInputLayout(IInputLayout::Desc const& desc, IInputLayout** outLayout) override;
createInputLayout(InputLayoutDesc const& desc, IInputLayout** outLayout) override;

virtual Result createShaderObjectLayout(
slang::ISession* session,
Expand Down
2 changes: 1 addition & 1 deletion src/debug-layer/debug-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ Result DebugDevice::createSwapchain(ISwapchain::Desc const& desc, WindowHandle w
return Result();
}

Result DebugDevice::createInputLayout(IInputLayout::Desc const& desc, IInputLayout** outLayout)
Result DebugDevice::createInputLayout(InputLayoutDesc const& desc, IInputLayout** outLayout)
{
SLANG_RHI_API_FUNC;

Expand Down
2 changes: 1 addition & 1 deletion src/debug-layer/debug-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class DebugDevice : public DebugObject<IDevice>
virtual SLANG_NO_THROW Result SLANG_MCALL
createSwapchain(ISwapchain::Desc const& desc, WindowHandle window, ISwapchain** outSwapchain) override;
virtual SLANG_NO_THROW Result SLANG_MCALL
createInputLayout(IInputLayout::Desc const& desc, IInputLayout** outLayout) override;
createInputLayout(InputLayoutDesc const& desc, IInputLayout** outLayout) override;
virtual SLANG_NO_THROW Result SLANG_MCALL
createCommandQueue(const ICommandQueue::Desc& desc, ICommandQueue** outQueue) override;
virtual SLANG_NO_THROW Result SLANG_MCALL createShaderObject(
Expand Down
2 changes: 1 addition & 1 deletion src/immediate-renderer-base.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ class ImmediateComputeDeviceBase : public ImmediateRendererBase
}

virtual SLANG_NO_THROW Result SLANG_MCALL
createInputLayout(IInputLayout::Desc const& desc, IInputLayout** outLayout) override
createInputLayout(InputLayoutDesc const& desc, IInputLayout** outLayout) override
{
SLANG_UNUSED(desc);
SLANG_UNUSED(outLayout);
Expand Down
2 changes: 1 addition & 1 deletion src/metal/metal-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ Result DeviceImpl::createBufferView(
return SLANG_OK;
}

Result DeviceImpl::createInputLayout(IInputLayout::Desc const& desc, IInputLayout** outLayout)
Result DeviceImpl::createInputLayout(InputLayoutDesc const& desc, IInputLayout** outLayout)
{
AUTORELEASEPOOL

Expand Down
2 changes: 1 addition & 1 deletion src/metal/metal-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class DeviceImpl : public RendererBase
override;

virtual SLANG_NO_THROW Result SLANG_MCALL
createInputLayout(IInputLayout::Desc const& desc, IInputLayout** outLayout) override;
createInputLayout(InputLayoutDesc const& desc, IInputLayout** outLayout) override;

virtual Result createShaderObjectLayout(
slang::ISession* session,
Expand Down
2 changes: 1 addition & 1 deletion src/metal/metal-vertex-layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace rhi::metal {

Result InputLayoutImpl::init(const IInputLayout::Desc& desc)
Result InputLayoutImpl::init(const InputLayoutDesc& desc)
{
for (Index i = 0; i < desc.inputElementCount; i++)
{
Expand Down
2 changes: 1 addition & 1 deletion src/metal/metal-vertex-layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class InputLayoutImpl : public InputLayoutBase
std::vector<InputElementDesc> m_inputElements;
std::vector<VertexStreamDesc> m_vertexStreams;

Result init(const IInputLayout::Desc& desc);
Result init(const InputLayoutDesc& desc);
NS::SharedPtr<MTL::VertexDescriptor> createVertexDescriptor(NS::UInteger vertexBufferIndexOffset);
};

Expand Down
2 changes: 1 addition & 1 deletion src/vulkan/vk-device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2338,7 +2338,7 @@ Result DeviceImpl::createBufferView(
}
}

Result DeviceImpl::createInputLayout(IInputLayout::Desc const& desc, IInputLayout** outLayout)
Result DeviceImpl::createInputLayout(InputLayoutDesc const& desc, IInputLayout** outLayout)
{
RefPtr<InputLayoutImpl> layout(new InputLayoutImpl);

Expand Down
2 changes: 1 addition & 1 deletion src/vulkan/vk-device.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class DeviceImpl : public RendererBase
override;

virtual SLANG_NO_THROW Result SLANG_MCALL
createInputLayout(IInputLayout::Desc const& desc, IInputLayout** outLayout) override;
createInputLayout(InputLayoutDesc const& desc, IInputLayout** outLayout) override;

virtual Result createShaderObjectLayout(
slang::ISession* session,
Expand Down
2 changes: 1 addition & 1 deletion tests/test-instanced-draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class BaseDrawTest
{"POSITIONB", 0, Format::R32G32B32_FLOAT, offsetof(Instance, position), 1},
{"COLOR", 0, Format::R32G32B32_FLOAT, offsetof(Instance, color), 1},
};
IInputLayout::Desc inputLayoutDesc = {};
InputLayoutDesc inputLayoutDesc = {};
inputLayoutDesc.inputElementCount = SLANG_COUNT_OF(inputElements);
inputLayoutDesc.inputElements = inputElements;
inputLayoutDesc.vertexStreamCount = SLANG_COUNT_OF(vertexStreams);
Expand Down
2 changes: 1 addition & 1 deletion tests/test-resolve-resource-tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ struct BaseResolveResourceTest

REQUIRE_CALL(device->createTexture(dstTexDesc, dstTextureInfo.initData, dstTexture.writeRef()));

IInputLayout::Desc inputLayoutDesc = {};
InputLayoutDesc inputLayoutDesc = {};
inputLayoutDesc.inputElementCount = SLANG_COUNT_OF(inputElements);
inputLayoutDesc.inputElements = inputElements;
inputLayoutDesc.vertexStreamCount = SLANG_COUNT_OF(vertexStreams);
Expand Down
2 changes: 1 addition & 1 deletion tests/test-shader-cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ struct ShaderCacheTestGraphics : ShaderCacheTest
// Vertex buffer data
{"POSITION", 0, Format::R32G32B32_FLOAT, offsetof(Vertex, position), 0},
};
IInputLayout::Desc inputLayoutDesc = {};
InputLayoutDesc inputLayoutDesc = {};
inputLayoutDesc.inputElementCount = SLANG_COUNT_OF(inputElements);
inputLayoutDesc.inputElements = inputElements;
inputLayoutDesc.vertexStreamCount = SLANG_COUNT_OF(vertexStreams);
Expand Down
2 changes: 1 addition & 1 deletion tests/test-swapchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ struct SwapchainResizeTest
// Vertex buffer data
{"POSITIONA", 0, Format::R32G32B32_FLOAT, offsetof(Vertex, position), 0},
};
IInputLayout::Desc inputLayoutDesc = {};
InputLayoutDesc inputLayoutDesc = {};
inputLayoutDesc.inputElementCount = SLANG_COUNT_OF(inputElements);
inputLayoutDesc.inputElements = inputElements;
inputLayoutDesc.vertexStreamCount = SLANG_COUNT_OF(vertexStreams);
Expand Down
2 changes: 1 addition & 1 deletion tests/test-texture-types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ struct RenderTargetTests : BaseTextureViewTest

REQUIRE_CALL(device->createTexture(texDesc, textureInfo->subresourceDatas.data(), texture.writeRef()));

IInputLayout::Desc inputLayoutDesc = {};
InputLayoutDesc inputLayoutDesc = {};
inputLayoutDesc.inputElementCount = SLANG_COUNT_OF(inputElements);
inputLayoutDesc.inputElements = inputElements;
inputLayoutDesc.vertexStreamCount = SLANG_COUNT_OF(vertexStreams);
Expand Down

0 comments on commit b1a52c9

Please sign in to comment.