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