Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
24adb48
Move resource creation, readbacks, and InvocationState from DX backen…
manon-traverse Jun 24, 2026
beeaa3d
Remove error about mip levels not being supported in DX12 because the…
manon-traverse Jun 24, 2026
b298c94
Mark Texture2D.OperatorIndex.test.yaml as working since texture with …
manon-traverse Jun 24, 2026
273e4a5
Add support for Samplers on DX12.
manon-traverse Jun 24, 2026
ee08c94
Add mipmap support to createTextureWithData.
manon-traverse Jun 24, 2026
e8b104f
WIP: Replace large chunks of vulkan executeProgram with API agnostic …
manon-traverse Jun 22, 2026
5277a5c
Add support for combined sampler images.
manon-traverse Jun 24, 2026
8ed9fa9
Delete dead code.
manon-traverse Jun 24, 2026
197a8d2
Remove more dead code
manon-traverse Jun 25, 2026
d6124fe
Use generic code for resource creation and readbacks with todos for d…
manon-traverse Jun 25, 2026
603f580
Bind buffer and texture descriptors.
manon-traverse Jun 25, 2026
1257958
Mark DescTable resources as resident for compute.
manon-traverse Jun 25, 2026
fba2b14
Always perform readbacks.
manon-traverse Jun 25, 2026
e04c4a7
Add support for typed buffers in Metal.
manon-traverse Jun 25, 2026
e22d38b
Add support for 64-bit typed buffers.
manon-traverse Jun 25, 2026
53678d7
Let acceleration structures work.
manon-traverse Jun 25, 2026
14b8f94
Make resources resident for graphics commands.
manon-traverse Jun 25, 2026
d02eb8b
Remove dead code from metal.
manon-traverse Jun 25, 2026
39ec9d3
Fix variable name.
manon-traverse Jun 25, 2026
120cf3e
Delete more dead code.
manon-traverse Jun 25, 2026
3fd0b70
Add staging buffer for contributions buffer. Prevent race conditions.
manon-traverse Jun 26, 2026
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
4 changes: 3 additions & 1 deletion include/API/Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,16 @@ struct BufferCreateDesc {
false};
}

static BufferCreateDesc scratchBuffer() {
static BufferCreateDesc gpuOnlyStorage() {
return BufferCreateDesc{MemoryLocation::GpuOnly,
MemoryBacking::Automatic,
BufferUsage::Storage,
BufferShaderAccessType::Raw,
{},
false};
}

static BufferCreateDesc scratchBuffer() { return gpuOnlyStorage(); }
};

