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
4 changes: 4 additions & 0 deletions 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 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
6 changes: 0 additions & 6 deletions include/API/Texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,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
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
Loading