Skip to content

Commit dace83c

Browse files
committed
gfxlib2: Control selection of x86 MMX blitters
- added fb.GFX_NO_X86_MMX = &h00000100 constant to fbgfx.bi, when passed as flag to SCREEN[RES] disable MMX blitters on x86 32-bit - added fb.GET_X86_MMX_ENABLED = 18 constant to fbgfx.bi, used with ScreenControl to determine if MMX blitters are selected If returned value is non-zero, then MMX is enabled. If zero, then MMX is disabled. All other platforms return zero. - added fb.SET_X86_MMX_ENABLED = 118 constant to fbgfx.bi, used with ScreenControl to specific if MMX blitters should be used. Pass non-zero value to enable, and zero value to disable. All other platforms ignore this setting - internal: query the cpu type for MMX capability only when setting the graphics mode with SCREEN[RES] or when setting x86 MMX feature with ScreenControl fb.SET_X86_MMX_ENABLED function
1 parent b7154ff commit dace83c

File tree

6 files changed

+55
-11
lines changed

6 files changed

+55
-11
lines changed

changelog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Version 1.20.0
88
- emscripten/fbc: don't cast to integer for array indexing (possible regression of behaviour when fixing github #217)
99
- github #421: fbc: win32/win64: pass '-fno-ident' to gcc to help prevent identification strings from accumulating in the final binary
1010
- fbc: internal: rtlMathLongintDIV() decide on signed or unsigned division based on sign instead of exact data type
11+
- gfxlib2: on x86 32-bit, query the cpu type for MMX capability only when setting the graphics mode with SCREEN[RES] or when setting x86 MMX feature with ScreenControl fb.SET_X86_MMX_ENABLED function
1112

1213
[added]
1314
- x86_64: optimize SHL MOD INTDIV to use 32-bit operation when result will be converted to long/ulong
@@ -21,6 +22,9 @@ Version 1.20.0
2122
- gas64: optimizations: enable IR_OPT_ADDRCISC optimizations to use complex addressing (base + offset*multiplier) optimization for indexes (SARG)
2223
- fbc headers: add ./inc/fberror.bi for runtime library error constants
2324
- rtlib: ./inc/fbc-int/string.bi - for string descriptor and low level string functions
25+
- gfxlib2: added fb.GFX_NO_X86_MMX = &h00000100 constant to fbgfx.bi - when passed as flag to SCREEN[RES] disable MMX blitters on x86 32-bit
26+
- gfxlib2: added fb.GET_X86_MMX_ENABLED = 18 constant to fbgfx.bi - used with ScreenControl to determine if MMX blitters are selected on x86 32 bit. If returned value is non-zero, then MMX is enabled. If zero, then MMX is disabled. All other platforms return zero.
27+
- gfxlib2: added fb.SET_X86_MMX_ENABLED = 118 constant to fbgfx.bi - used with ScreenControl to specific if MMX blitters should be used on x86 32-bit. Pass non-zero value to enable, and zero value to disable. All other platforms ignore this setting
2428

2529
[fixed]
2630
- github #410: give consistent floating point comparisons results involving NaNs.

inc/fbgfx.bi

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ namespace FB
4848
GFX_SHAPED_WINDOW = &h00000010, _
4949
GFX_ALWAYS_ON_TOP = &h00000020, _
5050
GFX_ALPHA_PRIMITIVES = &h00000040, _
51-
GFX_HIGH_PRIORITY = &h00000080,_
51+
GFX_HIGH_PRIORITY = &h00000080, _
52+
GFX_NO_X86_MMX = &h00000100, _
5253
GFX_SCREEN_EXIT = &h80000000l
5354

5455
'' OpenGL options
@@ -85,6 +86,7 @@ namespace FB
8586
GET_GL_EXTENSIONS = 15, _
8687
GET_HIGH_PRIORITY = 16, _
8788
GET_SCANLINE_SIZE = 17, _
89+
GET_X86_MMX_ENABLED = 18, _
8890
_
8991
GET_GL_COLOR_BITS = 37, _
9092
GET_GL_COLOR_RED_BITS = 38, _
@@ -124,6 +126,7 @@ namespace FB
124126
SET_GL_ACCUM_BLUE_BITS = 115, _
125127
SET_GL_ACCUM_ALPHA_BITS = 116, _
126128
SET_GL_NUM_SAMPLES = 117, _
129+
SET_X86_MMX_ENABLED = 118, _
127130
_
128131
SET_GL_2D_MODE = 150, _
129132
SET_GL_SCALE = 151

src/gfxlib2/fb_gfx.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ DRIVER_SHAPED_WINDOW 0x00000010 yes no yes no no
4747
DRIVER_ALWAYS_ON_TOP 0x00000020 no no yes no no
4848
DRIVER_ALPHA_PRIMITIVES 0x00000040 yes no no no no
4949
DRIVER_HIGH_PRIORITY 0x00000080 yes no yes no no
50+
DRIVER_NO_X86_MMX 0x00000100 yes no yes no no
5051
DRIVER_OPENGL_OPTIONS 0x000F0000 no no yes no no
5152
HAS_STENCIL_BUFFER 0x00010000 no no yes no no
5253
HAS_ACCUMULATION_BUFFER 0x00020000 no no yes no no
@@ -78,6 +79,7 @@ OPENGL_SUPPORT 0x20000000 no yes no yes yes
7879
#define DRIVER_ALWAYS_ON_TOP 0x00000020
7980
#define DRIVER_ALPHA_PRIMITIVES 0x00000040
8081
#define DRIVER_HIGH_PRIORITY 0x00000080
82+
#define DRIVER_NO_X86_MMX 0x00000100
8183
#define DRIVER_OPENGL_OPTIONS 0x000F0000
8284
#define HAS_STENCIL_BUFFER 0x00010000
8385
#define HAS_ACCUMULATION_BUFFER 0x00020000
@@ -156,6 +158,7 @@ OPENGL_SUPPORT 0x20000000 no yes no yes yes
156158
#define GET_GL_EXTENSIONS 15
157159
#define GET_HIGH_PRIORITY 16
158160
#define GET_SCANLINE_SIZE 17
161+
#define GET_X86_MMX_ENABLED 18
159162

