Skip to content
Open
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
66 changes: 66 additions & 0 deletions include/API/Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@
#include "API/Capabilities.h"
#include "API/CommandBuffer.h"
#include "API/Texture.h"

#include "Support/Pipeline.h"

#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/iterator_range.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/MemoryBuffer.h"

#include <cstdint>
#include <memory>
#include <optional>
#include <string>

namespace llvm {
Expand All @@ -40,6 +46,56 @@ struct DeviceConfig {
bool EnableValidationLayer = false;
};

struct DXBinding {
uint32_t Register;
uint32_t Space;
};

struct InputLayoutDesc {
std::string Name;
Format Format;
uint32_t OffsetInBytes;
std::optional<uint32_t> InstanceStepRate;
Comment on lines +55 to +58
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This misses some parameters that are not used. Those will be added once we need them.

};

struct ResourceBindingDesc {
ResourceKind Kind;
DXBinding DXBinding;
std::optional<VulkanBinding> VKBinding;
uint32_t DescriptorCount;
};

struct DescriptorSetLayoutDesc {
llvm::SmallVector<ResourceBindingDesc> ResourceBindings;
};

struct PushConstantsRange {
uint32_t OffsetInBytes; // Must be multiple of 4
uint32_t SizeInBytes; // Must be multiple of 4
};

struct BindingsDesc {
llvm::SmallVector<DescriptorSetLayoutDesc> DescriptorSetDescs;
llvm::SmallVector<PushConstantsRange> PushConstantRanges;
};

struct ShaderContainer {
std::string EntryPoint;
const llvm::MemoryBuffer *Shader;
llvm::SmallVector<SpecializationConstant> SpecializationConstants;
};

class PipelineState {
public:
virtual ~PipelineState() = default;

PipelineState(const Buffer &) = delete;
PipelineState &operator=(const Buffer &) = delete;

protected:
PipelineState() = default;
};

class Fence {
public:
virtual ~Fence() = default;
Expand Down Expand Up @@ -75,6 +131,16 @@ class Device {

virtual Queue &getGraphicsQueue() = 0;

virtual llvm::Expected<std::unique_ptr<PipelineState>>
createPipelineCs(llvm::StringRef Name, const BindingsDesc &BindingsDesc,
ShaderContainer CS) = 0;

virtual llvm::Expected<std::unique_ptr<PipelineState>>
createPipelineVsPs(llvm::StringRef Name, const BindingsDesc &BindingsDesc,
llvm::ArrayRef<InputLayoutDesc> InputLayout,
llvm::ArrayRef<Format> RTFormats, ShaderContainer VS,
ShaderContainer PS) = 0;

virtual llvm::Expected<std::unique_ptr<Fence>>
createFence(llvm::StringRef Name) = 0;

Expand Down
29 changes: 29 additions & 0 deletions include/API/Enums.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

#ifndef OFFLOADTEST_API_ENUMS_H
#define OFFLOADTEST_API_ENUMS_H

namespace offloadtest {

enum class ResourceKind {
Buffer,
StructuredBuffer,
ByteAddressBuffer,
Texture2D,
RWBuffer,
RWStructuredBuffer,
RWByteAddressBuffer,
RWTexture2D,
ConstantBuffer,
Sampler,
SampledTexture2D,
};

enum ShaderContainerType {
DXIL,
SPIRV,
Metal,
};

} // namespace offloadtest

#endif // OFFLOADTEST_API_ENUMS_H
2 changes: 2 additions & 0 deletions include/API/FormatConversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ inline llvm::Expected<Format> toFormat(DataFormat Format, int Channels) {
return Format::R32Float;
case 2:
return Format::RG32Float;
case 3:
return Format::RGB32Float;
case 4:
return Format::RGBA32Float;
}
Expand Down
15 changes: 1 addition & 14 deletions include/Support/Pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#ifndef OFFLOADTEST_SUPPORT_PIPELINE_H
#define OFFLOADTEST_SUPPORT_PIPELINE_H

#include "API/Enums.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/MemoryBuffer.h"
Expand Down Expand Up @@ -48,20 +49,6 @@ enum class DataFormat {
Bool,
};

enum class ResourceKind {
Buffer,
StructuredBuffer,
ByteAddressBuffer,
Texture2D,
RWBuffer,
RWStructuredBuffer,
RWByteAddressBuffer,
RWTexture2D,
ConstantBuffer,
Sampler,
SampledTexture2D,
};

enum class FilterMode { Nearest, Linear };

enum class AddressMode { Clamp, Repeat, Mirror, Border, MirrorOnce };
Expand Down
Loading
Loading