Merge pull request #182 from atong-tcs/sse2
-DWITH_SSE2 now does runtime detection
This commit is contained in:
commit
e8a784195c
@ -76,7 +76,7 @@ if(CMAKE_COMPILER_IS_GNUCC)
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
|
||||
endif()
|
||||
if(WITH_SSE2)
|
||||
if(WITH_SSE2_TARGET)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2")
|
||||
endif()
|
||||
endif()
|
||||
|
@ -570,7 +570,7 @@ boolean xf_post_connect(freerdp* instance)
|
||||
xfi->primary_buffer = (uint8*) xzalloc(xfi->width * xfi->height * xfi->bpp);
|
||||
|
||||
if (instance->settings->rfx_codec)
|
||||
xfi->rfx_context = (void*) rfx_context_new();
|
||||
xfi->rfx_context = (void*) rfx_context_new(instance->settings);
|
||||
|
||||
if (instance->settings->ns_codec)
|
||||
xfi->nsc_context = (void*) nsc_context_new();
|
||||
@ -675,6 +675,35 @@ boolean xf_verify_certificate(freerdp* instance, char* subject, char* issuer, ch
|
||||
}
|
||||
|
||||
|
||||
void cpuid(unsigned info, unsigned *eax, unsigned *ebx, unsigned *ecx, unsigned *edx)
|
||||
{
|
||||
*eax = info;
|
||||
__asm volatile
|
||||
("mov %%ebx, %%edi;" /* 32bit PIC: don't clobber ebx */
|
||||
"cpuid;"
|
||||
"mov %%ebx, %%esi;"
|
||||
"mov %%edi, %%ebx;"
|
||||
:"+a" (*eax), "=S" (*ebx), "=c" (*ecx), "=d" (*edx)
|
||||
: :"edi");
|
||||
}
|
||||
|
||||
uint32 xf_detect_cpu()
|
||||
{
|
||||
unsigned int eax, ebx, ecx, edx;
|
||||
uint32 cpu_opt = 0;
|
||||
|
||||
cpuid(1, &eax, &ebx, &ecx, &edx);
|
||||
|
||||
if (edx & (1<<26))
|
||||
{
|
||||
DEBUG("SSE2 detected");
|
||||
cpu_opt |= CPU_SSE2;
|
||||
}
|
||||
|
||||
return cpu_opt;
|
||||
}
|
||||
|
||||
|
||||
int xf_process_client_args(rdpSettings* settings, const char* opt, const char* val, void* user_data)
|
||||
{
|
||||
int argc = 0;
|
||||
@ -971,6 +1000,11 @@ int main(int argc, char* argv[])
|
||||
instance->context->argv = argv;
|
||||
instance->settings->sw_gdi = False;
|
||||
|
||||
#ifdef WITH_SSE2
|
||||
/* detect only if needed */
|
||||
instance->settings->cpu_opt = xf_detect_cpu();
|
||||
#endif
|
||||
|
||||
data = (struct thread_data*) xzalloc(sizeof(struct thread_data));
|
||||
data->instance = instance;
|
||||
|
||||
|
@ -12,6 +12,9 @@ option(WITH_DEBUG_RFX "Print RemoteFX debug messages." OFF)
|
||||
option(WITH_DEBUG_X11 "Print X11 Client debug messages" OFF)
|
||||
option(WITH_DEBUG_RAIL "Print RemoteApp debug messages" OFF)
|
||||
option(WITH_DEBUG_XV "Print XVideo debug messages" OFF)
|
||||
option(WITH_DEBUG_SCARD "Print smartcard debug messages" OFF)
|
||||
option(WITH_DEBUG_ORDERS "Print drawing orders debug messages" OFF)
|
||||
option(WITH_MANPAGES "Generate manpages." ON)
|
||||
option(WITH_PROFILER "Compile profiler." OFF)
|
||||
option(WITH_SSE2 "Use SSE2 optimization." OFF)
|
||||
option(WITH_SSE2_TARGET "Allow compiler to generate SSE2 instructions." OFF)
|
||||
|
@ -31,9 +31,11 @@
|
||||
#cmakedefine WITH_DEBUG_RFX
|
||||
#cmakedefine WITH_PROFILER
|
||||
#cmakedefine WITH_SSE2
|
||||
#cmakedefine WITH_SSE2_TARGET
|
||||
#cmakedefine WITH_DEBUG_X11
|
||||
#cmakedefine WITH_DEBUG_RAIL
|
||||
#cmakedefine WITH_DEBUG_XV
|
||||
#cmakedefine WITH_DEBUG_SCARD
|
||||
#cmakedefine WITH_DEBUG_ORDERS
|
||||
|
||||
#endif
|
||||
|
@ -267,7 +267,7 @@ void test_dwt(void)
|
||||
{
|
||||
RFX_CONTEXT* context;
|
||||
|
||||
context = rfx_context_new();
|
||||
context = rfx_context_new(NULL);
|
||||
rfx_dwt_2d_decode(buffer, context->priv->dwt_buffer);
|
||||
//dump_buffer(buffer, 4096);
|
||||
rfx_context_free(context);
|
||||
@ -304,7 +304,7 @@ void test_decode(void)
|
||||
stream_write(s, cr_data, sizeof(cr_data));
|
||||
stream_set_pos(s, 0);
|
||||
|
||||
context = rfx_context_new();
|
||||
context = rfx_context_new(NULL);
|
||||
context->mode = RLGR3;
|
||||
rfx_context_set_pixel_format(context, RFX_PIXEL_FORMAT_RGB);
|
||||
rfx_decode_rgb(context, s,
|
||||
@ -334,7 +334,7 @@ void test_encode(void)
|
||||
enc_stream = stream_new(65536);
|
||||
stream_clear(enc_stream);
|
||||
|
||||
context = rfx_context_new();
|
||||
context = rfx_context_new(NULL);
|
||||
context->mode = RLGR3;
|
||||
rfx_context_set_pixel_format(context, RFX_PIXEL_FORMAT_RGB);
|
||||
|
||||
@ -378,7 +378,7 @@ void test_message(void)
|
||||
s = stream_new(65536);
|
||||
stream_clear(s);
|
||||
|
||||
context = rfx_context_new();
|
||||
context = rfx_context_new(NULL);
|
||||
context->mode = RLGR3;
|
||||
context->width = 800;
|
||||
context->height = 600;
|
||||
|
@ -125,7 +125,7 @@ struct _RFX_CONTEXT
|
||||
};
|
||||
typedef struct _RFX_CONTEXT RFX_CONTEXT;
|
||||
|
||||
FREERDP_API RFX_CONTEXT* rfx_context_new(void);
|
||||
FREERDP_API RFX_CONTEXT* rfx_context_new(rdpSettings* settings);
|
||||
FREERDP_API void rfx_context_free(RFX_CONTEXT* context);
|
||||
FREERDP_API void rfx_context_set_pixel_format(RFX_CONTEXT* context, RFX_PIXEL_FORMAT pixel_format);
|
||||
FREERDP_API void rfx_context_reset(RFX_CONTEXT* context);
|
||||
|
@ -90,6 +90,9 @@
|
||||
#define GLYPH_SUPPORT_FULL 0x0002
|
||||
#define GLYPH_SUPPORT_ENCODE 0x0003
|
||||
|
||||
/* CPU Optimization flags */
|
||||
#define CPU_SSE2 0x1
|
||||
|
||||
/* SYSTEM_TIME */
|
||||
typedef struct
|
||||
{
|
||||
@ -325,6 +328,8 @@ struct rdp_settings
|
||||
boolean rail_langbar_supported;
|
||||
|
||||
boolean mouse_motion;
|
||||
|
||||
uint32 cpu_opt;
|
||||
};
|
||||
typedef struct rdp_settings rdpSettings;
|
||||
|
||||
|
@ -46,6 +46,7 @@ if(WITH_SSE2)
|
||||
rfx_sse2.c
|
||||
rfx_sse2.h
|
||||
)
|
||||
set_property(SOURCE rfx_sse2.c PROPERTY COMPILE_FLAGS "-msse2")
|
||||
endif()
|
||||
|
||||
add_library(freerdp-codec ${FREERDP_CODEC_SRCS})
|
||||
|
@ -128,7 +128,7 @@ static void rfx_profiler_print(RFX_CONTEXT* context)
|
||||
PROFILER_PRINT_FOOTER;
|
||||
}
|
||||
|
||||
RFX_CONTEXT* rfx_context_new(void)
|
||||
RFX_CONTEXT* rfx_context_new(rdpSettings* settings)
|
||||
{
|
||||
RFX_CONTEXT* context;
|
||||
|
||||
@ -157,8 +157,9 @@ RFX_CONTEXT* rfx_context_new(void)
|
||||
context->dwt_2d_decode = rfx_dwt_2d_decode;
|
||||
context->dwt_2d_encode = rfx_dwt_2d_encode;
|
||||
|
||||
/* detect and enable SIMD CPU acceleration */
|
||||
RFX_INIT_SIMD(context);
|
||||
/* enable SIMD CPU acceleration if detected */
|
||||
if (settings && settings->cpu_opt & CPU_SSE2)
|
||||
RFX_INIT_SIMD(context);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
@ -1054,7 +1054,7 @@ int gdi_init(freerdp* instance, uint32 flags, uint8* buffer)
|
||||
|
||||
gdi_register_graphics(instance->context->graphics);
|
||||
|
||||
gdi->rfx_context = rfx_context_new();
|
||||
gdi->rfx_context = rfx_context_new(instance->settings);
|
||||
gdi->nsc_context = nsc_context_new();
|
||||
|
||||
return 0;
|
||||
|
@ -121,7 +121,7 @@ void xf_peer_context_size(freerdp_peer* client, uint32* size)
|
||||
void xf_peer_context_new(freerdp_peer* client, xfPeerContext* context)
|
||||
{
|
||||
context->info = xf_info_init();
|
||||
context->rfx_context = rfx_context_new();
|
||||
context->rfx_context = rfx_context_new(client->settings);
|
||||
context->rfx_context->mode = RLGR3;
|
||||
context->rfx_context->width = client->settings->width;
|
||||
context->rfx_context->height = client->settings->height;
|
||||
|
@ -64,7 +64,7 @@ void test_peer_context_size(freerdp_peer* client, uint32* size)
|
||||
|
||||
void test_peer_context_new(freerdp_peer* client, testPeerContext* context)
|
||||
{
|
||||
context->rfx_context = rfx_context_new();
|
||||
context->rfx_context = rfx_context_new(client->settings);
|
||||
context->rfx_context->mode = RLGR3;
|
||||
context->rfx_context->width = client->settings->width;
|
||||
context->rfx_context->height = client->settings->height;
|
||||
|
Loading…
Reference in New Issue
Block a user