1.0 branch: Merge back cmake changes, the debian unstable directory changes and the whole of zzogl-pg.

git-svn-id: http://pcsx2.googlecode.com/svn/branches/1.0.0@5250 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
ramapcsx2 2012-05-31 18:40:35 +00:00
parent 309516bc2b
commit fd6511fc6e
55 changed files with 2862 additions and 999 deletions

View File

@ -1,8 +1,8 @@
# Project Name # Project Name
project(Pcsx2) project(Pcsx2)
# There is some incompatible change with version 2.6 and below ! # Debian-based distributions require at least 2.8.5 due to multiarch.
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8.5)
# Variable to check that people use the good file # Variable to check that people use the good file
set(TOP_CMAKE_WAS_SOURCED TRUE) set(TOP_CMAKE_WAS_SOURCED TRUE)

View File

@ -20,6 +20,7 @@
### Packaging options ### Packaging options
# Installation path : -DPACKAGE_MODE=TRUE(follow FHS)|FALSE(local bin/) # Installation path : -DPACKAGE_MODE=TRUE(follow FHS)|FALSE(local bin/)
# Plugin installation path : -DPLUGIN_DIR="/usr/lib/pcsx2" # Plugin installation path : -DPLUGIN_DIR="/usr/lib/pcsx2"
# GL Shader installation path : -DGLSL_SHADER_DIR="/usr/share/games/pcsx2"
# Game DB installation path : -DGAMEINDEX_DIR="/var/games/pcsx2" # Game DB installation path : -DGAMEINDEX_DIR="/var/games/pcsx2"
# Follow XDG standard : -DXDG_STD=TRUE|FALSE # Follow XDG standard : -DXDG_STD=TRUE|FALSE
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
@ -123,7 +124,7 @@ set(CMAKE_SHARED_LIBRARY_CXX_FLAGS "")
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
# Set some default compiler flags # Set some default compiler flags
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
set(DEFAULT_WARNINGS "-Wno-write-strings -Wno-format -Wno-unused-parameter -Wno-unused-value -Wstrict-aliasing") set(DEFAULT_WARNINGS "-Wno-write-strings -Wno-format -Wno-unused-parameter -Wno-unused-value -Wstrict-aliasing -Wno-unused-function")
set(DEFAULT_GCC_FLAG "-m32 -msse -msse2 -march=i686 -pthread ${DEFAULT_WARNINGS}") set(DEFAULT_GCC_FLAG "-m32 -msse -msse2 -march=i686 -pthread ${DEFAULT_WARNINGS}")
set(DEFAULT_CPP_FLAG "${DEFAULT_GCC_FLAG} -Wno-invalid-offsetof") set(DEFAULT_CPP_FLAG "${DEFAULT_GCC_FLAG} -Wno-invalid-offsetof")
@ -183,8 +184,13 @@ if(PACKAGE_MODE)
set(GAMEINDEX_DIR "/var/games/pcsx2") set(GAMEINDEX_DIR "/var/games/pcsx2")
endif(NOT DEFINED GAMEINDEX_DIR) endif(NOT DEFINED GAMEINDEX_DIR)
# Compile all source codes with these 2 defines if(NOT DEFINED GLSL_SHADER_DIR)
set(GLSL_SHADER_DIR "/usr/share/games/pcsx2")
endif(NOT DEFINED GLSL_SHADER_DIR)
# Compile all source codes with these 3 defines
add_definitions(-DPLUGIN_DIR_COMPILATION=${PLUGIN_DIR} -DGAMEINDEX_DIR_COMPILATION=${GAMEINDEX_DIR}) add_definitions(-DPLUGIN_DIR_COMPILATION=${PLUGIN_DIR} -DGAMEINDEX_DIR_COMPILATION=${GAMEINDEX_DIR})
add_definitions(-DGLSL_SHADER_DIR_COMPILATION=${GLSL_SHADER_DIR})
endif(PACKAGE_MODE) endif(PACKAGE_MODE)
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------

View File

@ -1,594 +0,0 @@
# - FindGTK2.cmake
# This module can find the GTK2 widget libraries and several of its other
# optional components like gtkmm, glade, and glademm.
#
# NOTE: If you intend to use version checking, CMake 2.6.2 or later is
# required.
#
# Specify one or more of the following components
# as you call this find module. See example below.
#
# gtk
# gtkmm
# glade
# glademm
#
# The following variables will be defined for your use
#
# GTK2_FOUND - Were all of your specified components found?
# GTK2_INCLUDE_DIRS - All include directories
# GTK2_LIBRARIES - All libraries
#
# GTK2_VERSION - The version of GTK2 found (x.y.z)
# GTK2_MAJOR_VERSION - The major version of GTK2
# GTK2_MINOR_VERSION - The minor version of GTK2
# GTK2_PATCH_VERSION - The patch version of GTK2
#
# Optional variables you can define prior to calling this module:
#
# GTK2_DEBUG - Enables verbose debugging of the module
# GTK2_SKIP_MARK_AS_ADVANCED - Disable marking cache variables as advanced
# GTK2_ADDITIONAL_SUFFIXES - Allows defining additional directories to
# search for include files
#
#=================
# Example Usage:
#
# Call find_package() once, here are some examples to pick from:
#
# Require GTK 2.6 or later
# find_package(GTK2 2.6 REQUIRED gtk)
#
# Require GTK 2.10 or later and Glade
# find_package(GTK2 2.10 REQUIRED gtk glade)
#
# Search for GTK/GTKMM 2.8 or later
# find_package(GTK2 2.8 COMPONENTS gtk gtkmm)
#
# if(GTK2_FOUND)
# include_directories(${GTK2_INCLUDE_DIRS})
# add_executable(mygui mygui.cc)
# target_link_libraries(mygui ${GTK2_LIBRARIES})
# endif()
#
#=============================================================================
# Copyright 2009 Kitware, Inc.
# Copyright 2008-2009 Philip Lowman <philip@yhbt.com>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
# Version 1.3 (11/9/2010) (CMake 2.8.4)
# * 11429: Add support for detecting GTK2 built with Visual Studio 10.
# Thanks to Vincent Levesque for the patch.
# Version 1.2 (8/30/2010) (CMake 2.8.3)
# * Merge patch for detecting gdk-pixbuf library (split off
# from core GTK in 2.21). Thanks to Vincent Untz for the patch
# and Ricardo Cruz for the heads up.
# Version 1.1 (8/19/2010) (CMake 2.8.3)
# * Add support for detecting GTK2 under macports (thanks to Gary Kramlich)
# Version 1.0 (8/12/2010) (CMake 2.8.3)
# * Add support for detecting new pangommconfig.h header file
# (Thanks to Sune Vuorela & the Debian Project for the patch)
# * Add support for detecting fontconfig.h header
# * Call find_package(Freetype) since it's required
# * Add support for allowing users to add additional library directories
# via the GTK2_ADDITIONAL_SUFFIXES variable (kind of a future-kludge in
# case the GTK developers change versions on any of the directories in the
# future).
# Version 0.8 (1/4/2010)
# * Get module working under MacOSX fink by adding /sw/include, /sw/lib
# to PATHS and the gobject library
# Version 0.7 (3/22/09)
# * Checked into CMake CVS
# * Added versioning support
# * Module now defaults to searching for GTK if COMPONENTS not specified.
# * Added HKCU prior to HKLM registry key and GTKMM specific environment
# variable as per mailing list discussion.
# * Added lib64 to include search path and a few other search paths where GTK
# may be installed on Unix systems.
# * Switched to lowercase CMake commands
# * Prefaced internal variables with _GTK2 to prevent collision
# * Changed internal macros to functions
# * Enhanced documentation
# Version 0.6 (1/8/08)
# Added GTK2_SKIP_MARK_AS_ADVANCED option
# Version 0.5 (12/19/08)
# Second release to cmake mailing list
#=============================================================
# _GTK2_GET_VERSION
# Internal function to parse the version number in gtkversion.h
# _OUT_major = Major version number
# _OUT_minor = Minor version number
# _OUT_micro = Micro version number
# _gtkversion_hdr = Header file to parse
#=============================================================
function(_GTK2_GET_VERSION _OUT_major _OUT_minor _OUT_micro _gtkversion_hdr)
file(READ ${_gtkversion_hdr} _contents)
if(_contents)
string(REGEX REPLACE ".*#define GTK_MAJOR_VERSION[ \t]+\\(([0-9]+)\\).*" "\\1" ${_OUT_major} "${_contents}")
string(REGEX REPLACE ".*#define GTK_MINOR_VERSION[ \t]+\\(([0-9]+)\\).*" "\\1" ${_OUT_minor} "${_contents}")
string(REGEX REPLACE ".*#define GTK_MICRO_VERSION[ \t]+\\(([0-9]+)\\).*" "\\1" ${_OUT_micro} "${_contents}")
if(NOT ${_OUT_major} MATCHES "[0-9]+")
message(FATAL_ERROR "Version parsing failed for GTK2_MAJOR_VERSION!")
endif()
if(NOT ${_OUT_minor} MATCHES "[0-9]+")
message(FATAL_ERROR "Version parsing failed for GTK2_MINOR_VERSION!")
endif()
if(NOT ${_OUT_micro} MATCHES "[0-9]+")
message(FATAL_ERROR "Version parsing failed for GTK2_MICRO_VERSION!")
endif()
set(${_OUT_major} ${${_OUT_major}} PARENT_SCOPE)
set(${_OUT_minor} ${${_OUT_minor}} PARENT_SCOPE)
set(${_OUT_micro} ${${_OUT_micro}} PARENT_SCOPE)
else()
message(FATAL_ERROR "Include file ${_gtkversion_hdr} does not exist")
endif()
endfunction()
#=============================================================
# _GTK2_FIND_INCLUDE_DIR
# Internal function to find the GTK include directories
# _var = variable to set
# _hdr = header file to look for
#=============================================================
function(_GTK2_FIND_INCLUDE_DIR _var _hdr)
if(GTK2_DEBUG)
message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
"_GTK2_FIND_INCLUDE_DIR( ${_var} ${_hdr} )")
endif()
set(_relatives
# If these ever change, things will break.
${GTK2_ADDITIONAL_SUFFIXES}
glibmm-2.4
glib-2.0
atk-1.0
atkmm-1.6
cairo
cairomm-1.0
gdk-pixbuf-2.0
gdkmm-2.4
giomm-2.4
gtk-2.0
gtkmm-2.4
libglade-2.0
libglademm-2.4
pango-1.0
pangomm-1.4
sigc++-2.0
)
set(_suffixes)
foreach(_d ${_relatives})
list(APPEND _suffixes ${_d})
list(APPEND _suffixes ${_d}/include) # for /usr/lib/gtk-2.0/include
endforeach()
if(GTK2_DEBUG)
message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
"include suffixes = ${_suffixes}")
endif()
find_path(${_var} ${_hdr}
PATHS
# FIXME workaround of ubuntu 11.04 multiarch bug
# Hopefully PCSX2 only needs the i386 versions.
/usr/lib/i386-linux-gnu
# END
/usr/local/lib64
/usr/local/lib
/usr/lib64
/usr/lib
/opt/gnome/include
/opt/gnome/lib
/opt/openwin/include
/usr/openwin/lib
/sw/include
/sw/lib
/opt/local/include
/opt/local/lib
$ENV{GTKMM_BASEPATH}/include
$ENV{GTKMM_BASEPATH}/lib
[HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]/include
[HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]/lib
[HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]/include
[HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]/lib
PATH_SUFFIXES
${_suffixes}
)
if(${_var})
set(GTK2_INCLUDE_DIRS ${GTK2_INCLUDE_DIRS} ${${_var}} PARENT_SCOPE)
if(NOT GTK2_SKIP_MARK_AS_ADVANCED)
mark_as_advanced(${_var})
endif()
endif()
endfunction(_GTK2_FIND_INCLUDE_DIR)
#=============================================================
# _GTK2_FIND_LIBRARY
# Internal function to find libraries packaged with GTK2
# _var = library variable to create
#=============================================================
function(_GTK2_FIND_LIBRARY _var _lib _expand_vc _append_version)
if(GTK2_DEBUG)
message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
"_GTK2_FIND_LIBRARY( ${_var} ${_lib} ${_expand_vc} ${_append_version} )")
endif()
# Not GTK versions per se but the versions encoded into Windows
# import libraries (GtkMM 2.14.1 has a gtkmm-vc80-2_4.lib for example)
# Also the MSVC libraries use _ for . (this is handled below)
set(_versions 2.20 2.18 2.16 2.14 2.12
2.10 2.8 2.6 2.4 2.2 2.0
1.20 1.18 1.16 1.14 1.12
1.10 1.8 1.6 1.4 1.2 1.0)
set(_library)
set(_library_d)
set(_library ${_lib})
if(_expand_vc AND MSVC)
# Add vc80/vc90/vc100 midfixes
if(MSVC80)
set(_library ${_library}-vc80)
elseif(MSVC90)
set(_library ${_library}-vc90)
elseif(MSVC10)
set(_library ${_library}-vc100)
endif()
set(_library_d ${_library}-d)
endif()
if(GTK2_DEBUG)
message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
"After midfix addition = ${_library} and ${_library_d}")
endif()
set(_lib_list)
set(_libd_list)
if(_append_version)
foreach(_ver ${_versions})
list(APPEND _lib_list "${_library}-${_ver}")
list(APPEND _libd_list "${_library_d}-${_ver}")
endforeach()
else()
set(_lib_list ${_library})
set(_libd_list ${_library_d})
endif()
if(GTK2_DEBUG)
message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
"library list = ${_lib_list} and library debug list = ${_libd_list}")
endif()
# For some silly reason the MSVC libraries use _ instead of .
# in the version fields
if(_expand_vc AND MSVC)
set(_no_dots_lib_list)
set(_no_dots_libd_list)
foreach(_l ${_lib_list})
string(REPLACE "." "_" _no_dots_library ${_l})
list(APPEND _no_dots_lib_list ${_no_dots_library})
endforeach()
# And for debug
set(_no_dots_libsd_list)
foreach(_l ${_libd_list})
string(REPLACE "." "_" _no_dots_libraryd ${_l})
list(APPEND _no_dots_libd_list ${_no_dots_libraryd})
endforeach()
# Copy list back to original names
set(_lib_list ${_no_dots_lib_list})
set(_libd_list ${_no_dots_libd_list})
endif()
if(GTK2_DEBUG)
message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
"While searching for ${_var}, our proposed library list is ${_lib_list}")
endif()
find_library(${_var}
NAMES ${_lib_list}
PATHS
/opt/gnome/lib
/opt/gnome/lib64
/usr/openwin/lib
/usr/openwin/lib64
/sw/lib
$ENV{GTKMM_BASEPATH}/lib
[HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]/lib
[HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]/lib
)
if(_expand_vc AND MSVC)
if(GTK2_DEBUG)
message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
"While searching for ${_var}_DEBUG our proposed library list is ${_libd_list}")
endif()
find_library(${_var}_DEBUG
NAMES ${_libd_list}
PATHS
$ENV{GTKMM_BASEPATH}/lib
[HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]/lib
[HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]/lib
)
if(${_var} AND ${_var}_DEBUG)
if(NOT GTK2_SKIP_MARK_AS_ADVANCED)
mark_as_advanced(${_var}_DEBUG)
endif()
set(GTK2_LIBRARIES ${GTK2_LIBRARIES} optimized ${${_var}} debug ${${_var}_DEBUG})
set(GTK2_LIBRARIES ${GTK2_LIBRARIES} PARENT_SCOPE)
endif()
else()
if(NOT GTK2_SKIP_MARK_AS_ADVANCED)
mark_as_advanced(${_var})
endif()
set(GTK2_LIBRARIES ${GTK2_LIBRARIES} ${${_var}})
set(GTK2_LIBRARIES ${GTK2_LIBRARIES} PARENT_SCOPE)
# Set debug to release
set(${_var}_DEBUG ${${_var}})
set(${_var}_DEBUG ${${_var}} PARENT_SCOPE)
endif()
endfunction(_GTK2_FIND_LIBRARY)
#=============================================================
#
# main()
#
set(GTK2_FOUND)
set(GTK2_INCLUDE_DIRS)
set(GTK2_LIBRARIES)
if(NOT GTK2_FIND_COMPONENTS)
# Assume they only want GTK
set(GTK2_FIND_COMPONENTS gtk)
endif()
#
# If specified, enforce version number
#
if(GTK2_FIND_VERSION)
cmake_minimum_required(VERSION 2.6.2)
set(GTK2_FAILED_VERSION_CHECK true)
if(GTK2_DEBUG)
message(STATUS "[FindGTK2.cmake:${CMAKE_CURRENT_LIST_LINE}] "
"Searching for version ${GTK2_FIND_VERSION}")
endif()
_GTK2_FIND_INCLUDE_DIR(GTK2_GTK_INCLUDE_DIR gtk/gtk.h)
if(GTK2_GTK_INCLUDE_DIR)
_GTK2_GET_VERSION(GTK2_MAJOR_VERSION
GTK2_MINOR_VERSION
GTK2_PATCH_VERSION
${GTK2_GTK_INCLUDE_DIR}/gtk/gtkversion.h)
set(GTK2_VERSION
${GTK2_MAJOR_VERSION}.${GTK2_MINOR_VERSION}.${GTK2_PATCH_VERSION})
if(GTK2_FIND_VERSION_EXACT)
if(GTK2_VERSION VERSION_EQUAL GTK2_FIND_VERSION)
set(GTK2_FAILED_VERSION_CHECK false)
endif()
else()
if(GTK2_VERSION VERSION_EQUAL GTK2_FIND_VERSION OR
GTK2_VERSION VERSION_GREATER GTK2_FIND_VERSION)
set(GTK2_FAILED_VERSION_CHECK false)
endif()
endif()
else()
# If we can't find the GTK include dir, we can't do version checking
if(GTK2_FIND_REQUIRED AND NOT GTK2_FIND_QUIETLY)
message(FATAL_ERROR "Could not find GTK2 include directory")
endif()
return()
endif()
if(GTK2_FAILED_VERSION_CHECK)
if(GTK2_FIND_REQUIRED AND NOT GTK2_FIND_QUIETLY)
if(GTK2_FIND_VERSION_EXACT)
message(FATAL_ERROR "GTK2 version check failed. Version ${GTK2_VERSION} was found, version ${GTK2_FIND_VERSION} is needed exactly.")
else()
message(FATAL_ERROR "GTK2 version check failed. Version ${GTK2_VERSION} was found, at least version ${GTK2_FIND_VERSION} is required")
endif()
endif()
# If the version check fails, exit out of the module here
return()
endif()
endif()
#
# Find all components
#
find_package(Freetype)
list(APPEND GTK2_INCLUDE_DIRS ${FREETYPE_INCLUDE_DIRS})
list(APPEND GTK2_LIBRARIES ${FREETYPE_LIBRARIES})
foreach(_GTK2_component ${GTK2_FIND_COMPONENTS})
if(_GTK2_component STREQUAL "gtk")
_GTK2_FIND_INCLUDE_DIR(GTK2_GLIB_INCLUDE_DIR glib.h)
_GTK2_FIND_INCLUDE_DIR(GTK2_GLIBCONFIG_INCLUDE_DIR glibconfig.h)
_GTK2_FIND_LIBRARY (GTK2_GLIB_LIBRARY glib false true)
_GTK2_FIND_INCLUDE_DIR(GTK2_GOBJECT_INCLUDE_DIR gobject/gobject.h)
_GTK2_FIND_LIBRARY (GTK2_GOBJECT_LIBRARY gobject false true)
_GTK2_FIND_INCLUDE_DIR(GTK2_GDK_PIXBUF_INCLUDE_DIR gdk-pixbuf/gdk-pixbuf.h)
_GTK2_FIND_LIBRARY (GTK2_GDK_PIXBUF_LIBRARY gdk_pixbuf false true)
_GTK2_FIND_INCLUDE_DIR(GTK2_GDK_INCLUDE_DIR gdk/gdk.h)
_GTK2_FIND_INCLUDE_DIR(GTK2_GDKCONFIG_INCLUDE_DIR gdkconfig.h)
_GTK2_FIND_INCLUDE_DIR(GTK2_GTK_INCLUDE_DIR gtk/gtk.h)
if(UNIX)
_GTK2_FIND_LIBRARY (GTK2_GDK_LIBRARY gdk-x11 false true)
_GTK2_FIND_LIBRARY (GTK2_GTK_LIBRARY gtk-x11 false true)
else()
_GTK2_FIND_LIBRARY (GTK2_GDK_LIBRARY gdk-win32 false true)
_GTK2_FIND_LIBRARY (GTK2_GTK_LIBRARY gtk-win32 false true)
endif()
_GTK2_FIND_INCLUDE_DIR(GTK2_CAIRO_INCLUDE_DIR cairo.h)
_GTK2_FIND_LIBRARY (GTK2_CAIRO_LIBRARY cairo false false)
_GTK2_FIND_INCLUDE_DIR(GTK2_FONTCONFIG_INCLUDE_DIR fontconfig/fontconfig.h)
_GTK2_FIND_INCLUDE_DIR(GTK2_PANGO_INCLUDE_DIR pango/pango.h)
_GTK2_FIND_LIBRARY (GTK2_PANGO_LIBRARY pango false true)
_GTK2_FIND_INCLUDE_DIR(GTK2_ATK_INCLUDE_DIR atk/atk.h)
_GTK2_FIND_LIBRARY (GTK2_ATK_LIBRARY atk false true)
elseif(_GTK2_component STREQUAL "gtkmm")
_GTK2_FIND_INCLUDE_DIR(GTK2_GLIBMM_INCLUDE_DIR glibmm.h)
_GTK2_FIND_INCLUDE_DIR(GTK2_GLIBMMCONFIG_INCLUDE_DIR glibmmconfig.h)
_GTK2_FIND_LIBRARY (GTK2_GLIBMM_LIBRARY glibmm true true)
_GTK2_FIND_INCLUDE_DIR(GTK2_GDKMM_INCLUDE_DIR gdkmm.h)
_GTK2_FIND_INCLUDE_DIR(GTK2_GDKMMCONFIG_INCLUDE_DIR gdkmmconfig.h)
_GTK2_FIND_LIBRARY (GTK2_GDKMM_LIBRARY gdkmm true true)
_GTK2_FIND_INCLUDE_DIR(GTK2_GTKMM_INCLUDE_DIR gtkmm.h)
_GTK2_FIND_INCLUDE_DIR(GTK2_GTKMMCONFIG_INCLUDE_DIR gtkmmconfig.h)
_GTK2_FIND_LIBRARY (GTK2_GTKMM_LIBRARY gtkmm true true)
_GTK2_FIND_INCLUDE_DIR(GTK2_CAIROMM_INCLUDE_DIR cairomm/cairomm.h)
_GTK2_FIND_LIBRARY (GTK2_CAIROMM_LIBRARY cairomm true true)
_GTK2_FIND_INCLUDE_DIR(GTK2_PANGOMM_INCLUDE_DIR pangomm.h)
_GTK2_FIND_INCLUDE_DIR(GTK2_PANGOMMCONFIG_INCLUDE_DIR pangommconfig.h)
_GTK2_FIND_LIBRARY (GTK2_PANGOMM_LIBRARY pangomm true true)
_GTK2_FIND_INCLUDE_DIR(GTK2_SIGC++_INCLUDE_DIR sigc++/sigc++.h)
_GTK2_FIND_INCLUDE_DIR(GTK2_SIGC++CONFIG_INCLUDE_DIR sigc++config.h)
_GTK2_FIND_LIBRARY (GTK2_SIGC++_LIBRARY sigc true true)
_GTK2_FIND_INCLUDE_DIR(GTK2_GIOMM_INCLUDE_DIR giomm.h)
_GTK2_FIND_INCLUDE_DIR(GTK2_GIOMMCONFIG_INCLUDE_DIR giommconfig.h)
_GTK2_FIND_LIBRARY (GTK2_GIOMM_LIBRARY giomm true true)
_GTK2_FIND_INCLUDE_DIR(GTK2_ATKMM_INCLUDE_DIR atkmm.h)
_GTK2_FIND_LIBRARY (GTK2_ATKMM_LIBRARY atkmm true true)
elseif(_GTK2_component STREQUAL "glade")
_GTK2_FIND_INCLUDE_DIR(GTK2_GLADE_INCLUDE_DIR glade/glade.h)
_GTK2_FIND_LIBRARY (GTK2_GLADE_LIBRARY glade false true)
elseif(_GTK2_component STREQUAL "glademm")
_GTK2_FIND_INCLUDE_DIR(GTK2_GLADEMM_INCLUDE_DIR libglademm.h)
_GTK2_FIND_INCLUDE_DIR(GTK2_GLADEMMCONFIG_INCLUDE_DIR libglademmconfig.h)
_GTK2_FIND_LIBRARY (GTK2_GLADEMM_LIBRARY glademm true true)
else()
message(FATAL_ERROR "Unknown GTK2 component ${_component}")
endif()
endforeach()
#
# Solve for the GTK2 version if we haven't already
#
if(NOT GTK2_FIND_VERSION AND GTK2_GTK_INCLUDE_DIR)
_GTK2_GET_VERSION(GTK2_MAJOR_VERSION
GTK2_MINOR_VERSION
GTK2_PATCH_VERSION
${GTK2_GTK_INCLUDE_DIR}/gtk/gtkversion.h)
set(GTK2_VERSION ${GTK2_MAJOR_VERSION}.${GTK2_MINOR_VERSION}.${GTK2_PATCH_VERSION})
endif()
#
# Try to enforce components
#
set(_GTK2_did_we_find_everything true) # This gets set to GTK2_FOUND
include(FindPackageHandleStandardArgs)
foreach(_GTK2_component ${GTK2_FIND_COMPONENTS})
string(TOUPPER ${_GTK2_component} _COMPONENT_UPPER)
if(_GTK2_component STREQUAL "gtk")
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK2_${_COMPONENT_UPPER} "Some or all of the gtk libraries were not found."
GTK2_GTK_LIBRARY
GTK2_GTK_INCLUDE_DIR
GTK2_GLIB_INCLUDE_DIR
GTK2_GLIBCONFIG_INCLUDE_DIR
GTK2_GLIB_LIBRARY
GTK2_GDK_INCLUDE_DIR
GTK2_GDKCONFIG_INCLUDE_DIR
GTK2_GDK_LIBRARY
)
elseif(_GTK2_component STREQUAL "gtkmm")
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK2_${_COMPONENT_UPPER} "Some or all of the gtkmm libraries were not found."
GTK2_GTKMM_LIBRARY
GTK2_GTKMM_INCLUDE_DIR
GTK2_GTKMMCONFIG_INCLUDE_DIR
GTK2_GLIBMM_INCLUDE_DIR
GTK2_GLIBMMCONFIG_INCLUDE_DIR
GTK2_GLIBMM_LIBRARY
GTK2_GDKMM_INCLUDE_DIR
GTK2_GDKMMCONFIG_INCLUDE_DIR
GTK2_GDKMM_LIBRARY
)
elseif(_GTK2_component STREQUAL "glade")
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK2_${_COMPONENT_UPPER} "The glade library was not found."
GTK2_GLADE_LIBRARY
GTK2_GLADE_INCLUDE_DIR
)
elseif(_GTK2_component STREQUAL "glademm")
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK2_${_COMPONENT_UPPER} "The glademm library was not found."
GTK2_GLADEMM_LIBRARY
GTK2_GLADEMM_INCLUDE_DIR
GTK2_GLADEMMCONFIG_INCLUDE_DIR
)
endif()
if(NOT GTK2_${_COMPONENT_UPPER}_FOUND)
set(_GTK2_did_we_find_everything false)
endif()
endforeach()
if(_GTK2_did_we_find_everything AND NOT GTK2_VERSION_CHECK_FAILED)
set(GTK2_FOUND true)
else()
# Unset our variables.
set(GTK2_FOUND false)
set(GTK2_VERSION)
set(GTK2_VERSION_MAJOR)
set(GTK2_VERSION_MINOR)
set(GTK2_VERSION_PATCH)
set(GTK2_INCLUDE_DIRS)
set(GTK2_LIBRARIES)
endif()
if(GTK2_INCLUDE_DIRS)
list(REMOVE_DUPLICATES GTK2_INCLUDE_DIRS)
endif()

View File

@ -7,12 +7,7 @@ SET(FIND_LIBRARY_USE_LIB64_PATHS FALSE)
## Linux only libraries ## Linux only libraries
if(Linux) if(Linux)
# Most plugins (if not all) and PCSX2 core need gtk2, so set the required flags # Most plugins (if not all) and PCSX2 core need gtk2, so set the required flags
# find_package(GTK2 REQUIRED gtk)
# Warning: because of multiarch Ubuntu move /usr/lib/glib-2.0/include/glibconfig.h to /usr/lib/i386-linux-gnu/glib-2.0/include/glibconfig.h
# So as temporary work around, I copy the FindGTK2 module inside pcsx2 and add the /usr/lib/i386-linux-gnu path... -- Gregory
#
# find_package(GTK2 REQUIRED gtk)
find_package(GTK2_pcsx2 REQUIRED gtk)
if(GTK2_FOUND) if(GTK2_FOUND)
# From version 2.21.3 gtk moved gdk-pixbuf into a separate module # From version 2.21.3 gtk moved gdk-pixbuf into a separate module
# Cmake need to be fixed. For the moment uses a manual detection. # Cmake need to be fixed. For the moment uses a manual detection.

View File

@ -30,6 +30,8 @@ endif(GLSL_API)
#--------------------------------------- #---------------------------------------
if(wxWidgets_FOUND AND SPARSEHASH_FOUND) if(wxWidgets_FOUND AND SPARSEHASH_FOUND)
set(common_libs TRUE) set(common_libs TRUE)
elseif(NOT EXISTS "${PROJECT_SOURCE_DIR}/common/src")
set(common_libs FALSE)
else(wxWidgets_FOUND AND SPARSEHASH_FOUND) else(wxWidgets_FOUND AND SPARSEHASH_FOUND)
set(common_libs FALSE) set(common_libs FALSE)
message(STATUS "Skip build of common libraries: miss some dependencies") message(STATUS "Skip build of common libraries: miss some dependencies")
@ -46,17 +48,19 @@ endif(wxWidgets_FOUND AND SPARSEHASH_FOUND)
# Common dependancy # Common dependancy
if(wxWidgets_FOUND AND ZLIB_FOUND AND common_libs) if(wxWidgets_FOUND AND ZLIB_FOUND AND common_libs)
set(pcsx2_core TRUE) set(pcsx2_core TRUE)
elseif(NOT EXISTS "${PROJECT_SOURCE_DIR}/pcsx2")
set(pcsx2_core FALSE)
else(wxWidgets_FOUND AND ZLIB_FOUND AND common_libs) else(wxWidgets_FOUND AND ZLIB_FOUND AND common_libs)
set(pcsx2_core FALSE) set(pcsx2_core FALSE)
message(STATUS "Skip build of pcsx2 core: miss some dependencies") message(STATUS "Skip build of pcsx2 core: miss some dependencies")
message(STATUS "${msg_dep_pcsx2}") message(STATUS "${msg_dep_pcsx2}")
endif(wxWidgets_FOUND AND ZLIB_FOUND AND common_libs) endif(wxWidgets_FOUND AND ZLIB_FOUND AND common_libs)
# Linux need also gtk2 # Linux need also gtk2
if(Linux AND NOT GTK2_FOUND) if(Linux AND pcsx2_core AND NOT GTK2_FOUND)
set(pcsx2_core FALSE) set(pcsx2_core FALSE)
message(STATUS "Skip build of pcsx2 core: miss some dependencies") message(STATUS "Skip build of pcsx2 core: miss some dependencies")
message(STATUS "${msg_dep_pcsx2}") message(STATUS "${msg_dep_pcsx2}")
endif(Linux AND NOT GTK2_FOUND) endif(Linux AND pcsx2_core AND NOT GTK2_FOUND)
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
@ -83,6 +87,8 @@ endif(GTK2_FOUND)
#--------------------------------------- #---------------------------------------
if(BZIP2_FOUND AND GTK2_FOUND) if(BZIP2_FOUND AND GTK2_FOUND)
set(CDVDiso TRUE) set(CDVDiso TRUE)
elseif(NOT EXISTS "${PROJECT_SOURCE_DIR}/plugins/CDVDiso")
set(CDVDiso FALSE)
else(BZIP2_FOUND AND GTK2_FOUND) else(BZIP2_FOUND AND GTK2_FOUND)
set(CDVDiso FALSE) set(CDVDiso FALSE)
message(STATUS "Skip build of CDVDiso: miss some dependencies") message(STATUS "Skip build of CDVDiso: miss some dependencies")
@ -127,6 +133,8 @@ endif(GTK2_FOUND)
#--------------------------------------- #---------------------------------------
if(OPENGL_FOUND AND X11_FOUND) if(OPENGL_FOUND AND X11_FOUND)
set(GSdx TRUE) set(GSdx TRUE)
elseif(NOT EXISTS "${PROJECT_SOURCE_DIR}/plugins/GSdx")
set(GSdx FALSE)
else(OPENGL_FOUND AND X11_FOUND) else(OPENGL_FOUND AND X11_FOUND)
set(GSdx FALSE) set(GSdx FALSE)
message(STATUS "Skip build of GSdx: miss some dependencies") message(STATUS "Skip build of GSdx: miss some dependencies")
@ -144,6 +152,8 @@ endif(OPENGL_FOUND AND X11_FOUND)
#--------------------------------------- #---------------------------------------
if(GLEW_FOUND AND OPENGL_FOUND AND X11_FOUND AND CG_FOUND) if(GLEW_FOUND AND OPENGL_FOUND AND X11_FOUND AND CG_FOUND)
set(zerogs TRUE) set(zerogs TRUE)
elseif(NOT EXISTS "${PROJECT_SOURCE_DIR}/plugins/zerogs")
set(zerogs FALSE)
else(GLEW_FOUND AND OPENGL_FOUND AND X11_FOUND AND CG_FOUND) else(GLEW_FOUND AND OPENGL_FOUND AND X11_FOUND AND CG_FOUND)
set(zerogs FALSE) set(zerogs FALSE)
message(STATUS "Skip build of zerogs: miss some dependencies") message(STATUS "Skip build of zerogs: miss some dependencies")
@ -168,6 +178,10 @@ if((GLEW_FOUND AND OPENGL_FOUND AND X11_FOUND AND JPEG_FOUND AND common_libs) AN
else(CG_FOUND AND NOT GLSL_API) else(CG_FOUND AND NOT GLSL_API)
set(zzoglcg FALSE) set(zzoglcg FALSE)
endif(CG_FOUND AND NOT GLSL_API) endif(CG_FOUND AND NOT GLSL_API)
elseif(NOT EXISTS "${PROJECT_SOURCE_DIR}/plugins/zzogl-pg")
set(zzogl FALSE)
set(zzoglcg FALSE)
set(REBUILD_SHADER FALSE)
else((GLEW_FOUND AND OPENGL_FOUND AND X11_FOUND AND JPEG_FOUND AND common_libs) AND (CG_FOUND OR GLSL_API)) else((GLEW_FOUND AND OPENGL_FOUND AND X11_FOUND AND JPEG_FOUND AND common_libs) AND (CG_FOUND OR GLSL_API))
set(zzogl FALSE) set(zzogl FALSE)
set(zzoglcg FALSE) set(zzoglcg FALSE)
@ -192,6 +206,8 @@ endif(GTK2_FOUND)
#--------------------------------------- #---------------------------------------
if(SDL_FOUND) if(SDL_FOUND)
set(onepad TRUE) set(onepad TRUE)
elseif(NOT EXISTS "${PROJECT_SOURCE_DIR}/plugins/onepad")
set(onepad FALSE)
else(SDL_FOUND) else(SDL_FOUND)
set(onepad FALSE) set(onepad FALSE)
message(STATUS "Skip build of onepad: miss some dependencies") message(STATUS "Skip build of onepad: miss some dependencies")
@ -217,6 +233,8 @@ endif(GTK2_FOUND)
#--------------------------------------- #---------------------------------------
if(ALSA_FOUND AND PORTAUDIO_FOUND AND SOUNDTOUCH_FOUND AND common_libs) if(ALSA_FOUND AND PORTAUDIO_FOUND AND SOUNDTOUCH_FOUND AND common_libs)
set(spu2-x TRUE) set(spu2-x TRUE)
elseif(NOT EXISTS "${PROJECT_SOURCE_DIR}/plugins/spu2-x")
set(spu2-x FALSE)
else(ALSA_FOUND AND PORTAUDIO_FOUND AND SOUNDTOUCH_FOUND AND common_libs) else(ALSA_FOUND AND PORTAUDIO_FOUND AND SOUNDTOUCH_FOUND AND common_libs)
set(spu2-x FALSE) set(spu2-x FALSE)
message(STATUS "Skip build of spu2-x: miss some dependencies") message(STATUS "Skip build of spu2-x: miss some dependencies")
@ -231,16 +249,18 @@ endif(ALSA_FOUND AND PORTAUDIO_FOUND AND SOUNDTOUCH_FOUND AND common_libs)
# -ALSA # -ALSA
# -PortAudio # -PortAudio
#--------------------------------------- #---------------------------------------
if(SOUNDTOUCH_FOUND AND ALSA_FOUND) if(EXISTS "${PROJECT_SOURCE_DIR}/plugins/zerospu2" AND SOUNDTOUCH_FOUND AND ALSA_FOUND)
set(zerospu2 TRUE) set(zerospu2 TRUE)
# Comment the next line, if you want to compile zerospu2 # Comment the next line, if you want to compile zerospu2
set(zerospu2 FALSE) set(zerospu2 FALSE)
message(STATUS "Don't build zerospu2. It is super-seeded by spu2x") message(STATUS "Don't build zerospu2. It is super-seeded by spu2x")
else(SOUNDTOUCH_FOUND AND ALSA_FOUND) elseif(NOT EXISTS "${PROJECT_SOURCE_DIR}/plugins/zerospu2")
set(zerospu2 FALSE)
else(EXISTS "${PROJECT_SOURCE_DIR}/plugins/zerospu2" AND SOUNDTOUCH_FOUND AND ALSA_FOUND)
set(zerospu2 FALSE) set(zerospu2 FALSE)
message(STATUS "Skip build of zerospu2: miss some dependencies") message(STATUS "Skip build of zerospu2: miss some dependencies")
message(STATUS "${msg_dep_zerospu2}") message(STATUS "${msg_dep_zerospu2}")
endif(SOUNDTOUCH_FOUND AND ALSA_FOUND) endif(EXISTS "${PROJECT_SOURCE_DIR}/plugins/zerospu2" AND SOUNDTOUCH_FOUND AND ALSA_FOUND)
#--------------------------------------- #---------------------------------------
#--------------------------------------- #---------------------------------------

View File

@ -1,15 +1,72 @@
pcsx2 for debian ------------------------------
========================= Package information for PCSX2
------------------------------
* This version has some major modifications against the default upstream code. * The reasons given by upstream as to why they remove -fPIC are the following:
-> documents are stored in $XDG_CONFIG_HOME instead of $HOME/pcsx2 - Code only supports the i386 architecture.
- Code uses the ebx register and this is not compliant with -fPIC.
- The use of -fPIC negatively impacts the performance of the program.
- The .so file are not shared libraries but plug-ins. No program should try
to link with them.
* Documentation needs some love. Feel free to help. ------------------------------------------
Information about the plug-ins for video
------------------------------------------
* -fPIC option was removed for multiple reasons. * The zzogl plug-in comes in two flavors:
- Code only supports the x86 architecture. - The Nvidia Cg version which requires the non-free nvidia-cg-toolkit
- Upstream code uses the ebx register so it's not compliant with PIC. package. Since this package contains GPL-2+ code this plug-in can't be
- Impacts the performance too much. distributed without an GPL exception allowing linking with non-free
- Only plugins. No package will link to them. libraries. If the user desires to try this flavor of the plug-in he/she
must:
+ Install the nvidia-cg-dev or nvidia-cg-toolkit package from non-free.
+ Pass "-DGLSL_API=FALSE" to dh_auto_configure in the rules file.
+ Add "usr/lib/*/games/pcsx2/*.dat /usr/share/games/pcsx2/" to the install
file.
+ Compile the program using dpkg-buildpackage.
This plug-in currently provides the greatest compatibility with video cards
and drivers. It currently works with open source drivers like radeon R600.
- The OpenGL Shading Language (GLSL) version which currently only works with
AMD video cards but support for other cards is being worked on.
* The GSdx plug-in currently only supports the OpenGL software renderer.
* The GSdx and zzogl GLSL plug-ins currently require a video card that supports
at least OpenGL 3.0. A noninclusive list of cards that support OpenGL 3.0 is:
- Radeon HD series (except HD2300)
- GeForce 8, 9, 100-series, 200-series, 300-series, 400-series and 500-series
- Intel Sandy Bridge HD Graphics 2000 and 3000
* Currently only the proprietary drivers for AMD and Nvidia have support for
OpenGL 3.0 and above. The GSdx and/or zzogl GLSL plug-ins use the following
extensions/commands that may or may not be completely implemented in the open
source video stack:
- OpenGL 3.0
+ glClearBuffer
+ glGetStringi
+ glVertexAttribI
+ GLX_ARB_create_context
+ GL_APPLE_vertex_array_object
+ GL_ARB_framebuffer_object
- OpenGL 3.1
+ GL_ARB_texture_rectangle (zzogl)
+ GL_ARB_uniform_buffer_object
- OpenGL 3.2
+ GL_ARB_geometry_shader4 (GSdx)
+ GL_ARB_draw_elements_base_vertex
+ GLX_ARB_create_context_profile
- OpenGL 3.3
+ GL_ARB_blend_func_extended (GSdx)
+ GL_ARB_explicit_attrib_location
+ GL_ARB_sampler_objects (GSdx)
- OpenGL 4.1
+ GL_ARB_separate_shader_objects
- OpenGL 4.2
+ GL_ARB_map_buffer_alignment
+ GL_ARB_shading_language_420pack
+ GL_ARB_texture_storage
- Extensions that may get included in future versions:
+ GL_NV_copy_image
The current status for the open source drivers can be found at:
- http://cgit.freedesktop.org/mesa/mesa/tree/docs/GL3.txt
-- Gregory Hainaut <gregory.hainaut@gmail.com> Sat, 24 Apr 2010 23:11:10 +0200

View File

@ -1,9 +0,0 @@
* policy bin2cpp tool ??
May be we could pregenerate the file in the upstream tar ball!!
* copyright and doc stuff
Lots of work to do here....
* need to add copyrigh info in Cmake file
## 64 bit
=> see multiarch

View File

@ -1 +1 @@
7 8

View File

@ -2,16 +2,14 @@ Source: pcsx2.snapshot
Section: contrib/games Section: contrib/games
Priority: optional Priority: optional
Maintainer: Gregory Hainaut <gregory.hainaut@gmail.com> Maintainer: Gregory Hainaut <gregory.hainaut@gmail.com>
# WARNING Natty need at least cmake 2.8.5 (multiarch issue) Build-Depends: cmake (>= 2.8.5),
Build-Depends: cmake (>= 2.8), debhelper (>= 8.9),
debhelper (>= 7.0.50),
dpkg-dev (>= 1.15.7), dpkg-dev (>= 1.15.7),
libasound2-dev, libasound2-dev,
libbz2-dev, libbz2-dev,
libgl1-mesa-dev, libgl1-mesa-dev,
# Future GSdx version will need glew1.6. Only Oneiric have it... # GSdx need glew1.6 and would love glew1.7
# libglew1.6-dev, libglew-dev (>= 1.6)| libglew1.6-dev,
libglew-dev (>= 1.6)| libglew1.5-dev,
libglu1-mesa-dev, libglu1-mesa-dev,
libgtk2.0-dev (>= 2.16), libgtk2.0-dev (>= 2.16),
libjpeg-dev, libjpeg-dev,
@ -26,49 +24,38 @@ Build-Depends: cmake (>= 2.8),
libcg, nvidia-cg-toolkit (>= 3), libcg, nvidia-cg-toolkit (>= 3),
portaudio19-dev, portaudio19-dev,
zlib1g-dev (>= 1:1.2.3.3) zlib1g-dev (>= 1:1.2.3.3)
Standards-Version: 3.9.2 Standards-Version: 3.9.3
Homepage: http://pcsx2.net/ Homepage: http://pcsx2.net/
Package: pcsx2-unstable Package: pcsx2-unstable
Architecture: i386 Architecture: i386
# manually add nvidia-cg-toolkit for zzogl (cg pacakge does not provide symbol or shlibs files)
# recommand libasound for alsa plugin for pulseaudio
Depends: ${shlibs:Depends}, ${misc:Depends}, Depends: ${shlibs:Depends}, ${misc:Depends},
pcsx2-plugins-unstable (>= ${binary:Version}) libcg | nvidia-cg-toolkit (>= 2.1)
Recommends: libasound2-plugins
Conflicts: pcsx2, Conflicts: pcsx2,
pcsx2-data-unstable pcsx2-data-unstable,
Replaces: pcsx2-data-unstable pcsx2-l10n-unstable,
pcsx2-plugins-unstable
Replaces: pcsx2-data-unstable,
pcsx2-l10n-unstable,
pcsx2-plugins-unstable
Description: Playstation 2 emulator Description: Playstation 2 emulator
PCSX2 is a PlayStation 2 emulator for Windows and Linux. PCSX2 is a PlayStation 2 emulator for Windows and Linux.
. .
WARNING: It requires a CPU with SSE2 instructions. If your CPU does not support WARNING: It requires a CPU with SSE2 instructions. If your CPU does not support
this instruction set, it does not have enough horse power to run this emulator this instruction set, it does not have enough horse power to run this emulator
anyway. anyway.
.
This package includes the main binary file.
Package: pcsx2-plugins-unstable
Architecture: i386
# manually add nvidia-cg-toolkit for zzogl (cg pacakge does not provide symbol or shlibs files)
Depends: ${shlibs:Depends}, ${misc:Depends},
libcg | nvidia-cg-toolkit (>= 2.1)
Recommends: pcsx2-unstable (>= ${binary:Version}),
Conflicts: pcsx2-plugins,
pcsx2-data-unstable
Replaces: pcsx2-data-unstable
Description: Various plugins for PCSX2
PCSX2 is a PlayStation 2 emulator for Windows and Linux.
.
WARNING: It requires a CPU with SSE2 instructions. If your CPU does not support
this instruction set, it does not have enough horse power to run this emulator
anyway.
.
This package includes the plugins for PCSX2.
Package: pcsx2-unstable-dbg Package: pcsx2-unstable-dbg
Section: contrib/debug Section: contrib/debug
Priority: extra Priority: extra
Architecture: i386 Architecture: i386
Depends: ${misc:Depends}, pcsx2-unstable (= ${binary:Version}) Depends: ${misc:Depends}, pcsx2-unstable (= ${binary:Version})
Conflicts: pcsx2-dbg Conflicts: pcsx2-dbg,
pcsx2-plugins-unstable-dbg
Replaces: pcsx2-plugins-unstable-dbg
Description: Debug symbols for pcsx2 Description: Debug symbols for pcsx2
PCSX2 is a PlayStation 2 emulator for Windows and Linux. PCSX2 is a PlayStation 2 emulator for Windows and Linux.
. .
@ -78,32 +65,3 @@ Description: Debug symbols for pcsx2
. .
This package contains the debug symbols for PCSX2. This package contains the debug symbols for PCSX2.
Package: pcsx2-plugins-unstable-dbg
Section: contrib/debug
Priority: extra
Architecture: i386
Depends: ${misc:Depends}, pcsx2-plugins-unstable (= ${binary:Version})
Conflicts: pcsx2-plugins-dbg
Description: Debug symbols of the pcsx2-plugins
PCSX2 is a PlayStation 2 emulator for Windows and Linux.
.
WARNING: It requires a CPU with SSE2 instructions. If your CPU does not support
this instruction set, it does not have enough horse power to run this emulator
anyway.
.
This package contains the debug symbols for the PCSX2 plugins.
Package: pcsx2-l10n-unstable
Section: contrib/localization
Architecture: all
Depends: ${misc:Depends}
Recommends: pcsx2-unstable (>= ${source:Version})
Conflicts: pcsx2-l10n
Description: Language files for PCSX2
PCSX2 is a PlayStation 2 emulator for Windows and Linux.
.
WARNING: It requires a CPU with SSE2 instructions. If your CPU does not support
this instruction set, it does not have enough horse power to run this emulator
anyway.
.
This package contains the localization of the emulator in various languages.

View File

@ -1,168 +1,155 @@
This work was packaged for Debian by: Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: PCSX2
Gregory Hainaut <gregory.hainaut@gmail.com> on Sat, 24 Apr 2010 23:11:10 +0200 Source: http://code.google.com/p/pcsx2/source
It was downloaded from:
http://pcsx2.googlecode.com/svn/
Upstream Author(s):
PCSX2 Dev Team
Files: debian/*
Copyright: Copyright:
2010-2012 Gregory Hainaut <gregory.hainaut@gmail.com>
2010-2012 Miguel Colon <debian.micove@gmail.com>
License: LGPL-3
Copyright (C) 2002-2010 PCSX2 Dev Team Files: pcsx2/* common/* plugins/spu2-x/* plugins/PadNull/Pad* plugins/USBnull/* plugins/FWnull/* plugins/CDVDnull/CDVD* plugins/GSnull/* plugins/dev9null/DEV9.cpp
Copyright: 2002-2012 PCSX2 Dev Team
Files: pcsx2/*, common/*, plugins/spu2-x/*, plugins/PadNull/Pad*, plugins/USBnull/*, plugins/FWnull/*, plugins/CDVDnull/CDVD*, plugins/GSnull/*, plugins/dev9null/DEV9.cpp
License: LGPL-3+ License: LGPL-3+
This program is free software: you can redistribute it and/or modify Files: pcsx2/Mdec.cpp pcsx2/Mdec.h pcsx2/RDebug/deci2_drfp.cpp pcsx2/IPU/mpeg2lib/* pcsx2/cheatscpp.h common/include/api/* plugins/onepad/* plugins/PadNull/Linux/* plugins/SPU2null/* plugins/FWnull/FW.cpp plugins/zerospu2/* plugins/zzogl-pg/* plugins/GSnull/Registers.h plugins/GSnull/Linux/Linux* plugins/GSnull/Linux/Config* plugins/dev9null/DEV9.h plugins/dev9null/Config.*
it under the terms of the GNU Lesser General Public License as published by Copyright: 2002-2012 PCSX2 Dev Team
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This package 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
On Debian systems, the complete text of the GNU Lesser General
Public License version 3 can be found in "/usr/share/common-licenses/LGPL-3".
Files: pcsx2/Mdec.cpp, pcsx2/Mdec.h, pcsx2/RDebug/deci2_drfp.cpp, pcsx2/IPU/mpeg2lib/*, pcsx2/cheatscpp.h, common/include/api/*, plugins/onepad/*, plugins/PadNull/Linux/*, plugins/SPU2null/*, plugins/FWnull/FW.cpp, plugins/zerospu2/*, plugins/zzogl-pg/*, plugins/GSnull/Registers.h, plugins/GSnull/Linux/Linux*, plugins/GSnull/Linux/Config*, plugins/dev9null/DEV9.h, plugins/dev9null/Config.*
License: GPL-2+ License: GPL-2+
This program is free software: you can redistribute it and/or modify Files: plugins/spu2-x/src/Spu2replay.* plugins/spu2-x/src/Decode* plugins/spu2-x/src/Linux/ConfigSoundTouch.cpp plugins/spu2-x/src/spdif.h plugins/spu2-x/src/Debug.h
it under the terms of the GNU General Public License as published by Copyright: 2002-2012 PCSX2 Dev Team
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This package 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 this program. If not, see <http://www.gnu.org/licenses/>.
On Debian systems, the complete text of the GNU General
Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
Files: plugins/spu2-x/src/Spu2replay.*, plugins/spu2-x/src/Decode*, plugins/spu2-x/src/Linux/ConfigSoundTouch.cpp, plugins/spu2-x/src/spdif.h, plugins/spu2-x/src/Debug.h
License: LGPL-2.1+ License: LGPL-2.1+
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 2.1 of the License, or
(at your option) any later version.
This package 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
On Debian systems, the complete text of the GNU Lesser General
Public License version 2.1 can be found in "/usr/share/common-licenses/LGPL-2.1".
Files: plugins/zzogl-pg/opengl/glprocs.* Files: plugins/zzogl-pg/opengl/glprocs.*
Copyright: 1991-2000, Silicon Graphics, Inc Copyright: 1991-2000 Silicon Graphics, Inc
License: MIT/X11 (BSD like) License: SGI FREE SOFTWARE LICENSE B 2.0
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice including the dates of first publication and
either this permission notice or a reference to
http://oss.sgi.com/projects/FreeB/
shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Except as contained in this notice, the name of Silicon Graphics, Inc.
shall not be used in advertising or otherwise to promote the sale, use or
other dealings in this Software without prior written authorization from
Silicon Graphics, Inc.
Files: common/include/intrin_x86.h Files: common/include/intrin_x86.h
Copyright: 2006, KJK::Hyperion <hackbunny@reactos.com> Copyright: 2006 KJK::Hyperion <hackbunny@reactos.com>
License: MIT/X11 (BSD like) License: Expat
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Files: common/src/Utilities/vssprintf.cpp Files: common/src/Utilities/vssprintf.cpp
Copyright: 2002, Michael Ringgaard Copyright: 2002 Michael Ringgaard
License: BSD (3 clause) License: BSD-3-Clause
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
Files: plugins/zzogl-pg/opengl/zpipe.cpp Files: plugins/zzogl-pg/opengl/zpipe.cpp
Copyright: public domain Copyright: not applicable
License: public-domain
Author's Note:
zpipe.c: example of proper use of zlib's inflate() and deflate()
Not copyrighted -- provided to the public domain
Version 1.4 11 December 2005 Mark Adler
Files: plugins/zzogl-pg/opengl/ZeroGSShaders/zerogsshaders* License: LGPL-3 or LGPL-3+
Copyright: Unknown This program is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation, either version 3 of the License, 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 Lesser General Public License for more details.
.
You should have received a copy of the GNU Lesser General Public License along
with this program. If not, see <http://www.gnu.org/licenses/>.
Comment: On Debian systems, the complete text of the GNU Lesser General Public
License version 3 can be found in "/usr/share/common-licenses/LGPL-3".
The Debian packaging is: License: GPL-2+
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 of the License, 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
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
Street, Fifth Floor, Boston, MA 02110-1301, USA.
Comment: On Debian systems, the complete text of the GNU General Public License
version 2 can be found in "/usr/share/common-licenses/GPL-2".
Copyright (C) 2010 Gregory Hainaut <gregory.hainaut@gmail.com> License: LGPL-2.1+
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 2.1 of the License, 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 Lesser General Public License for more details.
.
You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc., 51
Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Comment: On Debian systems, the complete text of the GNU Lesser General Public
License version 2.1 can be found in "/usr/share/common-licenses/LGPL-2.1".
and is licensed under the Lesser GPL version 3, see above. License: SGI FREE SOFTWARE LICENSE B 2.0
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
.
The above copyright notice including the dates of first publication and either
this permission notice or a reference to http://oss.sgi.com/projects/FreeB/
shall be included in all copies or substantial portions of the Software.
.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL SILICON
GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
.
Except as contained in this notice, the name of Silicon Graphics, Inc. shall
not be used in advertising or otherwise to promote the sale, use or other
dealings in this Software without prior written authorization from Silicon
Graphics, Inc.
License: Expat
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
License: BSD-3-Clause
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
.
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors may be
used to endorse or promote products derived from this software without specific
prior written permission.
.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -105,7 +105,7 @@ echo "Downloading pcsx2 source revision ${SVN_CO_VERSION}"
mkdir -p $ROOT_DIR; mkdir -p $ROOT_DIR;
(cd $ROOT_DIR; (cd $ROOT_DIR;
get_svn_file CMakeLists.txt; get_svn_file CMakeLists.txt;
get_svn_dir common cmake locales pcsx2 tools; get_svn_dir common cmake locales pcsx2;
get_svn_dir debian-unstable-upstream linux_various; get_svn_dir debian-unstable-upstream linux_various;
echo "Done") echo "Done")
@ -125,18 +125,18 @@ mkdir -p $ROOT_DIR/plugins
# get_svn_dir plugins/CDVDnull plugins/CDVDiso; # get_svn_dir plugins/CDVDnull plugins/CDVDiso;
get_svn_dir plugins/PadNull plugins/onepad; get_svn_dir plugins/PadNull plugins/onepad;
get_svn_dir plugins/SPU2null plugins/spu2-x; get_svn_dir plugins/SPU2null plugins/spu2-x;
get_svn_dir plugins/GSnull plugins/zzogl-pg plugins/GSdx; get_svn_dir plugins/GSnull plugins/zzogl-pg plugins/zzogl-pg-cg plugins/GSdx;
get_svn_dir plugins/dev9null plugins/FWnull plugins/USBnull; get_svn_dir plugins/dev9null plugins/FWnull plugins/USBnull;
echo "Note: some plugins are more or less deprecated CDVDisoEFP, CDVDlinuz, Zerogs, Zeropad ..."; echo "Note: some plugins are more or less deprecated CDVDisoEFP, CDVDlinuz, Zerogs, Zeropad ...";
echo "Done") echo "Done")
## Download the internal sdl 1.3 for gsdx ## Download the internal sdl 1.3 for gsdx
echo "Downloading 3rdpary SDL 1.3 (need by gsdx) revision ${SVN_CO_VERSION}" # echo "Downloading 3rdpary SDL 1.3 (need by gsdx) revision ${SVN_CO_VERSION}"
mkdir -p $ROOT_DIR/3rdparty # mkdir -p $ROOT_DIR/3rdparty
(cd $ROOT_DIR/3rdparty/; # (cd $ROOT_DIR/3rdparty/;
get_svn_file 3rdparty/CMakeLists.txt; # get_svn_file 3rdparty/CMakeLists.txt;
get_svn_dir 3rdparty/SDL-1.3.0-5387;) # get_svn_dir 3rdparty/SDL-1.3.0-5387;)
echo "Done" # echo "Done"
## Installation ## Installation
@ -147,22 +147,12 @@ cp -r $ROOT_DIR $NEW_DIR
echo "Remove .svn directories" echo "Remove .svn directories"
find $NEW_DIR -name ".svn" -type d -exec rm -fr {} \; 2> /dev/null find $NEW_DIR -name ".svn" -type d -exec rm -fr {} \; 2> /dev/null
echo "Remove old build system (scripts and autotools)"
find $NEW_DIR -name "build.sh" -exec rm -f {} \;
find $NEW_DIR -name "install-sh" -exec rm -f {} \;
find $NEW_DIR -name "depcomp" -exec rm -f {} \;
find $NEW_DIR -name "missing" -exec rm -f {} \;
find $NEW_DIR -name "aclocal.m4" -exec rm -f {} \;
find $NEW_DIR -name "configure.ac" -exec rm -f {} \;
find $NEW_DIR -name "Makefile.am" -exec rm -f {} \;
echo "Remove windows files (useless & copyright issues)" echo "Remove windows files (useless & copyright issues)"
find $NEW_DIR -iname "windows" -type d -exec rm -fr {} \; 2> /dev/null find $NEW_DIR -iname "windows" -type d -exec rm -fr {} \; 2> /dev/null
find $NEW_DIR -name "Win32" -type d -exec rm -fr {} \; 2> /dev/null find $NEW_DIR -name "Win32" -type d -exec rm -fr {} \; 2> /dev/null
rm -fr "${NEW_DIR}/plugins/zzogl-pg/opengl/Win32" rm -fr "${NEW_DIR}/plugins/zzogl-pg/opengl/Win32"
rm -fr "${NEW_DIR}/tools/GSDumpGUI"
rm -fr "${NEW_DIR}/common/vsprops" rm -fr "${NEW_DIR}/common/vsprops"
echo "Remove useless files (copyright issues)" echo "Remove useless files (copyright issues)"
rm -fr "${NEW_DIR}/pcsx2/3rdparty" # useless link which annoy me
rm -fr "${NEW_DIR}/plugins/zzogl-pg/opengl/ZeroGSShaders" rm -fr "${NEW_DIR}/plugins/zzogl-pg/opengl/ZeroGSShaders"
rm -fr "${NEW_DIR}/common/src/Utilities/x86/MemcpyFast.cpp" rm -fr "${NEW_DIR}/common/src/Utilities/x86/MemcpyFast.cpp"
rm -fr "${NEW_DIR}/plugins/GSdx/baseclasses" rm -fr "${NEW_DIR}/plugins/GSdx/baseclasses"

View File

@ -0,0 +1,2 @@
debian/tmp/usr/share/doc/pcsx2
bin/docs/*.pdf

View File

@ -0,0 +1,7 @@
usr/bin/pcsx2 /usr/games/
usr/lib/games/pcsx2
usr/share/applications/pcsx2.desktop
usr/share/pixmaps/pcsx2.xpm
usr/share/locale usr/share/
var/games/pcsx2
usr/share/games/pcsx2

View File

@ -3,4 +3,4 @@
# - Upstream code uses the ebx register so it's not compliant with PIC. # - Upstream code uses the ebx register so it's not compliant with PIC.
# - Impacts the performance too much. # - Impacts the performance too much.
# - Only plugins. No package will link to them. # - Only plugins. No package will link to them.
pcsx2-plugins-unstable: shlib-with-non-pic-code : shlib-with-non-pic-code

View File

@ -0,0 +1 @@
bin/docs/pcsx2.1

View File

@ -2,5 +2,5 @@
needs="X11" \ needs="X11" \
section="Applications/Emulators" \ section="Applications/Emulators" \
title="pcsx2" \ title="pcsx2" \
longtitle="A playstation 2 emulators" \ longtitle="A playstation 2 emulator" \
command="/usr/games/pcsx2" command="/usr/games/pcsx2"

View File

@ -1 +0,0 @@
usr/share/locale usr/share/

View File

@ -1 +0,0 @@
usr/lib/games/pcsx2

View File

@ -1 +0,0 @@
debian/tmp/usr/share/doc/pcsx2

View File

@ -1,4 +0,0 @@
usr/bin/pcsx2
usr/share/applications/pcsx2.desktop
usr/share/pixmaps/pcsx2.xpm
var/games/pcsx2

View File

@ -1 +0,0 @@
bin/docs/pcsx2.man

View File

@ -1,5 +1,4 @@
#!/usr/bin/make -f #!/usr/bin/make -f
# -*- makefile -*-
# Uncomment this to turn on verbose mode. # Uncomment this to turn on verbose mode.
# export DH_VERBOSE=1 # export DH_VERBOSE=1
@ -15,20 +14,15 @@ override_dh_auto_configure:
-DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE) \ -DCMAKE_BUILD_TYPE=$(CMAKE_BUILD_TYPE) \
-DCMAKE_BUILD_STRIP=FALSE \ -DCMAKE_BUILD_STRIP=FALSE \
-DXDG_STD=TRUE \ -DXDG_STD=TRUE \
-DFORCE_INTERNAL_SDL=TRUE \
-DPACKAGE_MODE=TRUE -DPACKAGE_MODE=TRUE
clean:
dh_testdir
dh_testroot
dh_auto_clean
dh_clean
override_dh_strip: override_dh_strip:
dh_strip --package=pcsx2-unstable --dbg-package=pcsx2-unstable-dbg dh_strip --package=pcsx2-unstable --dbg-package=pcsx2-unstable-dbg
dh_strip --package=pcsx2-plugins-unstable --dbg-package=pcsx2-plugins-unstable-dbg
override_dh_makeshlibs:
clean:
dh_auto_clean
dh_clean
%: %:
dh $@ --parallel dh $@
.PHONY: clean

View File

@ -1,9 +1,3 @@
# Example watch control file for uscan
# Rename this file to "watch" and then you can run the "uscan" command
# to check for upstream updates and more.
# See uscan(1) for format
# Compulsory line, this is a version 3 file
version=3 version=3
# Note: Upstream does not release prepackaged source files. # Note: Upstream does not release prepackaged source files.

View File

@ -58,13 +58,14 @@ void GSDump::Close()
} }
} }
void GSDump::Transfer(int index, const u8* mem, size_t size) void GSDump::Transfer(int index, const u32* mem, size_t size, u32 real_size)
{ {
if(m_gs && size > 0) if(m_gs && size > 0)
{ {
fputc(0, m_gs); fputc(0, m_gs);
fputc(index, m_gs); fputc(index, m_gs);
fwrite(&size, 4, 1, m_gs); fwrite(&size, 4, 1, m_gs);
fwrite(&real_size, 4, 1, m_gs);
fwrite(mem, size, 1, m_gs); fwrite(mem, size, 1, m_gs);
} }
} }

View File

@ -56,7 +56,7 @@ public:
void Open(const string& fn, u32 crc, const freezeData& fd, u8* regs); void Open(const string& fn, u32 crc, const freezeData& fd, u8* regs);
void Close(); void Close();
void ReadFIFO(u32 size); void ReadFIFO(u32 size);
void Transfer(int index, const u8* mem, size_t size); void Transfer(int index, const u32* mem, size_t size, u32 real_size);
void VSync(int field, bool last, u8* regs); void VSync(int field, bool last, u8* regs);
operator bool() {return m_gs != NULL;} operator bool() {return m_gs != NULL;}
}; };

View File

@ -399,7 +399,7 @@ static bool get_snapshot_filename(char *filename, char* path, const char* extens
{ {
snapshotnr++; snapshotnr++;
sprintf(filename, "%s/snap%03ld.%s", path, snapshotnr, extension); sprintf(filename, "%s/snap%03d.%s", path, snapshotnr, extension);
bmpfile = fopen(filename, "rb"); bmpfile = fopen(filename, "rb");
@ -627,6 +627,7 @@ struct Packet
{ {
u8 type, param; u8 type, param;
u32 size, addr; u32 size, addr;
u32 real_size;
vector<u32> buff; vector<u32> buff;
}; };
@ -680,18 +681,20 @@ EXPORT_C_(void) GSReplay(char* lpszCmdLine)
p->param = (u8)fgetc(fp); p->param = (u8)fgetc(fp);
fread(&p->size, 4, 1, fp); fread(&p->size, 4, 1, fp);
fread(&p->real_size, 4, 1, fp);
switch(p->param) switch(p->param)
{ {
case 0: case 0:
p->buff.resize(0x4000); p->buff.resize(0x4000/4);
p->addr = 0x4000 - p->size; //p->addr = 0x4000 - p->size;
fread(&p->buff[p->addr], p->size, 1, fp); //fread(&p->buff[p->addr], p->size, 1, fp);
fread(&p->buff[0], p->size, 1, fp);
break; break;
case 1: case 1:
case 2: case 2:
case 3: case 3:
p->buff.resize(p->size); p->buff.resize(p->size/4);
fread(&p->buff[0], p->size, 1, fp); fread(&p->buff[0], p->size, 1, fp);
break; break;
} }
@ -712,7 +715,7 @@ EXPORT_C_(void) GSReplay(char* lpszCmdLine)
case 3: case 3:
p->buff.resize(0x2000); p->buff.resize(0x2000/4);
fread(&p->buff[0], 0x2000, 1, fp); fread(&p->buff[0], 0x2000, 1, fp);
@ -741,12 +744,14 @@ EXPORT_C_(void) GSReplay(char* lpszCmdLine)
{ {
case 0: case 0:
//fprintf(stderr, "TRANSFER %d size %d\n", p->param, p->real_size);
switch(p->param) switch(p->param)
{ {
case 0: GSgifTransfer1(&p->buff[0], p->addr); break; //case 0: GSgifTransfer1((u32*)&p->buff[0], p->addr); break;
case 1: GSgifTransfer2(&p->buff[0], p->size / 16); break; case 0: _GSgifTransfer<0>(&p->buff[0], p->real_size); break;
case 2: GSgifTransfer3(&p->buff[0], p->size / 16); break; case 1: GSgifTransfer2((u32*)&p->buff[0], p->real_size); break;
case 3: GSgifTransfer(&p->buff[0], p->size / 16); break; case 2: GSgifTransfer3((u32*)&p->buff[0], p->real_size); break;
case 3: GSgifTransfer((u32*)&p->buff[0], p->real_size); break;
} }
break; break;
@ -775,8 +780,8 @@ EXPORT_C_(void) GSReplay(char* lpszCmdLine)
} }
} }
unsigned long end = timeGetTime(); unsigned long end = timeGetTime();
fprintf(stderr, "The %d frames of the scene was render on %dms\n", frame_number, end - start); fprintf(stderr, "The %ld frames of the scene was render on %ldms\n", frame_number, end - start);
fprintf(stderr, "A means of %fms by frame\n", (float)(end - start)/(float)frame_number); fprintf(stderr, "A means of %fms by frame (limit 16ms/f)\n", (float)(end - start)/(float)frame_number);
sleep(1); sleep(1);
finished--; finished--;

View File

@ -76,8 +76,8 @@ template<int index> void _GSgifTransfer(const u32 *pMem, u32 size)
#ifdef _DEBUG #ifdef _DEBUG
gifTransferLog(index, pMem, size); gifTransferLog(index, pMem, size);
const u32* start = pMem;
g_dump.Transfer(index, (const u8*)pMem, size); u32 size_arg = size;
#endif #endif
while (size > 0) while (size > 0)
@ -218,6 +218,10 @@ template<int index> void _GSgifTransfer(const u32 *pMem, u32 size)
} }
} }
#ifdef _DEBUG
g_dump.Transfer(index, start, pMem - start, size_arg);
#endif
// This is the case when not all data was readed from one try: VU1 has too much data. // This is the case when not all data was readed from one try: VU1 has too much data.
// So we should redo reading from the start. // So we should redo reading from the start.
if (index == 0) if (index == 0)

View File

@ -20,7 +20,6 @@ set(CommonFlags
-fno-strict-aliasing -fno-strict-aliasing
-Wstrict-aliasing # Allow to track strict aliasing issue. -Wstrict-aliasing # Allow to track strict aliasing issue.
-Wunused-variable -Wunused-variable
#-DOGL4_LOG # Easier for development
) )
set(OptimizationFlags set(OptimizationFlags
@ -31,7 +30,7 @@ set(OptimizationFlags
# Debug - Build # Debug - Build
if(CMAKE_BUILD_TYPE STREQUAL Debug) if(CMAKE_BUILD_TYPE STREQUAL Debug)
# add defines # add defines
add_definitions(${CommonFlags} -g -Wall -D_DEBUG) add_definitions(${CommonFlags} -g -Wall -D_DEBUG)
endif(CMAKE_BUILD_TYPE STREQUAL Debug) endif(CMAKE_BUILD_TYPE STREQUAL Debug)
# Devel - Build # Devel - Build
@ -48,7 +47,8 @@ endif(CMAKE_BUILD_TYPE STREQUAL Release)
# Select the shader API # Select the shader API
if(GLSL_API) if(GLSL_API)
add_definitions(-DGLSL_API) add_definitions(-DGLSL_API -DGLSL4_API -DOGL4_LOG)
#add_definitions(-DGLSL_API)
else(GLSL_API) else(GLSL_API)
add_definitions(-DNVIDIA_CG_API) add_definitions(-DNVIDIA_CG_API)
endif(GLSL_API) endif(GLSL_API)
@ -87,6 +87,7 @@ set(zzoglSources
ZZoglSave.cpp ZZoglSave.cpp
ZZoglShaders.cpp ZZoglShaders.cpp
ZZoglShadersGLSL.cpp ZZoglShadersGLSL.cpp
ZZoglShadersGLSL4.cpp
ZZoglShoots.cpp ZZoglShoots.cpp
ZZoglVB.cpp ZZoglVB.cpp
) )
@ -190,7 +191,8 @@ endif(NOT USER_CMAKE_LD_FLAGS STREQUAL "")
if(PACKAGE_MODE) if(PACKAGE_MODE)
install(TARGETS ${Output} DESTINATION ${PLUGIN_DIR}) install(TARGETS ${Output} DESTINATION ${PLUGIN_DIR})
if(GLSL_API) if(GLSL_API)
install(FILES ${PROJECT_SOURCE_DIR}/plugins/zzogl-pg/opengl/ps2hw.glsl DESTINATION ${PLUGIN_DIR}) install(FILES ${PROJECT_SOURCE_DIR}/plugins/zzogl-pg/opengl/ps2hw.glsl DESTINATION ${GLSL_SHADER_DIR})
install(FILES ${PROJECT_SOURCE_DIR}/plugins/zzogl-pg/opengl/ps2hw_gl4.glsl DESTINATION ${GLSL_SHADER_DIR})
else(GLSL_API) else(GLSL_API)
if(NOT REBUILD_SHADER) if(NOT REBUILD_SHADER)
install(FILES ${PROJECT_SOURCE_DIR}/plugins/zzogl-pg/opengl/ps2hw.dat DESTINATION ${PLUGIN_DIR}) install(FILES ${PROJECT_SOURCE_DIR}/plugins/zzogl-pg/opengl/ps2hw.dat DESTINATION ${PLUGIN_DIR})
@ -200,6 +202,7 @@ else(PACKAGE_MODE)
install(TARGETS ${Output} DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) install(TARGETS ${Output} DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins)
if(GLSL_API) if(GLSL_API)
install(FILES ${PROJECT_SOURCE_DIR}/plugins/zzogl-pg/opengl/ps2hw.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) install(FILES ${PROJECT_SOURCE_DIR}/plugins/zzogl-pg/opengl/ps2hw.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins)
install(FILES ${PROJECT_SOURCE_DIR}/plugins/zzogl-pg/opengl/ps2hw_gl4.glsl DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins)
else(GLSL_API) else(GLSL_API)
if(NOT REBUILD_SHADER) if(NOT REBUILD_SHADER)
install(FILES ${PROJECT_SOURCE_DIR}/plugins/zzogl-pg/opengl/ps2hw.dat DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins) install(FILES ${PROJECT_SOURCE_DIR}/plugins/zzogl-pg/opengl/ps2hw.dat DESTINATION ${CMAKE_SOURCE_DIR}/bin/plugins)

View File

@ -228,9 +228,9 @@ bool GLWindow::CreateContextGL(int major, int minor)
void GLWindow::CreateContextGL() void GLWindow::CreateContextGL()
{ {
#ifdef OGL4_LOG #if defined(OGL4_LOG) || defined(GLSL4_API)
// We need to define a debug context. So we need at a 3.0 context (if not 3.2) // We need to define a debug context. So we need at a 3.0 context (if not 3.2 actually)
CreateContextGL(4, 1); CreateContextGL(3, 3);
#else #else
// FIXME there was some issue with previous context creation on Geforce7. Code was rewritten // FIXME there was some issue with previous context creation on Geforce7. Code was rewritten
// for GSdx unfortunately it was not tested on Geforce7 so keep the 2.0 context for now. // for GSdx unfortunately it was not tested on Geforce7 so keep the 2.0 context for now.

View File

@ -26,6 +26,7 @@
#include "Util.h" #include "Util.h"
#include "GifTransfer.h" #include "GifTransfer.h"
#include "HostMemory.h" #include "HostMemory.h"
#include "ZZoglShoots.h"
using namespace std; using namespace std;
@ -39,7 +40,7 @@ extern float fFPS;
extern int g_LastCRC; extern int g_LastCRC;
#define VB_NUMBUFFERS 512 // number of vbo buffer allocated #define VB_NUMBUFFERS 128 // number of vbo buffer allocated
struct Vector_16F struct Vector_16F
{ {
@ -422,7 +423,7 @@ union tex_0_info
#define TEX_HIGHLIGHT 2 #define TEX_HIGHLIGHT 2
#define TEX_HIGHLIGHT2 3 #define TEX_HIGHLIGHT2 3
bool SaveTexture(const char* filename, u32 textarget, u32 tex, int width, int height); //bool SaveTexture(const char* filename, u32 textarget, u32 tex, int width, int height, int ext_format = 0);
extern void SaveTex(tex0Info* ptex, int usevid); extern void SaveTex(tex0Info* ptex, int usevid);
extern char* NamedSaveTex(tex0Info* ptex, int usevid); extern char* NamedSaveTex(tex0Info* ptex, int usevid);

View File

@ -58,13 +58,14 @@ void GSDump::Close()
} }
} }
void GSDump::Transfer(int index, const u8* mem, size_t size) void GSDump::Transfer(int index, const u32* mem, size_t size, u32 real_size)
{ {
if(m_gs && size > 0) if(m_gs && size > 0)
{ {
fputc(0, m_gs); fputc(0, m_gs);
fputc(index, m_gs); fputc(index, m_gs);
fwrite(&size, 4, 1, m_gs); fwrite(&size, 4, 1, m_gs);
fwrite(&real_size, 4, 1, m_gs);
fwrite(mem, size, 1, m_gs); fwrite(mem, size, 1, m_gs);
} }
} }

View File

@ -56,7 +56,7 @@ public:
void Open(const string& fn, u32 crc, const freezeData& fd, u8* regs); void Open(const string& fn, u32 crc, const freezeData& fd, u8* regs);
void Close(); void Close();
void ReadFIFO(u32 size); void ReadFIFO(u32 size);
void Transfer(int index, const u8* mem, size_t size); void Transfer(int index, const u32* mem, size_t size, u32 real_size);
void VSync(int field, bool last, u8* regs); void VSync(int field, bool last, u8* regs);
operator bool() {return m_gs != NULL;} operator bool() {return m_gs != NULL;}
}; };

View File

@ -0,0 +1,71 @@
/*
* Copyright (C) 2011-2011 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, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
// Note: it is same code that was developed for GSdx plugin
#pragma once
#ifdef GLSL4_API
class GSUniformBufferOGL {
GLuint buffer; // data object
GLuint index; // GLSL slot
uint size; // size of the data
const GLenum target;
public:
GSUniformBufferOGL(GLuint index, uint size) : index(index)
, size(size)
,target(GL_UNIFORM_BUFFER)
{
glGenBuffers(1, &buffer);
bind();
allocate();
attach();
}
void bind()
{
glBindBuffer(target, buffer);
}
void allocate()
{
glBufferData(target, size, NULL, GL_STREAM_DRAW);
}
void attach()
{
glBindBufferBase(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);
}
~GSUniformBufferOGL() {
glDeleteBuffers(1, &buffer);
}
};
#endif

View File

@ -0,0 +1,283 @@
/*
* Copyright (C) 2011-2011 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, 675 Mass Ave, Cambridge, MA 02139, USA.
* http://www.gnu.org/copyleft/gpl.html
*
*/
// Note: it is same code that was developed for GSdx plugin
#pragma once
#ifdef GLSL4_API
struct GSInputLayoutOGL {
GLuint index;
GLint size;
GLenum type;
GLboolean normalize;
GLsizei stride;
const GLvoid* offset;
};
class GSBufferOGL {
size_t m_stride;
size_t m_start;
size_t m_count;
size_t m_limit;
GLenum m_target;
GLuint m_buffer;
size_t m_default_size;
public:
GSBufferOGL(GLenum target, size_t stride) :
m_stride(stride)
, m_start(0)
, m_count(0)
, m_limit(0)
, m_target(target)
{
glGenBuffers(1, &m_buffer);
// Opengl works best with 1-4MB buffer.
m_default_size = 2 * 1024 * 1024 / m_stride;
}
~GSBufferOGL() { glDeleteBuffers(1, &m_buffer); }
void allocate() { allocate(m_default_size); }
void allocate(size_t new_limit)
{
m_start = 0;
m_limit = new_limit;
glBufferData(m_target, m_limit * m_stride, NULL, GL_STREAM_DRAW);
}
void bind()
{
glBindBuffer(m_target, m_buffer);
}
void upload(const void* src, uint32 count)
{
// Upload the data to the buffer
void* dst;
if (Map(&dst, count)) {
// FIXME which one to use
// GSVector4i::storent(dst, src, m_count * m_stride);
memcpy(dst, src, m_stride*m_count);
Unmap();
}
}
bool Map(void** pointer, uint32 count ) {
#ifdef OGL_DEBUG
GLint b_size = -1;
glGetBufferParameteriv(m_target, GL_BUFFER_SIZE, &b_size);
if (b_size <= 0) return false;
#endif
m_count = count;
// Note: For an explanation of the map flag
// see http://www.opengl.org/wiki/Buffer_Object_Streaming
uint32 map_flags = GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT;
// Current GPU buffer is really too small need to allocate a new one
if (m_count > m_limit) {
allocate(std::max<int>(m_count * 3 / 2, m_default_size));
} else if (m_count > (m_limit - m_start) ) {
// Not enough left free room. Just go back at the beginning
m_start = 0;
// Tell the driver that it can orphan previous buffer and restart from a scratch buffer.
// Technically the buffer will not be accessible by the application anymore but the
// GL will effectively remove it when draws call are finised.
map_flags |= GL_MAP_INVALIDATE_BUFFER_BIT;
} else {
// Tell the driver that it doesn't need to contain any valid buffer data, and that you promise to write the entire range you map
map_flags |= GL_MAP_INVALIDATE_RANGE_BIT;
}
// Upload the data to the buffer
*pointer = (uint8*) glMapBufferRange(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
if (*pointer == NULL) {
fprintf(stderr, "CRITICAL ERROR map failed for vb!!!\n");
return false;
}
#endif
return true;
}
void Unmap() { glUnmapBuffer(m_target); }
void EndScene()
{
m_start += m_count;
m_count = 0;
}
void Draw(GLenum mode)
{
glDrawArrays(mode, m_start, m_count);
}
void Draw(GLenum mode, GLint basevertex)
{
glDrawElementsBaseVertex(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);
}
size_t GetStart() { return m_start; }
void debug()
{
fprintf(stderr, "data buffer: start %d, count %d\n", m_start, m_count);
}
};
class GSVertexBufferStateOGL {
GSBufferOGL *m_vb;
GSBufferOGL *m_ib;
GLuint m_va;
GLenum m_topology;
// DEBUG
vector<GSInputLayoutOGL> layout_store;
public:
GSVertexBufferStateOGL(size_t stride, GSInputLayoutOGL* layout, uint32 layout_nbr)
{
glGenVertexArrays(1, &m_va);
layout_store.clear();
m_vb = new GSBufferOGL(GL_ARRAY_BUFFER, stride);
m_ib = new GSBufferOGL(GL_ELEMENT_ARRAY_BUFFER, sizeof(uint32));
bind();
// Note: index array are part of the VA state so it need to be bind only once.
m_ib->bind();
m_vb->allocate();
m_ib->allocate();
set_internal_format(layout, layout_nbr);
}
void bind()
{
glBindVertexArray(m_va);
m_vb->bind();
}
void set_internal_format()
{
for (vector<GSInputLayoutOGL>::iterator it = layout_store.begin(); it != layout_store.end(); it++)
set_internal_format(*it);
}
void set_internal_format(GSInputLayoutOGL& layout) {
// Note this function need both a vertex array object and a GL_ARRAY_BUFFER buffer
glEnableVertexAttribArray(layout.index);
switch (layout.type) {
case GL_UNSIGNED_SHORT:
case GL_UNSIGNED_INT:
case GL_SHORT:
case GL_INT:
// Rule: when shader use integral (not normalized) you must use glVertexAttribIPointer (note the extra I)
if (layout.normalize == false)
glVertexAttribIPointer(layout.index, layout.size, layout.type, layout.stride, layout.offset);
else
glVertexAttribPointer(layout.index, layout.size, layout.type, layout.normalize, layout.stride, layout.offset);
break;
default:
glVertexAttribPointer(layout.index, layout.size, layout.type, layout.normalize, layout.stride, layout.offset);
break;
}
}
void set_internal_format(GSInputLayoutOGL* layout, uint32 layout_nbr)
{
for (uint i = 0; i < layout_nbr; i++) {
// DEBUG
layout_store.push_back(layout[i]);
set_internal_format(layout[i]);
}
}
void EndScene()
{
m_vb->EndScene();
m_ib->EndScene();
}
void DrawPrimitive() { m_vb->Draw(m_topology); }
void DrawIndexedPrimitive() { m_ib->Draw(m_topology, m_vb->GetStart() ); }
void DrawIndexedPrimitive(int offset, int count) { m_ib->Draw(m_topology, m_vb->GetStart(), offset, count ); }
void SetTopology(GLenum topology) { m_topology = topology; }
void UploadVB(const void* vertices, size_t count) { m_vb->upload(vertices, count); }
void UploadIB(const void* index, size_t count) { m_ib->upload(index, count); }
bool MapVB(void **pointer, size_t count) { return m_vb->Map(pointer, count); }
void UnmapVB() { m_vb->Unmap(); }
~GSVertexBufferStateOGL()
{
glDeleteVertexArrays(1, &m_va);
delete m_vb;
delete m_ib;
}
void debug()
{
string topo;
switch (m_topology) {
case GL_POINTS:
topo = "point";
break;
case GL_LINES:
topo = "line";
break;
case GL_TRIANGLES:
topo = "triangle";
break;
case GL_TRIANGLE_STRIP:
topo = "triangle strip";
break;
}
m_vb->debug();
m_ib->debug();
fprintf(stderr, "primitives of %s\n", topo.c_str());
}
};
#endif

View File

@ -403,7 +403,7 @@ static bool get_snapshot_filename(char *filename, char* path, const char* extens
{ {
snapshotnr++; snapshotnr++;
sprintf(filename, "%s/snap%03ld.%s", path, snapshotnr, extension); sprintf(filename, "%s/snap%03d.%s", path, snapshotnr, extension);
bmpfile = fopen(filename, "rb"); bmpfile = fopen(filename, "rb");
@ -641,6 +641,7 @@ struct Packet
{ {
u8 type, param; u8 type, param;
u32 size, addr; u32 size, addr;
u32 real_size;
vector<u32> buff; vector<u32> buff;
}; };
@ -694,18 +695,20 @@ EXPORT_C_(void) GSReplay(char* lpszCmdLine)
p->param = (u8)fgetc(fp); p->param = (u8)fgetc(fp);
fread(&p->size, 4, 1, fp); fread(&p->size, 4, 1, fp);
fread(&p->real_size, 4, 1, fp);
switch(p->param) switch(p->param)
{ {
case 0: case 0:
p->buff.resize(0x4000); p->buff.resize(0x4000/4);
p->addr = 0x4000 - p->size; //p->addr = 0x4000 - p->size;
fread(&p->buff[p->addr], p->size, 1, fp); //fread(&p->buff[p->addr], p->size, 1, fp);
fread(&p->buff[0], p->size, 1, fp);
break; break;
case 1: case 1:
case 2: case 2:
case 3: case 3:
p->buff.resize(p->size); p->buff.resize(p->size/4);
fread(&p->buff[0], p->size, 1, fp); fread(&p->buff[0], p->size, 1, fp);
break; break;
} }
@ -726,7 +729,7 @@ EXPORT_C_(void) GSReplay(char* lpszCmdLine)
case 3: case 3:
p->buff.resize(0x2000); p->buff.resize(0x2000/4);
fread(&p->buff[0], 0x2000, 1, fp); fread(&p->buff[0], 0x2000, 1, fp);
@ -755,12 +758,14 @@ EXPORT_C_(void) GSReplay(char* lpszCmdLine)
{ {
case 0: case 0:
//fprintf(stderr, "TRANSFER %d size %d\n", p->param, p->real_size);
switch(p->param) switch(p->param)
{ {
case 0: GSgifTransfer1(&p->buff[0], p->addr); break; //case 0: GSgifTransfer1((u32*)&p->buff[0], p->addr); break;
case 1: GSgifTransfer2(&p->buff[0], p->size / 16); break; case 0: _GSgifTransfer<0>(&p->buff[0], p->real_size); break;
case 2: GSgifTransfer3(&p->buff[0], p->size / 16); break; case 1: GSgifTransfer2((u32*)&p->buff[0], p->real_size); break;
case 3: GSgifTransfer(&p->buff[0], p->size / 16); break; case 2: GSgifTransfer3((u32*)&p->buff[0], p->real_size); break;
case 3: GSgifTransfer((u32*)&p->buff[0], p->real_size); break;
} }
break; break;
@ -789,8 +794,8 @@ EXPORT_C_(void) GSReplay(char* lpszCmdLine)
} }
} }
unsigned long end = timeGetTime(); unsigned long end = timeGetTime();
fprintf(stderr, "The %d frames of the scene was render on %dms\n", frame_number, end - start); fprintf(stderr, "The %ld frames of the scene was render on %ldms\n", frame_number, end - start);
fprintf(stderr, "A means of %fms by frame\n", (float)(end - start)/(float)frame_number); fprintf(stderr, "A means of %fms by frame (limit 16ms/f)\n", (float)(end - start)/(float)frame_number);
sleep(1); sleep(1);
finished--; finished--;

View File

@ -76,8 +76,8 @@ template<int index> void _GSgifTransfer(const u32 *pMem, u32 size)
#ifdef _DEBUG #ifdef _DEBUG
gifTransferLog(index, pMem, size); gifTransferLog(index, pMem, size);
const u32* start = pMem;
g_dump.Transfer(index, (const u8*)pMem, size); u32 size_arg = size;
#endif #endif
while (size > 0) while (size > 0)
@ -222,6 +222,10 @@ template<int index> void _GSgifTransfer(const u32 *pMem, u32 size)
} }
} }
#ifdef _DEBUG
g_dump.Transfer(index, start, pMem - start, size_arg);
#endif
// This is the case when not all data was readed from one try: VU1 has too much data. // This is the case when not all data was readed from one try: VU1 has too much data.
// So we should redo reading from the start. // So we should redo reading from the start.
if (index == 0) if (index == 0)

