mirror of
https://github.com/TheRedShip/RT_GPU.git
synced 2025-09-27 18:48:36 +02:00
server now sends jobs to client and client can send result image to server
This commit is contained in:
@ -6,15 +6,15 @@
|
||||
/* By: tomoron <tomoron@student.42angouleme.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/02/20 18:25:18 by tomoron #+# #+# */
|
||||
/* Updated: 2025/02/23 22:41:25 by tomoron ### ########.fr */
|
||||
/* Updated: 2025/02/25 01:49:07 by tomoron ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#ifndef CLUSTERIZER_HPP
|
||||
# define CLUSTERIZER_HPP
|
||||
#pragma once
|
||||
|
||||
# include "RT.hpp"
|
||||
|
||||
|
||||
typedef enum e_job_status
|
||||
{
|
||||
WAITING,
|
||||
@ -24,19 +24,19 @@ typedef enum e_job_status
|
||||
|
||||
typedef struct s_job
|
||||
{
|
||||
std::string scene;
|
||||
glm::vec3 pos;
|
||||
glm::vec2 dir;
|
||||
size_t samples;
|
||||
GPUDenoise denoise;
|
||||
|
||||
size_t id;
|
||||
size_t frameNb;
|
||||
} t_job;
|
||||
|
||||
typedef struct s_client
|
||||
{
|
||||
std::vector<uint8_t> buffer;
|
||||
t_job *curJob;
|
||||
int progress;
|
||||
uint8_t progress;
|
||||
bool ready;
|
||||
} t_client;
|
||||
|
||||
@ -44,33 +44,31 @@ typedef enum e_msg
|
||||
{
|
||||
RDY,
|
||||
JOB,
|
||||
JOB_RES_RQ,
|
||||
ACK,
|
||||
WAIT,
|
||||
IMAGE,
|
||||
ERR,
|
||||
UNKNOWN
|
||||
PROGRESS_UPDATE,
|
||||
IMG_SEND_RQ,
|
||||
IMG
|
||||
} t_msg;
|
||||
|
||||
class Clusterizer
|
||||
{
|
||||
public:
|
||||
Clusterizer(Arguments &args);
|
||||
Clusterizer(Arguments &args, Renderer *renderer);
|
||||
~Clusterizer();
|
||||
|
||||
void update(void);
|
||||
void update(Scene &scene, Window &win, std::vector<GLuint> &textures, ShaderProgram &denoisingProgram);
|
||||
bool getError(void);
|
||||
void imguiRender(void);
|
||||
bool isServer(void);
|
||||
bool hasJobs(void);
|
||||
|
||||
void addJob(glm::vec3 pos, glm::vec2 dir, size_t samples);
|
||||
void addJob(glm::vec3 pos, glm::vec2 dir, size_t samples, size_t frames, GPUDenoise &denoise);
|
||||
|
||||
private:
|
||||
bool _isActive;
|
||||
bool _isServer;
|
||||
bool _error;
|
||||
std::string _sceneName;
|
||||
Renderer *_renderer;
|
||||
|
||||
std::vector<t_job *> _jobs[3];
|
||||
|
||||
@ -78,18 +76,23 @@ class Clusterizer
|
||||
void imguiClients(void);
|
||||
|
||||
private: //client
|
||||
void initClient(std::string &dest);
|
||||
void openClientConnection(const char *ip, int port);
|
||||
void clientHandleBuffer(void);
|
||||
void updateClient(void);
|
||||
void clientGetJob(void);
|
||||
void clientReceive(void);
|
||||
void initClient(std::string &dest);
|
||||
void openClientConnection(const char *ip, int port);
|
||||
void clientHandleBuffer(void);
|
||||
void updateClient(Scene &scene, Window &win, std::vector<GLuint> &textures, ShaderProgram &denoisingProgram);
|
||||
void clientGetJob(void);
|
||||
void clientReceive(void);
|
||||
void handleCurrentJob(Scene &scene, Window &win, std::vector<GLuint> &textures, ShaderProgram &denoisingProgram);
|
||||
void sendProgress(uint8_t progress);
|
||||
void sendImageToServer(std::vector<GLuint> &textures, ShaderProgram &denoisingProgram);
|
||||
|
||||
int _serverFd;
|
||||
std::string _serverIp;
|
||||
int _serverPort;
|
||||
std::vector<uint8_t> _receiveBuffer;
|
||||
t_job _currentJob;
|
||||
t_job *_currentJob;
|
||||
uint8_t _progress;
|
||||
bool _srvReady;
|
||||
|
||||
private: //server
|
||||
void initServer(std::string port);
|
||||
@ -104,13 +107,8 @@ class Clusterizer
|
||||
|
||||
int dispatchJobs(void);
|
||||
|
||||
|
||||
|
||||
|
||||
int _serverSocket;
|
||||
struct pollfd *_pollfds;
|
||||
std::map<int, t_client> _clients;
|
||||
size_t _curId;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user