I HAVE AQUIRED GPUTRACE
This commit is contained in:
@@ -49,9 +49,6 @@ find_package(Ktx CONFIG REQUIRED)
|
||||
find_package(nlohmann_json CONFIG REQUIRED)
|
||||
find_package(fmt CONFIG REQUIRED)
|
||||
find_package(VulkanMemoryAllocator CONFIG REQUIRED)
|
||||
find_package(spirv_cross_core CONFIG REQUIRED)
|
||||
find_package(spirv_cross_glsl CONFIG REQUIRED)
|
||||
find_package(spirv_cross_msl CONFIG REQUIRED)
|
||||
find_package(glslang CONFIG REQUIRED)
|
||||
|
||||
if(UNIX)
|
||||
|
||||
@@ -69,7 +69,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset)
|
||||
OFloatParameter p = new FloatParameter(param.key(), uniformBufferOffset, uniformBinding);
|
||||
if(uniformBinding == -1)
|
||||
{
|
||||
layout->addDescriptorBinding(bindingCounter, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||
layout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = bindingCounter, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER,});
|
||||
uniformBinding = bindingCounter++;
|
||||
}
|
||||
uniformBufferOffset += 4;
|
||||
@@ -86,7 +86,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset)
|
||||
OVectorParameter p = new VectorParameter(param.key(), uniformBufferOffset, uniformBinding);
|
||||
if(uniformBinding == -1)
|
||||
{
|
||||
layout->addDescriptorBinding(bindingCounter, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||
layout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = bindingCounter, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER,});
|
||||
uniformBinding = bindingCounter++;
|
||||
}
|
||||
uniformBufferOffset += 12;
|
||||
@@ -100,7 +100,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset)
|
||||
else if(type.compare("Texture2D") == 0)
|
||||
{
|
||||
OTextureParameter p = new TextureParameter(param.key(), 0, bindingCounter);
|
||||
layout->addDescriptorBinding(bindingCounter++, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE);
|
||||
layout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = bindingCounter++, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE,});
|
||||
if(defaultValue != param.value().end())
|
||||
{
|
||||
std::string defaultString = defaultValue.value().get<std::string>();
|
||||
@@ -116,7 +116,7 @@ void MaterialLoader::import(MaterialImportArgs args, PMaterialAsset asset)
|
||||
else if(type.compare("Sampler") == 0)
|
||||
{
|
||||
OSamplerParameter p = new SamplerParameter(param.key(), 0, bindingCounter);
|
||||
layout->addDescriptorBinding(bindingCounter++, Gfx::SE_DESCRIPTOR_TYPE_SAMPLER);
|
||||
layout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = bindingCounter++, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLER,});
|
||||
p->data = graphics->createSampler({});
|
||||
parameters.add(p->key);
|
||||
expressions.add(std::move(p));
|
||||
|
||||
@@ -24,19 +24,11 @@ DescriptorLayout& DescriptorLayout::operator=(const DescriptorLayout& other) {
|
||||
|
||||
DescriptorLayout::~DescriptorLayout() {}
|
||||
|
||||
void DescriptorLayout::addDescriptorBinding(uint32 bindingIndex, SeDescriptorType type, SeImageViewType textureType, uint32 arrayCount,
|
||||
SeDescriptorBindingFlags bindingFlags, SeShaderStageFlags shaderStages) {
|
||||
if (descriptorBindings.size() <= bindingIndex) {
|
||||
descriptorBindings.resize(bindingIndex + 1);
|
||||
void DescriptorLayout::addDescriptorBinding(DescriptorBinding binding) {
|
||||
if (descriptorBindings.size() <= binding.binding) {
|
||||
descriptorBindings.resize(binding.binding + 1);
|
||||
}
|
||||
descriptorBindings[bindingIndex] = DescriptorBinding{
|
||||
.binding = bindingIndex,
|
||||
.descriptorType = type,
|
||||
.textureType = textureType,
|
||||
.descriptorCount = arrayCount,
|
||||
.bindingFlags = bindingFlags,
|
||||
.shaderStages = shaderStages,
|
||||
};
|
||||
descriptorBindings[binding.binding] = binding;
|
||||
}
|
||||
|
||||
PDescriptorSet DescriptorLayout::allocateDescriptorSet() { return pool->allocateDescriptorSet(); }
|
||||
|
||||
@@ -23,10 +23,7 @@ public:
|
||||
DescriptorLayout(const DescriptorLayout& other);
|
||||
DescriptorLayout& operator=(const DescriptorLayout& other);
|
||||
virtual ~DescriptorLayout();
|
||||
void addDescriptorBinding(uint32 binding, SeDescriptorType type,
|
||||
SeImageViewType textureType = Gfx::SE_IMAGE_VIEW_TYPE_2D, uint32 arrayCount = 1,
|
||||
SeDescriptorBindingFlags bindingFlags = 0,
|
||||
SeShaderStageFlags shaderStages = SeShaderStageFlagBits::SE_SHADER_STAGE_ALL);
|
||||
void addDescriptorBinding(DescriptorBinding binding);
|
||||
void reset();
|
||||
PDescriptorSet allocateDescriptorSet();
|
||||
virtual void create() = 0;
|
||||
|
||||
@@ -226,8 +226,6 @@ struct LegacyPipelineCreateInfo
|
||||
DepthStencilState depthStencilState;
|
||||
ColorBlendState colorBlend;
|
||||
LegacyPipelineCreateInfo();
|
||||
LegacyPipelineCreateInfo(LegacyPipelineCreateInfo&& rhs) = default;
|
||||
LegacyPipelineCreateInfo& operator=(LegacyPipelineCreateInfo&& rhs) = default;
|
||||
~LegacyPipelineCreateInfo();
|
||||
};
|
||||
|
||||
@@ -243,8 +241,6 @@ struct MeshPipelineCreateInfo
|
||||
DepthStencilState depthStencilState;
|
||||
ColorBlendState colorBlend;
|
||||
MeshPipelineCreateInfo();
|
||||
MeshPipelineCreateInfo(MeshPipelineCreateInfo&& rhs) = default;
|
||||
MeshPipelineCreateInfo& operator=(MeshPipelineCreateInfo&& rhs) = default;
|
||||
~MeshPipelineCreateInfo();
|
||||
};
|
||||
struct ComputePipelineCreateInfo
|
||||
@@ -252,8 +248,6 @@ struct ComputePipelineCreateInfo
|
||||
Gfx::PComputeShader computeShader;
|
||||
Gfx::PPipelineLayout pipelineLayout;
|
||||
ComputePipelineCreateInfo();
|
||||
ComputePipelineCreateInfo(ComputePipelineCreateInfo&& rhs) = default;
|
||||
ComputePipelineCreateInfo& operator=(ComputePipelineCreateInfo&& rhs) = default;
|
||||
~ComputePipelineCreateInfo();
|
||||
};
|
||||
} // namespace Gfx
|
||||
|
||||
@@ -68,9 +68,10 @@ public:
|
||||
virtual void drawMesh(uint32 groupX, uint32 groupY, uint32 groupZ) override;
|
||||
|
||||
private:
|
||||
PGraphicsPipeline boundPipeline;
|
||||
PIndexBuffer boundIndexBuffer;
|
||||
MTL::Buffer* argumentBuffer;
|
||||
MTL::RenderCommandEncoder* encoder;
|
||||
PIndexBuffer boundIndexBuffer;
|
||||
PGraphicsPipeline boundPipeline;
|
||||
std::string name;
|
||||
};
|
||||
DEFINE_REF(RenderCommand)
|
||||
@@ -90,6 +91,7 @@ private:
|
||||
PComputePipeline boundPipeline;
|
||||
MTL::CommandBuffer* commandBuffer;
|
||||
MTL::ComputeCommandEncoder* encoder;
|
||||
MTL::Buffer* argumentBuffer;
|
||||
std::string name;
|
||||
};
|
||||
DEFINE_REF(ComputeCommand)
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#include "Pipeline.h"
|
||||
#include "Resources.h"
|
||||
#include "Window.h"
|
||||
#include <Metal/Metal.h>
|
||||
|
||||
using namespace Seele;
|
||||
using namespace Seele::Metal;
|
||||
@@ -123,7 +122,7 @@ void RenderCommand::drawIndexed(uint32 indexCount, uint32 instanceCount, int32 f
|
||||
|
||||
void RenderCommand::drawMesh(uint32 groupX, uint32 groupY, uint32 groupZ) {
|
||||
// TODO:
|
||||
encoder->drawMeshThreadgroups(MTL::Size(groupX, groupY, groupZ), MTL::Size(128, 128, 128), MTL::Size(32, 32, 32));
|
||||
encoder->drawMeshThreadgroups(MTL::Size(groupX, groupY, groupZ), MTL::Size(128, 1, 1), MTL::Size(32, 1, 1));
|
||||
}
|
||||
|
||||
ComputeCommand::ComputeCommand(MTL::CommandBuffer* cmdBuffer, const std::string& name)
|
||||
@@ -139,13 +138,15 @@ void ComputeCommand::end() {
|
||||
void ComputeCommand::bindPipeline(Gfx::PComputePipeline pipeline) {
|
||||
boundPipeline = pipeline.cast<ComputePipeline>();
|
||||
encoder->setComputePipelineState(boundPipeline->getHandle());
|
||||
argumentBuffer = boundPipeline->graphics->getDevice()->newBuffer(sizeof(uint64) * boundPipeline->getPipelineLayout()->getLayouts().size(), MTL::ResourceOptionCPUCacheModeDefault);
|
||||
}
|
||||
|
||||
void ComputeCommand::bindDescriptor(Gfx::PDescriptorSet set) {
|
||||
auto metalSet = set.cast<DescriptorSet>();
|
||||
metalSet->bind();
|
||||
uint32 parameterIndex = boundPipeline->getPipelineLayout()->findParameter(set->getLayout()->getName());
|
||||
encoder->setBuffer(metalSet->getBuffer(), 0, parameterIndex);
|
||||
uint64* topLevelTable = (uint64*)argumentBuffer->contents();
|
||||
topLevelTable[parameterIndex] = metalSet->getBuffer()->gpuAddress();
|
||||
auto bindings =metalSet->getLayout()->getBindings();
|
||||
for(size_t i = 0; i < bindings.size(); ++i)
|
||||
{
|
||||
@@ -190,6 +191,7 @@ void ComputeCommand::pushConstants(Gfx::PPipelineLayout, Gfx::SeShaderStageFlags
|
||||
|
||||
void ComputeCommand::dispatch(uint32 threadX, uint32 threadY, uint32 threadZ) {
|
||||
// TODO
|
||||
encoder->setBuffer(argumentBuffer, 0, 2);
|
||||
encoder->dispatchThreadgroups(MTL::Size(threadX, threadY, threadZ), MTL::Size(32, 32, 1));
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
private:
|
||||
PGraphics graphics;
|
||||
PDescriptorPool owner;
|
||||
MTL::Buffer* buffer;
|
||||
MTL::Buffer* buffer = nullptr;
|
||||
MTL::ArgumentEncoder* encoder;
|
||||
Array<MTL::Resource*> boundResources;
|
||||
uint32 bindCount;
|
||||
|
||||
@@ -116,16 +116,14 @@ void DescriptorPool::reset() {
|
||||
|
||||
DescriptorSet::DescriptorSet(PGraphics graphics, PDescriptorPool owner)
|
||||
: Gfx::DescriptorSet(owner->getLayout()), graphics(graphics), owner(owner), bindCount(0), currentlyInUse(false) {
|
||||
// auto desc = (MTL::ArgumentDescriptor*)owner->getArguments()->object(0);
|
||||
// std::cout << desc->access() << " " << desc->arrayLength() << " " << desc->index() << " " << desc->textureType() <<
|
||||
// " " << desc->dataType() << std::endl;
|
||||
if (owner->getArguments()->count() == 0) {
|
||||
buffer = graphics->getDevice()->newBuffer(0, MTL::ResourceOptionCPUCacheModeDefault);
|
||||
} else {
|
||||
boundResources.resize(owner->getArguments()->count());
|
||||
encoder = graphics->getDevice()->newArgumentEncoder(owner->getArguments());
|
||||
buffer = graphics->getDevice()->newBuffer(encoder->encodedLength(), MTL::ResourceOptionCPUCacheModeDefault);
|
||||
encoder->setArgumentBuffer(buffer, 0);
|
||||
if (owner->getArguments()->count() > 0) {
|
||||
boundResources.resize(owner->getArguments()->count());
|
||||
encoder = graphics->getDevice()->newArgumentEncoder(owner->getArguments());
|
||||
buffer = graphics->getDevice()->newBuffer(encoder->encodedLength(), MTL::ResourceOptionCPUCacheModeDefault);
|
||||
encoder->setArgumentBuffer(buffer, 0);
|
||||
} else
|
||||
{
|
||||
buffer = graphics->getDevice()->newBuffer(8, MTL::ResourceOptionCPUCacheModeDefault);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +147,13 @@ void DescriptorSet::updateSampler(uint32_t binding, Gfx::PSampler samplerState)
|
||||
}
|
||||
void DescriptorSet::updateTexture(uint32_t binding, Gfx::PTexture texture, Gfx::PSampler samplerState) {
|
||||
PTextureBase base = texture.cast<TextureBase>();
|
||||
encoder->setTexture(base->getTexture(), binding);
|
||||
if(layout->getBindings()[binding].access == Gfx::SE_DESCRIPTOR_ACCESS_READ_ONLY_BIT)
|
||||
{
|
||||
encoder->setTexture(base->getTexture(), binding);
|
||||
|
||||
}else{
|
||||
encoder->setBuffer(base->getTexture()->buffer(), 0, binding);
|
||||
}
|
||||
boundResources[binding] = base->getTexture();
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ void Graphics::init(GraphicsInitializer)
|
||||
queue = new CommandQueue(this);
|
||||
ioQueue = new IOCommandQueue(this);
|
||||
cache = new PipelineCache(this, "pipelines.metal");
|
||||
meshShadingEnabled = false;
|
||||
meshShadingEnabled = true;
|
||||
}
|
||||
|
||||
Gfx::OWindow Graphics::createWindow(const WindowCreateInfo &createInfo)
|
||||
|
||||
@@ -31,8 +31,8 @@ public:
|
||||
virtual ~ComputePipeline();
|
||||
constexpr MTL::ComputePipelineState* getHandle() const { return state; }
|
||||
|
||||
private:
|
||||
PGraphics graphics;
|
||||
private:
|
||||
MTL::ComputePipelineState* state;
|
||||
};
|
||||
DEFINE_REF(ComputePipeline)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "Shader.h"
|
||||
#include "Descriptor.h"
|
||||
#include "Foundation/NSError.hpp"
|
||||
#include "Foundation/NSString.hpp"
|
||||
#include "Graphics.h"
|
||||
@@ -6,7 +7,6 @@
|
||||
#include "Graphics/slang-compile.h"
|
||||
#include "Metal/MTLDevice.hpp"
|
||||
#include "Metal/MTLLibrary.hpp"
|
||||
#include "Descriptor.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <metal_irconverter/metal_irconverter.h>
|
||||
@@ -25,75 +25,83 @@ Shader::~Shader() {
|
||||
}
|
||||
|
||||
void Shader::create(const ShaderCreateInfo& createInfo) {
|
||||
Map<std::string, uint32> test;
|
||||
std::cout << "Compiling " << createInfo.name << std::endl;
|
||||
Map<std::string, uint32> test;
|
||||
Slang::ComPtr<slang::IBlob> kernelBlob = generateShader(createInfo, SLANG_DXIL, test);
|
||||
hash = CRC::Calculate(kernelBlob->getBufferPointer(), kernelBlob->getBufferSize(), CRC::CRC_32());
|
||||
IRCompiler* pCompiler = IRCompilerCreate();
|
||||
IRCompilerSetMinimumGPUFamily(pCompiler, IRGPUFamilyMetal3);
|
||||
IRCompilerIgnoreRootSignature(pCompiler, true);
|
||||
IRCompilerSetMinimumGPUFamily(pCompiler, IRGPUFamilyMetal3);
|
||||
IRCompilerIgnoreRootSignature(pCompiler, true);
|
||||
IRCompilerSetEntryPointName(pCompiler, "main");
|
||||
IRCompilerSetValidationFlags(pCompiler, IRCompilerValidationFlagAll);
|
||||
|
||||
IRObject* pDXIL = IRObjectCreateFromDXIL((const uint8*)kernelBlob->getBufferPointer(), kernelBlob->getBufferSize(),
|
||||
IRBytecodeOwnershipNone);
|
||||
IRVersionedRootSignatureDescriptor descriptor;
|
||||
descriptor.version = IRRootSignatureVersion_1_1;
|
||||
Map<std::string, Gfx::PDescriptorLayout> layouts =createInfo.rootSignature->getLayouts();
|
||||
descriptor.desc_1_1.NumParameters = layouts.size();
|
||||
descriptor.desc_1_1.NumStaticSamplers = 0;
|
||||
descriptor.desc_1_1.pStaticSamplers = nullptr;
|
||||
Array<IRRootParameter1> parameters;
|
||||
// each layout has an array for its bindings
|
||||
Array<Array<IRDescriptorRange1>> ranges;
|
||||
for(const auto& [name, layout] : layouts)
|
||||
{
|
||||
uint32 textureReg = 0; // SRV
|
||||
uint32 samplerReg = 0; // Sampler
|
||||
uint32 uavReg = 0; // UAV
|
||||
uint32 constantReg = 0; // CBV
|
||||
auto& bindingRanges = ranges.add();
|
||||
for(auto binding : layout->getBindings())
|
||||
{
|
||||
IRDescriptorRangeType type;
|
||||
uint32 reg = 0;
|
||||
switch(binding.descriptorType)
|
||||
{
|
||||
case Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
|
||||
case Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER:
|
||||
type = IRDescriptorRangeTypeSRV;
|
||||
reg = textureReg++;
|
||||
break;
|
||||
case Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
|
||||
case Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
|
||||
type = IRDescriptorRangeTypeCBV;
|
||||
reg = constantReg++;
|
||||
break;
|
||||
case Gfx::SE_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
|
||||
case Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE:
|
||||
type = IRDescriptorRangeTypeUAV;
|
||||
reg = uavReg++;
|
||||
break;
|
||||
default: throw std::logic_error("Not implemented");
|
||||
};
|
||||
bindingRanges.add() = IRDescriptorRange1{
|
||||
.BaseShaderRegister = reg,
|
||||
.NumDescriptors = binding.descriptorCount,
|
||||
.RangeType = type,
|
||||
.RegisterSpace = createInfo.rootSignature->findParameter(name),
|
||||
};
|
||||
IRVersionedRootSignatureDescriptor descriptor;
|
||||
descriptor.version = IRRootSignatureVersion_1_1;
|
||||
Map<std::string, Gfx::PDescriptorLayout> layouts = createInfo.rootSignature->getLayouts();
|
||||
descriptor.desc_1_1.NumParameters = layouts.size();
|
||||
descriptor.desc_1_1.NumStaticSamplers = 0;
|
||||
descriptor.desc_1_1.pStaticSamplers = nullptr;
|
||||
Array<IRRootParameter1> parameters;
|
||||
// each layout has an array for its bindings
|
||||
Array<Array<IRDescriptorRange1>> ranges;
|
||||
for (const auto& [name, layout] : layouts) {
|
||||
uint32 textureReg = 0; // SRV
|
||||
uint32 samplerReg = 0; // Sampler
|
||||
uint32 uavReg = 0; // UAV
|
||||
uint32 constantReg = 0; // CBV
|
||||
auto& bindingRanges = ranges.add();
|
||||
for (auto binding : layout->getBindings()) {
|
||||
IRDescriptorRangeType type;
|
||||
uint32 reg = 0;
|
||||
switch (binding.descriptorType) {
|
||||
case Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE:
|
||||
type = IRDescriptorRangeTypeSRV;
|
||||
reg = textureReg++;
|
||||
break;
|
||||
case Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER:
|
||||
case Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER:
|
||||
type = IRDescriptorRangeTypeCBV;
|
||||
reg = constantReg++;
|
||||
break;
|
||||
case Gfx::SE_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER:
|
||||
case Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE:
|
||||
case Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER:
|
||||
if (binding.access == Gfx::SE_DESCRIPTOR_ACCESS_READ_ONLY_BIT) {
|
||||
type = IRDescriptorRangeTypeSRV;
|
||||
reg = textureReg++;
|
||||
break;
|
||||
} else {
|
||||
type = IRDescriptorRangeTypeUAV;
|
||||
reg = uavReg++;
|
||||
break;
|
||||
}
|
||||
parameters.add() = IRRootParameter1{
|
||||
.ParameterType = IRRootParameterTypeDescriptorTable,
|
||||
.DescriptorTable = IRRootDescriptorTable1{ .NumDescriptorRanges = (uint32)(bindingRanges.size()), bindingRanges.data() },
|
||||
.ShaderVisibility = IRShaderVisibilityAll,
|
||||
};
|
||||
default:
|
||||
throw std::logic_error("Not implemented");
|
||||
};
|
||||
bindingRanges.add() = IRDescriptorRange1{
|
||||
.BaseShaderRegister = reg,
|
||||
.NumDescriptors = binding.descriptorCount,
|
||||
.RangeType = type,
|
||||
.RegisterSpace = createInfo.rootSignature->findParameter(name),
|
||||
.Flags = IRDescriptorRangeFlagDescriptorsStaticKeepingBufferBoundsChecks,
|
||||
};
|
||||
}
|
||||
IRError* signatureError = nullptr;
|
||||
descriptor.desc_1_1.NumParameters = parameters.size();
|
||||
descriptor.desc_1_1.pParameters = parameters.data();
|
||||
IRRootSignature* rootSignature = IRRootSignatureCreateFromDescriptor(&descriptor, &signatureError);
|
||||
assert(rootSignature);
|
||||
IRCompilerSetGlobalRootSignature(pCompiler, rootSignature);
|
||||
// Compile DXIL to Metal IR:
|
||||
parameters.add() = IRRootParameter1{
|
||||
.ParameterType = IRRootParameterTypeDescriptorTable,
|
||||
.DescriptorTable =
|
||||
IRRootDescriptorTable1{.NumDescriptorRanges = (uint32)(bindingRanges.size()), bindingRanges.data()},
|
||||
.ShaderVisibility = IRShaderVisibilityAll,
|
||||
};
|
||||
}
|
||||
IRError* signatureError = nullptr;
|
||||
descriptor.desc_1_1.NumParameters = parameters.size();
|
||||
descriptor.desc_1_1.pParameters = parameters.data();
|
||||
IRRootSignature* rootSignature = IRRootSignatureCreateFromDescriptor(&descriptor, &signatureError);
|
||||
assert(rootSignature);
|
||||
IRCompilerSetGlobalRootSignature(pCompiler, rootSignature);
|
||||
// Compile DXIL to Metal IR:
|
||||
IRError* pError = nullptr;
|
||||
IRObject* pOutIR = IRCompilerAllocCompileAndLink(pCompiler, NULL, pDXIL, &pError);
|
||||
|
||||
@@ -124,18 +132,16 @@ void Shader::create(const ShaderCreateInfo& createInfo) {
|
||||
IRObjectGetMetalLibBinary(pOutIR, irStage, pMetallib);
|
||||
dispatch_data_t data = IRMetalLibGetBytecodeData(pMetallib);
|
||||
|
||||
IRShaderReflection* reflection = IRShaderReflectionCreate();
|
||||
IRObjectGetReflection(pOutIR, irStage, reflection);
|
||||
std::cout << " NumRes: " << IRShaderReflectionGetResourceCount(reflection) << std::endl;
|
||||
std::cout << IRShaderReflectionAllocStringAndSerialize(reflection) << std::endl;
|
||||
IRShaderReflectionDestroy(reflection);
|
||||
|
||||
IRShaderReflection* reflection = IRShaderReflectionCreate();
|
||||
IRObjectGetReflection(pOutIR, irStage, reflection);
|
||||
std::cout << IRShaderReflectionAllocStringAndSerialize(reflection) << std::endl;
|
||||
IRShaderReflectionDestroy(reflection);
|
||||
|
||||
// Store the metallib to custom format or disk, or use to create a MTLLibrary.
|
||||
NS::Error* error;
|
||||
library = graphics->getDevice()->newLibrary(data, &error);
|
||||
function = library->newFunction(NS::String::string("main", NS::ASCIIStringEncoding));
|
||||
if(!function)
|
||||
{
|
||||
if (!function) {
|
||||
assert(false);
|
||||
}
|
||||
IRMetalLibBinaryDestroy(pMetallib);
|
||||
|
||||
@@ -51,7 +51,6 @@ private:
|
||||
CAMetalLayer* metalLayer;
|
||||
CA::MetalDrawable* drawable;
|
||||
OTexture2D backBuffer;
|
||||
MTL::CaptureDescriptor* capture = nullptr;
|
||||
|
||||
std::function<void(KeyCode, InputAction, KeyModifier)> keyCallback;
|
||||
std::function<void(double, double)> mouseMoveCallback;
|
||||
|
||||
@@ -94,17 +94,6 @@ Window::~Window() { glfwDestroyWindow(static_cast<GLFWwindow*>(windowHandle)); }
|
||||
void Window::pollInput() { glfwPollEvents(); }
|
||||
|
||||
void Window::beginFrame() {
|
||||
auto captureManager = MTL::CaptureManager::sharedCaptureManager();
|
||||
capture = MTL::CaptureDescriptor::alloc()->init();
|
||||
capture->setCaptureObject((__bridge id<MTLDevice>)graphics->getDevice());
|
||||
capture->setDestination(MTL::CaptureDestinationDeveloperTools);
|
||||
capture->setOutputURL(NS::URL::fileURLWithPath(NS::String::string(fmt::format("frame{0}.trace", Gfx::getCurrentFrameIndex()).c_str(), NS::ASCIIStringEncoding)));
|
||||
NS::Error* error;
|
||||
captureManager->startCapture(capture, &error);
|
||||
if(error)
|
||||
{
|
||||
std::cout << error->localizedDescription()->cString(NS::ASCIIStringEncoding) << std::endl;
|
||||
}
|
||||
drawable = (__bridge CA::MetalDrawable*)[metalLayer nextDrawable];
|
||||
createBackBuffer();
|
||||
}
|
||||
@@ -112,7 +101,6 @@ void Window::beginFrame() {
|
||||
void Window::endFrame() {
|
||||
graphics->getQueue()->getCommands()->present(drawable);
|
||||
graphics->getQueue()->submitCommands();
|
||||
MTL::CaptureManager::sharedCaptureManager()->stopCapture();
|
||||
currentFrameIndex++;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,16 +49,12 @@ void BasePass::render()
|
||||
Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
|
||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
|
||||
|
||||
descriptorSets[INDEX_VIEW_PARAMS] = viewParamsSet;
|
||||
descriptorSets[INDEX_LIGHT_ENV] = scene->getLightEnvironment()->getDescriptorSet();
|
||||
|
||||
opaqueCulling->updateBuffer(0, oLightIndexList);
|
||||
opaqueCulling->updateTexture(1, oLightGrid);
|
||||
transparentCulling->updateBuffer(0, tLightIndexList);
|
||||
transparentCulling->updateTexture(1, tLightGrid);
|
||||
opaqueCulling->writeChanges();
|
||||
transparentCulling->writeChanges();
|
||||
descriptorSets[INDEX_LIGHT_CULLING] = opaqueCulling;
|
||||
|
||||
Gfx::ShaderPermutation permutation;
|
||||
if (graphics->supportMeshShading())
|
||||
@@ -122,12 +118,14 @@ void BasePass::render()
|
||||
Gfx::PGraphicsPipeline pipeline = graphics->createGraphicsPipeline(std::move(pipelineInfo));
|
||||
command->bindPipeline(pipeline);
|
||||
}
|
||||
descriptorSets[INDEX_VERTEX_DATA] = vertexData->getVertexDataSet();
|
||||
command->bindDescriptor(vertexData->getVertexDataSet());
|
||||
command->bindDescriptor(viewParamsSet);
|
||||
command->bindDescriptor(scene->getLightEnvironment()->getDescriptorSet());
|
||||
command->bindDescriptor(opaqueCulling);
|
||||
for (const auto& [_, instance] : materialData.instances)
|
||||
{
|
||||
descriptorSets[INDEX_MATERIAL] = instance.materialInstance->getDescriptorSet();
|
||||
descriptorSets[INDEX_SCENE_DATA] = instance.descriptorSet;
|
||||
command->bindDescriptor(descriptorSets);
|
||||
command->bindDescriptor(instance.materialInstance->getDescriptorSet());
|
||||
command->bindDescriptor(instance.descriptorSet);
|
||||
if (graphics->supportMeshShading())
|
||||
{
|
||||
command->drawMesh(instance.meshes.size(), 1, 1);
|
||||
@@ -166,9 +164,9 @@ void BasePass::publishOutputs()
|
||||
|
||||
lightCullingLayout = graphics->createDescriptorLayout("pLightCullingData");
|
||||
// oLightIndexList
|
||||
lightCullingLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
lightCullingLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 0, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,});
|
||||
// oLightGrid
|
||||
lightCullingLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE);
|
||||
lightCullingLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 1, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE,});
|
||||
lightCullingLayout->create();
|
||||
|
||||
basePassLayout->addDescriptorLayout(lightCullingLayout);
|
||||
|
||||
@@ -100,19 +100,19 @@ void LightCullingPass::publishOutputs()
|
||||
cullingDescriptorLayout = graphics->createDescriptorLayout("pCullingParams");
|
||||
|
||||
//DepthTexture
|
||||
cullingDescriptorLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE);
|
||||
cullingDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 0, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE,});
|
||||
//o_lightIndexCounter
|
||||
cullingDescriptorLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
cullingDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 1, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER, .access = Gfx::SE_DESCRIPTOR_ACCESS_READ_WRITE_BIT});
|
||||
//t_lightIndexCounter
|
||||
cullingDescriptorLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
cullingDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 2, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER, .access = Gfx::SE_DESCRIPTOR_ACCESS_READ_WRITE_BIT});
|
||||
//o_lightIndexList
|
||||
cullingDescriptorLayout->addDescriptorBinding(3, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
cullingDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 3, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER, .access = Gfx::SE_DESCRIPTOR_ACCESS_READ_WRITE_BIT});
|
||||
//t_lightIndexList
|
||||
cullingDescriptorLayout->addDescriptorBinding(4, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
cullingDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 4, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER, .access = Gfx::SE_DESCRIPTOR_ACCESS_READ_WRITE_BIT});
|
||||
//o_lightGrid
|
||||
cullingDescriptorLayout->addDescriptorBinding(5, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE);
|
||||
cullingDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 5, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE, .access = Gfx::SE_DESCRIPTOR_ACCESS_READ_WRITE_BIT});
|
||||
//t_lightGrid
|
||||
cullingDescriptorLayout->addDescriptorBinding(6, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE);
|
||||
cullingDescriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 6, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_IMAGE, .access = Gfx::SE_DESCRIPTOR_ACCESS_READ_WRITE_BIT});
|
||||
|
||||
lightEnv = scene->getLightEnvironment();
|
||||
|
||||
@@ -122,8 +122,10 @@ void LightCullingPass::publishOutputs()
|
||||
cullingLayout->addDescriptorLayout(cullingDescriptorLayout);
|
||||
cullingLayout->addDescriptorLayout(lightEnv->getDescriptorLayout());
|
||||
Map<std::string, uint32> mapping;
|
||||
mapping["pViewParams"] = 0;
|
||||
mapping["pDispatchParams"] = 1;
|
||||
mapping["pViewParams"] = 1;
|
||||
mapping["pDispatchParams"] = 2;
|
||||
mapping["pCullingParams"] = 0;
|
||||
mapping["pLightEnv"] = 3;
|
||||
cullingLayout->addMapping(mapping);
|
||||
cullingLayout->create();
|
||||
|
||||
@@ -209,8 +211,8 @@ void LightCullingPass::setupFrustums()
|
||||
dispatchParams.numThreadGroups = numThreadGroups;
|
||||
|
||||
dispatchParamsLayout = graphics->createDescriptorLayout("pDispatchParams");
|
||||
dispatchParamsLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||
dispatchParamsLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
dispatchParamsLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 0, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER, });
|
||||
dispatchParamsLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 1, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER, .access = Gfx::SE_DESCRIPTOR_ACCESS_WRITE_ONLY_BIT });
|
||||
frustumLayout = graphics->createPipelineLayout();
|
||||
frustumLayout->addDescriptorLayout(viewParamsLayout);
|
||||
frustumLayout->addDescriptorLayout(dispatchParamsLayout);
|
||||
@@ -231,8 +233,8 @@ void LightCullingPass::setupFrustums()
|
||||
|
||||
Gfx::ComputePipelineCreateInfo pipelineInfo;
|
||||
pipelineInfo.computeShader = frustumShader;
|
||||
pipelineInfo.pipelineLayout = std::move(frustumLayout);
|
||||
frustumPipeline = graphics->createComputePipeline(std::move(pipelineInfo));
|
||||
pipelineInfo.pipelineLayout = frustumLayout;
|
||||
frustumPipeline = graphics->createComputePipeline(pipelineInfo);
|
||||
|
||||
Gfx::OUniformBuffer frustumDispatchParamsBuffer = graphics->createUniformBuffer(UniformBufferCreateInfo{
|
||||
.sourceData = {
|
||||
|
||||
@@ -8,7 +8,7 @@ RenderPass::RenderPass(Gfx::PGraphics graphics, PScene scene)
|
||||
{
|
||||
|
||||
viewParamsLayout = graphics->createDescriptorLayout("pViewParams");
|
||||
viewParamsLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||
viewParamsLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 0, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER,});
|
||||
UniformBufferCreateInfo uniformInitializer = {
|
||||
.sourceData = {
|
||||
.size = sizeof(ViewParameter),
|
||||
@@ -56,5 +56,4 @@ void RenderPass::setResources(PRenderGraphResources _resources)
|
||||
void RenderPass::setViewport(Gfx::PViewport _viewport)
|
||||
{
|
||||
viewport = _viewport;
|
||||
publishOutputs();
|
||||
}
|
||||
|
||||
@@ -75,12 +75,12 @@ void SkyboxRenderPass::endFrame()
|
||||
void SkyboxRenderPass::publishOutputs()
|
||||
{
|
||||
skyboxDataLayout = graphics->createDescriptorLayout("pSkyboxData");
|
||||
skyboxDataLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||
skyboxDataLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 0, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER,});
|
||||
skyboxDataLayout->create();
|
||||
textureLayout = graphics->createDescriptorLayout("pSkyboxTextures");
|
||||
textureLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE);
|
||||
textureLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE);
|
||||
textureLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_SAMPLER);
|
||||
textureLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 0, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE,});
|
||||
textureLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 1, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE,});
|
||||
textureLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 2, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLER,});
|
||||
textureLayout->create();
|
||||
|
||||
skyboxSampler = graphics->createSampler({});
|
||||
|
||||
@@ -121,12 +121,12 @@ void TextPass::createRenderPass()
|
||||
createInfo.entryPoint = "fragmentMain";
|
||||
fragmentShader = graphics->createFragmentShader(createInfo);
|
||||
generalLayout = graphics->createDescriptorLayout("pRender");
|
||||
generalLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||
generalLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_SAMPLER);
|
||||
generalLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 0, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER,});
|
||||
generalLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 1, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLER,});
|
||||
generalLayout->create();
|
||||
|
||||
textureArrayLayout = graphics->createDescriptorLayout("pGlyphTextures");
|
||||
textureArrayLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE, Gfx::SE_IMAGE_VIEW_TYPE_2D_ARRAY, 256, Gfx::SE_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT);
|
||||
textureArrayLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 0, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE, .textureType = Gfx::SE_IMAGE_VIEW_TYPE_2D_ARRAY, .descriptorCount = 256, .bindingFlags = Gfx::SE_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT,});
|
||||
textureArrayLayout->create();
|
||||
|
||||
projectionBuffer = graphics->createUniformBuffer({
|
||||
|
||||
@@ -107,10 +107,10 @@ void UIPass::createRenderPass()
|
||||
fragmentShader = graphics->createFragmentShader(createInfo);
|
||||
|
||||
descriptorLayout = graphics->createDescriptorLayout("pParams");
|
||||
descriptorLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||
descriptorLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_SAMPLER);
|
||||
descriptorLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||
descriptorLayout->addDescriptorBinding(3, Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE, Gfx::SE_IMAGE_VIEW_TYPE_2D_ARRAY, 256, Gfx::SE_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT | Gfx::SE_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT);
|
||||
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 0, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER,});
|
||||
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 1, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLER,});
|
||||
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 2, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER,});
|
||||
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 3, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_SAMPLED_IMAGE, .textureType = Gfx::SE_IMAGE_VIEW_TYPE_2D_ARRAY, .descriptorCount = 256, .bindingFlags = Gfx::SE_DESCRIPTOR_BINDING_VARIABLE_DESCRIPTOR_COUNT_BIT | Gfx::SE_DESCRIPTOR_BINDING_PARTIALLY_BOUND_BIT,});
|
||||
descriptorLayout->create();
|
||||
|
||||
Matrix4 projectionMatrix = glm::ortho(0, 1, 1, 0);
|
||||
|
||||
@@ -81,6 +81,14 @@ void ShaderCompiler::compile()
|
||||
layout->addDescriptorLayout(vd->getVertexDataLayout());
|
||||
layout->addDescriptorLayout(vd->getInstanceDataLayout());
|
||||
layout->addDescriptorLayout(mat->getDescriptorLayout());
|
||||
Map<std::string, uint32> mapping;
|
||||
mapping["pLightCullingData"] = 1;
|
||||
mapping["pMaterial"] = 2;
|
||||
mapping["pViewParams"] = 3;
|
||||
mapping["pVertexData"] = 4;
|
||||
mapping["pScene"] = 5;
|
||||
mapping["pLightEnv"] = 6;
|
||||
layout->addMapping(mapping);
|
||||
permutation.setMaterial(mat->getName());
|
||||
createShaders(permutation, std::move(layout));
|
||||
}
|
||||
|
||||
@@ -117,12 +117,12 @@ void StaticMeshVertexData::init(Gfx::PGraphics _graphics)
|
||||
{
|
||||
VertexData::init(_graphics);
|
||||
descriptorLayout = _graphics->createDescriptorLayout("pVertexData");
|
||||
descriptorLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
descriptorLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
descriptorLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
descriptorLayout->addDescriptorBinding(3, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
descriptorLayout->addDescriptorBinding(4, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
descriptorLayout->addDescriptorBinding(5, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 0, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
||||
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 1, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
||||
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 2, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
||||
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 3, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
||||
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 4, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
||||
descriptorLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 5, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
||||
descriptorLayout->create();
|
||||
descriptorSet = descriptorLayout->allocateDescriptorSet();
|
||||
}
|
||||
|
||||
@@ -265,16 +265,16 @@ void Seele::VertexData::init(Gfx::PGraphics _graphics)
|
||||
graphics = _graphics;
|
||||
verticesAllocated = NUM_DEFAULT_ELEMENTS;
|
||||
instanceDataLayout = graphics->createDescriptorLayout("pScene");
|
||||
instanceDataLayout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
instanceDataLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding =0, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,});
|
||||
|
||||
// meshData
|
||||
instanceDataLayout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
instanceDataLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 1, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,});
|
||||
// meshletData
|
||||
instanceDataLayout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
instanceDataLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding =2, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
||||
// primitiveIndices
|
||||
instanceDataLayout->addDescriptorBinding(3, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
instanceDataLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding =3, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
||||
// vetexIndices
|
||||
instanceDataLayout->addDescriptorBinding(4, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
instanceDataLayout->addDescriptorBinding(Gfx::DescriptorBinding{.binding =4, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER});
|
||||
|
||||
instanceDataLayout->create();
|
||||
resizeBuffers();
|
||||
|
||||
@@ -106,7 +106,7 @@ void Material::load(ArchiveBuffer& buffer)
|
||||
Gfx::SeShaderStageFlags shaderStages;
|
||||
Serialization::load(buffer, shaderStages);
|
||||
|
||||
layout->addDescriptorBinding(binding, descriptorType, textureType, descriptorCount, bindingFlags, shaderStages);
|
||||
layout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = binding, .descriptorType = descriptorType, .textureType = textureType, .descriptorCount = descriptorCount, .bindingFlags = bindingFlags, .shaderStages = shaderStages,});
|
||||
}
|
||||
layout->create();
|
||||
}
|
||||
|
||||
@@ -7,9 +7,9 @@ LightEnvironment::LightEnvironment(Gfx::PGraphics graphics)
|
||||
: graphics(graphics)
|
||||
{
|
||||
layout = graphics->createDescriptorLayout("pLightEnv");
|
||||
layout->addDescriptorBinding(0, Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER);
|
||||
layout->addDescriptorBinding(1, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
layout->addDescriptorBinding(2, Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER);
|
||||
layout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 0, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_UNIFORM_BUFFER,});
|
||||
layout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 1, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,});
|
||||
layout->addDescriptorBinding(Gfx::DescriptorBinding{.binding = 2, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER,});
|
||||
layout->create();
|
||||
lightEnvBuffer = graphics->createUniformBuffer(UniformBufferCreateInfo{
|
||||
.sourceData = {
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
"gtest",
|
||||
"vulkan-memory-allocator",
|
||||
"shader-slang",
|
||||
"spirv-cross",
|
||||
"glslang"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user