fix resource loader
parent
ca88887dad
commit
e15bc0d71f
Binary file not shown.
|
@ -426,3 +426,27 @@
|
||||||
3276 3428 1689559335266750704 parksnrec 73f5327ec08a5e2d
|
3276 3428 1689559335266750704 parksnrec 73f5327ec08a5e2d
|
||||||
4 3241 1689559654724420197 CMakeFiles/parksnrec.dir/src/parks/renderer/engine.cpp.o 875432a17ebda434
|
4 3241 1689559654724420197 CMakeFiles/parksnrec.dir/src/parks/renderer/engine.cpp.o 875432a17ebda434
|
||||||
3242 3406 1689559654891086224 parksnrec 73f5327ec08a5e2d
|
3242 3406 1689559654891086224 parksnrec 73f5327ec08a5e2d
|
||||||
|
4 3226 1689560762539336139 CMakeFiles/parksnrec.dir/src/parks/renderer/engine.cpp.o 875432a17ebda434
|
||||||
|
3227 3384 1689560762699336787 parksnrec 73f5327ec08a5e2d
|
||||||
|
4 3270 1689560982176933513 CMakeFiles/parksnrec.dir/src/parks/renderer/engine.cpp.o 875432a17ebda434
|
||||||
|
3271 3430 1689560982336934217 parksnrec 73f5327ec08a5e2d
|
||||||
|
3 3331 1689561089374079142 CMakeFiles/parksnrec.dir/src/parks/renderer/engine.cpp.o 875432a17ebda434
|
||||||
|
3331 3486 1689561089530746518 parksnrec 73f5327ec08a5e2d
|
||||||
|
7 972 1689627773776677057 CMakeFiles/parksnrec.dir/src/parks/main.cpp.o 6390d2c60c8af1e3
|
||||||
|
7 1502 1689627774306664209 CMakeFiles/parksnrec.dir/src/parks/renderer/resources.cpp.o f83315eef0077471
|
||||||
|
5 3650 1689627790842956241 CMakeFiles/parksnrec.dir/src/parks/renderer/engine.cpp.o 875432a17ebda434
|
||||||
|
3655 3841 1689627791036285474 parksnrec 73f5327ec08a5e2d
|
||||||
|
4 1394 1689628079340653016 CMakeFiles/parksnrec.dir/src/parks/renderer/resources.cpp.o f83315eef0077471
|
||||||
|
1394 1545 1689628079493986103 parksnrec 73f5327ec08a5e2d
|
||||||
|
5 1498 1689628119669284220 CMakeFiles/parksnrec.dir/src/parks/renderer/resources.cpp.o f83315eef0077471
|
||||||
|
1498 1655 1689628119825943047 parksnrec 73f5327ec08a5e2d
|
||||||
|
4 1500 1689628181339839650 CMakeFiles/parksnrec.dir/src/parks/renderer/resources.cpp.o f83315eef0077471
|
||||||
|
1501 1656 1689628181493166783 parksnrec 73f5327ec08a5e2d
|
||||||
|
7 1414 1689628275463236381 CMakeFiles/parksnrec.dir/src/parks/renderer/resources.cpp.o f83315eef0077471
|
||||||
|
1415 1570 1689628275619898399 parksnrec 73f5327ec08a5e2d
|
||||||
|
5 3261 1689628301879150929 CMakeFiles/parksnrec.dir/src/parks/renderer/engine.cpp.o 875432a17ebda434
|
||||||
|
3262 3416 1689628302032480074 parksnrec 73f5327ec08a5e2d
|
||||||
|
5 1483 1689628425826328479 CMakeFiles/parksnrec.dir/src/parks/renderer/resources.cpp.o f83315eef0077471
|
||||||
|
1483 1636 1689628425979658910 parksnrec 73f5327ec08a5e2d
|
||||||
|
4 1451 1689628531811248878 CMakeFiles/parksnrec.dir/src/parks/renderer/resources.cpp.o f83315eef0077471
|
||||||
|
1451 1628 1689628531987913007 parksnrec 73f5327ec08a5e2d
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,3 +1,3 @@
|
||||||
Start testing: Jul 16 22:07 EDT
|
Start testing: Jul 17 17:15 EDT
|
||||||
----------------------------------------------------------
|
----------------------------------------------------------
|
||||||
End testing: Jul 16 22:07 EDT
|
End testing: Jul 17 17:15 EDT
|
||||||
|
|
|
@ -9,7 +9,7 @@ Size=430,174
|
||||||
Collapsed=1
|
Collapsed=1
|
||||||
|
|
||||||
[Window][Dear ImGui Demo]
|
[Window][Dear ImGui Demo]
|
||||||
Pos=1333,405
|
Pos=929,405
|
||||||
Size=550,680
|
Size=550,680
|
||||||
Collapsed=1
|
Collapsed=1
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -5,7 +5,7 @@
|
||||||
#ifndef PARKSNREC_GENETIC_H
|
#ifndef PARKSNREC_GENETIC_H
|
||||||
#define PARKSNREC_GENETIC_H
|
#define PARKSNREC_GENETIC_H
|
||||||
|
|
||||||
#include <genetic/operators.h>
|
#include <genetic/old/operators.h>
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <ImNodes.h>
|
#include <ImNodes.h>
|
||||||
#include "ImNodesEz.h"
|
#include "ImNodesEz.h"
|
||||||
|
@ -310,6 +310,10 @@ namespace parks::genetic {
|
||||||
// nullptr)));
|
// nullptr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mutate(){
|
||||||
|
set.mutate();
|
||||||
|
}
|
||||||
|
|
||||||
Program* crossover(Program* program){
|
Program* crossover(Program* program){
|
||||||
return new Program(this, program);
|
return new Program(this, program);
|
||||||
}
|
}
|
|
@ -15,13 +15,13 @@ int main(){
|
||||||
settings.setProperty(Properties::WINDOW_TITLE, new Properties::Value<std::string>("So You Think You Can Park?"));
|
settings.setProperty(Properties::WINDOW_TITLE, new Properties::Value<std::string>("So You Think You Can Park?"));
|
||||||
|
|
||||||
// TODO: poll hardware
|
// TODO: poll hardware
|
||||||
//resources::init(16);
|
resources::init(16);
|
||||||
// TODO local
|
// TODO local
|
||||||
//resources::loadTexture("/home/brett/git/parksandrec/resources/textures/test.png", "test.png");
|
resources::loadTexture("/home/brett/git/parksandrec/resources/textures/test.png", "test.png");
|
||||||
|
|
||||||
Window::create(settings);
|
Window::create(settings);
|
||||||
|
|
||||||
//resources::beginLoading();
|
resources::beginLoading();
|
||||||
|
|
||||||
parks::Engine gameEngine(settings);
|
parks::Engine gameEngine(settings);
|
||||||
//Window::setMouseVisible(false);
|
//Window::setMouseVisible(false);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
//
|
//
|
||||||
#include "parks/renderer/engine.h"
|
#include "parks/renderer/engine.h"
|
||||||
#include <imgui.h>
|
#include <imgui.h>
|
||||||
#include <genetic/genetic.h>
|
#include <genetic/old/genetic.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <blt/profiling/profiler.h>
|
#include <blt/profiling/profiler.h>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
@ -17,6 +17,7 @@ namespace parks {
|
||||||
constexpr unsigned int gtChannels = 4;
|
constexpr unsigned int gtChannels = 4;
|
||||||
|
|
||||||
std::unique_ptr<genetic::Program> p;
|
std::unique_ptr<genetic::Program> p;
|
||||||
|
std::unique_ptr<genetic::Program> c;
|
||||||
std::unique_ptr<genetic::Program> old;
|
std::unique_ptr<genetic::Program> old;
|
||||||
std::unique_ptr<genetic::Program> save;
|
std::unique_ptr<genetic::Program> save;
|
||||||
double values[gtWidth * gtHeight * gtChannels];
|
double values[gtWidth * gtHeight * gtChannels];
|
||||||
|
@ -199,7 +200,7 @@ namespace parks {
|
||||||
|
|
||||||
testShader.bind();
|
testShader.bind();
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
//resources::getTexture("test.png")->bind();
|
resources::getTexture("test.png")->bind();
|
||||||
vao.bind();
|
vao.bind();
|
||||||
vao.bindEBO();
|
vao.bindEBO();
|
||||||
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
|
glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT, 0);
|
||||||
|
@ -231,6 +232,9 @@ namespace parks {
|
||||||
p = std::unique_ptr<genetic::Program>(np);
|
p = std::unique_ptr<genetic::Program>(np);
|
||||||
BLT_TRACE("cross| np: %d, old: %d, p: %d, save: %d", np, old.get(), p.get(), save.get());
|
BLT_TRACE("cross| np: %d, old: %d, p: %d, save: %d", np, old.get(), p.get(), save.get());
|
||||||
}
|
}
|
||||||
|
if (ImGui::Button("Mutate")){
|
||||||
|
p->mutate();
|
||||||
|
}
|
||||||
if (ImGui::Button("Save")){
|
if (ImGui::Button("Save")){
|
||||||
save = std::move(p);
|
save = std::move(p);
|
||||||
p = std::make_unique<genetic::Program>();
|
p = std::make_unique<genetic::Program>();
|
||||||
|
@ -320,6 +324,8 @@ namespace parks {
|
||||||
Engine::~Engine() {
|
Engine::~Engine() {
|
||||||
running = false;
|
running = false;
|
||||||
for (auto*& t : runningThread) {
|
for (auto*& t : runningThread) {
|
||||||
|
if (t == nullptr)
|
||||||
|
continue;
|
||||||
t->join();
|
t->join();
|
||||||
delete t;
|
delete t;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace parks {
|
||||||
stbi_set_flip_vertically_on_load(true);
|
stbi_set_flip_vertically_on_load(true);
|
||||||
for (int i = 0; i < TextureLoader.numThreads; i++) {
|
for (int i = 0; i < TextureLoader.numThreads; i++) {
|
||||||
TextureLoader.threads[i] = new std::thread(
|
TextureLoader.threads[i] = new std::thread(
|
||||||
[]() -> void {
|
[i]() -> void {
|
||||||
try {
|
try {
|
||||||
stbi_set_flip_vertically_on_load_thread(true);
|
stbi_set_flip_vertically_on_load_thread(true);
|
||||||
while (!TextureLoader.texturesToLoad.empty()) {
|
while (!TextureLoader.texturesToLoad.empty()) {
|
||||||
|
@ -63,6 +63,8 @@ namespace parks {
|
||||||
try {
|
try {
|
||||||
std::scoped_lock<std::mutex> textureQueueLock{
|
std::scoped_lock<std::mutex> textureQueueLock{
|
||||||
TextureLoader.textureQueueMutex};
|
TextureLoader.textureQueueMutex};
|
||||||
|
if (TextureLoader.texturesToLoad.empty())
|
||||||
|
break;
|
||||||
texture = TextureLoader.texturesToLoad.front();
|
texture = TextureLoader.texturesToLoad.front();
|
||||||
TextureLoader.texturesToLoad.pop();
|
TextureLoader.texturesToLoad.pop();
|
||||||
} catch (std::exception& e){
|
} catch (std::exception& e){
|
||||||
|
@ -71,6 +73,7 @@ namespace parks {
|
||||||
}
|
}
|
||||||
if (texture.path.empty())
|
if (texture.path.empty())
|
||||||
continue;
|
continue;
|
||||||
|
BLT_TRACE("Processing Texture %s", texture.path.c_str());
|
||||||
LoadedTexture loadedTexture;
|
LoadedTexture loadedTexture;
|
||||||
loadedTexture.data = stbi_load(
|
loadedTexture.data = stbi_load(
|
||||||
texture.path.c_str(), &loadedTexture.width,
|
texture.path.c_str(), &loadedTexture.width,
|
||||||
|
@ -92,7 +95,7 @@ namespace parks {
|
||||||
std::scoped_lock<std::mutex> threadSyncLock(
|
std::scoped_lock<std::mutex> threadSyncLock(
|
||||||
TextureLoader.threadSyncMutex
|
TextureLoader.threadSyncMutex
|
||||||
);
|
);
|
||||||
TextureLoader.finishedThreads++;
|
TextureLoader.finishedThreads += 1;
|
||||||
}
|
}
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
BLT_ERROR("An error has been detected in the loader thread loop!");
|
BLT_ERROR("An error has been detected in the loader thread loop!");
|
||||||
|
@ -108,7 +111,7 @@ namespace parks {
|
||||||
LoadedTexture texture;
|
LoadedTexture texture;
|
||||||
{
|
{
|
||||||
if (TextureLoader.loadedTextures.empty()) {
|
if (TextureLoader.loadedTextures.empty()) {
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
std::this_thread::sleep_for(std::chrono::milliseconds(50));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
std::scoped_lock<std::mutex> loadQueueLock{TextureLoader.glLoadQueueMutex};
|
std::scoped_lock<std::mutex> loadQueueLock{TextureLoader.glLoadQueueMutex};
|
||||||
|
|
Loading…
Reference in New Issue