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