lot of metal changes, but no idea how this stuff works
This commit is contained in:
@@ -4,7 +4,9 @@
|
||||
#include "Foundation/NSObject.hpp"
|
||||
#include "Graphics/Descriptor.h"
|
||||
#include "Graphics/Initializer.h"
|
||||
#include "Graphics/Metal/Command.h"
|
||||
#include "Graphics/Metal/Resources.h"
|
||||
#include "Metal/MTLAccelerationStructure.hpp"
|
||||
#include "Metal/MTLArgumentEncoder.hpp"
|
||||
#include "Metal/MTLLibrary.hpp"
|
||||
#include "Metal/MTLResource.hpp"
|
||||
@@ -21,6 +23,7 @@ class DescriptorLayout : public Gfx::DescriptorLayout {
|
||||
MTL::ArgumentEncoder* createEncoder();
|
||||
uint32 getFlattenedIndex(uint32 binding, uint32 arrayIndex) const { return flattenMap.at(flattenIndex(binding, arrayIndex)); }
|
||||
constexpr uint32 getTotalBindingCount() const { return flattenedBindingCount; }
|
||||
constexpr bool isPlainDescriptor() const { return plainDescriptor; }
|
||||
|
||||
private:
|
||||
constexpr uint64 flattenIndex(uint32 binding, uint32 arrayIndex) const { return uint64(arrayIndex) << 32 | binding; }
|
||||
@@ -28,6 +31,9 @@ class DescriptorLayout : public Gfx::DescriptorLayout {
|
||||
NS::Array* arguments;
|
||||
Map<uint64, uint32> flattenMap;
|
||||
uint32 flattenedBindingCount = 0;
|
||||
// descriptor sets containing only uniform data are not actually argument buffers, so they need to be
|
||||
// handled separately
|
||||
bool plainDescriptor = true;
|
||||
};
|
||||
DEFINE_REF(DescriptorLayout)
|
||||
|
||||
@@ -62,15 +68,54 @@ class DescriptorSet : public Gfx::DescriptorSet, public CommandBoundResource {
|
||||
virtual void updateAccelerationStructure(uint32 binding, uint32 index, Gfx::PTopLevelAS as) override;
|
||||
|
||||
constexpr const Array<MTL::Resource*>& getBoundResources() const { return boundResources; }
|
||||
|
||||
MTL::Buffer* getArgumentBuffer() const { return argumentBuffer; }
|
||||
constexpr bool isPlainDescriptor() const { return owner->getLayout()->isPlainDescriptor(); }
|
||||
constexpr MTL::ArgumentEncoder* createEncoder() const { return owner->getLayout()->createEncoder(); }
|
||||
|
||||
private:
|
||||
PGraphics graphics;
|
||||
PDescriptorPool owner;
|
||||
Array<MTL::Resource*> boundResources;
|
||||
MTL::ArgumentEncoder* encoder;
|
||||
MTL::Buffer* argumentBuffer = nullptr;
|
||||
MTL::ArgumentEncoder* encoder = nullptr;
|
||||
|
||||
struct UniformWriteInfo
|
||||
{
|
||||
uint32 index;
|
||||
Array<uint8> content;
|
||||
void apply(MTL::ArgumentEncoder* encoder) const { std::memcpy(encoder->constantData(index), content.data(), content.size()); }
|
||||
};
|
||||
Array<UniformWriteInfo> uniformWrites;
|
||||
struct BufferWriteInfo
|
||||
{
|
||||
uint32 index;
|
||||
MTL::Buffer* buffer;
|
||||
void apply(MTL::ArgumentEncoder* encoder) const { encoder->setBuffer(buffer, 0, 2); }
|
||||
};
|
||||
Array<BufferWriteInfo> bufferWrites;
|
||||
struct TextureWriteInfo
|
||||
{
|
||||
uint32 index;
|
||||
MTL::Texture* texture;
|
||||
void apply(MTL::ArgumentEncoder* encoder) const { encoder->setTexture(texture, index); }
|
||||
};
|
||||
Array<TextureWriteInfo> textureWrites;
|
||||
struct SamplerWriteInfo
|
||||
{
|
||||
uint32 index;
|
||||
MTL::SamplerState* sampler;
|
||||
void apply(MTL::ArgumentEncoder* encoder) const { encoder->setSamplerState(sampler, index); }
|
||||
};
|
||||
Array<SamplerWriteInfo> samplerWrites;
|
||||
struct AccelerationStructureWriteInfo
|
||||
{
|
||||
uint32 index;
|
||||
MTL::AccelerationStructure* accelerationStructure;
|
||||
void apply(MTL::ArgumentEncoder* encoder) const { encoder->setAccelerationStructure(accelerationStructure, index); }
|
||||
};
|
||||
Array<AccelerationStructureWriteInfo> accelerationWrites;
|
||||
|
||||
friend class RenderCommand;
|
||||
friend class ComputeCommand;
|
||||
};
|
||||
DEFINE_REF(DescriptorSet)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user