Use continous memory for loading files
This commit is contained in:
parent
949c502d5d
commit
04358ed368
|
@ -6,22 +6,33 @@ namespace FileProcessor {
|
|||
class State {
|
||||
private:
|
||||
struct Reserved {
|
||||
uint32_t _reserved[2] = {0};
|
||||
uint32_t reserved[2];
|
||||
};
|
||||
|
||||
typedef bool (*ProcessRoutine)(uint32_t*, size_t, Reserved&);
|
||||
struct Configuration;
|
||||
typedef bool (*ProcessRoutine)(Configuration&, Reserved&, size_t);
|
||||
|
||||
struct Configuration {
|
||||
ProcessRoutine process_routine = nullptr;
|
||||
const uint32_t* data_adr = nullptr;
|
||||
|
||||
template<typename T>
|
||||
static __always_inline Configuration from(bool (*process_routine)(Configuration&, T&, size_t), const uint32_t* data_adr) {
|
||||
return {reinterpret_cast<ProcessRoutine>(process_routine), data_adr};
|
||||
}
|
||||
};
|
||||
|
||||
private:
|
||||
ProcessRoutine process_adr = nullptr;
|
||||
Reserved reserved;
|
||||
Configuration config;
|
||||
Reserved reserved;
|
||||
|
||||
public:
|
||||
bool process(uint32_t* data, size_t size) {
|
||||
return (*this->process_adr)(data, size, this->reserved);
|
||||
bool process(size_t size) {
|
||||
return (*this->config.process_routine)(this->config, this->reserved, size);
|
||||
}
|
||||
};
|
||||
|
||||
State create(const SimpleTIM& file);
|
||||
State create(const uint32_t* data_adr, const SimpleTIM& file);
|
||||
}
|
||||
|
||||
#endif // !__JABYENGINE_FILE_PROCESSOR_HPP__
|
|
@ -36,8 +36,8 @@ namespace GPU {
|
|||
Display::enable();
|
||||
|
||||
//For now
|
||||
auto state = FileProcessor::create(SimpleTIM(0, 0, 0, 0));
|
||||
while(state.process(nullptr, 0ull));
|
||||
auto state = FileProcessor::create(nullptr, SimpleTIM(0, 0, 0, 0));
|
||||
while(state.process(0ull));
|
||||
}
|
||||
|
||||
void setup() {
|
||||
|
|
|
@ -14,15 +14,15 @@ namespace FileProcessor {
|
|||
};
|
||||
static_assert(sizeof(SimpleTIMState) <= sizeof(State::Reserved));
|
||||
|
||||
static bool process(uint32_t*, size_t, SimpleTIMState &state) {
|
||||
static bool process(State::Configuration& config, SimpleTIMState& state, size_t size) {
|
||||
printf("Dino: %i\n", state.test);
|
||||
return false;
|
||||
}
|
||||
|
||||
State create(const SimpleTIM& file) {
|
||||
State create(const uint32_t* data_adr, const SimpleTIM& file) {
|
||||
SimpleTIMState test(123);
|
||||
|
||||
return State{.process_adr = reinterpret_cast<State::ProcessRoutine>(process), .reserved = test._reserved};
|
||||
return State{.config = State::Configuration::from(process, data_adr), .reserved = test._reserved};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue