somewhat fixed threadpool

This commit is contained in:
2021-11-13 19:28:18 +01:00
parent 01049019fd
commit ad09492e3e
20 changed files with 71 additions and 90 deletions
+1
View File
@@ -66,6 +66,7 @@ else()
${ASSIMP_ROOT}/code ${ASSIMP_ROOT}/code
DOC "Assimp library file") DOC "Assimp library file")
endif() endif()
# Handle REQUIRD argument, define *_FOUND variable # Handle REQUIRD argument, define *_FOUND variable
+1 -3
View File
@@ -7,9 +7,6 @@ list(APPEND DEPENDENCIES assimp)
set(ASSIMP_BUILD_TESTS OFF CACHE INTERNAL "") set(ASSIMP_BUILD_TESTS OFF CACHE INTERNAL "")
set(ASSIMP_BUILD_SAMPLES OFF CACHE INTERNAL "") set(ASSIMP_BUILD_SAMPLES OFF CACHE INTERNAL "")
set(ASSIMP_BUILD_OVERALLS OFF CACHE INTERNAL "") set(ASSIMP_BUILD_OVERALLS OFF CACHE INTERNAL "")
set(ASSIMP_BUILD_ASSIMP_TOOLS OFF CACHE INTERNAL "")
set(ASSIMP_INSTALL OFF CACHE INTERNAL "")
set(ASSIMP_BUILD_ZLIB OFF CACHE INTERNAL "")
set(BUILD_SHARED_LIBS ON CACHE INTERNAL "") set(BUILD_SHARED_LIBS ON CACHE INTERNAL "")
add_subdirectory(${ASSIMP_ROOT} ${ASSIMP_ROOT}) add_subdirectory(${ASSIMP_ROOT} ${ASSIMP_ROOT})
@@ -18,6 +15,7 @@ if(WIN32)
target_compile_options(assimp PRIVATE /WX-) target_compile_options(assimp PRIVATE /WX-)
else() else()
target_compile_options(assimp PRIVATE -Wno-error -fPIC) target_compile_options(assimp PRIVATE -Wno-error -fPIC)
target_compile_options(IrrXML PRIVATE -fPIC)
endif() endif()
#-------------BOOST---------------- #-------------BOOST----------------
list(APPEND DEPENDENCIES boost) list(APPEND DEPENDENCIES boost)
+1 -1
View File
@@ -72,6 +72,6 @@ float4 fragmentMain(
PointLight pointLight = pointLights[lightIndex]; PointLight pointLight = pointLights[lightIndex];
result += pointLight.illuminate(materialParams, brdf, viewDir); result += pointLight.illuminate(materialParams, brdf, viewDir);
} }
return float4(result, 1); return float4(result, 0.1f);
} }
+6 -2
View File
@@ -165,6 +165,7 @@ public:
{ {
add(it); add(it);
} }
markIteratorDirty();
} }
return *this; return *this;
} }
@@ -182,6 +183,7 @@ public:
endIt = other.endIt; endIt = other.endIt;
_size = other._size; _size = other._size;
other._size = 0; other._size = 0;
markIteratorDirty();
} }
return *this; return *this;
} }
@@ -206,6 +208,7 @@ public:
deallocateNode(tmp->prev); deallocateNode(tmp->prev);
} }
deallocateNode(tail); deallocateNode(tail);
markIteratorDirty();
tail = nullptr; tail = nullptr;
root = nullptr; root = nullptr;
} }
@@ -347,6 +350,7 @@ public:
newNode->prev = tmp; newNode->prev = tmp;
newNode->next = pos.node; newNode->next = pos.node;
pos.node->prev = newNode; pos.node->prev = newNode;
markIteratorDirty();
return Iterator(newNode); return Iterator(newNode);
} }
iterator find(const T &value) iterator find(const T &value)
@@ -360,11 +364,11 @@ public:
} }
return endIt; return endIt;
} }
bool empty() bool empty() const
{ {
return _size == 0; return _size == 0;
} }
size_type size() size_type size() const
{ {
return _size; return _size;
} }
+11 -16
View File
@@ -12,7 +12,7 @@ BasePassMeshProcessor::BasePassMeshProcessor(Gfx::PViewport viewport, Gfx::PGrap
: MeshProcessor(graphics) : MeshProcessor(graphics)
, target(viewport) , target(viewport)
, translucentBasePass(translucentBasePass) , translucentBasePass(translucentBasePass)
, cachedPrimitiveIndex(0) //, cachedPrimitiveIndex(0)
{ {
} }
@@ -29,28 +29,26 @@ void BasePassMeshProcessor::addMeshBatch(
Array<Gfx::PDescriptorSet>& descriptorSets, Array<Gfx::PDescriptorSet>& descriptorSets,
int32 /*staticMeshId*/) int32 /*staticMeshId*/)
{ {
const PMaterialAsset material = batch.material; PMaterialAsset material = batch.material;
//const Gfx::MaterialShadingModel shadingModel = material->getShadingModel(); //const Gfx::MaterialShadingModel shadingModel = material->getShadingModel();
const PVertexShaderInput vertexInput = batch.vertexInput; const PVertexShaderInput vertexInput = batch.vertexInput;
const Gfx::ShaderCollection* collection = material->getShaders(Gfx::RenderPassType::BasePass, vertexInput->getType()); const Gfx::ShaderCollection* collection = material->getShaders(Gfx::RenderPassType::BasePass, vertexInput->getType());
assert(collection != nullptr); assert(collection != nullptr);
Gfx::PRenderCommand renderCommand = graphics->createRenderCommand();
renderCommand->setViewport(target);
pipelineLayout->addDescriptorLayout(BasePass::INDEX_MATERIAL, material->getDescriptorLayout());
pipelineLayout->create();
Gfx::PDescriptorSet materialSet = material->createDescriptorSet();
descriptorSets[BasePass::INDEX_MATERIAL] = materialSet;
for(uint32 i = 0; i < batch.elements.size(); ++i) for(uint32 i = 0; i < batch.elements.size(); ++i)
{ {
Gfx::PDescriptorSet descriptorSet = primitiveLayout->allocateDescriptorSet(); Gfx::PDescriptorSet descriptorSet = primitiveLayout->allocateDescriptorSet();
descriptorSet->updateBuffer(0, batch.elements[i].uniformBuffer); descriptorSet->updateBuffer(0, batch.elements[i].uniformBuffer);
descriptorSet->writeChanges(); descriptorSet->writeChanges();
cachedPrimitiveSets.add(descriptorSet); descriptorSets[BasePass::INDEX_SCENE_DATA] = descriptorSet;
}
Gfx::PRenderCommand renderCommand = graphics->createRenderCommand();
renderCommand->setViewport(target);
for(uint32 i = 0; i < batch.elements.size(); ++i)
{
pipelineLayout->addDescriptorLayout(BasePass::INDEX_MATERIAL, material->getDescriptorLayout());
pipelineLayout->create();
descriptorSets[BasePass::INDEX_MATERIAL] = material->getDescriptor();
descriptorSets[BasePass::INDEX_SCENE_DATA] = cachedPrimitiveSets[cachedPrimitiveIndex++];
buildMeshDrawCommand(batch, buildMeshDrawCommand(batch,
// primitiveComponent, // primitiveComponent,
renderPass, renderPass,
@@ -75,8 +73,6 @@ Array<Gfx::PRenderCommand> BasePassMeshProcessor::getRenderCommands()
void BasePassMeshProcessor::clearCommands() void BasePassMeshProcessor::clearCommands()
{ {
renderCommands.clear(); renderCommands.clear();
cachedPrimitiveSets.clear();
cachedPrimitiveIndex = 0;
} }
BasePass::BasePass(Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor source) BasePass::BasePass(Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor source)
@@ -148,8 +144,7 @@ void BasePass::beginFrame()
void BasePass::render() void BasePass::render()
{ {
oLightIndexList->pipelineBarrier(
oLightIndexList->pipelineBarrier(
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);
oLightGrid->pipelineBarrier( oLightGrid->pipelineBarrier(
+2 -2
View File
@@ -23,10 +23,10 @@ public:
void clearCommands(); void clearCommands();
private: private:
Array<Gfx::PRenderCommand> renderCommands; Array<Gfx::PRenderCommand> renderCommands;
Array<Gfx::PDescriptorSet> cachedPrimitiveSets; //Array<Gfx::PDescriptorSet> cachedPrimitiveSets;
Gfx::PViewport target; Gfx::PViewport target;
uint8 translucentBasePass; uint8 translucentBasePass;
uint32 cachedPrimitiveIndex; //uint32 cachedPrimitiveIndex;
}; };
DEFINE_REF(BasePassMeshProcessor) DEFINE_REF(BasePassMeshProcessor)
DECLARE_REF(CameraActor) DECLARE_REF(CameraActor)
+13 -15
View File
@@ -11,7 +11,6 @@ using namespace Seele;
DepthPrepassMeshProcessor::DepthPrepassMeshProcessor(Gfx::PViewport viewport, Gfx::PGraphics graphics) DepthPrepassMeshProcessor::DepthPrepassMeshProcessor(Gfx::PViewport viewport, Gfx::PGraphics graphics)
: MeshProcessor(graphics) : MeshProcessor(graphics)
, target(viewport) , target(viewport)
, cachedPrimitiveIndex(0)
{ {
} }
@@ -28,28 +27,26 @@ void DepthPrepassMeshProcessor::addMeshBatch(
Array<Gfx::PDescriptorSet>& descriptorSets, Array<Gfx::PDescriptorSet>& descriptorSets,
int32 /*staticMeshId*/) int32 /*staticMeshId*/)
{ {
const PMaterialAsset material = batch.material; PMaterialAsset material = batch.material;
//const Gfx::MaterialShadingModel shadingModel = material->getShadingModel(); //const Gfx::MaterialShadingModel shadingModel = material->getShadingModel();
const PVertexShaderInput vertexInput = batch.vertexInput; const PVertexShaderInput vertexInput = batch.vertexInput;
const Gfx::ShaderCollection* collection = material->getShaders(Gfx::RenderPassType::DepthPrepass, vertexInput->getType()); const Gfx::ShaderCollection* collection = material->getShaders(Gfx::RenderPassType::DepthPrepass, vertexInput->getType());
assert(collection != nullptr); assert(collection != nullptr);
Gfx::PRenderCommand renderCommand = graphics->createRenderCommand();
renderCommand->setViewport(target);
pipelineLayout->addDescriptorLayout(DepthPrepass::INDEX_MATERIAL, material->getDescriptorLayout());
pipelineLayout->create();
Gfx::PDescriptorSet materialSet = material->createDescriptorSet();
descriptorSets[DepthPrepass::INDEX_MATERIAL] = materialSet;
for(uint32 i = 0; i < batch.elements.size(); ++i) for(uint32 i = 0; i < batch.elements.size(); ++i)
{ {
Gfx::PDescriptorSet descriptorSet = primitiveLayout->allocateDescriptorSet(); Gfx::PDescriptorSet descriptorSet = primitiveLayout->allocateDescriptorSet();
descriptorSet->updateBuffer(0, batch.elements[i].uniformBuffer); descriptorSet->updateBuffer(0, batch.elements[i].uniformBuffer);
descriptorSet->writeChanges(); descriptorSet->writeChanges();
cachedPrimitiveSets.add(descriptorSet); descriptorSets[DepthPrepass::INDEX_SCENE_DATA] = descriptorSet;
}
Gfx::PRenderCommand renderCommand = graphics->createRenderCommand();
renderCommand->setViewport(target);
for(uint32 i = 0; i < batch.elements.size(); ++i)
{
pipelineLayout->addDescriptorLayout(DepthPrepass::INDEX_MATERIAL, material->getDescriptorLayout());
pipelineLayout->create();
descriptorSets[DepthPrepass::INDEX_MATERIAL] = material->getDescriptor();
descriptorSets[DepthPrepass::INDEX_SCENE_DATA] = cachedPrimitiveSets[cachedPrimitiveIndex++];
buildMeshDrawCommand(batch, buildMeshDrawCommand(batch,
// primitiveComponent, // primitiveComponent,
renderPass, renderPass,
@@ -74,8 +71,8 @@ Array<Gfx::PRenderCommand> DepthPrepassMeshProcessor::getRenderCommands()
void DepthPrepassMeshProcessor::clearCommands() void DepthPrepassMeshProcessor::clearCommands()
{ {
renderCommands.clear(); renderCommands.clear();
cachedPrimitiveSets.clear(); //cachedPrimitiveSets.clear();
cachedPrimitiveIndex = 0; //cachedPrimitiveIndex = 0;
} }
DepthPrepass::DepthPrepass(Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor source) DepthPrepass::DepthPrepass(Gfx::PGraphics graphics, Gfx::PViewport viewport, PCameraActor source)
@@ -129,6 +126,7 @@ void DepthPrepass::beginFrame()
void DepthPrepass::render() void DepthPrepass::render()
{ {
depthAttachment->getTexture()->pipelineBarrier( depthAttachment->getTexture()->pipelineBarrier(
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT, Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT,
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT); Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT);
@@ -23,9 +23,9 @@ public:
void clearCommands(); void clearCommands();
private: private:
Array<Gfx::PRenderCommand> renderCommands; Array<Gfx::PRenderCommand> renderCommands;
Array<Gfx::PDescriptorSet> cachedPrimitiveSets; //Array<Gfx::PDescriptorSet> cachedPrimitiveSets;
Gfx::PViewport target; Gfx::PViewport target;
uint32 cachedPrimitiveIndex; //uint32 cachedPrimitiveIndex;
}; };
DEFINE_REF(DepthPrepassMeshProcessor) DEFINE_REF(DepthPrepassMeshProcessor)
DECLARE_REF(CameraActor) DECLARE_REF(CameraActor)
@@ -87,6 +87,7 @@ void CmdBuffer::executeCommands(const Array<Gfx::PRenderCommand>& commands)
executingRenders.add(command); executingRenders.add(command);
for(auto descriptor : command->boundDescriptors) for(auto descriptor : command->boundDescriptors)
{ {
descriptor->free();
boundDescriptors.add(descriptor); boundDescriptors.add(descriptor);
} }
cmdBuffers[i] = command->getHandle(); cmdBuffers[i] = command->getHandle();
@@ -104,6 +105,7 @@ void CmdBuffer::executeCommands(const Array<Gfx::PComputeCommand>& commands)
executingComputes.add(command); executingComputes.add(command);
for(auto descriptor : command->boundDescriptors) for(auto descriptor : command->boundDescriptors)
{ {
descriptor->free();
boundDescriptors.add(descriptor); boundDescriptors.add(descriptor);
} }
cmdBuffers[i] = command->getHandle(); cmdBuffers[i] = command->getHandle();
@@ -117,12 +117,12 @@ DescriptorSet::~DescriptorSet()
void DescriptorSet::updateBuffer(uint32_t binding, Gfx::PUniformBuffer uniformBuffer) void DescriptorSet::updateBuffer(uint32_t binding, Gfx::PUniformBuffer uniformBuffer)
{ {
PUniformBuffer vulkanBuffer = uniformBuffer.cast<UniformBuffer>(); PUniformBuffer vulkanBuffer = uniformBuffer.cast<UniformBuffer>();
//UniformBuffer* cachedBuffer = reinterpret_cast<UniformBuffer*>(cachedData[binding]); UniformBuffer* cachedBuffer = reinterpret_cast<UniformBuffer*>(cachedData[binding]);
/*if(vulkanBuffer->isDataEquals(cachedBuffer)) if(vulkanBuffer->isDataEquals(cachedBuffer))
{ {
std::cout << "uniform data equal, skip" << std::endl; std::cout << "uniform data equal, skip" << std::endl;
return; return;
}*/ }
bufferInfos.add(init::DescriptorBufferInfo(vulkanBuffer->getHandle(), 0, vulkanBuffer->getSize())); bufferInfos.add(init::DescriptorBufferInfo(vulkanBuffer->getHandle(), 0, vulkanBuffer->getSize()));
VkWriteDescriptorSet writeDescriptor = init::WriteDescriptorSet(setHandle, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, binding, &bufferInfos.back()); VkWriteDescriptorSet writeDescriptor = init::WriteDescriptorSet(setHandle, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, binding, &bufferInfos.back());
+4 -3
View File
@@ -152,10 +152,9 @@ void MaterialAsset::endFrame()
{ {
} }
void MaterialAsset::updateDescriptorData() Gfx::PDescriptorSet MaterialAsset::createDescriptorSet()
{ {
layout->reset(); Gfx::PDescriptorSet descriptorSet = layout->allocateDescriptorSet();
descriptorSet = layout->allocateDescriptorSet();
BulkResourceData uniformUpdate; BulkResourceData uniformUpdate;
uniformUpdate.size = uniformDataSize; uniformUpdate.size = uniformDataSize;
uniformUpdate.data = uniformData; uniformUpdate.data = uniformData;
@@ -169,8 +168,10 @@ void MaterialAsset::updateDescriptorData()
descriptorSet->updateBuffer(uniformBinding, uniformBuffer); descriptorSet->updateBuffer(uniformBinding, uniformBuffer);
} }
descriptorSet->writeChanges(); descriptorSet->writeChanges();
return descriptorSet;
} }
const Gfx::ShaderCollection* MaterialAsset::getShaders(Gfx::RenderPassType renderPass, VertexInputType* vertexInput) const const Gfx::ShaderCollection* MaterialAsset::getShaders(Gfx::RenderPassType renderPass, VertexInputType* vertexInput) const
{ {
Gfx::ShaderPermutation permutation; Gfx::ShaderPermutation permutation;
+1 -5
View File
@@ -20,10 +20,7 @@ public:
Gfx::SeBlendOp getBlendMode() const {return Gfx::SE_BLEND_OP_END_RANGE;} Gfx::SeBlendOp getBlendMode() const {return Gfx::SE_BLEND_OP_END_RANGE;}
Gfx::MaterialShadingModel getShadingModel() const {return Gfx::MaterialShadingModel::DefaultLit;} Gfx::MaterialShadingModel getShadingModel() const {return Gfx::MaterialShadingModel::DefaultLit;}
// This needs to be called while the descriptorset is unused Gfx::PDescriptorSet createDescriptorSet();
void updateDescriptorData();
void resetDescriptorSet();
const Gfx::PDescriptorSet getDescriptor() const { return descriptorSet; };
Gfx::PDescriptorLayout getDescriptorLayout() const { return layout; } Gfx::PDescriptorLayout getDescriptorLayout() const { return layout; }
// The name of the generated material shader, opposed to the name of the .asset file // The name of the generated material shader, opposed to the name of the .asset file
@@ -37,7 +34,6 @@ private:
//For now its simply the collection of parameters, since there is no point for expressions //For now its simply the collection of parameters, since there is no point for expressions
Array<PShaderParameter> parameters; Array<PShaderParameter> parameters;
Gfx::PDescriptorSet descriptorSet;
Gfx::PDescriptorLayout layout; Gfx::PDescriptorLayout layout;
Gfx::PUniformBuffer uniformBuffer; Gfx::PUniformBuffer uniformBuffer;
uint32 uniformDataSize; uint32 uniformDataSize;
-4
View File
@@ -35,10 +35,6 @@ Scene::~Scene()
void Scene::tick(double deltaTime) void Scene::tick(double deltaTime)
{ {
for(auto &&meshBatch : staticMeshes)
{
meshBatch.material->updateDescriptorData();
}
} }
void Scene::addActor(PActor actor) void Scene::addActor(PActor actor)
+6 -10
View File
@@ -53,7 +53,7 @@ void ThreadPool::addJob(Job&& job)
void ThreadPool::addJob(MainJob&& job) void ThreadPool::addJob(MainJob&& job)
{ {
std::unique_lock lock(mainJobLock); std::unique_lock lock(mainJobLock);
//std::cout << "Adding main job " << job << std::endl; //std::cout << "Adding main job " << std::addressof(job.handle) << std::endl;
mainJobs.add(std::move(job)); mainJobs.add(std::move(job));
mainJobCV.notify_one(); mainJobCV.notify_one();
} }
@@ -65,7 +65,7 @@ void ThreadPool::enqueueWaiting(Event* event, Job&& job)
} }
void ThreadPool::enqueueWaiting(Event* event, MainJob&& job) void ThreadPool::enqueueWaiting(Event* event, MainJob&& job)
{ {
//std::cout << job << " main waiting for event " << event->name << std::endl; //std::cout << std::addressof(job.handle) << " main waiting for event " << event->name << std::endl;
std::unique_lock lock(waitingMainLock); std::unique_lock lock(waitingMainLock);
waitingMainJobs[*event].add(std::move(job)); waitingMainJobs[*event].add(std::move(job));
} }
@@ -74,23 +74,19 @@ void ThreadPool::notify(Event* event)
{ {
std::unique_lock lock(jobQueueLock); std::unique_lock lock(jobQueueLock);
std::unique_lock lock2(waitingLock); std::unique_lock lock2(waitingLock);
for(Job& job : waitingJobs[*event]) while(!waitingJobs.empty())
{ {
//std::cout << "Waking up job " << job << std::endl; //std::cout << "Waking up job " << job << std::endl;
jobQueue.add(std::move(job)); jobQueue.add(std::move(waitingJobs[*event].retrieve()));
jobQueueCV.notify_one(); jobQueueCV.notify_one();
} }
waitingJobs[*event].clear();
} }
{ {
std::unique_lock lock(mainJobLock); std::unique_lock lock(mainJobLock);
std::unique_lock lock2(waitingMainLock); std::unique_lock lock2(waitingMainLock);
auto&& jobsToQueue = std::move(waitingMainJobs[*event]); while(!waitingMainJobs[*event].empty())
waitingMainJobs.erase(*event);
for(MainJob& job : jobsToQueue)
{ {
//std::cout << "Waking up main job " << job << std::endl; mainJobs.add(std::move(waitingMainJobs[*event].retrieve()));
mainJobs.add(std::move(job));
mainJobCV.notify_one(); mainJobCV.notify_one();
} }
} }
+10 -16
View File
@@ -35,7 +35,14 @@ public:
explicit JobBase(std::coroutine_handle<promise_type> handle) explicit JobBase(std::coroutine_handle<promise_type> handle)
: handle(handle) : handle(handle)
{ {
std::cout << "Creating job " << handle.address() << std::endl; /*if constexpr(MainJob)
{
std::cout << "Creating mainjob " << handle.address() << std::endl;
}
else
{
std::cout << "Creating job " << handle.address() << std::endl;
}*/
} }
JobBase(const JobBase & rhs) = delete; JobBase(const JobBase & rhs) = delete;
JobBase(JobBase&& rhs) JobBase(JobBase&& rhs)
@@ -47,7 +54,6 @@ public:
{ {
if(handle) if(handle)
{ {
std::cout << "Destroying job " << handle.address() << std::endl;
handle.destroy(); handle.destroy();
} }
} }
@@ -61,24 +67,12 @@ public:
} }
return *this; return *this;
} }
friend std::basic_ostream<char>& operator<<(std::basic_ostream<char>& stream, const JobBase& obj)
{
if (obj.handle == nullptr)
{
stream << nullptr;
}
else
{
stream << obj.handle.address();
}
return stream;
}
void resume() void resume()
{ {
handle.resume(); handle.resume();
} }
private:
std::coroutine_handle<promise_type> handle; std::coroutine_handle<promise_type> handle;
private:
}; };
using MainJob = JobBase<true>; using MainJob = JobBase<true>;
@@ -91,7 +85,7 @@ public:
Event(const std::string& name); Event(const std::string& name);
auto operator<=>(const Event& other) const auto operator<=>(const Event& other) const
{ {
return name <=> other.name; return flag <=> other.flag;
} }
Event operator co_await() Event operator co_await()
{ {
+1 -1
View File
@@ -4,7 +4,7 @@
using namespace Seele; using namespace Seele;
InspectorView::InspectorView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &createInfo) InspectorView::InspectorView(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &createInfo)
: View(graphics, window, createInfo) : View(graphics, window, createInfo, "InspectorView")
, uiPass(UIPass(graphics, viewport, new Gfx::SwapchainAttachment(window->getGfxHandle()))) , uiPass(UIPass(graphics, viewport, new Gfx::SwapchainAttachment(window->getGfxHandle())))
{ {
} }
+1 -1
View File
@@ -8,7 +8,7 @@
using namespace Seele; using namespace Seele;
Seele::SceneView::SceneView(Gfx::PGraphics graphics, PWindow owner, const ViewportCreateInfo &createInfo) Seele::SceneView::SceneView(Gfx::PGraphics graphics, PWindow owner, const ViewportCreateInfo &createInfo)
: View(graphics, owner, createInfo) : View(graphics, owner, createInfo, "SceneView")
, activeCamera(new CameraActor()) , activeCamera(new CameraActor())
, depthPrepass(DepthPrepass(graphics, viewport, activeCamera)) , depthPrepass(DepthPrepass(graphics, viewport, activeCamera))
, lightCullingPass(LightCullingPass(graphics, viewport, activeCamera)) , lightCullingPass(LightCullingPass(graphics, viewport, activeCamera))
+2 -2
View File
@@ -4,8 +4,8 @@
using namespace Seele; using namespace Seele;
View::View(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &viewportInfo) View::View(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &viewportInfo, std::string name)
: graphics(graphics), owner(window) : graphics(graphics), owner(window), name(name)
{ {
viewport = graphics->createViewport(owner->getGfxHandle(), viewportInfo); viewport = graphics->createViewport(owner->getGfxHandle(), viewportInfo);
} }
+2 -1
View File
@@ -8,7 +8,7 @@ DECLARE_REF(Window)
class View class View
{ {
public: public:
View(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &createInfo); View(Gfx::PGraphics graphics, PWindow window, const ViewportCreateInfo &createInfo, std::string name);
virtual ~View(); virtual ~View();
// These are called from the view thread, and handle updating game data // These are called from the view thread, and handle updating game data
@@ -28,6 +28,7 @@ protected:
Gfx::PGraphics graphics; Gfx::PGraphics graphics;
Gfx::PViewport viewport; Gfx::PViewport viewport;
PWindow owner; PWindow owner;
std::string name;
virtual void keyCallback(KeyCode code, InputAction action, KeyModifier modifier) = 0; virtual void keyCallback(KeyCode code, InputAction action, KeyModifier modifier) = 0;
virtual void mouseMoveCallback(double xPos, double yPos) = 0; virtual void mouseMoveCallback(double xPos, double yPos) = 0;
+2 -3
View File
@@ -18,7 +18,7 @@ void Window::addView(PView view)
{ {
WindowView* windowView = new WindowView(); WindowView* windowView = new WindowView();
windowView->view = view; windowView->view = view;
windowView->updateFinished = Event("test"); windowView->updateFinished = Event(view->name);
//windowView->worker = std::thread(&Window::viewWorker, this, windowView); //windowView->worker = std::thread(&Window::viewWorker, this, windowView);
views.add(windowView); views.add(windowView);
viewWorker(views.size() - 1); viewWorker(views.size() - 1);
@@ -30,7 +30,6 @@ MainJob Window::render()
for(auto& windowView : views) for(auto& windowView : views)
{ {
co_await windowView->updateFinished; co_await windowView->updateFinished;
std::cout << "view update finished" << std::endl;
{ {
std::unique_lock lock(windowView->workerMutex); std::unique_lock lock(windowView->workerMutex);
windowView->view->prepareRender(); windowView->view->prepareRender();
@@ -73,7 +72,7 @@ Job Window::viewWorker(size_t viewIndex)
std::unique_lock lock(windowView->workerMutex); std::unique_lock lock(windowView->workerMutex);
windowView->view->commitUpdate(); windowView->view->commitUpdate();
} }
std::cout << "Update completed" << std::endl; //std::cout << "Update completed" << std::endl;
windowView->updateFinished.raise(); windowView->updateFinished.raise();
// enqueue next frame update // enqueue next frame update
viewWorker(viewIndex); viewWorker(viewIndex);