Batch viewport render commands with main render commands
I don't know why I did it the other way...?
This commit is contained in:
parent
e9bb4bc82c
commit
63f844a20d
7 changed files with 33 additions and 7 deletions
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
class Engine;
|
class Engine;
|
||||||
|
class GFXCommandBuffer;
|
||||||
|
|
||||||
/// The base class for any Prism application.
|
/// The base class for any Prism application.
|
||||||
class App {
|
class App {
|
||||||
|
@ -23,6 +24,8 @@ public:
|
||||||
@param delta_time Delta time in milliseconds.
|
@param delta_time Delta time in milliseconds.
|
||||||
*/
|
*/
|
||||||
virtual void update([[maybe_unused]] const float delta_time) {}
|
virtual void update([[maybe_unused]] const float delta_time) {}
|
||||||
|
|
||||||
|
virtual void render([[maybe_unused]] GFXCommandBuffer* command_buffer) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// This is an app's equivalent main(). You can check command line arguments through Engine::comand_line_arguments.
|
/// This is an app's equivalent main(). You can check command line arguments through Engine::comand_line_arguments.
|
||||||
|
|
|
@ -759,8 +759,14 @@ void Engine::render(const int index) {
|
||||||
_imgui->render(0);
|
_imgui->render(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GFXCommandBuffer* commandbuffer = _gfx->acquire_command_buffer();
|
||||||
|
|
||||||
|
_app->render(commandbuffer);
|
||||||
|
|
||||||
if(window->renderer != nullptr)
|
if(window->renderer != nullptr)
|
||||||
window->renderer->render(_current_scene, index);
|
window->renderer->render(commandbuffer, _current_scene, index);
|
||||||
|
|
||||||
|
_gfx->submit(commandbuffer, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Engine::add_timer(Timer& timer) {
|
void Engine::add_timer(Timer& timer) {
|
||||||
|
|
|
@ -70,7 +70,8 @@ public:
|
||||||
int elementOffset = 0;
|
int elementOffset = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
void render(Scene* scene, int index);
|
void start_render(Scene* scene, int index);
|
||||||
|
void render(GFXCommandBuffer* command_buffer, Scene* scene, int index);
|
||||||
|
|
||||||
void render_screen(GFXCommandBuffer* commandBuffer, ui::Screen* screen, ControllerContinuity& continuity, RenderScreenOptions options = RenderScreenOptions());
|
void render_screen(GFXCommandBuffer* commandBuffer, ui::Screen* screen, ControllerContinuity& continuity, RenderScreenOptions options = RenderScreenOptions());
|
||||||
void render_camera(GFXCommandBuffer* command_buffer, Scene& scene, Object camera_object, Camera& camera, prism::Extent extent, ControllerContinuity& continuity);
|
void render_camera(GFXCommandBuffer* command_buffer, Scene& scene, Object camera_object, Camera& camera, prism::Extent extent, ControllerContinuity& continuity);
|
||||||
|
|
|
@ -211,9 +211,15 @@ void Renderer::stopSceneBlur() {
|
||||||
blurring = false;
|
blurring = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::render(Scene* scene, int index) {
|
void Renderer::start_render(Scene* scene, int index) {
|
||||||
GFXCommandBuffer* commandbuffer = engine->get_gfx()->acquire_command_buffer();
|
GFXCommandBuffer* commandbuffer = engine->get_gfx()->acquire_command_buffer();
|
||||||
|
|
||||||
|
render(commandbuffer, scene, index);
|
||||||
|
|
||||||
|
gfx->submit(commandbuffer, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Renderer::render(GFXCommandBuffer* commandbuffer, Scene* scene, int index) {
|
||||||
if(render_options.render_scale != current_render_scale) {
|
if(render_options.render_scale != current_render_scale) {
|
||||||
if(viewport_mode)
|
if(viewport_mode)
|
||||||
resize_viewport(viewport_extent);
|
resize_viewport(viewport_extent);
|
||||||
|
@ -406,8 +412,6 @@ void Renderer::render(Scene* scene, int index) {
|
||||||
pass->render_post(commandbuffer, index);
|
pass->render_post(commandbuffer, index);
|
||||||
|
|
||||||
commandbuffer->pop_group();
|
commandbuffer->pop_group();
|
||||||
|
|
||||||
gfx->submit(commandbuffer, index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::render_camera(GFXCommandBuffer* command_buffer, Scene& scene, Object camera_object, Camera& camera, prism::Extent extent, ControllerContinuity& continuity) {
|
void Renderer::render_camera(GFXCommandBuffer* command_buffer, Scene& scene, Object camera_object, Camera& camera, prism::Extent extent, ControllerContinuity& continuity) {
|
||||||
|
|
|
@ -117,6 +117,12 @@ public:
|
||||||
|
|
||||||
void update(float deltaTime) override;
|
void update(float deltaTime) override;
|
||||||
|
|
||||||
|
virtual void renderEditor([[maybe_unused]] GFXCommandBuffer* command_buffer) {}
|
||||||
|
|
||||||
|
void render(GFXCommandBuffer* command_buffer) override {
|
||||||
|
renderEditor(command_buffer);
|
||||||
|
}
|
||||||
|
|
||||||
virtual void updateEditor([[maybe_unused]] float deltaTime) {}
|
virtual void updateEditor([[maybe_unused]] float deltaTime) {}
|
||||||
|
|
||||||
virtual void object_selected([[maybe_unused]] Object object) {}
|
virtual void object_selected([[maybe_unused]] Object object) {}
|
||||||
|
|
|
@ -56,6 +56,7 @@ class PrismEditor : public CommonEditor {
|
||||||
public:
|
public:
|
||||||
PrismEditor();
|
PrismEditor();
|
||||||
|
|
||||||
|
void renderEditor(GFXCommandBuffer* command_buffer) override;
|
||||||
void drawUI() override;
|
void drawUI() override;
|
||||||
void updateEditor(float deltaTime) override;
|
void updateEditor(float deltaTime) override;
|
||||||
|
|
||||||
|
|
|
@ -179,6 +179,12 @@ void PrismEditor::open_asset(const file::Path path) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PrismEditor::renderEditor(GFXCommandBuffer* command_buffer) {
|
||||||
|
for (auto& editor : editors) {
|
||||||
|
editor->renderer->render(command_buffer, editor->get_scene(), -1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void PrismEditor::drawUI() {
|
void PrismEditor::drawUI() {
|
||||||
createDockArea();
|
createDockArea();
|
||||||
|
|
||||||
|
@ -316,7 +322,6 @@ void PrismEditor::drawUI() {
|
||||||
if(debugPass != nullptr)
|
if(debugPass != nullptr)
|
||||||
debugPass->selected_object = selected_object;
|
debugPass->selected_object = selected_object;
|
||||||
|
|
||||||
editor->renderer->render(editor->get_scene(), -1);
|
|
||||||
engine->set_current_scene(editor->get_scene());
|
engine->set_current_scene(editor->get_scene());
|
||||||
set_undo_stack(&editor->undo_stack);
|
set_undo_stack(&editor->undo_stack);
|
||||||
editor->draw(this);
|
editor->draw(this);
|
||||||
|
|
Reference in a new issue