mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 07:11:41 +00:00
[video] Get 16 and 32 bit sw32 mostly working in x11
Lighting on alias models seems to be borked, and skies are borked in both sw renderers (seems to be nothing to do with this commit, though).
This commit is contained in:
parent
34dd434147
commit
a05210d864
37 changed files with 371 additions and 131 deletions
|
@ -81,7 +81,8 @@ struct gl_ctx_s *X11_GL_Context (void);
|
|||
void X11_GL_Init_Cvars (void);
|
||||
|
||||
struct sw_ctx_s *X11_SW_Context (void);
|
||||
void X11_SW_Init_Cvars (void);
|
||||
struct sw_ctx_s *X11_SW32_Context (void);
|
||||
void X11_SW_Init_Cvars (void); // sw and sw32 cvars shared
|
||||
|
||||
struct vulkan_ctx_s *X11_Vulkan_Context (void);
|
||||
void X11_Vulkan_Init_Cvars (void);
|
||||
|
|
|
@ -158,7 +158,6 @@ extern qboolean r_recursiveaffinetriangles; // true if a driver wants to use
|
|||
// a certain distance (normally
|
||||
// used only by the software
|
||||
// driver)
|
||||
extern int r_pixbytes;
|
||||
extern qboolean r_dowarp;
|
||||
|
||||
extern affinetridesc_t r_affinetridesc;
|
||||
|
|
|
@ -94,10 +94,10 @@ void R_PushDlights (const vec3_t entorigin);
|
|||
void R_DrawWaterSurfaces (void);
|
||||
|
||||
void *D_SurfaceCacheAddress (void) __attribute__((pure));
|
||||
int D_SurfaceCacheForRes (int width, int height);
|
||||
void D_FlushCaches (void);
|
||||
int D_SurfaceCacheForRes (void *data, int width, int height);
|
||||
void D_FlushCaches (void *data);
|
||||
void D_DeleteSurfaceCache (void);
|
||||
void D_InitCaches (void *buffer, int size);
|
||||
void D_InitCaches (void *data, void *buffer, int size);
|
||||
void R_SetVrect (const vrect_t *pvrect, vrect_t *pvrectin, int lineadj);
|
||||
|
||||
void R_LoadSkys (const char *);
|
||||
|
@ -119,7 +119,7 @@ void R_DrawAliasModel (entity_t *e);
|
|||
|
||||
void R_MarkLeaves (void);
|
||||
|
||||
void GL_SetPalette (const byte *palette);
|
||||
void GLSL_SetPalette (const byte *palette);
|
||||
void GL_SetPalette (void *data, const byte *palette);
|
||||
void GLSL_SetPalette (void *data, const byte *palette);
|
||||
|
||||
#endif//__r_internal_h
|
||||
|
|
|
@ -5,17 +5,20 @@
|
|||
#include "QF/plugin/vid_render.h"
|
||||
|
||||
typedef struct vid_internal_s {
|
||||
int (*surf_cache_size) (int width, int height);
|
||||
void (*flush_caches) (void);
|
||||
void (*init_caches) (void *cache, int size);
|
||||
void (*init_buffers) (void);
|
||||
void (*set_palette) (const byte *palette);
|
||||
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);
|
||||
|
||||
void (*choose_visual) (void);
|
||||
void (*create_context) (void);
|
||||
void (*choose_visual) (void *data);
|
||||
void (*create_context) (void *data);
|
||||
|
||||
void *data;
|
||||
|
||||
struct gl_ctx_s *(*gl_context) (void);
|
||||
struct sw_ctx_s *(*sw_context) (void);
|
||||
struct sw_ctx_s *(*sw32_context) (void);
|
||||
struct vulkan_ctx_s *(*vulkan_context) (void);
|
||||
} vid_internal_t;
|
||||
|
||||
|
|
|
@ -3,10 +3,11 @@
|
|||
|
||||
struct vrect_s;
|
||||
typedef struct sw_ctx_s {
|
||||
int pixbytes;
|
||||
void (*choose_visual) (struct sw_ctx_s *ctx);
|
||||
void (*create_context) (struct sw_ctx_s *ctx);
|
||||
void (*set_palette) (const byte *palette);
|
||||
void (*update) (struct vrect_s *rects);
|
||||
void (*set_palette) (struct sw_ctx_s *ctx, const byte *palette);
|
||||
void (*update) (struct sw_ctx_s *ctx, struct vrect_s *rects);
|
||||
} sw_ctx_t;
|
||||
|
||||
extern sw_ctx_t *sw_ctx;
|
||||
|
|
|
@ -701,7 +701,7 @@ VID_Init8bitPalette (void)
|
|||
}
|
||||
|
||||
void
|
||||
GL_SetPalette (const byte *palette)
|
||||
GL_SetPalette (void *data, const byte *palette)
|
||||
{
|
||||
const byte *pal;
|
||||
char s[255];
|
||||
|
|
|
@ -69,7 +69,7 @@ GLSL_Common_Init_Cvars (void)
|
|||
}
|
||||
|
||||
void
|
||||
GLSL_SetPalette (const byte *palette)
|
||||
GLSL_SetPalette (void *data, const byte *palette)
|
||||
{
|
||||
const byte *col, *ip;
|
||||
byte *pal, *op;
|
||||
|
|
|
@ -54,7 +54,7 @@ D_SurfaceCacheAddress (void)
|
|||
}
|
||||
|
||||
int
|
||||
D_SurfaceCacheForRes (int width, int height)
|
||||
D_SurfaceCacheForRes (void *data, int width, int height)
|
||||
{
|
||||
int size, pix;
|
||||
|
||||
|
@ -96,7 +96,7 @@ D_ClearCacheGuard (void)
|
|||
}
|
||||
|
||||
void
|
||||
D_InitCaches (void *buffer, int size)
|
||||
D_InitCaches (void *data, void *buffer, int size)
|
||||
{
|
||||
Sys_MaskPrintf (SYS_dev, "D_InitCaches: %ik surface cache\n", size/1024);
|
||||
|
||||
|
@ -114,7 +114,7 @@ D_InitCaches (void *buffer, int size)
|
|||
}
|
||||
|
||||
void
|
||||
D_FlushCaches (void)
|
||||
D_FlushCaches (void *data)
|
||||
{
|
||||
surfcache_t *c;
|
||||
|
||||
|
|
|
@ -828,5 +828,5 @@ Draw_BlendScreen (quat_t color)
|
|||
newpal[2] = vid.gammatable[b];
|
||||
newpal += 3;
|
||||
}
|
||||
vid.vid_internal->set_palette (pal);
|
||||
vid.vid_internal->set_palette (vid.vid_internal->data, pal);
|
||||
}
|
||||
|
|
|
@ -240,5 +240,5 @@ R_RenderFrame (SCR_Func scr_3dfunc, SCR_Func *scr_funcs)
|
|||
vrect.height = vr_data.scr_view->ylen;
|
||||
vrect.next = 0;
|
||||
}
|
||||
sw_ctx->update (&vrect);
|
||||
sw_ctx->update (sw_ctx, &vrect);
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "d_local.h"
|
||||
#include "r_internal.h"
|
||||
#include "vid_internal.h"
|
||||
#include "vid_sw.h"
|
||||
|
||||
static int miplevel;
|
||||
|
||||
|
@ -81,7 +82,7 @@ D_DrawSolidSurface (surf_t *surf, int color)
|
|||
{
|
||||
espan_t *span;
|
||||
|
||||
switch(sw32_r_pixbytes) {
|
||||
switch(sw32_ctx->pixbytes) {
|
||||
case 1:
|
||||
{
|
||||
byte *pdest, pix;
|
||||
|
@ -132,7 +133,7 @@ D_DrawSolidSurface (surf_t *surf, int color)
|
|||
break;
|
||||
default:
|
||||
Sys_Error("D_DrawSolidSurface: unsupported r_pixbytes %i",
|
||||
sw32_r_pixbytes);
|
||||
sw32_ctx->pixbytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,12 +36,12 @@
|
|||
#include "d_iface.h"
|
||||
#include "r_internal.h"
|
||||
#include "vid_internal.h"
|
||||
|
||||
#include "vid_sw.h"
|
||||
|
||||
void
|
||||
sw32_D_FillRect (vrect_t *rect, int color)
|
||||
{
|
||||
switch (sw32_r_pixbytes)
|
||||
switch (sw32_ctx->pixbytes)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
|
@ -159,6 +159,6 @@ sw32_D_FillRect (vrect_t *rect, int color)
|
|||
}
|
||||
break;
|
||||
default:
|
||||
Sys_Error("D_FillRect: unsupported r_pixbytes %i", sw32_r_pixbytes);
|
||||
Sys_Error("D_FillRect: unsupported r_pixbytes %i", sw32_ctx->pixbytes);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "d_local.h"
|
||||
#include "r_internal.h"
|
||||
#include "vid_internal.h"
|
||||
#include "vid_sw.h"
|
||||
|
||||
#define NUM_MIPS 4
|
||||
|
||||
|
@ -105,7 +106,7 @@ sw32_D_SetupFrame (void)
|
|||
if (sw32_r_dowarp)
|
||||
sw32_screenwidth = WARP_WIDTH;
|
||||
else
|
||||
sw32_screenwidth = vid.rowbytes / sw32_r_pixbytes;
|
||||
sw32_screenwidth = vid.rowbytes / sw32_ctx->pixbytes;
|
||||
|
||||
sw32_d_roverwrapped = false;
|
||||
sw32_d_initial_rover = sw32_sc_rover;
|
||||
|
|
|
@ -35,6 +35,7 @@
|
|||
|
||||
#include "d_local.h"
|
||||
#include "r_internal.h"
|
||||
#include "vid_sw.h"
|
||||
|
||||
int sw32_d_vrectx, sw32_d_vrecty, sw32_d_vrectright_particle, sw32_d_vrectbottom_particle;
|
||||
|
||||
|
@ -57,7 +58,7 @@ sw32_D_ViewChanged (void)
|
|||
if (sw32_r_dowarp)
|
||||
rowpixels = WARP_WIDTH;
|
||||
else
|
||||
rowpixels = vid.rowbytes / sw32_r_pixbytes;
|
||||
rowpixels = vid.rowbytes / sw32_ctx->pixbytes;
|
||||
|
||||
sw32_scale_for_mip = sw32_xscale;
|
||||
if (sw32_yscale > sw32_xscale)
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "d_local.h"
|
||||
#include "r_internal.h"
|
||||
#include "vid_internal.h"
|
||||
#include "vid_sw.h"
|
||||
|
||||
|
||||
void
|
||||
|
@ -78,7 +79,7 @@ sw32_D_DrawParticle (particle_t *pparticle)
|
|||
else if (pix > sw32_d_pix_max)
|
||||
pix = sw32_d_pix_max;
|
||||
|
||||
switch(sw32_r_pixbytes)
|
||||
switch(sw32_ctx->pixbytes)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
|
@ -368,6 +369,6 @@ sw32_D_DrawParticle (particle_t *pparticle)
|
|||
break;
|
||||
default:
|
||||
Sys_Error("D_DrawParticles: unsupported r_pixbytes %i",
|
||||
sw32_r_pixbytes);
|
||||
sw32_ctx->pixbytes);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
|
||||
#include "d_local.h"
|
||||
#include "r_internal.h"
|
||||
#include "vid_sw.h"
|
||||
|
||||
static int ubasestep, errorterm, erroradjustup, erroradjustdown;
|
||||
|
||||
|
@ -383,7 +384,7 @@ D_PolysetDrawSpans (spanpackage_t * pspanpackage)
|
|||
texscantable[i] = j;
|
||||
texscan = texscantable + sw32_r_affinetridesc.skinheight;
|
||||
|
||||
switch(sw32_r_pixbytes) {
|
||||
switch(sw32_ctx->pixbytes) {
|
||||
case 1:
|
||||
{
|
||||
int lcount, count = 0;
|
||||
|
@ -622,7 +623,7 @@ done32: ;
|
|||
|
||||
default:
|
||||
Sys_Error("D_PolysetDrawSpans: unsupported r_pixbytes %i",
|
||||
sw32_r_pixbytes);
|
||||
sw32_ctx->pixbytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "d_local.h"
|
||||
#include "r_internal.h"
|
||||
#include "vid_internal.h"
|
||||
#include "vid_sw.h"
|
||||
|
||||
static byte *r_turb_pbase;
|
||||
static void *r_turb_pdest;
|
||||
|
@ -56,7 +57,7 @@ static int r_turb_spancount;
|
|||
void
|
||||
sw32_D_WarpScreen (void)
|
||||
{
|
||||
switch(sw32_r_pixbytes) {
|
||||
switch(sw32_ctx->pixbytes) {
|
||||
case 1:
|
||||
{
|
||||
int w, h;
|
||||
|
@ -205,7 +206,7 @@ sw32_D_WarpScreen (void)
|
|||
}
|
||||
break;
|
||||
default:
|
||||
Sys_Error("D_WarpScreen: unsupported r_pixbytes %i", sw32_r_pixbytes);
|
||||
Sys_Error("D_WarpScreen: unsupported r_pixbytes %i", sw32_ctx->pixbytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -214,7 +215,7 @@ D_DrawTurbulentSpan (void)
|
|||
{
|
||||
int sturb, tturb;
|
||||
|
||||
switch (sw32_r_pixbytes) {
|
||||
switch (sw32_ctx->pixbytes) {
|
||||
case 1:
|
||||
{
|
||||
byte *pdest = (byte *) r_turb_pdest;
|
||||
|
@ -262,7 +263,7 @@ D_DrawTurbulentSpan (void)
|
|||
break;
|
||||
default:
|
||||
Sys_Error("D_DrawTurbulentSpan: unsupported r_pixbytes %i",
|
||||
sw32_r_pixbytes);
|
||||
sw32_ctx->pixbytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -287,7 +288,7 @@ sw32_Turbulent (espan_t *pspan)
|
|||
|
||||
do {
|
||||
r_turb_pdest = (byte *) sw32_d_viewbuffer + ((sw32_screenwidth * pspan->v) +
|
||||
pspan->u) * sw32_r_pixbytes;
|
||||
pspan->u) * sw32_ctx->pixbytes;
|
||||
|
||||
count = pspan->count;
|
||||
|
||||
|
@ -394,7 +395,7 @@ sw32_Turbulent (espan_t *pspan)
|
|||
void
|
||||
sw32_D_DrawSpans (espan_t *pspan)
|
||||
{
|
||||
switch(sw32_r_pixbytes) {
|
||||
switch(sw32_ctx->pixbytes) {
|
||||
case 1:
|
||||
{
|
||||
byte *pbase = (byte *) sw32_cacheblock, *pdest;
|
||||
|
@ -812,7 +813,7 @@ sw32_D_DrawSpans (espan_t *pspan)
|
|||
}
|
||||
break;
|
||||
default:
|
||||
Sys_Error("D_DrawSpans: unsupported r_pixbytes %i", sw32_r_pixbytes);
|
||||
Sys_Error("D_DrawSpans: unsupported r_pixbytes %i", sw32_ctx->pixbytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
|
||||
#include "d_local.h"
|
||||
#include "r_internal.h"
|
||||
#include "vid_sw.h"
|
||||
|
||||
#define SKY_SPAN_SHIFT 5
|
||||
#define SKY_SPAN_MAX (1 << SKY_SPAN_SHIFT)
|
||||
|
@ -69,7 +70,7 @@ D_Sky_uv_To_st (int u, int v, fixed16_t *s, fixed16_t *t)
|
|||
void
|
||||
sw32_D_DrawSkyScans (espan_t *pspan)
|
||||
{
|
||||
switch(sw32_r_pixbytes) {
|
||||
switch(sw32_ctx->pixbytes) {
|
||||
case 1:
|
||||
{
|
||||
int count, spancount, u, v;
|
||||
|
@ -278,6 +279,6 @@ sw32_D_DrawSkyScans (espan_t *pspan)
|
|||
break;
|
||||
|
||||
default:
|
||||
Sys_Error("D_DrawSkyScans: unsupported r_pixbytes %i", sw32_r_pixbytes);
|
||||
Sys_Error("D_DrawSkyScans: unsupported r_pixbytes %i", sw32_ctx->pixbytes);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "d_local.h"
|
||||
#include "r_internal.h"
|
||||
#include "vid_internal.h"
|
||||
#include "vid_sw.h"
|
||||
|
||||
static int sprite_height;
|
||||
static int minindex, maxindex;
|
||||
|
@ -48,7 +49,7 @@ static sspan_t *sprite_spans;
|
|||
void
|
||||
sw32_D_SpriteDrawSpans (sspan_t *pspan)
|
||||
{
|
||||
switch(sw32_r_pixbytes) {
|
||||
switch(sw32_ctx->pixbytes) {
|
||||
case 1:
|
||||
{
|
||||
int count, spancount, izistep;
|
||||
|
@ -504,7 +505,7 @@ NextSpan4:
|
|||
|
||||
default:
|
||||
Sys_Error("D_SpriteDrawSpans: unsupported r_pixbytes %i",
|
||||
sw32_r_pixbytes);
|
||||
sw32_ctx->pixbytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "compat.h"
|
||||
#include "d_local.h"
|
||||
#include "r_internal.h"
|
||||
#include "vid_sw.h"
|
||||
|
||||
static float surfscale;
|
||||
|
||||
|
@ -58,7 +59,7 @@ sw32_D_SurfaceCacheAddress (void)
|
|||
|
||||
|
||||
int
|
||||
sw32_D_SurfaceCacheForRes (int width, int height)
|
||||
sw32_D_SurfaceCacheForRes (void *data, int width, int height)
|
||||
{
|
||||
int size, pix;
|
||||
|
||||
|
@ -73,7 +74,7 @@ sw32_D_SurfaceCacheForRes (int width, int height)
|
|||
if (pix > 64000)
|
||||
size += (pix - 64000) * 3;
|
||||
|
||||
size *= sw32_r_pixbytes;
|
||||
size *= sw32_ctx->pixbytes;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
@ -105,7 +106,7 @@ D_ClearCacheGuard (void)
|
|||
|
||||
|
||||
void
|
||||
sw32_D_InitCaches (void *buffer, int size)
|
||||
sw32_D_InitCaches (void *data, void *buffer, int size)
|
||||
{
|
||||
Sys_MaskPrintf (SYS_dev, "D_InitCaches: %ik surface cache\n", size/1024);
|
||||
|
||||
|
@ -124,7 +125,7 @@ sw32_D_InitCaches (void *buffer, int size)
|
|||
|
||||
|
||||
void
|
||||
sw32_D_FlushCaches (void)
|
||||
sw32_D_FlushCaches (void *data)
|
||||
{
|
||||
surfcache_t *c;
|
||||
|
||||
|
@ -152,7 +153,7 @@ D_SCAlloc (int width, int size)
|
|||
if ((width < 0) || (width > 512)) // FIXME shouldn't really have a max
|
||||
Sys_Error ("D_SCAlloc: bad cache width %d", width);
|
||||
|
||||
if ((size <= 0) || (size > (0x40000 * sw32_r_pixbytes))) //FIXME ditto
|
||||
if ((size <= 0) || (size > (0x40000 * sw32_ctx->pixbytes))) //FIXME ditto
|
||||
Sys_Error ("D_SCAlloc: bad cache size %d", size);
|
||||
|
||||
/* This adds the offset of data[0] in the surfcache_t struct. */
|
||||
|
@ -207,7 +208,7 @@ D_SCAlloc (int width, int size)
|
|||
// DEBUG
|
||||
if (width > 0)
|
||||
new->height = (size - sizeof (*new) + sizeof (new->data)) /
|
||||
(width * sw32_r_pixbytes);
|
||||
(width * sw32_ctx->pixbytes);
|
||||
|
||||
new->owner = NULL; // should be set properly after return
|
||||
|
||||
|
@ -250,7 +251,7 @@ sw32_D_CacheSurface (msurface_t *surface, int miplevel)
|
|||
surfscale = 1.0 / (1 << miplevel);
|
||||
sw32_r_drawsurf.surfmip = miplevel;
|
||||
sw32_r_drawsurf.surfwidth = surface->extents[0] >> miplevel;
|
||||
sw32_r_drawsurf.rowbytes = sw32_r_drawsurf.surfwidth * sw32_r_pixbytes;
|
||||
sw32_r_drawsurf.rowbytes = sw32_r_drawsurf.surfwidth * sw32_ctx->pixbytes;
|
||||
sw32_r_drawsurf.surfheight = surface->extents[1] >> miplevel;
|
||||
|
||||
// allocate memory if needed
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "d_local.h"
|
||||
#include "r_internal.h"
|
||||
#include "vid_internal.h"
|
||||
#include "vid_sw.h"
|
||||
|
||||
|
||||
void
|
||||
|
@ -49,7 +50,7 @@ sw32_D_DrawZPoint (void)
|
|||
|
||||
if (*pz <= izi) {
|
||||
*pz = izi;
|
||||
switch(sw32_r_pixbytes)
|
||||
switch(sw32_ctx->pixbytes)
|
||||
{
|
||||
case 1:
|
||||
((byte *) sw32_d_viewbuffer) [sw32_d_scantable[sw32_r_zpointdesc.v] +
|
||||
|
@ -66,7 +67,7 @@ sw32_D_DrawZPoint (void)
|
|||
d_8to24table[sw32_r_zpointdesc.color];
|
||||
break;
|
||||
default:
|
||||
Sys_Error("D_DrawZPoint: unsupported r_pixbytes %i", sw32_r_pixbytes);
|
||||
Sys_Error("D_DrawZPoint: unsupported r_pixbytes %i", sw32_ctx->pixbytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
#include "d_iface.h"
|
||||
#include "r_internal.h"
|
||||
#include "vid_internal.h"
|
||||
#include "vid_sw.h"
|
||||
|
||||
typedef struct {
|
||||
vrect_t rect;
|
||||
|
@ -283,7 +284,7 @@ sw32_Draw_Character (int x, int y, unsigned int chr)
|
|||
drawline = 8;
|
||||
|
||||
|
||||
switch(sw32_r_pixbytes) {
|
||||
switch(sw32_ctx->pixbytes) {
|
||||
case 1:
|
||||
{
|
||||
byte *dest = (byte *) vid.conbuffer + y * vid.conrowbytes + x;
|
||||
|
@ -367,7 +368,7 @@ sw32_Draw_Character (int x, int y, unsigned int chr)
|
|||
}
|
||||
break;
|
||||
default:
|
||||
Sys_Error("Draw_Character: unsupported r_pixbytes %i", sw32_r_pixbytes);
|
||||
Sys_Error("Draw_Character: unsupported r_pixbytes %i", sw32_ctx->pixbytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -403,7 +404,7 @@ sw32_Draw_AltString (int x, int y, const char *str)
|
|||
static void
|
||||
Draw_Pixel (int x, int y, byte color)
|
||||
{
|
||||
switch(sw32_r_pixbytes)
|
||||
switch(sw32_ctx->pixbytes)
|
||||
{
|
||||
case 1:
|
||||
((byte *) vid.conbuffer)[y * vid.conrowbytes + x] = color;
|
||||
|
@ -417,7 +418,7 @@ Draw_Pixel (int x, int y, byte color)
|
|||
d_8to24table[color];
|
||||
break;
|
||||
default:
|
||||
Sys_Error("Draw_Pixel: unsupported r_pixbytes %i", sw32_r_pixbytes);
|
||||
Sys_Error("Draw_Pixel: unsupported r_pixbytes %i", sw32_ctx->pixbytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -570,7 +571,7 @@ sw32_Draw_Pic (int x, int y, qpic_t *pic)
|
|||
|
||||
source = pic->data;
|
||||
|
||||
switch(sw32_r_pixbytes) {
|
||||
switch(sw32_ctx->pixbytes) {
|
||||
case 1:
|
||||
{
|
||||
byte *dest = (byte *) vid.buffer + y * vid.rowbytes + x;
|
||||
|
@ -643,7 +644,7 @@ sw32_Draw_Pic (int x, int y, qpic_t *pic)
|
|||
}
|
||||
break;
|
||||
default:
|
||||
Sys_Error("Draw_Pic: unsupported r_pixbytes %i", sw32_r_pixbytes);
|
||||
Sys_Error("Draw_Pic: unsupported r_pixbytes %i", sw32_ctx->pixbytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -688,7 +689,7 @@ sw32_Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width,
|
|||
|
||||
source = pic->data + srcy * pic->width + srcx;
|
||||
|
||||
switch (sw32_r_pixbytes) {
|
||||
switch (sw32_ctx->pixbytes) {
|
||||
case 1:
|
||||
{
|
||||
byte *dest = (byte *) vid.buffer + y * vid.rowbytes + x;
|
||||
|
@ -725,7 +726,7 @@ sw32_Draw_SubPic (int x, int y, qpic_t *pic, int srcx, int srcy, int width,
|
|||
}
|
||||
break;
|
||||
default:
|
||||
Sys_Error("Draw_SubPic: unsupported r_pixbytes %i", sw32_r_pixbytes);
|
||||
Sys_Error("Draw_SubPic: unsupported r_pixbytes %i", sw32_ctx->pixbytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -741,7 +742,7 @@ sw32_Draw_ConsoleBackground (int lines, byte alpha)
|
|||
conback = sw32_Draw_CachePic ("gfx/conback.lmp", true);
|
||||
|
||||
// draw the pic
|
||||
switch(sw32_r_pixbytes) {
|
||||
switch(sw32_ctx->pixbytes) {
|
||||
case 1:
|
||||
{
|
||||
byte *dest = vid.conbuffer;
|
||||
|
@ -812,7 +813,7 @@ sw32_Draw_ConsoleBackground (int lines, byte alpha)
|
|||
|
||||
default:
|
||||
Sys_Error("Draw_ConsoleBackground: unsupported r_pixbytes %i",
|
||||
sw32_r_pixbytes);
|
||||
sw32_ctx->pixbytes);
|
||||
}
|
||||
|
||||
// if (!cls.download)
|
||||
|
@ -824,7 +825,7 @@ sw32_Draw_ConsoleBackground (int lines, byte alpha)
|
|||
static void
|
||||
R_DrawRect (vrect_t *prect, int rowbytes, byte * psrc, int transparent)
|
||||
{
|
||||
switch(sw32_r_pixbytes) {
|
||||
switch(sw32_ctx->pixbytes) {
|
||||
case 1:
|
||||
{
|
||||
byte t;
|
||||
|
@ -1097,7 +1098,7 @@ R_DrawRect (vrect_t *prect, int rowbytes, byte * psrc, int transparent)
|
|||
}
|
||||
break;
|
||||
default:
|
||||
Sys_Error("R_DrawRect: unsupported r_pixbytes %i", sw32_r_pixbytes);
|
||||
Sys_Error("R_DrawRect: unsupported r_pixbytes %i", sw32_ctx->pixbytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1183,7 +1184,7 @@ sw32_Draw_Fill (int x, int y, int w, int h, int c)
|
|||
}
|
||||
CLIP (x, y, w, h, (int) vid.width, (int) vid.height);
|
||||
|
||||
switch (sw32_r_pixbytes) {
|
||||
switch (sw32_ctx->pixbytes) {
|
||||
case 1:
|
||||
{
|
||||
byte *dest = (byte *) vid.buffer + y * vid.rowbytes + x;
|
||||
|
@ -1213,7 +1214,7 @@ sw32_Draw_Fill (int x, int y, int w, int h, int c)
|
|||
}
|
||||
break;
|
||||
default:
|
||||
Sys_Error("Draw_Fill: unsupported r_pixbytes %i", sw32_r_pixbytes);
|
||||
Sys_Error("Draw_Fill: unsupported r_pixbytes %i", sw32_ctx->pixbytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1227,7 +1228,7 @@ sw32_Draw_FadeScreen (void)
|
|||
S_ExtraUpdate ();
|
||||
VID_LockBuffer ();
|
||||
|
||||
switch(sw32_r_pixbytes) {
|
||||
switch(sw32_ctx->pixbytes) {
|
||||
case 1:
|
||||
{
|
||||
for (y = 0; y < vid.conview->ylen; y++) {
|
||||
|
@ -1264,7 +1265,7 @@ sw32_Draw_FadeScreen (void)
|
|||
}
|
||||
break;
|
||||
default:
|
||||
Sys_Error("Draw_FadeScreen: unsupported r_pixbytes %i", sw32_r_pixbytes);
|
||||
Sys_Error("Draw_FadeScreen: unsupported r_pixbytes %i", sw32_ctx->pixbytes);
|
||||
}
|
||||
vr_data.scr_copyeverything = 1;
|
||||
|
||||
|
@ -1281,7 +1282,7 @@ sw32_Draw_BlendScreen (quat_t color)
|
|||
byte *newpal;
|
||||
byte pal[768];
|
||||
|
||||
switch(sw32_r_pixbytes) {
|
||||
switch(sw32_ctx->pixbytes) {
|
||||
case 1:
|
||||
{
|
||||
basepal = vid.basepal;
|
||||
|
@ -1302,7 +1303,7 @@ sw32_Draw_BlendScreen (quat_t color)
|
|||
newpal[2] = vid.gammatable[b];
|
||||
newpal += 3;
|
||||
}
|
||||
vid.vid_internal->set_palette (pal);
|
||||
vid.vid_internal->set_palette (vid.vid_internal->data, pal);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
|
@ -1367,6 +1368,6 @@ sw32_Draw_BlendScreen (quat_t color)
|
|||
break;
|
||||
default:
|
||||
Sys_Error("sw32_Draw_BlendScreen: unsupported r_pixbytes %i",
|
||||
sw32_r_pixbytes);
|
||||
sw32_ctx->pixbytes);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ sw32_SCR_ScreenShot_f (void)
|
|||
sw32_D_EnableBackBufferAccess ();
|
||||
|
||||
// save the pcx file
|
||||
switch(sw32_r_pixbytes) {
|
||||
switch(sw32_ctx->pixbytes) {
|
||||
case 1:
|
||||
pcx = EncodePCX (vid.buffer, vid.width, vid.height, vid.rowbytes,
|
||||
vid.basepal, false, &pcx_len);
|
||||
|
@ -124,7 +124,7 @@ sw32_SCR_ScreenShot_f (void)
|
|||
Sys_Printf("SCR_ScreenShot_f: FIXME - add 32bit support\n");
|
||||
break;
|
||||
default:
|
||||
Sys_Error("SCR_ScreenShot_f: unsupported r_pixbytes %i", sw32_r_pixbytes);
|
||||
Sys_Error("SCR_ScreenShot_f: unsupported r_pixbytes %i", sw32_ctx->pixbytes);
|
||||
}
|
||||
|
||||
// for adapters that can't stay mapped in for linear writes all the time
|
||||
|
@ -197,5 +197,5 @@ sw32_R_RenderFrame (SCR_Func scr_3dfunc, SCR_Func *scr_funcs)
|
|||
vrect.height = vr_data.scr_view->ylen;
|
||||
vrect.next = 0;
|
||||
}
|
||||
sw32_ctx->update (&vrect);
|
||||
sw32_ctx->update (sw32_ctx, &vrect);
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
|
||||
#include "r_internal.h"
|
||||
#include "vid_internal.h"
|
||||
#include "vid_sw.h"
|
||||
|
||||
/*
|
||||
R_LineGraph
|
||||
|
@ -67,7 +68,7 @@ sw32_R_LineGraph (int x, int y, int *h_vals, int count)
|
|||
if (h > s)
|
||||
h = s;
|
||||
|
||||
switch(sw32_r_pixbytes) {
|
||||
switch(sw32_ctx->pixbytes) {
|
||||
case 1:
|
||||
{
|
||||
byte *dest = (byte *) vid.buffer + vid.rowbytes * y + x;
|
||||
|
@ -95,7 +96,7 @@ sw32_R_LineGraph (int x, int y, int *h_vals, int count)
|
|||
break;
|
||||
default:
|
||||
Sys_Error("R_LineGraph: unsupported r_pixbytes %i",
|
||||
sw32_r_pixbytes);
|
||||
sw32_ctx->pixbytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define NH_DEFINE
|
||||
#include "namehack.h"
|
||||
|
||||
|
@ -39,8 +41,7 @@
|
|||
|
||||
#include "d_ifacea.h"
|
||||
#include "r_internal.h"
|
||||
|
||||
#include "stdlib.h"
|
||||
#include "vid_sw.h"
|
||||
|
||||
#define LIGHT_MIN 5 // lowest light value we'll allow, to
|
||||
// avoid the need for inner-loop light
|
||||
|
@ -650,15 +651,15 @@ sw32_R_AliasDrawModel (alight_t *plighting)
|
|||
|
||||
if (!sw32_acolormap)
|
||||
sw32_acolormap = vid.colormap8;
|
||||
if (sw32_acolormap == &vid.colormap8 && sw32_r_pixbytes != 1)
|
||||
if (sw32_acolormap == &vid.colormap8 && sw32_ctx->pixbytes != 1)
|
||||
{
|
||||
if (sw32_r_pixbytes == 2)
|
||||
if (sw32_ctx->pixbytes == 2)
|
||||
sw32_acolormap = vid.colormap16;
|
||||
else if (sw32_r_pixbytes == 4)
|
||||
else if (sw32_ctx->pixbytes == 4)
|
||||
sw32_acolormap = vid.colormap32;
|
||||
else
|
||||
Sys_Error("R_AliasDrawmodel: unsupported r_pixbytes %i",
|
||||
sw32_r_pixbytes);
|
||||
sw32_ctx->pixbytes);
|
||||
}
|
||||
|
||||
if (currententity != vr_data.view_model)
|
||||
|
|
|
@ -62,7 +62,6 @@ int sw32_r_numallocatededges;
|
|||
qboolean sw32_r_drawpolys;
|
||||
qboolean sw32_r_drawculledpolys;
|
||||
qboolean sw32_r_worldpolysbacktofront;
|
||||
int sw32_r_pixbytes = 1;
|
||||
float sw32_r_aliasuvscale = 1.0;
|
||||
int sw32_r_outofsurfaces;
|
||||
int sw32_r_outofedges;
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
|
||||
#include "r_internal.h"
|
||||
#include "vid_internal.h"
|
||||
#include "vid_sw.h"
|
||||
|
||||
|
||||
static int iskyspeed = 8;
|
||||
|
@ -128,7 +129,7 @@ sw32_R_MakeSky (void)
|
|||
xshift1 = xshift2 >> 1;
|
||||
yshift1 = yshift2 >> 1;
|
||||
|
||||
switch(sw32_r_pixbytes)
|
||||
switch(sw32_ctx->pixbytes)
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
|
@ -188,7 +189,7 @@ sw32_R_MakeSky (void)
|
|||
}
|
||||
break;
|
||||
default:
|
||||
Sys_Error("R_MakeSky: unsupported r_pixbytes %i", sw32_r_pixbytes);
|
||||
Sys_Error("R_MakeSky: unsupported r_pixbytes %i", sw32_ctx->pixbytes);
|
||||
}
|
||||
sw32_r_skymade = 1;
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
#include "compat.h"
|
||||
#include "r_internal.h"
|
||||
#include "vid_sw.h"
|
||||
|
||||
drawsurf_t sw32_r_drawsurf;
|
||||
|
||||
|
@ -203,7 +204,7 @@ R_BuildLightMap (void)
|
|||
* JohnnyonFlame:
|
||||
* 32 and 16bpp modes uses the positive lighting, unlike 8bpp
|
||||
*/
|
||||
switch (sw32_r_pixbytes) {
|
||||
switch (sw32_ctx->pixbytes) {
|
||||
case 1:
|
||||
// bound, invert, and shift
|
||||
for (i = 0; i < size; i++) {
|
||||
|
@ -272,7 +273,7 @@ sw32_R_DrawSurface (void)
|
|||
soffset = sw32_r_drawsurf.surf->texturemins[0];
|
||||
basetoffset = sw32_r_drawsurf.surf->texturemins[1];
|
||||
|
||||
switch (sw32_r_pixbytes) {
|
||||
switch (sw32_ctx->pixbytes) {
|
||||
case 1:
|
||||
pblockdrawer = surfmiptable8[sw32_r_drawsurf.surfmip];
|
||||
break;
|
||||
|
@ -283,11 +284,11 @@ sw32_R_DrawSurface (void)
|
|||
pblockdrawer = surfmiptable32[sw32_r_drawsurf.surfmip];
|
||||
break;
|
||||
default:
|
||||
Sys_Error("R_DrawSurface: unsupported r_pixbytes %i", sw32_r_pixbytes);
|
||||
Sys_Error("R_DrawSurface: unsupported r_pixbytes %i", sw32_ctx->pixbytes);
|
||||
pblockdrawer = NULL;
|
||||
}
|
||||
|
||||
horzblockstep = blocksize * sw32_r_pixbytes;
|
||||
horzblockstep = blocksize * sw32_ctx->pixbytes;
|
||||
|
||||
r_sourcemax = r_source + (tmax * smax);
|
||||
|
||||
|
|
|
@ -46,13 +46,13 @@
|
|||
gl_ctx_t *gl_ctx;
|
||||
|
||||
static void
|
||||
gl_vid_render_choose_visual (void)
|
||||
gl_vid_render_choose_visual (void *data)
|
||||
{
|
||||
gl_ctx->choose_visual (gl_ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
gl_vid_render_create_context (void)
|
||||
gl_vid_render_create_context (void *data)
|
||||
{
|
||||
gl_ctx->create_context (gl_ctx);
|
||||
}
|
||||
|
@ -93,6 +93,7 @@ gl_vid_render_init (void)
|
|||
gl_ctx->init_gl = GL_Init_Common;
|
||||
gl_ctx->load_gl ();
|
||||
|
||||
vr_data.vid->vid_internal->data = gl_ctx;
|
||||
vr_data.vid->vid_internal->set_palette = GL_SetPalette;
|
||||
vr_data.vid->vid_internal->choose_visual = gl_vid_render_choose_visual;
|
||||
vr_data.vid->vid_internal->create_context = gl_vid_render_create_context;
|
||||
|
|
|
@ -46,13 +46,13 @@
|
|||
gl_ctx_t *glsl_ctx;
|
||||
|
||||
static void
|
||||
glsl_vid_render_choose_visual (void)
|
||||
glsl_vid_render_choose_visual (void *data)
|
||||
{
|
||||
glsl_ctx->choose_visual (glsl_ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
glsl_vid_render_create_context (void)
|
||||
glsl_vid_render_create_context (void *data)
|
||||
{
|
||||
glsl_ctx->create_context (glsl_ctx);
|
||||
}
|
||||
|
@ -93,6 +93,7 @@ glsl_vid_render_init (void)
|
|||
glsl_ctx->init_gl = GLSL_Init_Common;
|
||||
glsl_ctx->load_gl ();
|
||||
|
||||
vr_data.vid->vid_internal->data = glsl_ctx;
|
||||
vr_data.vid->vid_internal->set_palette = GLSL_SetPalette;
|
||||
vr_data.vid->vid_internal->choose_visual = glsl_vid_render_choose_visual;
|
||||
vr_data.vid->vid_internal->create_context = glsl_vid_render_create_context;
|
||||
|
|
|
@ -39,17 +39,23 @@
|
|||
sw_ctx_t *sw_ctx;
|
||||
|
||||
static void
|
||||
sw_vid_render_choose_visual (void)
|
||||
sw_vid_render_choose_visual (void *data)
|
||||
{
|
||||
sw_ctx->choose_visual (sw_ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
sw_vid_render_create_context (void)
|
||||
sw_vid_render_create_context (void *data)
|
||||
{
|
||||
sw_ctx->create_context (sw_ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
sw_vid_render_set_palette (void *data, const byte *palette)
|
||||
{
|
||||
sw_ctx->set_palette (sw_ctx, palette);
|
||||
}
|
||||
|
||||
static vid_model_funcs_t model_funcs = {
|
||||
0,
|
||||
sw_Mod_LoadLighting,
|
||||
|
@ -84,7 +90,8 @@ sw_vid_render_init (void)
|
|||
}
|
||||
sw_ctx = vr_data.vid->vid_internal->sw_context ();
|
||||
|
||||
vr_data.vid->vid_internal->set_palette = sw_ctx->set_palette;
|
||||
vr_data.vid->vid_internal->data = sw_ctx;
|
||||
vr_data.vid->vid_internal->set_palette = sw_vid_render_set_palette;
|
||||
vr_data.vid->vid_internal->choose_visual = sw_vid_render_choose_visual;
|
||||
vr_data.vid->vid_internal->create_context = sw_vid_render_create_context;
|
||||
|
||||
|
|
|
@ -44,17 +44,23 @@
|
|||
sw_ctx_t *sw32_ctx;
|
||||
|
||||
static void
|
||||
sw32_vid_render_choose_visual (void)
|
||||
sw32_vid_render_choose_visual (void *data)
|
||||
{
|
||||
sw32_ctx->choose_visual (sw32_ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
sw32_vid_render_create_context (void)
|
||||
sw32_vid_render_create_context (void *data)
|
||||
{
|
||||
sw32_ctx->create_context (sw32_ctx);
|
||||
}
|
||||
|
||||
static void
|
||||
sw32_vid_render_set_palette (void *data, const byte *palette)
|
||||
{
|
||||
sw32_ctx->set_palette (sw32_ctx, palette);
|
||||
}
|
||||
|
||||
static vid_model_funcs_t model_funcs = {
|
||||
0,
|
||||
sw_Mod_LoadLighting,
|
||||
|
@ -87,9 +93,10 @@ sw32_vid_render_init (void)
|
|||
if (!vr_data.vid->vid_internal->sw_context) {
|
||||
Sys_Error ("Sorry, software rendering not supported by this program.");
|
||||
}
|
||||
sw32_ctx = vr_data.vid->vid_internal->sw_context ();
|
||||
sw32_ctx = vr_data.vid->vid_internal->sw32_context ();
|
||||
|
||||
vr_data.vid->vid_internal->set_palette = sw32_ctx->set_palette;
|
||||
vr_data.vid->vid_internal->data = sw32_ctx;
|
||||
vr_data.vid->vid_internal->set_palette = sw32_vid_render_set_palette;
|
||||
vr_data.vid->vid_internal->choose_visual = sw32_vid_render_choose_visual;
|
||||
vr_data.vid->vid_internal->create_context = sw32_vid_render_create_context;
|
||||
|
||||
|
|
|
@ -519,7 +519,7 @@ vulkan_Skin_InitTranslations (void)
|
|||
}
|
||||
|
||||
static void
|
||||
set_palette (const byte *palette)
|
||||
set_palette (void *data, const byte *palette)
|
||||
{
|
||||
//FIXME really don't want this here: need an application domain
|
||||
//so Quake can be separated from QuakeForge (ie, Quake itself becomes
|
||||
|
@ -527,7 +527,7 @@ set_palette (const byte *palette)
|
|||
}
|
||||
|
||||
static void
|
||||
vulkan_vid_render_choose_visual (void)
|
||||
vulkan_vid_render_choose_visual (void *data)
|
||||
{
|
||||
Vulkan_CreateDevice (vulkan_ctx);
|
||||
vulkan_ctx->choose_visual (vulkan_ctx);
|
||||
|
@ -546,7 +546,7 @@ vulkan_vid_render_choose_visual (void)
|
|||
}
|
||||
|
||||
static void
|
||||
vulkan_vid_render_create_context (void)
|
||||
vulkan_vid_render_create_context (void *data)
|
||||
{
|
||||
vulkan_ctx->create_window (vulkan_ctx);
|
||||
vulkan_ctx->surface = vulkan_ctx->create_surface (vulkan_ctx);
|
||||
|
@ -591,6 +591,7 @@ vulkan_vid_render_init (void)
|
|||
|
||||
Vulkan_Init_Common (vulkan_ctx);
|
||||
|
||||
vr_data.vid->vid_internal->data = vulkan_ctx;
|
||||
vr_data.vid->vid_internal->set_palette = set_palette;
|
||||
vr_data.vid->vid_internal->choose_visual = vulkan_vid_render_choose_visual;
|
||||
vr_data.vid->vid_internal->create_context = vulkan_vid_render_create_context;
|
||||
|
|
|
@ -21,8 +21,6 @@
|
|||
#include "context_sdl.h"
|
||||
#include "vid_internal.h"
|
||||
|
||||
cvar_t *vid_bitdepth;
|
||||
|
||||
void
|
||||
VID_SDL_GammaCheck (void)
|
||||
{
|
||||
|
@ -73,7 +71,4 @@ SDL_Init_Cvars (void)
|
|||
"Toggles fullscreen mode");
|
||||
vid_system_gamma = Cvar_Get ("vid_system_gamma", "1", CVAR_ARCHIVE, NULL,
|
||||
"Use system gamma control if available");
|
||||
// FIXME: vid_colorbpp in common GL setup, make consistent with sdl32 scheme
|
||||
vid_bitdepth = Cvar_Get ("vid_bitdepth", "8", CVAR_ROM, NULL, "Sets "
|
||||
"display bitdepth (supported modes: 8 16 32)");
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
|
||||
/* Software and hardware gamma support */
|
||||
#define viddef (*r_data->vid)
|
||||
#define vi (viddef.vid_internal)
|
||||
cvar_t *vid_gamma;
|
||||
cvar_t *vid_system_gamma;
|
||||
cvar_t *con_width; // FIXME: Try to move with rest of con code
|
||||
|
@ -211,7 +212,8 @@ VID_UpdateGamma (cvar_t *vid_gamma)
|
|||
*p32++ = 255;
|
||||
}
|
||||
p32[-1] = 0; // color 255 is transparent
|
||||
viddef.vid_internal->set_palette (viddef.palette); // update with the new palette
|
||||
// update with the new palette
|
||||
vi->set_palette (vi->data, viddef.palette);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,9 +256,10 @@ VID_InitBuffers (void)
|
|||
// Calculate the sizes we want first
|
||||
buffersize = viddef.rowbytes * viddef.height;
|
||||
zbuffersize = viddef.width * viddef.height * sizeof (*viddef.zbuffer);
|
||||
if (viddef.vid_internal->surf_cache_size)
|
||||
cachesize = viddef.vid_internal->surf_cache_size (viddef.width,
|
||||
viddef.height);
|
||||
if (vi->surf_cache_size) {
|
||||
cachesize = vi->surf_cache_size (vi->data,
|
||||
viddef.width, viddef.height);
|
||||
}
|
||||
|
||||
// Free the old z-buffer
|
||||
if (viddef.zbuffer) {
|
||||
|
@ -265,13 +268,14 @@ VID_InitBuffers (void)
|
|||
}
|
||||
// Free the old surface cache
|
||||
if (viddef.surfcache) {
|
||||
if (viddef.vid_internal->flush_caches)
|
||||
viddef.vid_internal->flush_caches ();
|
||||
if (vi->flush_caches) {
|
||||
vi->flush_caches (vi->data);
|
||||
}
|
||||
free (viddef.surfcache);
|
||||
viddef.surfcache = NULL;
|
||||
}
|
||||
if (viddef.vid_internal->init_buffers) {
|
||||
viddef.vid_internal->init_buffers ();
|
||||
if (vi->init_buffers) {
|
||||
vi->init_buffers (vi->data);
|
||||
} else {
|
||||
// Free the old screen buffer
|
||||
if (viddef.buffer) {
|
||||
|
@ -301,13 +305,15 @@ VID_InitBuffers (void)
|
|||
Sys_Error ("Not enough memory for video mode");
|
||||
}
|
||||
|
||||
if (viddef.vid_internal->init_caches)
|
||||
viddef.vid_internal->init_caches (viddef.surfcache, cachesize);
|
||||
if (vi->init_caches) {
|
||||
vi->init_caches (vi->data, viddef.surfcache, cachesize);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
VID_ClearMemory (void)
|
||||
{
|
||||
if (viddef.vid_internal->flush_caches)
|
||||
viddef.vid_internal->flush_caches ();
|
||||
if (vi->flush_caches) {
|
||||
vi->flush_caches (vi->data);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,6 +102,7 @@ VID_Init (byte *palette, byte *colormap)
|
|||
|
||||
vid_internal.gl_context = X11_GL_Context;
|
||||
vid_internal.sw_context = X11_SW_Context;
|
||||
vid_internal.sw32_context = X11_SW32_Context;
|
||||
#ifdef HAVE_VULKAN
|
||||
vid_internal.vulkan_context = X11_Vulkan_Context;
|
||||
#endif
|
||||
|
@ -116,14 +117,14 @@ VID_Init (byte *palette, byte *colormap)
|
|||
|
||||
VID_GetWindowSize (640, 480);
|
||||
X11_OpenDisplay ();
|
||||
vid_internal.choose_visual ();
|
||||
vid_internal.choose_visual (vid_internal.data);
|
||||
X11_SetVidMode (viddef.width, viddef.height);
|
||||
X11_CreateWindow (viddef.width, viddef.height);
|
||||
X11_CreateNullCursor (); // hide mouse pointer
|
||||
vid_internal.create_context ();
|
||||
vid_internal.create_context (vid_internal.data);
|
||||
|
||||
VID_InitGamma (palette);
|
||||
viddef.vid_internal->set_palette (viddef.palette);
|
||||
vid_internal.set_palette (vid_internal.data, viddef.palette);
|
||||
|
||||
Sys_MaskPrintf (SYS_vid, "Video mode %dx%d initialized.\n",
|
||||
viddef.width, viddef.height);
|
||||
|
@ -140,6 +141,7 @@ VID_Init_Cvars ()
|
|||
X11_Vulkan_Init_Cvars ();
|
||||
#endif
|
||||
X11_GL_Init_Cvars ();
|
||||
X11_SW_Init_Cvars ();
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
|
|
@ -69,6 +69,8 @@ int XShmGetEventBase (Display *x); // for broken X11 headers
|
|||
|
||||
static GC x_gc;
|
||||
|
||||
static cvar_t *vid_bitdepth;
|
||||
|
||||
static qboolean doShm;
|
||||
static XShmSegmentInfo x_shminfo[2];
|
||||
|
||||
|
@ -188,7 +190,7 @@ xlib_rgb24 (int r, int g, int b)
|
|||
}
|
||||
|
||||
static void
|
||||
x11_set_palette (const byte *palette)
|
||||
x11_set_palette (sw_ctx_t *ctx, const byte *palette)
|
||||
{
|
||||
int i;
|
||||
XColor colors[256];
|
||||
|
@ -280,7 +282,7 @@ st3_fixup (XImage * framebuf, int x, int y, int width, int height)
|
|||
Flush the given rectangles from the view buffer to the screen.
|
||||
*/
|
||||
static void
|
||||
x11_sw_update (vrect_t *rects)
|
||||
x11_sw8_update (sw_ctx_t *ctx, vrect_t *rects)
|
||||
{
|
||||
while (rects) {
|
||||
switch (x_visinfo->depth) {
|
||||
|
@ -319,6 +321,148 @@ x11_sw_update (vrect_t *rects)
|
|||
r_data->scr_fullupdate = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
x11_sw16_16_update (sw_ctx_t *ctx, vrect_t *rects)
|
||||
{
|
||||
uint16_t *buffer = (uint16_t *) viddef.buffer;
|
||||
XImage *framebuf = x_framebuffer[current_framebuffer];
|
||||
int rowbytes = framebuf->bytes_per_line;
|
||||
|
||||
while (rects) {
|
||||
int x = rects->x;
|
||||
int y = rects->y;
|
||||
int width = rects->width;
|
||||
int height = rects->height;
|
||||
for (int yi = y; yi < (y + height); yi++) {
|
||||
uint16_t *src = buffer + yi * viddef.width + x;
|
||||
PIXEL16 *dest = (PIXEL16 *) (framebuf->data + yi * rowbytes) + x;
|
||||
|
||||
for (int count = width; count-- > 0; ) {
|
||||
*dest++ = *src++;
|
||||
}
|
||||
}
|
||||
if (doShm) {
|
||||
if (!XShmPutImage (x_disp, x_win, x_gc,
|
||||
x_framebuffer[current_framebuffer],
|
||||
rects->x, rects->y, rects->x, rects->y,
|
||||
rects->width, rects->height, True)) {
|
||||
Sys_Error ("VID_Update: XShmPutImage failed");
|
||||
}
|
||||
oktodraw = false;
|
||||
while (!oktodraw)
|
||||
X11_ProcessEvent ();
|
||||
rects = rects->next;
|
||||
|
||||
current_framebuffer = !current_framebuffer;
|
||||
} else {
|
||||
if (XPutImage (x_disp, x_win, x_gc, x_framebuffer[0],
|
||||
rects->x, rects->y, rects->x, rects->y,
|
||||
rects->width, rects->height)) {
|
||||
Sys_Error ("VID_Update: XPutImage failed");
|
||||
}
|
||||
rects = rects->next;
|
||||
}
|
||||
}
|
||||
XSync (x_disp, False);
|
||||
r_data->scr_fullupdate = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
x11_sw16_32_update (sw_ctx_t *ctx, vrect_t *rects)
|
||||
{
|
||||
uint16_t *buffer = (uint16_t *) viddef.buffer;
|
||||
XImage *framebuf = x_framebuffer[current_framebuffer];
|
||||
int rowbytes = framebuf->bytes_per_line;
|
||||
|
||||
while (rects) {
|
||||
int x = rects->x;
|
||||
int y = rects->y;
|
||||
int width = rects->width;
|
||||
int height = rects->height;
|
||||
for (int yi = y; yi < (y + height); yi++) {
|
||||
uint16_t *src = buffer + yi * viddef.width + x;
|
||||
PIXEL24 *dest = (PIXEL24 *) (framebuf->data + yi * rowbytes) + x;
|
||||
|
||||
for (int count = width; count-- > 0; ) {
|
||||
uint32_t c = *src++;
|
||||
*dest++ = 0xff000000
|
||||
| ((c & 0xf800) << 8)
|
||||
| ((c & 0x07e0) << 5)
|
||||
| ((c & 0x001f) << 3);
|
||||
}
|
||||
}
|
||||
if (doShm) {
|
||||
if (!XShmPutImage (x_disp, x_win, x_gc,
|
||||
x_framebuffer[current_framebuffer],
|
||||
rects->x, rects->y, rects->x, rects->y,
|
||||
rects->width, rects->height, True)) {
|
||||
Sys_Error ("VID_Update: XShmPutImage failed");
|
||||
}
|
||||
oktodraw = false;
|
||||
while (!oktodraw)
|
||||
X11_ProcessEvent ();
|
||||
rects = rects->next;
|
||||
|
||||
current_framebuffer = !current_framebuffer;
|
||||
} else {
|
||||
if (XPutImage (x_disp, x_win, x_gc, x_framebuffer[0],
|
||||
rects->x, rects->y, rects->x, rects->y,
|
||||
rects->width, rects->height)) {
|
||||
Sys_Error ("VID_Update: XPutImage failed");
|
||||
}
|
||||
rects = rects->next;
|
||||
}
|
||||
}
|
||||
XSync (x_disp, False);
|
||||
r_data->scr_fullupdate = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
x11_sw32_update (sw_ctx_t *ctx, vrect_t *rects)
|
||||
{
|
||||
uint32_t *buffer = (uint32_t *) viddef.buffer;
|
||||
XImage *framebuf = x_framebuffer[current_framebuffer];
|
||||
int rowbytes = framebuf->bytes_per_line;
|
||||
|
||||
while (rects) {
|
||||
int x = rects->x;
|
||||
int y = rects->y;
|
||||
int width = rects->width;
|
||||
int height = rects->height;
|
||||
for (int yi = y; yi < (y + height); yi++) {
|
||||
uint32_t *src = buffer + yi * viddef.width + x;
|
||||
PIXEL24 *dest = (PIXEL24 *) (framebuf->data + yi * rowbytes) + x;
|
||||
|
||||
for (int count = width; count-- > 0; ) {
|
||||
*dest++ = *src++;
|
||||
}
|
||||
}
|
||||
if (doShm) {
|
||||
if (!XShmPutImage (x_disp, x_win, x_gc,
|
||||
x_framebuffer[current_framebuffer],
|
||||
rects->x, rects->y, rects->x, rects->y,
|
||||
rects->width, rects->height, True)) {
|
||||
Sys_Error ("VID_Update: XShmPutImage failed");
|
||||
}
|
||||
oktodraw = false;
|
||||
while (!oktodraw)
|
||||
X11_ProcessEvent ();
|
||||
rects = rects->next;
|
||||
|
||||
current_framebuffer = !current_framebuffer;
|
||||
} else {
|
||||
if (XPutImage (x_disp, x_win, x_gc, x_framebuffer[0],
|
||||
rects->x, rects->y, rects->x, rects->y,
|
||||
rects->width, rects->height)) {
|
||||
Sys_Error ("VID_Update: XPutImage failed");
|
||||
}
|
||||
rects = rects->next;
|
||||
}
|
||||
}
|
||||
XSync (x_disp, False);
|
||||
r_data->scr_fullupdate = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
x11_choose_visual (sw_ctx_t *ctx)
|
||||
{
|
||||
|
@ -348,6 +492,34 @@ x11_choose_visual (sw_ctx_t *ctx)
|
|||
x_cmap = XCreateColormap (x_disp, x_win, x_vis, AllocAll);
|
||||
x_vis = x_visinfo->visual;
|
||||
|
||||
ctx->update = x11_sw8_update;
|
||||
switch (x_visinfo->depth) {
|
||||
case 8:
|
||||
ctx->pixbytes = 1;
|
||||
ctx->update = x11_sw8_update;
|
||||
break;
|
||||
case 16:
|
||||
if (ctx->pixbytes > 2) {
|
||||
ctx->pixbytes = 2;
|
||||
}
|
||||
if (ctx->pixbytes == 2) {
|
||||
ctx->update = x11_sw16_16_update;
|
||||
}
|
||||
break;
|
||||
case 24:
|
||||
switch (ctx->pixbytes) {
|
||||
case 1:
|
||||
break;
|
||||
case 2:
|
||||
ctx->update = x11_sw16_32_update;
|
||||
break;
|
||||
case 4:
|
||||
ctx->update = x11_sw32_update;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (num_visuals > 1) {
|
||||
Sys_MaskPrintf (SYS_vid,
|
||||
"Found more than one visual id at depth %d:\n",
|
||||
|
@ -461,8 +633,9 @@ ResetSharedFrameBuffers (void)
|
|||
}
|
||||
|
||||
static void
|
||||
x11_init_buffers (void)
|
||||
x11_init_buffers (void *data)
|
||||
{
|
||||
sw_ctx_t *ctx = data;
|
||||
if (doShm)
|
||||
ResetSharedFrameBuffers ();
|
||||
else
|
||||
|
@ -471,11 +644,11 @@ x11_init_buffers (void)
|
|||
current_framebuffer = 0;
|
||||
|
||||
viddef.direct = 0;
|
||||
viddef.rowbytes = viddef.width;
|
||||
viddef.rowbytes = ctx->pixbytes * viddef.width;
|
||||
if (x_visinfo->depth != 8) {
|
||||
if (viddef.buffer)
|
||||
free (viddef.buffer);
|
||||
viddef.buffer = calloc (viddef.width, viddef.height);
|
||||
viddef.buffer = calloc (viddef.rowbytes, viddef.height);
|
||||
if (!viddef.buffer)
|
||||
Sys_Error ("Not enough memory for video mode");
|
||||
} else {
|
||||
|
@ -527,14 +700,43 @@ sw_ctx_t *
|
|||
X11_SW_Context (void)
|
||||
{
|
||||
sw_ctx_t *ctx = calloc (1, sizeof (sw_ctx_t));
|
||||
ctx->pixbytes = 1;
|
||||
ctx->set_palette = x11_set_palette;
|
||||
ctx->choose_visual = x11_choose_visual;
|
||||
ctx->create_context = x11_create_context;
|
||||
ctx->update = x11_sw_update;
|
||||
ctx->update = x11_sw8_update;
|
||||
return ctx;
|
||||
}
|
||||
|
||||
sw_ctx_t *
|
||||
X11_SW32_Context (void)
|
||||
{
|
||||
sw_ctx_t *ctx = calloc (1, sizeof (sw_ctx_t));
|
||||
ctx->pixbytes = 1;
|
||||
ctx->set_palette = x11_set_palette;
|
||||
ctx->choose_visual = x11_choose_visual;
|
||||
ctx->create_context = x11_create_context;
|
||||
|
||||
switch (vid_bitdepth->int_val) {
|
||||
case 8:
|
||||
ctx->pixbytes = 1;
|
||||
break;
|
||||
case 16:
|
||||
ctx->pixbytes = 2;
|
||||
break;
|
||||
case 32:
|
||||
ctx->pixbytes = 4;
|
||||
break;
|
||||
default:
|
||||
Sys_Error ("X11_SW32_Context: unsupported bit depth");
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
void
|
||||
X11_SW_Init_Cvars (void)
|
||||
{
|
||||
// FIXME: vid_colorbpp in common GL setup, make consistent with sdl32 scheme
|
||||
vid_bitdepth = Cvar_Get ("vid_bitdepth", "8", CVAR_ROM, NULL, "Sets "
|
||||
"display bitdepth (supported modes: 8 16 32)");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue