File src/resource_manager/resource_manager.cpp changed (mode: 100644) (index 56fb7b3..52cc282) |
... |
... |
create_render(jen::ModuleGraphics mg, jrf::Vertices *p_jrf, jen::VertexData *p) |
154 |
154 |
jen::WriteData wd; |
jen::WriteData wd; |
155 |
155 |
wd.size = p_jrf->data_size; |
wd.size = p_jrf->data_size; |
156 |
156 |
wd.p = p_jrf->p_data; |
wd.p = p_jrf->p_data; |
157 |
|
auto res = mg.create(wd, &p->p_data, true); |
|
|
157 |
|
jen::Result res = mg.create(wd, &p->p_data, true); |
158 |
158 |
if (res == VK_SUCCESS) |
if (res == VK_SUCCESS) |
159 |
159 |
*p_jrf = {}; |
*p_jrf = {}; |
160 |
160 |
return res; |
return res; |
|
... |
... |
create_render(jen::ModuleGraphics mg, jrf::Indices *p_jrf, jen::IndexData *p) |
175 |
175 |
p->count = uint32_t(p_jrf->size / p_jrf->format); |
p->count = uint32_t(p_jrf->size / p_jrf->format); |
176 |
176 |
wd.size = p_jrf->size; |
wd.size = p_jrf->size; |
177 |
177 |
wd.p = p_jrf->p_data; |
wd.p = p_jrf->p_data; |
178 |
|
auto res = mg.create(wd, &p->p_data, true); |
|
|
178 |
|
jen::Result res = mg.create(wd, &p->p_data, true); |
179 |
179 |
if (res == VK_SUCCESS) |
if (res == VK_SUCCESS) |
180 |
180 |
*p_jrf = {}; |
*p_jrf = {}; |
181 |
181 |
return res; |
return res; |
|
... |
... |
create_render(jen::ModuleGraphics mg, jrf::Indices *p_jrf, jen::IndexData *p) |
185 |
185 |
create_render(jen::ModuleGraphics mg, jrf::Image *p_jrf, jen::TextureData *p) |
create_render(jen::ModuleGraphics mg, jrf::Image *p_jrf, jen::TextureData *p) |
186 |
186 |
{ |
{ |
187 |
187 |
p->layer_index = 0; |
p->layer_index = 0; |
188 |
|
auto res = mg.create(*p_jrf, &p->p_data, true); |
|
|
188 |
|
jen::Result res = mg.create(*p_jrf, &p->p_data, true); |
189 |
189 |
if (res == VK_SUCCESS) |
if (res == VK_SUCCESS) |
190 |
190 |
*p_jrf = {}; |
*p_jrf = {}; |
191 |
191 |
return res; |
return res; |
|
... |
... |
create(const jl::string_ro &path, detail::ResHandle<RT> *p_dst) { |
275 |
275 |
if (not path_move.init(path)) |
if (not path_move.init(path)) |
276 |
276 |
return { VK_ERROR_OUT_OF_HOST_MEMORY, {}}; |
return { VK_ERROR_OUT_OF_HOST_MEMORY, {}}; |
277 |
277 |
Result res = create_res(&path_move, p_dst); |
Result res = create_res(&path_move, p_dst); |
278 |
|
if (res != VK_SUCCESS) |
|
|
278 |
|
if (not res) |
279 |
279 |
path_move.destroy(); |
path_move.destroy(); |
280 |
280 |
return res; |
return res; |
281 |
281 |
} |
} |
|
... |
... |
template<jrf::ResourceType RT> |
285 |
285 |
create(const jl::string_ro &path, Resource<RT> *p_dst) { |
create(const jl::string_ro &path, Resource<RT> *p_dst) { |
286 |
286 |
detail::ResHandle<RT> rh; |
detail::ResHandle<RT> rh; |
287 |
287 |
Result res = create(path, &rh); |
Result res = create(path, &rh); |
288 |
|
if (res != VK_SUCCESS) |
|
|
288 |
|
if (not res) |
289 |
289 |
return res; |
return res; |
290 |
290 |
*p_dst = rh; |
*p_dst = rh; |
291 |
291 |
return {}; |
return {}; |
|
... |
... |
void RMM::destroy_model(const jl::string_ro &model_path) { |
605 |
605 |
///*****************************SCENE****************************************/// |
///*****************************SCENE****************************************/// |
606 |
606 |
|
|
607 |
607 |
[[nodiscard]] RMM::Result RMM:: |
[[nodiscard]] RMM::Result RMM:: |
608 |
|
create_scene(const jl::string_ro &path, uint32_t shift_scale, SceneData *p_dst) |
|
|
608 |
|
create_scene(const jl::string_ro &path, uint32_t offset_shift, SceneData *p_dst) |
609 |
609 |
{ |
{ |
610 |
610 |
detail::ResHandle<jrf::SCENE> rh; |
detail::ResHandle<jrf::SCENE> rh; |
611 |
611 |
jrf::Scene &scene = rh.res; |
jrf::Scene &scene = rh.res; |
|
... |
... |
create_scene(const jl::string_ro &path, uint32_t shift_scale, SceneData *p_dst) |
613 |
613 |
if (jrfres != jrf::SUCCESS) |
if (jrfres != jrf::SUCCESS) |
614 |
614 |
return { vkw::ERROR_JRF, jrfres }; |
return { vkw::ERROR_JRF, jrfres }; |
615 |
615 |
|
|
616 |
|
int32_t scale_diff = int32_t(shift_scale) - scene.options.shift_po2; |
|
|
616 |
|
int32_t shift_diff = int32_t(offset_shift) - scene.options.offset_shift; |
617 |
617 |
uint64_t i = 0; |
uint64_t i = 0; |
618 |
618 |
|
|
619 |
619 |
Result res; |
Result res; |
|
... |
... |
create_scene(const jl::string_ro &path, uint32_t shift_scale, SceneData *p_dst) |
636 |
636 |
sizeof(jrf::SceneEntryOptions::transform) == 0, |
sizeof(jrf::SceneEntryOptions::transform) == 0, |
637 |
637 |
"checking memcpy"); |
"checking memcpy"); |
638 |
638 |
|
|
639 |
|
memcpy(&ed.world.position, &e.options.pos, |
|
|
639 |
|
memcpy(&ed.world.position, &e.options.position, |
640 |
640 |
sizeof(jen::ModelWorld::position)); |
sizeof(jen::ModelWorld::position)); |
641 |
641 |
static_assert(sizeof(jen::ModelWorld::position) - |
static_assert(sizeof(jen::ModelWorld::position) - |
642 |
|
sizeof(jrf::SceneEntryOptions::pos) == 0, |
|
|
642 |
|
sizeof(jrf::SceneEntryOptions::position) == 0, |
643 |
643 |
"checking memcpy"); |
"checking memcpy"); |
644 |
644 |
|
|
645 |
645 |
for (unsigned int c = 0; c < 3; ++c) |
for (unsigned int c = 0; c < 3; ++c) |
646 |
646 |
ed.world.position_offset[c] |
ed.world.position_offset[c] |
647 |
|
= (e.options.shift[c] + scene.options.shift[c]) << scale_diff; |
|
|
647 |
|
= (e.options.offset[c] + scene.options.offset[c]) << shift_diff; |
648 |
648 |
} |
} |
649 |
649 |
|
|
650 |
650 |
if (rh.path.init(path)) { |
if (rh.path.init(path)) { |