Fixing some descriptor binding stuff, made it work
This commit is contained in:
+4
-1
@@ -3,4 +3,7 @@
|
||||
url = https://github.com/d-bahr/CRCpp.git
|
||||
[submodule "external/vcpkg"]
|
||||
path = external/vcpkg
|
||||
url = https://github.com/Microsoft/vcpkg.git
|
||||
url = https://github.com/Microsoft/vcpkg.git
|
||||
[submodule "external/slang"]
|
||||
path = external/slang
|
||||
url = https://github.com/shader-slang/slang.git
|
||||
|
||||
+4
-8
@@ -98,8 +98,8 @@ target_include_directories(AssetViewer PRIVATE src/AssetViewer)
|
||||
|
||||
if(MSVC)
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||
target_compile_options(Engine PUBLIC /std:c++20 /Zi /MP14 /W4 /wd4505 /fsanitize=address)
|
||||
target_compile_options(Editor PUBLIC /std:c++20 /Zi /MP14 /W4 /fsanitize=address)
|
||||
target_compile_options(Engine PUBLIC /std:c++20 /Zi /MP14 /W4 /wd4505)
|
||||
target_compile_options(Editor PUBLIC /std:c++20 /Zi /MP14 /W4)
|
||||
target_sources(Engine INTERFACE
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/Seele.natvis>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/Seele/Seele.natvis>
|
||||
@@ -107,13 +107,9 @@ if(MSVC)
|
||||
install(FILES
|
||||
Seele.natvis
|
||||
DESTINATION Seele/)
|
||||
target_link_options(Engine PUBLIC /fsanitize=address /DEBUG)
|
||||
target_link_options(Editor PUBLIC /fsanitize=address /DEBUG)
|
||||
else()
|
||||
target_compile_options(Engine PUBLIC -g -Wall -Wextra -Wno-error -pedantic -std=c++20 -Wno-missing-field-initializers -Wno-unused-function -fsanitize=address)
|
||||
target_compile_options(Editor PUBLIC -g -Wall -Wextra -Wno-error -pedantic -std=c++20 -fsanitize=address)
|
||||
target_link_options(Engine PUBLIC -fsanitize=address)
|
||||
target_link_options(Editor PUBLIC -fsanitize=address)
|
||||
target_compile_options(Engine PUBLIC -g -Wall -Wextra -Wno-error -pedantic -std=c++20 -Wno-missing-field-initializers -Wno-unused-function)
|
||||
target_compile_options(Editor PUBLIC -g -Wall -Wextra -Wno-error -pedantic -std=c++20)
|
||||
endif()
|
||||
if(APPLE)
|
||||
#Metal lib throws that internally for some reason
|
||||
|
||||
+5
-5
@@ -9,14 +9,14 @@
|
||||
"intelliSenseMode": "windows-msvc-x64",
|
||||
"inheritEnvironments": [ "msvc_x64" ],
|
||||
"cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=\"\" -DCMAKE_PLATFORM=x64",
|
||||
"buildRoot": "C:/Users/Dynamitos/Seele/build",
|
||||
"buildRoot": "${workspaceRoot}/build",
|
||||
"installRoot": "C:/Program Files/Seele"
|
||||
},
|
||||
{
|
||||
"name": "Release",
|
||||
"generator": "Visual Studio 17 2022 Win64",
|
||||
"configurationType": "Release",
|
||||
"buildRoot": "C:/Users/Dynamitos/Seele/build/",
|
||||
"buildRoot": "${workspaceRoot}/build",
|
||||
"cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=\"\" -DCMAKE_PLATFORM=x64",
|
||||
"buildCommandArgs": "",
|
||||
"ctestCommandArgs": "",
|
||||
@@ -28,7 +28,7 @@
|
||||
"name": "RelWithDebInfo",
|
||||
"generator": "Visual Studio 17 2022 Win64",
|
||||
"configurationType": "RelWithDebInfo",
|
||||
"buildRoot": "C:/Users/Dynamitos/Seele/build/",
|
||||
"buildRoot": "${workspaceRoot}/build",
|
||||
"installRoot": "C:/Program Files/Seele",
|
||||
"cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=\"\" -DCMAKE_PLATFORM=x64",
|
||||
"buildCommandArgs": "",
|
||||
@@ -45,7 +45,7 @@
|
||||
"intelliSenseMode": "windows-msvc-x64",
|
||||
"inheritEnvironments": [ "msvc_x64" ],
|
||||
"cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=\"\" -DCMAKE_PLATFORM=x64",
|
||||
"buildRoot": "C:/Users/Dynamitos/Seele/build/",
|
||||
"buildRoot": "${workspaceRoot}/build",
|
||||
"installRoot": "C:/Program Files/Seele",
|
||||
"addressSanitizerEnabled": true
|
||||
},
|
||||
@@ -53,7 +53,7 @@
|
||||
"name": "MinSizeRel",
|
||||
"generator": "Visual Studio 17 2022 Win64",
|
||||
"configurationType": "MinSizeRel",
|
||||
"buildRoot": "C:/Users/Dynamitos/Seele/build/",
|
||||
"buildRoot": "${workspaceRoot}/build",
|
||||
"installRoot": "C:/Program Files/Seele",
|
||||
"cmakeCommandArgs": "-DCMAKE_DEBUG_POSTFIX=\"\" -DCMAKE_PLATFORM=x64",
|
||||
"buildCommandArgs": "",
|
||||
|
||||
+1
Submodule external/slang added at 62b7219e71
Vendored
+1
-1
Submodule external/vcpkg updated: 943c5ef1c8...4002e5f359
@@ -134,21 +134,21 @@ public:
|
||||
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
||||
|
||||
constexpr List()
|
||||
: root(nullptr)
|
||||
, tail(nullptr)
|
||||
: allocator(Allocator())
|
||||
, root(allocateNode())
|
||||
, tail(root)
|
||||
, beginIt(Iterator(root))
|
||||
, endIt(Iterator(tail))
|
||||
, _size(0)
|
||||
, allocator(Allocator())
|
||||
{
|
||||
}
|
||||
constexpr explicit List(const Allocator& alloc)
|
||||
: root(nullptr)
|
||||
, tail(nullptr)
|
||||
: allocator(alloc)
|
||||
, root(allocateNode())
|
||||
, tail(root)
|
||||
, beginIt(Iterator(root))
|
||||
, endIt(Iterator(tail))
|
||||
, _size(0)
|
||||
, allocator(alloc)
|
||||
{
|
||||
}
|
||||
constexpr List(size_type count, const T& value = T(), const Allocator& alloc = Allocator())
|
||||
@@ -187,28 +187,33 @@ public:
|
||||
}
|
||||
}
|
||||
constexpr List(List&& other)
|
||||
: root(std::move(other.root))
|
||||
: allocator(std::move(other.allocator))
|
||||
, root(std::move(other.root))
|
||||
, tail(std::move(other.tail))
|
||||
, beginIt(std::move(other.beginIt))
|
||||
, endIt(std::move(other.endIt))
|
||||
, _size(std::move(other._size))
|
||||
, allocator(std::move(other.allocator))
|
||||
{
|
||||
other.root = nullptr;
|
||||
other.tail = nullptr;
|
||||
other._size = 0;
|
||||
}
|
||||
constexpr List(List&& other, const Allocator& alloc)
|
||||
: root(std::move(other.root))
|
||||
: allocator(alloc)
|
||||
, root(std::move(other.root))
|
||||
, tail(std::move(other.tail))
|
||||
, beginIt(std::move(other.beginIt))
|
||||
, endIt(std::move(other.endIt))
|
||||
, _size(std::move(other._size))
|
||||
, allocator(alloc)
|
||||
{
|
||||
other.root = nullptr;
|
||||
other.tail = nullptr;
|
||||
other._size = 0;
|
||||
}
|
||||
constexpr ~List()
|
||||
{
|
||||
clear();
|
||||
deallocateNode(tail);
|
||||
}
|
||||
constexpr List& operator=(const List& other)
|
||||
{
|
||||
@@ -246,6 +251,8 @@ public:
|
||||
beginIt = other.beginIt;
|
||||
endIt = other.endIt;
|
||||
_size = other._size;
|
||||
other.root = nullptr;
|
||||
other.tail = nullptr;
|
||||
other._size = 0;
|
||||
markIteratorDirty();
|
||||
}
|
||||
@@ -272,9 +279,7 @@ public:
|
||||
destroyNode(tmp->prev);
|
||||
deallocateNode(tmp->prev);
|
||||
}
|
||||
deallocateNode(tail);
|
||||
tail = nullptr;
|
||||
root = nullptr;
|
||||
root = tail;
|
||||
markIteratorDirty();
|
||||
_size = 0;
|
||||
}
|
||||
@@ -287,29 +292,9 @@ public:
|
||||
{
|
||||
return addInternal(std::move(value));
|
||||
}
|
||||
// takes all elements from other and move-inserts them into
|
||||
// this, clearing other in the process
|
||||
constexpr void moveElements(List&& other)
|
||||
{
|
||||
tail->prev->next = other.root;
|
||||
other.root->prev = tail->prev;
|
||||
_size += other._size;
|
||||
deallocateNode(tail);
|
||||
tail = other.tail;
|
||||
other._size = 0;
|
||||
other.root = nullptr;
|
||||
other.tail = nullptr;
|
||||
markIteratorDirty();
|
||||
other.markIteratorDirty();
|
||||
}
|
||||
template<typename... args>
|
||||
constexpr reference emplace(args... arguments)
|
||||
{
|
||||
if (root == nullptr)
|
||||
{
|
||||
root = allocateNode();
|
||||
tail = root;
|
||||
}
|
||||
std::allocator_traits<NodeAllocator>::construct(allocator,
|
||||
tail,
|
||||
tail->prev,
|
||||
@@ -355,12 +340,6 @@ public:
|
||||
}
|
||||
destroyNode(pos.node);
|
||||
deallocateNode(pos.node);
|
||||
if (_size == 0)
|
||||
{
|
||||
deallocateNode(tail);
|
||||
root = nullptr;
|
||||
tail = nullptr;
|
||||
}
|
||||
markIteratorDirty();
|
||||
return Iterator(next);
|
||||
}
|
||||
@@ -387,25 +366,20 @@ public:
|
||||
constexpr iterator insert(iterator pos, const T &value)
|
||||
{
|
||||
_size++;
|
||||
if (root == nullptr)
|
||||
{
|
||||
root = allocateNode();
|
||||
root->data = value;
|
||||
tail = allocateNode();
|
||||
root->next = tail;
|
||||
root->prev = nullptr;
|
||||
tail->prev = root;
|
||||
tail->next = nullptr;
|
||||
markIteratorDirty();
|
||||
return beginIt;
|
||||
}
|
||||
Node *tmp = pos.node->prev;
|
||||
Node *newNode = allocateNode();
|
||||
initializeNode(newNode, value);
|
||||
tmp->next = newNode;
|
||||
newNode->prev = tmp;
|
||||
newNode->next = pos.node;
|
||||
pos.node->prev = newNode;
|
||||
Node *tmp = pos.node->prev;
|
||||
if (tmp != nullptr)
|
||||
{
|
||||
tmp->next = newNode;
|
||||
newNode->prev = tmp;
|
||||
}
|
||||
else
|
||||
{
|
||||
root = newNode;
|
||||
}
|
||||
markIteratorDirty();
|
||||
return Iterator(newNode);
|
||||
}
|
||||
@@ -474,11 +448,6 @@ private:
|
||||
template<typename ValueType>
|
||||
constexpr iterator addInternal(ValueType&& value)
|
||||
{
|
||||
if (root == nullptr)
|
||||
{
|
||||
root = allocateNode();
|
||||
tail = root;
|
||||
}
|
||||
initializeNode(tail, std::forward<ValueType>(value));
|
||||
Node* newTail = allocateNode();
|
||||
newTail->prev = tail;
|
||||
@@ -497,6 +466,7 @@ private:
|
||||
cbeginIt = ConstIterator(root);
|
||||
cendIt = ConstIterator(tail);
|
||||
}
|
||||
NodeAllocator allocator;
|
||||
Node *root;
|
||||
Node *tail;
|
||||
iterator beginIt;
|
||||
@@ -504,6 +474,5 @@ private:
|
||||
const_iterator cbeginIt;
|
||||
const_iterator cendIt;
|
||||
size_type _size;
|
||||
NodeAllocator allocator;
|
||||
};
|
||||
} // namespace Seele
|
||||
@@ -70,7 +70,7 @@ void ShaderCompiler::compile()
|
||||
{
|
||||
for (const auto& [matName, mat] : materials)
|
||||
{
|
||||
work.add([=]() {
|
||||
//work.add([=]() {
|
||||
ShaderPermutation permutation;
|
||||
if (pass.positionOnly)
|
||||
{
|
||||
@@ -99,12 +99,12 @@ void ShaderCompiler::compile()
|
||||
layout->addDescriptorLayout(mat->getDescriptorLayout());
|
||||
permutation.setMaterial(mat->getName());
|
||||
createShaders(permutation, std::move(layout));
|
||||
});
|
||||
//});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
work.add([=]() {
|
||||
//work.add([=]() {
|
||||
ShaderPermutation permutation;
|
||||
if (pass.positionOnly)
|
||||
{
|
||||
@@ -131,11 +131,11 @@ void ShaderCompiler::compile()
|
||||
layout->addDescriptorLayout(vd->getVertexDataLayout());
|
||||
layout->addDescriptorLayout(vd->getInstanceDataLayout());
|
||||
createShaders(permutation, std::move(layout));
|
||||
});
|
||||
//});
|
||||
}
|
||||
}
|
||||
}
|
||||
getThreadPool().runAndWait(std::move(work));
|
||||
//getThreadPool().runAndWait(std::move(work));
|
||||
}
|
||||
|
||||
void ShaderCompiler::createShaders(ShaderPermutation permutation, Gfx::OPipelineLayout layout)
|
||||
|
||||
@@ -137,8 +137,7 @@ void VertexData::createDescriptors()
|
||||
.size = cullingOffsets.size() * sizeof(uint32),
|
||||
.data = (uint8*)cullingOffsets.data(),
|
||||
},
|
||||
.numElements = cullingOffsets.size(),
|
||||
.name = "MeshletOffset"
|
||||
.numElements = cullingOffsets.size()
|
||||
});
|
||||
cullingOffsetBuffer->pipelineBarrier(
|
||||
Gfx::SE_ACCESS_TRANSFER_WRITE_BIT,
|
||||
@@ -151,9 +150,8 @@ void VertexData::createDescriptors()
|
||||
.sourceData = {
|
||||
.size = numMeshlets * sizeof(uint32),
|
||||
},
|
||||
.numElements = numMeshlets,
|
||||
.name = "MeshletCulling"
|
||||
});
|
||||
.numElements = numMeshlets
|
||||
});
|
||||
cullingBuffer->pipelineBarrier(
|
||||
Gfx::SE_ACCESS_TRANSFER_WRITE_BIT,
|
||||
Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
@@ -166,8 +164,7 @@ void VertexData::createDescriptors()
|
||||
.size = instanceData.size() * sizeof(InstanceData),
|
||||
.data = (uint8*)instanceData.data(),
|
||||
},
|
||||
.numElements = instanceData.size(),
|
||||
.name = "InstanceBuffer"
|
||||
.numElements = instanceData.size()
|
||||
});
|
||||
instanceBuffer->pipelineBarrier(
|
||||
Gfx::SE_ACCESS_TRANSFER_WRITE_BIT,
|
||||
@@ -182,8 +179,7 @@ void VertexData::createDescriptors()
|
||||
.size = sizeof(MeshData) * instanceMeshData.size(),
|
||||
.data = (uint8*)instanceMeshData.data(),
|
||||
},
|
||||
.numElements = instanceMeshData.size(),
|
||||
.name = "MeshDataBuffer"
|
||||
.numElements = instanceMeshData.size()
|
||||
});
|
||||
instanceMeshDataBuffer->pipelineBarrier(
|
||||
Gfx::SE_ACCESS_TRANSFER_WRITE_BIT,
|
||||
@@ -236,8 +232,8 @@ void VertexData::loadMesh(MeshId id, Array<uint32> loadedIndices, Array<Meshlet>
|
||||
.bounding = meshAABB,//.toSphere(),
|
||||
.numMeshlets = (uint32)loadedMeshlets.size(),
|
||||
.meshletOffset = meshletOffset,
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
meshData[id].firstIndex = indices.size();
|
||||
meshData[id].numIndices = loadedIndices.size();
|
||||
if (!graphics->supportMeshShading())
|
||||
@@ -347,10 +343,23 @@ void VertexData::init(Gfx::PGraphics _graphics)
|
||||
instanceDataLayout->addDescriptorBinding(Gfx::DescriptorBinding{ .binding = 5, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER });
|
||||
// cullingOffset
|
||||
instanceDataLayout->addDescriptorBinding(Gfx::DescriptorBinding{ .binding = 6, .descriptorType = Gfx::SE_DESCRIPTOR_TYPE_STORAGE_BUFFER });
|
||||
cullingOffsetBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{ .dynamic = true });
|
||||
cullingBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{ .dynamic = true });
|
||||
instanceBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{ .dynamic = true });
|
||||
instanceMeshDataBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{ .dynamic = true });
|
||||
|
||||
cullingOffsetBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{
|
||||
.dynamic = true,
|
||||
.name = "MeshletOffset",
|
||||
});
|
||||
cullingBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{
|
||||
.dynamic = true,
|
||||
.name = "MeshletCulling",
|
||||
});
|
||||
instanceBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{
|
||||
.dynamic = true,
|
||||
.name = "InstanceBuffer",
|
||||
});
|
||||
instanceMeshDataBuffer = graphics->createShaderBuffer(ShaderBufferCreateInfo{
|
||||
.dynamic = true,
|
||||
.name = "MeshDataBuffer",
|
||||
});
|
||||
instanceDataLayout->create();
|
||||
resizeBuffers();
|
||||
graphics->getShaderCompiler()->registerVertexData(this);
|
||||
|
||||
@@ -282,8 +282,11 @@ void RenderCommand::bindDescriptor(Gfx::PDescriptorSet descriptorSet, Array<uint
|
||||
assert(descriptor->writeDescriptors.size() == 0);
|
||||
descriptor->bind();
|
||||
boundResources.add(descriptor.getHandle());
|
||||
boundResources.addAll(descriptor->boundResources);
|
||||
descriptor->boundResources.clear();
|
||||
for (auto binding : descriptor->boundResources)
|
||||
{
|
||||
binding->bind();
|
||||
boundResources.add(binding);
|
||||
}
|
||||
|
||||
VkDescriptorSet setHandle = descriptor->getHandle();
|
||||
vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline->getLayout(), pipeline->getPipelineLayout()->findParameter(descriptorSet->getName()), 1, &setHandle, dynamicOffsets.size(), dynamicOffsets.data());
|
||||
@@ -298,10 +301,13 @@ void RenderCommand::bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptorS
|
||||
auto descriptorSet = descriptorSets[i].cast<DescriptorSet>();
|
||||
assert(descriptorSet->writeDescriptors.size() == 0);
|
||||
descriptorSet->bind();
|
||||
|
||||
boundResources.add(descriptorSet.getHandle());
|
||||
boundResources.addAll(descriptorSet->boundResources);
|
||||
descriptorSet->boundResources.clear();
|
||||
|
||||
for (auto binding : descriptorSet->boundResources)
|
||||
{
|
||||
binding->bind();
|
||||
boundResources.add(binding);
|
||||
}
|
||||
sets[pipeline->getPipelineLayout()->findParameter(descriptorSet->getName())] = descriptorSet->getHandle();
|
||||
}
|
||||
vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline->getLayout(), 0, (uint32)descriptorSets.size(), sets, dynamicOffsets.size(), dynamicOffsets.data());
|
||||
@@ -434,9 +440,12 @@ void ComputeCommand::bindDescriptor(Gfx::PDescriptorSet descriptorSet, Array<uin
|
||||
auto descriptor = descriptorSet.cast<DescriptorSet>();
|
||||
assert(descriptor->writeDescriptors.size() == 0);
|
||||
boundResources.add(descriptor.getHandle());
|
||||
boundResources.addAll(descriptor->boundResources);
|
||||
descriptor->boundResources.clear();
|
||||
descriptor->bind();
|
||||
|
||||
for (auto binding : descriptor->boundResources)
|
||||
{
|
||||
binding->bind();
|
||||
boundResources.add(binding);
|
||||
}
|
||||
|
||||
VkDescriptorSet setHandle = descriptor->getHandle();
|
||||
vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline->getLayout(), pipeline->getPipelineLayout()->findParameter(descriptorSet->getName()), 1, &setHandle, dynamicOffsets.size(), dynamicOffsets.data());
|
||||
@@ -451,11 +460,14 @@ void ComputeCommand::bindDescriptor(const Array<Gfx::PDescriptorSet>& descriptor
|
||||
auto descriptorSet = descriptorSets[i].cast<DescriptorSet>();
|
||||
assert(descriptorSet->writeDescriptors.size() == 0);
|
||||
descriptorSet->bind();
|
||||
boundResources.add(descriptorSet.getHandle());
|
||||
|
||||
//std::cout << "Binding descriptor " << descriptorSet->getHandle() << " to cmd " << handle << std::endl;
|
||||
boundResources.add(descriptorSet.getHandle());
|
||||
boundResources.addAll(descriptorSet->boundResources);
|
||||
descriptorSet->boundResources.clear();
|
||||
for (auto binding : descriptorSet->boundResources)
|
||||
{
|
||||
binding->bind();
|
||||
boundResources.add(binding);
|
||||
}
|
||||
sets[pipeline->getPipelineLayout()->findParameter(descriptorSet->getName())] = descriptorSet->getHandle();
|
||||
}
|
||||
vkCmdBindDescriptorSets(handle, VK_PIPELINE_BIND_POINT_COMPUTE, pipeline->getLayout(), 0, (uint32)descriptorSets.size(), sets, dynamicOffsets.size(), dynamicOffsets.data());
|
||||
|
||||
@@ -142,9 +142,6 @@ Gfx::PDescriptorSet DescriptorPool::allocateDescriptorSet() {
|
||||
cachedHandles[setIndex]->allocate();
|
||||
|
||||
PDescriptorSet vulkanSet = cachedHandles[setIndex];
|
||||
vulkanSet->cachedData.resize(layout->bindings.size());
|
||||
// Not really pretty, but this way the set knows which ones are valid
|
||||
std::memset(vulkanSet->cachedData.data(), 0, sizeof(void*) * vulkanSet->cachedData.size());
|
||||
|
||||
// Found set, stop searching
|
||||
return vulkanSet;
|
||||
@@ -177,7 +174,9 @@ DescriptorSet::DescriptorSet(PGraphics graphics, PDescriptorPool owner)
|
||||
, owner(owner)
|
||||
, bindCount(0)
|
||||
, currentlyInUse(false)
|
||||
{}
|
||||
{
|
||||
boundResources.resize(owner->getLayout()->getBindings().size());
|
||||
}
|
||||
|
||||
DescriptorSet::~DescriptorSet()
|
||||
{
|
||||
@@ -186,11 +185,6 @@ DescriptorSet::~DescriptorSet()
|
||||
|
||||
void DescriptorSet::updateBuffer(uint32_t binding, Gfx::PUniformBuffer uniformBuffer) {
|
||||
PUniformBuffer vulkanBuffer = uniformBuffer.cast<UniformBuffer>();
|
||||
UniformBuffer* cachedBuffer = reinterpret_cast<UniformBuffer*>(cachedData[binding]);
|
||||
if (vulkanBuffer->isDataEquals(cachedBuffer)) {
|
||||
// std::cout << "uniform data equal, skip" << std::endl;
|
||||
return;
|
||||
}
|
||||
bufferInfos.add(VkDescriptorBufferInfo{
|
||||
.buffer = vulkanBuffer->getHandle(),
|
||||
.offset = 0,
|
||||
@@ -208,17 +202,11 @@ void DescriptorSet::updateBuffer(uint32_t binding, Gfx::PUniformBuffer uniformBu
|
||||
.pBufferInfo = &bufferInfos.back(),
|
||||
});
|
||||
|
||||
cachedData[binding] = vulkanBuffer.getHandle();
|
||||
vulkanBuffer->getAlloc()->bind();
|
||||
boundResources.add(vulkanBuffer->getAlloc());
|
||||
boundResources[binding] = vulkanBuffer->getAlloc();
|
||||
}
|
||||
|
||||
void DescriptorSet::updateBuffer(uint32_t binding, Gfx::PShaderBuffer shaderBuffer) {
|
||||
PShaderBuffer vulkanBuffer = shaderBuffer.cast<ShaderBuffer>();
|
||||
ShaderBuffer* cachedBuffer = reinterpret_cast<ShaderBuffer*>(cachedData[binding]);
|
||||
if (vulkanBuffer.getHandle() == cachedBuffer) {
|
||||
return;
|
||||
}
|
||||
|
||||
bufferInfos.add(VkDescriptorBufferInfo{
|
||||
.buffer = vulkanBuffer->getHandle(),
|
||||
@@ -236,18 +224,11 @@ void DescriptorSet::updateBuffer(uint32_t binding, Gfx::PShaderBuffer shaderBuff
|
||||
.pBufferInfo = &bufferInfos.back(),
|
||||
});
|
||||
|
||||
cachedData[binding] = vulkanBuffer.getHandle();
|
||||
vulkanBuffer->getAlloc()->bind();
|
||||
boundResources.add(vulkanBuffer->getAlloc());
|
||||
boundResources[binding] = vulkanBuffer->getAlloc();
|
||||
}
|
||||
|
||||
void DescriptorSet::updateBuffer(uint32_t binding, uint32 index, Gfx::PShaderBuffer shaderBuffer) {
|
||||
PShaderBuffer vulkanBuffer = shaderBuffer.cast<ShaderBuffer>();
|
||||
ShaderBuffer* cachedBuffer = reinterpret_cast<ShaderBuffer*>(cachedData[binding]);
|
||||
if (vulkanBuffer.getHandle() == cachedBuffer) {
|
||||
return;
|
||||
}
|
||||
|
||||
bufferInfos.add(VkDescriptorBufferInfo{
|
||||
.buffer = vulkanBuffer->getHandle(),
|
||||
.offset = 0,
|
||||
@@ -265,19 +246,14 @@ void DescriptorSet::updateBuffer(uint32_t binding, uint32 index, Gfx::PShaderBuf
|
||||
.pBufferInfo = &bufferInfos.back(),
|
||||
});
|
||||
|
||||
cachedData[binding] = vulkanBuffer.getHandle();
|
||||
vulkanBuffer->getAlloc()->bind();
|
||||
boundResources.add(vulkanBuffer->getAlloc());
|
||||
boundResources[binding] = vulkanBuffer->getAlloc();
|
||||
}
|
||||
|
||||
void DescriptorSet::updateSampler(uint32_t binding, Gfx::PSampler samplerState) {
|
||||
PSampler vulkanSampler = samplerState.cast<Sampler>();
|
||||
Sampler* cachedSampler = reinterpret_cast<Sampler*>(cachedData[binding]);
|
||||
if (vulkanSampler.getHandle() == cachedSampler) {
|
||||
return;
|
||||
}
|
||||
|
||||
imageInfos.add(VkDescriptorImageInfo{
|
||||
.sampler = vulkanSampler->sampler,
|
||||
.sampler = vulkanSampler->getSampler(),
|
||||
.imageView = VK_NULL_HANDLE,
|
||||
.imageLayout = VK_IMAGE_LAYOUT_UNDEFINED,
|
||||
});
|
||||
@@ -293,18 +269,15 @@ void DescriptorSet::updateSampler(uint32_t binding, Gfx::PSampler samplerState)
|
||||
.pImageInfo = &imageInfos.back(),
|
||||
});
|
||||
|
||||
cachedData[binding] = vulkanSampler.getHandle();
|
||||
boundResources[binding] = vulkanSampler->getHandle();
|
||||
}
|
||||
|
||||
void DescriptorSet::updateTexture(uint32_t binding, Gfx::PTexture texture, Gfx::PSampler samplerState) {
|
||||
TextureBase* vulkanTexture = texture.cast<TextureBase>().getHandle();
|
||||
TextureBase* cachedTexture = reinterpret_cast<TextureBase*>(cachedData[binding]);
|
||||
if (vulkanTexture == cachedTexture) {
|
||||
return;
|
||||
}
|
||||
|
||||
// It is assumed that the image is in the correct layout
|
||||
imageInfos.add(VkDescriptorImageInfo{
|
||||
.sampler = samplerState != nullptr ? samplerState.cast<Sampler>()->sampler : VK_NULL_HANDLE,
|
||||
.sampler = samplerState != nullptr ? samplerState.cast<Sampler>()->getSampler() : VK_NULL_HANDLE,
|
||||
.imageView = vulkanTexture->getView(),
|
||||
.imageLayout = cast(vulkanTexture->getLayout()),
|
||||
});
|
||||
@@ -325,13 +298,12 @@ void DescriptorSet::updateTexture(uint32_t binding, Gfx::PTexture texture, Gfx::
|
||||
.pImageInfo = &imageInfos.back(),
|
||||
});
|
||||
|
||||
cachedData[binding] = vulkanTexture;
|
||||
vulkanTexture->getHandle()->bind();
|
||||
boundResources.add(vulkanTexture->getHandle());
|
||||
boundResources[binding] = vulkanTexture->getHandle();
|
||||
}
|
||||
void DescriptorSet::updateTextureArray(uint32_t binding, Array<Gfx::PTexture> textures) {
|
||||
// maybe make this a parameter?
|
||||
uint32 arrayElement = 0;
|
||||
boundResources.resize(binding + textures.size());
|
||||
for (auto& gfxTexture : textures) {
|
||||
TextureBase* vulkanTexture = gfxTexture.cast<TextureBase>().getHandle();
|
||||
imageInfos.add(VkDescriptorImageInfo{
|
||||
@@ -344,6 +316,7 @@ void DescriptorSet::updateTextureArray(uint32_t binding, Array<Gfx::PTexture> te
|
||||
if (vulkanTexture->getUsage() & VK_IMAGE_USAGE_STORAGE_BIT) {
|
||||
descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
|
||||
}
|
||||
boundResources[binding + arrayElement] = vulkanTexture->getHandle();
|
||||
writeDescriptors.add(VkWriteDescriptorSet{
|
||||
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
|
||||
.pNext = nullptr,
|
||||
@@ -355,7 +328,6 @@ void DescriptorSet::updateTextureArray(uint32_t binding, Array<Gfx::PTexture> te
|
||||
.pImageInfo = &imageInfos.back(),
|
||||
});
|
||||
vulkanTexture->getHandle()->bind();
|
||||
boundResources.add(vulkanTexture->getHandle());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ private:
|
||||
// contains the previously bound resources at every binding
|
||||
// since the layout is fixed, trying to bind a texture to a buffer
|
||||
// would not work anyways, so casts should be safe
|
||||
Array<void*> cachedData;
|
||||
//Array<void*> cachedData;
|
||||
Array<PCommandBoundResource> boundResources;
|
||||
VkDescriptorSet setHandle;
|
||||
PGraphics graphics;
|
||||
|
||||
@@ -217,7 +217,6 @@ Gfx::PComputePipeline Graphics::createComputePipeline(Gfx::ComputePipelineCreate
|
||||
|
||||
Gfx::OSampler Graphics::createSampler(const SamplerCreateInfo& createInfo)
|
||||
{
|
||||
OSampler sampler = new Sampler();
|
||||
VkSamplerCreateInfo vkInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO,
|
||||
.pNext = nullptr,
|
||||
@@ -238,8 +237,7 @@ Gfx::OSampler Graphics::createSampler(const SamplerCreateInfo& createInfo)
|
||||
.borderColor = cast(createInfo.borderColor),
|
||||
.unnormalizedCoordinates = createInfo.unnormalizedCoordinates,
|
||||
};
|
||||
VK_CHECK(vkCreateSampler(handle, &vkInfo, nullptr, &sampler->sampler));
|
||||
return sampler;
|
||||
return new Sampler(this, vkInfo);
|
||||
}
|
||||
|
||||
Gfx::ODescriptorLayout Graphics::createDescriptorLayout(const std::string& name)
|
||||
|
||||
@@ -117,3 +117,24 @@ void DestructionManager::notifyCommandComplete()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SamplerHandle::SamplerHandle(PGraphics graphics, VkSamplerCreateInfo createInfo)
|
||||
: CommandBoundResource(graphics)
|
||||
{
|
||||
vkCreateSampler(graphics->getDevice(), &createInfo, nullptr, &sampler);
|
||||
}
|
||||
|
||||
SamplerHandle::~SamplerHandle()
|
||||
{
|
||||
vkDestroySampler(graphics->getDevice(), sampler, nullptr);
|
||||
}
|
||||
|
||||
Sampler::Sampler(PGraphics graphics, VkSamplerCreateInfo createInfo)
|
||||
: graphics(graphics)
|
||||
, handle(new SamplerHandle(graphics, createInfo))
|
||||
{}
|
||||
|
||||
Sampler::~Sampler()
|
||||
{
|
||||
graphics->getDestructionManager()->queueResourceForDestruction(std::move(handle));
|
||||
}
|
||||
|
||||
@@ -85,10 +85,25 @@ protected:
|
||||
};
|
||||
DEFINE_REF(CommandBoundResource)
|
||||
|
||||
class SamplerHandle : public CommandBoundResource
|
||||
{
|
||||
public:
|
||||
SamplerHandle(PGraphics graphics, VkSamplerCreateInfo createInfo);
|
||||
virtual ~SamplerHandle();
|
||||
VkSampler sampler;
|
||||
};
|
||||
DEFINE_REF(SamplerHandle)
|
||||
|
||||
class Sampler : public Gfx::Sampler
|
||||
{
|
||||
public:
|
||||
VkSampler sampler;
|
||||
Sampler(PGraphics graphics, VkSamplerCreateInfo createInfo);
|
||||
virtual ~Sampler();
|
||||
PSamplerHandle getHandle() const { return handle; }
|
||||
VkSampler getSampler() const { return handle->sampler; }
|
||||
private:
|
||||
PGraphics graphics;
|
||||
OSamplerHandle handle;
|
||||
};
|
||||
DEFINE_REF(Sampler)
|
||||
|
||||
|
||||
@@ -23,12 +23,13 @@ Slang::ComPtr<slang::IBlob> Seele::generateShader(const ShaderCreateInfo& create
|
||||
option[1].name = slang::CompilerOptionName::EmitSpirvViaGLSL;
|
||||
option[1].value.kind = slang::CompilerOptionValueKind::Int;
|
||||
option[1].value.intValue0 = 1;
|
||||
option[2].name = slang::CompilerOptionName::EmitIr;
|
||||
option[2].name = slang::CompilerOptionName::DebugInformation;
|
||||
option[2].value.kind = slang::CompilerOptionValueKind::Int;
|
||||
option[2].value.intValue0 = 1;
|
||||
option[2].value.intValue0 = SLANG_DEBUG_INFO_LEVEL_NONE;
|
||||
option[3].name = slang::CompilerOptionName::DebugInformationFormat;
|
||||
option[3].value.kind = slang::CompilerOptionValueKind::Int;
|
||||
option[3].value.intValue0 = SLANG_DEBUG_INFO_FORMAT_C7;
|
||||
option[3].value.intValue0 = SLANG_DEBUG_INFO_FORMAT_PDB;
|
||||
|
||||
sessionDesc.compilerOptionEntries = option.data();
|
||||
sessionDesc.compilerOptionEntryCount = option.size();
|
||||
sessionDesc.defaultMatrixLayoutMode = SLANG_MATRIX_LAYOUT_COLUMN_MAJOR;
|
||||
@@ -43,7 +44,7 @@ Slang::ComPtr<slang::IBlob> Seele::generateShader(const ShaderCreateInfo& create
|
||||
sessionDesc.preprocessorMacroCount = macros.size();
|
||||
sessionDesc.preprocessorMacros = macros.data();
|
||||
slang::TargetDesc targetDesc;
|
||||
targetDesc.profile = globalSession->findProfile("sm_6_6");
|
||||
targetDesc.profile = globalSession->findProfile("spirv_1_5");
|
||||
targetDesc.format = target;
|
||||
sessionDesc.targetCount = 1;
|
||||
sessionDesc.targets = &targetDesc;
|
||||
|
||||
@@ -26,14 +26,14 @@ public:
|
||||
template<typename... Deps>
|
||||
void setupView(Dependencies<Deps...>)
|
||||
{
|
||||
List<std::function<void()>> work;
|
||||
//List<std::function<void()>> work;
|
||||
registry.view<Components..., Deps...>().each([&](Components&... comp, Deps&... deps){
|
||||
work.add([&]() {
|
||||
//work.add([&]() {
|
||||
(accessComponent(deps), ...);
|
||||
update(comp...);
|
||||
});
|
||||
//});
|
||||
});
|
||||
getThreadPool().runAndWait(std::move(work));
|
||||
//getThreadPool().runAndWait(std::move(work));
|
||||
}
|
||||
virtual void run(double delta) override
|
||||
{
|
||||
|
||||
+12
-12
@@ -23,18 +23,18 @@ ThreadPool::~ThreadPool()
|
||||
}
|
||||
}
|
||||
|
||||
void ThreadPool::runAndWait(List<std::function<void()>> functions)
|
||||
{
|
||||
std::unique_lock l(taskLock);
|
||||
currentTask.numRemaining = functions.size();
|
||||
currentTask.functions = std::move(functions);
|
||||
taskCV.notify_all();
|
||||
|
||||
while (currentTask.numRemaining > 0)
|
||||
{
|
||||
completedCV.wait(l);
|
||||
}
|
||||
}
|
||||
//void ThreadPool::runAndWait(List<std::function<void()>> functions)
|
||||
//{
|
||||
// std::unique_lock l(taskLock);
|
||||
// currentTask.numRemaining = functions.size();
|
||||
// currentTask.functions = std::move(functions);
|
||||
// taskCV.notify_all();
|
||||
//
|
||||
// while (currentTask.numRemaining > 0)
|
||||
// {
|
||||
// completedCV.wait(l);
|
||||
// }
|
||||
//}
|
||||
|
||||
void ThreadPool::work()
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@ class ThreadPool
|
||||
public:
|
||||
ThreadPool(uint32 numWorkers = std::thread::hardware_concurrency());
|
||||
~ThreadPool();
|
||||
void runAndWait(List<std::function<void()>> functions);
|
||||
//void runAndWait(List<std::function<void()>> functions);
|
||||
private:
|
||||
struct Task
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user