cmake/sse2: initial sse2 detect
This commit is contained in:
parent
89f2942caa
commit
ce59c2226f
@ -76,7 +76,7 @@ if(CMAKE_COMPILER_IS_GNUCC)
|
|||||||
if(CMAKE_BUILD_TYPE STREQUAL "Release")
|
if(CMAKE_BUILD_TYPE STREQUAL "Release")
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
|
||||||
endif()
|
endif()
|
||||||
if(WITH_SSE2)
|
if(WITH_SSE2_TARGET)
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse2")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
@ -85,6 +85,10 @@ if(XV_FOUND)
|
|||||||
target_link_libraries(xfreerdp ${XV_LIBRARIES})
|
target_link_libraries(xfreerdp ${XV_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
||||||
|
add_definitions(-DWITH_LINUX)
|
||||||
|
endif()
|
||||||
|
|
||||||
include_directories(${CMAKE_SOURCE_DIR}/resources)
|
include_directories(${CMAKE_SOURCE_DIR}/resources)
|
||||||
|
|
||||||
target_link_libraries(xfreerdp freerdp-core)
|
target_link_libraries(xfreerdp freerdp-core)
|
||||||
|
@ -570,7 +570,7 @@ boolean xf_post_connect(freerdp* instance)
|
|||||||
xfi->primary_buffer = (uint8*) xzalloc(xfi->width * xfi->height * xfi->bpp);
|
xfi->primary_buffer = (uint8*) xzalloc(xfi->width * xfi->height * xfi->bpp);
|
||||||
|
|
||||||
if (instance->settings->rfx_codec)
|
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)
|
if (instance->settings->ns_codec)
|
||||||
xfi->nsc_context = (void*) nsc_context_new();
|
xfi->nsc_context = (void*) nsc_context_new();
|
||||||
@ -675,6 +675,46 @@ boolean xf_verify_certificate(freerdp* instance, char* subject, char* issuer, ch
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
uint32 xf_detect_cpu()
|
||||||
|
{
|
||||||
|
uint32 cpu_opt = 0;
|
||||||
|
|
||||||
|
#ifdef WITH_LINUX
|
||||||
|
/* for now, read /proc/cpuinfo */
|
||||||
|
FILE* f;
|
||||||
|
char* buf;
|
||||||
|
|
||||||
|
f = fopen("/proc/cpuinfo", "r");
|
||||||
|
if (!f)
|
||||||
|
return cpu_opt;
|
||||||
|
|
||||||
|
buf = xmalloc(1024);
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
if (!fgets(buf, 1024, f))
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (strncmp(buf, "flags", 5))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!strstr(buf, " sse2"))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
cpu_opt |= CPU_SSE2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
xfree(buf);
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
|
#elif defined(WITH_SSE2)
|
||||||
|
/* no detect, assume sse2 available for now */
|
||||||
|
cpu_opt |= CPU_SSE2;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return cpu_opt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int xf_process_client_args(rdpSettings* settings, const char* opt, const char* val, void* user_data)
|
int xf_process_client_args(rdpSettings* settings, const char* opt, const char* val, void* user_data)
|
||||||
{
|
{
|
||||||
int argc = 0;
|
int argc = 0;
|
||||||
@ -970,6 +1010,7 @@ int main(int argc, char* argv[])
|
|||||||
instance->context->argc = argc;
|
instance->context->argc = argc;
|
||||||
instance->context->argv = argv;
|
instance->context->argv = argv;
|
||||||
instance->settings->sw_gdi = False;
|
instance->settings->sw_gdi = False;
|
||||||
|
instance->settings->cpu_opt = xf_detect_cpu();
|
||||||
|
|
||||||
data = (struct thread_data*) xzalloc(sizeof(struct thread_data));
|
data = (struct thread_data*) xzalloc(sizeof(struct thread_data));
|
||||||
data->instance = instance;
|
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_X11 "Print X11 Client debug messages" OFF)
|
||||||
option(WITH_DEBUG_RAIL "Print RemoteApp debug messages" OFF)
|
option(WITH_DEBUG_RAIL "Print RemoteApp debug messages" OFF)
|
||||||
option(WITH_DEBUG_XV "Print XVideo 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_MANPAGES "Generate manpages." ON)
|
||||||
option(WITH_PROFILER "Compile profiler." OFF)
|
option(WITH_PROFILER "Compile profiler." OFF)
|
||||||
option(WITH_SSE2 "Use SSE2 optimization." 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_DEBUG_RFX
|
||||||
#cmakedefine WITH_PROFILER
|
#cmakedefine WITH_PROFILER
|
||||||
#cmakedefine WITH_SSE2
|
#cmakedefine WITH_SSE2
|
||||||
|
#cmakedefine WITH_SSE2_TARGET
|
||||||
#cmakedefine WITH_DEBUG_X11
|
#cmakedefine WITH_DEBUG_X11
|
||||||
#cmakedefine WITH_DEBUG_RAIL
|
#cmakedefine WITH_DEBUG_RAIL
|
||||||
#cmakedefine WITH_DEBUG_XV
|
#cmakedefine WITH_DEBUG_XV
|
||||||
#cmakedefine WITH_DEBUG_SCARD
|
#cmakedefine WITH_DEBUG_SCARD
|
||||||
|
#cmakedefine WITH_DEBUG_ORDERS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -267,7 +267,7 @@ void test_dwt(void)
|
|||||||
{
|
{
|
||||||
RFX_CONTEXT* context;
|
RFX_CONTEXT* context;
|
||||||
|
|
||||||
context = rfx_context_new();
|
context = rfx_context_new(NULL);
|
||||||
rfx_dwt_2d_decode(buffer, context->priv->dwt_buffer);
|
rfx_dwt_2d_decode(buffer, context->priv->dwt_buffer);
|
||||||
//dump_buffer(buffer, 4096);
|
//dump_buffer(buffer, 4096);
|
||||||
rfx_context_free(context);
|
rfx_context_free(context);
|
||||||
@ -304,7 +304,7 @@ void test_decode(void)
|
|||||||
stream_write(s, cr_data, sizeof(cr_data));
|
stream_write(s, cr_data, sizeof(cr_data));
|
||||||
stream_set_pos(s, 0);
|
stream_set_pos(s, 0);
|
||||||
|
|
||||||
context = rfx_context_new();
|
context = rfx_context_new(NULL);
|
||||||
context->mode = RLGR3;
|
context->mode = RLGR3;
|
||||||
rfx_context_set_pixel_format(context, RFX_PIXEL_FORMAT_RGB);
|
rfx_context_set_pixel_format(context, RFX_PIXEL_FORMAT_RGB);
|
||||||
rfx_decode_rgb(context, s,
|
rfx_decode_rgb(context, s,
|
||||||
@ -334,7 +334,7 @@ void test_encode(void)
|
|||||||
enc_stream = stream_new(65536);
|
enc_stream = stream_new(65536);
|
||||||
stream_clear(enc_stream);
|
stream_clear(enc_stream);
|
||||||
|
|
||||||
context = rfx_context_new();
|
context = rfx_context_new(NULL);
|
||||||
context->mode = RLGR3;
|
context->mode = RLGR3;
|
||||||
rfx_context_set_pixel_format(context, RFX_PIXEL_FORMAT_RGB);
|
rfx_context_set_pixel_format(context, RFX_PIXEL_FORMAT_RGB);
|
||||||
|
|
||||||
@ -378,7 +378,7 @@ void test_message(void)
|
|||||||
s = stream_new(65536);
|
s = stream_new(65536);
|
||||||
stream_clear(s);
|
stream_clear(s);
|
||||||
|
|
||||||
context = rfx_context_new();
|
context = rfx_context_new(NULL);
|
||||||
context->mode = RLGR3;
|
context->mode = RLGR3;
|
||||||
context->width = 800;
|
context->width = 800;
|
||||||
context->height = 600;
|
context->height = 600;
|
||||||
|
@ -125,7 +125,7 @@ struct _RFX_CONTEXT
|
|||||||
};
|
};
|
||||||
typedef struct _RFX_CONTEXT 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_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_set_pixel_format(RFX_CONTEXT* context, RFX_PIXEL_FORMAT pixel_format);
|
||||||
FREERDP_API void rfx_context_reset(RFX_CONTEXT* context);
|
FREERDP_API void rfx_context_reset(RFX_CONTEXT* context);
|
||||||
|
@ -90,6 +90,9 @@
|
|||||||
#define GLYPH_SUPPORT_FULL 0x0002
|
#define GLYPH_SUPPORT_FULL 0x0002
|
||||||
#define GLYPH_SUPPORT_ENCODE 0x0003
|
#define GLYPH_SUPPORT_ENCODE 0x0003
|
||||||
|
|
||||||
|
/* CPU Optimization flags */
|
||||||
|
#define CPU_SSE2 0x1
|
||||||
|
|
||||||
/* SYSTEM_TIME */
|
/* SYSTEM_TIME */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
@ -325,6 +328,8 @@ struct rdp_settings
|
|||||||
boolean rail_langbar_supported;
|
boolean rail_langbar_supported;
|
||||||
|
|
||||||
boolean mouse_motion;
|
boolean mouse_motion;
|
||||||
|
|
||||||
|
uint32 cpu_opt;
|
||||||
};
|
};
|
||||||
typedef struct rdp_settings rdpSettings;
|
typedef struct rdp_settings rdpSettings;
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@ if(WITH_SSE2)
|
|||||||
rfx_sse2.c
|
rfx_sse2.c
|
||||||
rfx_sse2.h
|
rfx_sse2.h
|
||||||
)
|
)
|
||||||
|
set_property(SOURCE rfx_sse2.c PROPERTY COMPILE_FLAGS "-msse2")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(freerdp-codec ${FREERDP_CODEC_SRCS})
|
add_library(freerdp-codec ${FREERDP_CODEC_SRCS})
|
||||||
|
@ -128,7 +128,7 @@ static void rfx_profiler_print(RFX_CONTEXT* context)
|
|||||||
PROFILER_PRINT_FOOTER;
|
PROFILER_PRINT_FOOTER;
|
||||||
}
|
}
|
||||||
|
|
||||||
RFX_CONTEXT* rfx_context_new(void)
|
RFX_CONTEXT* rfx_context_new(rdpSettings* settings)
|
||||||
{
|
{
|
||||||
RFX_CONTEXT* context;
|
RFX_CONTEXT* context;
|
||||||
|
|
||||||
@ -157,8 +157,9 @@ RFX_CONTEXT* rfx_context_new(void)
|
|||||||
context->dwt_2d_decode = rfx_dwt_2d_decode;
|
context->dwt_2d_decode = rfx_dwt_2d_decode;
|
||||||
context->dwt_2d_encode = rfx_dwt_2d_encode;
|
context->dwt_2d_encode = rfx_dwt_2d_encode;
|
||||||
|
|
||||||
/* detect and enable SIMD CPU acceleration */
|
/* enable SIMD CPU acceleration if detected */
|
||||||
RFX_INIT_SIMD(context);
|
if (settings && settings->cpu_opt & CPU_SSE2)
|
||||||
|
RFX_INIT_SIMD(context);
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
}
|
}
|
||||||
|
@ -1054,7 +1054,7 @@ int gdi_init(freerdp* instance, uint32 flags, uint8* buffer)
|
|||||||
|
|
||||||
gdi_register_graphics(instance->context->graphics);
|
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();
|
gdi->nsc_context = nsc_context_new();
|
||||||
|
|
||||||
return 0;
|
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)
|
void xf_peer_context_new(freerdp_peer* client, xfPeerContext* context)
|
||||||
{
|
{
|
||||||
context->info = xf_info_init();
|
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->mode = RLGR3;
|
||||||
context->rfx_context->width = client->settings->width;
|
context->rfx_context->width = client->settings->width;
|
||||||
context->rfx_context->height = client->settings->height;
|
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)
|
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->mode = RLGR3;
|
||||||
context->rfx_context->width = client->settings->width;
|
context->rfx_context->width = client->settings->width;
|
||||||
context->rfx_context->height = client->settings->height;
|
context->rfx_context->height = client->settings->height;
|
||||||
|
Loading…
Reference in New Issue
Block a user