160163
#define GET_GL_COLOR_BITS 37
161164
#define GET_GL_COLOR_RED_BITS 38
@@ -195,6 +198,7 @@ OPENGL_SUPPORT 0x20000000 no yes no yes yes
195198
#define SET_GL_ACCUM_BLUE_BITS 115
196199
#define SET_GL_ACCUM_ALPHA_BITS 116
197200
#define SET_GL_NUM_SAMPLES 117
201+
#define SET_X86_MMX_ENABLED 118
198202

199203
#define SET_GL_2D_MODE 150
200204
#define SET_GL_SCALE 151

src/gfxlib2/gfx_control.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ FBCALL void fb_GfxControl_i( int what, ssize_t *param1, ssize_t *param2, ssize_t
165165
res1 = __fb_gfx->scanline_size;
166166
break;
167167

168+
case GET_X86_MMX_ENABLED:
169+
if (__fb_gfx)
170+
res1 = (__fb_gfx->flags & X86_MMX_ENABLED) ? FB_TRUE : FB_FALSE;
171+
break;
172+
168173
case SET_WINDOW_POS:
169174
if ((__fb_gfx) && (__fb_gfx->driver->set_window_pos))
170175
__fb_gfx->driver->set_window_pos(*param1, *param2);
@@ -303,6 +308,23 @@ FBCALL void fb_GfxControl_i( int what, ssize_t *param1, ssize_t *param2, ssize_t
303308
__fb_gl_params.num_samples = *param1;
304309
break;
305310

311+
case SET_X86_MMX_ENABLED:
312+
#ifdef HOST_X86
313+
if (__fb_gfx) {
314+
if (fb_CpuDetect() & 0x800000) {
315+
if (*param1) {
316+
__fb_gfx->flags |= X86_MMX_ENABLED;
317+
} else {
318+
__fb_gfx->flags &= ~X86_MMX_ENABLED;
319+
}
320+
} else {
321+
__fb_gfx->flags &= ~X86_MMX_ENABLED;
322+
}
323+
}
324+
#endif
325+
context->last_target = NULL;
326+
break;
327+
306328
case SET_GL_2D_MODE:
307329
/* set the initial 2d mode only; we don't want to
308330
change the active mode in use. The activie mode

src/gfxlib2/gfx_core.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,7 @@ static void *fb_hPixelCpy4(void *dest, const void *src, size_t size)
290290
void fb_hSetupFuncs(int bpp)
291291
{
292292
#ifdef HOST_X86
293-
if (fb_CpuDetect() & 0x800000) {
294-
__fb_gfx->flags |= X86_MMX_ENABLED;
293+
if (__fb_gfx->flags & X86_MMX_ENABLED) {
295294
fb_hMemCpy = fb_hMemCpyMMX;
296295
fb_hMemSet = fb_hMemSetMMX;
297296
} else {

src/gfxlib2/gfx_screen.c

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -285,14 +285,26 @@ static int set_mode
285285
__fb_gfx->event_queue = (EVENT *)malloc(sizeof(EVENT) * MAX_EVENTS);
286286
__fb_gfx->event_mutex = fb_MutexCreate();
287287
__fb_color_conv_16to32 = (unsigned int *)malloc(sizeof(int) * 512);
288-
if (flags != DRIVER_NULL) {
289-
if (flags & DRIVER_ALPHA_PRIMITIVES)
290-
__fb_gfx->flags |= ALPHA_PRIMITIVES;
291-
if (flags & DRIVER_OPENGL)
292-
__fb_gfx->flags |= OPENGL_SUPPORT;
293-
if (flags & DRIVER_HIGH_PRIORITY)
294-
__fb_gfx->flags |= HIGH_PRIORITY;
295-
}
288+
289+
if (flags != DRIVER_NULL) {
290+
if (flags & DRIVER_ALPHA_PRIMITIVES) {
291+
__fb_gfx->flags |= ALPHA_PRIMITIVES;
292+
}
293+
if (flags & DRIVER_OPENGL) {
294+
__fb_gfx->flags |= OPENGL_SUPPORT;
295+
}
296+
if (flags & DRIVER_HIGH_PRIORITY) {
297+
__fb_gfx->flags |= HIGH_PRIORITY;
298+
}
299+
}
300+
301+
#ifdef HOST_X86
302+
if (fb_CpuDetect() & 0x800000) {
303+
if (!(flags & DRIVER_NO_X86_MMX)) {
304+
__fb_gfx->flags |= X86_MMX_ENABLED;
305+
}
306+
}
307+
#endif
296308

297309
fb_hSetupFuncs(__fb_gfx->bpp);
298310
fb_hSetupData();

0 commit comments

Comments
 (0)