View File

@ -72,6 +72,16 @@ extern "C" u32 CALLBACK PS2EgetLibVersion2(u32 type);
extern "C" char* CALLBACK PS2EgetLibName(void); extern "C" char* CALLBACK PS2EgetLibName(void);
#endif #endif
// Allow easy copy/past between GSdx and zzogl
typedef unsigned char uint8;
typedef signed char int8;
typedef unsigned short uint16;
typedef signed short int16;
typedef unsigned int uint32;
typedef signed int int32;
typedef unsigned long long uint64;
typedef signed long long int64;
#include "ZZoglMath.h" #include "ZZoglMath.h"
#include "Profile.h" #include "Profile.h"
#include "GSDump.h" #include "GSDump.h"
@ -81,6 +91,37 @@ extern "C" char* CALLBACK PS2EgetLibName(void);
extern wxString s_strIniPath; // Air's new (r2361) new constant for ini file path extern wxString s_strIniPath; // Air's new (r2361) new constant for ini file path
static std::string format(const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
int result = -1, length = 256;
char* buffer = NULL;
while(result == -1)
{
if(buffer) delete [] buffer;
buffer = new char[length + 1];
memset(buffer, 0, length + 1);
result = vsnprintf(buffer, length, fmt, args);
length *= 2;
}
va_end(args);
std::string s(buffer);
delete [] buffer;
return s;
}
typedef struct typedef struct
{ {
int x, y, w, h; int x, y, w, h;

View File

@ -142,6 +142,7 @@
<ClCompile Include="..\ZZoglFlushHack.cpp" /> <ClCompile Include="..\ZZoglFlushHack.cpp" />
<ClCompile Include="..\ZZoglMem.cpp" /> <ClCompile Include="..\ZZoglMem.cpp" />
<ClCompile Include="..\ZZoglShadersGLSL.cpp" /> <ClCompile Include="..\ZZoglShadersGLSL.cpp" />
<ClCompile Include="..\ZZoglShadersGLSL4.cpp" />
<ClCompile Include="..\ZZRenderTargets.cpp" /> <ClCompile Include="..\ZZRenderTargets.cpp" />
<ClCompile Include="Conf.cpp" /> <ClCompile Include="Conf.cpp" />
<ClCompile Include="..\GifTransfer.cpp" /> <ClCompile Include="..\GifTransfer.cpp" />

View File

@ -129,6 +129,9 @@
<ClCompile Include="..\ZZoglShadersGLSL.cpp"> <ClCompile Include="..\ZZoglShadersGLSL.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\ZZoglShadersGLSL4.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="GSsoftdx.def"> <None Include="GSsoftdx.def">

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="windows-1253"?> <?xml version="1.0" encoding="windows-1253"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="9.00" Version="9,00"
Name="ZZOgl" Name="ZZOgl"
ProjectGUID="{2D4E85B2-F47F-4D65-B091-701E5C031DAC}" ProjectGUID="{2D4E85B2-F47F-4D65-B091-701E5C031DAC}"
RootNamespace="ZZogl" RootNamespace="ZZogl"
@ -412,6 +412,10 @@
RelativePath="..\ZZoglShadersGLSL.cpp" RelativePath="..\ZZoglShadersGLSL.cpp"
> >
</File> </File>
<File
RelativePath="..\ZZoglShadersGLSL4.cpp"
>
</File>
<File <File
RelativePath="..\ZZoglShoots.cpp" RelativePath="..\ZZoglShoots.cpp"
> >
@ -608,11 +612,11 @@
</File> </File>
</Filter> </Filter>
<File <File
RelativePath="..\ps2hw.dat" RelativePath=".\ps2hw.dat"
> >
</File> </File>
<File <File
RelativePath=".\ps2hw.dat" RelativePath="..\ps2hw.dat"
> >
</File> </File>
</Files> </Files>

View File

@ -84,13 +84,20 @@ static __forceinline void GL_STENCILFUNC_SET()
glStencilFunc(s_stencilfunc, s_stencilref, s_stencilmask); glStencilFunc(s_stencilfunc, s_stencilref, s_stencilmask);
} }
#ifdef GLSL4_API
#include "ZZoglShaders.h"
#endif
// sets the data stream // sets the data stream
static __forceinline void SET_STREAM() static __forceinline void SET_STREAM()
{ {
#ifndef GLSL4_API
glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(VertexGPU), (void*)8); glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(VertexGPU), (void*)8);
glSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, sizeof(VertexGPU), (void*)12); glSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, sizeof(VertexGPU), (void*)12);
glTexCoordPointer(3, GL_FLOAT, sizeof(VertexGPU), (void*)16); glTexCoordPointer(3, GL_FLOAT, sizeof(VertexGPU), (void*)16);
glVertexPointer(4, GL_SHORT, sizeof(VertexGPU), (void*)0); glVertexPointer(4, GL_SHORT, sizeof(VertexGPU), (void*)0);
#else
vertex_array->set_internal_format();
#endif
} }
// global alpha blending settings // global alpha blending settings
@ -149,8 +156,14 @@ extern PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC glGetFramebufferAttachmen
extern PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT; extern PFNGLGENERATEMIPMAPEXTPROC glGenerateMipmapEXT;
extern PFNGLDRAWBUFFERSPROC glDrawBuffers; extern PFNGLDRAWBUFFERSPROC glDrawBuffers;
#ifdef GLSL4_API
#include "ZZoglShaders.h"
#endif
static __forceinline void DrawTriangleArray() static __forceinline void DrawTriangleArray()
{ {
#ifdef GLSL4_API
ZZshSetupShader();
#endif
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
GL_REPORT_ERRORD(); GL_REPORT_ERRORD();
} }

