gsdx: merge back gsdx-ogl-wnd to the trunk

Here the list of the major change:
* Drop glew. It won't failed to load because of the wrong glew version
* shaders are include in the source code to ease release&packaging

* Port GSdx-ogl to MS Windows

* Fix lots of HW rendering bug. 8bits textures/upscale/transparency...
   - rendering isn't yet perfect but some games must be playable now.
* Add Fxaa shader.
* run on the opensouce driver (require mesa 9). You will need to build with EGL support
  - either use this cmake option -DEGL_API=TRUE
  - Or the handy script ./build.sh --egl ...
* Linux AMD users: you need to do a choice
    * speed but bad rendering => catalyst
    * correct rendering but slower => opensource radeon

* Some parts are still unimplemented:
 - MSAA
 - Vsync
 - Fully dynamic switch between EGL/GLX
 - Speed optimization
 - Others stuff that I have forgotten  :p



git-svn-id: http://pcsx2.googlecode.com/svn/trunk@5667 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
gregory.hainaut 2013-06-15 20:11:13 +00:00
commit 328cc55c60
57 changed files with 5437 additions and 2709 deletions

447
3rdparty/GL/glext.h vendored
View File

@ -6,7 +6,7 @@ extern "C" {
#endif
/*
** Copyright (c) 2007-2010 The Khronos Group Inc.
** Copyright (c) 2007-2011 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
@ -29,9 +29,9 @@ extern "C" {
*/
/* Header file version number, required by OpenGL ABI for Linux */
/* glext.h last updated $Date: 2010-12-09 02:15:08 -0800 (Thu, 09 Dec 2010) $ */
/* glext.h last updated $Date: 2011-08-08 00:34:29 -0700 (Mon, 08 Aug 2011) $ */
/* Current version at http://www.opengl.org/registry/ */
#define GL_GLEXT_VERSION 67
#define GL_GLEXT_VERSION 72
/* Function declaration macros - to move into glplatform.h */
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
@ -1047,6 +1047,124 @@ extern "C" {
/* reuse GL_UNDEFINED_VERTEX */
#endif
#ifndef GL_VERSION_4_2
/* Reuse tokens from ARB_base_instance (none) */
/* Reuse tokens from ARB_shading_language_420pack (none) */
/* Reuse tokens from ARB_transform_feedback_instanced (none) */
/* Reuse tokens from ARB_compressed_texture_pixel_storage */
/* reuse GL_UNPACK_COMPRESSED_BLOCK_WIDTH */
/* reuse GL_UNPACK_COMPRESSED_BLOCK_HEIGHT */
/* reuse GL_UNPACK_COMPRESSED_BLOCK_DEPTH */
/* reuse GL_UNPACK_COMPRESSED_BLOCK_SIZE */
/* reuse GL_PACK_COMPRESSED_BLOCK_WIDTH */
/* reuse GL_PACK_COMPRESSED_BLOCK_HEIGHT */
/* reuse GL_PACK_COMPRESSED_BLOCK_DEPTH */
/* reuse GL_PACK_COMPRESSED_BLOCK_SIZE */
/* Reuse tokens from ARB_conservative_depth (none) */
/* Reuse tokens from ARB_internalformat_query */
/* reuse GL_NUM_SAMPLE_COUNTS */
/* Reuse tokens from ARB_map_buffer_alignment */
/* reuse GL_MIN_MAP_BUFFER_ALIGNMENT */
/* Reuse tokens from ARB_shader_atomic_counters */
/* reuse GL_ATOMIC_COUNTER_BUFFER */
/* reuse GL_ATOMIC_COUNTER_BUFFER_BINDING */
/* reuse GL_ATOMIC_COUNTER_BUFFER_START */
/* reuse GL_ATOMIC_COUNTER_BUFFER_SIZE */
/* reuse GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE */
/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS */
/* reuse GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES */
/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER */
/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER */
/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER */
/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER */
/* reuse GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER */
/* reuse GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS */
/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS */
/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS */
/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS */
/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS */
/* reuse GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS */
/* reuse GL_MAX_VERTEX_ATOMIC_COUNTERS */
/* reuse GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS */
/* reuse GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS */
/* reuse GL_MAX_GEOMETRY_ATOMIC_COUNTERS */
/* reuse GL_MAX_FRAGMENT_ATOMIC_COUNTERS */
/* reuse GL_MAX_COMBINED_ATOMIC_COUNTERS */
/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE */
/* reuse GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS */
/* reuse GL_ACTIVE_ATOMIC_COUNTER_BUFFERS */
/* reuse GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX */
/* reuse GL_UNSIGNED_INT_ATOMIC_COUNTER */
/* Reuse tokens from ARB_shader_image_load_store */
/* reuse GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT */
/* reuse GL_ELEMENT_ARRAY_BARRIER_BIT */
/* reuse GL_UNIFORM_BARRIER_BIT */
/* reuse GL_TEXTURE_FETCH_BARRIER_BIT */
/* reuse GL_SHADER_IMAGE_ACCESS_BARRIER_BIT */
/* reuse GL_COMMAND_BARRIER_BIT */
/* reuse GL_PIXEL_BUFFER_BARRIER_BIT */
/* reuse GL_TEXTURE_UPDATE_BARRIER_BIT */
/* reuse GL_BUFFER_UPDATE_BARRIER_BIT */
/* reuse GL_FRAMEBUFFER_BARRIER_BIT */
/* reuse GL_TRANSFORM_FEEDBACK_BARRIER_BIT */
/* reuse GL_ATOMIC_COUNTER_BARRIER_BIT */
/* reuse GL_ALL_BARRIER_BITS */
/* reuse GL_MAX_IMAGE_UNITS */
/* reuse GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS */
/* reuse GL_IMAGE_BINDING_NAME */
/* reuse GL_IMAGE_BINDING_LEVEL */
/* reuse GL_IMAGE_BINDING_LAYERED */
/* reuse GL_IMAGE_BINDING_LAYER */
/* reuse GL_IMAGE_BINDING_ACCESS */
/* reuse GL_IMAGE_1D */
/* reuse GL_IMAGE_2D */
/* reuse GL_IMAGE_3D */
/* reuse GL_IMAGE_2D_RECT */
/* reuse GL_IMAGE_CUBE */
/* reuse GL_IMAGE_BUFFER */
/* reuse GL_IMAGE_1D_ARRAY */
/* reuse GL_IMAGE_2D_ARRAY */
/* reuse GL_IMAGE_CUBE_MAP_ARRAY */
/* reuse GL_IMAGE_2D_MULTISAMPLE */
/* reuse GL_IMAGE_2D_MULTISAMPLE_ARRAY */
/* reuse GL_INT_IMAGE_1D */
/* reuse GL_INT_IMAGE_2D */
/* reuse GL_INT_IMAGE_3D */
/* reuse GL_INT_IMAGE_2D_RECT */
/* reuse GL_INT_IMAGE_CUBE */
/* reuse GL_INT_IMAGE_BUFFER */
/* reuse GL_INT_IMAGE_1D_ARRAY */
/* reuse GL_INT_IMAGE_2D_ARRAY */
/* reuse GL_INT_IMAGE_CUBE_MAP_ARRAY */
/* reuse GL_INT_IMAGE_2D_MULTISAMPLE */
/* reuse GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY */
/* reuse GL_UNSIGNED_INT_IMAGE_1D */
/* reuse GL_UNSIGNED_INT_IMAGE_2D */
/* reuse GL_UNSIGNED_INT_IMAGE_3D */
/* reuse GL_UNSIGNED_INT_IMAGE_2D_RECT */
/* reuse GL_UNSIGNED_INT_IMAGE_CUBE */
/* reuse GL_UNSIGNED_INT_IMAGE_BUFFER */
/* reuse GL_UNSIGNED_INT_IMAGE_1D_ARRAY */
/* reuse GL_UNSIGNED_INT_IMAGE_2D_ARRAY */
/* reuse GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY */
/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE */
/* reuse GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY */
/* reuse GL_MAX_IMAGE_SAMPLES */
/* reuse GL_IMAGE_BINDING_FORMAT */
/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_TYPE */
/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE */
/* reuse GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS */
/* reuse GL_MAX_VERTEX_IMAGE_UNIFORMS */
/* reuse GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS */
/* reuse GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS */
/* reuse GL_MAX_GEOMETRY_IMAGE_UNIFORMS */
/* reuse GL_MAX_FRAGMENT_IMAGE_UNIFORMS */
/* reuse GL_MAX_COMBINED_IMAGE_UNIFORMS */
/* Reuse tokens from ARB_shading_language_packing (none) */
/* Reuse tokens from ARB_texture_storage */
/* reuse GL_TEXTURE_IMMUTABLE_FORMAT */
#endif
#ifndef GL_ARB_multitexture
#define GL_TEXTURE0_ARB 0x84C0
#define GL_TEXTURE1_ARB 0x84C1
@ -2140,6 +2258,143 @@ extern "C" {
#ifndef GL_ARB_shader_stencil_export
#endif
#ifndef GL_ARB_base_instance
#endif
#ifndef GL_ARB_shading_language_420pack
#endif
#ifndef GL_ARB_transform_feedback_instanced
#endif
#ifndef GL_ARB_compressed_texture_pixel_storage
#define GL_UNPACK_COMPRESSED_BLOCK_WIDTH 0x9127
#define GL_UNPACK_COMPRESSED_BLOCK_HEIGHT 0x9128
#define GL_UNPACK_COMPRESSED_BLOCK_DEPTH 0x9129
#define GL_UNPACK_COMPRESSED_BLOCK_SIZE 0x912A
#define GL_PACK_COMPRESSED_BLOCK_WIDTH 0x912B
#define GL_PACK_COMPRESSED_BLOCK_HEIGHT 0x912C
#define GL_PACK_COMPRESSED_BLOCK_DEPTH 0x912D
#define GL_PACK_COMPRESSED_BLOCK_SIZE 0x912E
#endif
#ifndef GL_ARB_conservative_depth
#endif
#ifndef GL_ARB_internalformat_query
#define GL_NUM_SAMPLE_COUNTS 0x9380
#endif
#ifndef GL_ARB_map_buffer_alignment
#define GL_MIN_MAP_BUFFER_ALIGNMENT 0x90BC
#endif
#ifndef GL_ARB_shader_atomic_counters
#define GL_ATOMIC_COUNTER_BUFFER 0x92C0
#define GL_ATOMIC_COUNTER_BUFFER_BINDING 0x92C1
#define GL_ATOMIC_COUNTER_BUFFER_START 0x92C2
#define GL_ATOMIC_COUNTER_BUFFER_SIZE 0x92C3
#define GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE 0x92C4
#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS 0x92C5
#define GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES 0x92C6
#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER 0x92C7
#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER 0x92C8
#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER 0x92C9
#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER 0x92CA
#define GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER 0x92CB
#define GL_MAX_VERTEX_ATOMIC_COUNTER_BUFFERS 0x92CC
#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTER_BUFFERS 0x92CD
#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTER_BUFFERS 0x92CE
#define GL_MAX_GEOMETRY_ATOMIC_COUNTER_BUFFERS 0x92CF
#define GL_MAX_FRAGMENT_ATOMIC_COUNTER_BUFFERS 0x92D0
#define GL_MAX_COMBINED_ATOMIC_COUNTER_BUFFERS 0x92D1
#define GL_MAX_VERTEX_ATOMIC_COUNTERS 0x92D2
#define GL_MAX_TESS_CONTROL_ATOMIC_COUNTERS 0x92D3
#define GL_MAX_TESS_EVALUATION_ATOMIC_COUNTERS 0x92D4
#define GL_MAX_GEOMETRY_ATOMIC_COUNTERS 0x92D5
#define GL_MAX_FRAGMENT_ATOMIC_COUNTERS 0x92D6
#define GL_MAX_COMBINED_ATOMIC_COUNTERS 0x92D7
#define GL_MAX_ATOMIC_COUNTER_BUFFER_SIZE 0x92D8
#define GL_MAX_ATOMIC_COUNTER_BUFFER_BINDINGS 0x92DC
#define GL_ACTIVE_ATOMIC_COUNTER_BUFFERS 0x92D9
#define GL_UNIFORM_ATOMIC_COUNTER_BUFFER_INDEX 0x92DA
#define GL_UNSIGNED_INT_ATOMIC_COUNTER 0x92DB
#endif
#ifndef GL_ARB_shader_image_load_store
#define GL_VERTEX_ATTRIB_ARRAY_BARRIER_BIT 0x00000001
#define GL_ELEMENT_ARRAY_BARRIER_BIT 0x00000002
#define GL_UNIFORM_BARRIER_BIT 0x00000004
#define GL_TEXTURE_FETCH_BARRIER_BIT 0x00000008
#define GL_SHADER_IMAGE_ACCESS_BARRIER_BIT 0x00000020
#define GL_COMMAND_BARRIER_BIT 0x00000040
#define GL_PIXEL_BUFFER_BARRIER_BIT 0x00000080
#define GL_TEXTURE_UPDATE_BARRIER_BIT 0x00000100
#define GL_BUFFER_UPDATE_BARRIER_BIT 0x00000200
#define GL_FRAMEBUFFER_BARRIER_BIT 0x00000400
#define GL_TRANSFORM_FEEDBACK_BARRIER_BIT 0x00000800
#define GL_ATOMIC_COUNTER_BARRIER_BIT 0x00001000
#define GL_ALL_BARRIER_BITS 0xFFFFFFFF
#define GL_MAX_IMAGE_UNITS 0x8F38
#define GL_MAX_COMBINED_IMAGE_UNITS_AND_FRAGMENT_OUTPUTS 0x8F39
#define GL_IMAGE_BINDING_NAME 0x8F3A
#define GL_IMAGE_BINDING_LEVEL 0x8F3B
#define GL_IMAGE_BINDING_LAYERED 0x8F3C
#define GL_IMAGE_BINDING_LAYER 0x8F3D
#define GL_IMAGE_BINDING_ACCESS 0x8F3E
#define GL_IMAGE_1D 0x904C
#define GL_IMAGE_2D 0x904D
#define GL_IMAGE_3D 0x904E
#define GL_IMAGE_2D_RECT 0x904F
#define GL_IMAGE_CUBE 0x9050
#define GL_IMAGE_BUFFER 0x9051
#define GL_IMAGE_1D_ARRAY 0x9052
#define GL_IMAGE_2D_ARRAY 0x9053
#define GL_IMAGE_CUBE_MAP_ARRAY 0x9054
#define GL_IMAGE_2D_MULTISAMPLE 0x9055
#define GL_IMAGE_2D_MULTISAMPLE_ARRAY 0x9056
#define GL_INT_IMAGE_1D 0x9057
#define GL_INT_IMAGE_2D 0x9058
#define GL_INT_IMAGE_3D 0x9059
#define GL_INT_IMAGE_2D_RECT 0x905A
#define GL_INT_IMAGE_CUBE 0x905B
#define GL_INT_IMAGE_BUFFER 0x905C
#define GL_INT_IMAGE_1D_ARRAY 0x905D
#define GL_INT_IMAGE_2D_ARRAY 0x905E
#define GL_INT_IMAGE_CUBE_MAP_ARRAY 0x905F
#define GL_INT_IMAGE_2D_MULTISAMPLE 0x9060
#define GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x9061
#define GL_UNSIGNED_INT_IMAGE_1D 0x9062
#define GL_UNSIGNED_INT_IMAGE_2D 0x9063
#define GL_UNSIGNED_INT_IMAGE_3D 0x9064
#define GL_UNSIGNED_INT_IMAGE_2D_RECT 0x9065
#define GL_UNSIGNED_INT_IMAGE_CUBE 0x9066
#define GL_UNSIGNED_INT_IMAGE_BUFFER 0x9067
#define GL_UNSIGNED_INT_IMAGE_1D_ARRAY 0x9068
#define GL_UNSIGNED_INT_IMAGE_2D_ARRAY 0x9069
#define GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY 0x906A
#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE 0x906B
#define GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY 0x906C
#define GL_MAX_IMAGE_SAMPLES 0x906D
#define GL_IMAGE_BINDING_FORMAT 0x906E
#define GL_IMAGE_FORMAT_COMPATIBILITY_TYPE 0x90C7
#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_SIZE 0x90C8
#define GL_IMAGE_FORMAT_COMPATIBILITY_BY_CLASS 0x90C9
#define GL_MAX_VERTEX_IMAGE_UNIFORMS 0x90CA
#define GL_MAX_TESS_CONTROL_IMAGE_UNIFORMS 0x90CB
#define GL_MAX_TESS_EVALUATION_IMAGE_UNIFORMS 0x90CC
#define GL_MAX_GEOMETRY_IMAGE_UNIFORMS 0x90CD
#define GL_MAX_FRAGMENT_IMAGE_UNIFORMS 0x90CE
#define GL_MAX_COMBINED_IMAGE_UNIFORMS 0x90CF
#endif
#ifndef GL_ARB_shading_language_packing
#endif
#ifndef GL_ARB_texture_storage
#define GL_TEXTURE_IMMUTABLE_FORMAT 0x912F
#endif
#ifndef GL_EXT_abgr
#define GL_ABGR_EXT 0x8000
#endif
@ -5032,6 +5287,32 @@ extern "C" {
#define GL_SKIP_DECODE_EXT 0x8A4A
#endif
#ifndef GL_NV_texture_multisample
#define GL_TEXTURE_COVERAGE_SAMPLES_NV 0x9045
#define GL_TEXTURE_COLOR_SAMPLES_NV 0x9046
#endif
#ifndef GL_AMD_blend_minmax_factor
#define GL_FACTOR_MIN_AMD 0x901C
#define GL_FACTOR_MAX_AMD 0x901D
#endif
#ifndef GL_AMD_sample_positions
#define GL_SUBSAMPLE_DISTANCE_AMD 0x883F
#endif
#ifndef GL_EXT_x11_sync_object
#define GL_SYNC_X11_FENCE_EXT 0x90E1
#endif
#ifndef GL_AMD_multi_draw_indirect
#endif
#ifndef GL_EXT_framebuffer_multisample_blit_scaled
#define GL_SCALED_RESOLVE_FASTEST_EXT 0x90BA
#define GL_SCALED_RESOLVE_NICEST_EXT 0x90BB
#endif
/*************************************************************/
@ -5891,7 +6172,7 @@ typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB,
#ifndef GL_VERSION_4_1
#define GL_VERSION_4_1 1
/* OpenGL 4.1 also reuses entry points from these extensions: */
/* OpenGL 4.1 reuses entry points from these extensions: */
/* ARB_ES2_compatibility */
/* ARB_get_program_binary */
/* ARB_separate_shader_objects */
@ -5900,6 +6181,22 @@ typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB,
/* ARB_viewport_array */
#endif
#ifndef GL_VERSION_4_2
#define GL_VERSION_4_2 1
/* OpenGL 4.2 reuses entry points from these extensions: */
/* ARB_base_instance */
/* ARB_shading_language_420pack (no entry points) */
/* ARB_transform_feedback_instanced */
/* ARB_compressed_texture_pixel_storage (no entry points) */
/* ARB_conservative_depth (no entry points) */
/* ARB_internalformat_query */
/* ARB_map_buffer_alignment (no entry points) */
/* ARB_shader_atomic_counters */
/* ARB_shader_image_load_store */
/* ARB_shading_language_packing (no entry points) */
/* ARB_texture_storage */
#endif
#ifndef GL_ARB_multitexture
#define GL_ARB_multitexture 1
#ifdef GL_GLEXT_PROTOTYPES
@ -6825,6 +7122,10 @@ typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERFVPROC) (GLuint sampler, GLenum
typedef void (APIENTRYP PFNGLGETSAMPLERPARAMETERIUIVPROC) (GLuint sampler, GLenum pname, GLuint *params);
#endif
#ifndef GL_ARB_shader_bit_encoding
#define GL_ARB_shader_bit_encoding 1
#endif
#ifndef GL_ARB_texture_rgb10_a2ui
#define GL_ARB_texture_rgb10_a2ui 1
#endif
@ -7331,6 +7632,92 @@ typedef void (APIENTRYP PFNGLGETNUNIFORMDVARBPROC) (GLuint program, GLint locati
#define GL_ARB_shader_stencil_export 1
#endif
#ifndef GL_ARB_base_instance
#define GL_ARB_base_instance 1
#ifdef GL_GLEXT_PROTOTYPES
GLAPI void APIENTRY glDrawArraysInstancedBaseInstance (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance);
GLAPI void APIENTRY glDrawElementsInstancedBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance);
GLAPI void APIENTRY glDrawElementsInstancedBaseVertexBaseInstance (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance);
#endif /* GL_GLEXT_PROTOTYPES */
typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount, GLuint baseinstance);
typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLuint baseinstance);
typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXBASEINSTANCEPROC) (GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount, GLint basevertex, GLuint baseinstance);
#endif
#ifndef GL_ARB_shading_language_420pack
#define GL_ARB_shading_language_420pack 1
#endif
#ifndef GL_ARB_transform_feedback_instanced
#define GL_ARB_transform_feedback_instanced 1
#ifdef GL_GLEXT_PROTOTYPES
GLAPI void APIENTRY glDrawTransformFeedbackInstanced (GLenum mode, GLuint id, GLsizei primcount);
GLAPI void APIENTRY glDrawTransformFeedbackStreamInstanced (GLenum mode, GLuint id, GLuint stream, GLsizei primcount);
#endif /* GL_GLEXT_PROTOTYPES */
typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKINSTANCEDPROC) (GLenum mode, GLuint id, GLsizei primcount);
typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKSTREAMINSTANCEDPROC) (GLenum mode, GLuint id, GLuint stream, GLsizei primcount);
#endif
#ifndef GL_ARB_compressed_texture_pixel_storage
#define GL_ARB_compressed_texture_pixel_storage 1
#endif
#ifndef GL_ARB_conservative_depth
#define GL_ARB_conservative_depth 1
#endif
#ifndef GL_ARB_internalformat_query
#define GL_ARB_internalformat_query 1
#ifdef GL_GLEXT_PROTOTYPES
GLAPI void APIENTRY glGetInternalformativ (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params);
#endif /* GL_GLEXT_PROTOTYPES */
typedef void (APIENTRYP PFNGLGETINTERNALFORMATIVPROC) (GLenum target, GLenum internalformat, GLenum pname, GLsizei bufSize, GLint *params);
#endif
#ifndef GL_ARB_map_buffer_alignment
#define GL_ARB_map_buffer_alignment 1
#endif
#ifndef GL_ARB_shader_atomic_counters
#define GL_ARB_shader_atomic_counters 1
#ifdef GL_GLEXT_PROTOTYPES
GLAPI void APIENTRY glGetActiveAtomicCounterBufferiv (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params);
#endif /* GL_GLEXT_PROTOTYPES */
typedef void (APIENTRYP PFNGLGETACTIVEATOMICCOUNTERBUFFERIVPROC) (GLuint program, GLuint bufferIndex, GLenum pname, GLint *params);
#endif
#ifndef GL_ARB_shader_image_load_store
#define GL_ARB_shader_image_load_store 1
#ifdef GL_GLEXT_PROTOTYPES
GLAPI void APIENTRY glBindImageTexture (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format);
GLAPI void APIENTRY glMemoryBarrier (GLbitfield barriers);
#endif /* GL_GLEXT_PROTOTYPES */
typedef void (APIENTRYP PFNGLBINDIMAGETEXTUREPROC) (GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format);
typedef void (APIENTRYP PFNGLMEMORYBARRIERPROC) (GLbitfield barriers);
#endif
#ifndef GL_ARB_shading_language_packing
#define GL_ARB_shading_language_packing 1
#endif
#ifndef GL_ARB_texture_storage
#define GL_ARB_texture_storage 1
#ifdef GL_GLEXT_PROTOTYPES
GLAPI void APIENTRY glTexStorage1D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
GLAPI void APIENTRY glTexStorage2D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
GLAPI void APIENTRY glTexStorage3D (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
GLAPI void APIENTRY glTextureStorage1DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
GLAPI void APIENTRY glTextureStorage2DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
GLAPI void APIENTRY glTextureStorage3DEXT (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
#endif /* GL_GLEXT_PROTOTYPES */
typedef void (APIENTRYP PFNGLTEXSTORAGE1DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
typedef void (APIENTRYP PFNGLTEXSTORAGE2DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
typedef void (APIENTRYP PFNGLTEXSTORAGE3DPROC) (GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
typedef void (APIENTRYP PFNGLTEXTURESTORAGE1DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width);
typedef void (APIENTRYP PFNGLTEXTURESTORAGE2DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height);
typedef void (APIENTRYP PFNGLTEXTURESTORAGE3DEXTPROC) (GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth);
#endif
#ifndef GL_EXT_abgr
#define GL_EXT_abgr 1
#endif
@ -11041,6 +11428,58 @@ typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, cons
#define GL_EXT_texture_sRGB_decode 1
#endif
#ifndef GL_NV_texture_multisample
#define GL_NV_texture_multisample 1
#ifdef GL_GLEXT_PROTOTYPES
GLAPI void APIENTRY glTexImage2DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
GLAPI void APIENTRY glTexImage3DMultisampleCoverageNV (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
GLAPI void APIENTRY glTextureImage2DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
GLAPI void APIENTRY glTextureImage3DMultisampleNV (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
GLAPI void APIENTRY glTextureImage2DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
GLAPI void APIENTRY glTextureImage3DMultisampleCoverageNV (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
#endif /* GL_GLEXT_PROTOTYPES */
typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLENVPROC) (GLuint texture, GLenum target, GLsizei samples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLboolean fixedSampleLocations);
typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DMULTISAMPLECOVERAGENVPROC) (GLuint texture, GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedSampleLocations);
#endif
#ifndef GL_AMD_blend_minmax_factor
#define GL_AMD_blend_minmax_factor 1
#endif
#ifndef GL_AMD_sample_positions
#define GL_AMD_sample_positions 1
#ifdef GL_GLEXT_PROTOTYPES
GLAPI void APIENTRY glSetMultisamplefvAMD (GLenum pname, GLuint index, const GLfloat *val);
#endif /* GL_GLEXT_PROTOTYPES */
typedef void (APIENTRYP PFNGLSETMULTISAMPLEFVAMDPROC) (GLenum pname, GLuint index, const GLfloat *val);
#endif
#ifndef GL_EXT_x11_sync_object
#define GL_EXT_x11_sync_object 1
#ifdef GL_GLEXT_PROTOTYPES
GLAPI GLsync APIENTRY glImportSyncEXT (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags);
#endif /* GL_GLEXT_PROTOTYPES */
typedef GLsync (APIENTRYP PFNGLIMPORTSYNCEXTPROC) (GLenum external_sync_type, GLintptr external_sync, GLbitfield flags);
#endif
#ifndef GL_AMD_multi_draw_indirect
#define GL_AMD_multi_draw_indirect 1
#ifdef GL_GLEXT_PROTOTYPES
GLAPI void APIENTRY glMultiDrawArraysIndirectAMD (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride);
GLAPI void APIENTRY glMultiDrawElementsIndirectAMD (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride);
#endif /* GL_GLEXT_PROTOTYPES */
typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSINDIRECTAMDPROC) (GLenum mode, const GLvoid *indirect, GLsizei primcount, GLsizei stride);
typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSINDIRECTAMDPROC) (GLenum mode, GLenum type, const GLvoid *indirect, GLsizei primcount, GLsizei stride);
#endif
#ifndef GL_EXT_framebuffer_multisample_blit_scaled
#define GL_EXT_framebuffer_multisample_blit_scaled 1
#endif
#ifdef __cplusplus
}

View File

@ -14,8 +14,6 @@ INCLUDE(CheckCXXSymbolExists)
# include dir
find_path(EGL_INCLUDE_DIR EGL/eglext.h)
CHECK_CXX_SYMBOL_EXISTS(EGL_KHR_create_context "EGL/eglext.h" EGL_GL_CONTEXT_SUPPORT)
# finally the library itself
find_library(libEGL NAMES EGL)
set(EGL_LIBRARIES ${libEGL})

View File

@ -2,20 +2,25 @@
use strict;
use warnings;
use File::Spec;
my @res = qw/convert interlace merge shadeboost tfx/;
my $path = "plugins/GSdx/res";
my $path = File::Spec->catdir("plugins", "GSdx", "res");
foreach my $r (@res) {
glsl2h($path, $r);
glsl2h($path, $r, "glsl");
}
glsl2h($path, "fxaa", "fx");
sub glsl2h {
my $path = shift;
my $glsl = shift;
my $ext = shift;
open(my $GLSL, "<$path/${glsl}.glsl");
open(my $H, ">$path/${glsl}.h");
my $in = File::Spec->catfile($path, "${glsl}.$ext");
my $out = File::Spec->catfile($path, "${glsl}.h");
open(my $GLSL, "<$in") or die;
open(my $H, ">$out") or die;
my $header = <<EOS;
/*
@ -45,7 +50,7 @@ sub glsl2h {
#include "stdafx.h"
extern const char* ${glsl}_glsl =
static const char* ${glsl}_${ext} =
EOS
print $H $header;

View File

@ -10,7 +10,6 @@ endif(NOT TOP_CMAKE_WAS_SOURCED)
set(Output GSdx-0.1.16)
set(CommonFlags
-DOGL_MT_HACK
-D_LINUX
-fno-operator-names
-mpreferred-stack-boundary=2
@ -19,7 +18,6 @@ set(CommonFlags
-Wunused-variable
-std=c++0x
-fno-strict-aliasing
#-DOGL_DEBUG # FIXME remove me when code is ready
)
set(OptimizationFlags
@ -29,7 +27,7 @@ set(OptimizationFlags
# Debug - Build
if(CMAKE_BUILD_TYPE STREQUAL Debug)
add_definitions(${CommonFlags} -DOGL_DEBUG -g -Wall)
add_definitions(${CommonFlags} -D_DEBUG -g -Wall)
endif(CMAKE_BUILD_TYPE STREQUAL Debug)
# Devel - Build
@ -46,7 +44,13 @@ if(XDG_STD)
add_definitions(-DXDG_STD)
endif(XDG_STD)
# Select the EGL API
if(EGL_API AND EGL_FOUND)
add_definitions(-DEGL_API)
endif()
set(GSdxSources
GLLoader.cpp
GPU.cpp
GPUDrawScanline.cpp
GPUDrawScanlineCodeGenerator.cpp
@ -105,6 +109,8 @@ set(GSdxSources
GSVector.cpp
GSVertexTrace.cpp
GSWnd.cpp
GSWndOGL.cpp
GSWndEGL.cpp
GSdx.cpp
stdafx.cpp
)
@ -166,6 +172,8 @@ set(GSdxHeaders
GSVertexSW.h
GSVertexTrace.h
GSWnd.h
GSWndOGL.h
GSWndEGL.h
GSdx.h
stdafx.h
xbyak/xbyak.h
@ -179,8 +187,10 @@ include_directories(.)
add_library(${Output} SHARED ${GSdxSources} ${GSdxHeaders})
target_link_libraries(${Output} ${X11_LIBRARIES})
target_link_libraries(${Output} ${GLEW_LIBRARY})
target_link_libraries(${Output} ${OPENGL_LIBRARIES})
if(EGL_API AND EGL_FOUND)
target_link_libraries(${Output} ${EGL_LIBRARIES})
endif()
if(Linux)
target_link_libraries(${Output} ${GTK2_LIBRARIES})
@ -193,41 +203,24 @@ endif(NOT USER_CMAKE_LD_FLAGS STREQUAL "")
if(PACKAGE_MODE)
install(TARGETS ${Output} DESTINATION ${PLUGIN_DIR})
foreach(glsl IN ITEMS convert.glsl interlace.glsl merge.glsl tfx.glsl shadeboost.glsl)
foreach(glsl IN ITEMS convert.glsl interlace.glsl merge.glsl tfx.glsl shadeboost.glsl fxaa.fx)
install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/${glsl} DESTINATION ${GLSL_SHADER_DIR})
endforeach(glsl IN ITEMS convert.glsl interlace.glsl merge.glsl tfx.glsl shadeboost.glsl)
endforeach()
else(PACKAGE_MODE)
install(TARGETS ${Output} DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins)
foreach(glsl IN ITEMS convert.glsl interlace.glsl merge.glsl tfx.glsl shadeboost.glsl)
foreach(glsl IN ITEMS convert.glsl interlace.glsl merge.glsl tfx.glsl shadeboost.glsl fxaa.fx)
install(FILES ${PROJECT_SOURCE_DIR}/plugins/GSdx/res/${glsl} DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins)
endforeach(glsl IN ITEMS convert.glsl interlace.glsl merge.glsl tfx.glsl shadeboost.glsl)
endforeach()
endif(PACKAGE_MODE)
################################### Replay Loader
if(BUILD_REPLAY_LOADERS)
set(Replay pcsx2_GSReplayLoader)
set(Static GSdx-static)
# We can have separate option for gsdx inside the player. It will only
# cost a 2nd rebuild of gsdx...
#add_definitions(${CommonFlags} ${OptimizationFlags} -W)
add_library(${Static} STATIC ${GSdxSources} ${GSdxHeaders})
add_executable(${Replay} linux_replay.cpp)
target_link_libraries(${Static} ${OPENGL_LIBRARIES})
target_link_libraries(${Static} ${X11_LIBRARIES})
target_link_libraries(${Static} ${GLEW_LIBRARY})
target_link_libraries(${Static} ${GTK2_LIBRARIES})
target_link_libraries(${Replay} ${Static})
# Warning others lib must be linked after GSdx...
target_link_libraries(${Replay} ${OPENGL_LIBRARIES})
target_link_libraries(${Replay} ${X11_LIBRARIES})
target_link_libraries(${Replay} ${GLEW_LIBRARY})
target_link_libraries(${Replay} ${GTK2_LIBRARIES})
target_link_libraries(${Replay} ${LIBC_LIBRARIES})
if(NOT USER_CMAKE_LD_FLAGS STREQUAL "")
target_link_libraries(${Replay} "${USER_CMAKE_LD_FLAGS}")

275
plugins/GSdx/GLLoader.cpp Normal file
View File

@ -0,0 +1,275 @@
/*
* Copyright (C) 2011-2013 Gregory hainaut
* Copyright (C) 2007-2009 Gabest
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#include "stdafx.h"
#include "GLLoader.h"
#include "GSdx.h"
PFNGLACTIVETEXTUREPROC gl_ActiveTexture = NULL;
PFNGLBLENDCOLORPROC gl_BlendColor = NULL;
PFNGLATTACHSHADERPROC gl_AttachShader = NULL;
PFNGLBINDBUFFERPROC gl_BindBuffer = NULL;
PFNGLBINDBUFFERBASEPROC gl_BindBufferBase = NULL;
PFNGLBINDFRAGDATALOCATIONINDEXEDPROC gl_BindFragDataLocationIndexed = NULL;
PFNGLBINDFRAMEBUFFERPROC gl_BindFramebuffer = NULL;
PFNGLBINDPROGRAMPIPELINEPROC gl_BindProgramPipeline = NULL;
PFNGLBINDSAMPLERPROC gl_BindSampler = NULL;
PFNGLBINDVERTEXARRAYPROC gl_BindVertexArray = NULL;
PFNGLBLENDEQUATIONSEPARATEPROC gl_BlendEquationSeparate = NULL;
PFNGLBLENDFUNCSEPARATEPROC gl_BlendFuncSeparate = NULL;
PFNGLBLITFRAMEBUFFERPROC gl_BlitFramebuffer = NULL;
PFNGLBUFFERDATAPROC gl_BufferData = NULL;
PFNGLCHECKFRAMEBUFFERSTATUSPROC gl_CheckFramebufferStatus = NULL;
PFNGLCLEARBUFFERFVPROC gl_ClearBufferfv = NULL;
PFNGLCLEARBUFFERIVPROC gl_ClearBufferiv = NULL;
PFNGLCOMPILESHADERPROC gl_CompileShader = NULL;
PFNGLCOPYIMAGESUBDATANVPROC gl_CopyImageSubDataNV = NULL;
PFNGLCREATEPROGRAMPROC gl_CreateProgram = NULL;
PFNGLCREATESHADERPROC gl_CreateShader = NULL;
PFNGLCREATESHADERPROGRAMVPROC gl_CreateShaderProgramv = NULL;
PFNGLDELETEBUFFERSPROC gl_DeleteBuffers = NULL;
PFNGLDELETEFRAMEBUFFERSPROC gl_DeleteFramebuffers = NULL;
PFNGLDELETEPROGRAMPROC gl_DeleteProgram = NULL;
PFNGLDELETEPROGRAMPIPELINESPROC gl_DeleteProgramPipelines = NULL;
PFNGLDELETESAMPLERSPROC gl_DeleteSamplers = NULL;
PFNGLDELETESHADERPROC gl_DeleteShader = NULL;
PFNGLDELETEVERTEXARRAYSPROC gl_DeleteVertexArrays = NULL;
PFNGLDETACHSHADERPROC gl_DetachShader = NULL;
PFNGLDRAWBUFFERSPROC gl_DrawBuffers = NULL;
PFNGLDRAWELEMENTSBASEVERTEXPROC gl_DrawElementsBaseVertex = NULL;
PFNGLENABLEVERTEXATTRIBARRAYPROC gl_EnableVertexAttribArray = NULL;
PFNGLFRAMEBUFFERRENDERBUFFERPROC gl_FramebufferRenderbuffer = NULL;
PFNGLFRAMEBUFFERTEXTURE2DPROC gl_FramebufferTexture2D = NULL;
PFNGLGENBUFFERSPROC gl_GenBuffers = NULL;
PFNGLGENFRAMEBUFFERSPROC gl_GenFramebuffers = NULL;
PFNGLGENPROGRAMPIPELINESPROC gl_GenProgramPipelines = NULL;
PFNGLGENSAMPLERSPROC gl_GenSamplers = NULL;
PFNGLGENVERTEXARRAYSPROC gl_GenVertexArrays = NULL;
PFNGLGETBUFFERPARAMETERIVPROC gl_GetBufferParameteriv = NULL;
PFNGLGETDEBUGMESSAGELOGARBPROC gl_GetDebugMessageLogARB = NULL;
PFNGLGETFRAGDATAINDEXPROC gl_GetFragDataIndex = NULL;
PFNGLGETFRAGDATALOCATIONPROC gl_GetFragDataLocation = NULL;
PFNGLGETPROGRAMINFOLOGPROC gl_GetProgramInfoLog = NULL;
PFNGLGETPROGRAMIVPROC gl_GetProgramiv = NULL;
PFNGLGETSHADERIVPROC gl_GetShaderiv = NULL;
PFNGLGETSTRINGIPROC gl_GetStringi = NULL;
PFNGLISFRAMEBUFFERPROC gl_IsFramebuffer = NULL;
PFNGLLINKPROGRAMPROC gl_LinkProgram = NULL;
PFNGLMAPBUFFERPROC gl_MapBuffer = NULL;
PFNGLMAPBUFFERRANGEPROC gl_MapBufferRange = NULL;
PFNGLPROGRAMPARAMETERIPROC gl_ProgramParameteri = NULL;
PFNGLSAMPLERPARAMETERFPROC gl_SamplerParameterf = NULL;
PFNGLSAMPLERPARAMETERIPROC gl_SamplerParameteri = NULL;
PFNGLSHADERSOURCEPROC gl_ShaderSource = NULL;
PFNGLUNIFORM1IPROC gl_Uniform1i = NULL;
PFNGLUNMAPBUFFERPROC gl_UnmapBuffer = NULL;
PFNGLUSEPROGRAMSTAGESPROC gl_UseProgramStages = NULL;
PFNGLVERTEXATTRIBIPOINTERPROC gl_VertexAttribIPointer = NULL;
PFNGLVERTEXATTRIBPOINTERPROC gl_VertexAttribPointer = NULL;
PFNGLTEXSTORAGE2DPROC gl_TexStorage2D = NULL;
PFNGLBUFFERSUBDATAPROC gl_BufferSubData = NULL;
// NO GL4.1
PFNGLUSEPROGRAMPROC gl_UseProgram = NULL;
PFNGLGETSHADERINFOLOGPROC gl_GetShaderInfoLog = NULL;
PFNGLPROGRAMUNIFORM1IPROC gl_ProgramUniform1i = NULL;
// NO GL4.2
PFNGLGETUNIFORMBLOCKINDEXPROC gl_GetUniformBlockIndex = NULL;
PFNGLUNIFORMBLOCKBINDINGPROC gl_UniformBlockBinding = NULL;
PFNGLGETUNIFORMLOCATIONPROC gl_GetUniformLocation = NULL;
namespace GLLoader {
bool fglrx_buggy_driver = false;
bool found_GL_ARB_separate_shader_objects = false;
bool found_GL_ARB_shading_language_420pack = false;
bool found_GL_ARB_texture_storage = false;
bool found_geometry_shader = true;
bool found_GL_NV_copy_image = false;
bool found_GL_ARB_copy_image = false;
bool found_only_gl30 = false;
bool check_gl_version(uint32 major, uint32 minor) {
const GLubyte* s = glGetString(GL_VERSION);
if (s == NULL) return false;
const char* vendor = (const char*)glGetString(GL_VENDOR);
fprintf(stderr, "Supported Opengl version: %s on GPU: %s. Vendor: %s\n", s, glGetString(GL_RENDERER), vendor);
// Name change but driver is still bad!
if (strstr(vendor, "ATI") || strstr(vendor, "Advanced Micro Devices"))
fglrx_buggy_driver = true;
GLuint dot = 0;
while (s[dot] != '\0' && s[dot] != '.') dot++;
if (dot == 0) return false;
GLuint major_gl = s[dot-1]-'0';
GLuint minor_gl = s[dot+1]-'0';
if ( (major_gl < 3) || ( major_gl == 3 && minor_gl < 2 ) ) {
fprintf(stderr, "Geometry shaders are not supported. Required openGL3.2\n");
found_geometry_shader = false;
}
if (theApp.GetConfig("override_geometry_shader", -1) != -1) {
found_geometry_shader = !!theApp.GetConfig("override_geometry_shader", -1);
fprintf(stderr, "Override geometry shaders detection\n");
}
if ( (major_gl == 3) && minor_gl < 3) {
// Opensource driver spotted
found_only_gl30 = true;
}
if ( (major_gl < major) || ( major_gl == major && minor_gl < minor ) ) {
fprintf(stderr, "OPENGL %d.%d is not supported\n", major, minor);
return false;
}
return true;
}
void init_gl_function() {
GL_LOADFN(gl_ActiveTexture, glActiveTexture);
GL_LOADFN(gl_BlendColor, glBlendColor);
GL_LOADFN(gl_AttachShader, glAttachShader);
GL_LOADFN(gl_BindBuffer, glBindBuffer);
GL_LOADFN(gl_BindBufferBase, glBindBufferBase);
GL_LOADFN(gl_BindFragDataLocationIndexed, glBindFragDataLocationIndexed);
GL_LOADFN(gl_BindFramebuffer, glBindFramebuffer);
GL_LOADFN(gl_BindProgramPipeline, glBindProgramPipeline);
GL_LOADFN(gl_BindSampler, glBindSampler);
GL_LOADFN(gl_BindVertexArray, glBindVertexArray);
GL_LOADFN(gl_BlendEquationSeparate, glBlendEquationSeparate);
GL_LOADFN(gl_BlendFuncSeparate, glBlendFuncSeparate);
GL_LOADFN(gl_BlitFramebuffer, glBlitFramebuffer);
GL_LOADFN(gl_BufferData, glBufferData);
GL_LOADFN(gl_CheckFramebufferStatus, glCheckFramebufferStatus);
GL_LOADFN(gl_ClearBufferfv, glClearBufferfv);
GL_LOADFN(gl_ClearBufferiv, glClearBufferiv);
GL_LOADFN(gl_CompileShader, glCompileShader);
GL_LOADFN(gl_CopyImageSubDataNV, glCopyImageSubDataNV);
GL_LOADFN(gl_CreateProgram, glCreateProgram);
GL_LOADFN(gl_CreateShader, glCreateShader);
GL_LOADFN(gl_CreateShaderProgramv, glCreateShaderProgramv);
GL_LOADFN(gl_DeleteBuffers, glDeleteBuffers);
GL_LOADFN(gl_DeleteFramebuffers, glDeleteFramebuffers);
GL_LOADFN(gl_DeleteProgram, glDeleteProgram);
GL_LOADFN(gl_DeleteProgramPipelines, glDeleteProgramPipelines);
GL_LOADFN(gl_DeleteSamplers, glDeleteSamplers);
GL_LOADFN(gl_DeleteShader, glDeleteShader);
GL_LOADFN(gl_DeleteVertexArrays, glDeleteVertexArrays);
GL_LOADFN(gl_DetachShader, glDetachShader);
GL_LOADFN(gl_DrawBuffers, glDrawBuffers);
GL_LOADFN(gl_DrawElementsBaseVertex, glDrawElementsBaseVertex);
GL_LOADFN(gl_EnableVertexAttribArray, glEnableVertexAttribArray);
GL_LOADFN(gl_FramebufferRenderbuffer, glFramebufferRenderbuffer);
GL_LOADFN(gl_FramebufferTexture2D, glFramebufferTexture2D);
GL_LOADFN(gl_GenBuffers, glGenBuffers);
GL_LOADFN(gl_GenFramebuffers, glGenFramebuffers);
GL_LOADFN(gl_GenProgramPipelines, glGenProgramPipelines);
GL_LOADFN(gl_GenSamplers, glGenSamplers);
GL_LOADFN(gl_GenVertexArrays, glGenVertexArrays);
GL_LOADFN(gl_GetBufferParameteriv, glGetBufferParameteriv);
GL_LOADFN(gl_GetDebugMessageLogARB, glGetDebugMessageLogARB);
GL_LOADFN(gl_GetFragDataIndex, glGetFragDataIndex);
GL_LOADFN(gl_GetFragDataLocation, glGetFragDataLocation);
GL_LOADFN(gl_GetProgramInfoLog, glGetProgramInfoLog);
GL_LOADFN(gl_GetProgramiv, glGetProgramiv);
GL_LOADFN(gl_GetShaderiv, glGetShaderiv);
GL_LOADFN(gl_GetStringi, glGetStringi);
GL_LOADFN(gl_IsFramebuffer, glIsFramebuffer);
GL_LOADFN(gl_LinkProgram, glLinkProgram);
GL_LOADFN(gl_MapBuffer, glMapBuffer);
GL_LOADFN(gl_MapBufferRange, glMapBufferRange);
GL_LOADFN(gl_ProgramParameteri, glProgramParameteri);
GL_LOADFN(gl_SamplerParameterf, glSamplerParameterf);
GL_LOADFN(gl_SamplerParameteri, glSamplerParameteri);
GL_LOADFN(gl_ShaderSource, glShaderSource);
GL_LOADFN(gl_Uniform1i, glUniform1i);
GL_LOADFN(gl_UnmapBuffer, glUnmapBuffer);
GL_LOADFN(gl_UseProgramStages, glUseProgramStages);
GL_LOADFN(gl_VertexAttribIPointer, glVertexAttribIPointer);
GL_LOADFN(gl_VertexAttribPointer, glVertexAttribPointer);
GL_LOADFN(gl_TexStorage2D, glTexStorage2D);
GL_LOADFN(gl_BufferSubData, glBufferSubData);
// NO GL4.1
GL_LOADFN(gl_UseProgram, glUseProgram);
GL_LOADFN(gl_GetShaderInfoLog, glGetShaderInfoLog);
GL_LOADFN(gl_ProgramUniform1i, glProgramUniform1i);
// NO GL4.2
GL_LOADFN(gl_GetUniformBlockIndex, glGetUniformBlockIndex);
GL_LOADFN(gl_UniformBlockBinding, glUniformBlockBinding);
GL_LOADFN(gl_GetUniformLocation, glGetUniformLocation);
}
bool check_gl_supported_extension() {
int max_ext = 0;
glGetIntegerv(GL_NUM_EXTENSIONS, &max_ext);
fprintf(stderr, "DEBUG: check_gl_supported_extension\n");
if (gl_GetStringi && max_ext) {
for (GLint i = 0; i < max_ext; i++) {
string ext((const char*)gl_GetStringi(GL_EXTENSIONS, i));
if (ext.compare("GL_ARB_separate_shader_objects") == 0) {
if (!fglrx_buggy_driver) found_GL_ARB_separate_shader_objects = true;
else fprintf(stderr, "Buggy driver detected, GL_ARB_separate_shader_objects will be disabled\n");
}
if (ext.compare("GL_ARB_shading_language_420pack") == 0) found_GL_ARB_shading_language_420pack = true;
if (ext.compare("GL_ARB_texture_storage") == 0) found_GL_ARB_texture_storage = true;
if (ext.compare("GL_NV_copy_image") == 0) found_GL_NV_copy_image = true;
// Replace previous extensions (when driver will be updated)
if (ext.compare("GL_ARB_copy_image") == 0) found_GL_ARB_copy_image = true;
}
}
if (!found_GL_ARB_separate_shader_objects) {
fprintf(stderr, "GL_ARB_separate_shader_objects is not supported\n");
}
if (!found_GL_ARB_shading_language_420pack) {
fprintf(stderr, "GL_ARB_shading_language_420pack is not supported\n");
}
if (!found_GL_ARB_texture_storage) {
fprintf(stderr, "GL_ARB_texture_storage is not supported\n");
return false;
}
if (theApp.GetConfig("override_GL_ARB_shading_language_420pack", -1) != -1) {
found_GL_ARB_shading_language_420pack = !!theApp.GetConfig("override_GL_ARB_shading_language_420pack", -1);
fprintf(stderr, "Override GL_ARB_shading_language_420pack detection\n");
}
if (theApp.GetConfig("override_GL_ARB_separate_shader_objects", -1) != -1) {
found_GL_ARB_separate_shader_objects = !!theApp.GetConfig("override_GL_ARB_separate_shader_objects", -1);
fprintf(stderr, "Override GL_ARB_separate_shader_objects detection\n");
}
if (theApp.GetConfig("ovveride_GL_ARB_copy_image", -1) != -1) {
// Same extension so override both
found_GL_ARB_copy_image = !!theApp.GetConfig("override_GL_ARB_copy_image", -1);
found_GL_NV_copy_image = !!theApp.GetConfig("override_GL_ARB_copy_image", -1);
fprintf(stderr, "Override GL_ARB_copy_image detection\n");
fprintf(stderr, "Override GL_NV_copy_image detection\n");
}
return true;
}
}

138
plugins/GSdx/GLLoader.h Normal file
View File

@ -0,0 +1,138 @@
/*
* Copyright (C) 2011-2013 Gregory hainaut
* Copyright (C) 2007-2009 Gabest
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#pragma once
#ifdef _LINUX
#include <GL/glx.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
#endif
#ifdef _WINDOWS
#define GL_LOADFN(name, glName) { \
if( (*(void**)&name = (void*)wglGetProcAddress(#glName)) == NULL ) { \
fprintf(stderr,"Failed to find %s\n", #glName); \
} \
}
#else
#ifdef EGL_API
#define GL_LOADFN(name, glName) { \
if( (*(void**)&name = (void*)eglGetProcAddress(#glName)) == NULL ) { \
fprintf(stderr,"Failed to find %s\n", #glName); \
} \
}
#else
#define GL_LOADFN(name, glName) { \
if( (*(void**)&name = (void*)glXGetProcAddress((const GLubyte*)#glName)) == NULL ) { \
fprintf(stderr,"Failed to find %s\n", #glName); \
} \
}
#endif
#endif
extern PFNGLACTIVETEXTUREPROC gl_ActiveTexture;
extern PFNGLBLENDCOLORPROC gl_BlendColor;
extern PFNGLATTACHSHADERPROC gl_AttachShader;
extern PFNGLBINDBUFFERPROC gl_BindBuffer;
extern PFNGLBINDBUFFERBASEPROC gl_BindBufferBase;
extern PFNGLBINDFRAGDATALOCATIONINDEXEDPROC gl_BindFragDataLocationIndexed;
extern PFNGLBINDFRAMEBUFFERPROC gl_BindFramebuffer;
extern PFNGLBINDPROGRAMPIPELINEPROC gl_BindProgramPipeline;
extern PFNGLBINDSAMPLERPROC gl_BindSampler;
extern PFNGLBINDVERTEXARRAYPROC gl_BindVertexArray;
extern PFNGLBLENDEQUATIONSEPARATEPROC gl_BlendEquationSeparate;
extern PFNGLBLENDFUNCSEPARATEPROC gl_BlendFuncSeparate;
extern PFNGLBLITFRAMEBUFFERPROC gl_BlitFramebuffer;
extern PFNGLBUFFERDATAPROC gl_BufferData;
extern PFNGLCHECKFRAMEBUFFERSTATUSPROC gl_CheckFramebufferStatus;
extern PFNGLCLEARBUFFERFVPROC gl_ClearBufferfv;
extern PFNGLCLEARBUFFERIVPROC gl_ClearBufferiv;
extern PFNGLCOMPILESHADERPROC gl_CompileShader;
extern PFNGLCOPYIMAGESUBDATANVPROC gl_CopyImageSubDataNV;
extern PFNGLCREATEPROGRAMPROC gl_CreateProgram;
extern PFNGLCREATESHADERPROC gl_CreateShader;
extern PFNGLCREATESHADERPROGRAMVPROC gl_CreateShaderProgramv;
extern PFNGLDELETEBUFFERSPROC gl_DeleteBuffers;
extern PFNGLDELETEFRAMEBUFFERSPROC gl_DeleteFramebuffers;
extern PFNGLDELETEPROGRAMPROC gl_DeleteProgram;
extern PFNGLDELETEPROGRAMPIPELINESPROC gl_DeleteProgramPipelines;
extern PFNGLDELETESAMPLERSPROC gl_DeleteSamplers;
extern PFNGLDELETESHADERPROC gl_DeleteShader;
extern PFNGLDELETEVERTEXARRAYSPROC gl_DeleteVertexArrays;
extern PFNGLDETACHSHADERPROC gl_DetachShader;
extern PFNGLDRAWBUFFERSPROC gl_DrawBuffers;
extern PFNGLDRAWELEMENTSBASEVERTEXPROC gl_DrawElementsBaseVertex;
extern PFNGLENABLEVERTEXATTRIBARRAYPROC gl_EnableVertexAttribArray;
extern PFNGLFRAMEBUFFERRENDERBUFFERPROC gl_FramebufferRenderbuffer;
extern PFNGLFRAMEBUFFERTEXTURE2DPROC gl_FramebufferTexture2D;
extern PFNGLGENBUFFERSPROC gl_GenBuffers;
extern PFNGLGENFRAMEBUFFERSPROC gl_GenFramebuffers;
extern PFNGLGENPROGRAMPIPELINESPROC gl_GenProgramPipelines;
extern PFNGLGENSAMPLERSPROC gl_GenSamplers;
extern PFNGLGENVERTEXARRAYSPROC gl_GenVertexArrays;
extern PFNGLGETBUFFERPARAMETERIVPROC gl_GetBufferParameteriv;
extern PFNGLGETDEBUGMESSAGELOGARBPROC gl_GetDebugMessageLogARB;
extern PFNGLGETFRAGDATAINDEXPROC gl_GetFragDataIndex;
extern PFNGLGETFRAGDATALOCATIONPROC gl_GetFragDataLocation;
extern PFNGLGETPROGRAMINFOLOGPROC gl_GetProgramInfoLog;
extern PFNGLGETPROGRAMIVPROC gl_GetProgramiv;
extern PFNGLGETSHADERIVPROC gl_GetShaderiv;
extern PFNGLGETSTRINGIPROC gl_GetStringi;
extern PFNGLISFRAMEBUFFERPROC gl_IsFramebuffer;
extern PFNGLLINKPROGRAMPROC gl_LinkProgram;
extern PFNGLMAPBUFFERPROC gl_MapBuffer;
extern PFNGLMAPBUFFERRANGEPROC gl_MapBufferRange;
extern PFNGLPROGRAMPARAMETERIPROC gl_ProgramParameteri;
extern PFNGLSAMPLERPARAMETERFPROC gl_SamplerParameterf;
extern PFNGLSAMPLERPARAMETERIPROC gl_SamplerParameteri;
extern PFNGLSHADERSOURCEPROC gl_ShaderSource;
extern PFNGLUNIFORM1IPROC gl_Uniform1i;
extern PFNGLUNMAPBUFFERPROC gl_UnmapBuffer;
extern PFNGLUSEPROGRAMSTAGESPROC gl_UseProgramStages;
extern PFNGLVERTEXATTRIBIPOINTERPROC gl_VertexAttribIPointer;
extern PFNGLVERTEXATTRIBPOINTERPROC gl_VertexAttribPointer;
extern PFNGLTEXSTORAGE2DPROC gl_TexStorage2D;
extern PFNGLBUFFERSUBDATAPROC gl_BufferSubData;
// NO GL4.1
extern PFNGLUSEPROGRAMPROC gl_UseProgram;
extern PFNGLGETSHADERINFOLOGPROC gl_GetShaderInfoLog;
extern PFNGLPROGRAMUNIFORM1IPROC gl_ProgramUniform1i;
// NO GL4.2
extern PFNGLGETUNIFORMBLOCKINDEXPROC gl_GetUniformBlockIndex;
extern PFNGLUNIFORMBLOCKBINDINGPROC gl_UniformBlockBinding;
extern PFNGLGETUNIFORMLOCATIONPROC gl_GetUniformLocation;
namespace GLLoader {
bool check_gl_version(uint32 major, uint32 minor);
void init_gl_function();
bool check_gl_supported_extension();
extern bool found_GL_ARB_separate_shader_objects;
extern bool found_GL_ARB_shading_language_420pack;
extern bool found_GL_ARB_texture_storage;
extern bool found_GL_ARB_copy_image;
extern bool found_GL_NV_copy_image;
extern bool found_geometry_shader;
extern bool fglrx_buggy_driver;
extern bool found_only_gl30;
}

View File

@ -45,6 +45,8 @@ GPURenderer::GPURenderer(GSDevice* dev)
m_hWnd = NULL;
m_wndproc = NULL;
m_wnd = new GSWndDX();
#endif
}
@ -74,7 +76,7 @@ bool GPURenderer::Create(void* hWnd)
SetWindowLongPtr(m_hWnd, GWLP_WNDPROC, (LONG_PTR)WndProc);
if(!m_wnd.Attach(m_hWnd))
if(!m_wnd->Attach(m_hWnd))
{
return false;
}
@ -85,9 +87,9 @@ bool GPURenderer::Create(void* hWnd)
#endif
m_wnd.Show();
m_wnd->Show();
if(!m_dev->Create(&m_wnd))
if(!m_dev->Create(m_wnd))
{
return false;
}
@ -189,10 +191,10 @@ void GPURenderer::VSync()
s = format("%s | %.2f mpps", s.c_str(), fps * fillrate / (1024 * 1024));
}
m_wnd.SetWindowText(s.c_str());
m_wnd->SetWindowText(s.c_str());
}
GSVector4i r = m_wnd.GetClientRect();
GSVector4i r = m_wnd->GetClientRect();
m_dev->Present(r.fit(m_aspectratio), 0);
}

View File

@ -24,6 +24,9 @@
#include "GPUState.h"
#include "GSVertexList.h"
#include "GSDevice.h"
#ifdef _WINDOWS
#include "GSWndDX.h"
#endif
class GPURenderer : public GPUState
{
@ -53,7 +56,7 @@ protected:
#endif
GSWnd m_wnd;
GSWnd* m_wnd;
public:
GPURenderer(GSDevice* dev);

View File

@ -25,6 +25,8 @@
#include "GSRendererSW.h"
#include "GSRendererNull.h"
#include "GSDeviceNull.h"
#include "GSDeviceOGL.h"
#include "GSRendererOGL.h"
#ifdef _WINDOWS
@ -32,6 +34,8 @@
#include "GSRendererDX11.h"
#include "GSDevice9.h"
#include "GSDevice11.h"
#include "GSWndDX.h"
#include "GSWndWGL.h"
#include "GSRendererCS.h"
#include "GSSettingsDlg.h"
@ -39,8 +43,8 @@ static HRESULT s_hr = E_FAIL;
#else
#include "GSDeviceOGL.h"
#include "GSRendererOGL.h"
#include "GSWndOGL.h"
#include "GSWndEGL.h"
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
@ -54,7 +58,7 @@ extern bool RunLinuxDialog();
#define PS2E_X86 0x01 // 32 bit
#define PS2E_X86_64 0x02 // 64 bit
#ifdef OGL_MT_HACK
#ifdef ENABLE_OGL_MT_HACK
GSRenderer* s_gs = NULL;
#else
static GSRenderer* s_gs = NULL;
@ -173,7 +177,7 @@ EXPORT_C GSclose()
s_gs->m_dev = NULL;
s_gs->m_wnd.Detach();
s_gs->m_wnd->Detach();
}
static int _GSopen(void** dsp, char* title, int renderer, int threads = -1)
@ -231,10 +235,8 @@ static int _GSopen(void** dsp, char* title, int renderer, int threads = -1)
case 0: dev = new GSDevice9(); break;
case 1: dev = new GSDevice11(); break;
#endif
#ifdef _LINUX
case 4: dev = new GSDeviceOGL(); break;
#endif
case 3: dev = new GSDeviceNull(); break;
case 4: dev = new GSDeviceOGL(); break;
}
if(dev == NULL)
@ -246,25 +248,45 @@ static int _GSopen(void** dsp, char* title, int renderer, int threads = -1)
{
switch(renderer % 3)
{
default:
case 0:
default:
case 0:
switch(renderer)
{
default:
#ifdef _WINDOWS
s_gs = (renderer / 3) == 0 ? (GSRenderer*)new GSRendererDX9() : (GSRenderer*)new GSRendererDX11();
#else
s_gs = (GSRenderer*)new GSRendererOGL();
case 0: s_gs = (GSRenderer*)new GSRendererDX9(); break;
case 3: s_gs = (GSRenderer*)new GSRendererDX11(); break;
#endif
break;
case 1:
s_gs = new GSRendererSW(threads);
break;
case 2:
s_gs = new GSRendererNull();
break;
case 12: s_gs = (GSRenderer*)new GSRendererOGL(); break;
}
break;
case 1:
s_gs = new GSRendererSW(threads);
break;
case 2:
s_gs = new GSRendererNull();
break;
}
s_renderer = renderer;
}
}
if (s_gs->m_wnd == NULL)
{
#ifdef _WINDOWS
if (renderer / 3 == 4)
s_gs->m_wnd = new GSWndWGL();
else
s_gs->m_wnd = new GSWndDX();
#else
#ifdef EGL_API
s_gs->m_wnd = new GSWndEGL();
#else
s_gs->m_wnd = new GSWndOGL();
#endif
#endif
}
}
catch(std::exception& ex)
{
@ -296,9 +318,9 @@ static int _GSopen(void** dsp, char* title, int renderer, int threads = -1)
return -1;
}
s_gs->m_wnd.Show();
s_gs->m_wnd->Show();
*dsp = s_gs->m_wnd.GetDisplay();
*dsp = s_gs->m_wnd->GetDisplay();
}
else
{
@ -306,10 +328,10 @@ static int _GSopen(void** dsp, char* title, int renderer, int threads = -1)
#ifdef _LINUX
// Get the Xwindow from dsp.
if( !s_gs->m_wnd.Attach((void*)((uint32*)(dsp)+1), false) )
if( !s_gs->m_wnd->Attach((void*)((uint32*)(dsp)+1), false) )
return -1;
#else
s_gs->m_wnd.Attach(*dsp, false);
s_gs->m_wnd->Attach(*dsp, false);
#endif
}
@ -440,19 +462,19 @@ EXPORT_C GSreadFIFO(uint8* mem)
{
try
{
#ifdef OGL_MT_HACK
#ifdef ENABLE_OGL_MT_HACK
// FIXME: double check which thread call this function
// See fifo2 issue below
#ifdef OGL_DEBUG
#ifdef ENABLE_OGL_DEBUG
if (theApp.GetConfig("renderer", 0) / 3 == 4) fprintf(stderr, "Disable FIFO1 on opengl\n");
#endif
s_gs->m_wnd.AttachContext();
s_gs->m_wnd->AttachContext();
#endif
s_gs->ReadFIFO(mem, 1);
#ifdef OGL_MT_HACK
s_gs->m_wnd.DetachContext();
#ifdef ENABLE_OGL_MT_HACK
s_gs->m_wnd->DetachContext();
#endif
}
catch (GSDXRecoverableError)
@ -464,19 +486,16 @@ EXPORT_C GSreadFIFO2(uint8* mem, uint32 size)
{
try
{
#ifdef OGL_MT_HACK
#ifdef ENABLE_OGL_MT_HACK
// FIXME called from EE core thread not MTGS which cause
// invalidate data for opengl
#ifdef OGL_DEBUG
if (theApp.GetConfig("renderer", 0) / 3 == 4) fprintf(stderr, "Disable FIFO2(%d) on opengl\n", size);
#endif
s_gs->m_wnd.AttachContext();
s_gs->m_wnd->AttachContext();
#endif
s_gs->ReadFIFO(mem, size);
#ifdef OGL_MT_HACK
s_gs->m_wnd.DetachContext();
#ifdef ENABLE_OGL_MT_HACK
s_gs->m_wnd->DetachContext();
#endif
}
catch (GSDXRecoverableError)
@ -534,7 +553,7 @@ EXPORT_C GSvsync(int field)
{
#ifdef _WINDOWS
if(s_gs->m_wnd.IsManaged())
if(s_gs->m_wnd->IsManaged())
{
MSG msg;
@ -549,8 +568,8 @@ EXPORT_C GSvsync(int field)
#endif
#ifdef OGL_MT_HACK
s_gs->m_wnd.AttachContext();
#ifdef ENABLE_OGL_MT_HACK
s_gs->m_wnd->AttachContext();
#endif
s_gs->VSync(field);
}
@ -623,7 +642,7 @@ EXPORT_C GSconfigure()
if(GSSettingsDlg(s_isgsopen2).DoModal() == IDOK)
{
if(s_gs != NULL && s_gs->m_wnd.IsManaged())
if(s_gs != NULL && s_gs->m_wnd->IsManaged())
{
// Legacy apps like gsdxgui expect this...
@ -633,15 +652,10 @@ EXPORT_C GSconfigure()
#else
// TODO: linux
if (RunLinuxDialog())
{
if(s_gs != NULL && s_gs->m_wnd.IsManaged())
{
GSshutdown();
}
if (RunLinuxDialog()) {
theApp.ReloadConfig();
}
#endif
} catch (GSDXRecoverableError)
{

File diff suppressed because it is too large Load Diff

View File

@ -105,11 +105,11 @@ public:
glEnable(GL_BLEND);
if (HasConstantFactor()) {
debug_factor = factor;
glBlendColor(factor, factor, factor, 0);
gl_BlendColor(factor, factor, factor, 0);
}
glBlendEquationSeparate(m_equation_RGB, m_equation_ALPHA);
glBlendFuncSeparate(m_func_sRGB, m_func_dRGB, m_func_sALPHA, m_func_dALPHA);
gl_BlendEquationSeparate(m_equation_RGB, m_equation_ALPHA);
gl_BlendFuncSeparate(m_func_sRGB, m_func_dRGB, m_func_sALPHA, m_func_dALPHA);
} else {
glDisable(GL_BLEND);
}
@ -152,11 +152,11 @@ class GSDepthStencilOGL {
GLboolean m_depth_mask;
// Note front face and back might be split but it seems they have same parameter configuration
bool m_stencil_enable;
GLuint m_stencil_mask;
const GLuint m_stencil_mask;
GLuint m_stencil_func;
GLuint m_stencil_ref;
GLuint m_stencil_sfail_op;
GLuint m_stencil_spass_dfail_op;
const GLuint m_stencil_ref;
const GLuint m_stencil_sfail_op;
const GLuint m_stencil_spass_dfail_op;
GLuint m_stencil_spass_dpass_op;
char* NameOfParam(GLenum p)
@ -182,7 +182,7 @@ public:
, m_stencil_enable(false)
, m_stencil_mask(1)
, m_stencil_func(0)
, m_stencil_ref(0)
, m_stencil_ref(1)
, m_stencil_sfail_op(GL_KEEP)
, m_stencil_spass_dfail_op(GL_KEEP)
, m_stencil_spass_dpass_op(GL_KEEP)
@ -204,13 +204,16 @@ public:
glDisable(GL_DEPTH_TEST);
}
void SetupStencil(uint8 sref)
void SetupStencil()
{
uint ref = sref;
if (m_stencil_enable) {
glEnable(GL_STENCIL_TEST);
glStencilFunc(m_stencil_func, ref, m_stencil_mask);
// Note: here the mask control which bitplane is considered by the operation
glStencilFunc(m_stencil_func, m_stencil_ref, m_stencil_mask);
glStencilOp(m_stencil_sfail_op, m_stencil_spass_dfail_op, m_stencil_spass_dpass_op);
// FIXME only needed once since m_stencil_mask is constant
// Control which stencil bitplane are written
glStencilMask(m_stencil_mask);
} else
glDisable(GL_STENCIL_TEST);
}
@ -280,8 +283,7 @@ class GSDeviceOGL : public GSDevice
uint32 tme:1;
uint32 fst:1;
uint32 logz:1;
uint32 rtcopy:1;
uint32 wildhack:2;
//uint32 rtcopy:1;
};
uint32 key;
@ -504,7 +506,6 @@ class GSDeviceOGL : public GSDevice
GLuint ps[8]; // program object
GLuint ln; // sampler object
GLuint pt; // sampler object
GLuint gs;
GSDepthStencilOGL* dss;
GSBlendStateOGL* bs;
} m_convert;
@ -540,7 +541,6 @@ class GSDeviceOGL : public GSDevice
GSVector2i viewport;
GSVector4i scissor;
GSDepthStencilOGL* dss;
uint8 sref;
GSBlendStateOGL* bs;
float bf;
// FIXME texture attachment in the FBO
@ -552,9 +552,6 @@ class GSDeviceOGL : public GSDevice
GLenum draw;
} m_state;
bool m_srv_changed;
bool m_ss_changed;
hash_map<uint32, GLuint > m_vs;
hash_map<uint32, GLuint > m_gs;
hash_map<uint32, GLuint > m_ps;
@ -574,8 +571,10 @@ class GSDeviceOGL : public GSDevice
protected:
GSTexture* CreateSurface(int type, int w, int h, bool msaa, int format);
GSTexture* FetchSurface(int type, int w, int h, bool msaa, int format);
void DoMerge(GSTexture* st[2], GSVector4* sr, GSTexture* dt, GSVector4* dr, bool slbg, bool mmod, const GSVector4& c);
void DoInterlace(GSTexture* st, GSTexture* dt, int shader, bool linear, float yoffset = 0);
void DoFXAA(GSTexture* st, GSTexture* dt);
void DoShadeBoost(GSTexture* st, GSTexture* dt);
public:
@ -584,9 +583,6 @@ class GSDeviceOGL : public GSDevice
void CheckDebugLog();
static void DebugOutputToFile(unsigned int source, unsigned int type, unsigned int id, unsigned int severity, const char* message);
void DebugOutput();
void DebugInput();
void DebugBB();
bool HasStencil() { return true; }
bool HasDepth32() { return true; }
@ -607,6 +603,7 @@ class GSDeviceOGL : public GSDevice
void ClearDepth(GSTexture* t, float c);
void ClearStencil(GSTexture* t, uint8 c);
void CreateSampler(GLuint& sampler, bool bilinear, bool tau, bool tav);
GSTexture* CreateRenderTarget(int w, int h, bool msaa, int format = 0);
GSTexture* CreateDepthStencil(int w, int h, bool msaa, int format = 0);
GSTexture* CreateTexture(int w, int h, int format = 0);
@ -657,9 +654,6 @@ class GSDeviceOGL : public GSDevice
void SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerSelector ssel);
void SetupOM(OMDepthStencilSelector dssel, OMBlendSelector bsel, uint8 afix);
#ifdef DISABLE_GL41_SSO
hash_map<uint64, GLuint > m_single_prog;
GLuint link_prog();
#endif
};

View File

@ -24,8 +24,8 @@
#include "GSdx.h"
#include "GSLinuxLogo.h"
GtkWidget *msaa_combo_box, *render_combo_box, *filter_combo_box;
GtkWidget *shadeboost_check, *paltex_check, *fba_check, *aa_check, *native_res_check;
GtkWidget *fsaa_combo_box, *render_combo_box, *filter_combo_box;
GtkWidget *shadeboost_check, *paltex_check, *fba_check, *aa_check, *native_res_check, *fxaa_check;
GtkWidget *sb_contrast, *sb_brightness, *sb_saturation;
GtkWidget *resx_spin, *resy_spin;
@ -133,7 +133,7 @@ GtkWidget* CreateMsaaComboBox()
gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), "5x");
gtk_combo_box_append_text(GTK_COMBO_BOX(combo_box), "6x");
gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box), theApp.GetConfig("msaa", 0));
gtk_combo_box_set_active(GTK_COMBO_BOX(combo_box), theApp.GetConfig("upscale_multiplier", 2)-1);
return combo_box;
}
@ -152,31 +152,29 @@ GtkWidget* CreateFilterComboBox()
void toggle_widget_states( GtkWidget *widget, gpointer callback_data )
{
int render_type;
bool hardware_render = false, software_render = false, null_render = false;
render_type = gtk_combo_box_get_active(GTK_COMBO_BOX(render_combo_box));
hardware_render = ((render_type % 3) == 1);
#if 0
int render_type = gtk_combo_box_get_active(GTK_COMBO_BOX(render_combo_box));
bool hardware_render = ((render_type % 3) == 1);
if (hardware_render)
{
gtk_widget_set_sensitive(filter_combo_box, true);
gtk_widget_set_sensitive(shadeboost_check, true);
gtk_widget_set_sensitive(paltex_check, true);
gtk_widget_set_sensitive(fba_check, true);
gtk_widget_set_sensitive(native_res_check, true);
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(native_res_check)))
{
gtk_widget_set_sensitive(msaa_combo_box, false);
gtk_widget_set_sensitive(fsaa_combo_box, false);
gtk_widget_set_sensitive(resx_spin, false);
gtk_widget_set_sensitive(resy_spin, false);
}
else
{
gtk_widget_set_sensitive(msaa_combo_box, true);
gtk_widget_set_sensitive(fsaa_combo_box, true);
if (gtk_combo_box_get_active(GTK_COMBO_BOX(msaa_combo_box)) == 0)
if (gtk_combo_box_get_active(GTK_COMBO_BOX(fsaa_combo_box)) == 0)
{
gtk_widget_set_sensitive(resx_spin, true);
gtk_widget_set_sensitive(resy_spin, true);
@ -188,26 +186,19 @@ void toggle_widget_states( GtkWidget *widget, gpointer callback_data )
}
}
gtk_widget_set_sensitive(sb_brightness,true);
gtk_widget_set_sensitive(sb_saturation,true);
gtk_widget_set_sensitive(sb_contrast,true);
}
else
{
gtk_widget_set_sensitive(filter_combo_box, false);
gtk_widget_set_sensitive(shadeboost_check, false);
gtk_widget_set_sensitive(paltex_check, false);
gtk_widget_set_sensitive(fba_check, false);
gtk_widget_set_sensitive(native_res_check, false);
gtk_widget_set_sensitive(msaa_combo_box, false);
gtk_widget_set_sensitive(fsaa_combo_box, false);
gtk_widget_set_sensitive(resx_spin, false);
gtk_widget_set_sensitive(resy_spin, false);
gtk_widget_set_sensitive(sb_brightness,false);
gtk_widget_set_sensitive(sb_saturation,false);
gtk_widget_set_sensitive(sb_contrast,false);
}
#endif
}
void set_hex_entry(GtkWidget *text_box, int hex_value) {
@ -228,11 +219,11 @@ int get_hex_entry(GtkWidget *text_box) {
bool RunLinuxDialog()
{
GtkWidget *dialog;
GtkWidget *main_box, *res_box, *hw_box, *sw_box;
GtkWidget *native_box, *msaa_box, *resxy_box, *renderer_box, *interlace_box, *threads_box, *filter_box;
GtkWidget *hw_table, *res_frame, *hw_frame, *sw_frame;
GtkWidget *main_box, *res_box, *hw_box, *sw_box, *shader_box;
GtkWidget *native_box, *fsaa_box, *resxy_box, *renderer_box, *interlace_box, *threads_box, *filter_box;
GtkWidget *hw_table, *shader_table, *res_frame, *hw_frame, *sw_frame, *shader_frame;
GtkWidget *interlace_combo_box, *threads_spin;
GtkWidget *interlace_label, *threads_label, *native_label, *msaa_label, *rexy_label, *render_label, *filter_label;
GtkWidget *interlace_label, *threads_label, *native_label, *fsaa_label, *rexy_label, *render_label, *filter_label;
GtkWidget *hack_table, *hack_skipdraw_label, *hack_box, *hack_frame;
GtkWidget *hack_alpha_check, *hack_offset_check, *hack_skipdraw_spin, *hack_msaa_check, *hack_sprite_check, * hack_wild_check, *hack_enble_check;
@ -262,6 +253,13 @@ bool RunLinuxDialog()
res_frame = gtk_frame_new ("OpenGL Internal Resolution (can cause glitches)");
gtk_container_add(GTK_CONTAINER(res_frame), res_box);
// The extra shader setting frame/container/table
shader_box = gtk_vbox_new(false, 5);
shader_frame = gtk_frame_new("Custom Shader Settings");
gtk_container_add(GTK_CONTAINER(shader_frame), shader_box);
shader_table = gtk_table_new(5,2, false);
gtk_container_add(GTK_CONTAINER(shader_box), shader_table);
// The hardware mode frame, container, and table.
hw_box = gtk_vbox_new(false, 5);
hw_frame = gtk_frame_new ("Hardware Mode Settings");
@ -323,11 +321,11 @@ bool RunLinuxDialog()
gtk_box_pack_start(GTK_BOX(native_box), native_label, false, false, 5);
gtk_box_pack_start(GTK_BOX(native_box), native_res_check, false, false, 5);
msaa_label = gtk_label_new("Or Use Scaling (broken):");
msaa_combo_box = CreateMsaaComboBox();
msaa_box = gtk_hbox_new(false, 5);
gtk_box_pack_start(GTK_BOX(msaa_box), msaa_label, false, false, 5);
gtk_box_pack_start(GTK_BOX(msaa_box), msaa_combo_box, false, false, 5);
fsaa_label = gtk_label_new("Or Use Scaling (broken):");
fsaa_combo_box = CreateMsaaComboBox();
fsaa_box = gtk_hbox_new(false, 5);
gtk_box_pack_start(GTK_BOX(fsaa_box), fsaa_label, false, false, 5);
gtk_box_pack_start(GTK_BOX(fsaa_box), fsaa_combo_box, false, false, 5);
rexy_label = gtk_label_new("Custom Resolution:");
resx_spin = gtk_spin_button_new_with_range(256,8192,1);
@ -368,15 +366,17 @@ bool RunLinuxDialog()
// Create our checkboxes.
shadeboost_check = gtk_check_button_new_with_label("Shade boost");
paltex_check = gtk_check_button_new_with_label("Allow 8 bit textures");
paltex_check = gtk_check_button_new_with_label("Allow 8 bits textures");
fba_check = gtk_check_button_new_with_label("Alpha correction (FBA)");
aa_check = gtk_check_button_new_with_label("Edge anti-aliasing (AA1)");
fxaa_check = gtk_check_button_new_with_label("Fxaa shader");
// Set the checkboxes.
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(shadeboost_check), theApp.GetConfig("shadeboost", 1));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(paltex_check), theApp.GetConfig("paltex", 0));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fba_check), theApp.GetConfig("fba", 1));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(aa_check), theApp.GetConfig("aa1", 0));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(fxaa_check), theApp.GetConfig("fxaa", 0));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(native_res_check), theApp.GetConfig("nativeres", 0));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(hack_alpha_check), theApp.GetConfig("UserHacks_AlphaHack", 0));
@ -405,29 +405,32 @@ bool RunLinuxDialog()
// Populate all those boxes we created earlier with widgets.
gtk_container_add(GTK_CONTAINER(res_box), native_box);
gtk_container_add(GTK_CONTAINER(res_box), msaa_box);
gtk_container_add(GTK_CONTAINER(res_box), fsaa_box);
gtk_container_add(GTK_CONTAINER(res_box), resxy_box);
gtk_container_add(GTK_CONTAINER(sw_box), threads_box);
gtk_container_add(GTK_CONTAINER(sw_box), aa_check);
// Tables are strange. The numbers are for their position: left, right, top, bottom.
gtk_table_attach_defaults(GTK_TABLE(shader_table), fxaa_check, 0, 1, 0, 1);
gtk_table_attach_defaults(GTK_TABLE(shader_table), shadeboost_check, 1, 2, 0, 1);
gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_brightness_label, 0, 1, 1, 2);
gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_brightness, 1, 2, 1, 2);
gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_contrast_label, 0, 1, 2, 3);
gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_contrast, 1, 2, 2, 3);
gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_saturation_label, 0, 1, 3, 4);
gtk_table_attach_defaults(GTK_TABLE(shader_table), sb_saturation, 1, 2, 3, 4);
// Tables are strange. The numbers are for their position: left, right, top, bottom.
gtk_table_attach_defaults(GTK_TABLE(hw_table), filter_box, 0, 1, 0, 1);
gtk_table_attach_defaults(GTK_TABLE(hw_table), shadeboost_check, 1, 2, 0, 1);
gtk_table_attach_defaults(GTK_TABLE(hw_table), paltex_check, 0, 1, 1, 2);
gtk_table_attach_defaults(GTK_TABLE(hw_table), fba_check, 1, 2, 1, 2);
gtk_table_attach_defaults(GTK_TABLE(hw_table), sb_brightness_label, 0, 1, 2, 3);
gtk_table_attach_defaults(GTK_TABLE(hw_table), sb_brightness, 1, 2, 2, 3);
gtk_table_attach_defaults(GTK_TABLE(hw_table), sb_contrast_label, 0, 1, 3, 4);
gtk_table_attach_defaults(GTK_TABLE(hw_table), sb_contrast, 1, 2, 3, 4);
gtk_table_attach_defaults(GTK_TABLE(hw_table), sb_saturation_label, 0, 1, 4, 5);
gtk_table_attach_defaults(GTK_TABLE(hw_table), sb_saturation, 1, 2, 4, 5);
// Put everything in the big box.
gtk_container_add(GTK_CONTAINER(main_box), renderer_box);
gtk_container_add(GTK_CONTAINER(main_box), interlace_box);
gtk_container_add(GTK_CONTAINER(main_box), res_frame);
gtk_container_add(GTK_CONTAINER(main_box), shader_frame);
gtk_container_add(GTK_CONTAINER(main_box), hw_frame);
gtk_container_add(GTK_CONTAINER(main_box), sw_frame);
@ -437,7 +440,7 @@ bool RunLinuxDialog()
}
g_signal_connect(render_combo_box, "changed", G_CALLBACK(toggle_widget_states), NULL);
g_signal_connect(msaa_combo_box, "changed", G_CALLBACK(toggle_widget_states), NULL);
g_signal_connect(fsaa_combo_box, "changed", G_CALLBACK(toggle_widget_states), NULL);
g_signal_connect(native_res_check, "toggled", G_CALLBACK(toggle_widget_states), NULL);
// Put the box in the dialog and show it to the world.
gtk_container_add (GTK_CONTAINER(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), main_box);
@ -478,13 +481,14 @@ bool RunLinuxDialog()
theApp.SetConfig("paltex", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(paltex_check)));
theApp.SetConfig("fba", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(fba_check)));
theApp.SetConfig("aa1", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(aa_check)));
theApp.SetConfig("fxaa", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(fxaa_check)));
theApp.SetConfig("nativeres", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(native_res_check)));
theApp.SetConfig("ShadeBoost_Saturation", (int)gtk_range_get_value(GTK_RANGE(sb_saturation)));
theApp.SetConfig("ShadeBoost_Brightness", (int)gtk_range_get_value(GTK_RANGE(sb_brightness)));
theApp.SetConfig("ShadeBoost_Contrast", (int)gtk_range_get_value(GTK_RANGE(sb_contrast)));
theApp.SetConfig("msaa", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(msaa_combo_box)));
theApp.SetConfig("upscale_multiplier", (int)gtk_combo_box_get_active(GTK_COMBO_BOX(fsaa_combo_box))+1);
theApp.SetConfig("resx", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(resx_spin)));
theApp.SetConfig("resy", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(resy_spin)));
@ -498,6 +502,9 @@ bool RunLinuxDialog()
theApp.SetConfig("UserHacks", (int)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(hack_enble_check)));
theApp.SetConfig("UserHacks_TCOffset", get_hex_entry(hack_tco_entry));
// NOT supported yet
theApp.SetConfig("msaa", 0);
// Let's just be windowed for the moment.
theApp.SetConfig("windowed", 1);

View File

@ -23,7 +23,8 @@
#include "GSRenderer.h"
GSRenderer::GSRenderer()
: m_dev(NULL)
: m_wnd(NULL)
, m_dev(NULL)
, m_shader(0)
, m_shift_key(false)
, m_control_key(false)
@ -52,7 +53,7 @@ GSRenderer::~GSRenderer()
bool GSRenderer::CreateWnd(const string& title, int w, int h)
{
return m_wnd.Create(title.c_str(), w, h);
return m_wnd->Create(title.c_str(), w, h);
}
bool GSRenderer::CreateDevice(GSDevice* dev)
@ -60,7 +61,7 @@ bool GSRenderer::CreateDevice(GSDevice* dev)
ASSERT(dev);
ASSERT(!m_dev);
if(!dev->Create(&m_wnd))
if(!dev->Create(m_wnd))
{
return false;
}
@ -330,7 +331,7 @@ void GSRenderer::VSync(int field)
#ifdef GSTITLEINFO_API_FORCE_VERBOSE
if (1)//force verbose reply
#else
if (m_wnd.IsManaged())
if (m_wnd->IsManaged())
#endif
{
//GSdx owns the window's title, be verbose.
@ -379,9 +380,9 @@ void GSRenderer::VSync(int field)
s += " | Recording...";
}
if(m_wnd.IsManaged())
if(m_wnd->IsManaged())
{
m_wnd.SetWindowText(s.c_str());
m_wnd->SetWindowText(s.c_str());
}
else
{
@ -411,7 +412,7 @@ void GSRenderer::VSync(int field)
// present
m_dev->Present(m_wnd.GetClientRect().fit(m_aspectratio), m_shader);
m_dev->Present(m_wnd->GetClientRect().fit(m_aspectratio), m_shader);
// snapshot
@ -537,7 +538,7 @@ void GSRenderer::KeyEvent(GSKeyEventData* e)
printf("GSdx: Set deinterlace mode to %d (%s).\n", (int)m_interlace, theApp.m_gs_interlace.at(m_interlace).name.c_str());
return;
case VK_F6:
if( m_wnd.IsManaged() )
if( m_wnd->IsManaged() )
m_aspectratio = (m_aspectratio + 3 + step) % 3;
return;
case VK_F7:
@ -571,7 +572,7 @@ void GSRenderer::KeyEvent(GSKeyEventData* e)
fprintf(stderr, "GSdx: Set deinterlace mode to %d (%s).\n", (int)m_interlace, theApp.m_gs_interlace.at(m_interlace).name.c_str());
return;
case XK_F6:
if( m_wnd.IsManaged() )
if( m_wnd->IsManaged() )
m_aspectratio = (m_aspectratio + 3 + step) % 3;
return;
case XK_F7:

View File

@ -53,7 +53,7 @@ protected:
virtual GSTexture* GetOutput(int i) = 0;
public:
GSWnd m_wnd;
GSWnd* m_wnd;
GSDevice* m_dev;
public:

View File

@ -19,6 +19,7 @@
*
*/
#include "stdafx.h"
#include "GSRendererOGL.h"
#include "GSRenderer.h"
@ -29,7 +30,6 @@ GSRendererOGL::GSRendererOGL()
m_logz = !!theApp.GetConfig("logz", 0);
m_fba = !!theApp.GetConfig("fba", 1);
UserHacks_AlphaHack = !!theApp.GetConfig("UserHacks_AlphaHack", 0) && !!theApp.GetConfig("UserHacks", 0);
UserHacks_WildHack = !!theApp.GetConfig("UserHacks", 0) ? theApp.GetConfig("UserHacks_WildHack", 0) : 0;
UserHacks_AlphaStencil = !!theApp.GetConfig("UserHacks_AlphaStencil", 0) && !!theApp.GetConfig("UserHacks", 0);
m_pixelcenter = GSVector2(-0.5f, -0.5f);
@ -46,10 +46,113 @@ bool GSRendererOGL::CreateDevice(GSDevice* dev)
return true;
}
void GSRendererOGL::EmulateGS()
{
switch(m_vt.m_primclass)
{
case GS_LINE_CLASS:
if(PRIM->IIP == 0)
{
for(size_t i = 0, j = m_index.tail; i < j; i += 2)
{
uint32 tmp = m_index.buff[i + 0];
m_index.buff[i + 0] = m_index.buff[i + 1];
m_index.buff[i + 1] = tmp;
}
}
break;
case GS_TRIANGLE_CLASS:
if(PRIM->IIP == 0)
{
for(size_t i = 0, j = m_index.tail; i < j; i += 3)
{
uint32 tmp = m_index.buff[i + 0];
m_index.buff[i + 0] = m_index.buff[i + 2];
m_index.buff[i + 2] = tmp;
}
}
break;
case GS_SPRITE_CLASS:
// each sprite converted to quad needs twice the space
while(m_vertex.tail * 2 > m_vertex.maxcount)
{
GrowVertexBuffer();
}
// assume vertices are tightly packed and sequentially indexed (it should be the case)
if(m_vertex.next >= 2)
{
size_t count = m_vertex.next;
int i = (int)count * 2 - 4;
GSVertex* s = &m_vertex.buff[count - 2];
GSVertex* q = &m_vertex.buff[count * 2 - 4];
uint32* RESTRICT index = &m_index.buff[count * 3 - 6];
for(; i >= 0; i -= 4, s -= 2, q -= 4, index -= 6)
{
GSVertex v0 = s[0];
GSVertex v1 = s[1];
v0.RGBAQ = v1.RGBAQ;
v0.XYZ.Z = v1.XYZ.Z;
v0.FOG = v1.FOG;
q[0] = v0;
q[3] = v1;
// swap x, s, u
uint16 x = v0.XYZ.X;
v0.XYZ.X = v1.XYZ.X;
v1.XYZ.X = x;
float s = v0.ST.S;
v0.ST.S = v1.ST.S;
v1.ST.S = s;
uint16 u = v0.U;
v0.U = v1.U;
v1.U = u;
q[1] = v0;
q[2] = v1;
index[0] = i + 0;
index[1] = i + 1;
index[2] = i + 2;
index[3] = i + 1;
index[4] = i + 2;
index[5] = i + 3;
}
m_vertex.head = m_vertex.tail = m_vertex.next = count * 2;
m_index.tail = count * 3;
}
break;
default:
__assume(0);
}
}
void GSRendererOGL::SetupIA()
{
GSDeviceOGL* dev = (GSDeviceOGL*)m_dev;
if (!GLLoader::found_geometry_shader)
EmulateGS();
void* ptr = NULL;
dev->IASetVertexState();
@ -58,14 +161,15 @@ void GSRendererOGL::SetupIA()
{
GSVector4i::storent(ptr, m_vertex.buff, sizeof(GSVertex) * m_vertex.next);
if(UserHacks_WildHack && !isPackedUV_HackFlag)
{
GSVertex* RESTRICT d = (GSVertex*)ptr;
if(UserHacks_WildHack && !isPackedUV_HackFlag)
{
GSVertex* RESTRICT d = (GSVertex*)ptr;
for(unsigned int i = 0; i < m_vertex.next; i++, d++)
if(PRIM->TME && PRIM->FST)
d->UV &= 0x3FEF3FEF;
}
for(unsigned int i = 0; i < m_vertex.next; i++)
{
if(PRIM->TME && PRIM->FST) d[i].UV &= 0x3FEF3FEF;
}
}
dev->IAUnmapVertexBuffer();
}
@ -80,9 +184,14 @@ void GSRendererOGL::SetupIA()
t = GL_POINTS;
break;
case GS_LINE_CLASS:
case GS_SPRITE_CLASS:
t = GL_LINES;
break;
case GS_SPRITE_CLASS:
if (GLLoader::found_geometry_shader)
t = GL_LINES;
else
t = GL_TRIANGLES;
break;
case GS_TRIANGLE_CLASS:
t = GL_TRIANGLES;
break;
@ -129,10 +238,10 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour
{GSVector4(dst.x, -dst.w, 0.5f, 1.0f), GSVector2(src.x, src.w)},
{GSVector4(dst.z, -dst.w, 0.5f, 1.0f), GSVector2(src.z, src.w)},
#else
{GSVector4(dst.x, -dst.w, 0.5f, 1.0f), GSVector2(src.x, src.y)},
{GSVector4(dst.z, -dst.w, 0.5f, 1.0f), GSVector2(src.z, src.y)},
{GSVector4(dst.x, -dst.y, 0.5f, 1.0f), GSVector2(src.x, src.w)},
{GSVector4(dst.z, -dst.y, 0.5f, 1.0f), GSVector2(src.z, src.w)},
{GSVector4(dst.x, dst.y, 0.5f, 1.0f), GSVector2(src.x, src.y)},
{GSVector4(dst.z, dst.y, 0.5f, 1.0f), GSVector2(src.z, src.y)},
{GSVector4(dst.x, dst.w, 0.5f, 1.0f), GSVector2(src.x, src.w)},
{GSVector4(dst.z, dst.w, 0.5f, 1.0f), GSVector2(src.z, src.w)},
#endif
};
//fprintf(stderr, "DATE A:%fx%f B:%fx%f\n", dst.x, -dst.y, dst.z, -dst.w);
@ -210,10 +319,8 @@ void GSRendererOGL::DrawPrims(GSTexture* rt, GSTexture* ds, GSTextureCache::Sour
vs_sel.tme = PRIM->TME;
vs_sel.fst = PRIM->FST;
//vs_sel.logz = dev->HasDepth32() ? 0 : m_logz ? 1 : 0;
vs_sel.logz = m_logz ? 1 : 0;
//OGL vs_sel.rtcopy = !!rtcopy;
vs_sel.rtcopy = false;
// The real GS appears to do no masking based on the Z buffer format and writing larger Z values
// than the buffer supports seems to be an error condition on the real GS, causing it to crash.

View File

@ -39,11 +39,11 @@ class GSRendererOGL : public GSRendererHW
bool m_fba;
bool UserHacks_AlphaHack;
bool UserHacks_AlphaStencil;
unsigned int UserHacks_WildHack;
unsigned int UserHacks_TCOffset;
float UserHacks_TCO_x, UserHacks_TCO_y;
protected:
void EmulateGS();
void SetupIA();
public:

View File

@ -23,7 +23,7 @@
#include "GSState.h"
#include "GSdx.h"
#ifdef OGL_MT_HACK
#ifdef ENABLE_OGL_MT_HACK
#include "GSRendererOGL.h"
extern GSRenderer* s_gs;
@ -1275,8 +1275,8 @@ void GSState::GIFRegHandlerTRXDIR(const GIFReg* RESTRICT r)
break;
case 1: // local -> host
m_tr.Init(m_env.TRXPOS.SSAX, m_env.TRXPOS.SSAY);
#ifdef OGL_MT_HACK
s_gs->m_wnd.DetachContext();
#ifdef ENABLE_OGL_MT_HACK
s_gs->m_wnd->DetachContext();
#endif
break;
case 2: // local -> local
@ -1782,8 +1782,8 @@ static hash_map<uint64, uint64> s_tags;
template<int index> void GSState::Transfer(const uint8* mem, uint32 size)
{
GSPerfMonAutoTimer pmat(&m_perfmon);
#ifdef OGL_MT_HACK
s_gs->m_wnd.AttachContext();
#ifdef ENABLE_OGL_MT_HACK
s_gs->m_wnd->AttachContext();
#endif
const uint8* start = mem;

View File

@ -33,33 +33,15 @@ void GSDeviceOGL::CreateTextureFX()
m_vs_cb = new GSUniformBufferOGL(g_vs_cb_index, sizeof(VSConstantBuffer));
m_ps_cb = new GSUniformBufferOGL(g_ps_cb_index, sizeof(PSConstantBuffer));
glGenSamplers(1, &m_rt_ss);
// FIXME, seem to have no difference between sampler !!!
m_palette_ss = m_rt_ss;
glSamplerParameteri(m_rt_ss, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glSamplerParameteri(m_rt_ss, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glSamplerParameteri(m_rt_ss, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
glSamplerParameteri(m_rt_ss, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glSamplerParameteri(m_rt_ss, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// FIXME which value for GL_TEXTURE_MIN_LOD
glSamplerParameterf(m_rt_ss, GL_TEXTURE_MAX_LOD, FLT_MAX);
// FIXME: seems there is 2 possibility in opengl
// DX: sd.ComparisonFunc = D3D11_COMPARISON_NEVER;
// glSamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_MODE, GL_NONE);
glSamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
glSamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_FUNC, GL_NEVER);
// FIXME: need ogl extension sd.MaxAnisotropy = 16;
CreateSampler(m_palette_ss, false, false, false);
GSInputLayoutOGL vert_format[] =
{
// FIXME
{0 , 2 , GL_FLOAT , GL_FALSE , sizeof(GSVertex) , (const GLvoid*)(0) } ,
{1 , 4 , GL_UNSIGNED_BYTE , GL_TRUE , sizeof(GSVertex) , (const GLvoid*)(8) } ,
{2 , 1 , GL_FLOAT , GL_FALSE , sizeof(GSVertex) , (const GLvoid*)(12) } ,
{3 , 2 , GL_UNSIGNED_SHORT , GL_FALSE , sizeof(GSVertex) , (const GLvoid*)(16) } ,
{4 , 1 , GL_UNSIGNED_INT , GL_FALSE , sizeof(GSVertex) , (const GLvoid*)(20) } ,
// note: there is a 32 bits pad
{5 , 2 , GL_UNSIGNED_SHORT , GL_FALSE , sizeof(GSVertex) , (const GLvoid*)(24) } ,
{6 , 4 , GL_UNSIGNED_BYTE , GL_TRUE , sizeof(GSVertex) , (const GLvoid*)(28) } ,
};
@ -67,10 +49,26 @@ void GSDeviceOGL::CreateTextureFX()
// Compile some dummy shaders to allow modification inside Apitrace for debug
GLuint dummy;
std::string macro = "";
std::string macro = "\n";
CompileShaderFromSource("tfx.glsl", "vs_main", GL_VERTEX_SHADER, &dummy, tfx_glsl, macro);
CompileShaderFromSource("tfx.glsl", "gs_main", GL_GEOMETRY_SHADER, &dummy, tfx_glsl, macro);
CompileShaderFromSource("tfx.glsl", "ps_main", GL_FRAGMENT_SHADER, &dummy, tfx_glsl, macro);
// Pre compile all Geometry & Vertex Shader
// It might cost a seconds at startup but it would reduce benchmark pollution
GSDeviceOGL::GSSelector gs_sel;
for (uint32 key = 0; key < (1 << 3); key++) {
gs_sel.key = key;
SetupGS(gs_sel);
}
GSDeviceOGL::VSSelector vs_sel;
for (uint32 key = 0; key < (1 << 5); key++) {
vs_sel.key = key;
SetupVS(vs_sel, NULL);
}
// Use sane reset value
GSSetShader(0);
VSSetShader(0);
}
void GSDeviceOGL::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
@ -85,8 +83,7 @@ void GSDeviceOGL::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
std::string macro = format("#define VS_BPPZ %d\n", sel.bppz)
+ format("#define VS_LOGZ %d\n", sel.logz)
+ format("#define VS_TME %d\n", sel.tme)
+ format("#define VS_FST %d\n", sel.fst)
+ format("#define VS_RTCOPY %d\n", sel.rtcopy);
+ format("#define VS_FST %d\n", sel.fst);
GLuint vs;
CompileShaderFromSource("tfx.glsl", "vs_main", GL_VERTEX_SHADER, &vs, tfx_glsl, macro);
@ -98,7 +95,7 @@ void GSDeviceOGL::SetupVS(VSSelector sel, const VSConstantBuffer* cb)
// *************************************************************
// Dynamic
// *************************************************************
if(m_vs_cb_cache.Update(cb)) {
if(cb != NULL && m_vs_cb_cache.Update(cb)) {
SetUniformBuffer(m_vs_cb);
m_vs_cb->upload(cb);
}
@ -165,7 +162,6 @@ void GSDeviceOGL::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerS
CompileShaderFromSource("tfx.glsl", "ps_main", GL_FRAGMENT_SHADER, &ps, tfx_glsl, macro);
m_ps[sel] = ps;
i = m_ps.find(sel);
} else {
ps = i->second;
}
@ -198,36 +194,7 @@ void GSDeviceOGL::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerS
// *************************************************************
// Static
// *************************************************************
glGenSamplers(1, &ss0);
if (ssel.ltf) {
glSamplerParameteri(ss0, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glSamplerParameteri(ss0, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
} else {
glSamplerParameteri(ss0, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glSamplerParameteri(ss0, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
}
// FIXME ensure U -> S, V -> T and W->R
if (ssel.tau)
glSamplerParameteri(ss0, GL_TEXTURE_WRAP_S, GL_REPEAT);
else
glSamplerParameteri(ss0, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
if (ssel.tav)
glSamplerParameteri(ss0, GL_TEXTURE_WRAP_T, GL_REPEAT);
else
glSamplerParameteri(ss0, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glSamplerParameteri(ss0, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
// FIXME which value for GL_TEXTURE_MIN_LOD
glSamplerParameterf(m_rt_ss, GL_TEXTURE_MAX_LOD, FLT_MAX);
// FIXME: seems there is 2 possibility in opengl
// DX: sd.ComparisonFunc = D3D11_COMPARISON_NEVER;
// glSamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_MODE, GL_NONE);
glSamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
glSamplerParameteri(m_rt_ss, GL_TEXTURE_COMPARE_FUNC, GL_NEVER);
// FIXME: need ogl extension sd.MaxAnisotropy = 16;
CreateSampler(ss0, ssel.ltf, ssel.tau, ssel.tav);
m_ps_ss[ssel] = ss0;
}
@ -238,8 +205,7 @@ void GSDeviceOGL::SetupPS(PSSelector sel, const PSConstantBuffer* cb, PSSamplerS
}
}
PSSetSamplerState(ss0, ss1, sel.date ? m_rt_ss : 0);
PSSetSamplerState(ss0, ss1, 0);
PSSetShader(ps);
}

View File

@ -19,10 +19,18 @@
*
*/
#include "stdafx.h"
#include <limits.h>
#include "GSTextureOGL.h"
static int g_state_texture_unit = -1;
static int g_state_texture_id = -1;
static GLuint g_state_texture_unit = -1;
static GLuint g_state_texture_id[7] = {0, 0, 0, 0, 0, 0, 0};
static GLuint g_color0 = 0;
static GLuint g_color1 = 0;
static GLuint g_depth = 0;
// FIXME: check if it possible to always use those setup by default
// glPixelStorei(GL_PACK_ALIGNMENT, 1);
// glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint fbo_read)
: m_pbo_id(0),
@ -32,19 +40,19 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint
// Opengl world
// Render work in parallal with framebuffer object (FBO) http://www.opengl.org/wiki/Framebuffer_Objects
// render are attached to FBO through : glFramebufferRenderbuffer. You can query the number of colorattachement with GL_MAX_COLOR_ATTACHMENTS
// FBO : constructor -> glGenFramebuffers, glDeleteFramebuffers
// binding -> glBindFramebuffer (target can be read/write/both)
// blit -> glBlitFramebuffer (read FB to draw FB)
// info -> glIsFramebuffer, glGetFramebufferAttachmentParameter, glCheckFramebufferStatus
// render are attached to FBO through : gl_FramebufferRenderbuffer. You can query the number of colorattachement with GL_MAX_COLOR_ATTACHMENTS
// FBO : constructor -> gl_GenFramebuffers, gl_DeleteFramebuffers
// binding -> gl_BindFramebuffer (target can be read/write/both)
// blit -> gl_BlitFramebuffer (read FB to draw FB)
// info -> gl_IsFramebuffer, glGetFramebufferAttachmentParameter, gl_CheckFramebufferStatus
//
// There are two types of framebuffer-attachable images; texture images and renderbuffer images.
// If an image of a texture object is attached to a framebuffer, OpenGL performs "render to texture".
// And if an image of a renderbuffer object is attached to a framebuffer, then OpenGL performs "offscreen rendering".
// Blitting:
// glDrawBuffers
// gl_DrawBuffers
// glReadBuffer
// glBlitFramebuffer
// gl_BlitFramebuffer
// *************************************************************
// m_size.x = w;
@ -61,7 +69,7 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint
switch (m_type) {
case GSTexture::Offscreen:
//FIXME I not sure we need a pixel buffer object. It seems more a texture
// glGenBuffers(1, &m_texture_id);
// gl_GenBuffers(1, &m_texture_id);
// m_texture_target = GL_PIXEL_UNPACK_BUFFER;
// ASSERT(0);
// Note there is also a buffer texture!!!
@ -83,15 +91,17 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint
break;
}
// Extra buffer to handle various pixel transfer
glGenBuffers(1, &m_pbo_id);
gl_GenBuffers(1, &m_pbo_id);
uint msaa_level;
#if 0
uint32 msaa_level;
if (m_msaa) {
// FIXME which level of MSAA
msaa_level = 1;
} else {
msaa_level = 0;
}
#endif
// Allocate the buffer
switch (m_type) {
@ -104,25 +114,21 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint
ASSERT(0); // TODO Later
}
glBindBuffer(GL_PIXEL_PACK_BUFFER, m_pbo_id);
glBufferData(GL_PIXEL_PACK_BUFFER, m_pbo_size, NULL, GL_STREAM_DRAW);
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
gl_BindBuffer(GL_PIXEL_PACK_BUFFER, m_pbo_id);
gl_BufferData(GL_PIXEL_PACK_BUFFER, m_pbo_size, NULL, GL_STREAM_DRAW);
gl_BindBuffer(GL_PIXEL_PACK_BUFFER, 0);
ASSERT(!m_msaa);
case GSTexture::DepthStencil:
case GSTexture::RenderTarget:
case GSTexture::Texture:
// FIXME: check the opensource driver
// Howto allocate the texture unit !!!
// In worst case the HW renderer seems to use 3 texture unit
// For the moment SW renderer only use 1 so don't bother
EnableUnit(0);
EnableUnit(3);
if (m_msaa) {
ASSERT(m_texture_target == GL_TEXTURE_2D_MULTISAMPLE);
// Require a recent GLEW and GL4.3
//glTexStorage2DMultisample(m_texture_target, msaa_level, m_format, m_size.x, m_size.y, false);
// Require a recent GL4.3 extension
//gl_TexStorage2DMultisample(m_texture_target, msaa_level, m_format, m_size.x, m_size.y, false);
} else {
glTexStorage2D(m_texture_target, 1, m_format, m_size.x, m_size.y);
gl_TexStorage2D(m_texture_target, 1, m_format, m_size.x, m_size.y);
}
break;
default: break;
@ -131,16 +137,49 @@ GSTextureOGL::GSTextureOGL(int type, int w, int h, bool msaa, int format, GLuint
GSTextureOGL::~GSTextureOGL()
{
glDeleteBuffers(1, &m_pbo_id);
/* Unbind the texture from our local state */
for (uint32 i = 0; i < 7; i++)
if (g_state_texture_id[i] == m_texture_id)
g_state_texture_id[i] = 0;
gl_DeleteBuffers(1, &m_pbo_id);
glDeleteTextures(1, &m_texture_id);
}
void GSTextureOGL::Attach(GLenum attachment)
{
//fprintf(stderr, "format %d,%x\n", m_type, m_format);
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, attachment, m_texture_target, m_texture_id, 0);
switch(attachment) {
case GL_COLOR_ATTACHMENT0:
if (g_color0 != m_texture_id) {
g_color0 = m_texture_id;
gl_FramebufferTexture2D(GL_DRAW_FRAMEBUFFER, attachment, m_texture_target, m_texture_id, 0);
}
break;
case GL_COLOR_ATTACHMENT1:
if (g_color1 != m_texture_id) {
g_color1 = m_texture_id;
gl_FramebufferTexture2D(GL_DRAW_FRAMEBUFFER, attachment, m_texture_target, m_texture_id, 0);
}
break;
case GL_DEPTH_STENCIL_ATTACHMENT:
if (g_depth != m_texture_id) {
gl_FramebufferTexture2D(GL_DRAW_FRAMEBUFFER, attachment, m_texture_target, m_texture_id, 0);
g_depth = m_texture_id;
}
break;
default:
gl_FramebufferTexture2D(GL_DRAW_FRAMEBUFFER, attachment, m_texture_target, m_texture_id, 0);
break;
}
// FIXME DEBUG
//fprintf(stderr, "FB status %x\n", glCheckFramebufferStatus(GL_FRAMEBUFFER));
//fprintf(stderr, "FB status %x\n", gl_CheckFramebufferStatus(GL_FRAMEBUFFER));
}
void GSTextureOGL::AttachRead(GLenum attachment)
{
gl_FramebufferTexture2D(GL_READ_FRAMEBUFFER, attachment, m_texture_target, m_texture_id, 0);
glReadBuffer(attachment);
}
bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch)
@ -150,35 +189,53 @@ bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch)
// FIXME warning order of the y axis
// FIXME I'm not confident with GL_UNSIGNED_BYTE type
EnableUnit(0);
EnableUnit(4);
// pitch could be different of width*element_size
glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch>>2);
// FIXME : it crash on colin mcrae rally 3 (others game too) when the size is 16
//fprintf(stderr, "Texture %dx%d with a pitch of %d\n", m_size.x, m_size.y, pitch >>2);
//fprintf(stderr, "Box (%d,%d)x(%d,%d)\n", r.x, r.y, r.width(), r.height());
if (m_format == GL_RGBA8)
glTexSubImage2D(m_texture_target, 0, r.x, r.y, r.width(), r.height(), GL_RGBA, GL_UNSIGNED_BYTE, data);
else if (m_format == GL_R16UI)
glTexSubImage2D(m_texture_target, 0, r.x, r.y, r.width(), r.height(), GL_RED_INTEGER, GL_R16UI, data);
else if (m_format == GL_R8)
glTexSubImage2D(m_texture_target, 0, r.x, r.y, r.width(), r.height(), GL_RED, GL_R8, data);
else {
fprintf(stderr, "wrong texture pixel format :%x\n", m_format);
ASSERT(0);
// pitch is in byte wherease GL_UNPACK_ROW_LENGTH is in pixel
GLenum format;
GLenum type;
switch (m_format) {
case GL_RGBA8:
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch>>2);
format = GL_RGBA;
type = GL_UNSIGNED_BYTE;
break;
case GL_R16UI:
glPixelStorei(GL_UNPACK_ALIGNMENT, 2);
glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch>>1);
format = GL_RED;
type = GL_UNSIGNED_SHORT;
break;
case GL_R8:
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch);
format = GL_RED;
type = GL_UNSIGNED_BYTE;
break;
default:
fprintf(stderr, "wrong texture pixel format :%x\n", m_format);
ASSERT(0);
}
#if 0
//if (m_size.x != 16)
if (r.width() > 16 && r.height() > 16)
glTexSubImage2D(m_texture_target, 0, r.x, r.y, r.width(), r.height(), GL_RGBA, GL_UNSIGNED_BYTE, data);
else {
fprintf(stderr, "skip texture upload\n");
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); // Restore default behavior
return false;
#ifdef _LINUX
if (GLLoader::fglrx_buggy_driver) {
// FIXME : it crash on colin mcrae rally 3 (others game too) when the texture is small
//if ((pitch >> 2) == 32 || r.width() < 32 || r.height() < 32) {
if ((r.width() < 32) || (pitch == 128 && r.width() == 32)) {
#ifdef ENABLE_OGL_DEBUG
fprintf(stderr, "Skip Texture %dx%d with a pitch of %d pixel. Type %x\n", m_size.x, m_size.y, pitch >>2, m_format);
fprintf(stderr, "Box (%d,%d)x(%d,%d)\n", r.x, r.y, r.width(), r.height());
#endif
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); // Restore default behavior
return false;
}
}
#endif
glTexSubImage2D(m_texture_target, 0, r.x, r.y, r.width(), r.height(), format, type, data);
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); // Restore default behavior
return true;
@ -196,23 +253,20 @@ bool GSTextureOGL::Update(const GSVector4i& r, const void* data, int pitch)
#endif
}
void GSTextureOGL::EnableUnit(uint unit)
void GSTextureOGL::EnableUnit(uint32 unit)
{
if (!IsBackbuffer()) {
// FIXME
// Howto allocate the texture unit !!!
// In worst case the HW renderer seems to use 3 texture unit
// For the moment SW renderer only use 1 so don't bother
if (g_state_texture_unit != unit) {
g_state_texture_unit = unit;
glActiveTexture(GL_TEXTURE0 + unit);
// When you change the texture unit, texture must be rebinded
g_state_texture_id = m_texture_id;
glBindTexture(m_texture_target, m_texture_id);
} else if (g_state_texture_id != m_texture_id) {
g_state_texture_id = m_texture_id;
glBindTexture(m_texture_target, m_texture_id);
}
/* Not a real texture */
if (IsBackbuffer()) {
return;
}
if (g_state_texture_unit != unit) {
gl_ActiveTexture(GL_TEXTURE0 + unit);
g_state_texture_unit = unit;
}
if (g_state_texture_id[unit] != m_texture_id) {
g_state_texture_id[unit] = m_texture_id;
glBindTexture(m_texture_target, m_texture_id);
}
}
@ -223,42 +277,44 @@ bool GSTextureOGL::Map(GSMap& m, const GSVector4i* r)
// Set m.pitch <- size of a row
// I think in opengl we need to copy back the data to the RAM: glReadPixels — read a block of pixels from the frame buffer
//
// glMapBuffer — map a buffer object's data store
// gl_MapBuffer — map a buffer object's data store
// Can be used on GL_PIXEL_UNPACK_BUFFER or GL_TEXTURE_BUFFER
if (m_type == GSTexture::Offscreen) {
// Bind the texture to the read framebuffer to avoid any disturbance
EnableUnit(0);
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read);
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_texture_target, m_texture_id, 0);
EnableUnit(5);
gl_BindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read);
gl_FramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_texture_target, m_texture_id, 0);
glReadBuffer(GL_COLOR_ATTACHMENT0);
// FIXME It might be possible to only read a subrange of the texture based on r object
// Load the PBO with the data
glBindBuffer(GL_PIXEL_PACK_BUFFER, m_pbo_id);
gl_BindBuffer(GL_PIXEL_PACK_BUFFER, m_pbo_id);
if (m_format == GL_RGBA8) {
glPixelStorei(GL_PACK_ALIGNMENT, 4);
glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, 0);
m.pitch = m_size.x * 4;
} else if (m_format == GL_R16UI) {
glPixelStorei(GL_PACK_ALIGNMENT, 2);
glReadPixels(0, 0, m_size.x, m_size.y, GL_RED_INTEGER, GL_UNSIGNED_SHORT, 0);
m.pitch = m_size.x * 2;
} else if (m_format == GL_R8) {
glPixelStorei(GL_PACK_ALIGNMENT, 1);
glReadPixels(0, 0, m_size.x, m_size.y, GL_RED, GL_UNSIGNED_BYTE, 0);
m.pitch = m_size.x;
} else {
fprintf(stderr, "wrong texture pixel format :%x\n", m_format);
ASSERT(0);
}
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
gl_BindFramebuffer(GL_READ_FRAMEBUFFER, 0);
// Give access from the CPU
m.bits = (uint8*) glMapBufferRange(GL_PIXEL_PACK_BUFFER, 0, m_pbo_size, GL_MAP_READ_BIT);
m.pitch = m_size.x;
m.bits = (uint8*) gl_MapBufferRange(GL_PIXEL_PACK_BUFFER, 0, m_pbo_size, GL_MAP_READ_BIT);
if ( m.bits ) {
return true;
} else {
fprintf(stderr, "bad mapping of the pbo\n");
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
gl_BindBuffer(GL_PIXEL_PACK_BUFFER, 0);
return false;
}
}
@ -285,8 +341,8 @@ bool GSTextureOGL::Map(GSMap& m, const GSVector4i* r)
void GSTextureOGL::Unmap()
{
if (m_type == GSTexture::Offscreen) {
glUnmapBuffer(GL_PIXEL_PACK_BUFFER);
glBindBuffer(GL_PIXEL_PACK_BUFFER, 0);
gl_UnmapBuffer(GL_PIXEL_PACK_BUFFER);
gl_BindBuffer(GL_PIXEL_PACK_BUFFER, 0);
}
}
@ -404,22 +460,20 @@ bool GSTextureOGL::Save(const string& fn, bool dds)
// for us
if (IsBackbuffer()) {
//glReadBuffer(GL_BACK);
//glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
//gl_BindFramebuffer(GL_READ_FRAMEBUFFER, 0);
glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, image);
} else if(IsDss()) {
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read);
gl_BindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read);
//EnableUnit(0);
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_texture_target, m_texture_id, 0);
gl_FramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_texture_target, m_texture_id, 0);
glReadPixels(0, 0, m_size.x, m_size.y, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, image);
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
gl_BindFramebuffer(GL_READ_FRAMEBUFFER, 0);
} else {
glBindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read);
gl_BindFramebuffer(GL_READ_FRAMEBUFFER, m_fbo_read);
EnableUnit(0);
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_texture_target, m_texture_id, 0);
EnableUnit(6);
gl_FramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_texture_target, m_texture_id, 0);
glReadBuffer(GL_COLOR_ATTACHMENT0);
if (m_format == GL_RGBA8)
@ -437,7 +491,7 @@ bool GSTextureOGL::Save(const string& fn, bool dds)
status = false;
}
glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
gl_BindFramebuffer(GL_READ_FRAMEBUFFER, 0);
}
if (status) Save(fn, image, pitch);

