mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-22 20:41:20 +00:00
[vid] Remove VID_InitBuffers
Its guts have been moved to D_Init temporarily while I work on the frame buffer design. This is actually a big part of that work as it moves most of the frame buffer creation into the one place, making it easier to ensure I get all the sub-buffers and caches created.
This commit is contained in:
parent
3b4608a0cd
commit
b82a353a20
6 changed files with 39 additions and 78 deletions
|
@ -52,10 +52,10 @@ void R_PushDlights (const vec3_t entorigin);
|
|||
void R_DrawWaterSurfaces (void);
|
||||
|
||||
void *D_SurfaceCacheAddress (void) __attribute__((pure));
|
||||
int D_SurfaceCacheForRes (void *data, int width, int height);
|
||||
int D_SurfaceCacheForRes (int width, int height);
|
||||
void D_FlushCaches (void *data);
|
||||
void D_DeleteSurfaceCache (void);
|
||||
void D_InitCaches (void *data, void *buffer, int size);
|
||||
void D_InitCaches (void *buffer, int size);
|
||||
void R_SetVrect (const vrect_t *pvrect, vrect_t *pvrectin, int lineadj);
|
||||
|
||||
void R_LoadSkys (const char *);
|
||||
|
|
|
@ -5,9 +5,7 @@
|
|||
#include "QF/plugin/vid_render.h"
|
||||
|
||||
typedef struct vid_internal_s {
|
||||
int (*surf_cache_size) (void *data, int width, int height);
|
||||
void (*flush_caches) (void *data);
|
||||
void (*init_caches) (void *data, void *cache, int size);
|
||||
void (*init_buffers) (void *data);
|
||||
void (*set_palette) (void *data, const byte *palette);
|
||||
|
||||
|
@ -31,7 +29,6 @@ void VID_InitGamma (const byte *);
|
|||
qboolean VID_SetGamma (double);
|
||||
void VID_UpdateGamma (struct cvar_s *);
|
||||
|
||||
void VID_InitBuffers (void);
|
||||
void VID_MakeColormaps (void);
|
||||
|
||||
#endif//__vid_internal_h
|
||||
|
|
|
@ -56,11 +56,33 @@ D_Init (void)
|
|||
r_worldpolysbacktofront = false;
|
||||
r_recursiveaffinetriangles = true;
|
||||
|
||||
vr_data.vid->vid_internal->surf_cache_size = D_SurfaceCacheForRes;
|
||||
vr_data.vid->vid_internal->flush_caches = D_FlushCaches;
|
||||
vr_data.vid->vid_internal->init_caches = D_InitCaches;
|
||||
viddef_t *vid = vr_data.vid;
|
||||
|
||||
VID_InitBuffers ();
|
||||
vid->vid_internal->flush_caches = D_FlushCaches;
|
||||
|
||||
int buffersize = vid->rowbytes * vid->height;
|
||||
int zbuffersize = vid->width * vid->height * sizeof (*vid->zbuffer);
|
||||
int cachesize = D_SurfaceCacheForRes (vid->width, vid->height);
|
||||
|
||||
if (vid->zbuffer) {
|
||||
free (vid->zbuffer);
|
||||
vid->zbuffer = 0;
|
||||
}
|
||||
if (vid->surfcache) {
|
||||
D_FlushCaches (0);
|
||||
free (vid->surfcache);
|
||||
vid->surfcache = 0;
|
||||
}
|
||||
if (vid->vid_internal->init_buffers) {
|
||||
vid->vid_internal->init_buffers (vid->vid_internal->data);
|
||||
} else {
|
||||
free (vid->buffer);
|
||||
vid->buffer = calloc (buffersize, 1);
|
||||
}
|
||||
vid->zbuffer = calloc (zbuffersize, 1);
|
||||
vid->surfcache = calloc (cachesize, 1);
|
||||
|
||||
D_InitCaches (vid->surfcache, cachesize);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -54,7 +54,7 @@ D_SurfaceCacheAddress (void)
|
|||
}
|
||||
|
||||
int
|
||||
D_SurfaceCacheForRes (void *data, int width, int height)
|
||||
D_SurfaceCacheForRes (int width, int height)
|
||||
{
|
||||
int size, pix;
|
||||
|
||||
|
@ -96,7 +96,7 @@ D_ClearCacheGuard (void)
|
|||
}
|
||||
|
||||
void
|
||||
D_InitCaches (void *data, void *buffer, int size)
|
||||
D_InitCaches (void *buffer, int size)
|
||||
{
|
||||
Sys_MaskPrintf (SYS_dev, "D_InitCaches: %ik surface cache\n", size/1024);
|
||||
|
||||
|
|
|
@ -247,73 +247,6 @@ VID_InitGamma (const byte *pal)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
VID_InitBuffers (void)
|
||||
{
|
||||
int buffersize, zbuffersize, cachesize = 1;
|
||||
|
||||
// No console scaling in the sw renderer
|
||||
viddef.conview->xlen = viddef.width;
|
||||
viddef.conview->ylen = viddef.height;
|
||||
Con_CheckResize ();
|
||||
|
||||
// Calculate the sizes we want first
|
||||
buffersize = viddef.rowbytes * viddef.height;
|
||||
zbuffersize = viddef.width * viddef.height * sizeof (*viddef.zbuffer);
|
||||
if (vi->surf_cache_size) {
|
||||
cachesize = vi->surf_cache_size (vi->data,
|
||||
viddef.width, viddef.height);
|
||||
}
|
||||
|
||||
// Free the old z-buffer
|
||||
if (viddef.zbuffer) {
|
||||
free (viddef.zbuffer);
|
||||
viddef.zbuffer = NULL;
|
||||
}
|
||||
// Free the old surface cache
|
||||
if (viddef.surfcache) {
|
||||
if (vi->flush_caches) {
|
||||
vi->flush_caches (vi->data);
|
||||
}
|
||||
free (viddef.surfcache);
|
||||
viddef.surfcache = NULL;
|
||||
}
|
||||
if (vi->init_buffers) {
|
||||
vi->init_buffers (vi->data);
|
||||
} else {
|
||||
// Free the old screen buffer
|
||||
if (viddef.buffer) {
|
||||
free (viddef.buffer);
|
||||
viddef.buffer = NULL;
|
||||
}
|
||||
// Allocate the new screen buffer
|
||||
viddef.buffer = calloc (buffersize, 1);
|
||||
if (!viddef.buffer) {
|
||||
Sys_Error ("Not enough memory for video mode");
|
||||
}
|
||||
}
|
||||
// Allocate the new z-buffer
|
||||
viddef.zbuffer = calloc (zbuffersize, 1);
|
||||
if (!viddef.zbuffer) {
|
||||
free (viddef.buffer);
|
||||
viddef.buffer = NULL;
|
||||
Sys_Error ("Not enough memory for video mode");
|
||||
}
|
||||
// Allocate the new surface cache; free the z-buffer if we fail
|
||||
viddef.surfcache = calloc (cachesize, 1);
|
||||
if (!viddef.surfcache) {
|
||||
free (viddef.buffer);
|
||||
free (viddef.zbuffer);
|
||||
viddef.buffer = NULL;
|
||||
viddef.zbuffer = NULL;
|
||||
Sys_Error ("Not enough memory for video mode");
|
||||
}
|
||||
|
||||
if (vi->init_caches) {
|
||||
vi->init_caches (vi->data, viddef.surfcache, cachesize);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
VID_ClearMemory (void)
|
||||
{
|
||||
|
|
|
@ -55,11 +55,14 @@
|
|||
#include <X11/Xutil.h>
|
||||
#include <X11/extensions/XShm.h>
|
||||
|
||||
#include "QF/console.h"
|
||||
#include "QF/cvar.h"
|
||||
#include "QF/qargs.h"
|
||||
#include "QF/sys.h"
|
||||
#include "QF/vid.h"
|
||||
|
||||
#include "QF/ui/view.h"
|
||||
|
||||
#include "context_x11.h"
|
||||
#include "r_internal.h"
|
||||
#include "vid_internal.h"
|
||||
|
@ -633,6 +636,12 @@ x11_create_context (sw_ctx_t *ctx)
|
|||
x_shmeventtype = XShmGetEventBase (x_disp) + ShmCompletion;
|
||||
}
|
||||
|
||||
// FIXME this really shouldn't be here (ideally, scale console in sw)
|
||||
// No console scaling in the sw renderer
|
||||
viddef.conview->xlen = viddef.width;
|
||||
viddef.conview->ylen = viddef.height;
|
||||
Con_CheckResize ();
|
||||
|
||||
viddef.vid_internal->init_buffers = x11_init_buffers;
|
||||
// XSynchronize (x_disp, False);
|
||||
// X11_AddEvent (x_shmeventtype, event_shm);
|
||||
|
|
Loading…
Reference in a new issue