View File

@ -881,10 +881,10 @@ void RenderCRTC()
tex0Info& texframe = dispinfo[i]; tex0Info& texframe = dispinfo[i];
// I don't think this is neccessary, now that we make sure the ciruit we are working with is enabled. // I don't think this is neccessary, now that we make sure the ciruit we are working with is enabled.
/*if (texframe.th <= 1) //
{ // Actually it seems there are still empty frame in some games (persona 4 and tales of abyss). I'm not sure it
continue; // is normal, for the moment keep the check to avoid some undefined behavior. -- Gregory
}*/ if (texframe.th <= 1) continue;
if (SMODE2->INT && SMODE2->FFMD) if (SMODE2->INT && SMODE2->FFMD)
{ {

View File

@ -40,9 +40,7 @@ typedef void (APIENTRYP _PFNSWAPINTERVAL)(int);
map<string, GLbyte> mapGLExtensions; map<string, GLbyte> mapGLExtensions;
extern bool LoadEffects();
extern bool ZZshLoadExtraEffects(); extern bool ZZshLoadExtraEffects();
extern FRAGMENTSHADER* ZZshLoadShadeEffect(int type, int texfilter, int fog, int testaem, int exactcolor, const clampInfo& clamp, int context, bool* pbFailed);
GLuint vboRect = 0; GLuint vboRect = 0;
GLuint g_vboBuffers[VB_NUMBUFFERS]; // VBOs for all drawing commands GLuint g_vboBuffers[VB_NUMBUFFERS]; // VBOs for all drawing commands
@ -574,6 +572,18 @@ bool ZZCreate(int _width, int _height)
GL_REPORT_ERROR(); GL_REPORT_ERROR();
#ifdef GLSL4_API
GSInputLayoutOGL vert_format[] =
{
{0 , 2 , GL_SHORT , GL_FALSE , sizeof(VertexGPU) , (const GLvoid*)(0) } , // vertex
{1 , 4 , GL_UNSIGNED_BYTE , GL_TRUE , sizeof(VertexGPU) , (const GLvoid*)(8) } , // color
{2 , 4 , GL_UNSIGNED_BYTE , GL_TRUE , sizeof(VertexGPU) , (const GLvoid*)(12) } , // z value. FIXME WTF 4 unsigned byte, why not a full integer
{3 , 3 , GL_FLOAT , GL_FALSE , sizeof(VertexGPU) , (const GLvoid*)(16) } , // tex coord
};
vertex_array = new GSVertexBufferStateOGL(sizeof(VertexGPU), vert_format, 4);
#endif
g_nCurVBOIndex = 0; g_nCurVBOIndex = 0;
if (!vb_buffer_allocated) { if (!vb_buffer_allocated) {
@ -582,6 +592,9 @@ bool ZZCreate(int _width, int _height)
{ {
glBindBuffer(GL_ARRAY_BUFFER, g_vboBuffers[i]); glBindBuffer(GL_ARRAY_BUFFER, g_vboBuffers[i]);
glBufferData(GL_ARRAY_BUFFER, 0x100*sizeof(VertexGPU), NULL, GL_STREAM_DRAW); glBufferData(GL_ARRAY_BUFFER, 0x100*sizeof(VertexGPU), NULL, GL_STREAM_DRAW);
#ifdef GLSL4_API
vertex_array->set_internal_format();
#endif
} }
vb_buffer_allocated = true; // mark the buffer allocated vb_buffer_allocated = true; // mark the buffer allocated
} }
@ -663,6 +676,9 @@ bool ZZCreate(int _width, int _height)
// fill a simple rect // fill a simple rect
glGenBuffers(1, &vboRect); glGenBuffers(1, &vboRect);
glBindBuffer(GL_ARRAY_BUFFER, vboRect); glBindBuffer(GL_ARRAY_BUFFER, vboRect);
#ifdef GLSL4_API
vertex_array->set_internal_format();
#endif
vector<VertexGPU> verts(4); vector<VertexGPU> verts(4);
@ -682,6 +698,7 @@ bool ZZCreate(int _width, int _height)
glBufferDataARB(GL_ARRAY_BUFFER, 4*sizeof(VertexGPU), &verts[0], GL_STATIC_DRAW); glBufferDataARB(GL_ARRAY_BUFFER, 4*sizeof(VertexGPU), &verts[0], GL_STATIC_DRAW);
#ifndef GLSL4_API
// setup the default vertex declaration // setup the default vertex declaration
glEnableClientState(GL_VERTEX_ARRAY); glEnableClientState(GL_VERTEX_ARRAY);
glClientActiveTexture(GL_TEXTURE0); glClientActiveTexture(GL_TEXTURE0);
@ -689,6 +706,7 @@ bool ZZCreate(int _width, int _height)
glEnableClientState(GL_SECONDARY_COLOR_ARRAY); glEnableClientState(GL_SECONDARY_COLOR_ARRAY);
glEnableClientState(GL_COLOR_ARRAY); glEnableClientState(GL_COLOR_ARRAY);
GL_REPORT_ERROR(); GL_REPORT_ERROR();
#endif
// some cards don't support this // some cards don't support this
// glClientActiveTexture(GL_TEXTURE0); // glClientActiveTexture(GL_TEXTURE0);
@ -815,6 +833,10 @@ void ZZDestroy()
vb_buffer_allocated = false; // mark the buffer unallocated vb_buffer_allocated = false; // mark the buffer unallocated
} }
#ifdef GLSL4_API
delete vertex_array;
#endif
g_nCurVBOIndex = 0; g_nCurVBOIndex = 0;
if (pvs != NULL) if (pvs != NULL)

View File