class Buffer {
Expand Down
16 changes: 15 additions & 1 deletion include/API/Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "API/Capabilities.h"
#include "API/CommandBuffer.h"
#include "API/RenderPass.h"
#include "API/Sampler.h"
#include "API/ShaderBindingTable.h"
#include "API/Texture.h"

Expand Down Expand Up @@ -346,6 +347,9 @@ class Device {
virtual llvm::Expected<std::unique_ptr<Texture>>
createTexture(std::string Name, const TextureCreateDesc &Desc) = 0;

virtual llvm::Expected<std::unique_ptr<Sampler>>
createSampler(std::string Name, const SamplerCreateDesc &Desc) = 0;

virtual llvm::Expected<std::unique_ptr<MemoryHeap>>
createMemoryHeap(std::string Name, size_t SizeInBytes) = 0;

Expand All @@ -354,6 +358,12 @@ class Device {
virtual uint32_t
getTextureUploadRowStrideInBytes(const TextureCreateDesc &Desc) const = 0;

// The layout an upload buffer must have to feed createTextureWithData /
// copyBufferToTexture for the given texture description. Encodes per-mip
// offsets, row pitch, and total size in the backend's required alignment.
virtual TextureUploadLayout
getTextureUploadLayout(const TextureCreateDesc &Desc) const = 0;

virtual llvm::Expected<std::unique_ptr<RenderPass>>
createRenderPass(const RenderPassDesc &Desc) = 0;

Expand Down Expand Up @@ -382,7 +392,8 @@ class Device {
createBLAS(const AccelerationStructureSizes &Sizes) = 0;

virtual llvm::Expected<std::unique_ptr<AccelerationStructure>>
createTLAS(const AccelerationStructureSizes &Sizes) = 0;
createTLAS(const AccelerationStructureSizes &Sizes,
uint32_t InstanceCount) = 0;

virtual ~Device() = 0;

Expand Down Expand Up @@ -421,6 +432,9 @@ createBufferWithData(Device &Dev, std::string Name,
size_t SizeInBytes, ComputeEncoder *Encoder,
std::unique_ptr<offloadtest::Buffer> *OutUploadBuffer);

// Create a texture and upload `Data` (tightly-packed across mip levels) into
// it via a staging buffer recorded on `Encoder`. The staging buffer is handed
// back through `OutUploadBuffer` and must outlive command-buffer submission.
llvm::Expected<std::unique_ptr<offloadtest::Texture>>
createTextureWithData(Device &Dev, std::string Name,
const TextureCreateDesc &Desc, const void *Data,
Expand Down
67 changes: 67 additions & 0 deletions include/API/Sampler.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//===- Sampler.h - Offload API Texture ------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
//
//===----------------------------------------------------------------------===//

#ifndef OFFLOADTEST_API_SAMPLER_H
#define OFFLOADTEST_API_SAMPLER_H

#include "API/API.h"
#include "API/Resources.h"

namespace offloadtest {

enum class FilterMode { Nearest, Linear };

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

enum class CompareFunction {
Never,
Less,
Equal,
LessEqual,
Greater,
NotEqual,
GreaterEqual,
Always
};

enum class SamplerKind { Sampler, SamplerComparison };

struct SamplerCreateDesc {
FilterMode MinFilter = FilterMode::Linear;
FilterMode MagFilter = FilterMode::Linear;
AddressMode Address = AddressMode::Clamp;
float MinLOD = 0.0f;
float MaxLOD = std::numeric_limits<float>::max();
float MipLODBias = 0.0f;
CompareFunction ComparisonOp = CompareFunction::Never;
SamplerKind Kind = SamplerKind::Sampler;
};

class Sampler {
GPUAPI API;

public:
virtual ~Sampler();
Sampler(const Sampler &) = delete;
// Sampler(Sampler &&) = delete;
Sampler &operator=(const Sampler &) = delete;
// Sampler &operator=(Sampler &&) = delete;

GPUAPI getAPI() const { return API; }
virtual const SamplerCreateDesc &getDesc() const = 0;

protected:
explicit Sampler(GPUAPI API) : API(API) {}
};

} // namespace offloadtest

#endif // OFFLOADTEST_API_SAMPLER_H
25 changes: 19 additions & 6 deletions include/API/Texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "API/Resources.h"

#include "llvm/ADT/BitmaskEnum.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Error.h"
Expand Down Expand Up @@ -105,12 +106,6 @@ inline llvm::Error validateTextureCreateDesc(const TextureCreateDesc &Desc) {
std::errc::not_supported,
"DepthStencil combined with Storage is not yet supported.");

// Depth formats require DepthStencil usage; non-depth formats forbid it.
if (IsDepth && !IsDS)
return llvm::createStringError(
std::errc::invalid_argument,
"Depth format '%s' requires DepthStencil usage.",
getFormatName(Desc.Fmt).data());
if (!IsDepth && IsDS)
return llvm::createStringError(
std::errc::invalid_argument,
Expand Down Expand Up @@ -154,6 +149,24 @@ struct TileShape {
uint32_t Depth = 1;
};

struct SubresourceFootprint {
uint64_t Offset = 0; // Byte offset of this subresource in the buffer.
uint32_t RowPitchInBytes = 0; // Destination row stride (may include padding).
uint32_t RowSizeInBytes = 0; // Tightly-packed bytes per row to copy.
uint32_t NumRows = 0; // Number of rows in this subresource.
};

struct TextureUploadLayout {
llvm::SmallVector<SubresourceFootprint> Subresources; // One entry per mip.
uint64_t TotalSizeInBytes = 0;
};

// Compute a tightly-packed upload layout (no row or subresource padding) for
// the given texture description. Suitable for backends whose buffer-to-texture
// copy consumes a tightly-packed staging buffer (e.g. Vulkan, Metal).
TextureUploadLayout
computeTightTextureUploadLayout(const TextureCreateDesc &Desc);

class Texture {
GPUAPI API;

Expand Down
32 changes: 8 additions & 24 deletions include/Support/Pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "API/AccelerationStructure.h"
#include "API/Enums.h"
#include "API/Resources.h"
#include "API/Sampler.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Error.h"
Expand Down Expand Up @@ -140,24 +141,7 @@ static inline DescriptorKind getDescriptorKind(ResourceKind RK) {
llvm_unreachable("All cases handled");
}

enum class FilterMode { Nearest, Linear };

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

enum class CompareFunction {
Never,
Less,
Equal,
LessEqual,
Greater,
NotEqual,
GreaterEqual,
Always
};

enum class SamplerKind { Sampler, SamplerComparison };

struct Sampler {
struct YAMLSampler {
std::string Name;
FilterMode MinFilter = FilterMode::Linear;
FilterMode MagFilter = FilterMode::Linear;
Expand Down Expand Up @@ -270,7 +254,7 @@ struct Resource {
DirectXBinding DXBinding;
std::optional<VulkanBinding> VKBinding;
CPUBuffer *BufferPtr = nullptr;
Sampler *SamplerPtr = nullptr;
YAMLSampler *SamplerPtr = nullptr;
bool HasCounter = false;
std::optional<uint32_t> TilesMapped;
bool IsReserved = false;
Expand Down Expand Up @@ -630,7 +614,7 @@ struct Pipeline {
IOBindings Bindings;
llvm::SmallVector<PushConstantBlock> PushConstants;
llvm::SmallVector<CPUBuffer> Buffers;
llvm::SmallVector<Sampler> Samplers;
llvm::SmallVector<YAMLSampler> Samplers;
llvm::SmallVector<Result> Results;
llvm::SmallVector<DescriptorSet> Sets;
DispatchParametersSet DispatchParameters;
Expand Down Expand Up @@ -671,7 +655,7 @@ struct Pipeline {
return nullptr;
}

Sampler *getSampler(llvm::StringRef Name) {
YAMLSampler *getSampler(llvm::StringRef Name) {
for (auto &S : Samplers)
if (Name == S.Name)
return &S;
Expand Down Expand Up @@ -712,7 +696,7 @@ struct Pipeline {
LLVM_YAML_IS_SEQUENCE_VECTOR(offloadtest::DescriptorSet)
LLVM_YAML_IS_SEQUENCE_VECTOR(offloadtest::Resource)
LLVM_YAML_IS_SEQUENCE_VECTOR(offloadtest::CPUBuffer)
LLVM_YAML_IS_SEQUENCE_VECTOR(offloadtest::Sampler)
LLVM_YAML_IS_SEQUENCE_VECTOR(offloadtest::YAMLSampler)
LLVM_YAML_IS_SEQUENCE_VECTOR(offloadtest::Shader)
LLVM_YAML_IS_SEQUENCE_VECTOR(offloadtest::dx::RootParameter)
LLVM_YAML_IS_SEQUENCE_VECTOR(offloadtest::Result)
Expand Down Expand Up @@ -744,8 +728,8 @@ template <> struct MappingTraits<offloadtest::CPUBuffer> {
static void mapping(IO &I, offloadtest::CPUBuffer &R);
};

template <> struct MappingTraits<offloadtest::Sampler> {
static void mapping(IO &I, offloadtest::Sampler &S);
template <> struct MappingTraits<offloadtest::YAMLSampler> {
static void mapping(IO &I, offloadtest::YAMLSampler &S);
};

template <> struct MappingTraits<offloadtest::Result> {
Expand Down
Loading