View File

@ -28,7 +28,7 @@ class GSTextureOGL : public GSTexture
private:
GLenum m_texture_target; // texture target: 2D, rectangle etc...
GLuint m_texture_id; // the texture id
uint m_pbo_id;
uint32 m_pbo_id;
int m_pbo_size;
GLuint m_fbo_read;
@ -42,8 +42,9 @@ class GSTextureOGL : public GSTexture
bool Save(const string& fn, bool dds = false);
void Save(const string& fn, const void* image, uint32 pitch);
void EnableUnit(uint unit);
void EnableUnit(uint32 unit);
void Attach(GLenum attachment);
void AttachRead(GLenum attachment);
bool IsBackbuffer() { return (m_type == GSTexture::Backbuffer); }
bool IsDss() { return (m_type == GSTexture::DepthStencil); }

View File

@ -24,15 +24,15 @@
class GSUniformBufferOGL {
GLuint buffer; // data object
GLuint index; // GLSL slot
uint size; // size of the data
uint32 size; // size of the data
const GLenum target;
public:
GSUniformBufferOGL(GLuint index, uint size) : index(index)
GSUniformBufferOGL(GLuint index, uint32 size) : index(index)
, size(size)
,target(GL_UNIFORM_BUFFER)
{
glGenBuffers(1, &buffer);
gl_GenBuffers(1, &buffer);
bind();
allocate();
attach();
@ -40,28 +40,28 @@ public:
void bind()
{
glBindBuffer(target, buffer);
gl_BindBuffer(target, buffer);
}
void allocate()
{
glBufferData(target, size, NULL, GL_STREAM_DRAW);
gl_BufferData(target, size, NULL, GL_STREAM_DRAW);
}
void attach()
{
glBindBufferBase(target, index, buffer);
gl_BindBufferBase(target, index, buffer);
}
void upload(const void* src)
{
uint32 flags = GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT;
uint8* dst = (uint8*) glMapBufferRange(target, 0, size, flags);
memcpy(dst, src, size);
glUnmapBuffer(target);
// glMapBufferRange allow to set various parameter but the call is
// synchronous whereas glBufferSubData could be asynchronous.
// TODO: investigate the extension ARB_invalidate_subdata
gl_BufferSubData(target, 0, size, src);
}
~GSUniformBufferOGL() {
glDeleteBuffers(1, &buffer);
gl_DeleteBuffers(1, &buffer);
}
};

View File

@ -47,12 +47,12 @@ class GSBufferOGL {
, m_limit(0)
, m_target(target)
{
glGenBuffers(1, &m_buffer);
gl_GenBuffers(1, &m_buffer);
// Opengl works best with 1-4MB buffer.
m_default_size = 2 * 1024 * 1024 / m_stride;
}
~GSBufferOGL() { glDeleteBuffers(1, &m_buffer); }
~GSBufferOGL() { gl_DeleteBuffers(1, &m_buffer); }
void allocate() { allocate(m_default_size); }
@ -60,12 +60,12 @@ class GSBufferOGL {
{
m_start = 0;
m_limit = new_limit;
glBufferData(m_target, m_limit * m_stride, NULL, GL_STREAM_DRAW);
gl_BufferData(m_target, m_limit * m_stride, NULL, GL_STREAM_DRAW);
}
void bind()
{
glBindBuffer(m_target, m_buffer);
gl_BindBuffer(m_target, m_buffer);
}
void upload(const void* src, uint32 count)
@ -81,9 +81,9 @@ class GSBufferOGL {
}
bool Map(void** pointer, uint32 count ) {
#ifdef OGL_DEBUG
#ifdef ENABLE_OGL_DEBUG
GLint b_size = -1;
glGetBufferParameteriv(m_target, GL_BUFFER_SIZE, &b_size);
gl_GetBufferParameteriv(m_target, GL_BUFFER_SIZE, &b_size);
if (b_size <= 0) return false;
#endif
@ -112,9 +112,9 @@ class GSBufferOGL {
}
// Upload the data to the buffer
*pointer = (uint8*) glMapBufferRange(m_target, m_stride*m_start, m_stride*m_count, map_flags);
*pointer = (uint8*) gl_MapBufferRange(m_target, m_stride*m_start, m_stride*m_count, map_flags);
//fprintf(stderr, "Map %x from %d to %d\n", *pointer, m_start, m_start+m_count);
#ifdef OGL_DEBUG
#ifdef ENABLE_OGL_DEBUG
if (*pointer == NULL) {
fprintf(stderr, "CRITICAL ERROR map failed for vb!!!\n");
return false;
@ -123,7 +123,7 @@ class GSBufferOGL {
return true;
}
void Unmap() { glUnmapBuffer(m_target); }
void Unmap() { gl_UnmapBuffer(m_target); }
void EndScene()
{
@ -138,12 +138,12 @@ class GSBufferOGL {
void Draw(GLenum mode, GLint basevertex)
{
glDrawElementsBaseVertex(mode, m_count, GL_UNSIGNED_INT, (void*)(m_start * m_stride), basevertex);
gl_DrawElementsBaseVertex(mode, m_count, GL_UNSIGNED_INT, (void*)(m_start * m_stride), basevertex);
}
void Draw(GLenum mode, GLint basevertex, int offset, int count)
{
glDrawElementsBaseVertex(mode, count, GL_UNSIGNED_INT, (void*)((m_start + offset) * m_stride), basevertex);
gl_DrawElementsBaseVertex(mode, count, GL_UNSIGNED_INT, (void*)((m_start + offset) * m_stride), basevertex);
}
size_t GetStart() { return m_start; }
@ -165,7 +165,7 @@ class GSVertexBufferStateOGL {
public:
GSVertexBufferStateOGL(size_t stride, GSInputLayoutOGL* layout, uint32 layout_nbr)
{
glGenVertexArrays(1, &m_va);
gl_GenVertexArrays(1, &m_va);
m_vb = new GSBufferOGL(GL_ARRAY_BUFFER, stride);
m_ib = new GSBufferOGL(GL_ELEMENT_ARRAY_BUFFER, sizeof(uint32));
@ -181,23 +181,23 @@ public:
void bind()
{
glBindVertexArray(m_va);
gl_BindVertexArray(m_va);
m_vb->bind();
}
void set_internal_format(GSInputLayoutOGL* layout, uint32 layout_nbr)
{
for (uint i = 0; i < layout_nbr; i++) {
for (uint32 i = 0; i < layout_nbr; i++) {
// Note this function need both a vertex array object and a GL_ARRAY_BUFFER buffer
glEnableVertexAttribArray(layout[i].index);
gl_EnableVertexAttribArray(layout[i].index);
switch (layout[i].type) {
case GL_UNSIGNED_SHORT:
case GL_UNSIGNED_INT:
// Rule: when shader use integral (not normalized) you must use glVertexAttribIPointer (note the extra I)
glVertexAttribIPointer(layout[i].index, layout[i].size, layout[i].type, layout[i].stride, layout[i].offset);
// Rule: when shader use integral (not normalized) you must use gl_VertexAttribIPointer (note the extra I)
gl_VertexAttribIPointer(layout[i].index, layout[i].size, layout[i].type, layout[i].stride, layout[i].offset);
break;
default:
glVertexAttribPointer(layout[i].index, layout[i].size, layout[i].type, layout[i].normalize, layout[i].stride, layout[i].offset);
gl_VertexAttribPointer(layout[i].index, layout[i].size, layout[i].type, layout[i].normalize, layout[i].stride, layout[i].offset);
break;
}
}
@ -227,7 +227,7 @@ public:
~GSVertexBufferStateOGL()
{
glDeleteVertexArrays(1, &m_va);
gl_DeleteVertexArrays(1, &m_va);
delete m_vb;
delete m_ib;
}

View File

@ -20,466 +20,3 @@
*/
#include "stdafx.h"
#include "GSdx.h"
#include "GSWnd.h"
#ifdef _WINDOWS
GSWnd::GSWnd()
: m_hWnd(NULL)
, m_managed(true)
, m_frame(true)
{
}
GSWnd::~GSWnd()
{
}
LRESULT CALLBACK GSWnd::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
GSWnd* wnd = NULL;
if(message == WM_NCCREATE)
{
wnd = (GSWnd*)((LPCREATESTRUCT)lParam)->lpCreateParams;
SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)wnd);
wnd->m_hWnd = hWnd;
}
else
{
wnd = (GSWnd*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
}
if(wnd == NULL)
{
return DefWindowProc(hWnd, message, wParam, lParam);
}
return wnd->OnMessage(message, wParam, lParam);
}
LRESULT GSWnd::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_CLOSE:
Hide();
// DestroyWindow(m_hWnd);
return 0;
case WM_DESTROY:
// This kills the emulator when GS is closed, which *really* isn't desired behavior,
// especially in STGS mode (worked in MTGS mode since it only quit the thread, but even
// that wasn't needed).
//PostQuitMessage(0);
return 0;
default:
break;
}
return DefWindowProc((HWND)m_hWnd, message, wParam, lParam);
}
bool GSWnd::Create(const string& title, int w, int h)
{
if(m_hWnd) return false;
WNDCLASS wc;
memset(&wc, 0, sizeof(wc));
wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
wc.lpfnWndProc = WndProc;
wc.hInstance = theApp.GetModuleHandle();
// TODO: wc.hIcon = ;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszClassName = "GSWnd";
if(!GetClassInfo(wc.hInstance, wc.lpszClassName, &wc))
{
if(!RegisterClass(&wc))
{
return false;
}
}
DWORD style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_OVERLAPPEDWINDOW | WS_BORDER;
GSVector4i r;
GetWindowRect(GetDesktopWindow(), r);
bool remote = !!GetSystemMetrics(SM_REMOTESESSION);
if(w <= 0 || h <= 0 || remote)
{
w = r.width() / 3;
h = r.width() / 4;
if(!remote)
{
w *= 2;
h *= 2;
}
}
r.left = (r.left + r.right - w) / 2;
r.top = (r.top + r.bottom - h) / 2;
r.right = r.left + w;
r.bottom = r.top + h;
AdjustWindowRect(r, style, FALSE);
m_hWnd = CreateWindow(wc.lpszClassName, title.c_str(), style, r.left, r.top, r.width(), r.height(), NULL, NULL, wc.hInstance, (LPVOID)this);
return m_hWnd != NULL;
}
bool GSWnd::Attach(void* handle, bool managed)
{
// TODO: subclass
m_hWnd = (HWND)handle;
m_managed = managed;
return true;
}
void GSWnd::Detach()
{
if(m_hWnd && m_managed)
{
// close the window, since it's under GSdx care. It's not taking messages anyway, and
// that means its big, ugly, and in the way.
DestroyWindow(m_hWnd);
}
m_hWnd = NULL;
m_managed = true;
}
GSVector4i GSWnd::GetClientRect()
{
GSVector4i r;
::GetClientRect(m_hWnd, r);
return r;
}
// Returns FALSE if the window has no title, or if th window title is under the strict
// management of the emulator.
bool GSWnd::SetWindowText(const char* title)
{
if(!m_managed) return false;
::SetWindowText(m_hWnd, title);
return m_frame;
}
void GSWnd::Show()
{
if(!m_managed) return;
SetForegroundWindow(m_hWnd);
ShowWindow(m_hWnd, SW_SHOWNORMAL);
UpdateWindow(m_hWnd);
}
void GSWnd::Hide()
{
if(!m_managed) return;
ShowWindow(m_hWnd, SW_HIDE);
}
void GSWnd::HideFrame()
{
if(!m_managed) return;
SetWindowLong(m_hWnd, GWL_STYLE, GetWindowLong(m_hWnd, GWL_STYLE) & ~(WS_CAPTION|WS_THICKFRAME));
SetWindowPos(m_hWnd, NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
SetMenu(m_hWnd, NULL);
m_frame = false;
}
#else
GSWnd::GSWnd()
: m_window(NULL), m_Xwindow(0), m_XDisplay(NULL), m_ctx_attached(false), m_swapinterval(NULL)
{
}
GSWnd::~GSWnd()
{
if (m_XDisplay) {
XCloseDisplay(m_XDisplay);
m_XDisplay = NULL;
}
}
static bool ctxError = false;
static int ctxErrorHandler(Display *dpy, XErrorEvent *ev)
{
ctxError = true;
return 0;
}
bool GSWnd::CreateContext(int major, int minor)
{
if ( !m_XDisplay || !m_Xwindow )
{
fprintf( stderr, "Wrong X11 display/window\n" );
exit(1);
}
// Get visual information
static int attrListDbl[] =
{
// GLX_X_RENDERABLE: If True is specified, then only frame buffer configurations that have associated X
// visuals (and can be used to render to Windows and/or GLX pixmaps) will be considered. The default value is GLX_DONT_CARE.
GLX_X_RENDERABLE , True,
GLX_RED_SIZE , 8,
GLX_GREEN_SIZE , 8,
GLX_BLUE_SIZE , 8,
GLX_DEPTH_SIZE , 24,
GLX_DOUBLEBUFFER , True,
None
};
PFNGLXCHOOSEFBCONFIGPROC glXChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC) glXGetProcAddress((GLubyte *) "glXChooseFBConfig");
int fbcount = 0;
GLXFBConfig *fbc = glXChooseFBConfig(m_XDisplay, DefaultScreen(m_XDisplay), attrListDbl, &fbcount);
if (!fbc || fbcount < 1) return false;
PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress((const GLubyte*) "glXCreateContextAttribsARB");
if (!glXCreateContextAttribsARB) return false;
// Install a dummy handler to handle gracefully (aka not segfault) the support of GL version
int (*oldHandler)(Display*, XErrorEvent*) = XSetErrorHandler(&ctxErrorHandler);
// Be sure the handler is installed
XSync( m_XDisplay, false);
// Create a context
int context_attribs[] =
{
GLX_CONTEXT_MAJOR_VERSION_ARB, major,
GLX_CONTEXT_MINOR_VERSION_ARB, minor,
// FIXME : Request a debug context to ease opengl development
// Note: don't support deprecated feature (pre openg 3.1)
//GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB | GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB,
None
};
m_context = glXCreateContextAttribsARB(m_XDisplay, fbc[0], 0, true, context_attribs);
// Don't forget to reinstall the older Handler
XSetErrorHandler(oldHandler);
// Get latest error
XSync( m_XDisplay, false);
if (!m_context || ctxError) {
fprintf(stderr, "Failed to create the opengl context. Check your drivers support openGL %d.%d. Hint: opensource drivers don't\n", major, minor );
return false;
}
return true;
}
void GSWnd::AttachContext()
{
if (!IsContextAttached()) {
//fprintf(stderr, "Attach the context\n");
glXMakeCurrent(m_XDisplay, m_Xwindow, m_context);
m_ctx_attached = true;
}
}
void GSWnd::DetachContext()
{
if (IsContextAttached()) {
//fprintf(stderr, "Detach the context\n");
glXMakeCurrent(m_XDisplay, None, NULL);
m_ctx_attached = false;
}
}
void GSWnd::CheckContext()
{
int glxMajorVersion, glxMinorVersion;
glXQueryVersion(m_XDisplay, &glxMajorVersion, &glxMinorVersion);
if (glXIsDirect(m_XDisplay, m_context))
fprintf(stderr, "glX-Version %d.%d with Direct Rendering\n", glxMajorVersion, glxMinorVersion);
else
fprintf(stderr, "glX-Version %d.%d with Indirect Rendering !!! It won't support properly opengl\n", glxMajorVersion, glxMinorVersion);
}
bool GSWnd::Attach(void* handle, bool managed)
{
m_Xwindow = *(Window*)handle;
m_managed = managed;
m_renderer = theApp.GetConfig("renderer", 0) / 3;
assert(m_renderer != 2);
m_XDisplay = XOpenDisplay(NULL);
// Note: 4.2 crash on latest nvidia drivers!
if (!CreateContext(3, 3)) return false;
AttachContext();
CheckContext();
PFNGLXSWAPINTERVALMESAPROC m_swapinterval = (PFNGLXSWAPINTERVALMESAPROC)glXGetProcAddress((const GLubyte*) "glXSwapIntervalMESA");
//PFNGLXSWAPINTERVALMESAPROC m_swapinterval = (PFNGLXSWAPINTERVALMESAPROC)glXGetProcAddress((const GLubyte*) "glXSwapInterval");
return true;
}
void GSWnd::Detach()
{
// Actually the destructor is not called when there is only a GSclose/GSshutdown
// The window still need to be closed
DetachContext();
if (m_context) glXDestroyContext(m_XDisplay, m_context);
if (m_XDisplay) {
XCloseDisplay(m_XDisplay);
m_XDisplay = NULL;
}
}
bool GSWnd::Create(const string& title, int w, int h)
{
if(m_window != NULL) return false;
if(w <= 0 || h <= 0) {
w = theApp.GetConfig("ModeWidth", 640);
h = theApp.GetConfig("ModeHeight", 480);
}
m_managed = true;
// note this part must be only executed when replaying .gs debug file
m_XDisplay = XOpenDisplay(NULL);
int attrListDbl[] = { GLX_RGBA, GLX_DOUBLEBUFFER,
GLX_RED_SIZE, 8,
GLX_GREEN_SIZE, 8,
GLX_BLUE_SIZE, 8,
GLX_DEPTH_SIZE, 24,
None
};
XVisualInfo* vi = glXChooseVisual(m_XDisplay, DefaultScreen(m_XDisplay), attrListDbl);
/* create a color map */
XSetWindowAttributes attr;
attr.colormap = XCreateColormap(m_XDisplay, RootWindow(m_XDisplay, vi->screen),
vi->visual, AllocNone);
attr.border_pixel = 0;
attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask |
StructureNotifyMask | SubstructureRedirectMask | SubstructureNotifyMask |
EnterWindowMask | LeaveWindowMask | FocusChangeMask ;
// Create a window at the last position/size
m_Xwindow = XCreateWindow(m_XDisplay, RootWindow(m_XDisplay, vi->screen),
0 , 0 , w, h, 0, vi->depth, InputOutput, vi->visual,
CWBorderPixel | CWColormap | CWEventMask, &attr);
XMapWindow (m_XDisplay, m_Xwindow);
XFree(vi);
if (!CreateContext(3, 3)) return false;
AttachContext();
return (m_Xwindow != 0);
}
Display* GSWnd::GetDisplay()
{
// note this part must be only executed when replaying .gs debug file
return m_XDisplay;
}
GSVector4i GSWnd::GetClientRect()
{
unsigned int h = 480;
unsigned int w = 640;
unsigned int borderDummy;
unsigned int depthDummy;
Window winDummy;
int xDummy;
int yDummy;
if (!m_XDisplay) m_XDisplay = XOpenDisplay(NULL);
XGetGeometry(m_XDisplay, m_Xwindow, &winDummy, &xDummy, &yDummy, &w, &h, &borderDummy, &depthDummy);
return GSVector4i(0, 0, (int)w, (int)h);
}
// Returns FALSE if the window has no title, or if th window title is under the strict
// management of the emulator.
bool GSWnd::SetWindowText(const char* title)
{
if (!m_managed) return true;
XTextProperty prop;
memset(&prop, 0, sizeof(prop));
char* ptitle = (char*)title;
if (XStringListToTextProperty(&ptitle, 1, &prop)) {
XSetWMName(m_XDisplay, m_Xwindow, &prop);
}
XFree(prop.value);
XFlush(m_XDisplay);
return true;
}
void GSWnd::SetVSync(bool enable)
{
// m_swapinterval uses an integer as parameter
// 0 -> disable vsync
// n -> wait n frame
if (m_swapinterval) m_swapinterval((int)enable);
}
void GSWnd::Flip()
{
glXSwapBuffers(m_XDisplay, m_Xwindow);
}
void GSWnd::Show()
{
XMapRaised(m_XDisplay, m_Xwindow);
XFlush(m_XDisplay);
}
void GSWnd::Hide()
{
XUnmapWindow(m_XDisplay, m_Xwindow);
XFlush(m_XDisplay);
}
void GSWnd::HideFrame()
{
// TODO
}
#endif

View File

@ -21,81 +21,37 @@
#pragma once
#include "stdafx.h"
#include "GSdx.h"
#include "GSVector.h"
#ifdef _WINDOWS
class GSWnd
{
HWND m_hWnd;
protected:
bool m_managed; // set true when we're attached to a 3rdparty window that's amanged by the emulator
bool m_frame;
static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
virtual LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
public:
GSWnd();
virtual ~GSWnd();
GSWnd() : m_managed(false) {};
virtual ~GSWnd() {};
bool Create(const string& title, int w, int h);
bool Attach(void* handle, bool managed = true);
void Detach();
virtual bool Create(const string& title, int w, int h) = 0;
virtual bool Attach(void* handle, bool managed = true) = 0;
virtual void Detach() = 0;
bool IsManaged() const {return m_managed;}
void* GetDisplay() {return m_hWnd;}
void* GetHandle() {return m_hWnd;}
GSVector4i GetClientRect();
bool SetWindowText(const char* title);
virtual void* GetDisplay() = 0;
virtual void* GetHandle() = 0;
virtual GSVector4i GetClientRect() = 0;
virtual bool SetWindowText(const char* title) = 0;
virtual void AttachContext() {};
virtual void DetachContext() {};
virtual void Show() = 0;
virtual void Hide() = 0;
virtual void HideFrame() = 0;
virtual void Flip() {};
virtual void SetVSync(bool enable) {};
void Show();
void Hide();
void HideFrame();
};
#else
#include <X11/Xlib.h>
class GSWnd
{
void* m_window;
Window m_Xwindow;
Display* m_XDisplay;
bool m_ctx_attached;
bool m_managed;
int m_renderer;
GLXContext m_context;
PFNGLXSWAPINTERVALMESAPROC m_swapinterval;
public:
GSWnd();
virtual ~GSWnd();
bool Create(const string& title, int w, int h);
bool Attach(void* handle, bool managed = true);
void Detach();
bool IsManaged() const {return m_managed;}
bool IsContextAttached() const { return m_ctx_attached; }
Display* GetDisplay();
void* GetHandle() {return (void*)m_Xwindow;}
GSVector4i GetClientRect();
bool SetWindowText(const char* title);
bool CreateContext(int major, int minor);
void AttachContext();
void DetachContext();
void CheckContext();
void Show();
void Hide();
void HideFrame();
void Flip();
void SetVSync(bool enable);
};
#endif

209
plugins/GSdx/GSWndDX.cpp Normal file
View File

@ -0,0 +1,209 @@
/*
* Copyright (C) 2007-2012 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#include "stdafx.h"
#include "GSWndDX.h"
#ifdef _WINDOWS
GSWndDX::GSWndDX()
: m_hWnd(NULL)
, m_frame(true)
{
}
GSWndDX::~GSWndDX()
{
}
LRESULT CALLBACK GSWndDX::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
GSWndDX* wnd = NULL;
if(message == WM_NCCREATE)
{
wnd = (GSWndDX*)((LPCREATESTRUCT)lParam)->lpCreateParams;
SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)wnd);
wnd->m_hWnd = hWnd;
}
else
{
wnd = (GSWndDX*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
}
if(wnd == NULL)
{
return DefWindowProc(hWnd, message, wParam, lParam);
}
return wnd->OnMessage(message, wParam, lParam);
}
LRESULT GSWndDX::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
{
switch(message)
{
case WM_CLOSE:
Hide();
// DestroyWindow(m_hWnd);
return 0;
case WM_DESTROY:
// This kills the emulator when GS is closed, which *really* isn't desired behavior,
// especially in STGS mode (worked in MTGS mode since it only quit the thread, but even
// that wasn't needed).
//PostQuitMessage(0);
return 0;
default:
break;
}
return DefWindowProc((HWND)m_hWnd, message, wParam, lParam);
}
bool GSWndDX::Create(const string& title, int w, int h)
{
if(m_hWnd) return false;
WNDCLASS wc;
memset(&wc, 0, sizeof(wc));
wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
wc.lpfnWndProc = WndProc;
wc.hInstance = theApp.GetModuleHandle();
// TODO: wc.hIcon = ;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszClassName = "GSWndDX";
if(!GetClassInfo(wc.hInstance, wc.lpszClassName, &wc))
{
if(!RegisterClass(&wc))
{
return false;
}
}
DWORD style = WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_OVERLAPPEDWINDOW | WS_BORDER;
GSVector4i r;
GetWindowRect(GetDesktopWindow(), r);
bool remote = !!GetSystemMetrics(SM_REMOTESESSION);
if(w <= 0 || h <= 0 || remote)
{
w = r.width() / 3;
h = r.width() / 4;
if(!remote)
{
w *= 2;
h *= 2;
}
}
r.left = (r.left + r.right - w) / 2;
r.top = (r.top + r.bottom - h) / 2;
r.right = r.left + w;
r.bottom = r.top + h;
AdjustWindowRect(r, style, FALSE);
m_hWnd = CreateWindow(wc.lpszClassName, title.c_str(), style, r.left, r.top, r.width(), r.height(), NULL, NULL, wc.hInstance, (LPVOID)this);
return m_hWnd != NULL;
}
bool GSWndDX::Attach(void* handle, bool managed)
{
// TODO: subclass
m_hWnd = (HWND)handle;
m_managed = managed;
return true;
}
void GSWndDX::Detach()
{
if(m_hWnd && m_managed)
{
// close the window, since it's under GSdx care. It's not taking messages anyway, and
// that means its big, ugly, and in the way.
DestroyWindow(m_hWnd);
}
m_hWnd = NULL;
m_managed = true;
}
GSVector4i GSWndDX::GetClientRect()
{
GSVector4i r;
::GetClientRect(m_hWnd, r);
return r;
}
// Returns FALSE if the window has no title, or if th window title is under the strict
// management of the emulator.
bool GSWndDX::SetWindowText(const char* title)
{
if(!m_managed) return false;
::SetWindowText(m_hWnd, title);
return m_frame;
}
void GSWndDX::Show()
{
if(!m_managed) return;
SetForegroundWindow(m_hWnd);
ShowWindow(m_hWnd, SW_SHOWNORMAL);
UpdateWindow(m_hWnd);
}
void GSWndDX::Hide()
{
if(!m_managed) return;
ShowWindow(m_hWnd, SW_HIDE);
}
void GSWndDX::HideFrame()
{
if(!m_managed) return;
SetWindowLong(m_hWnd, GWL_STYLE, GetWindowLong(m_hWnd, GWL_STYLE) & ~(WS_CAPTION|WS_THICKFRAME));
SetWindowPos(m_hWnd, NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
SetMenu(m_hWnd, NULL);
m_frame = false;
}
#endif

52
plugins/GSdx/GSWndDX.h Normal file
View File

@ -0,0 +1,52 @@
/*
* Copyright (C) 2007-2012 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#include "stdafx.h"
#include "GSWnd.h"
#ifdef _WINDOWS
class GSWndDX : public GSWnd
{
HWND m_hWnd;
bool m_frame;
static LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
virtual LRESULT OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
public:
GSWndDX();
virtual ~GSWndDX();
bool Create(const string& title, int w, int h);
bool Attach(void* handle, bool managed = true);
void Detach();
void* GetDisplay() {return m_hWnd;}
void* GetHandle() {return m_hWnd;}
GSVector4i GetClientRect();
bool SetWindowText(const char* title);
void Show();
void Hide();
void HideFrame();
};
#endif

282
plugins/GSdx/GSWndEGL.cpp Normal file
View File

@ -0,0 +1,282 @@
/*
* Copyright (C) 2007-2012 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#include "stdafx.h"
#include "GSWndEGL.h"
// Need at least MESA 9.0 (plan for october/november 2012)
// So force the destiny to at least check the compilation
#ifndef EGL_KHR_create_context
#define EGL_KHR_create_context 1
#define EGL_CONTEXT_MAJOR_VERSION_KHR EGL_CONTEXT_CLIENT_VERSION
#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB
#define EGL_CONTEXT_FLAGS_KHR 0x30FC
#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD
#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD
#define EGL_NO_RESET_NOTIFICATION_KHR 0x31BE
#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31BF
#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001
#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002
#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004
#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001
#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002
#endif
#if defined(_LINUX) && defined (EGL_API)
GSWndEGL::GSWndEGL()
: m_NativeWindow(0), m_NativeDisplay(NULL), m_ctx_attached(false)
{
}
bool GSWndEGL::CreateContext(int major, int minor)
{
EGLConfig eglConfig;
EGLint numConfigs;
EGLint contextAttribs[] =
{
// Not yet supported by Radeon/Gallium
#if 0
EGL_CONTEXT_MAJOR_VERSION_KHR, major,
EGL_CONTEXT_MINOR_VERSION_KHR, minor,
// Keep compatibility for old cruft
//EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR, EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR,
// FIXME : Request a debug context to ease opengl development
EGL_CONTEXT_FLAGS_KHR, EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR | EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR,
#endif
EGL_NONE
};
EGLint attrList[] = {
EGL_RED_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_BLUE_SIZE, 8,
EGL_DEPTH_SIZE, 24,
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
EGL_NONE
};
eglBindAPI(EGL_OPENGL_API);
if ( !eglChooseConfig(m_eglDisplay, attrList, &eglConfig, 1, &numConfigs) )
{
fprintf(stderr,"EGL: Failed to get a frame buffer config!\n");
return EGL_FALSE;
}
m_eglSurface = eglCreateWindowSurface(m_eglDisplay, eglConfig, m_NativeWindow, NULL);
if ( m_eglSurface == EGL_NO_SURFACE )
{
fprintf(stderr,"EGL: Failed to get a window surface\n");
return EGL_FALSE;
}
m_eglContext = eglCreateContext(m_eglDisplay, eglConfig, EGL_NO_CONTEXT, contextAttribs );
if ( m_eglContext == EGL_NO_CONTEXT )
{
fprintf(stderr,"EGL: Failed to create the context\n");
fprintf(stderr,"EGL STATUS: %x\n", eglGetError());
return EGL_FALSE;
}
if ( !eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext) )
{
return EGL_FALSE;
}
return EGL_TRUE;
}
void GSWndEGL::AttachContext()
{
if (!IsContextAttached()) {
// The setting of the API is local to a thread. This function
// can be called from 2 threads.
eglBindAPI(EGL_OPENGL_API);
//fprintf(stderr, "Attach the context\n");
eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext);
m_ctx_attached = true;
}
}
void GSWndEGL::DetachContext()
{
if (IsContextAttached()) {
//fprintf(stderr, "Detach the context\n");
eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
m_ctx_attached = false;
}
}
void GSWndEGL::CheckContext()
{
fprintf(stderr,"EGL: %s : %s\n", eglQueryString(m_eglDisplay, EGL_VENDOR) , eglQueryString(m_eglDisplay, EGL_VERSION) );
fprintf(stderr,"EGL: extensions supported: %s\n", eglQueryString(m_eglDisplay, EGL_EXTENSIONS));
}
bool GSWndEGL::Attach(void* handle, bool managed)
{
m_NativeWindow = *(Window*)handle;
m_managed = managed;
m_NativeDisplay = XOpenDisplay(NULL);
if (!OpenEGLDisplay()) return false;
// Note: 4.2 crash on latest nvidia drivers!
if (!CreateContext(3, 3)) return false;
AttachContext();
CheckContext();
return true;
}
void GSWndEGL::Detach()
{
// Actually the destructor is not called when there is only a GSclose/GSshutdown
// The window still need to be closed
DetachContext();
CloseEGLDisplay();
if (m_NativeDisplay) {
XCloseDisplay(m_NativeDisplay);
m_NativeDisplay = NULL;
}
}
bool GSWndEGL::Create(const string& title, int w, int h)
{
if(m_NativeWindow) return false;
if(w <= 0 || h <= 0) {
w = theApp.GetConfig("ModeWidth", 640);
h = theApp.GetConfig("ModeHeight", 480);
}
m_managed = true;
// note this part must be only executed when replaying .gs debug file
m_NativeDisplay = XOpenDisplay(NULL);
if (!OpenEGLDisplay()) return false;
m_NativeWindow = XCreateSimpleWindow(m_NativeDisplay, DefaultRootWindow(m_NativeDisplay), 0, 0, w, h, 0, 0, 0);
XMapWindow (m_NativeDisplay, m_NativeWindow);
if (!CreateContext(3, 3)) return false;
AttachContext();
return (m_NativeWindow != 0);
}
void* GSWndEGL::GetDisplay()
{
// note this part must be only executed when replaying .gs debug file
return (void*)m_NativeDisplay;
}
GSVector4i GSWndEGL::GetClientRect()
{
unsigned int h = 480;
unsigned int w = 640;
unsigned int borderDummy;
unsigned int depthDummy;
Window winDummy;
int xDummy;
int yDummy;
if (!m_NativeDisplay) m_NativeDisplay = XOpenDisplay(NULL);
XGetGeometry(m_NativeDisplay, m_NativeWindow, &winDummy, &xDummy, &yDummy, &w, &h, &borderDummy, &depthDummy);
return GSVector4i(0, 0, (int)w, (int)h);
}
// Returns FALSE if the window has no title, or if th window title is under the strict
// management of the emulator.
bool GSWndEGL::SetWindowText(const char* title)
{
if (!m_managed) return true;
XTextProperty prop;
memset(&prop, 0, sizeof(prop));
char* ptitle = (char*)title;
if (XStringListToTextProperty(&ptitle, 1, &prop)) {
XSetWMName(m_NativeDisplay, m_NativeWindow, &prop);
}
XFree(prop.value);
XFlush(m_NativeDisplay);
return true;
}
void GSWndEGL::SetVSync(bool enable)
{
// 0 -> disable vsync
// n -> wait n frame
eglSwapInterval(m_eglDisplay, enable);
}
void GSWndEGL::Flip()
{
eglSwapBuffers(m_eglDisplay, m_eglSurface);
}
void GSWndEGL::Show()
{
XMapRaised(m_NativeDisplay, m_NativeWindow);
XFlush(m_NativeDisplay);
}
void GSWndEGL::Hide()
{
XUnmapWindow(m_NativeDisplay, m_NativeWindow);
XFlush(m_NativeDisplay);
}
void GSWndEGL::HideFrame()
{
// TODO
}
void GSWndEGL::CloseEGLDisplay()
{
eglTerminate(m_eglDisplay);
}
EGLBoolean GSWndEGL::OpenEGLDisplay()
{
// Create an EGL display from the native display
m_eglDisplay = eglGetDisplay((EGLNativeDisplayType)m_NativeDisplay);
if ( m_eglDisplay == EGL_NO_DISPLAY ) return EGL_FALSE;
if ( !eglInitialize(m_eglDisplay, NULL, NULL) ) return EGL_FALSE;
return EGL_TRUE;
}
#endif

70
plugins/GSdx/GSWndEGL.h Normal file
View File

@ -0,0 +1,70 @@
/*
* Copyright (C) 2007-2012 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#include "GSWnd.h"
#if defined(_LINUX) && defined (EGL_API)
#include <X11/Xlib.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
class GSWndEGL : public GSWnd
{
EGLNativeWindowType m_NativeWindow;
EGLNativeDisplayType m_NativeDisplay;
EGLDisplay m_eglDisplay;
EGLSurface m_eglSurface;
EGLContext m_eglContext;
bool m_ctx_attached;
bool IsContextAttached() const { return m_ctx_attached; }
bool CreateContext(int major, int minor);
void CheckContext();
EGLBoolean OpenEGLDisplay();
void CloseEGLDisplay();
public:
GSWndEGL();
virtual ~GSWndEGL() {};
bool Create(const string& title, int w, int h);
bool Attach(void* handle, bool managed = true);
void Detach();
void* GetDisplay();
void* GetHandle() {return (void*)m_NativeWindow;}
GSVector4i GetClientRect();
bool SetWindowText(const char* title);
void AttachContext();
void DetachContext();
void Show();
void Hide();
void HideFrame();
void Flip();
void SetVSync(bool enable);
};
#endif

297
plugins/GSdx/GSWndOGL.cpp Normal file
View File

@ -0,0 +1,297 @@
/*
* Copyright (C) 2007-2012 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#include "stdafx.h"
#include "GSWndOGL.h"
#ifdef _LINUX
GSWndOGL::GSWndOGL()
: m_NativeWindow(0), m_NativeDisplay(NULL), m_swapinterval(NULL), m_ctx_attached(false)
{
}
static bool ctxError = false;
static int ctxErrorHandler(Display *dpy, XErrorEvent *ev)
{
ctxError = true;
return 0;
}
bool GSWndOGL::CreateContext(int major, int minor)
{
if ( !m_NativeDisplay || !m_NativeWindow )
{
fprintf( stderr, "Wrong X11 display/window\n" );
exit(1);
}
// Get visual information
static int attrListDbl[] =
{
// GLX_X_RENDERABLE: If True is specified, then only frame buffer configurations that have associated X
// visuals (and can be used to render to Windows and/or GLX pixmaps) will be considered. The default value is GLX_DONT_CARE.
GLX_X_RENDERABLE , True,
GLX_RED_SIZE , 8,
GLX_GREEN_SIZE , 8,
GLX_BLUE_SIZE , 8,
GLX_DEPTH_SIZE , 24,
GLX_DOUBLEBUFFER , True,
None
};
PFNGLXCHOOSEFBCONFIGPROC glX_ChooseFBConfig = (PFNGLXCHOOSEFBCONFIGPROC) glXGetProcAddress((GLubyte *) "glXChooseFBConfig");
int fbcount = 0;
GLXFBConfig *fbc = glX_ChooseFBConfig(m_NativeDisplay, DefaultScreen(m_NativeDisplay), attrListDbl, &fbcount);
if (!fbc || fbcount < 1) return false;
PFNGLXCREATECONTEXTATTRIBSARBPROC glX_CreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress((const GLubyte*) "glXCreateContextAttribsARB");
if (!glX_CreateContextAttribsARB) return false;
// Install a dummy handler to handle gracefully (aka not segfault) the support of GL version
int (*oldHandler)(Display*, XErrorEvent*) = XSetErrorHandler(&ctxErrorHandler);
// Be sure the handler is installed
XSync( m_NativeDisplay, false);
// Create a context
int context_attribs[] =
{
GLX_CONTEXT_MAJOR_VERSION_ARB, major,
GLX_CONTEXT_MINOR_VERSION_ARB, minor,
// FIXME : Request a debug context to ease opengl development
// Note: don't support deprecated feature (pre openg 3.1)
//GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB | GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB,
None
};
m_context = glX_CreateContextAttribsARB(m_NativeDisplay, fbc[0], 0, true, context_attribs);
// Don't forget to reinstall the older Handler
XSetErrorHandler(oldHandler);
// Get latest error
XSync( m_NativeDisplay, false);
if (!m_context || ctxError) {
fprintf(stderr, "Failed to create the opengl context. Check your drivers support openGL %d.%d. Hint: opensource drivers don't\n", major, minor );
return false;
}
return true;
}
void GSWndOGL::AttachContext()
{
if (!IsContextAttached()) {
//fprintf(stderr, "Attach the context\n");
glXMakeCurrent(m_NativeDisplay, m_NativeWindow, m_context);
m_ctx_attached = true;
}
}
void GSWndOGL::DetachContext()
{
if (IsContextAttached()) {
//fprintf(stderr, "Detach the context\n");
glXMakeCurrent(m_NativeDisplay, None, NULL);
m_ctx_attached = false;
}
}
void GSWndOGL::CheckContext()
{
int glxMajorVersion, glxMinorVersion;
glXQueryVersion(m_NativeDisplay, &glxMajorVersion, &glxMinorVersion);
if (glXIsDirect(m_NativeDisplay, m_context))
fprintf(stderr, "glX-Version %d.%d with Direct Rendering\n", glxMajorVersion, glxMinorVersion);
else
fprintf(stderr, "glX-Version %d.%d with Indirect Rendering !!! It won't support properly opengl\n", glxMajorVersion, glxMinorVersion);
}
bool GSWndOGL::Attach(void* handle, bool managed)
{
m_NativeWindow = *(Window*)handle;
m_managed = managed;
m_NativeDisplay = XOpenDisplay(NULL);
// Note: 4.2 crash on latest nvidia drivers!
#ifdef OGL_FREE_DRIVER
if (!CreateContext(3, 0)) return false;
#else
if (!CreateContext(3, 3)) return false;
#endif
AttachContext();
CheckContext();
m_swapinterval = (PFNGLXSWAPINTERVALMESAPROC)glXGetProcAddress((const GLubyte*) "glXSwapIntervalMESA");
//PFNGLXSWAPINTERVALMESAPROC m_swapinterval = (PFNGLXSWAPINTERVALMESAPROC)glXGetProcAddress((const GLubyte*) "glXSwapInterval");
return true;
}
void GSWndOGL::Detach()
{
// Actually the destructor is not called when there is only a GSclose/GSshutdown
// The window still need to be closed
DetachContext();
if (m_context) glXDestroyContext(m_NativeDisplay, m_context);
if (m_NativeDisplay) {
XCloseDisplay(m_NativeDisplay);
m_NativeDisplay = NULL;
}
}
bool GSWndOGL::Create(const string& title, int w, int h)
{
if(m_NativeWindow) return false;
if(w <= 0 || h <= 0) {
w = theApp.GetConfig("ModeWidth", 640);
h = theApp.GetConfig("ModeHeight", 480);
}
m_managed = true;
// note this part must be only executed when replaying .gs debug file
m_NativeDisplay = XOpenDisplay(NULL);
#if 0
int attrListDbl[] = { GLX_RGBA, GLX_DOUBLEBUFFER,
GLX_RED_SIZE, 8,
GLX_GREEN_SIZE, 8,
GLX_BLUE_SIZE, 8,
GLX_DEPTH_SIZE, 24,
None
};
XVisualInfo* vi = glXChooseVisual(m_NativeDisplay, DefaultScreen(m_NativeDisplay), attrListDbl);
/* create a color map */
XSetWindowAttributes attr;
attr.colormap = XCreateColormap(m_NativeDisplay, RootWindow(m_NativeDisplay, vi->screen),
vi->visual, AllocNone);
attr.border_pixel = 0;
attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask |
StructureNotifyMask | SubstructureRedirectMask | SubstructureNotifyMask |
EnterWindowMask | LeaveWindowMask | FocusChangeMask ;
// Create a window at the last position/size
m_NativeWindow = XCreateWindow(m_NativeDisplay, RootWindow(m_NativeDisplay, vi->screen),
0 , 0 , w, h, 0, vi->depth, InputOutput, vi->visual,
CWBorderPixel | CWColormap | CWEventMask, &attr);
XFree(vi);
#else
m_NativeWindow = XCreateSimpleWindow(m_NativeDisplay, DefaultRootWindow(m_NativeDisplay), 0, 0, w, h, 0, 0, 0);
#endif
XMapWindow (m_NativeDisplay, m_NativeWindow);
if (!CreateContext(3, 3)) return false;
AttachContext();
CheckContext();
return (m_NativeWindow != 0);
}
void* GSWndOGL::GetDisplay()
{
// note this part must be only executed when replaying .gs debug file
return (void*)m_NativeDisplay;
}
GSVector4i GSWndOGL::GetClientRect()
{
unsigned int h = 480;
unsigned int w = 640;
unsigned int borderDummy;
unsigned int depthDummy;
Window winDummy;
int xDummy;
int yDummy;
if (!m_NativeDisplay) m_NativeDisplay = XOpenDisplay(NULL);
XGetGeometry(m_NativeDisplay, m_NativeWindow, &winDummy, &xDummy, &yDummy, &w, &h, &borderDummy, &depthDummy);
return GSVector4i(0, 0, (int)w, (int)h);
}
// Returns FALSE if the window has no title, or if th window title is under the strict
// management of the emulator.
bool GSWndOGL::SetWindowText(const char* title)
{
if (!m_managed) return true;
XTextProperty prop;
memset(&prop, 0, sizeof(prop));
char* ptitle = (char*)title;
if (XStringListToTextProperty(&ptitle, 1, &prop)) {
XSetWMName(m_NativeDisplay, m_NativeWindow, &prop);
}
XFree(prop.value);
XFlush(m_NativeDisplay);
return true;
}
void GSWndOGL::SetVSync(bool enable)
{
// m_swapinterval uses an integer as parameter
// 0 -> disable vsync
// n -> wait n frame
if (m_swapinterval) m_swapinterval((int)enable);
}
void GSWndOGL::Flip()
{
glXSwapBuffers(m_NativeDisplay, m_NativeWindow);
}
void GSWndOGL::Show()
{
XMapRaised(m_NativeDisplay, m_NativeWindow);
XFlush(m_NativeDisplay);
}
void GSWndOGL::Hide()
{
XUnmapWindow(m_NativeDisplay, m_NativeWindow);
XFlush(m_NativeDisplay);
}
void GSWndOGL::HideFrame()
{
// TODO
}
#endif

65
plugins/GSdx/GSWndOGL.h Normal file
View File

@ -0,0 +1,65 @@
/*
* Copyright (C) 2007-2012 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#include "GSWnd.h"
#ifdef _LINUX
#include <X11/Xlib.h>
#include <GL/glx.h>
class GSWndOGL : public GSWnd
{
Window m_NativeWindow;
Display* m_NativeDisplay;
GLXContext m_context;
bool m_ctx_attached;
PFNGLXSWAPINTERVALMESAPROC m_swapinterval;
bool IsContextAttached() const { return m_ctx_attached; }
bool CreateContext(int major, int minor);
void CheckContext();
public:
GSWndOGL();
virtual ~GSWndOGL() {};
bool Create(const string& title, int w, int h);
bool Attach(void* handle, bool managed = true);
void Detach();
void* GetDisplay();
void* GetHandle() {return (void*)m_NativeWindow;}
GSVector4i GetClientRect();
bool SetWindowText(const char* title);
void AttachContext();
void DetachContext();
void Show();
void Hide();
void HideFrame();
void Flip();
void SetVSync(bool enable);
};
#endif

304
plugins/GSdx/GSWndWGL.cpp Normal file
View File

@ -0,0 +1,304 @@
/*
* Copyright (C) 2007-2012 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#include "stdafx.h"
#include "GSWndWGL.h"
#ifdef _WINDOWS
GSWndWGL::GSWndWGL()
: m_NativeWindow(NULL), m_NativeDisplay(NULL), m_context(NULL), m_ctx_attached(false)
{
}
bool GSWndWGL::CreateContext(int major, int minor)
{
if ( !m_NativeDisplay || !m_NativeWindow )
{
fprintf( stderr, "Wrong display/window\n" );
exit(1);
}
// GL2 context are quite easy but we need GL3 which is another painful story...
if (!(m_context = wglCreateContext(m_NativeDisplay))) {
fprintf(stderr, "Failed to create a 2.0 context\n");
return false;
}
// FIXME test it
// Note: albeit every tutorial said that we need an opengl context to use the GL function wglCreateContextAttribsARB
// On linux it works without the extra temporary context, not sure the limitation still applied
if (major >= 3) {
AttachContext();
// Create a context
int context_attribs[] =
{
WGL_CONTEXT_MAJOR_VERSION_ARB, major,
WGL_CONTEXT_MINOR_VERSION_ARB, minor,
// FIXME : Request a debug context to ease opengl development
// Note: don't support deprecated feature (pre openg 3.1)
//GLX_CONTEXT_FLAGS_ARB, GLX_CONTEXT_DEBUG_BIT_ARB | GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB,
WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB,
0
};
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
if (!wglCreateContextAttribsARB) {
fprintf(stderr, "Failed to init wglCreateContextAttribsARB function pointer\n");
return false;
}
HGLRC context30 = wglCreateContextAttribsARB(m_NativeDisplay, NULL, context_attribs);
if (!context30) {
fprintf(stderr, "Failed to create a 3.x context\n");
return false;
}
DetachContext();
wglDeleteContext(m_context);
m_context = context30;
fprintf(stderr, "3.x GL context successfully created\n");
}
return true;
}
void GSWndWGL::AttachContext()
{
if (!IsContextAttached()) {
wglMakeCurrent(m_NativeDisplay, m_context);
m_ctx_attached = true;
}
}
void GSWndWGL::DetachContext()
{
if (IsContextAttached()) {
wglMakeCurrent(NULL, NULL);
m_ctx_attached = false;
}
}
//TODO: DROP ???
void GSWndWGL::CheckContext()
{
#if 0
int glxMajorVersion, glxMinorVersion;
glXQueryVersion(m_NativeDisplay, &glxMajorVersion, &glxMinorVersion);
if (glXIsDirect(m_NativeDisplay, m_context))
fprintf(stderr, "glX-Version %d.%d with Direct Rendering\n", glxMajorVersion, glxMinorVersion);
else
fprintf(stderr, "glX-Version %d.%d with Indirect Rendering !!! It won't support properly opengl\n", glxMajorVersion, glxMinorVersion);
#endif
}
bool GSWndWGL::Attach(void* handle, bool managed)
{
m_NativeWindow = (HWND)handle;
m_managed = managed;
if (!OpenWGLDisplay()) return false;
if (!CreateContext(3, 3)) return false;
AttachContext();
CheckContext();
// TODO
//m_swapinterval = (PFNGLXSWAPINTERVALMESAPROC)glXGetProcAddress((const GLubyte*) "glXSwapIntervalMESA");
//PFNGLXSWAPINTERVALMESAPROC m_swapinterval = (PFNGLXSWAPINTERVALMESAPROC)glXGetProcAddress((const GLubyte*) "glXSwapInterval");
UpdateWindow(m_NativeWindow);
return true;
}
void GSWndWGL::Detach()
{
// Actually the destructor is not called when there is only a GSclose/GSshutdown
// The window still need to be closed
DetachContext();
if (m_context) wglDeleteContext(m_context);
m_context = NULL;
CloseWGLDisplay();
}
bool GSWndWGL::OpenWGLDisplay()
{
GLuint PixelFormat; // Holds The Results After Searching For A Match
PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be
{
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
PFD_DOUBLEBUFFER, // Must Support Double Buffering
PFD_TYPE_RGBA, // Request An RGBA Format
32, // Select Our Color Depth
0, 0, 0, 0, 0, 0, // Color Bits Ignored
0, // 8bit Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
24, // 24Bit Z-Buffer (Depth Buffer)
8, // 8bit Stencil Buffer
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
};
if (!(m_NativeDisplay = GetDC(m_NativeWindow)))
{
MessageBox(NULL, "(1) Can't Create A GL Device Context.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
return false;
}
if (!(PixelFormat = ChoosePixelFormat(m_NativeDisplay, &pfd)))
{
MessageBox(NULL, "(2) Can't Find A Suitable PixelFormat.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
return false;
}
if (!SetPixelFormat(m_NativeDisplay, PixelFormat, &pfd))
{
MessageBox(NULL, "(3) Can't Set The PixelFormat.", "ERROR", MB_OK | MB_ICONEXCLAMATION);
return false;
}
return true;
}
void GSWndWGL::CloseWGLDisplay()
{
if (m_NativeDisplay && !ReleaseDC(m_NativeWindow, m_NativeDisplay)) // Are We Able To Release The DC
{
MessageBox(NULL, "Release Device Context Failed.", "SHUTDOWN ERROR", MB_OK | MB_ICONINFORMATION);
}
m_NativeDisplay = NULL; // Set DC To NULL
}
//TODO: GSopen 1 => Drop?
bool GSWndWGL::Create(const string& title, int w, int h)
{
#if 0
if(m_NativeWindow) return false;
if(w <= 0 || h <= 0) {
w = theApp.GetConfig("ModeWidth", 640);
h = theApp.GetConfig("ModeHeight", 480);
}
m_managed = true;
// note this part must be only executed when replaying .gs debug file
m_NativeDisplay = XOpenDisplay(NULL);
int attrListDbl[] = { GLX_RGBA, GLX_DOUBLEBUFFER,
GLX_RED_SIZE, 8,
GLX_GREEN_SIZE, 8,
GLX_BLUE_SIZE, 8,
GLX_DEPTH_SIZE, 24,
None
};
XVisualInfo* vi = glXChooseVisual(m_NativeDisplay, DefaultScreen(m_NativeDisplay), attrListDbl);
/* create a color map */
XSetWindowAttributes attr;
attr.colormap = XCreateColormap(m_NativeDisplay, RootWindow(m_NativeDisplay, vi->screen),
vi->visual, AllocNone);
attr.border_pixel = 0;
attr.event_mask = ExposureMask | KeyPressMask | KeyReleaseMask | ButtonPressMask |
StructureNotifyMask | SubstructureRedirectMask | SubstructureNotifyMask |
EnterWindowMask | LeaveWindowMask | FocusChangeMask ;
// Create a window at the last position/size
m_NativeWindow = XCreateWindow(m_NativeDisplay, RootWindow(m_NativeDisplay, vi->screen),
0 , 0 , w, h, 0, vi->depth, InputOutput, vi->visual,
CWBorderPixel | CWColormap | CWEventMask, &attr);
XMapWindow (m_NativeDisplay, m_NativeWindow);
XFree(vi);
if (!CreateContext(3, 3)) return false;
AttachContext();
return (m_NativeWindow != 0);
#else
return false;
#endif
}
//Same as DX
GSVector4i GSWndWGL::GetClientRect()
{
GSVector4i r;
::GetClientRect(m_NativeWindow, r);
return r;
}
//TODO: check extensions supported or not
//FIXME : extension allocation
void GSWndWGL::SetVSync(bool enable)
{
// m_swapinterval uses an integer as parameter
// 0 -> disable vsync
// n -> wait n frame
//if (m_swapinterval) m_swapinterval((int)enable);
// wglSwapIntervalEXT(!enable);
}
void GSWndWGL::Flip()
{
SwapBuffers(m_NativeDisplay);
}
void GSWndWGL::Show()
{
}
void GSWndWGL::Hide()
{
}
void GSWndWGL::HideFrame()
{
}
// Returns FALSE if the window has no title, or if th window title is under the strict
// management of the emulator.
bool GSWndWGL::SetWindowText(const char* title)
{
return false;
}
#endif

66
plugins/GSdx/GSWndWGL.h Normal file
View File

@ -0,0 +1,66 @@
/*
* Copyright (C) 2007-2012 Gabest
* http://www.gabest.org
*
* This Program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This Program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GNU Make; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
#include "GSWnd.h"
#ifdef _WINDOWS
class GSWndWGL : public GSWnd
{
HWND m_NativeWindow;
HDC m_NativeDisplay;
HGLRC m_context;
bool m_ctx_attached;
//PFNGLXSWAPINTERVALMESAPROC m_swapinterval;
bool IsContextAttached() const { return m_ctx_attached; }
bool CreateContext(int major, int minor);
void CheckContext();
void CloseWGLDisplay();
bool OpenWGLDisplay();
public:
GSWndWGL();
virtual ~GSWndWGL() {};
bool Create(const string& title, int w, int h);
bool Attach(void* handle, bool managed = true);
void Detach();
void* GetDisplay() {return m_NativeWindow;}
void* GetHandle() {return m_NativeWindow;}
GSVector4i GetClientRect();
bool SetWindowText(const char* title);
void AttachContext();
void DetachContext();
void Show();
void Hide();
void HideFrame();
void Flip();
void SetVSync(bool enable);
};
#endif

View File

@ -120,10 +120,8 @@ GSdxApp::GSdxApp()
#endif
m_gs_renderers.push_back(GSSetting(10, "Null", "Software"));
m_gs_renderers.push_back(GSSetting(11, "Null", "Null"));
#ifdef _LINUX
m_gs_renderers.push_back(GSSetting(12, "OpenGL", "Hardware"));
m_gs_renderers.push_back(GSSetting(13, "OpenGL", "Software"));
#endif
m_gs_interlace.push_back(GSSetting(0, "None", ""));
m_gs_interlace.push_back(GSSetting(1, "Weave tff", "saw-tooth"));
@ -172,6 +170,16 @@ GSdxApp::GSdxApp()
}
#ifdef _LINUX
void GSdxApp::ReloadConfig()
{
auto file = m_configuration_map.find("inifile");
if (file == m_configuration_map.end()) return;
// A map was built so reload it
m_configuration_map.clear();
BuildConfigurationMap(file->second.c_str());
}
void GSdxApp::BuildConfigurationMap(const char* lpFileName)
{
// Check if the map was already built

View File

@ -41,6 +41,8 @@ public:
#endif
#ifdef _LINUX
void BuildConfigurationMap(const char* lpFileName);
void ReloadConfig();
size_t GetPrivateProfileString(const char* lpAppName, const char* lpKeyName, const char* lpDefault, char* lpReturnedString, size_t nSize, const char* lpFileName);
bool WritePrivateProfileString(const char* lpAppName, const char* lpKeyName, const char* pString, const char* lpFileName);
int GetPrivateProfileInt(const char* lpAppName, const char* lpKeyName, int nDefault, const char* lpFileName);

View File

@ -438,6 +438,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="GLLoader.cpp" />
<ClCompile Include="GPU.cpp" />
<ClCompile Include="GPUDrawScanline.cpp" />
<ClCompile Include="GPUDrawScanlineCodeGenerator.cpp" />
@ -460,6 +461,7 @@
<ClCompile Include="GSDevice9.cpp" />
<ClCompile Include="GSDeviceDX.cpp" />
<ClCompile Include="GSDeviceNull.cpp" />
<ClCompile Include="GSDeviceOGL.cpp" />
<ClCompile Include="GSDeviceSW.cpp" />
<ClCompile Include="GSDialog.cpp" />
<ClCompile Include="GSDirtyRect.cpp" />
@ -536,6 +538,7 @@
<ClCompile Include="GSRendererDX9.cpp" />
<ClCompile Include="GSRendererHW.cpp" />
<ClCompile Include="GSRendererNull.cpp" />
<ClCompile Include="GSRendererOGL.cpp" />
<ClCompile Include="GSRendererSW.cpp" />
<ClCompile Include="GSSetting.cpp" />
<ClCompile Include="GSSettingsDlg.cpp" />
@ -601,12 +604,15 @@
<ClCompile Include="GSTexture.cpp" />
<ClCompile Include="GSTexture11.cpp" />
<ClCompile Include="GSTexture9.cpp" />
<ClCompile Include="GSTextureOGL.cpp" />
<ClCompile Include="GSTextureCache.cpp" />
<ClCompile Include="GSTextureCache11.cpp" />
<ClCompile Include="GSTextureCache9.cpp" />
<ClCompile Include="GSTextureCacheOGL.cpp" />
<ClCompile Include="GSTextureCacheSW.cpp" />
<ClCompile Include="GSTextureFX11.cpp" />
<ClCompile Include="GSTextureFX9.cpp" />
<ClCompile Include="GSTextureFXOGL.cpp" />
<ClCompile Include="GSTextureNull.cpp" />
<ClCompile Include="GSTextureSW.cpp" />
<ClCompile Include="GSThread.cpp" />
@ -618,6 +624,8 @@
<ClCompile Include="GSVertexSW.cpp" />
<ClCompile Include="GSVertexTrace.cpp" />
<ClCompile Include="GSWnd.cpp" />
<ClCompile Include="GSWndDX.cpp" />
<ClCompile Include="GSWndWGL.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug SSE2|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug SSE2|x64'">Create</PrecompiledHeader>
@ -1562,6 +1570,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="config.h" />
<ClInclude Include="GLLoader.h" />
<ClInclude Include="GPU.h" />
<ClInclude Include="GPUDrawingEnvironment.h" />
<ClInclude Include="GPUDrawScanline.h" />
@ -1587,6 +1596,7 @@
<ClInclude Include="GSDevice9.h" />
<ClInclude Include="GSDeviceDX.h" />
<ClInclude Include="GSDeviceNull.h" />
<ClInclude Include="GSDeviceOGL.h" />
<ClInclude Include="GSDeviceSW.h" />
<ClInclude Include="GSDialog.h" />
<ClInclude Include="GSDirtyRect.h" />
@ -1607,6 +1617,7 @@
<ClInclude Include="GSRendererDX9.h" />
<ClInclude Include="GSRendererHW.h" />
<ClInclude Include="GSRendererNull.h" />
<ClInclude Include="GSRendererOGL.h" />
<ClInclude Include="GSRendererSW.h" />
<ClInclude Include="GSScanlineEnvironment.h" />
<ClInclude Include="GSSetting.h" />
@ -1617,21 +1628,27 @@
<ClInclude Include="GSTexture.h" />
<ClInclude Include="GSTexture11.h" />
<ClInclude Include="GSTexture9.h" />
<ClInclude Include="GSTextureOGL.h" />
<ClInclude Include="GSTextureCache.h" />
<ClInclude Include="GSTextureCache11.h" />
<ClInclude Include="GSTextureCache9.h" />
<ClInclude Include="GSTextureCacheOGL.h" />
<ClInclude Include="GSTextureCacheSW.h" />
<ClInclude Include="GSTextureNull.h" />
<ClInclude Include="GSTextureSW.h" />
<ClInclude Include="GSThread.h" />
<ClInclude Include="GSUniformBufferOGL.h" />
<ClInclude Include="GSUtil.h" />
<ClInclude Include="GSVector.h" />
<ClInclude Include="GSVertex.h" />
<ClInclude Include="GSVertexArrayOGL.h" />
<ClInclude Include="GSVertexHW.h" />
<ClInclude Include="GSVertexList.h" />
<ClInclude Include="GSVertexSW.h" />
<ClInclude Include="GSVertexTrace.h" />
<ClInclude Include="GSWnd.h" />
<ClInclude Include="GSWndDX.h" />
<ClInclude Include="GSWndWGL.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="svnrev.h" />
<ClInclude Include="resource.h" />

View File

@ -60,6 +60,9 @@
<ClCompile Include="GSDeviceNull.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GSDeviceOGL.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GSDialog.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -108,6 +111,9 @@
<ClCompile Include="GSRendererNull.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GSRendererOGL.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GSRendererSW.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -135,6 +141,9 @@
<ClCompile Include="GSTexture9.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GSTextureOGL.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GSTextureCache.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -144,6 +153,9 @@
<ClCompile Include="GSTextureCache9.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GSTextureCacheOGL.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GSTextureCacheSW.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -153,6 +165,9 @@
<ClCompile Include="GSTextureFX9.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GSTextureFXOGL.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GSTextureNull.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -177,6 +192,12 @@
<ClCompile Include="GSWnd.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GSWndDX.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GSWndWGL.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -249,6 +270,9 @@
<ClCompile Include="baseclasses\wxutil.cpp">
<Filter>Baseclasses</Filter>
</ClCompile>
<ClCompile Include="GLLoader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GPU.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -314,6 +338,9 @@
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="GLLoader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GS.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -353,6 +380,9 @@
<ClInclude Include="GSDeviceNull.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GSDeviceOGL.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GSDialog.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -407,6 +437,9 @@
<ClInclude Include="GSRendererNull.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GSRendererOGL.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GSRendererSW.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -437,6 +470,9 @@
<ClInclude Include="GSTexture9.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GSTextureOGL.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GSTextureCache.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -446,6 +482,9 @@
<ClInclude Include="GSTextureCache9.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GSTextureCacheOGL.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GSTextureCacheSW.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -455,6 +494,9 @@
<ClInclude Include="GSThread.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GSUniformBufferOGL.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GSUtil.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -464,6 +506,9 @@
<ClInclude Include="GSVertex.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GSVertexArrayOGL.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GSVertexHW.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -479,6 +524,12 @@
<ClInclude Include="GSWnd.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GSWndDX.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GSWndWGL.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>

View File

@ -566,6 +566,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="GLLoader.cpp" />
<ClCompile Include="GPU.cpp" />
<ClCompile Include="GPUDrawScanline.cpp" />
<ClCompile Include="GPUDrawScanlineCodeGenerator.cpp" />
@ -588,6 +589,7 @@
<ClCompile Include="GSDevice9.cpp" />
<ClCompile Include="GSDeviceDX.cpp" />
<ClCompile Include="GSDeviceNull.cpp" />
<ClCompile Include="GSDeviceOGL.cpp" />
<ClCompile Include="GSDeviceSW.cpp" />
<ClCompile Include="GSDialog.cpp" />
<ClCompile Include="GSDirtyRect.cpp" />
@ -678,6 +680,7 @@
<ClCompile Include="GSRendererDX9.cpp" />
<ClCompile Include="GSRendererHW.cpp" />
<ClCompile Include="GSRendererNull.cpp" />
<ClCompile Include="GSRendererOGL.cpp" />
<ClCompile Include="GSRendererSW.cpp" />
<ClCompile Include="GSSetting.cpp" />
<ClCompile Include="GSSettingsDlg.cpp" />
@ -755,12 +758,15 @@
<ClCompile Include="GSTexture.cpp" />
<ClCompile Include="GSTexture11.cpp" />
<ClCompile Include="GSTexture9.cpp" />
<ClCompile Include="GSTextureOGL.cpp" />
<ClCompile Include="GSTextureCache.cpp" />
<ClCompile Include="GSTextureCache11.cpp" />
<ClCompile Include="GSTextureCache9.cpp" />
<ClCompile Include="GSTextureCacheOGL.cpp" />
<ClCompile Include="GSTextureCacheSW.cpp" />
<ClCompile Include="GSTextureFX11.cpp" />
<ClCompile Include="GSTextureFX9.cpp" />
<ClCompile Include="GSTextureFXOGL.cpp" />
<ClCompile Include="GSTextureNull.cpp" />
<ClCompile Include="GSTextureSW.cpp" />
<ClCompile Include="GSThread.cpp" />
@ -773,6 +779,8 @@
<ClCompile Include="GSVertexSW.cpp" />
<ClCompile Include="GSVertexTrace.cpp" />
<ClCompile Include="GSWnd.cpp" />
<ClCompile Include="GSWndDX.cpp" />
<ClCompile Include="GSWndWGL.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug SSE2|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug SSE2|x64'">Create</PrecompiledHeader>
@ -1905,6 +1913,7 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="config.h" />
<ClInclude Include="GLLoader.h" />
<ClInclude Include="GPU.h" />
<ClInclude Include="GPUDrawingEnvironment.h" />
<ClInclude Include="GPUDrawScanline.h" />
@ -1930,6 +1939,7 @@
<ClInclude Include="GSDevice9.h" />
<ClInclude Include="GSDeviceDX.h" />
<ClInclude Include="GSDeviceNull.h" />
<ClInclude Include="GSDeviceOGL.h" />
<ClInclude Include="GSDeviceSW.h" />
<ClInclude Include="GSDialog.h" />
<ClInclude Include="GSDirtyRect.h" />
@ -1950,6 +1960,7 @@
<ClInclude Include="GSRendererDX9.h" />
<ClInclude Include="GSRendererHW.h" />
<ClInclude Include="GSRendererNull.h" />
<ClInclude Include="GSRendererOGL.h" />
<ClInclude Include="GSRendererSW.h" />
<ClInclude Include="GSScanlineEnvironment.h" />
<ClInclude Include="GSSetting.h" />
@ -1960,21 +1971,27 @@
<ClInclude Include="GSTexture.h" />
<ClInclude Include="GSTexture11.h" />
<ClInclude Include="GSTexture9.h" />
<ClInclude Include="GSTextureOGL.h" />
<ClInclude Include="GSTextureCache.h" />
<ClInclude Include="GSTextureCache11.h" />
<ClInclude Include="GSTextureCache9.h" />
<ClInclude Include="GSTextureCacheOGL.h" />
<ClInclude Include="GSTextureCacheSW.h" />
<ClInclude Include="GSTextureNull.h" />
<ClInclude Include="GSTextureSW.h" />
<ClInclude Include="GSThread.h" />
<ClInclude Include="GSUniformBufferOGL.h" />
<ClInclude Include="GSUtil.h" />
<ClInclude Include="GSVector.h" />
<ClInclude Include="GSVertex.h" />
<ClInclude Include="GSVertexArrayOGL.h" />
<ClInclude Include="GSVertexHW.h" />
<ClInclude Include="GSVertexList.h" />
<ClInclude Include="GSVertexSW.h" />
<ClInclude Include="GSVertexTrace.h" />
<ClInclude Include="GSWnd.h" />
<ClInclude Include="GSWndDX.h" />
<ClInclude Include="GSWndWGL.h" />
<ClInclude Include="stdafx.h" />
<ClInclude Include="svnrev.h" />
<ClInclude Include="resource.h" />

View File

@ -60,6 +60,9 @@
<ClCompile Include="GSDeviceNull.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GSDeviceOGL.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GSDialog.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -108,6 +111,9 @@
<ClCompile Include="GSRendererNull.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GSRendererOGL.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GSRendererSW.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -135,6 +141,9 @@
<ClCompile Include="GSTexture9.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GSTextureOGL.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GSTextureCache.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -144,6 +153,9 @@
<ClCompile Include="GSTextureCache9.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GSTextureCacheOGL.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GSTextureCacheSW.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -153,6 +165,9 @@
<ClCompile Include="GSTextureFX9.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GSTextureFXOGL.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GSTextureNull.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -177,6 +192,12 @@
<ClCompile Include="GSWnd.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GSWndDX.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GSWndWGL.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -249,6 +270,9 @@
<ClCompile Include="baseclasses\wxutil.cpp">
<Filter>Baseclasses</Filter>
</ClCompile>
<ClCompile Include="GLLoader.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GPU.cpp">
<Filter>Source Files</Filter>
</ClCompile>
@ -314,6 +338,9 @@
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="GLLoader.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GS.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -353,6 +380,9 @@
<ClInclude Include="GSDeviceNull.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GSDeviceOGL.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GSDialog.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -407,6 +437,9 @@
<ClInclude Include="GSRendererNull.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GSRendererOGL.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GSRendererSW.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -437,6 +470,9 @@
<ClInclude Include="GSTexture9.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GSTextureOGL.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GSTextureCache.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -446,6 +482,9 @@
<ClInclude Include="GSTextureCache9.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GSTextureCacheOGL.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GSTextureCacheSW.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -455,6 +494,9 @@
<ClInclude Include="GSThread.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GSUniformBufferOGL.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GSUtil.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -464,6 +506,9 @@
<ClInclude Include="GSVertex.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GSVertexArrayOGL.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GSVertexHW.h">
<Filter>Header Files</Filter>
</ClInclude>
@ -479,6 +524,12 @@
<ClInclude Include="GSWnd.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GSWndDX.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="GSWndWGL.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>

View File

@ -773,6 +773,10 @@
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\GLLoader.cpp"
>
</File>
<File
RelativePath=".\GPU.cpp"
>
@ -861,6 +865,10 @@
RelativePath=".\GSDeviceNull.cpp"
>
</File>
<File
RelativePath=".\GSDeviceOGL.cpp"
>
</File>
<File
RelativePath=".\GSDeviceSW.cpp"
>
@ -1037,6 +1045,10 @@
RelativePath=".\GSRendererNull.cpp"
>
</File>
<File
RelativePath=".\GSRendererOGL.cpp"
>
</File>
<File
RelativePath=".\GSRendererSW.cpp"
>
@ -1177,6 +1189,10 @@
RelativePath=".\GSTexture9.cpp"
>
</File>
<File
RelativePath=".\GSTextureOGL.cpp"
>
</File>
<File
RelativePath=".\GSTextureCache.cpp"
>
@ -1189,6 +1205,10 @@
RelativePath=".\GSTextureCache9.cpp"
>
</File>
<File
RelativePath=".\GSTextureCacheOGL.cpp"
>
</File>
<File
RelativePath=".\GSTextureCacheSW.cpp"
>
@ -1201,6 +1221,10 @@
RelativePath=".\GSTextureFX9.cpp"
>
</File>
<File
RelativePath=".\GSTextureFXOGL.cpp"
>
</File>
<File
RelativePath=".\GSTextureNull.cpp"
>
@ -1237,6 +1261,14 @@
RelativePath=".\GSWnd.cpp"
>
</File>
<File
RelativePath=".\GSWndDX.cpp"
>
</File>
<File
RelativePath=".\GSWndWGL.cpp"
>
</File>
<File
RelativePath=".\stdafx.cpp"
>
@ -1359,6 +1391,10 @@
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\GLLoader.h"
>
</File>
<File
RelativePath=".\GPU.h"
>
@ -1459,6 +1495,10 @@
RelativePath=".\GSDeviceNull.h"
>
</File>
<File
RelativePath=".\GSDeviceOGL.h"
>
</File>
<File
RelativePath=".\GSDeviceSW.h"
>
@ -1539,6 +1579,10 @@
RelativePath=".\GSRendererNull.h"
>
</File>
<File
RelativePath=".\GSRendererOGL.h"
>
</File>
<File
RelativePath=".\GSRendererSW.h"
>
@ -1579,6 +1623,10 @@
RelativePath=".\GSTexture9.h"
>
</File>
<File
RelativePath=".\GSTextureOGL.h"
>
</File>
<File
RelativePath=".\GSTextureCache.h"
>
@ -1591,6 +1639,10 @@
RelativePath=".\GSTextureCache9.h"
>
</File>
<File
RelativePath=".\GSTextureCacheOGL.h"
>
</File>
<File
RelativePath=".\GSTextureCacheSW.h"
>
@ -1611,6 +1663,10 @@
RelativePath=".\GSThread.h"
>
</File>
<File
RelativePath=".\GSUniformBufferOGL.h"
>
</File>
<File
RelativePath=".\GSUtil.h"
>
@ -1623,6 +1679,10 @@
RelativePath=".\GSVertex.h"
>
</File>
<File
RelativePath=".\GSVertexArrayOGL.h"
>
</File>
<File
RelativePath=".\GSVertexHW.h"
>
@ -1643,6 +1703,14 @@
RelativePath=".\GSWnd.h"
>
</File>
<File
RelativePath=".\GSWndDX.h"
>
</File>
<File
RelativePath=".\GSWndWGL.h"
>
</File>
<File
RelativePath=".\stdafx.h"
>

View File

@ -36,8 +36,10 @@
//#define DISABLE_DATE
// Set manually uniform buffer index
//#define DISABLE_GL42
#define ENABLE_OGL_MT_HACK // OpenGL doesn't allow to access the same bound context from multiple threads. This hack changes context binding for GSreadFIFO* access
#ifdef _DEBUG
#define ENABLE_OGL_DEBUG // Create a debug context and check opengl command status. Allow also to dump various textures/states.
#endif
// Debug: use single program for all shaders.
//#define DISABLE_GL41_SSO
// Allow to create only a 3.0 context for opensource driver
//#define OGL_FREE_DRIVER

View File

@ -19,43 +19,55 @@
*/
#include "stdafx.h"
EXPORT_C GSsetSettingsDir(const char* dir);
EXPORT_C GSReplay(char* lpszCmdLine, int renderer);
#include <dlfcn.h>
void help()
{
fprintf(stderr, "Loader gs file\n");
fprintf(stderr, "ARG1 Ini directory\n");
fprintf(stderr, "ARG1 GSdx plugin\n");
fprintf(stderr, "ARG2 .gs file\n");
fprintf(stderr, "ARG3 Ini directory\n");
exit(1);
}
int main ( int argc, char *argv[] )
{
if ( argc == 3) {
GSsetSettingsDir(argv[1]);
GSReplay(argv[2], 12);
} else if ( argc == 2) {
if (argc < 3) help();
void *handle = dlopen(argv[1], RTLD_LAZY|RTLD_GLOBAL);
if (handle == NULL) {
fprintf(stderr, "Failed to open plugin %s\n", argv[1]);
help();
}
__attribute__((stdcall)) void (*GSsetSettingsDir_ptr)(const char*);
__attribute__((stdcall)) void (*GSReplay_ptr)(char*, int);
*(void**)(&GSsetSettingsDir_ptr) = dlsym(handle, "GSsetSettingsDir");
*(void**)(&GSReplay_ptr) = dlsym(handle, "GSReplay");
if ( argc == 4) {
(void)GSsetSettingsDir_ptr(argv[3]);
} else if ( argc == 3) {
#ifdef XDG_STD
std::string home("HOME");
char * val = getenv( home.c_str() );
if (val == NULL) {
fprintf(stderr, "Failed to get the home dir\n");
help();
}
char *val = getenv("HOME");
if (val == NULL) {
dlclose(handle);
fprintf(stderr, "Failed to get the home dir\n");
help();
}
std::string ini_dir(val);
ini_dir += "/.config/pcsx2/inis";
std::string ini_dir(val);
ini_dir += "/.config/pcsx2/inis";
GSsetSettingsDir(ini_dir.c_str());
GSReplay(argv[1], 12);
GSsetSettingsDir_ptr(ini_dir.c_str());
#else
fprintf(stderr, "default ini dir only supported on XDG\n");
help();
fprintf(stderr, "default ini dir only supported on XDG\n");
dlclose(handle);
help();
#endif
} else
help();
}
GSReplay_ptr(argv[2], 12);
dlclose(handle);
}

View File

@ -9,11 +9,13 @@ struct vertex_basic
#ifdef VERTEX_SHADER
#if __VERSION__ > 140
out gl_PerVertex {
vec4 gl_Position;
float gl_PointSize;
float gl_ClipDistance[];
};
#endif
layout(location = 0) in vec4 POSITION;
layout(location = 1) in vec2 TEXCOORD0;
@ -26,75 +28,75 @@ layout(location = 1) in vec2 TEXCOORD0;
// smooth, the default, means to do perspective-correct interpolation.
//
// The centroid qualifier only matters when multisampling. If this qualifier is not present, then the value is interpolated to the pixel's center, anywhere in the pixel, or to one of the pixel's samples. This sample may lie outside of the actual primitive being rendered, since a primitive can cover only part of a pixel's area. The centroid qualifier is used to prevent this; the interpolation point must fall within both the pixel's area and the primitive's area.
#if __VERSION__ > 140 && !(defined(NO_STRUCT))
layout(location = 0) out vertex_basic VSout;
#define VSout_p (VSout.p)
#define VSout_t (VSout.t)
#else
#ifdef DISABLE_SSO
out vec4 SHADERp;
out vec2 SHADERt;
#else
layout(location = 0) out vec4 SHADERp;
layout(location = 1) out vec2 SHADERt;
#endif
#define VSout_p SHADERp
#define VSout_t SHADERt
#endif
void vs_main()
{
VSout.p = POSITION;
VSout.t = TEXCOORD0;
VSout_p = POSITION;
VSout_t = TEXCOORD0;
gl_Position = POSITION; // NOTE I don't know if it is possible to merge POSITION_OUT and gl_Position
}
#endif
#ifdef GEOMETRY_SHADER
in gl_PerVertex {
vec4 gl_Position;
float gl_PointSize;
float gl_ClipDistance[];
} gl_in[];
out gl_PerVertex {
vec4 gl_Position;
float gl_PointSize;
float gl_ClipDistance[];
};
// FIXME
// AMD Driver bug again !!!!
//layout(location = 0) in vertex GSin[];
in vertex_basic GSin[];
layout(location = 0) out vertex_basic GSout;
layout(triangles) in;
layout(triangle_strip, max_vertices = 3) out;
void gs_main()
{
for(int i = 0; i < gl_in.length(); i++) {
gl_Position = gl_in[i].gl_Position;
GSout = GSin[i];
EmitVertex();
}
EndPrimitive();
}
#endif
#ifdef FRAGMENT_SHADER
// NOTE: pixel can be clip with "discard"
#if __VERSION__ > 140 && !(defined(NO_STRUCT))
layout(location = 0) in vertex_basic PSin;
#define PSin_p (PSin.p)
#define PSin_t (PSin.t)
#else
#ifdef DISABLE_SSO
in vec4 SHADERp;
in vec2 SHADERt;
#else
layout(location = 0) in vec4 SHADERp;
layout(location = 1) in vec2 SHADERt;
#endif
#define PSin_p SHADERp
#define PSin_t SHADERt
#endif
layout(location = 0) out vec4 SV_Target0;
layout(location = 1) out uint SV_Target1;
#ifdef DISABLE_GL42
uniform sampler2D TextureSampler;
#else
layout(binding = 0) uniform sampler2D TextureSampler;
#endif
vec4 sample_c()
{
return texture(TextureSampler, PSin.t );
return texture(TextureSampler, PSin_t );
}
vec4 ps_crt(uint i)
{
vec4 mask[4] =
{
uniform vec4 mask[4] = vec4[4]
(
vec4(1, 0, 0, 0),
vec4(0, 1, 0, 0),
vec4(0, 0, 1, 0),
vec4(1, 1, 1, 0)
};
);
vec4 ps_crt(uint i)
{
return sample_c() * clamp((mask[i] + 0.5f), 0.0f, 1.0f);
}
@ -125,7 +127,7 @@ void ps_main7()
void ps_main5() // triangular
{
highp uvec4 p = uvec4(PSin.p);
highp uvec4 p = uvec4(PSin_p);
vec4 c = ps_crt(((p.x + ((p.y >> 1u) & 1u) * 3u) >> 1u) % 3u);
@ -134,27 +136,35 @@ void ps_main5() // triangular
void ps_main6() // diagonal
{
uvec4 p = uvec4(PSin.p);
uvec4 p = uvec4(PSin_p);
vec4 c = ps_crt((p.x + (p.y % 3u)) % 3u);
SV_Target0 = c;
}
// Used for DATE (stencil)
void ps_main2()
{
if((sample_c().a - 128.0f / 255) < 0) // >= 0x80 pass
if((sample_c().a - 127.5f / 255) < 0) // >= 0x80 pass
discard;
SV_Target0 = vec4(0.0f, 0.0f, 0.0f, 0.0f);
#ifdef ENABLE_OGL_STENCIL_DEBUG
SV_Target0 = vec4(1.0f, 0.0f, 0.0f, 1.0f);
#endif
}
// Used for DATE (stencil)
void ps_main3()
{
if((127.95f / 255 - sample_c().a) <0) // < 0x80 pass (== 0x80 should not pass)
if((127.5f / 255 - sample_c().a) < 0) // < 0x80 pass (== 0x80 should not pass)
discard;
SV_Target0 = vec4(0.0f, 0.0f, 0.0f, 0.0f);
#ifdef ENABLE_OGL_STENCIL_DEBUG
SV_Target0 = vec4(1.0f, 0.0f, 0.0f, 1.0f);
#endif
}
void ps_main4()
{
// FIXME mod and fmod are different when value are negative

View File

@ -25,7 +25,7 @@
#include "stdafx.h"
extern const char* convert_glsl =
static const char* convert_glsl =
"//#version 420 // Keep it for editor detection\n"
"\n"
"struct vertex_basic\n"
@ -37,11 +37,13 @@ extern const char* convert_glsl =
"\n"
"#ifdef VERTEX_SHADER\n"
"\n"
"#if __VERSION__ > 140\n"
"out gl_PerVertex {\n"
" vec4 gl_Position;\n"
" float gl_PointSize;\n"
" float gl_ClipDistance[];\n"
"};\n"
"#endif\n"
"\n"
"layout(location = 0) in vec4 POSITION;\n"
"layout(location = 1) in vec2 TEXCOORD0;\n"
@ -54,75 +56,75 @@ extern const char* convert_glsl =
"// smooth, the default, means to do perspective-correct interpolation.\n"
"//\n"
"// The centroid qualifier only matters when multisampling. If this qualifier is not present, then the value is interpolated to the pixel's center, anywhere in the pixel, or to one of the pixel's samples. This sample may lie outside of the actual primitive being rendered, since a primitive can cover only part of a pixel's area. The centroid qualifier is used to prevent this; the interpolation point must fall within both the pixel's area and the primitive's area.\n"
"#if __VERSION__ > 140 && !(defined(NO_STRUCT))\n"
"layout(location = 0) out vertex_basic VSout;\n"
"#define VSout_p (VSout.p)\n"
"#define VSout_t (VSout.t)\n"
"#else\n"
"#ifdef DISABLE_SSO\n"
"out vec4 SHADERp;\n"
"out vec2 SHADERt;\n"
"#else\n"
"layout(location = 0) out vec4 SHADERp;\n"
"layout(location = 1) out vec2 SHADERt;\n"
"#endif\n"
"#define VSout_p SHADERp\n"
"#define VSout_t SHADERt\n"
"#endif\n"
"\n"
"void vs_main()\n"
"{\n"
" VSout.p = POSITION;\n"
" VSout.t = TEXCOORD0;\n"
" VSout_p = POSITION;\n"
" VSout_t = TEXCOORD0;\n"
" gl_Position = POSITION; // NOTE I don't know if it is possible to merge POSITION_OUT and gl_Position\n"
"}\n"
"\n"
"#endif\n"
"\n"
"#ifdef GEOMETRY_SHADER\n"
"in gl_PerVertex {\n"
" vec4 gl_Position;\n"
" float gl_PointSize;\n"
" float gl_ClipDistance[];\n"
"} gl_in[];\n"
"\n"
"out gl_PerVertex {\n"
" vec4 gl_Position;\n"
" float gl_PointSize;\n"
" float gl_ClipDistance[];\n"
"};\n"
"\n"
"// FIXME\n"
"// AMD Driver bug again !!!!\n"
"//layout(location = 0) in vertex GSin[];\n"
"in vertex_basic GSin[];\n"
"\n"
"layout(location = 0) out vertex_basic GSout;\n"
"layout(triangles) in;\n"
"layout(triangle_strip, max_vertices = 3) out;\n"
"\n"
"void gs_main()\n"
"{\n"
" for(int i = 0; i < gl_in.length(); i++) {\n"
" gl_Position = gl_in[i].gl_Position;\n"
" GSout = GSin[i];\n"
" EmitVertex();\n"
" }\n"
" EndPrimitive();\n"
"}\n"
"#endif\n"
"\n"
"#ifdef FRAGMENT_SHADER\n"
"// NOTE: pixel can be clip with \"discard\"\n"
"\n"
"#if __VERSION__ > 140 && !(defined(NO_STRUCT))\n"
"layout(location = 0) in vertex_basic PSin;\n"
"#define PSin_p (PSin.p)\n"
"#define PSin_t (PSin.t)\n"
"#else\n"
"#ifdef DISABLE_SSO\n"
"in vec4 SHADERp;\n"
"in vec2 SHADERt;\n"
"#else\n"
"layout(location = 0) in vec4 SHADERp;\n"
"layout(location = 1) in vec2 SHADERt;\n"
"#endif\n"
"#define PSin_p SHADERp\n"
"#define PSin_t SHADERt\n"
"#endif\n"
"\n"
"layout(location = 0) out vec4 SV_Target0;\n"
"layout(location = 1) out uint SV_Target1;\n"
"\n"
"#ifdef DISABLE_GL42\n"
"uniform sampler2D TextureSampler;\n"
"#else\n"
"layout(binding = 0) uniform sampler2D TextureSampler;\n"
"#endif\n"
"\n"
"vec4 sample_c()\n"
"{\n"
" return texture(TextureSampler, PSin.t );\n"
" return texture(TextureSampler, PSin_t );\n"
"}\n"
"\n"
"vec4 ps_crt(uint i)\n"
"{\n"
" vec4 mask[4] =\n"
" {\n"
"uniform vec4 mask[4] = vec4[4]\n"
"(\n"
" vec4(1, 0, 0, 0),\n"
" vec4(0, 1, 0, 0),\n"
" vec4(0, 0, 1, 0),\n"
" vec4(1, 1, 1, 0)\n"
" };\n"
");\n"
"\n"
"\n"
"vec4 ps_crt(uint i)\n"
"{\n"
" return sample_c() * clamp((mask[i] + 0.5f), 0.0f, 1.0f);\n"
"}\n"
"\n"
@ -153,7 +155,7 @@ extern const char* convert_glsl =
"\n"
"void ps_main5() // triangular\n"
"{\n"
" highp uvec4 p = uvec4(PSin.p);\n"
" highp uvec4 p = uvec4(PSin_p);\n"
"\n"
" vec4 c = ps_crt(((p.x + ((p.y >> 1u) & 1u) * 3u) >> 1u) \% 3u);\n"
"\n"
@ -162,27 +164,35 @@ extern const char* convert_glsl =
"\n"
"void ps_main6() // diagonal\n"
"{\n"
" uvec4 p = uvec4(PSin.p);\n"
" uvec4 p = uvec4(PSin_p);\n"
"\n"
" vec4 c = ps_crt((p.x + (p.y \% 3u)) \% 3u);\n"
"\n"
" SV_Target0 = c;\n"
"}\n"
"\n"
"// Used for DATE (stencil)\n"
"void ps_main2()\n"
"{\n"
" if((sample_c().a - 128.0f / 255) < 0) // >= 0x80 pass\n"
" if((sample_c().a - 127.5f / 255) < 0) // >= 0x80 pass\n"
" discard;\n"
"\n"
" SV_Target0 = vec4(0.0f, 0.0f, 0.0f, 0.0f);\n"
"#ifdef ENABLE_OGL_STENCIL_DEBUG\n"
" SV_Target0 = vec4(1.0f, 0.0f, 0.0f, 1.0f);\n"
"#endif\n"
"}\n"
"\n"
"// Used for DATE (stencil)\n"
"void ps_main3()\n"
"{\n"
" if((127.95f / 255 - sample_c().a) <0) // < 0x80 pass (== 0x80 should not pass)\n"
" if((127.5f / 255 - sample_c().a) < 0) // < 0x80 pass (== 0x80 should not pass)\n"
" discard;\n"
"\n"
" SV_Target0 = vec4(0.0f, 0.0f, 0.0f, 0.0f);\n"
"#ifdef ENABLE_OGL_STENCIL_DEBUG\n"
" SV_Target0 = vec4(1.0f, 0.0f, 0.0f, 1.0f);\n"
"#endif\n"
"}\n"
"\n"
"void ps_main4()\n"
"{\n"
" // FIXME mod and fmod are different when value are negative\n"

File diff suppressed because it is too large Load Diff

1270
plugins/GSdx/res/fxaa.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -6,8 +6,22 @@ struct vertex_basic
vec2 t;
};
#ifdef FRAGMENT_SHADER
#if __VERSION__ > 140 && !(defined(NO_STRUCT))
layout(location = 0) in vertex_basic PSin;
#define PSin_p (PSin.p)
#define PSin_t (PSin.t)
#else
#ifdef DISABLE_SSO
in vec4 SHADERp;
in vec2 SHADERt;
#else
layout(location = 0) in vec4 SHADERp;
layout(location = 1) in vec2 SHADERt;
#endif
#define PSin_p SHADERp
#define PSin_t SHADERt
#endif
#ifdef FRAGMENT_SHADER
layout(location = 0) out vec4 SV_Target0;
@ -21,15 +35,19 @@ layout(std140, binding = 11) uniform cb11
float hH;
};
#ifdef DISABLE_GL42
uniform sampler2D TextureSampler;
#else
layout(binding = 0) uniform sampler2D TextureSampler;
#endif
// TODO ensure that clip (discard) is < 0 and not <= 0 ???
void ps_main0()
{
// I'm not sure it impact us but be safe to lookup texture before conditional if
// see: http://www.opengl.org/wiki/GLSL_Sampler#Non-uniform_flow_control
vec4 c = texture(TextureSampler, PSin.t);
if (fract(PSin.t.y * hH) - 0.5 < 0.0)
vec4 c = texture(TextureSampler, PSin_t);
if (fract(PSin_t.y * hH) - 0.5 < 0.0)
discard;
SV_Target0 = c;
@ -39,8 +57,8 @@ void ps_main1()
{
// I'm not sure it impact us but be safe to lookup texture before conditional if
// see: http://www.opengl.org/wiki/GLSL_Sampler#Non-uniform_flow_control
vec4 c = texture(TextureSampler, PSin.t);
if (0.5 - fract(PSin.t.y * hH) < 0.0)
vec4 c = texture(TextureSampler, PSin_t);
if (0.5 - fract(PSin_t.y * hH) < 0.0)
discard;
SV_Target0 = c;
@ -48,16 +66,16 @@ void ps_main1()
void ps_main2()
{
vec4 c0 = texture(TextureSampler, PSin.t - ZrH);
vec4 c1 = texture(TextureSampler, PSin.t);
vec4 c2 = texture(TextureSampler, PSin.t + ZrH);
vec4 c0 = texture(TextureSampler, PSin_t - ZrH);
vec4 c1 = texture(TextureSampler, PSin_t);
vec4 c2 = texture(TextureSampler, PSin_t + ZrH);
SV_Target0 = (c0 + c1 * 2 + c2) / 4;
}
void ps_main3()
{
SV_Target0 = texture(TextureSampler, PSin.t);
SV_Target0 = texture(TextureSampler, PSin_t);
}
#endif

View File

@ -25,7 +25,7 @@
#include "stdafx.h"
extern const char* interlace_glsl =
static const char* interlace_glsl =
"//#version 420 // Keep it for editor detection\n"
"\n"
"struct vertex_basic\n"
@ -34,8 +34,22 @@ extern const char* interlace_glsl =
" vec2 t;\n"
"};\n"
"\n"
"#ifdef FRAGMENT_SHADER\n"
"#if __VERSION__ > 140 && !(defined(NO_STRUCT))\n"
"layout(location = 0) in vertex_basic PSin;\n"
"#define PSin_p (PSin.p)\n"
"#define PSin_t (PSin.t)\n"
"#else\n"
"#ifdef DISABLE_SSO\n"
"in vec4 SHADERp;\n"
"in vec2 SHADERt;\n"
"#else\n"
"layout(location = 0) in vec4 SHADERp;\n"
"layout(location = 1) in vec2 SHADERt;\n"
"#endif\n"
"#define PSin_p SHADERp\n"
"#define PSin_t SHADERt\n"
"#endif\n"
"#ifdef FRAGMENT_SHADER\n"
"\n"
"layout(location = 0) out vec4 SV_Target0;\n"
"\n"
@ -49,15 +63,19 @@ extern const char* interlace_glsl =
" float hH;\n"
"};\n"
"\n"
"#ifdef DISABLE_GL42\n"
"uniform sampler2D TextureSampler;\n"
"#else\n"
"layout(binding = 0) uniform sampler2D TextureSampler;\n"
"#endif\n"
"\n"
"// TODO ensure that clip (discard) is < 0 and not <= 0 ???\n"
"void ps_main0()\n"
"{\n"
" // I'm not sure it impact us but be safe to lookup texture before conditional if\n"
" // see: http://www.opengl.org/wiki/GLSL_Sampler#Non-uniform_flow_control\n"
" vec4 c = texture(TextureSampler, PSin.t);\n"
" if (fract(PSin.t.y * hH) - 0.5 < 0.0)\n"
" vec4 c = texture(TextureSampler, PSin_t);\n"
" if (fract(PSin_t.y * hH) - 0.5 < 0.0)\n"
" discard;\n"
"\n"
" SV_Target0 = c;\n"
@ -67,8 +85,8 @@ extern const char* interlace_glsl =
"{\n"
" // I'm not sure it impact us but be safe to lookup texture before conditional if\n"
" // see: http://www.opengl.org/wiki/GLSL_Sampler#Non-uniform_flow_control\n"
" vec4 c = texture(TextureSampler, PSin.t);\n"
" if (0.5 - fract(PSin.t.y * hH) < 0.0)\n"
" vec4 c = texture(TextureSampler, PSin_t);\n"
" if (0.5 - fract(PSin_t.y * hH) < 0.0)\n"
" discard;\n"
"\n"
" SV_Target0 = c;\n"
@ -76,16 +94,16 @@ extern const char* interlace_glsl =
"\n"
"void ps_main2()\n"
"{\n"
" vec4 c0 = texture(TextureSampler, PSin.t - ZrH);\n"
" vec4 c1 = texture(TextureSampler, PSin.t);\n"
" vec4 c2 = texture(TextureSampler, PSin.t + ZrH);\n"
" vec4 c0 = texture(TextureSampler, PSin_t - ZrH);\n"
" vec4 c1 = texture(TextureSampler, PSin_t);\n"
" vec4 c2 = texture(TextureSampler, PSin_t + ZrH);\n"
"\n"
" SV_Target0 = (c0 + c1 * 2 + c2) / 4;\n"
"}\n"
"\n"
"void ps_main3()\n"
"{\n"
" SV_Target0 = texture(TextureSampler, PSin.t);\n"
" SV_Target0 = texture(TextureSampler, PSin_t);\n"
"}\n"
"\n"
"#endif\n"

View File

@ -6,8 +6,22 @@ struct vertex_basic
vec2 t;
};
#ifdef FRAGMENT_SHADER
#if __VERSION__ > 140 && !(defined(NO_STRUCT))
layout(location = 0) in vertex_basic PSin;
#define PSin_p (PSin.p)
#define PSin_t (PSin.t)
#else
#ifdef DISABLE_SSO
in vec4 SHADERp;
in vec2 SHADERt;
#else
layout(location = 0) in vec4 SHADERp;
layout(location = 1) in vec2 SHADERt;
#endif
#define PSin_p SHADERp
#define PSin_t SHADERt
#endif
#ifdef FRAGMENT_SHADER
layout(location = 0) out vec4 SV_Target0;
@ -20,18 +34,22 @@ layout(std140, binding = 10) uniform cb10
vec4 BGColor;
};
#ifdef DISABLE_GL42
uniform sampler2D TextureSampler;
#else
layout(binding = 0) uniform sampler2D TextureSampler;
#endif
void ps_main0()
{
vec4 c = texture(TextureSampler, PSin.t);
vec4 c = texture(TextureSampler, PSin_t);
c.a = min(c.a * 2, 1.0);
SV_Target0 = c;
}
void ps_main1()
{
vec4 c = texture(TextureSampler, PSin.t);
vec4 c = texture(TextureSampler, PSin_t);
c.a = BGColor.a;
SV_Target0 = c;
}

View File

@ -25,7 +25,7 @@
#include "stdafx.h"
extern const char* merge_glsl =
static const char* merge_glsl =
"//#version 420 // Keep it for editor detection\n"
"\n"
"struct vertex_basic\n"
@ -34,8 +34,22 @@ extern const char* merge_glsl =
" vec2 t;\n"
"};\n"
"\n"
"#ifdef FRAGMENT_SHADER\n"
"#if __VERSION__ > 140 && !(defined(NO_STRUCT))\n"
"layout(location = 0) in vertex_basic PSin;\n"
"#define PSin_p (PSin.p)\n"
"#define PSin_t (PSin.t)\n"
"#else\n"
"#ifdef DISABLE_SSO\n"
"in vec4 SHADERp;\n"
"in vec2 SHADERt;\n"
"#else\n"
"layout(location = 0) in vec4 SHADERp;\n"
"layout(location = 1) in vec2 SHADERt;\n"
"#endif\n"
"#define PSin_p SHADERp\n"
"#define PSin_t SHADERt\n"
"#endif\n"
"#ifdef FRAGMENT_SHADER\n"
"\n"
"layout(location = 0) out vec4 SV_Target0;\n"
"\n"
@ -48,18 +62,22 @@ extern const char* merge_glsl =
" vec4 BGColor;\n"
"};\n"
"\n"
"#ifdef DISABLE_GL42\n"
"uniform sampler2D TextureSampler;\n"
"#else\n"
"layout(binding = 0) uniform sampler2D TextureSampler;\n"
"#endif\n"
"\n"
"void ps_main0()\n"
"{\n"
" vec4 c = texture(TextureSampler, PSin.t);\n"
" vec4 c = texture(TextureSampler, PSin_t);\n"
" c.a = min(c.a * 2, 1.0);\n"
" SV_Target0 = c;\n"
"}\n"
"\n"
"void ps_main1()\n"
"{\n"
" vec4 c = texture(TextureSampler, PSin.t);\n"
" vec4 c = texture(TextureSampler, PSin_t);\n"
" c.a = BGColor.a;\n"
" SV_Target0 = c;\n"
"}\n"

View File

@ -14,7 +14,21 @@ struct vertex_basic
#ifdef FRAGMENT_SHADER
#if __VERSION__ > 140 && !(defined(NO_STRUCT))
layout(location = 0) in vertex_basic PSin;
#define PSin_p (PSin.p)
#define PSin_t (PSin.t)
#else
#ifdef DISABLE_SSO
in vec4 SHADERp;
in vec2 SHADERt;
#else
layout(location = 0) in vec4 SHADERp;
layout(location = 1) in vec2 SHADERt;
#endif
#define PSin_p SHADERp
#define PSin_t SHADERt
#endif
layout(location = 0) out vec4 SV_Target0;
@ -27,7 +41,11 @@ layout(std140, binding = 12) uniform cb12
vec4 BGColor;
};
#ifdef DISABLE_GL42
uniform sampler2D TextureSampler;
#else
layout(binding = 0) uniform sampler2D TextureSampler;
#endif
// For all settings: 1.0 = 100% 0.5=50% 1.5 = 150%
vec4 ContrastSaturationBrightness(vec4 color)
@ -57,7 +75,7 @@ vec4 ContrastSaturationBrightness(vec4 color)
void ps_main()
{
vec4 c = texture(TextureSampler, PSin.t);
vec4 c = texture(TextureSampler, PSin_t);
SV_Target0 = ContrastSaturationBrightness(c);
}

View File

@ -25,7 +25,7 @@
#include "stdafx.h"
extern const char* shadeboost_glsl =
static const char* shadeboost_glsl =
"//#version 420 // Keep it for editor detection\n"
"\n"
"/*\n"
@ -42,7 +42,21 @@ extern const char* shadeboost_glsl =
"\n"
"#ifdef FRAGMENT_SHADER\n"
"\n"
"#if __VERSION__ > 140 && !(defined(NO_STRUCT))\n"
"layout(location = 0) in vertex_basic PSin;\n"
"#define PSin_p (PSin.p)\n"
"#define PSin_t (PSin.t)\n"
"#else\n"
"#ifdef DISABLE_SSO\n"
"in vec4 SHADERp;\n"
"in vec2 SHADERt;\n"
"#else\n"
"layout(location = 0) in vec4 SHADERp;\n"
"layout(location = 1) in vec2 SHADERt;\n"
"#endif\n"
"#define PSin_p SHADERp\n"
"#define PSin_t SHADERt\n"
"#endif\n"
"\n"
"layout(location = 0) out vec4 SV_Target0;\n"
"\n"
@ -55,7 +69,11 @@ extern const char* shadeboost_glsl =
" vec4 BGColor;\n"
"};\n"
"\n"
"#ifdef DISABLE_GL42\n"
"uniform sampler2D TextureSampler;\n"
"#else\n"
"layout(binding = 0) uniform sampler2D TextureSampler;\n"
"#endif\n"
"\n"
"// For all settings: 1.0 = 100\% 0.5=50\% 1.5 = 150\% \n"
"vec4 ContrastSaturationBrightness(vec4 color)\n"
@ -85,7 +103,7 @@ extern const char* shadeboost_glsl =
"\n"
"void ps_main()\n"
"{\n"
" vec4 c = texture(TextureSampler, PSin.t);\n"
" vec4 c = texture(TextureSampler, PSin_t);\n"
" SV_Target0 = ContrastSaturationBrightness(c);\n"
"}\n"
"\n"

View File

@ -46,7 +46,7 @@
struct vertex
{
vec4 p;
//vec4 p;
vec4 t;
vec4 tp;
vec4 c;
@ -61,13 +61,37 @@ layout(location = 4) in uint i_z;
layout(location = 5) in uvec2 i_uv;
layout(location = 6) in vec4 i_f;
#if __VERSION__ > 140 && !(defined(NO_STRUCT))
layout(location = 0) out vertex VSout;
#define VSout_p (VSout.p)
#define VSout_t (VSout.t)
#define VSout_tp (VSout.tp)
#define VSout_c (VSout.c)
#else
#ifdef DISABLE_SSO
//out vec4 SHADERp;
out vec4 SHADERt;
out vec4 SHADERtp;
out vec4 SHADERc;
#else
//layout(location = 0) out vec4 SHADERp;
layout(location = 0) out vec4 SHADERt;
layout(location = 1) out vec4 SHADERtp;
layout(location = 2) out vec4 SHADERc;
#endif
//#define VSout_p SHADERp
#define VSout_t SHADERt
#define VSout_tp SHADERtp
#define VSout_c SHADERc
#endif
#if __VERSION__ > 140
out gl_PerVertex {
invariant vec4 gl_Position;
float gl_PointSize;
float gl_ClipDistance[];
};
#endif
#ifdef DISABLE_GL42
layout(std140) uniform cb20
@ -106,10 +130,10 @@ void vs_main()
final_p.z = log2(1.0f + float(z)) / 32.0f;
}
VSout.p = final_p;
//VSout_p = final_p;
gl_Position = final_p; // NOTE I don't know if it is possible to merge POSITION_OUT and gl_Position
#if VS_RTCOPY
VSout.tp = final_p * vec4(0.5, -0.5, 0, 0) + 0.5;
VSout_tp = final_p * vec4(0.5, -0.5, 0, 0) + 0.5;
#endif
@ -117,25 +141,25 @@ void vs_main()
{
if(VS_FST != 0)
{
//VSout.t.xy = i_t * TextureScale;
VSout.t.xy = i_uv * TextureScale;
VSout.t.w = 1.0f;
//VSout_t.xy = i_t * TextureScale;
VSout_t.xy = i_uv * TextureScale;
VSout_t.w = 1.0f;
}
else
{
//VSout.t.xy = i_t;
VSout.t.xy = i_st;
VSout.t.w = i_q;
//VSout_t.xy = i_t;
VSout_t.xy = i_st;
VSout_t.w = i_q;
}
}
else
{
VSout.t.xy = vec2(0.0f, 0.0f);
VSout.t.w = 1.0f;
VSout_t.xy = vec2(0.0f, 0.0f);
VSout_t.w = 1.0f;
}
VSout.c = i_c;
VSout.t.z = i_f.r;
VSout_c = i_c;
VSout_t.z = i_f.r;
}
#endif
@ -217,46 +241,50 @@ void gs_main()
// right bottom => GSin[1];
vertex rb = GSin[1];
vertex lt = GSin[0];
vec4 rb_p = gl_in[1].gl_Position;
vec4 lb_p = gl_in[1].gl_Position;
vec4 rt_p = gl_in[1].gl_Position;
vec4 lt_p = gl_in[0].gl_Position;
lt.p.z = rb.p.z;
lt_p.z = rb_p.z;
lt.t.zw = rb.t.zw;
#if GS_IIP == 0
lt.c = rb.c;
#endif
vertex lb = rb;
lb.p.x = lt.p.x;
lb_p.x = lt_p.x;
lb.t.x = lt.t.x;
vertex rt = rb;
rt.p.y = lt.p.y;
rt_p.y = lt_p.y;
rt.t.y = lt.t.y;
// Triangle 1
gl_Position = lt.p;
gl_Position = lt_p;
GSout = lt;
EmitVertex();
gl_Position = lb.p;
gl_Position = lb_p;
GSout = lb;
EmitVertex();
gl_Position = rt.p;
gl_Position = rt_p;
GSout = rt;
EmitVertex();
EndPrimitive();
// Triangle 2
gl_Position = lb.p;
gl_Position = lb_p;
GSout = lb;
EmitVertex();
gl_Position = rt.p;
gl_Position = rt_p;
GSout = rt;
EmitVertex();
gl_Position = rb.p;
gl_Position = rb_p;
GSout = rb;
EmitVertex();
@ -269,15 +297,43 @@ void gs_main()
#endif
#ifdef FRAGMENT_SHADER
#if __VERSION__ > 140 && !(defined(NO_STRUCT))
layout(location = 0) in vertex PSin;
//#define PSin_p (PSin.p)
#define PSin_t (PSin.t)
#define PSin_tp (PSin.tp)
#define PSin_c (PSin.c)
#else
#ifdef DISABLE_SSO
in vec4 SHADERp;
in vec4 SHADERt;
in vec4 SHADERtp;
in vec4 SHADERc;
#else
//layout(location = 0) in vec4 SHADERp;
layout(location = 0) in vec4 SHADERt;
layout(location = 1) in vec4 SHADERtp;
layout(location = 2) in vec4 SHADERc;
#endif
//#define PSin_p SHADERp
#define PSin_t SHADERt
#define PSin_tp SHADERtp
#define PSin_c SHADERc
#endif
// Same buffer but 2 colors for dual source blending
layout(location = 0, index = 0) out vec4 SV_Target0;
layout(location = 0, index = 1) out vec4 SV_Target1;
#ifdef DISABLE_GL42
uniform sampler2D TextureSampler;
uniform sampler2D PaletteSampler;
uniform sampler2D RTCopySampler;
#else
layout(binding = 0) uniform sampler2D TextureSampler;
layout(binding = 1) uniform sampler2D PaletteSampler;
layout(binding = 2) uniform sampler2D RTCopySampler;
#endif
#ifdef DISABLE_GL42
layout(std140) uniform cb21
@ -401,13 +457,12 @@ vec4 sample_4a(vec4 uv)
{
vec4 c;
// XXX
// I think .a is related to 8bit texture in alpha channel
// Opengl is only 8 bits on red channel. Not sure exactly of the impact
c.x = sample_c(uv.xy).a;
c.y = sample_c(uv.zy).a;
c.z = sample_c(uv.xw).a;
c.w = sample_c(uv.zw).a;
// Dx used the alpha channel.
// Opengl is only 8 bits on red channel.
c.x = sample_c(uv.xy).r;
c.y = sample_c(uv.zy).r;
c.z = sample_c(uv.xw).r;
c.w = sample_c(uv.zw).r;
return c * 255./256 + 0.5/256;
}
@ -470,14 +525,14 @@ vec4 sample_color(vec2 st, float q)
if((PS_FMT & ~FMT_PAL) == FMT_24)
{
// FIXME GLSL any only support bvec so try to mix it with notEqual
bvec3 rgb_check = notEqual( t.rgb, vec3(0.0f, 0.0f, 0.0f) );
t.a = ( (PS_AEM == 0) || any(rgb_check) ) ? TA.x : 0.0f;
bvec3 rgb_check = notEqual( c[i].rgb, vec3(0.0f, 0.0f, 0.0f) );
c[i].a = ( (PS_AEM == 0) || any(rgb_check) ) ? TA.x : 0.0f;
}
else if((PS_FMT & ~FMT_PAL) == FMT_16)
{
// FIXME GLSL any only support bvec so try to mix it with notEqual
bvec3 rgb_check = notEqual( t.rgb, vec3(0.0f, 0.0f, 0.0f) );
t.a = t.a >= 0.5 ? TA.y : ( (PS_AEM == 0) || any(rgb_check) ) ? TA.x : 0.0f;
bvec3 rgb_check = notEqual( c[i].rgb, vec3(0.0f, 0.0f, 0.0f) );
c[i].a = c[i].a >= 0.5 ? TA.y : ( (PS_AEM == 0) || any(rgb_check) ) ? TA.x : 0.0f;
}
}
@ -543,7 +598,7 @@ vec4 tfx(vec4 t, vec4 c)
void datst()
{
#if PS_DATE > 0
float alpha = sample_rt(PSin.tp.xy).a;
float alpha = sample_rt(PSin_tp.xy).a;
float alpha0x80 = 128. / 255;
if (PS_DATE == 1 && alpha >= alpha0x80)
@ -613,13 +668,13 @@ vec4 ps_color()
{
datst();
vec4 t = sample_color(PSin.t.xy, PSin.t.w);
vec4 t = sample_color(PSin_t.xy, PSin_t.w);
vec4 c = tfx(t, PSin.c);
vec4 c = tfx(t, PSin_c);
atst(c);
c = fog(c, PSin.t.z);
c = fog(c, PSin_t.z);
if (PS_COLCLIP == 2)
{

View File

@ -25,7 +25,7 @@
#include "stdafx.h"
extern const char* tfx_glsl =
static const char* tfx_glsl =
"//#version 420 // Keep it for text editor detection\n"
"\n"
"// note lerp => mix\n"
@ -74,7 +74,7 @@ extern const char* tfx_glsl =
"\n"
"struct vertex\n"
"{\n"
" vec4 p;\n"
" //vec4 p;\n"
" vec4 t;\n"
" vec4 tp;\n"
" vec4 c;\n"
@ -89,13 +89,37 @@ extern const char* tfx_glsl =
"layout(location = 5) in uvec2 i_uv;\n"
"layout(location = 6) in vec4 i_f;\n"
"\n"
"#if __VERSION__ > 140 && !(defined(NO_STRUCT))\n"
"layout(location = 0) out vertex VSout;\n"
"#define VSout_p (VSout.p)\n"
"#define VSout_t (VSout.t)\n"
"#define VSout_tp (VSout.tp)\n"
"#define VSout_c (VSout.c)\n"
"#else\n"
"#ifdef DISABLE_SSO\n"
"//out vec4 SHADERp;\n"
"out vec4 SHADERt;\n"
"out vec4 SHADERtp;\n"
"out vec4 SHADERc;\n"
"#else\n"
"//layout(location = 0) out vec4 SHADERp;\n"
"layout(location = 0) out vec4 SHADERt;\n"
"layout(location = 1) out vec4 SHADERtp;\n"
"layout(location = 2) out vec4 SHADERc;\n"
"#endif\n"
"//#define VSout_p SHADERp\n"
"#define VSout_t SHADERt\n"
"#define VSout_tp SHADERtp\n"
"#define VSout_c SHADERc\n"
"#endif\n"
"\n"
"#if __VERSION__ > 140\n"
"out gl_PerVertex {\n"
" invariant vec4 gl_Position;\n"
" float gl_PointSize;\n"
" float gl_ClipDistance[];\n"
"};\n"
"#endif\n"
"\n"
"#ifdef DISABLE_GL42\n"
"layout(std140) uniform cb20\n"
@ -134,10 +158,10 @@ extern const char* tfx_glsl =
" final_p.z = log2(1.0f + float(z)) / 32.0f;\n"
" }\n"
"\n"
" VSout.p = final_p;\n"
" //VSout_p = final_p;\n"
" gl_Position = final_p; // NOTE I don't know if it is possible to merge POSITION_OUT and gl_Position\n"
"#if VS_RTCOPY\n"
" VSout.tp = final_p * vec4(0.5, -0.5, 0, 0) + 0.5;\n"
" VSout_tp = final_p * vec4(0.5, -0.5, 0, 0) + 0.5;\n"
"#endif\n"
"\n"
"\n"
@ -145,25 +169,25 @@ extern const char* tfx_glsl =
" {\n"
" if(VS_FST != 0)\n"
" {\n"
" //VSout.t.xy = i_t * TextureScale;\n"
" VSout.t.xy = i_uv * TextureScale;\n"
" VSout.t.w = 1.0f;\n"
" //VSout_t.xy = i_t * TextureScale;\n"
" VSout_t.xy = i_uv * TextureScale;\n"
" VSout_t.w = 1.0f;\n"
" }\n"
" else\n"
" {\n"
" //VSout.t.xy = i_t;\n"
" VSout.t.xy = i_st;\n"
" VSout.t.w = i_q;\n"
" //VSout_t.xy = i_t;\n"
" VSout_t.xy = i_st;\n"
" VSout_t.w = i_q;\n"
" }\n"
" }\n"
" else\n"
" {\n"
" VSout.t.xy = vec2(0.0f, 0.0f);\n"
" VSout.t.w = 1.0f;\n"
" VSout_t.xy = vec2(0.0f, 0.0f);\n"
" VSout_t.w = 1.0f;\n"
" }\n"
"\n"
" VSout.c = i_c;\n"
" VSout.t.z = i_f.r;\n"
" VSout_c = i_c;\n"
" VSout_t.z = i_f.r;\n"
"}\n"
"\n"
"#endif\n"
@ -245,46 +269,50 @@ extern const char* tfx_glsl =
" // right bottom => GSin[1];\n"
" vertex rb = GSin[1];\n"
" vertex lt = GSin[0];\n"
" vec4 rb_p = gl_in[1].gl_Position;\n"
" vec4 lb_p = gl_in[1].gl_Position;\n"
" vec4 rt_p = gl_in[1].gl_Position;\n"
" vec4 lt_p = gl_in[0].gl_Position;\n"
"\n"
" lt.p.z = rb.p.z;\n"
" lt_p.z = rb_p.z;\n"
" lt.t.zw = rb.t.zw;\n"
"#if GS_IIP == 0\n"
" lt.c = rb.c;\n"
"#endif\n"
"\n"
" vertex lb = rb;\n"
" lb.p.x = lt.p.x;\n"
" lb_p.x = lt_p.x;\n"
" lb.t.x = lt.t.x;\n"
"\n"
" vertex rt = rb;\n"
" rt.p.y = lt.p.y;\n"
" rt_p.y = lt_p.y;\n"
" rt.t.y = lt.t.y;\n"
"\n"
" // Triangle 1\n"
" gl_Position = lt.p;\n"
" gl_Position = lt_p;\n"
" GSout = lt;\n"
" EmitVertex();\n"
"\n"
" gl_Position = lb.p;\n"
" gl_Position = lb_p;\n"
" GSout = lb;\n"
" EmitVertex();\n"
"\n"
" gl_Position = rt.p;\n"
" gl_Position = rt_p;\n"
" GSout = rt;\n"
" EmitVertex();\n"
"\n"
" EndPrimitive();\n"
"\n"
" // Triangle 2\n"
" gl_Position = lb.p;\n"
" gl_Position = lb_p;\n"
" GSout = lb;\n"
" EmitVertex();\n"
"\n"
" gl_Position = rt.p;\n"
" gl_Position = rt_p;\n"
" GSout = rt;\n"
" EmitVertex();\n"
"\n"
" gl_Position = rb.p;\n"
" gl_Position = rb_p;\n"
" GSout = rb;\n"
" EmitVertex();\n"
"\n"
@ -297,15 +325,43 @@ extern const char* tfx_glsl =
"#endif\n"
"\n"
"#ifdef FRAGMENT_SHADER\n"
"#if __VERSION__ > 140 && !(defined(NO_STRUCT))\n"
"layout(location = 0) in vertex PSin;\n"
"//#define PSin_p (PSin.p)\n"
"#define PSin_t (PSin.t)\n"
"#define PSin_tp (PSin.tp)\n"
"#define PSin_c (PSin.c)\n"
"#else\n"
"#ifdef DISABLE_SSO\n"
"in vec4 SHADERp;\n"
"in vec4 SHADERt;\n"
"in vec4 SHADERtp;\n"
"in vec4 SHADERc;\n"
"#else\n"
"//layout(location = 0) in vec4 SHADERp;\n"
"layout(location = 0) in vec4 SHADERt;\n"
"layout(location = 1) in vec4 SHADERtp;\n"
"layout(location = 2) in vec4 SHADERc;\n"
"#endif\n"
"//#define PSin_p SHADERp\n"
"#define PSin_t SHADERt\n"
"#define PSin_tp SHADERtp\n"
"#define PSin_c SHADERc\n"
"#endif\n"
"\n"
"// Same buffer but 2 colors for dual source blending\n"
"layout(location = 0, index = 0) out vec4 SV_Target0;\n"
"layout(location = 0, index = 1) out vec4 SV_Target1;\n"
"\n"
"#ifdef DISABLE_GL42\n"
"uniform sampler2D TextureSampler;\n"
"uniform sampler2D PaletteSampler;\n"
"uniform sampler2D RTCopySampler;\n"
"#else\n"
"layout(binding = 0) uniform sampler2D TextureSampler;\n"
"layout(binding = 1) uniform sampler2D PaletteSampler;\n"
"layout(binding = 2) uniform sampler2D RTCopySampler;\n"
"#endif\n"
"\n"
"#ifdef DISABLE_GL42\n"
"layout(std140) uniform cb21\n"
@ -429,13 +485,12 @@ extern const char* tfx_glsl =
"{\n"
" vec4 c;\n"
"\n"
" // XXX\n"
" // I think .a is related to 8bit texture in alpha channel\n"
" // Opengl is only 8 bits on red channel. Not sure exactly of the impact\n"
" c.x = sample_c(uv.xy).a;\n"
" c.y = sample_c(uv.zy).a;\n"
" c.z = sample_c(uv.xw).a;\n"
" c.w = sample_c(uv.zw).a;\n"
" // Dx used the alpha channel.\n"
" // Opengl is only 8 bits on red channel.\n"
" c.x = sample_c(uv.xy).r;\n"
" c.y = sample_c(uv.zy).r;\n"
" c.z = sample_c(uv.xw).r;\n"
" c.w = sample_c(uv.zw).r;\n"
"\n"
" return c * 255./256 + 0.5/256;\n"
"}\n"
@ -498,14 +553,14 @@ extern const char* tfx_glsl =
" if((PS_FMT & ~FMT_PAL) == FMT_24)\n"
" {\n"
" // FIXME GLSL any only support bvec so try to mix it with notEqual\n"
" bvec3 rgb_check = notEqual( t.rgb, vec3(0.0f, 0.0f, 0.0f) );\n"
" t.a = ( (PS_AEM == 0) || any(rgb_check) ) ? TA.x : 0.0f;\n"
" bvec3 rgb_check = notEqual( c[i].rgb, vec3(0.0f, 0.0f, 0.0f) );\n"
" c[i].a = ( (PS_AEM == 0) || any(rgb_check) ) ? TA.x : 0.0f;\n"
" }\n"
" else if((PS_FMT & ~FMT_PAL) == FMT_16)\n"
" {\n"
" // FIXME GLSL any only support bvec so try to mix it with notEqual\n"
" bvec3 rgb_check = notEqual( t.rgb, vec3(0.0f, 0.0f, 0.0f) );\n"
" t.a = t.a >= 0.5 ? TA.y : ( (PS_AEM == 0) || any(rgb_check) ) ? TA.x : 0.0f;\n"
" bvec3 rgb_check = notEqual( c[i].rgb, vec3(0.0f, 0.0f, 0.0f) );\n"
" c[i].a = c[i].a >= 0.5 ? TA.y : ( (PS_AEM == 0) || any(rgb_check) ) ? TA.x : 0.0f;\n"
" }\n"
" }\n"
"\n"
@ -571,7 +626,7 @@ extern const char* tfx_glsl =
"void datst()\n"
"{\n"
"#if PS_DATE > 0\n"
" float alpha = sample_rt(PSin.tp.xy).a;\n"
" float alpha = sample_rt(PSin_tp.xy).a;\n"
" float alpha0x80 = 128. / 255;\n"
"\n"
" if (PS_DATE == 1 && alpha >= alpha0x80)\n"
@ -641,13 +696,13 @@ extern const char* tfx_glsl =
"{\n"
" datst();\n"
"\n"
" vec4 t = sample_color(PSin.t.xy, PSin.t.w);\n"
" vec4 t = sample_color(PSin_t.xy, PSin_t.w);\n"
"\n"
" vec4 c = tfx(t, PSin.c);\n"
" vec4 c = tfx(t, PSin_c);\n"
"\n"
" atst(c);\n"
"\n"
" c = fog(c, PSin.t.z);\n"
" c = fog(c, PSin_t.z);\n"
"\n"
" if (PS_COLCLIP == 2)\n"
" {\n"

View File

@ -123,6 +123,11 @@ using namespace std;
#ifdef _WINDOWS
#include <GL/gl.h>
#include <GL/glext.h>
#include <GL/wglext.h>
#include "GLLoader.h"
#include <hash_map>
#include <hash_set>
@ -202,10 +207,9 @@ using namespace std;
//#include <ext/hash_map>
//#include <ext/hash_set>
#include <GL/glew.h>
#include <GL/gl.h>
#include <GL/glx.h>
#include <GL/glext.h>
#include "GLLoader.h"
//using namespace __gnu_cxx;

View File

@ -14,12 +14,12 @@
<WarningLevel>Level4</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4996;4995;4324;4100;4101;4201;4556;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<AdditionalIncludeDirectories>$(DXSDK_DIR)include;$(VTUNE_AMPLIFIER_XE_2013_DIR)include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>$(DXSDK_DIR)include;$(VTUNE_AMPLIFIER_XE_2013_DIR)include;$(SolutionDir)3rdparty;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<Link>
<AdditionalDependencies>d3d11.lib;d3dx11.lib;d3d10_1.lib;d3dx10.lib;d3d9.lib;d3dx9.lib;dxgi.lib;dxguid.lib;winmm.lib;strmiids.lib;xinput.lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>d3d9.dll;d3dx9_43.dll;d3d11.dll;d3dx11_43.dll;dxgi.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<AdditionalDependencies>d3d11.lib;d3dx11.lib;d3d10_1.lib;d3dx10.lib;d3d9.lib;d3dx9.lib;dxgi.lib;dxguid.lib;winmm.lib;strmiids.lib;xinput.lib;opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>d3d9.dll;d3dx9_43.dll;d3d11.dll;d3dx11_43.dll;dxgi.dll;opengl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>

View File

@ -9,7 +9,7 @@
<Tool
Name="VCCLCompilerTool"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="&quot;$(VTUNE_AMPLIFIER_XE_2011_DIR)include&quot;"
AdditionalIncludeDirectories="&quot;$(VTUNE_AMPLIFIER_XE_2011_DIR)include&quot;$(SolutionDir)3rdparty&quot;"
PreprocessorDefinitions="_WINDOWS;_WIN32_WINNT=0x500"
FloatingPointModel="2"
RuntimeTypeInfo="false"
@ -19,9 +19,9 @@
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="d3d11.lib d3dx11.lib d3d10_1.lib d3dx10.lib d3d9.lib d3dx9.lib dxgi.lib dxguid.lib winmm.lib strmiids.lib xinput.lib"
AdditionalDependencies="d3d11.lib d3dx11.lib d3d10_1.lib d3dx10.lib d3d9.lib d3dx9.lib dxgi.lib dxguid.lib winmm.lib strmiids.lib xinput.lib opengl32.lib"
AdditionalLibraryDirectories="&quot;$(VTUNE_AMPLIFIER_XE_2011_DIR)lib32&quot;"
DelayLoadDLLs="d3d9.dll;d3dx9_43.dll;d3d11.dll;d3dx11_43.dll;dxgi.dll"
DelayLoadDLLs="d3d9.dll;d3dx9_43.dll;d3d11.dll;d3dx11_43.dll;dxgi.dll;opengl32.dll"
GenerateDebugInformation="true"
SubSystem="2"
RandomizedBaseAddress="1"