@ -145,7 +145,7 @@ void Kick::DrawPrim(u32 prim_type)
break; break;
case PRIM_LINE_STRIP: case PRIM_LINE_STRIP:
if (likely(ValidPrevPrim)) { if (likely(ValidPrevPrim) && curvb.nCount != 0) {
assert(curvb.nCount >= 1); assert(curvb.nCount >= 1);
p[0] = p[-1]; p[0] = p[-1];
} else { } else {
@ -165,7 +165,7 @@ void Kick::DrawPrim(u32 prim_type)
break; break;
case PRIM_TRIANGLE_STRIP: case PRIM_TRIANGLE_STRIP:
if (likely(ValidPrevPrim)) { if (likely(ValidPrevPrim) && curvb.nCount != 0) {
assert(curvb.nCount >= 2); assert(curvb.nCount >= 2);
p[0] = p[-2]; p[0] = p[-2];
p[1] = p[-1]; p[1] = p[-1];
@ -180,7 +180,7 @@ void Kick::DrawPrim(u32 prim_type)
break; break;
case PRIM_TRIANGLE_FAN: case PRIM_TRIANGLE_FAN:
if (likely(ValidPrevPrim)) { if (likely(ValidPrevPrim) && curvb.nCount != 0) {
assert(curvb.nCount >= 2); assert(curvb.nCount >= 2);
VertexGPU* TriFanVert = curvb.pBufferData + gs.nTriFanVert; VertexGPU* TriFanVert = curvb.pBufferData + gs.nTriFanVert;
p[0] = TriFanVert[0]; p[0] = TriFanVert[0];

View File

@ -51,7 +51,7 @@ class Kick
void Output_Vertex(VertexGPU vert, u32 id); void Output_Vertex(VertexGPU vert, u32 id);
bool ValidPrevPrim; bool ValidPrevPrim;
public: public:
Kick() { } Kick() : ValidPrevPrim(false) { }
~Kick() { } ~Kick() { }
void KickVertex(bool adc); void KickVertex(bool adc);

View File

@ -89,6 +89,9 @@ int icurctx = -1;
void Draw(const VB& curvb) void Draw(const VB& curvb)
{ {
#ifdef GLSL4_API
ZZshSetupShader();
#endif
glDrawArrays(primtype[curvb.curprim.prim], 0, curvb.nCount); glDrawArrays(primtype[curvb.curprim.prim], 0, curvb.nCount);
} }
@ -688,7 +691,7 @@ inline float4 FlushSetPageOffset(FRAGMENTSHADER* pfragment, int shadertype, CRen
// zoe2 // zoe2
if (PSMT_ISZTEX(ptextarg->psm)) vpageoffset.w = -1.0f; if (PSMT_ISZTEX(ptextarg->psm)) vpageoffset.w = -1.0f;
ZZshSetParameter4fv(pfragment->fPageOffset, vpageoffset, "g_fPageOffset"); ZZshSetParameter4fv(pfragment->prog, pfragment->fPageOffset, vpageoffset, "g_fPageOffset");
return vpageoffset; return vpageoffset;
} }
@ -706,7 +709,7 @@ inline float4 FlushSetTexOffset(FRAGMENTSHADER* pfragment, int shadertype, VB& c
v.y = 16.0f / (float)curvb.tex0.th; v.y = 16.0f / (float)curvb.tex0.th;
v.z = 0.5f * v.x; v.z = 0.5f * v.x;
v.w = 0.5f * v.y; v.w = 0.5f * v.y;
ZZshSetParameter4fv(pfragment->fTexOffset, v, "g_fTexOffset"); ZZshSetParameter4fv(pfragment->prog, pfragment->fTexOffset, v, "g_fTexOffset");
} }
else if (shadertype == 4) else if (shadertype == 4)
{ {
@ -715,7 +718,7 @@ inline float4 FlushSetTexOffset(FRAGMENTSHADER* pfragment, int shadertype, VB& c
v.y = 16.0f / (float)ptextarg->fbh; v.y = 16.0f / (float)ptextarg->fbh;
v.z = -1; v.z = -1;
v.w = 8.0f / (float)ptextarg->fbh; v.w = 8.0f / (float)ptextarg->fbh;
ZZshSetParameter4fv(pfragment->fTexOffset, v, "g_fTexOffset"); ZZshSetParameter4fv(pfragment->prog, pfragment->fTexOffset, v, "g_fTexOffset");
} }
return v; return v;
@ -749,7 +752,7 @@ inline float4 FlushTextureDims(FRAGMENTSHADER* pfragment, int shadertype, VB& cu
if (shadertype == 4) if (shadertype == 4)
vTexDims.z += 8.0f; vTexDims.z += 8.0f;
ZZshSetParameter4fv(pfragment->fTexDims, vTexDims, "g_fTexDims"); ZZshSetParameter4fv(pfragment->prog, pfragment->fTexDims, vTexDims, "g_fTexDims");
return vTexDims; return vTexDims;
} }
@ -799,7 +802,7 @@ inline FRAGMENTSHADER* FlushUseExistRenderTarget(VB& curvb, CRenderTarget* ptext
float4 vTexDims = FlushTextureDims(pfragment, shadertype, curvb, ptextarg); float4 vTexDims = FlushTextureDims(pfragment, shadertype, curvb, ptextarg);
if (pfragment->sCLUT != NULL && ptexclut != 0) if (pfragment->sCLUT != NULL && ptexclut != 0)
ZZshGLSetTextureParameter(pfragment->sCLUT, ptexclut, "CLUT"); ZZshGLSetTextureParameter(pfragment->prog, pfragment->sCLUT, ptexclut, "CLUT");
FlushApplyResizeFilter(curvb, dwFilterOpts, ptextarg, context); FlushApplyResizeFilter(curvb, dwFilterOpts, ptextarg, context);
@ -846,13 +849,19 @@ inline void FlushSetTexture(VB& curvb, FRAGMENTSHADER* pfragment, CRenderTarget*
// have to enable the texture parameters(curtest.atst) // have to enable the texture parameters(curtest.atst)
if( curvb.ptexClamp[0] != 0 ) if( curvb.ptexClamp[0] != 0 )
ZZshGLSetTextureParameter(pfragment->sBitwiseANDX, curvb.ptexClamp[0], "Clamp 0"); ZZshGLSetTextureParameter(pfragment->prog, pfragment->sBitwiseANDX, curvb.ptexClamp[0], "Clamp 0");
if( curvb.ptexClamp[1] != 0 ) if( curvb.ptexClamp[1] != 0 )
ZZshGLSetTextureParameter(pfragment->sBitwiseANDY, curvb.ptexClamp[1], "Clamp 1"); ZZshGLSetTextureParameter(pfragment->prog, pfragment->sBitwiseANDY, curvb.ptexClamp[1], "Clamp 1");
// FIXME condition is a bit strange for GLSL
#ifdef GLSL4_API
if( s_ptexCurSet[context] != 0)
ZZshGLSetTextureParameter(pfragment->prog, pfragment->sMemory, s_ptexCurSet[context], "Clamp memory");
#else
if( pfragment->sMemory != NULL && s_ptexCurSet[context] != 0) if( pfragment->sMemory != NULL && s_ptexCurSet[context] != 0)
ZZshGLSetTextureParameter(pfragment->sMemory, s_ptexCurSet[context], "Clamp memory"); ZZshGLSetTextureParameter(pfragment->prog, pfragment->sMemory, s_ptexCurSet[context], "Clamp memory");
#endif
} }
// Reset program and texture variables; // Reset program and texture variables;
@ -975,7 +984,7 @@ inline void AlphaRenderFBA(VB& curvb, FRAGMENTSHADER* pfragment)
// needs to be before RenderAlphaTest // needs to be before RenderAlphaTest
if ((gs.pabe) || (curvb.fba.fba && !ZZOglGet_fbmHighByte(curvb.frame.fbm)) || (s_bDestAlphaTest && bCanRenderStencil)) if ((gs.pabe) || (curvb.fba.fba && !ZZOglGet_fbmHighByte(curvb.frame.fbm)) || (s_bDestAlphaTest && bCanRenderStencil))
{ {
RenderFBA(curvb, pfragment->sOneColor); RenderFBA(curvb, pfragment);
} }
} }
@ -990,7 +999,7 @@ inline u32 AlphaRenderAlpha(VB& curvb, const pixTest curtest, FRAGMENTSHADER* pf
if ((bNeedBlendFactorInAlpha || ((curtest.ate && curtest.atst > ATST_ALWAYS) && (curtest.aref > 0x80)))) if ((bNeedBlendFactorInAlpha || ((curtest.ate && curtest.atst > ATST_ALWAYS) && (curtest.aref > 0x80))))
{ {
// need special stencil processing for the alpha // need special stencil processing for the alpha
RenderAlphaTest(curvb, pfragment->sOneColor); RenderAlphaTest(curvb, pfragment);
dwUsingSpecialTesting = 1; dwUsingSpecialTesting = 1;
} }
@ -1003,13 +1012,13 @@ inline u32 AlphaRenderAlpha(VB& curvb, const pixTest curtest, FRAGMENTSHADER* pf
v.w *= 255; v.w *= 255;
} }
ZZshSetParameter4fv(pfragment->sOneColor, v, "g_fOneColor"); ZZshSetParameter4fv(pfragment->prog, pfragment->sOneColor, v, "g_fOneColor");
} }
else else
{ {
// not using blending so set to defaults // not using blending so set to defaults
float4 v = exactcolor ? float4(1, 510 * 255.0f / 256.0f, 0, 0) : float4(1, 2 * 255.0f / 256.0f, 0, 0); float4 v = exactcolor ? float4(1, 510 * 255.0f / 256.0f, 0, 0) : float4(1, 2 * 255.0f / 256.0f, 0, 0);
ZZshSetParameter4fv(pfragment->sOneColor, v, "g_fOneColor"); ZZshSetParameter4fv(pfragment->prog, pfragment->sOneColor, v, "g_fOneColor");
} }
@ -1100,7 +1109,7 @@ inline void AlphaPabe(VB& curvb, FRAGMENTSHADER* pfragment, int exactcolor)
if (exactcolor) v.y *= 255; if (exactcolor) v.y *= 255;
ZZshSetParameter4fv(pfragment->sOneColor, v, "g_fOneColor"); ZZshSetParameter4fv(pfragment->prog, pfragment->sOneColor, v, "g_fOneColor");
Draw(curvb); Draw(curvb);
@ -1169,7 +1178,7 @@ inline void AlphaFailureTestJob(VB& curvb, const pixTest curtest, FRAGMENTSHADE
if (exactcolor) { v.y *= 255; v.w *= 255; } if (exactcolor) { v.y *= 255; v.w *= 255; }
ZZshSetParameter4fv(pfragment->sOneColor, v, "g_fOneColor"); ZZshSetParameter4fv(pfragment->prog, pfragment->sOneColor, v, "g_fOneColor");
glEnable(GL_BLEND); glEnable(GL_BLEND);
GL_STENCILFUNC(GL_EQUAL, s_stencilref | STENCIL_FBA, s_stencilmask | STENCIL_FBA); GL_STENCILFUNC(GL_EQUAL, s_stencilref | STENCIL_FBA, s_stencilmask | STENCIL_FBA);
@ -1193,7 +1202,7 @@ inline void AlphaFailureTestJob(VB& curvb, const pixTest curtest, FRAGMENTSHADE
if (exactcolor) v.y *= 255; if (exactcolor) v.y *= 255;
ZZshSetParameter4fv(pfragment->sOneColor, v, "g_fOneColor"); ZZshSetParameter4fv(pfragment->prog, pfragment->sOneColor, v, "g_fOneColor");
Draw(curvb); Draw(curvb);
@ -1245,7 +1254,7 @@ inline void AlphaSpecialTesting(VB& curvb, FRAGMENTSHADER* pfragment, u32 dwUsin
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
float4 v = float4(0, exactcolor ? 510.0f : 2.0f, 0, 0); float4 v = float4(0, exactcolor ? 510.0f : 2.0f, 0, 0);
ZZshSetParameter4fv(pfragment->sOneColor, v, "g_fOneColor"); ZZshSetParameter4fv(pfragment->prog, pfragment->sOneColor, v, "g_fOneColor");
Draw(curvb); Draw(curvb);
// don't need to restore // don't need to restore
@ -1260,7 +1269,7 @@ inline void AlphaDestinationTest(VB& curvb, FRAGMENTSHADER* pfragment)
{ {
if (curvb.fba.fba) if (curvb.fba.fba)
{ {
ProcessFBA(curvb, pfragment->sOneColor); ProcessFBA(curvb, pfragment);
} }
else if (s_bDestAlphaTest && bCanRenderStencil) else if (s_bDestAlphaTest && bCanRenderStencil)
{ {
@ -1383,7 +1392,7 @@ void FlushIfNecesary(void* ptr)
if (vb[1].prndr == ptr || vb[1].pdepth == ptr) Flush(1); if (vb[1].prndr == ptr || vb[1].pdepth == ptr) Flush(1);
} }
inline void RenderFBA(const VB& curvb, ZZshParameter sOneColor) inline void RenderFBA(const VB& curvb, FRAGMENTSHADER* pfragment)
{ {
// add fba to all pixels // add fba to all pixels
GL_STENCILFUNC(GL_ALWAYS, STENCIL_FBA, 0xff); GL_STENCILFUNC(GL_ALWAYS, STENCIL_FBA, 0xff);
@ -1404,7 +1413,7 @@ inline void RenderFBA(const VB& curvb, ZZshParameter sOneColor)
float4 v(1,2,0,0); float4 v(1,2,0,0);
ZZshSetParameter4fv(sOneColor, v, "g_fOneColor"); ZZshSetParameter4fv(pfragment->prog, pfragment->sOneColor, v, "g_fOneColor");
Draw(curvb); Draw(curvb);
@ -1427,7 +1436,7 @@ inline void RenderFBA(const VB& curvb, ZZshParameter sOneColor)
GL_ZTEST(curvb.test.zte); GL_ZTEST(curvb.test.zte);
} }
__forceinline void RenderAlphaTest(const VB& curvb, ZZshParameter sOneColor) __forceinline void RenderAlphaTest(const VB& curvb, FRAGMENTSHADER* pfragment )
{ {
if (!g_bUpdateStencil) return; if (!g_bUpdateStencil) return;
@ -1443,7 +1452,7 @@ __forceinline void RenderAlphaTest(const VB& curvb, ZZshParameter sOneColor)
float4 v(1,2,0,0); float4 v(1,2,0,0);
ZZshSetParameter4fv(sOneColor, v, "g_fOneColor"); ZZshSetParameter4fv(pfragment->prog, pfragment->sOneColor, v, "g_fOneColor");
// or a 1 to the stencil buffer wherever alpha passes // or a 1 to the stencil buffer wherever alpha passes
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
@ -1467,7 +1476,7 @@ __forceinline void RenderAlphaTest(const VB& curvb, ZZshParameter sOneColor)
if (curvb.test.ate && curvb.test.atst > ATST_ALWAYS && curvb.test.aref > 0x80) if (curvb.test.ate && curvb.test.atst > ATST_ALWAYS && curvb.test.aref > 0x80)
{ {
v = float4(1,1,0,0); v = float4(1,1,0,0);
ZZshSetParameter4fv(sOneColor, v, "g_fOneColor"); ZZshSetParameter4fv(pfragment->prog, pfragment->sOneColor, v, "g_fOneColor");
glAlphaFunc(g_dwAlphaCmp[curvb.test.atst], AlphaReferedValue(curvb.test.aref)); glAlphaFunc(g_dwAlphaCmp[curvb.test.atst], AlphaReferedValue(curvb.test.aref));
} }
@ -1565,7 +1574,7 @@ inline void ProcessStencil(const VB& curvb)
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
} }
__forceinline void ProcessFBA(const VB& curvb, ZZshParameter sOneColor) __forceinline void ProcessFBA(const VB& curvb, FRAGMENTSHADER* pfragment )
{ {
if ((curvb.frame.fbm&0x80000000)) return; if ((curvb.frame.fbm&0x80000000)) return;
@ -1590,8 +1599,12 @@ __forceinline void ProcessFBA(const VB& curvb, ZZshParameter sOneColor)
GL_BLEND_ALPHA(GL_ONE, GL_ONE); GL_BLEND_ALPHA(GL_ONE, GL_ONE);
GL_BLENDEQ_ALPHA(GL_FUNC_ADD); GL_BLENDEQ_ALPHA(GL_FUNC_ADD);
float f = 1; // FIXME: Seem dangerous
ZZshSetParameter4fv(sOneColor, &f, "g_fOneColor"); // float f = 1;
// ZZshSetParameter4fv(pfragment->prog, pfragment->sOneColor, &f, "g_fOneColor");
float4 v = float4(1,1,0,0);
ZZshSetParameter4fv(pfragment->prog, pfragment->sOneColor, v, "g_fOneColor");
ZZshSetPixelShader(ppsOne.prog); ZZshSetPixelShader(ppsOne.prog);
Draw(curvb); Draw(curvb);
glDisable(GL_ALPHA_TEST); glDisable(GL_ALPHA_TEST);
@ -1840,11 +1853,10 @@ void SetTexClamping(int context, FRAGMENTSHADER* pfragment)
} }
if (pfragment->fTexWrapMode != 0) if (pfragment->fTexWrapMode != 0)
ZZshSetParameter4fv(pfragment->fTexWrapMode, v, "g_fTexWrapMode"); ZZshSetParameter4fv(pfragment->prog, pfragment->fTexWrapMode, v, "g_fTexWrapMode");
if (pfragment->fClampExts != 0) if (pfragment->fClampExts != 0)
ZZshSetParameter4fv(pfragment->fClampExts, v2, "g_fClampExts"); ZZshSetParameter4fv(pfragment->prog, pfragment->fClampExts, v2, "g_fClampExts");
} }
@ -1917,15 +1929,15 @@ void SetTexVariables(int context, FRAGMENTSHADER* pfragment)
valpha.z = (tex0.tfx == TFX_HIGHLIGHT2); valpha.z = (tex0.tfx == TFX_HIGHLIGHT2);
valpha.w = (tex0.tcc == 0) || (tex0.tcc == 1 && tex0.tfx == TFX_HIGHLIGHT); valpha.w = (tex0.tcc == 0) || (tex0.tcc == 1 && tex0.tfx == TFX_HIGHLIGHT);
ZZshSetParameter4fv(pfragment->fTexAlpha, valpha, "g_fTexAlpha"); ZZshSetParameter4fv(pfragment->prog, pfragment->fTexAlpha, valpha, "g_fTexAlpha");
ZZshSetParameter4fv(pfragment->fTexAlpha2, valpha2, "g_fTexAlpha2"); ZZshSetParameter4fv(pfragment->prog, pfragment->fTexAlpha2, valpha2, "g_fTexAlpha2");
if (IsAlphaTestExpansion(tex0)) if (IsAlphaTestExpansion(tex0))
{ {
float4 vblack; float4 vblack;
vblack.x = vblack.y = vblack.z = vblack.w = 10; vblack.x = vblack.y = vblack.z = vblack.w = 10;
if (tex0.tcc && gs.texa.aem && psm == PSMCT24) vblack.w = 0; if (tex0.tcc && gs.texa.aem && psm == PSMCT24) vblack.w = 0;
ZZshSetParameter4fv(pfragment->fTestBlack, vblack, "g_fTestBlack"); ZZshSetParameter4fv(pfragment->prog, pfragment->fTestBlack, vblack, "g_fTestBlack");
} }
SetTexClamping(context, pfragment); SetTexClamping(context, pfragment);
@ -2025,11 +2037,11 @@ void SetTexVariablesInt(int context, int bilinear, const tex0Info& tex0, bool Ch
v.z *= b.bpp * (1 / 32.0f); v.z *= b.bpp * (1 / 32.0f);
} }
ZZshSetParameter4fv(pfragment->fTexDims, vTexDims, "g_fTexDims"); ZZshSetParameter4fv(pfragment->prog, pfragment->fTexDims, vTexDims, "g_fTexDims");
// ZZshSetParameter4fv(pfragment->fTexBlock, b.vTexBlock, "g_fTexBlock"); // I change it, and it's working. Seems casting from float4 to float[4] is ok. // ZZshSetParameter4fv(pfragment->fTexBlock, b.vTexBlock, "g_fTexBlock"); // I change it, and it's working. Seems casting from float4 to float[4] is ok.
ZZshSetParameter4fv(pfragment->fTexBlock, &b.vTexBlock.x, "g_fTexBlock"); ZZshSetParameter4fv(pfragment->prog, pfragment->fTexBlock, &b.vTexBlock.x, "g_fTexBlock");
ZZshSetParameter4fv(pfragment->fTexOffset, v, "g_fTexOffset"); ZZshSetParameter4fv(pfragment->prog, pfragment->fTexOffset, v, "g_fTexOffset");
// get hardware texture dims // get hardware texture dims
//int texheight = pmemtarg->texH; //int texheight = pmemtarg->texH;
@ -2049,7 +2061,7 @@ void SetTexVariablesInt(int context, int bilinear, const tex0Info& tex0, bool Ch
v.w = 0.5f;*/ v.w = 0.5f;*/
v.w = 0.5f; v.w = 0.5f;
ZZshSetParameter4fv(pfragment->fPageOffset, v, "g_fPageOffset"); ZZshSetParameter4fv(pfragment->prog, pfragment->fPageOffset, v, "g_fPageOffset");
if (force) if (force)
s_ptexCurSet[context] = pmemtarg->ptex->tex; s_ptexCurSet[context] = pmemtarg->ptex->tex;

View File

@ -108,11 +108,11 @@ void SetAlphaVariables(const alphaInfo& ainfo); // zzz
inline void SetAlphaTestInt(pixTest curtest); inline void SetAlphaTestInt(pixTest curtest);
inline void RenderAlphaTest(const VB& curvb, ZZshParameter sOneColor); inline void RenderAlphaTest(const VB& curvb, FRAGMENTSHADER* pfragment);
inline void RenderStencil(const VB& curvb, u32 dwUsingSpecialTesting); inline void RenderStencil(const VB& curvb, u32 dwUsingSpecialTesting);
inline void ProcessStencil(const VB& curvb); inline void ProcessStencil(const VB& curvb);
inline void RenderFBA(const VB& curvb, ZZshParameter sOneColor); inline void RenderFBA(const VB& curvb, FRAGMENTSHADER* pfragment);
inline void ProcessFBA(const VB& curvb, ZZshParameter sOneColor); // zz inline void ProcessFBA(const VB& curvb, FRAGMENTSHADER* pfragment); // zz
void SetContextTarget(int context); void SetContextTarget(int context);

View File

@ -276,13 +276,13 @@ void ZZshSetParameter4fv(ZZshParameter param, const float* v, const char* name)
cgGLSetParameter4fv(param, v); cgGLSetParameter4fv(param, v);
} }
void ZZshSetParameter4fv(ZZshProgram prog, ZZshParameter param, const float* v, const char* name) { void ZZshSetParameter4fv(ZZshProgram& prog, ZZshParameter param, const float* v, const char* name) {
ShaderHandleName = name; ShaderHandleName = name;
cgGLSetParameter4fv(param, v); cgGLSetParameter4fv(param, v);
} }
// The same stuff, but also with retry of param, name should be USED name of param for prog. // The same stuff, but also with retry of param, name should be USED name of param for prog.
void ZZshSetParameter4fvWithRetry(ZZshParameter* param, ZZshProgram prog, const float* v, const char* name) { void ZZshSetParameter4fvWithRetry(ZZshParameter* param, ZZshProgram& prog, const float* v, const char* name) {
if (param != NULL) if (param != NULL)
ZZshSetParameter4fv(prog, param[0], v, name); ZZshSetParameter4fv(prog, param[0], v, name);
else else
@ -303,7 +303,7 @@ void ZZshGLSetTextureParameter(ZZshProgram prog, ZZshParameter param, GLuint tex
} }
// Used sometimes for color 1. // Used sometimes for color 1.
void ZZshDefaultOneColor( FRAGMENTSHADER ptr ) { void ZZshDefaultOneColor( FRAGMENTSHADER& ptr ) {
ShaderHandleName = "Set Default One color"; ShaderHandleName = "Set Default One color";
float4 v = float4 ( 1, 1, 1, 1 ); float4 v = float4 ( 1, 1, 1, 1 );
ZZshSetParameter4fv( ptr.prog, ptr.sOneColor, v, "DefaultOne"); ZZshSetParameter4fv( ptr.prog, ptr.sOneColor, v, "DefaultOne");

View File

@ -30,6 +30,7 @@
#define SHADER_REDUCED 1 // equivalent to ps2.0 #define SHADER_REDUCED 1 // equivalent to ps2.0
#define SHADER_ACCURATE 2 // for older cards with less accurate math (ps2.x+) #define SHADER_ACCURATE 2 // for older cards with less accurate math (ps2.x+)
#include <math.h>
#include "ZZoglMath.h" #include "ZZoglMath.h"
#include "GS.h" #include "GS.h"
@ -58,6 +59,11 @@ inline bool ZZshActiveParameter(ZZshParameter param) {return (param !=NULL); }
#endif // end NVIDIA cg-toolkit API #endif // end NVIDIA cg-toolkit API
#ifdef GLSL4_API
#include "GSUniformBufferOGL.h"
#include "GSVertexArrayOGL.h"
#endif
#ifdef GLSL_API #ifdef GLSL_API
enum ZZshPARAMTYPE { enum ZZshPARAMTYPE {
@ -106,6 +112,108 @@ inline bool ZZshActiveParameter(ZZshParameter param) {return (param > -1); }
#endif #endif
extern float4 g_vdepth;
extern float4 vlogz;
#ifdef GLSL4_API
enum {
ZZSH_CTX_0 = 0,
ZZSH_CTX_1 = 1,
ZZSH_CTX_ALL = 2
};
// Note A nice template could be better
// Warning order is important for buffer (see GLSL)
// Note must be keep POD (so you can map it to GLSL)
struct GlobalUniform {
union {
struct {
// VS
float g_fPosXY[4]; // dual context
// PS
float g_fFogColor[4];
};
float linear[2*4];
};
void SettleFloat(uint indice, const float* v) {
assert(indice + 3 < 2*4);
linear[indice+0] = v[0];
linear[indice+1] = v[1];
linear[indice+2] = v[2];
linear[indice+3] = v[3];
}
};
struct ConstantUniform {
union {
struct {
// Both VS/PS
float g_fBilinear[4];
float g_fZbias[4];
float g_fc0[4];
float g_fMult[4];
// VS
float g_fZ[4];
float g_fZMin[4];
float g_fZNorm[4];
// PS
float g_fExactColor[4];
};
float linear[8*4];
};
void SettleFloat(uint indice, const float* v) {
assert(indice + 3 < 8*4);
linear[indice+0] = v[0];
linear[indice+1] = v[1];
linear[indice+2] = v[2];
linear[indice+3] = v[3];
}
};
struct FragmentUniform {
union {
struct {
float g_fTexAlpha2[4]; // dual context
float g_fTexOffset[4]; // dual context
float g_fTexDims[4]; // dual context
float g_fTexBlock[4]; // dual context
float g_fClampExts[4]; // dual context
float g_fTexWrapMode[4]; // dual context
float g_fRealTexDims[4]; // dual context
float g_fTestBlack[4]; // dual context
float g_fPageOffset[4]; // dual context
float g_fTexAlpha[4]; // dual context
float g_fInvTexDims[4];
float g_fBitBltZ[4];
float g_fOneColor[4];
};
float linear[13*4];
};
void SettleFloat(uint indice, const float* v) {
assert(indice + 3 < 13*4);
linear[indice+0] = v[0];
linear[indice+1] = v[1];
linear[indice+2] = v[2];
linear[indice+3] = v[3];
}
};
struct VertexUniform {
union {
struct {
float g_fBitBltPos[4];
float g_fBitBltTex[4];
float g_fBitBltTrans[4];
};
float linear[3*4];
};
void SettleFloat(uint indice, const float* v) {
assert(indice + 3 < 3*4);
linear[indice+0] = v[0];
linear[indice+1] = v[1];
linear[indice+2] = v[2];
linear[indice+3] = v[3];
}
};
#endif
@ -124,6 +232,7 @@ extern ZZshParameter g_vparamPosXY[2], g_fparamFogColor;
#define MAX_ACTIVE_UNIFORMS 600 #define MAX_ACTIVE_UNIFORMS 600
#define MAX_ACTIVE_SHADERS 400 #define MAX_ACTIVE_SHADERS 400
#ifndef GLSL4_API
struct FRAGMENTSHADER struct FRAGMENTSHADER
{ {
FRAGMENTSHADER() : prog(sZero), Shader(0), sMemory(pZero), sFinal(pZero), sBitwiseANDX(pZero), sBitwiseANDY(pZero), sInterlace(pZero), sCLUT(pZero), sOneColor(pZero), sBitBltZ(pZero), FRAGMENTSHADER() : prog(sZero), Shader(0), sMemory(pZero), sFinal(pZero), sBitwiseANDX(pZero), sBitwiseANDY(pZero), sInterlace(pZero), sCLUT(pZero), sOneColor(pZero), sBitBltZ(pZero),
@ -217,7 +326,239 @@ struct FRAGMENTSHADER
} }
#endif #endif
}; };
#else
const GLenum g_texture_target[11] = {GL_TEXTURE_RECTANGLE, GL_TEXTURE_RECTANGLE, GL_TEXTURE_2D, GL_TEXTURE_2D, GL_TEXTURE_2D, GL_TEXTURE_3D, GL_TEXTURE_RECTANGLE, GL_TEXTURE_RECTANGLE, GL_TEXTURE_RECTANGLE, GL_TEXTURE_2D, GL_TEXTURE_RECTANGLE};
extern int g_current_texture_bind[11];
struct SamplerParam {
int unit;
GLuint texid;
GLenum target;
SamplerParam() : unit(-1), texid(0), target(0) {}
void set_unit(int new_unit) {
assert(new_unit < 11);
unit = new_unit;
target = g_texture_target[new_unit];
}
void enable_texture() {
assert(unit >= 0);
assert(unit < 11);
if (texid) {
if (g_current_texture_bind[unit] != texid) {
glActiveTexture(GL_TEXTURE0 + unit);
glBindTexture(target, texid);
g_current_texture_bind[unit] = texid;
}
}
}
void set_texture(GLuint new_texid) {
texid = new_texid;
}
void release_texture() {
texid = 0;
}
};
struct FRAGMENTSHADER
{
FRAGMENTSHADER() : prog(sZero)
, program(0)
, context(0)
, sMemory(0) // dual context need 2 slots
, sFinal(2)
, sBitwiseANDX(3)
, sBitwiseANDY(4)
, sInterlace(5)
, sCLUT(6)
{
// Uniform
sOneColor = (ZZshParameter)offsetof(struct FragmentUniform, g_fOneColor) /4;
sBitBltZ = (ZZshParameter)offsetof(struct FragmentUniform, g_fBitBltZ) /4;
sInvTexDims = (ZZshParameter)offsetof(struct FragmentUniform, g_fInvTexDims) /4;
fTexAlpha = (ZZshParameter)offsetof(struct FragmentUniform, g_fTexAlpha) /4;
fTexAlpha2 = (ZZshParameter)offsetof(struct FragmentUniform, g_fTexAlpha2) /4;
fTexOffset = (ZZshParameter)offsetof(struct FragmentUniform, g_fTexOffset) /4;
fTexDims = (ZZshParameter)offsetof(struct FragmentUniform, g_fTexDims) /4;
fTexBlock = (ZZshParameter)offsetof(struct FragmentUniform, g_fTexBlock) /4;
fClampExts = (ZZshParameter)offsetof(struct FragmentUniform, g_fClampExts) /4; // FIXME: There is a bug, that lead FFX-1 to incorrect CLAMP if this uniform have context.
fTexWrapMode = (ZZshParameter)offsetof(struct FragmentUniform, g_fTexWrapMode) /4;
fRealTexDims = (ZZshParameter)offsetof(struct FragmentUniform, g_fRealTexDims) /4;
fTestBlack = (ZZshParameter)offsetof(struct FragmentUniform, g_fTestBlack) /4;
fPageOffset = (ZZshParameter)offsetof(struct FragmentUniform, g_fPageOffset) /4;
//sFinal = 2;
//sBitwiseANDX = 3;
//sBitwiseANDY = 4;
//sInterlace = 5;
//sCLUT = 6;
samplers[sMemory].set_unit(10);
samplers[sMemory+1].set_unit(10); // Dual context. Use same unit
samplers[sFinal].set_unit(1);
samplers[sBitwiseANDX].set_unit(6);
samplers[sBitwiseANDY].set_unit(7);
samplers[sInterlace].set_unit(8);
samplers[sCLUT].set_unit(9);
prog.isFragment = true;
prog.link = (void*)this;
}
ZZshShaderLink prog; // it link to FRAGMENTSHADER structure, for compability between GLSL and CG
ZZshProgram program;
uint context;
FragmentUniform uniform_buffer[ZZSH_CTX_ALL];
// sampler
const ZZshParameter sMemory;
const ZZshParameter sFinal, sBitwiseANDX, sBitwiseANDY, sInterlace, sCLUT;
SamplerParam samplers[7];
// uniform
ZZshParameter sOneColor, sBitBltZ, sInvTexDims;
ZZshParameter fTexAlpha2, fTexOffset, fTexDims, fTexBlock, fClampExts, fTexWrapMode, fRealTexDims, fTestBlack, fPageOffset, fTexAlpha;
#ifdef _DEBUG
string filename;
#endif
void ZZshSetParameter4fv(ZZshParameter param, const float* v) {
if (IsDualContext(param))
uniform_buffer[context].SettleFloat((int) param, v);
else
for ( int i = 0; i < ZZSH_CTX_ALL ; i++)
uniform_buffer[i].SettleFloat((int) param, v);
}
bool IsDualContext(ZZshParameter param) {
if (param == sInvTexDims || param == sBitBltZ || param == sOneColor)
return false;
else
return true;
}
void enable_texture() {
samplers[sMemory+context].enable_texture(); // sMemory is dual context
for (int i = 2; i < 7; i++)
samplers[i].enable_texture();
}
void set_texture(ZZshParameter param, GLuint texid) {
if (param == sMemory) // sMemory is dual context
samplers[sMemory+context].set_texture(texid);
else
samplers[param].set_texture(texid);
}
void release_prog() {
if(program) {
glDeleteProgram(program);
program = 0;
}
for (uint i = 0; i < 7 ; i++)
samplers[i].release_texture();
}
};
#endif
#ifdef GLSL4_API
struct COMMONSHADER
{
COMMONSHADER() : context(0)
, sBlocks(0)
, sBilinearBlocks(1)
, sConv16to32(2)
, sConv32to16(3)
{
// sBlocks = 0;
// sBilinearBlocks = 1;
// sConv16to32 = 2;
// sConv32to16 = 3;
samplers[sBlocks].set_unit(2);
samplers[sBilinearBlocks].set_unit(3);
samplers[sConv16to32].set_unit(4);
samplers[sConv32to16].set_unit(5);
g_fparamFogColor = (ZZshParameter)offsetof(struct GlobalUniform, g_fFogColor) /4;
g_vparamPosXY = (ZZshParameter)offsetof(struct GlobalUniform, g_fPosXY) /4;
g_fBilinear = (ZZshParameter)offsetof(struct ConstantUniform, g_fBilinear) /4;
g_fZBias = (ZZshParameter)offsetof(struct ConstantUniform, g_fZbias) /4;
g_fc0 = (ZZshParameter)offsetof(struct ConstantUniform, g_fc0) /4;
g_fMult = (ZZshParameter)offsetof(struct ConstantUniform, g_fMult) /4;
g_fZ = (ZZshParameter)offsetof(struct ConstantUniform, g_fZ) /4;
g_fZMin = (ZZshParameter)offsetof(struct ConstantUniform, g_fZMin) /4;
g_fZNorm = (ZZshParameter)offsetof(struct ConstantUniform, g_fZNorm) /4;
g_fExactColor = (ZZshParameter)offsetof(struct ConstantUniform, g_fExactColor) /4;
// Setup the constant buffer
// Set Z-test, log or no log;
if (conf.settings().no_logz) {
g_vdepth = float4( 255.0 /256.0f, 255.0/65536.0f, 255.0f/(65535.0f*256.0f), 1.0f/(65536.0f*65536.0f));
vlogz = float4( 1.0f, 0.0f, 0.0f, 0.0f);
}
else {
g_vdepth = float4( 256.0f*65536.0f, 65536.0f, 256.0f, 65536.0f*65536.0f);
vlogz = float4( 0.0f, 1.0f, 0.0f, 0.0f);
}
uniform_buffer_constant.SettleFloat(g_fZ, g_vdepth );
uniform_buffer_constant.SettleFloat(g_fZMin, vlogz );
const float g_filog32 = 0.999f / (32.0f * logf(2.0f));
float4 vnorm = float4(g_filog32, 0, 0,0);
uniform_buffer_constant.SettleFloat(g_fZNorm, vnorm);
uniform_buffer_constant.SettleFloat(g_fBilinear, float4(-0.2f, -0.65f, 0.9f, 1.0f / 32767.0f ) );
uniform_buffer_constant.SettleFloat(g_fZBias, float4(1.0f/256.0f, 1.0004f, 1, 0.5f) );
uniform_buffer_constant.SettleFloat(g_fc0, float4(0,1, 0.001f, 0.5f) );
uniform_buffer_constant.SettleFloat(g_fExactColor, float4(0.5f, (conf.settings().exact_color)?0.9f/256.0f:0.5f/256.0f, 0,1/255.0f) );
uniform_buffer_constant.SettleFloat(g_fMult, float4(1/1024.0f, 0.2f/1024.0f, 1/128.0f, 1/512.0f));
}
ZZshParameter g_fparamFogColor, g_vparamPosXY;
ZZshParameter g_fBilinear, g_fZBias, g_fc0, g_fMult, g_fZ, g_fZMin, g_fZNorm, g_fExactColor;
uint context;
GlobalUniform uniform_buffer[ZZSH_CTX_ALL];
ConstantUniform uniform_buffer_constant;
// Sampler
const ZZshParameter sBlocks, sBilinearBlocks, sConv16to32, sConv32to16;
SamplerParam samplers[4];
void ZZshSetParameter4fv(ZZshParameter param, const float* v) {
if (IsDualContext(param))
uniform_buffer[context].SettleFloat((int) param, v);
else
for ( int i = 0; i < ZZSH_CTX_ALL ; i++)
uniform_buffer[i].SettleFloat((int) param, v);
}
bool IsDualContext(ZZshParameter param) {
if (param == g_vparamPosXY) return true;
else return false;
}
void set_texture(ZZshParameter param, GLuint texid) {
samplers[param].set_texture(texid);
}
void enable_texture() {
for (int i = 0; i < 4; i++)
samplers[i].enable_texture();
}
};
#endif
#ifndef GLSL4_API
struct VERTEXSHADER struct VERTEXSHADER
{ {
VERTEXSHADER() : prog(sZero), Shader(0), sBitBltPos(pZero), sBitBltTex(pZero) {} VERTEXSHADER() : prog(sZero), Shader(0), sBitBltPos(pZero), sBitBltTex(pZero) {}
@ -230,15 +571,54 @@ struct VERTEXSHADER
int ParametersStart, ParametersFinish; int ParametersStart, ParametersFinish;
}; };
#else
struct VERTEXSHADER
{
VERTEXSHADER() : prog(sZero), program(0), context(0)
{
sBitBltPos = (ZZshParameter)offsetof(struct VertexUniform, g_fBitBltPos) /4;
sBitBltTex = (ZZshParameter)offsetof(struct VertexUniform, g_fBitBltTex) /4;
fBitBltTrans = (ZZshParameter)offsetof(struct VertexUniform, g_fBitBltTrans) /4;
// Default value not sure it is needed
uniform_buffer[0].SettleFloat(fBitBltTrans, float4(0.5f, -0.5f, 0.5, 0.5 + 0.4/416.0f ) );
uniform_buffer[1].SettleFloat(fBitBltTrans, float4(0.5f, -0.5f, 0.5, 0.5 + 0.4/416.0f ) );
prog.isFragment = false;
prog.link = (void*)this;
}
VertexUniform uniform_buffer[ZZSH_CTX_ALL];
ZZshShaderLink prog;
ZZshProgram program;
uint context;
ZZshParameter sBitBltPos, sBitBltTex, fBitBltTrans; // vertex shader constants
void ZZshSetParameter4fv(ZZshParameter param, const float* v) {
if (IsDualContext(param))
uniform_buffer[context].SettleFloat((int) param, v);
else
for ( int i = 0; i < ZZSH_CTX_ALL ; i++)
uniform_buffer[i].SettleFloat((int) param, v);
}
bool IsDualContext(ZZshParameter param) { return false;}
};
#endif
extern float4 g_vdepth;
extern float4 vlogz;
extern VERTEXSHADER pvsBitBlt; extern VERTEXSHADER pvsBitBlt;
extern FRAGMENTSHADER ppsBitBlt[2], ppsBitBltDepth, ppsOne; // ppsOne used to stop using shaders for draw extern FRAGMENTSHADER ppsBitBlt[2], ppsBitBltDepth, ppsOne; // ppsOne used to stop using shaders for draw
extern FRAGMENTSHADER ppsBaseTexture, ppsConvert16to32, ppsConvert32to16; extern FRAGMENTSHADER ppsBaseTexture, ppsConvert16to32, ppsConvert32to16;
extern FRAGMENTSHADER ppsRegular[4], ppsTexture[NUM_SHADERS]; extern FRAGMENTSHADER ppsRegular[4], ppsTexture[NUM_SHADERS];
extern FRAGMENTSHADER ppsCRTC[2], /*ppsCRTC24[2],*/ ppsCRTCTarg[2]; extern FRAGMENTSHADER ppsCRTC[2], /*ppsCRTC24[2],*/ ppsCRTCTarg[2];
#ifdef GLSL4_API
extern COMMONSHADER g_cs;
#endif
extern int interlace_mode; extern int interlace_mode;
@ -271,11 +651,16 @@ inline bool ZZshExistProgram(FRAGMENTSHADER* pf) {return (pf->prog != NULL); };
inline bool ZZshExistProgram(VERTEXSHADER* pf) {return (pf->prog != NULL); }; inline bool ZZshExistProgram(VERTEXSHADER* pf) {return (pf->prog != NULL); };
inline bool ZZshExistProgram(ZZshShaderLink prog) {return (prog != NULL); }; inline bool ZZshExistProgram(ZZshShaderLink prog) {return (prog != NULL); };
#endif #endif
#ifdef GLSL_API #if defined(GLSL_API) && !defined(GLSL4_API)
inline bool ZZshExistProgram(FRAGMENTSHADER* pf) {return (pf->Shader != 0); }; inline bool ZZshExistProgram(FRAGMENTSHADER* pf) {return (pf->Shader != 0); };
inline bool ZZshExistProgram(VERTEXSHADER* pf) {return (pf->Shader != 0); }; inline bool ZZshExistProgram(VERTEXSHADER* pf) {return (pf->Shader != 0); };
inline bool ZZshExistProgram(ZZshShaderLink prog) {return (prog.link != NULL); } // This is used for pvs mainly. No NULL means that we do LOAD_VS inline bool ZZshExistProgram(ZZshShaderLink prog) {return (prog.link != NULL); } // This is used for pvs mainly. No NULL means that we do LOAD_VS
#endif #endif
#if defined(GLSL4_API)
inline bool ZZshExistProgram(FRAGMENTSHADER* pf) {return (pf->program != 0); };
inline bool ZZshExistProgram(VERTEXSHADER* pf) {return (pf->program != 0); };
inline bool ZZshExistProgram(ZZshShaderLink prog) {return (prog.link != NULL); } // This is used for pvs mainly. No NULL means that we do LOAD_VS
#endif
extern const char* ShaderCallerName; extern const char* ShaderCallerName;
extern const char* ShaderHandleName; extern const char* ShaderHandleName;
@ -318,16 +703,16 @@ extern void ZZshGLEnableProfile();
// Set the Uniform parameter in host (NOT GL) // Set the Uniform parameter in host (NOT GL)
// Param seem to be an absolute index inside a table of uniform // Param seem to be an absolute index inside a table of uniform
extern void ZZshSetParameter4fv(ZZshShaderLink prog, ZZshParameter param, const float* v, const char* name); extern void ZZshSetParameter4fv(ZZshShaderLink& prog, ZZshParameter param, const float* v, const char* name);
extern void ZZshSetParameter4fv(ZZshParameter param, const float* v, const char* name); extern void ZZshSetParameter4fv(ZZshParameter param, const float* v, const char* name);
extern void ZZshSetParameter4fvWithRetry(ZZshParameter* param, ZZshShaderLink prog, const float* v, const char* name); extern void ZZshSetParameter4fvWithRetry(ZZshParameter* param, ZZshShaderLink& prog, const float* v, const char* name);
// Set the Texture parameter in host (NOT GL) // Set the Texture parameter in host (NOT GL)
extern void ZZshGLSetTextureParameter(ZZshShaderLink prog, ZZshParameter param, GLuint texobj, const char* name); extern void ZZshGLSetTextureParameter(ZZshShaderLink prog, ZZshParameter param, GLuint texobj, const char* name);
extern void ZZshGLSetTextureParameter(ZZshParameter param, GLuint texobj, const char* name); extern void ZZshGLSetTextureParameter(ZZshParameter param, GLuint texobj, const char* name);
// Set a default value for 1 uniform in host (NOT GL) // Set a default value for 1 uniform in host (NOT GL)
extern void ZZshDefaultOneColor( FRAGMENTSHADER ptr ); extern void ZZshDefaultOneColor( FRAGMENTSHADER& ptr );
// Link then run with the new Vertex/Fragment Shader // Link then run with the new Vertex/Fragment Shader
extern void ZZshSetVertexShader(ZZshShaderLink prog); extern void ZZshSetVertexShader(ZZshShaderLink prog);
@ -350,5 +735,21 @@ extern u32 ptexConv16to32; // does not exists. This textures should be created o
extern u32 ptexBilinearBlocks; extern u32 ptexBilinearBlocks;
extern u32 ptexConv32to16; extern u32 ptexConv32to16;
#ifdef GLSL4_API
extern GSUniformBufferOGL *constant_buffer;
extern GSUniformBufferOGL *common_buffer;
extern GSUniformBufferOGL *vertex_buffer;
extern GSUniformBufferOGL *fragment_buffer;
extern GSVertexBufferStateOGL *vertex_array;
extern GLenum g_current_vs;
extern GLenum g_current_ps;
extern void init_shader();
extern void PutParametersInProgram(VERTEXSHADER* vs, FRAGMENTSHADER* ps);
extern void init_shader();
extern void ZZshSetupShader();
#endif
#endif #endif

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
#ifdef GLSL_API // This code is only for GLSL API #if defined(GLSL_API) && !defined(GLSL4_API) // This code is only for GLSL API
// ZZogl Shader manipulation functions. // ZZogl Shader manipulation functions.
/* /*
@ -237,10 +237,10 @@ bool ZZshCreateOpenShadersFile() {
if ((ShaderFD == -1) || (fstat(ShaderFD, &sb) == -1)) { if ((ShaderFD == -1) || (fstat(ShaderFD, &sb) == -1)) {
// Each linux distributions have his rules for path so we give them the possibility to // Each linux distributions have his rules for path so we give them the possibility to
// change it with compilation flags. -- Gregory // change it with compilation flags. -- Gregory
#ifdef PLUGIN_DIR_COMPILATION #ifdef GLSL_SHADER_DIR_COMPILATION
#define xPLUGIN_DIR_str(s) PLUGIN_DIR_str(s) #define xGLSL_SHADER_DIR_str(s) GLSL_SHADER_DIR_str(s)
#define PLUGIN_DIR_str(s) #s #define GLSL_SHADER_DIR_str(s) #s
ShaderFileName = string(xPLUGIN_DIR_str(PLUGIN_DIR_COMPILATION)) + "/ps2hw.glsl"; ShaderFileName = string(xGLSL_SHADER_DIR_str(GLSL_SHADER_DIR_COMPILATION)) + "/ps2hw.glsl";
ShaderFD = open(ShaderFileName.c_str(), O_RDONLY); ShaderFD = open(ShaderFileName.c_str(), O_RDONLY);
#endif #endif
if ((ShaderFD == -1) || (fstat(ShaderFD, &sb) == -1)) { if ((ShaderFD == -1) || (fstat(ShaderFD, &sb) == -1)) {
@ -290,7 +290,7 @@ void ZZshGLSetTextureParameter(ZZshShaderLink prog, ZZshParameter param, GLuint
// This is helper of cgGLSetParameter4fv, made for debug purpose. // This is helper of cgGLSetParameter4fv, made for debug purpose.
// Name could be any string. We must use it on compilation time, because erroneus handler does not // Name could be any string. We must use it on compilation time, because erroneus handler does not
// return name // return name
void ZZshSetParameter4fv(ZZshShaderLink prog, ZZshParameter param, const float* v, const char* name) { void ZZshSetParameter4fv(ZZshShaderLink& prog, ZZshParameter param, const float* v, const char* name) {
if (param > -1) { if (param > -1) {
// ZZLog::Error_Log("Set float parameter %s %f, %f, %f, %f... Ok", name, v[0], v[1], v[2], v[3]); // ZZLog::Error_Log("Set float parameter %s %f, %f, %f, %f... Ok", name, v[0], v[1], v[2], v[3]);
SettleFloat(UniformsIndex[param].fvalue, v); SettleFloat(UniformsIndex[param].fvalue, v);
@ -307,13 +307,13 @@ void ZZshSetParameter4fv(ZZshParameter param, const float* v, const char* name)
} }
// The same stuff, but also with retry of param, name should be USED name of param for prog. // The same stuff, but also with retry of param, name should be USED name of param for prog.
void ZZshSetParameter4fvWithRetry(ZZshParameter* param, ZZshShaderLink prog, const float* v, const char* name) { void ZZshSetParameter4fvWithRetry(ZZshParameter* param, ZZshShaderLink& prog, const float* v, const char* name) {
if (param != NULL) if (param != NULL)
ZZshSetParameter4fv(prog, *param, v, name); ZZshSetParameter4fv(prog, *param, v, name);
} }
// Used sometimes for color 1. // Used sometimes for color 1.
void ZZshDefaultOneColor( FRAGMENTSHADER ptr ) { void ZZshDefaultOneColor( FRAGMENTSHADER& ptr ) {
// return; // return;
ShaderHandleName = "Set Default One colot"; ShaderHandleName = "Set Default One colot";
float4 v = float4 ( 1, 1, 1, 1 ); float4 v = float4 ( 1, 1, 1, 1 );
@ -426,7 +426,7 @@ inline bool GetLinkLog(ZZshProgram prog) {
if (LinkStatus == GL_TRUE && glIsProgram(prog)) return true; if (LinkStatus == GL_TRUE && glIsProgram(prog)) return true;
#ifdef DEVBUILD #if defined(DEVBUILD) || defined(_DEBUG)
int* lenght, infologlength; int* lenght, infologlength;
glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &infologlength); glGetProgramiv(prog, GL_INFO_LOG_LENGTH, &infologlength);
char* InfoLog = new char[infologlength]; char* InfoLog = new char[infologlength];
@ -474,6 +474,9 @@ static void PutParametersInProgam(int start, int finish) {
} }
else else
{ {
// assert(param.texid != 0);
// ZZLog::Error_Log("Set texture (%s) : %d with sampler %d\n", param.ShName, param.texid, param.sampler);
// assert(param.sampler >= 0);
glActiveTexture(GL_TEXTURE0 + param.sampler); glActiveTexture(GL_TEXTURE0 + param.sampler);
if (param.type == ZZ_TEXTURE_2D) if (param.type == ZZ_TEXTURE_2D)
glBindTexture(GL_TEXTURE_2D, param.texid); glBindTexture(GL_TEXTURE_2D, param.texid);
@ -974,4 +977,4 @@ FRAGMENTSHADER* ZZshLoadShadeEffect(int type, int texfilter, int fog, int testae
return NULL; return NULL;
} }
#endif // GLSL_API #endif

View File

@ -0,0 +1,610 @@
/* ZZ Open GL graphics plugin
* Copyright (c)2009 zeydlitz@gmail.com
* Based on Zerofrog's ZeroGS KOSMOS (c)2005-2006
*
* 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 of the License, 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifdef GLSL4_API // This code is only for GLSL API
// ZZogl Shader manipulation functions.
/*
* used cg calls:
* cgGLIsProfileSupported -- don't needed
* cgGetErrorString -- later
* cgGetLastListing -- later
* cgSetErrorHandler -- later
* cgCreateContext -- think that don't need
* cgGLEnableProfile -- don't need
* cgGLSetOptimalOptions -- don't need?
* cgGLSetManageTextureParameters -- what's this?
* cgCreateParameter -- don't need
* cgGLLoadProgram void LinkProgram(uint program)
* cgGetError -- later
* cgGLDisableProfile -- don't need
* cgGLSetParameter4fv
* cgGetNamedParameter
* cgGLEnableTextureParameter
* cgIsParameterUsed
* cgGLBindProgram void UseProgram(uint program)
* cgConnectParameter
* cgIsProgram bool IsProgram(uint program)
* cgCreateProgramFromFile
*/
//------------------- Includes
#include "Util.h"
#include "ZZoglShaders.h"
#include "zpipe.h"
#include <math.h>
#include <map>
#include <fcntl.h> // this for open(). Maybe linux-specific
#include <sys/mman.h> // and this for mmap
// ----------------- Defines
#define TEXWRAP_REPEAT 0
#define TEXWRAP_CLAMP 1
#define TEXWRAP_REGION_REPEAT 2
#define TEXWRAP_REPEAT_CLAMP 3
#ifdef DEVBUILD
# define UNIFORM_ERROR_LOG ZZLog::Error_Log
#else
# define UNIFORM_ERROR_LOG
#endif
// Set it to 0 to diable context usage, 1 -- to enable. FFX-1 have a strange issue with ClampExt.
#define NOCONTEXT 0
#define NUMBER_OF_SAMPLERS 11
#define MAX_SHADER_NAME_SIZE 25
#define DEFINE_STRING_SIZE 256
// #define ENABLE_MARKER // Fire some marker for opengl Debugger (apitrace, gdebugger)
//------------------ Constants
// Used in a logarithmic Z-test, as (1-o(1))/log(MAX_U32).
const float g_filog32 = 0.999f / (32.0f * logf(2.0f));
const static char* g_pTexTypes[] = { "32", "tex32", "clut32", "tex32to16", "tex16to8h" };
const static char* g_pShaders[4] = { "full", "reduced", "accurate", "accurate-reduced" };
const static char* g_pPsTexWrap[] = { "#define REPEAT 1\n", "#define CLAMP 1\n", "#define REGION_REPEAT 1\n", "\n" };
const int GLSL_VERSION = 330;
// ----------------- Global Variables
ZZshContext g_cgcontext;
ZZshProfile cgvProf, cgfProf;
int g_nPixelShaderVer = 0; // default
u8* s_lpShaderResources = NULL;
ZZshShaderLink pvs[16] = {sZero}, g_vsprog = sZero, g_psprog = sZero; // 2 -- ZZ
ZZshParameter g_vparamPosXY[2] = {pZero}, g_fparamFogColor = pZero;
char* ZZshSource; // Shader's source data.
off_t ZZshSourceSize;
bool g_bCRTCBilinear = true;
float4 g_vdepth, vlogz;
FRAGMENTSHADER ppsBitBlt[2], ppsBitBltDepth, ppsOne;
FRAGMENTSHADER ppsBaseTexture, ppsConvert16to32, ppsConvert32to16;
FRAGMENTSHADER ppsRegular[4], ppsTexture[NUM_SHADERS];
FRAGMENTSHADER ppsCRTC[2], /*ppsCRTC24[2],*/ ppsCRTCTarg[2];
VERTEXSHADER pvsStore[16];
VERTEXSHADER pvsBitBlt;
inline bool LoadEffects();
extern bool s_bWriteDepth;
// Debug variable, store name of the function that call the shader.
const char* ShaderCallerName = "";
const char* ShaderHandleName = "";
ZZshProgram CompiledPrograms[MAX_ACTIVE_SHADERS][MAX_ACTIVE_SHADERS] = {{0}};
// new for GLSL4
GSUniformBufferOGL *constant_buffer;
GSUniformBufferOGL *common_buffer;
GSUniformBufferOGL *vertex_buffer;
GSUniformBufferOGL *fragment_buffer;
static bool dirty_common_buffer = true;
static bool dirty_vertex_buffer = true;
static bool dirty_fragment_buffer = true;
GSVertexBufferStateOGL *vertex_array;
COMMONSHADER g_cs;
static GLuint s_pipeline = 0;
int g_current_texture_bind[11] = {0};
GLenum g_current_vs = NULL;
GLenum g_current_ps = NULL;
//FRAGMENTSHADER ppsDebug;
//FRAGMENTSHADER ppsDebug2;
//------------------ Code
inline int GET_SHADER_INDEX(int type, int texfilter, int texwrap, int fog, int writedepth, int testaem, int exactcolor, int context, int ps) {
return type + texfilter*NUM_TYPES + NUM_FILTERS*NUM_TYPES*texwrap + NUM_TEXWRAPS*NUM_FILTERS*NUM_TYPES*(fog+2*writedepth+4*testaem+8*exactcolor+16*context+32*ps) ;
}
// Nothing need to be done.
bool ZZshCheckProfilesSupport() {
return true;
}
// Error handler. Setup in ZZogl_Create once.
void HandleCgError(ZZshContext ctx, ZZshError err, void* appdata)
{/*
ZZLog::Error_Log("%s->%s: %s", ShaderCallerName, ShaderHandleName, cgGetErrorString(err));
const char* listing = cgGetLastListing(g_cgcontext);
if (listing != NULL)
ZZLog::Debug_Log(" last listing: %s", listing);
*/
}
bool ZZshStartUsingShaders() {
ZZLog::Error_Log("Creating effects.");
B_G(LoadEffects(), return false);
if (!glCreateShader)
{
ZZLog::Error_Log("GLSL shaders is not supported, stop.");
return false;
}
init_shader();
// create a sample shader
clampInfo temp;
memset(&temp, 0, sizeof(temp));
temp.wms = 3; temp.wmt = 3;
g_nPixelShaderVer = 0;//SHADER_ACCURATE;
// test
bool bFailed;
FRAGMENTSHADER* pfrag = ZZshLoadShadeEffect(0, 1, 1, 1, 1, temp, 0, &bFailed);
if( bFailed || pfrag == NULL ) {
return false;
ZZLog::Error_Log("Shader test failed.");
}
ZZLog::Error_Log("Creating extra effects.");
B_G(ZZshLoadExtraEffects(), return false);
ZZLog::Error_Log("Using %s shaders.", g_pShaders[g_nPixelShaderVer]);
return true;
}
// open shader file according to build target
bool ZZshCreateOpenShadersFile() {
std::string ShaderFileName("plugins/ps2hw_gl4.glsl");
int ShaderFD = open(ShaderFileName.c_str(), O_RDONLY);
struct stat sb;
if ((ShaderFD == -1) || (fstat(ShaderFD, &sb) == -1)) {
// Each linux distributions have his rules for path so we give them the possibility to
// change it with compilation flags. -- Gregory
#ifdef GLSL_SHADER_DIR_COMPILATION
#define xGLSL_SHADER_DIR_str(s) GLSL_SHADER_DIR_str(s)
#define GLSL_SHADER_DIR_str(s) #s
ShaderFileName = string(xGLSL_SHADER_DIR_str(GLSL_SHADER_DIR_COMPILATION)) + "/ps2hw_gl4.glsl";
ShaderFD = open(ShaderFileName.c_str(), O_RDONLY);
#endif
if ((ShaderFD == -1) || (fstat(ShaderFD, &sb) == -1)) {
ZZLog::Error_Log("No source for %s: \n", ShaderFileName.c_str());
return false;
}
}
ZZshSourceSize = sb.st_size;
ZZshSource = (char*)mmap(NULL, sb.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, ShaderFD, 0); // This function directly maped file into memory.
ZZshSource[ ZZshSourceSize - 1] = 0; // Made source null-terminated.
close(ShaderFD);
return true;
}
void ZZshExitCleaning() {
munmap(ZZshSource, ZZshSourceSize);
delete constant_buffer;
delete common_buffer;
delete vertex_buffer;
delete fragment_buffer;
glDeleteProgramPipelines(1, &s_pipeline);
}
// Disable CG
void ZZshGLDisableProfile() { // This stop all other shader programs from running;
glBindProgramPipeline(0);
}
//Enable CG
void ZZshGLEnableProfile() {
glBindProgramPipeline(s_pipeline);
}
//-------------------------------------------------------------------------------------
// The same function for texture, also to cgGLEnable
void ZZshGLSetTextureParameter(ZZshParameter param, GLuint texobj, const char* name) {
#ifdef ENABLE_MARKER
char* debug = new char[100];
sprintf(debug, "CS: texture %d, param %d", texobj, param);
if (GLEW_GREMEDY_string_marker) glStringMarkerGREMEDY(0, debug);
#endif
g_cs.set_texture(param, texobj);
}
void ZZshGLSetTextureParameter(ZZshShaderLink prog, ZZshParameter param, GLuint texobj, const char* name) {
FRAGMENTSHADER* shader = (FRAGMENTSHADER*)prog.link;
#ifdef ENABLE_MARKER
char* debug = new char[100];
sprintf(debug, "FS(%d):texture %d, param %d", shader->program, texobj, param);
if (GLEW_GREMEDY_string_marker) glStringMarkerGREMEDY(0, debug);
#endif
shader->set_texture(param, texobj);
}
// This is helper of cgGLSetParameter4fv, made for debug purpose.
// Name could be any string. We must use it on compilation time, because erroneus handler does not
// return name
void ZZshSetParameter4fv(ZZshShaderLink& prog, ZZshParameter param, const float* v, const char* name) {
if (prog.isFragment) {
FRAGMENTSHADER* shader = (FRAGMENTSHADER*)prog.link;
shader->ZZshSetParameter4fv(param, v);
dirty_fragment_buffer = true;
} else {
VERTEXSHADER* shader = (VERTEXSHADER*)prog.link;
shader->ZZshSetParameter4fv(param, v);
dirty_vertex_buffer = true;
}
#ifdef ENABLE_MARKER
char* debug = new char[100];
sprintf(debug, "prog: uniform (%s) (%f)", name, *v);
if (GLEW_GREMEDY_string_marker) glStringMarkerGREMEDY(0, debug);
#endif
}
void ZZshSetParameter4fv(ZZshParameter param, const float* v, const char* name) {
g_cs.ZZshSetParameter4fv(param, v);
dirty_common_buffer = true;
#ifdef ENABLE_MARKER
char* debug = new char[100];
sprintf(debug, "CS: uniform (%s) (%f)", name, *v);
if (GLEW_GREMEDY_string_marker) glStringMarkerGREMEDY(0, debug);
#endif
}
// The same stuff, but also with retry of param, name should be USED name of param for prog.
void ZZshSetParameter4fvWithRetry(ZZshParameter* param, ZZshShaderLink& prog, const float* v, const char* name) {
ZZshSetParameter4fv(prog, *param, v, name);
}
// Used sometimes for color 1.
void ZZshDefaultOneColor( FRAGMENTSHADER& ptr ) {
ShaderHandleName = "Set Default One colot";
float4 v = float4 ( 1, 1, 1, 1 );
ptr.ZZshSetParameter4fv(ptr.sOneColor, v);
dirty_fragment_buffer = true;
}
//-------------------------------------------------------------------------------------
static bool ValidateProgram(ZZshProgram Prog) {
GLint isValid;
glValidateProgram(Prog);
glGetProgramiv(Prog, GL_VALIDATE_STATUS, &isValid);
if (!isValid) {
int lenght, infologlength;
glGetProgramiv(Prog, GL_INFO_LOG_LENGTH, &infologlength);
char* InfoLog = new char[infologlength];
glGetProgramInfoLog(Prog, infologlength, &lenght, InfoLog);
ZZLog::Error_Log("Validation %d... %d:\t %s", Prog, infologlength, InfoLog);
}
return (isValid != 0);
}
inline bool CompileShaderFromFile(ZZshProgram& program, const std::string& DefineString, std::string main_entry, GLenum ShaderType)
{
std::string header("");
header += format("#version %d\n", GLSL_VERSION);
header += format("#define %s main\n", main_entry.c_str());
if (ShaderType == GL_VERTEX_SHADER) header += "#define VERTEX_SHADER 1\n";
else if (ShaderType == GL_FRAGMENT_SHADER) header += "#define FRAGMENT_SHADER 1\n";
header += DefineString;
const GLchar* ShaderSource[2];
ShaderSource[0] = header.c_str();
ShaderSource[1] = (const GLchar*)ZZshSource;
program = glCreateShaderProgramv(ShaderType, 2, &ShaderSource[0]);
ZZLog::Debug_Log("Creating program %d for %s", program, main_entry.c_str());
#if defined(DEVBUILD) || defined(_DEBUG)
if (!ValidateProgram(program)) return false;
#endif
return true;
}
//-------------------------------------------------------------------------------------
void ZZshSetupShader() {
VERTEXSHADER* vs = (VERTEXSHADER*)g_vsprog.link;
FRAGMENTSHADER* ps = (FRAGMENTSHADER*)g_psprog.link;
if (vs == NULL || ps == NULL) return;
// From the glValidateProgram docs: "The implementation may use this as an opportunity to perform any internal
// shader modifications that may be required to ensure correct operation of the installed
// shaders given the current GL state"
// It might be a good idea to validate the pipeline also in release mode???
#if defined(DEVBUILD) || defined(_DEBUG)
glValidateProgramPipeline(s_pipeline);
GLint isValid;
glGetProgramPipelineiv(s_pipeline, GL_VALIDATE_STATUS, &isValid);
if (!isValid) ZZLog::Error_Log("Something weird happened on pipeline validation.");
#endif
PutParametersInProgram(vs, ps);
GL_REPORT_ERRORD();
}
void ZZshSetVertexShader(ZZshShaderLink prog) {
g_vsprog = prog;
VERTEXSHADER* vs = (VERTEXSHADER*)g_vsprog.link;
if (!vs) return;
if (vs->program != g_current_vs) {
glUseProgramStages(s_pipeline, GL_VERTEX_SHADER_BIT, vs->program);
g_current_ps = vs->program;
}
}
void ZZshSetPixelShader(ZZshShaderLink prog) {
g_psprog = prog;
FRAGMENTSHADER* ps = (FRAGMENTSHADER*)g_psprog.link;
if (!ps) return;
if (ps->program != g_current_ps) {
glUseProgramStages(s_pipeline, GL_FRAGMENT_SHADER_BIT, ps->program);
g_current_ps = ps->program;
}
}
//------------------------------------------------------------------------------------------------------------------
void init_shader() {
// TODO:
// Note it would be more clever to allocate buffer inside SHADER class
// Add a dirty flags to avoid to upload twice same data...
// You need to attach() properly the uniform buffer;
// Note: don't put GSUniformBuffer creation inside constructor of static object (context won't
// be set to call gl command)
// Warning put same order than GLSL
constant_buffer = new GSUniformBufferOGL(0, sizeof(ConstantUniform));
common_buffer = new GSUniformBufferOGL(1, sizeof(GlobalUniform));
vertex_buffer = new GSUniformBufferOGL(2, sizeof(VertexUniform));
fragment_buffer = new GSUniformBufferOGL(3, sizeof(FragmentUniform));
constant_buffer->bind();
constant_buffer->upload((void*)&g_cs.uniform_buffer_constant);
g_cs.set_texture(g_cs.sBlocks, ptexBlocks);
g_cs.set_texture(g_cs.sConv16to32, ptexConv16to32);
g_cs.set_texture(g_cs.sConv32to16, ptexConv32to16);
g_cs.set_texture(g_cs.sBilinearBlocks, ptexBilinearBlocks);
glGenProgramPipelines(1, &s_pipeline);
glBindProgramPipeline(s_pipeline);
}
void PutParametersInProgram(VERTEXSHADER* vs, FRAGMENTSHADER* ps) {
if (dirty_common_buffer) {
common_buffer->bind();
common_buffer->upload((void*)&g_cs.uniform_buffer[g_cs.context]);
dirty_common_buffer = false;
}
if (dirty_vertex_buffer) {
vertex_buffer->bind();
vertex_buffer->upload((void*)&vs->uniform_buffer[vs->context]);
dirty_vertex_buffer = false;
}
if (dirty_fragment_buffer) {
fragment_buffer->bind();
fragment_buffer->upload((void*)&ps->uniform_buffer[ps->context]);
dirty_fragment_buffer = false;
}
#ifdef ENABLE_MARKER
char* debug = new char[100];
sprintf(debug, "FS(%d): enable texture", ps->program);
if (GLEW_GREMEDY_string_marker) glStringMarkerGREMEDY(0, debug);
#endif
g_cs.enable_texture();
ps->enable_texture();
// By default enable the unit 0, so I have the guarantee that any
// texture command won't change current binding of others unit
glActiveTexture(GL_TEXTURE0);
}
std::string BuildGlslMacro(bool writedepth, int texwrap = 3, bool testaem = false, bool exactcolor = false)
{
std::string header("");
if (writedepth) header += "#define WRITE_DEPTH 1\n";
if (testaem) header += "#define TEST_AEM 1\n";
if (exactcolor) header += "#define EXACT_COLOR 1\n";
header += format("%s", g_pPsTexWrap[texwrap]);
//const char* AddAccurate = (ps & SHADER_ACCURATE)?"#define ACCURATE_DECOMPRESSION 1\n":"";
return header;
}
static __forceinline bool LOAD_VS(const std::string& DefineString, const char* name, VERTEXSHADER& vertex, ZZshProfile context)
{
bool flag = CompileShaderFromFile(vertex.program, DefineString, name, GL_VERTEX_SHADER);
vertex.context = context * NOCONTEXT;
return flag;
}
static __forceinline bool LOAD_PS(const std::string& DefineString, const char* name, FRAGMENTSHADER& fragment, ZZshProfile context)
{
bool flag = CompileShaderFromFile(fragment.program, DefineString, name, GL_FRAGMENT_SHADER);
fragment.context = context * NOCONTEXT;
return flag;
}
inline bool LoadEffects()
{
// clear the textures
for(u32 i = 0; i < ArraySize(ppsTexture); ++i)
ppsTexture[i].release_prog();
return true;
}
bool ZZshLoadExtraEffects() {
bool bLoadSuccess = true;
std::string depth_macro = BuildGlslMacro(true);
std::string empty_macro = BuildGlslMacro(false);
const char* pvsshaders[4] = { "RegularVS", "TextureVS", "RegularFogVS", "TextureFogVS" };
for (int i = 0; i < 4; ++i) {
if (!LOAD_VS(empty_macro, pvsshaders[i], pvsStore[2 * i], 0)) bLoadSuccess = false;
if (!LOAD_VS(empty_macro, pvsshaders[i], pvsStore[2 *i + 1 ], 1)) bLoadSuccess = false;
if (!LOAD_VS(depth_macro, pvsshaders[i], pvsStore[2 *i + 8 ], 0)) bLoadSuccess = false;
if (!LOAD_VS(depth_macro, pvsshaders[i], pvsStore[2 *i + 8 + 1], 1)) bLoadSuccess = false;
}
for (int i = 0; i < 16; ++i)
pvs[i] = pvsStore[i].prog;
if (!LOAD_VS(empty_macro, "BitBltVS", pvsBitBlt, 0)) bLoadSuccess = false;
GL_REPORT_ERRORD();
if (!LOAD_PS(empty_macro, "RegularPS", ppsRegular[0], 0)) bLoadSuccess = false;
if (!LOAD_PS(empty_macro, "RegularFogPS", ppsRegular[1], 0)) bLoadSuccess = false;
if( conf.mrtdepth ) {
if (!LOAD_PS(depth_macro, "RegularPS", ppsRegular[2], 0)) bLoadSuccess = false;
if (!bLoadSuccess) conf.mrtdepth = 0;
if (!LOAD_PS(depth_macro, "RegularFogPS", ppsRegular[3], 0)) bLoadSuccess = false;
if (!bLoadSuccess) conf.mrtdepth = 0;
}
if (!LOAD_PS(empty_macro, "BitBltPS", ppsBitBlt[0], 0)) bLoadSuccess = false;
if (!LOAD_PS(empty_macro, "BitBltAAPS", ppsBitBlt[1], 0)) bLoadSuccess = false;
if (!bLoadSuccess) {
ZZLog::Error_Log("Failed to load BitBltAAPS, using BitBltPS.");
if (!LOAD_PS(empty_macro, "BitBltPS", ppsBitBlt[1], 0)) bLoadSuccess = false;
}
if (!LOAD_PS(empty_macro, "BitBltDepthPS", ppsBitBltDepth, 0)) bLoadSuccess = false;
if (!LOAD_PS(empty_macro, "CRTCTargPS", ppsCRTCTarg[0], 0)) bLoadSuccess = false;
if (!LOAD_PS(empty_macro, "CRTCTargInterPS", ppsCRTCTarg[1], 0)) bLoadSuccess = false;
g_bCRTCBilinear = true;
if (!LOAD_PS(empty_macro, "CRTCPS", ppsCRTC[0], 0)) bLoadSuccess = false;
if( !bLoadSuccess ) {
// switch to simpler
g_bCRTCBilinear = false;
if (!LOAD_PS(empty_macro, "CRTCPS_Nearest", ppsCRTC[0], 0)) bLoadSuccess = false;
if (!LOAD_PS(empty_macro, "CRTCInterPS_Nearest", ppsCRTC[0], 0)) bLoadSuccess = false;
}
else {
if (!LOAD_PS(empty_macro, "CRTCInterPS", ppsCRTC[1], 0)) bLoadSuccess = false;
}
if( !bLoadSuccess )
ZZLog::Error_Log("Failed to create CRTC shaders.");
// if (!LOAD_PS(empty_macro, "CRTC24PS", ppsCRTC24[0], 0)) bLoadSuccess = false;
// if (!LOAD_PS(empty_macro, "CRTC24InterPS", ppsCRTC24[1], 0)) bLoadSuccess = false;
if (!LOAD_PS(empty_macro, "ZeroPS", ppsOne, 0)) bLoadSuccess = false;
if (!LOAD_PS(empty_macro, "BaseTexturePS", ppsBaseTexture, 0)) bLoadSuccess = false;
if (!LOAD_PS(empty_macro, "Convert16to32PS", ppsConvert16to32, 0)) bLoadSuccess = false;
if (!LOAD_PS(empty_macro, "Convert32to16PS", ppsConvert32to16, 0)) bLoadSuccess = false;
// DEBUG
// if (!LOAD_PS(empty_macro, "ZeroDebugPS", ppsDebug, 0)) bLoadSuccess = false;
// if (!LOAD_PS(empty_macro, "ZeroDebug2PS", ppsDebug2, 0)) bLoadSuccess = false;
GL_REPORT_ERRORD();
return true;
}
FRAGMENTSHADER* ZZshLoadShadeEffect(int type, int texfilter, int fog, int testaem, int exactcolor, const clampInfo& clamp, int context, bool* pbFailed)
{
int texwrap;
assert( texfilter < NUM_FILTERS );
if( clamp.wms == clamp.wmt ) {
switch( clamp.wms ) {
case 0: texwrap = TEXWRAP_REPEAT; break;
case 1: texwrap = TEXWRAP_CLAMP; break;
case 2: texwrap = TEXWRAP_CLAMP; break;
default:
texwrap = TEXWRAP_REGION_REPEAT; break;
}
}
else if( clamp.wms==3||clamp.wmt==3)
texwrap = TEXWRAP_REGION_REPEAT;
else
texwrap = TEXWRAP_REPEAT_CLAMP;
int index = GET_SHADER_INDEX(type, texfilter, texwrap, fog, s_bWriteDepth, testaem, exactcolor, context, 0);
if( pbFailed != NULL ) *pbFailed = false;
FRAGMENTSHADER* pf = ppsTexture+index;
if (ZZshExistProgram(pf))
{
return pf;
}
std::string macro = BuildGlslMacro(s_bWriteDepth, texwrap, testaem, exactcolor);
std::string main_entry = format("Texture%s%d_%sPS", fog?"Fog":"", texfilter, g_pTexTypes[type]);
pf->context = context * NOCONTEXT;
if (!CompileShaderFromFile(pf->program, macro, main_entry, GL_FRAGMENT_SHADER)) {
ZZLog::Error_Log("Failed to create shader %d,%d,%d,%d.", type, fog, texfilter, 4*clamp.wms+clamp.wmt);
if( pbFailed != NULL ) *pbFailed = false;
return NULL;
}
return pf;
}
#endif // GLSL4_API

View File

@ -101,7 +101,7 @@ bool SaveRenderTarget(const char* filename, int width, int height, int jpeg)
} }
// Save selected texture as TGA // Save selected texture as TGA
bool SaveTexture(const char* filename, u32 textarget, u32 tex, int width, int height) bool SaveTexture(const char* filename, u32 textarget, u32 tex, int width, int height, int ext_format)
{ {
vector<u32> data(width*height); vector<u32> data(width*height);
glBindTexture(textarget, tex); glBindTexture(textarget, tex);
@ -109,7 +109,20 @@ bool SaveTexture(const char* filename, u32 textarget, u32 tex, int width, int he
if (glGetError() != GL_NO_ERROR) return false; if (glGetError() != GL_NO_ERROR) return false;
return SaveTGA(filename, width, height, &data[0]); if (ext_format == EXT_BMP)
return SaveBMP(filename, width, height, &data[0]);
else if (ext_format == EXT_TGA)
return SaveTGA(filename, width, height, &data[0]);
else
return false;
}
// Save image as BMP
bool SaveBMP(const char* filename, int width, int height, void* pdata)
{
// FIXME
assert(0);
return false;
} }
// save image as JPEG // save image as JPEG

View File

@ -22,9 +22,10 @@
void SaveSnapshot(const char* filename); void SaveSnapshot(const char* filename);
bool SaveRenderTarget(const char* filename, int width, int height, int jpeg); bool SaveRenderTarget(const char* filename, int width, int height, int jpeg);
bool SaveTexture(const char* filename, u32 textarget, u32 tex, int width, int height); bool SaveTexture(const char* filename, u32 textarget, u32 tex, int width, int height, int ext_format = 0);
bool SaveJPEG(const char* filename, int width, int height, const void* pdata, int quality); bool SaveJPEG(const char* filename, int width, int height, const void* pdata, int quality);
bool SaveTGA(const char* filename, int width, int height, void* pdata); bool SaveTGA(const char* filename, int width, int height, void* pdata);
bool SaveBMP(const char* filename, int width, int height, void* pdata);
void Stop_Avi(); void Stop_Avi();
void Delete_Avi_Capture(); void Delete_Avi_Capture();
@ -32,4 +33,10 @@ void StartCapture();
void StopCapture(); void StopCapture();
void CaptureFrame(); void CaptureFrame();
enum {
EXT_TGA = 0,
EXT_BMP = 1,
EXT_JPG = 2
};
#endif // ZZOGLSHOOTS_H_INCLUDED #endif // ZZOGLSHOOTS_H_INCLUDED

View File

@ -1,4 +1,20 @@
// Cg Shaders for PS2 GS emulation // ZZ Open GL graphics plugin
// Copyright (c)2009-2010 zeydlitz@gmail.com, arcum42@gmail.com
// Based on Zerofrog's ZeroGS KOSMOS (c)2005-2008
//
// 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 of the License, 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 this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
// divides by z for every pixel, instead of in vertex shader // divides by z for every pixel, instead of in vertex shader
// fixes kh textures // fixes kh textures

View File

@ -0,0 +1,939 @@
//#version 420 Keep it for text editor detection
// ZZ Open GL graphics plugin
// Copyright (c)2009-2010 zeydlitz@gmail.com, arcum42@gmail.com, gregory.hainaut@gmail.com
// Based on Zerofrog's ZeroGS KOSMOS (c)2005-2008
//
// 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 of the License, 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 this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
// divides by z for every pixel, instead of in vertex shader
// fixes kh textures
#extension ARB_texture_rectangle: require
#extension GL_ARB_shading_language_420pack: require
#extension GL_ARB_separate_shader_objects : require
// Set with version macro
// #define GL_compatibility_profile 1
#define PERSPECTIVE_CORRECT_TEX
// When writting GLSL code we should change variables in code according to denominator
// Not than in and out variables are differ!
// in POSITION set by glVertexPointer goes to gl_Vertex;
// out POSITION goes to gl_position
// in COLOR0 gl_Color
// out COLOR0 gl_FrontColor
// in TEXCOORD0 gl_MultiTexCoord0
// out TEXCOORD0 gl_TexCoord[0]
//in Fragments:
// in TEXCOORD0 gl_TexCoord[0]
// out COLOR0 gl_FragData[0]
//#define TEST_AEM // tests AEM for black pixels
//#define REGION_REPEAT // set if texture wrapping mode is region repeat
//#define WRITE_DEPTH // set if depth is also written in a MRT
//#define ACCURATE_DECOMPRESSION // set for less capable hardware ATI Radeon 9000 series
//#define EXACT_COLOR // make sure the output color is clamped to 1/255 boundaries (for alpha testing)
#ifdef PERSPECTIVE_CORRECT_TEX
#define TEX_XY tex.xy/tex.z
#define TEX_DECL vec4
#else
#define TEX_XY tex.xy
#define TEX_DECL vec4
#endif
// NVidia CG-data types
#define half2 vec2
#define half3 vec3
#define half4 vec4
#define float2 vec2
#define float3 vec3
#define float4 vec4
////////////////////////////////////////////////////////////////////
// INPUT/OUTPUT
////////////////////////////////////////////////////////////////////
// NOTE: Future optimization tex.w is normally useless (in cg it is a float3) so it can contains the fog value
struct vertex
{
vec4 color;
TEX_DECL tex;
vec4 z;
float fog;
};
// VS input (from VBO)
//
// glColorPointer -> gl_Color (color)
// glSecondaryColorPointerEXT -> gl_SecondaryColor (it seems just a way to have another parameter in shader)
// glTexCoordPointer -> gl_MultiTexCoord0 (tex coord)
// glVertexPointer -> gl_Vertex (position)
//
// VS Output (to PS)
// gl_Position (must be kept)
// vertex
//
// FS input (from VS)
// vertex
//
// FS output
// gl_FragData[0]
// gl_FragData[1]
#ifdef VERTEX_SHADER
out gl_PerVertex {
invariant vec4 gl_Position;
float gl_PointSize;
float gl_ClipDistance[];
};
layout(location = 0) in ivec2 Vert;
layout(location = 1) in vec4 Color;
layout(location = 2) in vec4 SecondaryColor;
layout(location = 3) in vec3 TexCoord;
layout(location = 0) out vertex VSout;
/////// return ZZ_SH_CRTC;
// otex0 -> tex
// ointerpos -> z
#endif
#ifdef FRAGMENT_SHADER
layout(location = 0) in vertex PSin;
// FIXME: host only do glDrawBuffers of 1 buffers not 2. I think this is a major bug
layout(location = 0) out vec4 FragData0;
layout(location = 1) out vec4 FragData1;
#endif
////////////////////////////////////////////////////////////////////
// Texture SAMPLER
////////////////////////////////////////////////////////////////////
// // main ps2 memory, each pixel is stored in 32bit color
// uniform sampler2DRect g_sMemory[2];
//
// // used to get the tiled offset into a page given the linear offset
// uniform sampler2DRect g_sSrcFinal;
// uniform sampler2D g_sBlocks;
// uniform sampler2D g_sBilinearBlocks;
// uniform sampler2D g_sConv16to32;
// uniform sampler3D g_sConv32to16;
// uniform sampler2DRect g_sBitwiseANDX;
// uniform sampler2DRect g_sBitwiseANDY;
// uniform sampler2DRect g_sInterlace;
//
// // used only on rare cases where the render target is PSMT8H
// uniform sampler2D g_sCLUT;
// main ps2 memory, each pixel is stored in 32bit color
layout(binding = 10) uniform sampler2DRect g_sMemory; // dual context
// used to get the tiled offset into a page given the linear offset
layout(binding = 1) uniform sampler2DRect g_sSrcFinal;
layout(binding = 2) uniform sampler2D g_sBlocks;
layout(binding = 3) uniform sampler2D g_sBilinearBlocks;
layout(binding = 4) uniform sampler2D g_sConv16to32;
layout(binding = 5) uniform sampler3D g_sConv32to16;
layout(binding = 6) uniform sampler2DRect g_sBitwiseANDX;
layout(binding = 7) uniform sampler2DRect g_sBitwiseANDY;
layout(binding = 8) uniform sampler2DRect g_sInterlace;
// used only on rare cases where the render target is PSMT8H
layout(binding = 9) uniform sampler2D g_sCLUT;
////////////////////////////////////////////////////////////////////
// UNIFORM BUFFER
////////////////////////////////////////////////////////////////////
layout(std140, binding = 0) uniform constant_buffer
{
// Both shader
// .z is used for the addressing fn
// FIXME: not same value between c and shader...
// float4 g_fBilinear = float4(-0.7f, -0.65f, 0.9,1/32767.0f);
float4 g_fBilinear;
float4 g_fZBias;
float4 g_fc0;
float4 g_fMult;
// Vertex
float4 g_fZ; // transforms d3dcolor z into float z
float4 g_fZMin;
float4 g_fZNorm;
// Pixel
half4 g_fExactColor;
};
layout(std140, binding = 1) uniform common_buffer
{
float4 g_fPosXY;
float4 g_fFogColor;
};
layout(std140, binding = 2) uniform vertex_buffer
{
float4 g_fBitBltPos;
float4 g_fBitBltTex;
float4 g_fBitBltTrans;
};
layout(std140, binding = 3) uniform fragment_buffer
{
half4 fTexAlpha2;
float4 g_fTexOffset; // converts the page and block offsets into the mem addr/1024
float4 g_fTexDims; // mult by tex dims when accessing the block texture
float4 g_fTexBlock;
float4 g_fClampExts; // if clamping the texture, use (minu, minv, maxu, maxv)
float4 TexWrapMode; // 0 - repeat/clamp, 1 - region rep (use fRegRepMask)
float4 g_fRealTexDims; // tex dims used for linear filtering (w,h,1/w,1/h)
// (alpha0, alpha1, 1 if highlight2 and tcc is rgba, 1-y)
half4 g_fTestBlack; // used for aem bit
float4 g_fPageOffset;
half4 fTexAlpha;
float4 g_fInvTexDims; // similar to g_fClutOff
// used for rectblitting
float4 g_fBitBltZ;
half4 g_fOneColor; // col*.xxxy+.zzzw
};
// given a local tex coord, returns the coord in the memory
float2 ps2memcoord(float2 realtex)
{
float4 off;
// block off
realtex.xy = realtex.xy * g_fTexDims.xy + g_fTexDims.zw;
realtex.xy = (realtex.xy - fract(realtex.xy)) * g_fMult.zw;
float2 fblock = fract(realtex.xy);
off.xy = realtex.xy-fblock.xy;
#ifdef ACCURATE_DECOMPRESSION
off.zw = texture(g_sBlocks, g_fTexBlock.xy*fblock + g_fTexBlock.zw).ar;
off.x = dot(off.xy, g_fTexOffset.xy);
float r = g_fTexOffset.w;
float f = fract(off.x);
float fadd = g_fTexOffset.z * off.z;
off.w = off.x + fadd + r;
off.x = fract(f + fadd + r);
off.w -= off.x ;
#else
off.z = texture(g_sBlocks, g_fTexBlock.xy*fblock + g_fTexBlock.zw).a;
// combine the two
off.x = dot(off.xyz, g_fTexOffset.xyz)+g_fTexOffset.w;
off.x = modf(off.x, off.w);
#endif
off.xy = off.xw * g_fPageOffset.zy + g_fPageOffset.wx;
//off.y = off.w * g_fPageOffset.y + g_fPageOffset.x;
return off.xy;
}
// find all texcoords for bilinear filtering
// assume that orgtex are already on boundaries
void ps2memcoord4(float4 orgtex, out float4 off0, out float4 off1)
{
//float4 off0, off1, off2, off3;
float4 realtex;
// block off
realtex = (orgtex * g_fTexDims.xyxy + g_fTexDims.zwzw);// * g_fMult.zwzw;
float4 fblock = fract(realtex.xyzw);
float4 ftransblock = g_fTexBlock.xyxy*fblock + g_fTexBlock.zwzw;
realtex -= fblock;
float4 transvals = g_fTexOffset.x * realtex.xzxz + g_fTexOffset.y * realtex.yyww + g_fTexOffset.w;
float4 colors;// = texture(g_sBilinearBlocks, ftransblock.xy);
// this is faster on ffx ingame
colors.x = texture(g_sBlocks, ftransblock.xy).a;
colors.y = texture(g_sBlocks, ftransblock.zy).a;
colors.z = texture(g_sBlocks, ftransblock.xw).a;
colors.w = texture(g_sBlocks, ftransblock.zw).a;
float4 fr, rem;
#ifdef ACCURATE_DECOMPRESSION
fr = fract(transvals);
float4 fadd = colors * g_fTexOffset.z;
rem = transvals + fadd;
fr = fract(fr + fadd);
rem -= fr;
#else
transvals += colors * g_fTexOffset.z;
fr = modf(transvals, rem);
#endif
rem = rem * g_fPageOffset.y + g_fPageOffset.x;
fr = fr * g_fPageOffset.z + g_fPageOffset.w;
// combine
off0 = g_fc0.yxyx * fr.xxyy + g_fc0.xyxy * rem.xxyy;
off1 = g_fc0.yxyx * fr.zzww + g_fc0.xyxy * rem.zzww;
}
void ps2memcoord4_fast(float4 orgtex, out float4 off0, out float4 off1)
{
float4 realtex;
realtex = (orgtex * g_fTexDims.xyxy + g_fTexDims.zwzw);// * g_fMult.zwzw;
float4 fblock = fract(realtex.xyzw);
float2 ftransblock = g_fTexBlock.xy*fblock.xy + g_fTexBlock.zw;
realtex -= fblock;
float4 transvals = g_fTexOffset.x * realtex.xzxz + g_fTexOffset.y * realtex.yyww + g_fTexOffset.w;
float4 colors = texture(g_sBilinearBlocks, ftransblock.xy);
float4 fr, rem;
#ifdef ACCURATE_DECOMPRESSION
fr = fract(transvals);
float4 fadd = colors * g_fTexOffset.z;
rem = transvals + fadd;
fr = fract(fr + fadd);
rem -= fr;
#else
transvals += colors * g_fTexOffset.z;
fr = modf(transvals, rem);
#endif
rem = rem * g_fPageOffset.y + g_fPageOffset.x;
fr = fr * g_fPageOffset.z;
off0 = g_fc0.yxyx * fr.xxyy + g_fc0.xyxy * rem.xxyy;
off1 = g_fc0.yxyx * fr.zzww + g_fc0.xyxy * rem.zzww;
}
// Wrapping modes
#if defined(REPEAT)
float2 ps2addr(float2 coord)
{
return fract(coord.xy);
}
#elif defined(CLAMP)
float2 ps2addr(float2 coord)
{
return clamp(coord.xy, g_fClampExts.xy, g_fClampExts.zw);
}
#elif defined(REGION_REPEAT)
// computes the local tex coord along with addressing modes
float2 ps2addr(float2 coord)
{
float2 final = fract(clamp(coord.xy, g_fClampExts.xy, g_fClampExts.zw));
if( TexWrapMode.x > g_fBilinear.z ) // region repeat mode for x (umsk&x)|ufix
final.x = texture(g_sBitwiseANDX, abs(coord.x)*TexWrapMode.zx).x * g_fClampExts.x + g_fClampExts.z;
if( TexWrapMode.y > g_fBilinear.z ) // region repeat mode for x (vmsk&x)|vfix
final.y = texture(g_sBitwiseANDY, abs(coord.y)*TexWrapMode.wy).x * g_fClampExts.y + g_fClampExts.w;
return final;
}
#else
float2 ps2addr(float2 coord)
{
return fract(clamp(coord.xy, g_fClampExts.xy, g_fClampExts.zw));
}
#endif
half4 tex2DPS_32(float2 tex0)
{
return texture(g_sMemory, ps2memcoord(tex0).xy);
}
// use when texture is not tiled -- shader 1
half4 tex2DPS_tex32(float2 tex0)
{
return texture(g_sMemory, g_fTexDims.xy*tex0+g_fTexDims.zw)*g_fZBias.zzzw+g_fPageOffset.w;
}
// use when texture is not tiled -- shader 2
half4 tex2DPS_clut32(float2 tex0)
{
float index = texture(g_sMemory, g_fTexDims.xy*tex0+g_fTexDims.zw).a+g_fPageOffset.w;
return texture(g_sCLUT, index*g_fExactColor.xz+g_fExactColor.yz);
}
// Shader 3
// use when texture is not tiled and converting from 32bit to 16bit
// don't convert on the block level, only on the column level
// so every other 8 pixels, use the upper bits instead of lower
half4 tex2DPS_tex32to16(float2 tex0)
{
bool upper = false;
tex0.y += g_fPageOffset.z;
float2 ffrac = mod(tex0, g_fTexOffset.xy);
tex0.xy = g_fc0.ww * (tex0.xy + ffrac);
if( ffrac.x > g_fTexOffset.z ) {
tex0.x -= g_fTexOffset.z;
upper = true;
}
if( ffrac.y >= g_fTexOffset.w ) {
tex0.y -= g_fTexOffset.w;
tex0.x += g_fc0.w;
}
half4 color = texture(g_sMemory, g_fTexDims.xy*tex0+g_fTexDims.zw)*g_fZBias.zzzw+g_fPageOffset.w;
float2 uv = upper ? color.xw : color.zy;
return texture(g_sConv16to32, uv+g_fPageOffset.xy);
}
// Shader 4
// used when a 16 bit texture is used an 8h
half4 tex2DPS_tex16to8h(float2 tex0)
{
float4 final;
float2 ffrac = mod(tex0+g_fPageOffset.zw, g_fTexOffset.xy);
tex0.xy = g_fPageOffset.xy * tex0.xy - ffrac * g_fc0.yw;
if( ffrac.x > g_fTexOffset.x*g_fc0.w )
tex0.x += g_fTexOffset.x*g_fc0.w;
if( tex0.x >= g_fc0.y ) tex0 += g_fTexOffset.zw;
float4 upper = texture(g_sMemory, g_fTexDims.xy*tex0+g_fTexDims.zw);
// only need alpha
float index = texture(g_sConv32to16, upper.zyx-g_fc0.z).y + upper.w*g_fc0.w*g_fc0.w;
return texture(g_sCLUT, index+g_fExactColor.yz);
}
// Shader 5
// used when a 16 bit texture is used a 32bit one
half4 tex2DPS_tex16to32(float2 tex0)
{
float4 final;
float2 ffrac = mod(tex0+g_fPageOffset.zw, g_fTexOffset.xy);
//tex0.xy = g_fPageOffset.xy * tex0.xy - ffrac * g_fc0.yw;
tex0.y += g_fPageOffset.y * ffrac.y;
if( ffrac.x > g_fTexOffset.z ) {
tex0.x -= g_fTexOffset.z;
tex0.y += g_fTexOffset.w;
}
float fconst = g_fc0.w*g_fc0.w;
float4 lower = texture(g_sSrcFinal, g_fTexDims.xy*tex0);
float4 upper = texture(g_sMemory, g_fTexDims.xy*tex0+g_fTexDims.zw);
final.zy = texture(g_sConv32to16, lower.zyx).xy + lower.ww*fconst;
final.xw = texture(g_sConv32to16, upper.zyx).xy + upper.ww*fconst;
return final;
}
half4 tex2DPS_tex16to32h(float2 tex0)
{
float4 final = vec4(0.0, 0.0, 0.0, 0.0);
return final;
}
//half4 f;
//f.w = old.y > (127.2f/255.0f) ? 1 : 0;
//old.y -= 0.5f * f.w;
//f.xyz = fract(old.yyx*half3(2.002*255.0f/256.0f, 64.025f*255.0f/256.0f, 8.002*255.0f/256.0f));
//f.y += old.x * (0.25f*255.0f/256.0f);
////////////////////////////////
// calculates the texture color
////////////////////////////////
#define decl_ps2shade(num) \
decl_ps2shade_##num(_32) \
decl_ps2shade_##num(_tex32) \
decl_ps2shade_##num(_clut32) \
decl_ps2shade_##num(_tex32to16) \
decl_ps2shade_##num(_tex16to8h) \
decl_ps2shade_##num(_tex16to32h)
// nearest
#define decl_ps2shade_0(bit) \
float4 ps2shade0##bit( TEX_DECL tex) \
{ \
return tex2DPS##bit( ps2addr(TEX_XY)); \
}
// do fast memcoord4 calcs when textures behave well
#ifdef REPEAT
#define PS2MEMCOORD4 ps2memcoord4
#else
#define PS2MEMCOORD4 ps2memcoord4
#endif
#define decl_BilinearFilter(bit, addrfn) \
half4 BilinearFilter##bit(float2 tex0) \
{ \
float4 off0, off1; \
float4 ftex; \
float2 ffrac; \
ftex.xy = tex0 + g_fBilinear.xy * g_fRealTexDims.zw; \
ffrac = fract(ftex.xy*g_fRealTexDims.xy); \
ftex.xy -= ffrac.xy * g_fRealTexDims.zw; \
\
ftex.zw = ps2addr(ftex.xy + g_fRealTexDims.zw); \
ftex.xy = ps2addr(ftex.xy); \
\
PS2MEMCOORD4(ftex, off0, off1); \
half4 c0 = texture(g_sMemory, off0.xy); \
half4 c1 = texture(g_sMemory, off0.zw); \
half4 c2 = texture(g_sMemory, off1.xy); \
half4 c3 = texture(g_sMemory, off1.zw); \
return mix( mix(c0, c1, vec4(ffrac.x)), mix(c2, c3, ffrac.x), vec4(ffrac.y) ); \
}
decl_BilinearFilter(_32, ps2addr)
decl_BilinearFilter(_tex32, ps2addr)
decl_BilinearFilter(_clut32, ps2addr)
decl_BilinearFilter(_tex32to16, ps2addr)
decl_BilinearFilter(_tex16to8h, ps2addr)
decl_BilinearFilter(_tex16to32h, ps2addr)
//TODO! For mip maps, only apply when LOD >= 0
// lcm == 0, LOD = log(1/Q)*L + K, lcm == 1, LOD = K
// bilinear
#define decl_ps2shade_1(bit) \
half4 ps2shade1##bit(TEX_DECL tex) \
{ \
return BilinearFilter##bit(TEX_XY); \
}
// nearest, mip nearest
#define decl_ps2shade_2(bit) \
half4 ps2shade2##bit(TEX_DECL tex) \
{ \
return tex2DPS##bit( ps2addr(TEX_XY)); \
}
// nearest, mip linear
#define decl_ps2shade_3(bit) \
half4 ps2shade3##bit(TEX_DECL tex) \
{ \
return tex2DPS##bit(ps2addr(TEX_XY)); \
}
// linear, mip nearest
#define decl_ps2shade_4(bit) \
half4 ps2shade4##bit(TEX_DECL tex) \
{ \
return BilinearFilter##bit(TEX_XY); \
}
// linear, mip linear
#define decl_ps2shade_5(bit) \
half4 ps2shade5##bit(TEX_DECL tex) \
{ \
return BilinearFilter##bit(TEX_XY); \
}
decl_ps2shade(0)
decl_ps2shade(1)
decl_ps2shade(2)
decl_ps2shade(3)
decl_ps2shade(4)
decl_ps2shade(5)
half4 ps2CalcShade(half4 texcol, half4 color)
{
#ifdef TEST_AEM
if( dot(texcol.xyzw, g_fTestBlack.xyzw) <= g_fc0.z )
texcol.w = g_fc0.x;
else
#endif
texcol.w = texcol.w * fTexAlpha.y + fTexAlpha.x;
texcol = texcol * (fTexAlpha2.zzzw * color + fTexAlpha2.xxxy) + fTexAlpha.zzzw * color.wwww;
return texcol;
}
// final ops on the color
#ifdef EXACT_COLOR
half4 ps2FinalColor(half4 col)
{
// g_fOneColor has to scale by 255
half4 temp = col * g_fOneColor.xxxy + g_fOneColor.zzzw;
temp.w = floor(temp.w)*g_fExactColor.w;
return temp;
}
#else
half4 ps2FinalColor(half4 col)
{
return col * g_fOneColor.xxxy + g_fOneColor.zzzw;
}
#endif
#ifdef FRAGMENT_SHADER // This is code only for FRAGMENTS (pixel shader)
#ifdef WRITE_DEPTH
void write_depth_target(vec4 z)
{
FragData1 = z;
}
#else
void write_depth_target(vec4 z) { }
#endif
void RegularPS() {
// whenever outputting depth, make sure to mult by 255/256 and 1
FragData0 = ps2FinalColor(PSin.color);
write_depth_target(PSin.z);
}
#define DECL_TEXPS(num, bit) \
void Texture##num##bit##PS() \
{ \
FragData0 = ps2FinalColor(ps2CalcShade(ps2shade##num##bit(PSin.tex), PSin.color)); \
write_depth_target(PSin.z); \
}
#define DECL_TEXPS_(num) \
DECL_TEXPS(num, _32) \
DECL_TEXPS(num, _tex32) \
DECL_TEXPS(num, _clut32) \
DECL_TEXPS(num, _tex32to16) \
DECL_TEXPS(num, _tex16to8h)
DECL_TEXPS_(0)
DECL_TEXPS_(1)
DECL_TEXPS_(2)
DECL_TEXPS_(3)
DECL_TEXPS_(4)
DECL_TEXPS_(5)
void RegularFogPS() {
half4 c;
c.xyz = mix(g_fFogColor.xyz, PSin.color.xyz, vec3(PSin.fog));
c.w = PSin.color.w;
FragData0 = ps2FinalColor(c);
write_depth_target(PSin.z);
}
#define DECL_TEXFOGPS(num, bit) \
void TextureFog##num##bit##PS() \
{ \
half4 c = ps2CalcShade(ps2shade##num##bit(PSin.tex), PSin.color); \
c.xyz = mix(g_fFogColor.xyz, c.xyz, vec3(PSin.fog)); \
FragData0 = ps2FinalColor(c); \
write_depth_target(PSin.z); \
}
#define DECL_TEXFOGPS_(num) \
DECL_TEXFOGPS(num, _32) \
DECL_TEXFOGPS(num, _tex32) \
DECL_TEXFOGPS(num, _clut32) \
DECL_TEXFOGPS(num, _tex32to16) \
DECL_TEXFOGPS(num, _tex16to8h)
DECL_TEXFOGPS_(0)
DECL_TEXFOGPS_(1)
DECL_TEXFOGPS_(2)
DECL_TEXFOGPS_(3)
DECL_TEXFOGPS_(4)
DECL_TEXFOGPS_(5)
//-------------------------------------------------------
// Techniques not related to the main primitive commands
half4 BilinearBitBlt(float2 tex0)
{
float4 ftex;
float2 ffrac;
ffrac.xy = fract(tex0*g_fRealTexDims.xy);
ftex.xy = tex0 - ffrac.xy * g_fRealTexDims.zw;
ftex.zw = ftex.xy + g_fRealTexDims.zw;
float4 off0, off1;
ps2memcoord4_fast(ftex, off0, off1);
half4 c0 = texture(g_sMemory, off0.xy);
half4 c1 = texture(g_sMemory, off0.zw);
half4 c2 = texture(g_sMemory, off1.xy);
half4 c3 = texture(g_sMemory, off1.zw);
return mix( mix(c0, c1, vec4(ffrac.x)), mix(c2, c3, vec4(ffrac.x)), vec4(ffrac.y) );
}
void BitBltPS() {
FragData0 = texture(g_sMemory, ps2memcoord(PSin.tex.xy).xy)*g_fOneColor.xxxy;
}
// used when AA
void BitBltAAPS() {
FragData0 = BilinearBitBlt(PSin.tex.xy) * g_fOneColor.xxxy;
}
void BitBltDepthPS() {
vec4 data;
data = texture(g_sMemory, ps2memcoord(PSin.tex.xy));
FragData0 = data + g_fZBias.y;
gl_FragDepth = (log(g_fc0.y + dot(data, g_fBitBltZ)) * g_fOneColor.w) * g_fZMin.y + dot(data, g_fBitBltZ) * g_fZMin.x ;
}
void BitBltDepthMRTPS() {
vec4 data;
data = texture(g_sMemory, ps2memcoord(PSin.tex.xy));
FragData0 = data + g_fZBias.y;
FragData1.x = g_fc0.x;
gl_FragDepth = (log(g_fc0.y + dot(data, g_fBitBltZ)) * g_fOneColor.w) * g_fZMin.y + dot(data, g_fBitBltZ) * g_fZMin.x ;
}
// static const float BlurKernel[9] = {
// 0.027601,
// 0.066213,
// 0.123701,
// 0.179952,
// 0.205065,
// 0.179952,
// 0.123701,
// 0.066213,
// 0.027601
// };
half4 BilinearFloat16(float2 tex0)
{
return texture(g_sSrcFinal, tex0.xy);
}
void CRTCTargInterPS() {
float finter = texture(g_sInterlace, PSin.z.yy).x * g_fOneColor.z + g_fOneColor.w + g_fc0.w;
float4 c = BilinearFloat16(PSin.tex.xy);
c.w = ( g_fc0.w*c.w * g_fOneColor.x + g_fOneColor.y ) * finter;
FragData0 = c;
}
void CRTCTargPS() {
float4 c = BilinearFloat16(PSin.tex.xy);
// FIXME DEBUG: to validate tex coord on blit
//c = vec4(PSin.tex.x/512.0f, PSin.tex.y/512.0f, 0.0, 1.0);
c.w = g_fc0.w * c.w * g_fOneColor.x + g_fOneColor.y;
FragData0 = c;
}
void CRTCInterPS() {
float finter = texture(g_sInterlace, PSin.z.yy).x * g_fOneColor.z + g_fOneColor.w + g_fc0.w;
float2 filtcoord = trunc(PSin.tex.xy) * g_fInvTexDims.xy + g_fInvTexDims.zw;
half4 c = BilinearBitBlt(filtcoord);
c.w = (c.w * g_fOneColor.x + g_fOneColor.y)*finter;
FragData0 = c;
}
// simpler
void CRTCInterPS_Nearest() {
float finter = texture(g_sInterlace, PSin.z.yy).x * g_fOneColor.z + g_fOneColor.w + g_fc0.w;
half4 c = texture(g_sMemory, ps2memcoord(PSin.tex.xy).xy);
c.w = (c.w * g_fOneColor.x + g_fOneColor.y)*finter;
FragData0 = c;
}
void CRTCPS() {
float2 filtcoord = PSin.tex.xy * g_fInvTexDims.xy+g_fInvTexDims.zw;
half4 c = BilinearBitBlt(filtcoord);
c.w = c.w * g_fOneColor.x + g_fOneColor.y;
FragData0 = c;
}
// simpler
void CRTCPS_Nearest() {
half4 c = texture(g_sMemory, ps2memcoord(PSin.tex.xy).xy);
c.w = c.w * g_fOneColor.x + g_fOneColor.y;
FragData0 = c;
}
void CRTC24InterPS() {
float finter = texture(g_sInterlace, PSin.z.yy).x * g_fOneColor.z + g_fOneColor.w + g_fc0.w;
float2 filtcoord = trunc(PSin.tex.xy) * g_fInvTexDims.xy + g_fInvTexDims.zw;
half4 c = texture(g_sMemory, ps2memcoord(filtcoord).xy);
c.w = (c.w * g_fOneColor.x + g_fOneColor.y)*finter;
FragData0 = c;
}
void CRTC24PS() {
float2 filtcoord = trunc(PSin.tex.xy) * g_fInvTexDims.xy + g_fInvTexDims.zw;
half4 c = texture(g_sMemory, ps2memcoord(filtcoord).xy);
c.w = c.w * g_fOneColor.x + g_fOneColor.y;
FragData0 = c;
}
void ZeroPS() {
FragData0 = g_fOneColor;
}
void ZeroDebugPS() {
FragData0 = vec4(0.0, 1.0, 0.0, 0.5);
//FragData0 = vec4(PSin.position.x, PSin.position.y, 1.0, 0.5);
}
void ZeroDebug2PS() {
FragData0 = vec4(1.0, 0.0, 0.0, 0.5);
}
void BaseTexturePS() {
FragData0 = texture(g_sSrcFinal, PSin.tex.xy) * g_fOneColor;
}
void Convert16to32PS() {
float4 final;
float2 ffrac = mod ( PSin.tex.xy + g_fTexDims.zw, g_fTexOffset.xy);
float2 tex0 = g_fTexDims.xy * PSin.tex.xy - ffrac * g_fc0.yw;
if (ffrac.x > g_fTexOffset.x*g_fc0.w)
tex0.x += g_fTexOffset.x*g_fc0.w;
if (tex0.x >= g_fc0.y)
tex0 += g_fTexOffset.zw;
float4 lower = texture(g_sSrcFinal, tex0);
float4 upper = texture(g_sSrcFinal, tex0 + g_fPageOffset.xy);
final.zy = texture(g_sConv32to16, lower.zyx).xy + lower.ww*g_fPageOffset.zw;
final.xw = texture(g_sConv32to16, upper.zyx).xy + upper.ww*g_fPageOffset.zw;
FragData0= final;
}
// use when texture is not tiled and converting from 32bit to 16bit
// don't convert on the block level, only on the column level
// so every other 8 pixels, use the upper bits instead of lower
void Convert32to16PS() {
bool upper = false;
float2 ffrac = mod(PSin.tex.xy + g_fTexDims.zw, g_fTexOffset.xy);
float2 tex0 = g_fc0.ww * (PSin.tex.xy + ffrac);
if( ffrac.x > g_fTexOffset.z ) {
tex0.x -= g_fTexOffset.z;
upper = true;
}
if( ffrac.y >= g_fTexOffset.w ) {
tex0.y -= g_fTexOffset.w;
tex0.x += g_fc0.w;
}
half4 color = texture(g_sSrcFinal, tex0*g_fTexDims.xy)*g_fc0.yyyw;
float2 uv = upper ? color.xw : color.zy;
FragData0 = texture(g_sConv16to32, uv*g_fPageOffset.xy+g_fPageOffset.zw)*g_fTexDims.xxxy;
}
#endif //FRAGMENT_SHADER
#ifdef VERTEX_SHADER
void SetColor() {
VSout.color = Color;
}
void SetTex() {
#ifdef PERSPECTIVE_CORRECT_TEX
VSout.tex.xyz = TexCoord.xyz;
#else
VSout.tex.xy = TexCoord.xy/TexCoord.z;
#endif
}
void SetZ() {
#ifdef WRITE_DEPTH
VSout.z = SecondaryColor * g_fZBias.x + g_fZBias.y;
VSout.z.w = g_fc0.y;
#endif
}
float SetPosition() {
float4 position;
position.xy = vec2(Vert.xy) * g_fPosXY.xy + g_fPosXY.zw;
// FIXME: the factor in normal mode seem bogus. They don't have same order than in log mode. Or I failed to understand the logic
//// normal mode.
// -> dot(g_fZ, SecondaryColor.zyxw)) => reconstruct a float from normalized char. The float range from 0 to 1
// position.z = dot(g_fZ, SecondaryColor.zyxw);
//// logz mode
// -> dot(g_fZ, SecondaryColor.zyxw)) => reconstruct a float from normalized char. The float range from 0 to 2**32
// position.z = log(g_fc0.y + dot(g_fZ, SecondaryColor.zyxw)) * g_fZNorm.x
// position.z = log(1 + Z_INT) * 0.999f / (32 * log(2.0)) = log2(1 + Z_INT) * 0.999f / 32
// log2(...) will range from 0 to 32
position.z = (log(g_fc0.y + dot(g_fZ, SecondaryColor.zyxw)) * g_fZNorm.x + g_fZNorm.y) * g_fZMin.y + dot(g_fZ, SecondaryColor.zyxw) * g_fZMin.x ;
position.w = g_fc0.y;
gl_Position = position;
// For fog
return position.z;
}
void SetFog(float z) {
VSout.fog = z * g_fBilinear.w;
}
// just smooth shadering
void RegularVS() {
float z = SetPosition();
SetColor();
SetZ();
}
// diffuse texture mapping
void TextureVS() {
float z = SetPosition();
SetColor();
SetTex();
SetZ();
}
void RegularFogVS() {
float z = SetPosition();
SetColor();
SetZ();
SetFog(z);
}
void TextureFogVS() {
float z = SetPosition();
SetColor();
SetTex();
SetZ();
SetFog(z);
}
void BitBltVS() {
vec4 position;
position.xy = vec2(Vert.xy) * g_fBitBltPos.xy + g_fBitBltPos.zw;
position.zw = g_fc0.xy;
gl_Position = position;
VSout.tex.xy = TexCoord.xy * g_fBitBltTex.xy + g_fBitBltTex.zw;
VSout.z.xy = position.xy * g_fBitBltTrans.xy + g_fBitBltTrans.zw;
}
#endif