Fixing descriptors a little
This commit is contained in:
@@ -331,9 +331,11 @@ Gfx::PDescriptorSet DescriptorAllocator::allocateDescriptorSet()
|
||||
counts = binding.descriptorCount;
|
||||
}
|
||||
}
|
||||
setCounts.pDescriptorCounts = &counts;
|
||||
allocInfo.pNext = &setCounts;
|
||||
|
||||
if (layout.bindings.size() > 0)
|
||||
{
|
||||
setCounts.pDescriptorCounts = &counts;
|
||||
allocInfo.pNext = &setCounts;
|
||||
}
|
||||
for(uint32 setIndex = 0; setIndex < cachedHandles.size(); ++setIndex)
|
||||
{
|
||||
if(cachedHandles[setIndex] == nullptr)
|
||||
|
||||
@@ -27,6 +27,9 @@ uint32 Seele::Vulkan::Shader::getShaderHash() const
|
||||
return hash;
|
||||
}
|
||||
|
||||
#define CHECK_RESULT(x) {SlangResult r = x; if(r != 0) {throw std::runtime_error(std::format("Error: {0}", r));}}
|
||||
#define CHECK_DIAGNOSTICS() {if(diagnostics) {std::cout << (const char*)diagnostics->getBufferPointer() << std::endl; assert(false);}}
|
||||
|
||||
void Shader::create(const ShaderCreateInfo& createInfo)
|
||||
{
|
||||
entryPointName = createInfo.entryPoint;
|
||||
@@ -58,7 +61,7 @@ void Shader::create(const ShaderCreateInfo& createInfo)
|
||||
sessionDesc.searchPathCount = searchPaths.size();
|
||||
|
||||
Slang::ComPtr<slang::ISession> session;
|
||||
globalSession->createSession(sessionDesc, session.writeRef());
|
||||
CHECK_RESULT(globalSession->createSession(sessionDesc, session.writeRef()));
|
||||
|
||||
Slang::ComPtr<slang::IBlob> diagnostics;
|
||||
Array<slang::IComponentType*> modules;
|
||||
@@ -71,16 +74,10 @@ void Shader::create(const ShaderCreateInfo& createInfo)
|
||||
{
|
||||
mainModule = (slang::IModule*)modules.back();
|
||||
}
|
||||
if(diagnostics)
|
||||
{
|
||||
std::cout << (const char*)diagnostics->getBufferPointer() << std::endl;
|
||||
}
|
||||
CHECK_DIAGNOSTICS();
|
||||
}
|
||||
|
||||
if(diagnostics)
|
||||
{
|
||||
std::cout << (const char*)diagnostics->getBufferPointer() << std::endl;
|
||||
}
|
||||
CHECK_DIAGNOSTICS();
|
||||
|
||||
mainModule->findEntryPointByName(createInfo.entryPoint.c_str(), entrypoint.writeRef());
|
||||
modules.add(entrypoint);
|
||||
@@ -88,23 +85,16 @@ void Shader::create(const ShaderCreateInfo& createInfo)
|
||||
Slang::ComPtr<slang::IComponentType> moduleComposition;
|
||||
session->createCompositeComponentType(modules.data(), modules.size(), moduleComposition.writeRef(), diagnostics.writeRef());
|
||||
|
||||
if(diagnostics)
|
||||
{
|
||||
std::cout << (const char*)diagnostics->getBufferPointer() << std::endl;
|
||||
}
|
||||
|
||||
CHECK_DIAGNOSTICS();
|
||||
|
||||
Slang::ComPtr<slang::IComponentType> linkedProgram;
|
||||
moduleComposition->link(linkedProgram.writeRef(), diagnostics.writeRef());
|
||||
if(diagnostics)
|
||||
{
|
||||
std::cout << (const char*)diagnostics->getBufferPointer() << std::endl;
|
||||
}
|
||||
|
||||
CHECK_DIAGNOSTICS();
|
||||
|
||||
slang::ProgramLayout* reflection = linkedProgram->getLayout(0, diagnostics.writeRef());
|
||||
if(diagnostics)
|
||||
{
|
||||
std::cout << (const char*)diagnostics->getBufferPointer() << std::endl;
|
||||
}
|
||||
|
||||
CHECK_DIAGNOSTICS();
|
||||
|
||||
Array<slang::SpecializationArg> specialization;
|
||||
for(const auto& [key, value] : createInfo.typeParameter)
|
||||
@@ -113,10 +103,8 @@ void Shader::create(const ShaderCreateInfo& createInfo)
|
||||
}
|
||||
Slang::ComPtr<slang::IComponentType> specializedComponent;
|
||||
linkedProgram->specialize(specialization.data(), specialization.size(), specializedComponent.writeRef(), diagnostics.writeRef());
|
||||
if(diagnostics)
|
||||
{
|
||||
std::cout << (const char*)diagnostics->getBufferPointer() << std::endl;
|
||||
}
|
||||
CHECK_DIAGNOSTICS();
|
||||
|
||||
Slang::ComPtr<slang::IBlob> kernelBlob;
|
||||
specializedComponent->getEntryPointCode(
|
||||
0,
|
||||
@@ -124,16 +112,13 @@ void Shader::create(const ShaderCreateInfo& createInfo)
|
||||
kernelBlob.writeRef(),
|
||||
diagnostics.writeRef()
|
||||
);
|
||||
if(diagnostics)
|
||||
{
|
||||
std::cout << (const char*)diagnostics->getBufferPointer() << std::endl;
|
||||
}
|
||||
CHECK_DIAGNOSTICS();
|
||||
|
||||
for (uint32 i = 0; i < reflection->getParameterCount(); ++i)
|
||||
{
|
||||
slang::VariableLayoutReflection* varLayout = reflection->getParameterByIndex(i);
|
||||
std::cout << varLayout->getName() << " in space " << varLayout->getBindingSpace() << " index " << varLayout->getBindingIndex() << std::endl;
|
||||
//std::cout << varLayout->getName() << " in space " << varLayout->getBindingSpace() << " index " << varLayout->getBindingIndex() << std::endl;
|
||||
}
|
||||
std::cout << reflection->getGlobalConstantBufferSize() << std::endl;
|
||||
VkShaderModuleCreateInfo moduleInfo =
|
||||
{
|
||||
.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
|
||||
@@ -146,5 +131,4 @@ void Shader::create(const ShaderCreateInfo& createInfo)
|
||||
|
||||
hash = CRC::Calculate(entryPointName.data(), entryPointName.size(), CRC::CRC_32());
|
||||
hash = CRC::Calculate(kernelBlob->getBufferPointer(), kernelBlob->getBufferSize(), CRC::CRC_32(), hash);
|
||||
std::cout << "Creating Shader" << std::endl;
|
||||
}
|
||||
@@ -39,6 +39,7 @@ MaterialInstance::MaterialInstance(uint64 id,
|
||||
OShaderParameter param;
|
||||
Serialization::load(buffer, param);
|
||||
parameters.add(std::move(param));
|
||||
buffer.rewind();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,7 +51,6 @@ MaterialInstance::~MaterialInstance()
|
||||
void MaterialInstance::updateDescriptor()
|
||||
{
|
||||
Gfx::PDescriptorLayout layout = baseMaterial->getMaterial()->getDescriptorLayout();
|
||||
layout->reset();
|
||||
descriptor = layout->allocateDescriptorSet();
|
||||
for (auto& param : parameters)
|
||||
{
|
||||
|
||||
@@ -79,7 +79,6 @@ std::string ShaderParameter::evaluate(Map<std::string, std::string>& varState) c
|
||||
void ShaderParameter::save(ArchiveBuffer& buffer) const
|
||||
{
|
||||
ShaderExpression::save(buffer);
|
||||
Serialization::save(buffer, key);
|
||||
Serialization::save(buffer, byteOffset);
|
||||
Serialization::save(buffer, binding);
|
||||
}
|
||||
@@ -87,7 +86,6 @@ void ShaderParameter::save(ArchiveBuffer& buffer) const
|
||||
void ShaderParameter::load(ArchiveBuffer& buffer)
|
||||
{
|
||||
ShaderExpression::load(buffer);
|
||||
Serialization::load(buffer, key);
|
||||
Serialization::load(buffer, byteOffset);
|
||||
Serialization::load(buffer, binding);
|
||||
}
|
||||
|
||||
@@ -60,6 +60,10 @@ void LightEnvironment::addPointLight(Component::PointLight pointLight)
|
||||
|
||||
void LightEnvironment::commit()
|
||||
{
|
||||
dirs.add(Component::DirectionalLight{
|
||||
.color = Vector4(1, 1, 1, 1),
|
||||
.direction = Vector4(1, 0, 1, 0),
|
||||
});
|
||||
lightEnv.numDirectionalLights = dirs.size();
|
||||
lightEnv.numPointLights = points.size();
|
||||
lightEnvBuffer->updateContents(DataSource{
|
||||
|
||||
Reference in New Issue
Block a user