R_View_WorldVisibility(r_refdef.view.useclipplane);
R_View_UpdateEntityVisible();
R_View_UpdateEntityLighting();
- R_AnimCache_CacheVisibleEntities();
}
static void R_View_Update(void)
R_View_WorldVisibility(r_refdef.view.useclipplane);
R_View_UpdateEntityVisible();
R_View_UpdateEntityLighting();
- R_AnimCache_CacheVisibleEntities();
}
float viewscalefpsadjusted = 1.0f;
R_View_UpdateWithScissor(myscissor);
else
R_View_Update();
+ R_AnimCache_CacheVisibleEntities();
if(r_water_scissormode.integer & 1)
GL_Scissor(myscissor[0], myscissor[1], myscissor[2], myscissor[3]);
R_RenderScene(p->fbo_reflection, r_fb.water.depthtexture, p->texture_reflection);
R_View_UpdateWithScissor(myscissor);
else
R_View_Update();
+ R_AnimCache_CacheVisibleEntities();
if(r_water_scissormode.integer & 1)
GL_Scissor(myscissor[0], myscissor[1], myscissor[2], myscissor[3]);
R_RenderScene(p->fbo_refraction, r_fb.water.depthtexture, p->texture_refraction);
R_ResetViewRendering3D(p->fbo_camera, r_fb.water.depthtexture, p->texture_camera);
R_ClearScreen(r_refdef.fogenabled);
R_View_Update();
+ R_AnimCache_CacheVisibleEntities();
R_RenderScene(p->fbo_camera, r_fb.water.depthtexture, p->texture_camera);
if (!p->fbo_camera)
if (!r_fb.water.depthtexture)
R_ClearScreen(r_refdef.fogenabled);
R_View_Update();
+ R_AnimCache_CacheVisibleEntities();
goto finish;
error:
r_refdef.view = originalview;
if (r_timereport_active)
R_TimeReport("visibility");
+ R_AnimCache_CacheVisibleEntities();
+ if (r_timereport_active)
+ R_TimeReport("animcache");
+
R_Shadow_UpdateBounceGridTexture();
if (r_timereport_active && r_shadow_bouncegrid.integer)
R_TimeReport("bouncegrid");
#define Thread_CondWait(cond, mutex) (_Thread_CondWait(cond, mutex, __FILE__, __LINE__))
#define Thread_CreateThread(fn, data) (_Thread_CreateThread(fn, data, __FILE__, __LINE__))
#define Thread_WaitThread(thread, retval) (_Thread_WaitThread(thread, retval, __FILE__, __LINE__))
+#define Thread_CreateBarrier(count) (_Thread_CreateBarrier(count, __FILE__, __LINE__))
+#define Thread_DestroyBarrier(barrier) (_Thread_DestroyBarrier(barrier, __FILE__, __LINE__))
+#define Thread_WaitBarrier(barrier) (_Thread_WaitBarrier(barrier, __FILE__, __LINE__))
int Thread_Init(void);
void Thread_Shutdown(void);
int _Thread_CondWait(void *cond, void *mutex, const char *filename, int fileline);
void *_Thread_CreateThread(int (*fn)(void *), void *data, const char *filename, int fileline);
int _Thread_WaitThread(void *thread, int retval, const char *filename, int fileline);
+void *_Thread_CreateBarrier(unsigned int count, const char *filename, int fileline);
+void _Thread_DestroyBarrier(void *barrier, const char *filename, int fileline);
+void _Thread_WaitBarrier(void *barrier, const char *filename, int fileline);
#endif
-
{
return retval;
}
+
+void *_Thread_CreateBarrier(unsigned int count, const char *filename, int fileline)
+{
+ return NULL;
+}
+
+void _Thread_DestroyBarrier(void *barrier, const char *filename, int fileline)
+{
+}
+
+void _Thread_WaitBarrier(void *barrier, const char *filename, int fileline)
+{
+}
return (int) (intptr_t) status;
}
+#ifdef PTHREAD_BARRIER_SERIAL_THREAD
+void *_Thread_CreateBarrier(unsigned int count, const char *filename, int fileline)
+{
+ pthread_barrier_t *b = (pthread_barrier_t *) Z_Malloc(sizeof(pthread_barrier_t));
+#ifdef THREADDEBUG
+ Sys_PrintfToTerminal("%p barrier create(%d) %s:%i\n", b, count, filename, fileline);
+#endif
+ pthread_barrier_init(b, NULL, count);
+ return (void *) b;
+}
+
+void _Thread_DestroyBarrier(void *barrier, const char *filename, int fileline)
+{
+ pthread_barrier_t *b = (pthread_barrier_t *) barrier;
+#ifdef THREADDEBUG
+ Sys_PrintfToTerminal("%p barrier destroy %s:%i\n", b, filename, fileline);
+#endif
+ pthread_barrier_destroy(b);
+}
+
+void _Thread_WaitBarrier(void *barrier, const char *filename, int fileline)
+{
+ pthread_barrier_t *b = (pthread_barrier_t *) barrier;
+#ifdef THREADDEBUG
+ Sys_PrintfToTerminal("%p barrier wait %s:%i\n", b, filename, fileline);
+#endif
+ pthread_barrier_wait(b);
+}
+#else
+// standard barrier implementation using conds and mutexes
+// see: http://www.howforge.com/implementing-barrier-in-pthreads
+typedef struct {
+ unsigned int needed;
+ unsigned int called;
+ void *mutex;
+ void *cond;
+} barrier_t;
+
+void *_Thread_CreateBarrier(unsigned int count, const char *filename, int fileline)
+{
+ barrier_t *b = Z_Malloc(sizeof(barrier_t));
+#ifdef THREADDEBUG
+ Sys_PrintfToTerminal("%p barrier create(%d) %s:%i\n", b, count, filename, fileline);
+#endif
+ b->needed = count;
+ b->called = 0;
+ b->mutex = Thread_CreateMutex();
+ b->cond = Thread_CreateCond();
+ return (void *) b;
+}
+void _Thread_DestroyBarrier(void *barrier, const char *filename, int fileline)
+{
+ barrier_t *b = (barrier_t *) barrier;
+#ifdef THREADDEBUG
+ Sys_PrintfToTerminal("%p barrier destroy %s:%i\n", b, filename, fileline);
+#endif
+ Thread_DestroyMutex(b->mutex);
+ Thread_DestroyCond(b->cond);
+}
+
+void _Thread_WaitBarrier(void *barrier, const char *filename, int fileline)
+{
+ barrier_t *b = (barrier_t *) barrier;
+#ifdef THREADDEBUG
+ Sys_PrintfToTerminal("%p barrier wait %s:%i\n", b, filename, fileline);
+#endif
+ Thread_LockMutex(b->mutex);
+ b->called++;
+ if (b->called == b->needed) {
+ b->called = 0;
+ Thread_CondBroadcast(b->cond);
+ } else {
+ do {
+ Thread_CondWait(b->cond, b->mutex);
+ } while(b->called);
+ }
+ Thread_UnlockMutex(b->mutex);
+}
+#endif
return status;
}
+// standard barrier implementation using conds and mutexes
+// see: http://www.howforge.com/implementing-barrier-in-pthreads
+typedef struct {
+ unsigned int needed;
+ unsigned int called;
+ void *mutex;
+ void *cond;
+} barrier_t;
+
+void *_Thread_CreateBarrier(unsigned int count, const char *filename, int fileline)
+{
+ barrier_t *b = Z_Malloc(sizeof(barrier_t));
+#ifdef THREADDEBUG
+ Sys_PrintfToTerminal("%p barrier create(%d) %s:%i\n", b, count, filename, fileline);
+#endif
+ b->needed = count;
+ b->called = 0;
+ b->mutex = Thread_CreateMutex();
+ b->cond = Thread_CreateCond();
+ return (void *) b;
+}
+
+void _Thread_DestroyBarrier(void *barrier, const char *filename, int fileline)
+{
+ barrier_t *b = (barrier_t *) barrier;
+#ifdef THREADDEBUG
+ Sys_PrintfToTerminal("%p barrier destroy %s:%i\n", b, filename, fileline);
+#endif
+ Thread_DestroyMutex(b->mutex);
+ Thread_DestroyCond(b->cond);
+}
+
+void _Thread_WaitBarrier(void *barrier, const char *filename, int fileline)
+{
+ barrier_t *b = (barrier_t *) barrier;
+#ifdef THREADDEBUG
+ Sys_PrintfToTerminal("%p barrier wait %s:%i\n", b, filename, fileline);
+#endif
+ Thread_LockMutex(b->mutex);
+ b->called++;
+ if (b->called == b->needed) {
+ b->called = 0;
+ Thread_CondBroadcast(b->cond);
+ } else {
+ do {
+ Thread_CondWait(b->cond, b->mutex);
+ } while(b->called);
+ }
+ Thread_UnlockMutex(b->mutex);
+}
free(w);
return retval;
}
+
+// standard barrier implementation using conds and mutexes
+// see: http://www.howforge.com/implementing-barrier-in-pthreads
+typedef struct {
+ unsigned int needed;
+ unsigned int called;
+ void *mutex;
+ void *cond;
+} barrier_t;
+
+void *_Thread_CreateBarrier(unsigned int count, const char *filename, int fileline)
+{
+ barrier_t *b = Z_Malloc(sizeof(barrier_t));
+#ifdef THREADDEBUG
+ Sys_PrintfToTerminal("%p barrier create(%d) %s:%i\n", b, count, filename, fileline);
+#endif
+ b->needed = count;
+ b->called = 0;
+ b->mutex = Thread_CreateMutex();
+ b->cond = Thread_CreateCond();
+ return (void *) b;
+}
+
+void _Thread_DestroyBarrier(void *barrier, const char *filename, int fileline)
+{
+ barrier_t *b = (barrier_t *) barrier;
+#ifdef THREADDEBUG
+ Sys_PrintfToTerminal("%p barrier destroy %s:%i\n", b, filename, fileline);
+#endif
+ Thread_DestroyMutex(b->mutex);
+ Thread_DestroyCond(b->cond);
+}
+
+void _Thread_WaitBarrier(void *barrier, const char *filename, int fileline)
+{
+ barrier_t *b = (barrier_t *) barrier;
+#ifdef THREADDEBUG
+ Sys_PrintfToTerminal("%p barrier wait %s:%i\n", b, filename, fileline);
+#endif
+ Thread_LockMutex(b->mutex);
+ b->called++;
+ if (b->called == b->needed) {
+ b->called = 0;
+ Thread_CondBroadcast(b->cond);
+ } else {
+ do {
+ Thread_CondWait(b->cond, b->mutex);
+ } while(b->called);
+ }
+ Thread_UnlockMutex(b->mutex);
+}