Эх сурвалжийг харах

implemented ability to quick compare drawing command buffers
using memcmp and decide whether to draw a new frame or not:
* added NK_ZERO_COMMAND_MEMORY macro
* when NK_ZERO_COMMAND_MEMORY is defined, inside
nk_command_buffer_push function there is an additional call
to NK_MEMSET after allocating memory for new drawing command

Yaroslav Tsarko 9 жил өмнө
parent
commit
26d77f88ff
1 өөрчлөгдсөн 11 нэмэгдсэн , 0 устгасан
  1. 11 0
      nuklear.h

+ 11 - 0
nuklear.h

@@ -214,6 +214,13 @@ OPTIONAL DEFINES:
         will be selected and compile time validated. If they are incorrect you can
         will be selected and compile time validated. If they are incorrect you can
         define the correct types by overloading these type defines.
         define the correct types by overloading these type defines.
 
 
+    NK_ZERO_COMMAND_MEMORY
+        Defining this will zero out memory for each drawing command added to a
+        drawing queue (inside nk_command_buffer_push). This can be used to
+        implement fast check (using memcmp) that command buffers are equal and
+        avoid drawing frames when nothing on screen has changed since previous
+        frame.
+
 CREDITS:
 CREDITS:
     Developed by Micha Mettke and every direct or indirect contributor to the GitHub.
     Developed by Micha Mettke and every direct or indirect contributor to the GitHub.
 
 
@@ -5847,6 +5854,10 @@ nk_command_buffer_push(struct nk_command_buffer* b,
     memory = NK_ALIGN_PTR(unaligned, align);
     memory = NK_ALIGN_PTR(unaligned, align);
     alignment = (nk_size)((nk_byte*)memory - (nk_byte*)unaligned);
     alignment = (nk_size)((nk_byte*)memory - (nk_byte*)unaligned);
 
 
+#ifdef NK_ZERO_COMMAND_MEMORY
+    NK_MEMSET(cmd, 0, size + alignment);
+#endif
+
     cmd->type = t;
     cmd->type = t;
     cmd->next = b->base->allocated + alignment;
     cmd->next = b->base->allocated + alignment;
 #ifdef NK_INCLUDE_COMMAND_USERDATA
 #ifdef NK_INCLUDE_COMMAND_USERDATA