mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 07:12:16 +00:00
- added r_debug_draw that shows how the software renderer composes its scene
This commit is contained in:
parent
1b68b69ed8
commit
459f748c4e
3 changed files with 41 additions and 3 deletions
|
@ -40,6 +40,7 @@ void PeekThreadedErrorPane();
|
|||
#endif
|
||||
|
||||
CVAR(Bool, r_multithreaded, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG);
|
||||
CVAR(Int, r_debug_draw, 0, 0);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
@ -76,6 +77,23 @@ void DrawerThreads::Execute(DrawerCommandQueuePtr commands)
|
|||
queue->start_condition.notify_all();
|
||||
}
|
||||
|
||||
void DrawerThreads::ResetDebugDrawPos()
|
||||
{
|
||||
auto queue = Instance();
|
||||
std::unique_lock<std::mutex> start_lock(queue->start_mutex);
|
||||
bool reached_end = false;
|
||||
for (auto &thread : queue->threads)
|
||||
{
|
||||
if (thread.debug_draw_pos + r_debug_draw * 60 * 2 < queue->debug_draw_end)
|
||||
reached_end = true;
|
||||
thread.debug_draw_pos = 0;
|
||||
}
|
||||
if (!reached_end)
|
||||
queue->debug_draw_end += r_debug_draw;
|
||||
else
|
||||
queue->debug_draw_end = 0;
|
||||
}
|
||||
|
||||
void DrawerThreads::WaitForWorkers()
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
|
@ -124,10 +142,22 @@ void DrawerThreads::WorkerMain(DrawerThread *thread)
|
|||
start_lock.unlock();
|
||||
|
||||
// Do the work:
|
||||
if (r_debug_draw)
|
||||
{
|
||||
for (auto& command : list->commands)
|
||||
{
|
||||
thread->debug_draw_pos++;
|
||||
if (thread->debug_draw_pos < debug_draw_end)
|
||||
command->Execute(thread);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto& command : list->commands)
|
||||
{
|
||||
command->Execute(thread);
|
||||
}
|
||||
}
|
||||
|
||||
// Notify main thread that we finished:
|
||||
std::unique_lock<std::mutex> end_lock(end_mutex);
|
||||
|
|
|
@ -52,6 +52,8 @@ public:
|
|||
|
||||
std::shared_ptr<PolyTriangleThreadData> poly;
|
||||
|
||||
size_t debug_draw_pos = 0;
|
||||
|
||||
// Checks if a line is rendered by this thread
|
||||
bool line_skipped_by_thread(int line)
|
||||
{
|
||||
|
@ -110,6 +112,8 @@ public:
|
|||
// Waits for all commands to finish executing
|
||||
static void WaitForWorkers();
|
||||
|
||||
static void ResetDebugDrawPos();
|
||||
|
||||
private:
|
||||
DrawerThreads();
|
||||
~DrawerThreads();
|
||||
|
@ -132,6 +136,8 @@ private:
|
|||
std::condition_variable end_condition;
|
||||
size_t tasks_left = 0;
|
||||
|
||||
size_t debug_draw_end = 0;
|
||||
|
||||
DrawerThread single_core_thread;
|
||||
|
||||
friend class DrawerCommandQueue;
|
||||
|
|
|
@ -64,6 +64,7 @@ void PeekThreadedErrorPane();
|
|||
#endif
|
||||
|
||||
EXTERN_CVAR(Int, r_clearbuffer)
|
||||
EXTERN_CVAR(Int, r_debug_draw)
|
||||
|
||||
CVAR(Bool, r_scene_multithreaded, false, 0);
|
||||
CVAR(Bool, r_models, false, 0);
|
||||
|
@ -103,7 +104,7 @@ namespace swrenderer
|
|||
if (r_models)
|
||||
PolyTriangleDrawer::ClearBuffers(viewport->RenderTarget);
|
||||
|
||||
if (r_clearbuffer != 0)
|
||||
if (r_clearbuffer != 0 || r_debug_draw != 0)
|
||||
{
|
||||
if (!viewport->RenderTarget->IsBgra())
|
||||
{
|
||||
|
@ -118,6 +119,7 @@ namespace swrenderer
|
|||
for (int i = 0; i < size; i++)
|
||||
dest[i] = bgracolor.d;
|
||||
}
|
||||
DrawerThreads::ResetDebugDrawPos();
|
||||
}
|
||||
|
||||
RenderActorView(player->mo);
|
||||
|
|
Loading…
Reference in a new issue