/contrib/sdk/sources/Mesa/mesa-9.2.5/src/gallium/state_trackers/xorg/Makefile.am |
---|
0,0 → 1,51 |
# Copyright © 2012 Intel Corporation |
# |
# 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 (including the next |
# paragraph) 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. |
include $(top_srcdir)/src/gallium/Automake.inc |
AM_CFLAGS = \ |
$(GALLIUM_CFLAGS) \ |
$(XEXT_CFLAGS) \ |
$(LIBKMS_XORG_CFLAGS) \ |
$(LIBDRM_XORG_CFLAGS) \ |
$(shell $(PKG_CONFIG) --cflags-only-I xorg-server) |
AM_CPPFLAGS = \ |
-I$(top_srcdir)/include \ |
-I$(top_srcdir)/src/mesa \ |
-I$(top_srcdir)/src/mesa/drivers/dri/common \ |
-I$(top_srcdir)/src/mesa/main \ |
-DHAVE_CONFIG_H \ |
-DHAVE_LIBKMS |
noinst_LTLIBRARIES = libxorgtracker.la |
libxorgtracker_la_SOURCES = \ |
xorg_composite.c \ |
xorg_crtc.c \ |
xorg_dri2.c \ |
xorg_driver.c \ |
xorg_exa.c \ |
xorg_exa_tgsi.c \ |
xorg_output.c \ |
xorg_renderer.c \ |
xorg_xv.c \ |
xorg_xvmc.c |
/contrib/sdk/sources/Mesa/mesa-9.2.5/src/gallium/state_trackers/xorg/Makefile.in |
---|
0,0 → 1,810 |
# Makefile.in generated by automake 1.14 from Makefile.am. |
# @configure_input@ |
# Copyright (C) 1994-2013 Free Software Foundation, Inc. |
# This Makefile.in is free software; the Free Software Foundation |
# gives unlimited permission to copy and/or distribute it, |
# with or without modifications, as long as this notice is preserved. |
# This program is distributed in the hope that it will be useful, |
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without |
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
# PARTICULAR PURPOSE. |
@SET_MAKE@ |
# Copyright © 2012 Intel Corporation |
# |
# 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 (including the next |
# paragraph) 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. |
VPATH = @srcdir@ |
am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)' |
am__make_running_with_option = \ |
case $${target_option-} in \ |
?) ;; \ |
*) echo "am__make_running_with_option: internal error: invalid" \ |
"target option '$${target_option-}' specified" >&2; \ |
exit 1;; \ |
esac; \ |
has_opt=no; \ |
sane_makeflags=$$MAKEFLAGS; \ |
if $(am__is_gnu_make); then \ |
sane_makeflags=$$MFLAGS; \ |
else \ |
case $$MAKEFLAGS in \ |
*\\[\ \ ]*) \ |
bs=\\; \ |
sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ |
| sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ |
esac; \ |
fi; \ |
skip_next=no; \ |
strip_trailopt () \ |
{ \ |
flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ |
}; \ |
for flg in $$sane_makeflags; do \ |
test $$skip_next = yes && { skip_next=no; continue; }; \ |
case $$flg in \ |
*=*|--*) continue;; \ |
-*I) strip_trailopt 'I'; skip_next=yes;; \ |
-*I?*) strip_trailopt 'I';; \ |
-*O) strip_trailopt 'O'; skip_next=yes;; \ |
-*O?*) strip_trailopt 'O';; \ |
-*l) strip_trailopt 'l'; skip_next=yes;; \ |
-*l?*) strip_trailopt 'l';; \ |
-[dEDm]) skip_next=yes;; \ |
-[JT]) skip_next=yes;; \ |
esac; \ |
case $$flg in \ |
*$$target_option*) has_opt=yes; break;; \ |
esac; \ |
done; \ |
test $$has_opt = yes |
am__make_dryrun = (target_option=n; $(am__make_running_with_option)) |
am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) |
pkgdatadir = $(datadir)/@PACKAGE@ |
pkgincludedir = $(includedir)/@PACKAGE@ |
pkglibdir = $(libdir)/@PACKAGE@ |
pkglibexecdir = $(libexecdir)/@PACKAGE@ |
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd |
install_sh_DATA = $(install_sh) -c -m 644 |
install_sh_PROGRAM = $(install_sh) -c |
install_sh_SCRIPT = $(install_sh) -c |
INSTALL_HEADER = $(INSTALL_DATA) |
transform = $(program_transform_name) |
NORMAL_INSTALL = : |
PRE_INSTALL = : |
POST_INSTALL = : |
NORMAL_UNINSTALL = : |
PRE_UNINSTALL = : |
POST_UNINSTALL = : |
build_triplet = @build@ |
host_triplet = @host@ |
target_triplet = @target@ |
DIST_COMMON = $(top_srcdir)/src/gallium/Automake.inc \ |
$(srcdir)/Makefile.in $(srcdir)/Makefile.am \ |
$(top_srcdir)/bin/depcomp |
subdir = src/gallium/state_trackers/xorg |
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 |
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_prog_bison.m4 \ |
$(top_srcdir)/m4/ax_prog_cc_for_build.m4 \ |
$(top_srcdir)/m4/ax_prog_cxx_for_build.m4 \ |
$(top_srcdir)/m4/ax_prog_flex.m4 \ |
$(top_srcdir)/m4/ax_pthread.m4 \ |
$(top_srcdir)/m4/ax_python_module.m4 \ |
$(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ |
$(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ |
$(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac |
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ |
$(ACLOCAL_M4) |
mkinstalldirs = $(install_sh) -d |
CONFIG_CLEAN_FILES = |
CONFIG_CLEAN_VPATH_FILES = |
LTLIBRARIES = $(noinst_LTLIBRARIES) |
libxorgtracker_la_LIBADD = |
am_libxorgtracker_la_OBJECTS = xorg_composite.lo xorg_crtc.lo \ |
xorg_dri2.lo xorg_driver.lo xorg_exa.lo xorg_exa_tgsi.lo \ |
xorg_output.lo xorg_renderer.lo xorg_xv.lo xorg_xvmc.lo |
libxorgtracker_la_OBJECTS = $(am_libxorgtracker_la_OBJECTS) |
AM_V_lt = $(am__v_lt_@AM_V@) |
am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) |
am__v_lt_0 = --silent |
am__v_lt_1 = |
AM_V_P = $(am__v_P_@AM_V@) |
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) |
am__v_P_0 = false |
am__v_P_1 = : |
AM_V_GEN = $(am__v_GEN_@AM_V@) |
am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) |
am__v_GEN_0 = @echo " GEN " $@; |
am__v_GEN_1 = |
AM_V_at = $(am__v_at_@AM_V@) |
am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) |
am__v_at_0 = @ |
am__v_at_1 = |
DEFAULT_INCLUDES = -I.@am__isrc@ |
depcomp = $(SHELL) $(top_srcdir)/bin/depcomp |
am__depfiles_maybe = depfiles |
am__mv = mv -f |
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ |
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) |
LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ |
$(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ |
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ |
$(AM_CFLAGS) $(CFLAGS) |
AM_V_CC = $(am__v_CC_@AM_V@) |
am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) |
am__v_CC_0 = @echo " CC " $@; |
am__v_CC_1 = |
CCLD = $(CC) |
LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ |
$(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ |
$(AM_LDFLAGS) $(LDFLAGS) -o $@ |
AM_V_CCLD = $(am__v_CCLD_@AM_V@) |
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) |
am__v_CCLD_0 = @echo " CCLD " $@; |
am__v_CCLD_1 = |
SOURCES = $(libxorgtracker_la_SOURCES) |
DIST_SOURCES = $(libxorgtracker_la_SOURCES) |
am__can_run_installinfo = \ |
case $$AM_UPDATE_INFO_DIR in \ |
n|no|NO) false;; \ |
*) (install-info --version) >/dev/null 2>&1;; \ |
esac |
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) |
# Read a list of newline-separated strings from the standard input, |
# and print each of them once, without duplicates. Input order is |
# *not* preserved. |
am__uniquify_input = $(AWK) '\ |
BEGIN { nonempty = 0; } \ |
{ items[$$0] = 1; nonempty = 1; } \ |
END { if (nonempty) { for (i in items) print i; }; } \ |
' |
# Make sure the list of sources is unique. This is necessary because, |
# e.g., the same source file might be shared among _SOURCES variables |
# for different programs/libraries. |
am__define_uniq_tagged_files = \ |
list='$(am__tagged_files)'; \ |
unique=`for i in $$list; do \ |
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ |
done | $(am__uniquify_input)` |
ETAGS = etags |
CTAGS = ctags |
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) |
ACLOCAL = @ACLOCAL@ |
AMTAR = @AMTAR@ |
AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ |
AR = @AR@ |
AUTOCONF = @AUTOCONF@ |
AUTOHEADER = @AUTOHEADER@ |
AUTOMAKE = @AUTOMAKE@ |
AWK = @AWK@ |
BUILD_EXEEXT = @BUILD_EXEEXT@ |
BUILD_OBJEXT = @BUILD_OBJEXT@ |
CC = @CC@ |
CCAS = @CCAS@ |
CCASDEPMODE = @CCASDEPMODE@ |
CCASFLAGS = @CCASFLAGS@ |
CCDEPMODE = @CCDEPMODE@ |
CC_FOR_BUILD = @CC_FOR_BUILD@ |
CFLAGS = @CFLAGS@ |
CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@ |
CLANG_RESOURCE_DIR = @CLANG_RESOURCE_DIR@ |
CLOCK_LIB = @CLOCK_LIB@ |
CPP = @CPP@ |
CPPFLAGS = @CPPFLAGS@ |
CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@ |
CPP_FOR_BUILD = @CPP_FOR_BUILD@ |
CXX = @CXX@ |
CXXCPP = @CXXCPP@ |
CXXCPPFLAGS_FOR_BUILD = @CXXCPPFLAGS_FOR_BUILD@ |
CXXCPP_FOR_BUILD = @CXXCPP_FOR_BUILD@ |
CXXDEPMODE = @CXXDEPMODE@ |
CXXFLAGS = @CXXFLAGS@ |
CXXFLAGS_FOR_BUILD = @CXXFLAGS_FOR_BUILD@ |
CXX_FOR_BUILD = @CXX_FOR_BUILD@ |
CYGPATH_W = @CYGPATH_W@ |
DEFINES = @DEFINES@ |
DEFINES_FOR_BUILD = @DEFINES_FOR_BUILD@ |
DEFS = @DEFS@ |
DEPDIR = @DEPDIR@ |
DLLTOOL = @DLLTOOL@ |
DLOPEN_LIBS = @DLOPEN_LIBS@ |
DRI2PROTO_CFLAGS = @DRI2PROTO_CFLAGS@ |
DRI2PROTO_LIBS = @DRI2PROTO_LIBS@ |
DRIGL_CFLAGS = @DRIGL_CFLAGS@ |
DRIGL_LIBS = @DRIGL_LIBS@ |
DRI_DRIVER_INSTALL_DIR = @DRI_DRIVER_INSTALL_DIR@ |
DRI_DRIVER_SEARCH_DIR = @DRI_DRIVER_SEARCH_DIR@ |
DRI_LIB_DEPS = @DRI_LIB_DEPS@ |
DRI_PC_REQ_PRIV = @DRI_PC_REQ_PRIV@ |
DSYMUTIL = @DSYMUTIL@ |
DUMPBIN = @DUMPBIN@ |
ECHO_C = @ECHO_C@ |
ECHO_N = @ECHO_N@ |
ECHO_T = @ECHO_T@ |
EGL_CFLAGS = @EGL_CFLAGS@ |
EGL_CLIENT_APIS = @EGL_CLIENT_APIS@ |
EGL_DRIVER_INSTALL_DIR = @EGL_DRIVER_INSTALL_DIR@ |
EGL_LIB_DEPS = @EGL_LIB_DEPS@ |
EGL_LIB_GLOB = @EGL_LIB_GLOB@ |
EGL_LIB_NAME = @EGL_LIB_NAME@ |
EGL_NATIVE_PLATFORM = @EGL_NATIVE_PLATFORM@ |
EGL_PLATFORMS = @EGL_PLATFORMS@ |
EGREP = @EGREP@ |
ELF_LIB = @ELF_LIB@ |
EXEEXT = @EXEEXT@ |
EXPAT_INCLUDES = @EXPAT_INCLUDES@ |
FGREP = @FGREP@ |
FREEDRENO_CFLAGS = @FREEDRENO_CFLAGS@ |
FREEDRENO_LIBS = @FREEDRENO_LIBS@ |
GALLIUM_DRI_LIB_DEPS = @GALLIUM_DRI_LIB_DEPS@ |
GALLIUM_PIPE_LOADER_DEFINES = @GALLIUM_PIPE_LOADER_DEFINES@ |
GALLIUM_PIPE_LOADER_LIBS = @GALLIUM_PIPE_LOADER_LIBS@ |
GALLIUM_PIPE_LOADER_XCB_CFLAGS = @GALLIUM_PIPE_LOADER_XCB_CFLAGS@ |
GALLIUM_PIPE_LOADER_XCB_LIBS = @GALLIUM_PIPE_LOADER_XCB_LIBS@ |
GBM_PC_LIB_PRIV = @GBM_PC_LIB_PRIV@ |
GBM_PC_REQ_PRIV = @GBM_PC_REQ_PRIV@ |
GLAPI_LIB_GLOB = @GLAPI_LIB_GLOB@ |
GLAPI_LIB_NAME = @GLAPI_LIB_NAME@ |
GLESv1_CM_LIB_DEPS = @GLESv1_CM_LIB_DEPS@ |
GLESv1_CM_LIB_GLOB = @GLESv1_CM_LIB_GLOB@ |
GLESv1_CM_LIB_NAME = @GLESv1_CM_LIB_NAME@ |
GLESv1_CM_PC_LIB_PRIV = @GLESv1_CM_PC_LIB_PRIV@ |
GLESv2_LIB_DEPS = @GLESv2_LIB_DEPS@ |
GLESv2_LIB_GLOB = @GLESv2_LIB_GLOB@ |
GLESv2_LIB_NAME = @GLESv2_LIB_NAME@ |
GLESv2_PC_LIB_PRIV = @GLESv2_PC_LIB_PRIV@ |
GLPROTO_CFLAGS = @GLPROTO_CFLAGS@ |
GLPROTO_LIBS = @GLPROTO_LIBS@ |
GLX_TLS = @GLX_TLS@ |
GL_LIB = @GL_LIB@ |
GL_LIB_DEPS = @GL_LIB_DEPS@ |
GL_LIB_GLOB = @GL_LIB_GLOB@ |
GL_LIB_NAME = @GL_LIB_NAME@ |
GL_PC_CFLAGS = @GL_PC_CFLAGS@ |
GL_PC_LIB_PRIV = @GL_PC_LIB_PRIV@ |
GL_PC_REQ_PRIV = @GL_PC_REQ_PRIV@ |
GREP = @GREP@ |
HAVE_XF86VIDMODE = @HAVE_XF86VIDMODE@ |
INDENT = @INDENT@ |
INDENT_FLAGS = @INDENT_FLAGS@ |
INSTALL = @INSTALL@ |
INSTALL_DATA = @INSTALL_DATA@ |
INSTALL_PROGRAM = @INSTALL_PROGRAM@ |
INSTALL_SCRIPT = @INSTALL_SCRIPT@ |
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ |
INTEL_CFLAGS = @INTEL_CFLAGS@ |
INTEL_LIBS = @INTEL_LIBS@ |
LD = @LD@ |
LDFLAGS = @LDFLAGS@ |
LDFLAGS_FOR_BUILD = @LDFLAGS_FOR_BUILD@ |
LEX = @LEX@ |
LEXLIB = @LEXLIB@ |
LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ |
LIBCLC_INCLUDEDIR = @LIBCLC_INCLUDEDIR@ |
LIBCLC_LIBEXECDIR = @LIBCLC_LIBEXECDIR@ |
LIBDRM_CFLAGS = @LIBDRM_CFLAGS@ |
LIBDRM_LIBS = @LIBDRM_LIBS@ |
LIBDRM_XORG_CFLAGS = @LIBDRM_XORG_CFLAGS@ |
LIBDRM_XORG_LIBS = @LIBDRM_XORG_LIBS@ |
LIBKMS_XORG_CFLAGS = @LIBKMS_XORG_CFLAGS@ |
LIBKMS_XORG_LIBS = @LIBKMS_XORG_LIBS@ |
LIBOBJS = @LIBOBJS@ |
LIBS = @LIBS@ |
LIBTOOL = @LIBTOOL@ |
LIBUDEV_CFLAGS = @LIBUDEV_CFLAGS@ |
LIBUDEV_LIBS = @LIBUDEV_LIBS@ |
LIB_DIR = @LIB_DIR@ |
LIPO = @LIPO@ |
LLVM_BINDIR = @LLVM_BINDIR@ |
LLVM_CFLAGS = @LLVM_CFLAGS@ |
LLVM_CONFIG = @LLVM_CONFIG@ |
LLVM_CPPFLAGS = @LLVM_CPPFLAGS@ |
LLVM_CXXFLAGS = @LLVM_CXXFLAGS@ |
LLVM_INCLUDEDIR = @LLVM_INCLUDEDIR@ |
LLVM_LDFLAGS = @LLVM_LDFLAGS@ |
LLVM_LIBDIR = @LLVM_LIBDIR@ |
LLVM_LIBS = @LLVM_LIBS@ |
LLVM_VERSION = @LLVM_VERSION@ |
LN_S = @LN_S@ |
LTLIBOBJS = @LTLIBOBJS@ |
MAKE = @MAKE@ |
MAKEINFO = @MAKEINFO@ |
MANIFEST_TOOL = @MANIFEST_TOOL@ |
MESA_LLVM = @MESA_LLVM@ |
MKDIR_P = @MKDIR_P@ |
NM = @NM@ |
NMEDIT = @NMEDIT@ |
NOUVEAU_CFLAGS = @NOUVEAU_CFLAGS@ |
NOUVEAU_LIBS = @NOUVEAU_LIBS@ |
OBJDUMP = @OBJDUMP@ |
OBJEXT = @OBJEXT@ |
OPENCL_LIB_INSTALL_DIR = @OPENCL_LIB_INSTALL_DIR@ |
OSMESA_LIB = @OSMESA_LIB@ |
OSMESA_LIB_DEPS = @OSMESA_LIB_DEPS@ |
OSMESA_LIB_NAME = @OSMESA_LIB_NAME@ |
OSMESA_MESA_DEPS = @OSMESA_MESA_DEPS@ |
OSMESA_PC_LIB_PRIV = @OSMESA_PC_LIB_PRIV@ |
OSMESA_PC_REQ = @OSMESA_PC_REQ@ |
OSMESA_VERSION = @OSMESA_VERSION@ |
OTOOL = @OTOOL@ |
OTOOL64 = @OTOOL64@ |
PACKAGE = @PACKAGE@ |
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ |
PACKAGE_NAME = @PACKAGE_NAME@ |
PACKAGE_STRING = @PACKAGE_STRING@ |
PACKAGE_TARNAME = @PACKAGE_TARNAME@ |
PACKAGE_URL = @PACKAGE_URL@ |
PACKAGE_VERSION = @PACKAGE_VERSION@ |
PATH_SEPARATOR = @PATH_SEPARATOR@ |
PERL = @PERL@ |
PKG_CONFIG = @PKG_CONFIG@ |
PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ |
PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ |
POSIX_SHELL = @POSIX_SHELL@ |
PTHREAD_CC = @PTHREAD_CC@ |
PTHREAD_CFLAGS = @PTHREAD_CFLAGS@ |
PTHREAD_LIBS = @PTHREAD_LIBS@ |
PYTHON2 = @PYTHON2@ |
RADEON_CFLAGS = @RADEON_CFLAGS@ |
RADEON_LIBS = @RADEON_LIBS@ |
RANLIB = @RANLIB@ |
SED = @SED@ |
SELINUX_LIBS = @SELINUX_LIBS@ |
SET_MAKE = @SET_MAKE@ |
SHELL = @SHELL@ |
STRIP = @STRIP@ |
VDPAU_CFLAGS = @VDPAU_CFLAGS@ |
VDPAU_LIBS = @VDPAU_LIBS@ |
VDPAU_LIB_INSTALL_DIR = @VDPAU_LIB_INSTALL_DIR@ |
VDPAU_MAJOR = @VDPAU_MAJOR@ |
VDPAU_MINOR = @VDPAU_MINOR@ |
VERSION = @VERSION@ |
VG_LIB_DEPS = @VG_LIB_DEPS@ |
VG_LIB_GLOB = @VG_LIB_GLOB@ |
VG_LIB_NAME = @VG_LIB_NAME@ |
VG_PC_LIB_PRIV = @VG_PC_LIB_PRIV@ |
VISIBILITY_CFLAGS = @VISIBILITY_CFLAGS@ |
VISIBILITY_CXXFLAGS = @VISIBILITY_CXXFLAGS@ |
WAYLAND_CFLAGS = @WAYLAND_CFLAGS@ |
WAYLAND_LIBS = @WAYLAND_LIBS@ |
WAYLAND_SCANNER = @WAYLAND_SCANNER@ |
X11_INCLUDES = @X11_INCLUDES@ |
XA_MAJOR = @XA_MAJOR@ |
XA_MINOR = @XA_MINOR@ |
XA_TINY = @XA_TINY@ |
XA_VERSION = @XA_VERSION@ |
XCB_DRI2_CFLAGS = @XCB_DRI2_CFLAGS@ |
XCB_DRI2_LIBS = @XCB_DRI2_LIBS@ |
XEXT_CFLAGS = @XEXT_CFLAGS@ |
XEXT_LIBS = @XEXT_LIBS@ |
XF86VIDMODE_CFLAGS = @XF86VIDMODE_CFLAGS@ |
XF86VIDMODE_LIBS = @XF86VIDMODE_LIBS@ |
XLIBGL_CFLAGS = @XLIBGL_CFLAGS@ |
XLIBGL_LIBS = @XLIBGL_LIBS@ |
XORG_CFLAGS = @XORG_CFLAGS@ |
XORG_DRIVER_INSTALL_DIR = @XORG_DRIVER_INSTALL_DIR@ |
XORG_LIBS = @XORG_LIBS@ |
XVMC_CFLAGS = @XVMC_CFLAGS@ |
XVMC_LIBS = @XVMC_LIBS@ |
XVMC_LIB_INSTALL_DIR = @XVMC_LIB_INSTALL_DIR@ |
XVMC_MAJOR = @XVMC_MAJOR@ |
XVMC_MINOR = @XVMC_MINOR@ |
YACC = @YACC@ |
YFLAGS = @YFLAGS@ |
abs_builddir = @abs_builddir@ |
abs_srcdir = @abs_srcdir@ |
abs_top_builddir = @abs_top_builddir@ |
abs_top_srcdir = @abs_top_srcdir@ |
ac_ct_AR = @ac_ct_AR@ |
ac_ct_CC = @ac_ct_CC@ |
ac_ct_CC_FOR_BUILD = @ac_ct_CC_FOR_BUILD@ |
ac_ct_CXX = @ac_ct_CXX@ |
ac_ct_CXX_FOR_BUILD = @ac_ct_CXX_FOR_BUILD@ |
ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ |
am__include = @am__include@ |
am__leading_dot = @am__leading_dot@ |
am__quote = @am__quote@ |
am__tar = @am__tar@ |
am__untar = @am__untar@ |
ax_pthread_config = @ax_pthread_config@ |
bindir = @bindir@ |
build = @build@ |
build_alias = @build_alias@ |
build_cpu = @build_cpu@ |
build_os = @build_os@ |
build_vendor = @build_vendor@ |
builddir = @builddir@ |
datadir = @datadir@ |
datarootdir = @datarootdir@ |
docdir = @docdir@ |
dvidir = @dvidir@ |
exec_prefix = @exec_prefix@ |
host = @host@ |
host_alias = @host_alias@ |
host_cpu = @host_cpu@ |
host_os = @host_os@ |
host_vendor = @host_vendor@ |
htmldir = @htmldir@ |
includedir = @includedir@ |
infodir = @infodir@ |
install_sh = @install_sh@ |
libdir = @libdir@ |
libexecdir = @libexecdir@ |
localedir = @localedir@ |
localstatedir = @localstatedir@ |
mandir = @mandir@ |
mkdir_p = @mkdir_p@ |
oldincludedir = @oldincludedir@ |
pdfdir = @pdfdir@ |
prefix = @prefix@ |
program_transform_name = @program_transform_name@ |
psdir = @psdir@ |
sbindir = @sbindir@ |
sharedstatedir = @sharedstatedir@ |
srcdir = @srcdir@ |
sysconfdir = @sysconfdir@ |
target = @target@ |
target_alias = @target_alias@ |
target_cpu = @target_cpu@ |
target_os = @target_os@ |
target_vendor = @target_vendor@ |
top_build_prefix = @top_build_prefix@ |
top_builddir = @top_builddir@ |
top_srcdir = @top_srcdir@ |
GALLIUM_CFLAGS = \ |
-I$(top_srcdir)/include \ |
-I$(top_srcdir)/src/gallium/include \ |
-I$(top_srcdir)/src/gallium/auxiliary \ |
$(DEFINES) |
AM_CFLAGS = \ |
$(GALLIUM_CFLAGS) \ |
$(XEXT_CFLAGS) \ |
$(LIBKMS_XORG_CFLAGS) \ |
$(LIBDRM_XORG_CFLAGS) \ |
$(shell $(PKG_CONFIG) --cflags-only-I xorg-server) |
AM_CPPFLAGS = \ |
-I$(top_srcdir)/include \ |
-I$(top_srcdir)/src/mesa \ |
-I$(top_srcdir)/src/mesa/drivers/dri/common \ |
-I$(top_srcdir)/src/mesa/main \ |
-DHAVE_CONFIG_H \ |
-DHAVE_LIBKMS |
noinst_LTLIBRARIES = libxorgtracker.la |
libxorgtracker_la_SOURCES = \ |
xorg_composite.c \ |
xorg_crtc.c \ |
xorg_dri2.c \ |
xorg_driver.c \ |
xorg_exa.c \ |
xorg_exa_tgsi.c \ |
xorg_output.c \ |
xorg_renderer.c \ |
xorg_xv.c \ |
xorg_xvmc.c |
all: all-am |
.SUFFIXES: |
.SUFFIXES: .c .lo .o .obj |
$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/src/gallium/Automake.inc $(am__configure_deps) |
@for dep in $?; do \ |
case '$(am__configure_deps)' in \ |
*$$dep*) \ |
( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ |
&& { if test -f $@; then exit 0; else break; fi; }; \ |
exit 1;; \ |
esac; \ |
done; \ |
echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/gallium/state_trackers/xorg/Makefile'; \ |
$(am__cd) $(top_srcdir) && \ |
$(AUTOMAKE) --foreign src/gallium/state_trackers/xorg/Makefile |
.PRECIOUS: Makefile |
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status |
@case '$?' in \ |
*config.status*) \ |
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ |
*) \ |
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ |
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ |
esac; |
$(top_srcdir)/src/gallium/Automake.inc: |
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) |
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh |
$(top_srcdir)/configure: $(am__configure_deps) |
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh |
$(ACLOCAL_M4): $(am__aclocal_m4_deps) |
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh |
$(am__aclocal_m4_deps): |
clean-noinstLTLIBRARIES: |
-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) |
@list='$(noinst_LTLIBRARIES)'; \ |
locs=`for p in $$list; do echo $$p; done | \ |
sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ |
sort -u`; \ |
test -z "$$locs" || { \ |
echo rm -f $${locs}; \ |
rm -f $${locs}; \ |
} |
libxorgtracker.la: $(libxorgtracker_la_OBJECTS) $(libxorgtracker_la_DEPENDENCIES) $(EXTRA_libxorgtracker_la_DEPENDENCIES) |
$(AM_V_CCLD)$(LINK) $(libxorgtracker_la_OBJECTS) $(libxorgtracker_la_LIBADD) $(LIBS) |
mostlyclean-compile: |
-rm -f *.$(OBJEXT) |
distclean-compile: |
-rm -f *.tab.c |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorg_composite.Plo@am__quote@ |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorg_crtc.Plo@am__quote@ |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorg_dri2.Plo@am__quote@ |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorg_driver.Plo@am__quote@ |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorg_exa.Plo@am__quote@ |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorg_exa_tgsi.Plo@am__quote@ |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorg_output.Plo@am__quote@ |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorg_renderer.Plo@am__quote@ |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorg_xv.Plo@am__quote@ |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xorg_xvmc.Plo@am__quote@ |
.c.o: |
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< |
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po |
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ |
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< |
.c.obj: |
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` |
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po |
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ |
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` |
.c.lo: |
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< |
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo |
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ |
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ |
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $< |
mostlyclean-libtool: |
-rm -f *.lo |
clean-libtool: |
-rm -rf .libs _libs |
ID: $(am__tagged_files) |
$(am__define_uniq_tagged_files); mkid -fID $$unique |
tags: tags-am |
TAGS: tags |
tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) |
set x; \ |
here=`pwd`; \ |
$(am__define_uniq_tagged_files); \ |
shift; \ |
if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ |
test -n "$$unique" || unique=$$empty_fix; \ |
if test $$# -gt 0; then \ |
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ |
"$$@" $$unique; \ |
else \ |
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ |
$$unique; \ |
fi; \ |
fi |
ctags: ctags-am |
CTAGS: ctags |
ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) |
$(am__define_uniq_tagged_files); \ |
test -z "$(CTAGS_ARGS)$$unique" \ |
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ |
$$unique |
GTAGS: |
here=`$(am__cd) $(top_builddir) && pwd` \ |
&& $(am__cd) $(top_srcdir) \ |
&& gtags -i $(GTAGS_ARGS) "$$here" |
cscopelist: cscopelist-am |
cscopelist-am: $(am__tagged_files) |
list='$(am__tagged_files)'; \ |
case "$(srcdir)" in \ |
[\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ |
*) sdir=$(subdir)/$(srcdir) ;; \ |
esac; \ |
for i in $$list; do \ |
if test -f "$$i"; then \ |
echo "$(subdir)/$$i"; \ |
else \ |
echo "$$sdir/$$i"; \ |
fi; \ |
done >> $(top_builddir)/cscope.files |
distclean-tags: |
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags |
distdir: $(DISTFILES) |
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ |
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ |
list='$(DISTFILES)'; \ |
dist_files=`for file in $$list; do echo $$file; done | \ |
sed -e "s|^$$srcdirstrip/||;t" \ |
-e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ |
case $$dist_files in \ |
*/*) $(MKDIR_P) `echo "$$dist_files" | \ |
sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ |
sort -u` ;; \ |
esac; \ |
for file in $$dist_files; do \ |
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ |
if test -d $$d/$$file; then \ |
dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ |
if test -d "$(distdir)/$$file"; then \ |
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ |
fi; \ |
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ |
cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ |
find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ |
fi; \ |
cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ |
else \ |
test -f "$(distdir)/$$file" \ |
|| cp -p $$d/$$file "$(distdir)/$$file" \ |
|| exit 1; \ |
fi; \ |
done |
check-am: all-am |
check: check-am |
all-am: Makefile $(LTLIBRARIES) |
installdirs: |
install: install-am |
install-exec: install-exec-am |
install-data: install-data-am |
uninstall: uninstall-am |
install-am: all-am |
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am |
installcheck: installcheck-am |
install-strip: |
if test -z '$(STRIP)'; then \ |
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ |
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ |
install; \ |
else \ |
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ |
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ |
"INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ |
fi |
mostlyclean-generic: |
clean-generic: |
distclean-generic: |
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) |
-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) |
maintainer-clean-generic: |
@echo "This command is intended for maintainers to use" |
@echo "it deletes files that may require special tools to rebuild." |
clean: clean-am |
clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ |
mostlyclean-am |
distclean: distclean-am |
-rm -rf ./$(DEPDIR) |
-rm -f Makefile |
distclean-am: clean-am distclean-compile distclean-generic \ |
distclean-tags |
dvi: dvi-am |
dvi-am: |
html: html-am |
html-am: |
info: info-am |
info-am: |
install-data-am: |
install-dvi: install-dvi-am |
install-dvi-am: |
install-exec-am: |
install-html: install-html-am |
install-html-am: |
install-info: install-info-am |
install-info-am: |
install-man: |
install-pdf: install-pdf-am |
install-pdf-am: |
install-ps: install-ps-am |
install-ps-am: |
installcheck-am: |
maintainer-clean: maintainer-clean-am |
-rm -rf ./$(DEPDIR) |
-rm -f Makefile |
maintainer-clean-am: distclean-am maintainer-clean-generic |
mostlyclean: mostlyclean-am |
mostlyclean-am: mostlyclean-compile mostlyclean-generic \ |
mostlyclean-libtool |
pdf: pdf-am |
pdf-am: |
ps: ps-am |
ps-am: |
uninstall-am: |
.MAKE: install-am install-strip |
.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ |
clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \ |
ctags-am distclean distclean-compile distclean-generic \ |
distclean-libtool distclean-tags distdir dvi dvi-am html \ |
html-am info info-am install install-am install-data \ |
install-data-am install-dvi install-dvi-am install-exec \ |
install-exec-am install-html install-html-am install-info \ |
install-info-am install-man install-pdf install-pdf-am \ |
install-ps install-ps-am install-strip installcheck \ |
installcheck-am installdirs maintainer-clean \ |
maintainer-clean-generic mostlyclean mostlyclean-compile \ |
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ |
tags tags-am uninstall uninstall-am |
# Tell versions [3.59,3.63) of GNU make to not export all variables. |
# Otherwise a system limit (for SysV at least) may be exceeded. |
.NOEXPORT: |
/contrib/sdk/sources/Mesa/mesa-9.2.5/src/gallium/state_trackers/xorg/SConscript |
---|
0,0 → 1,42 |
####################################################################### |
# SConscript for xorg state_tracker |
Import('*') |
env = env.Clone() |
env.Append(CPPPATH = [ |
'#/src/mesa', |
]) |
env.PkgUseModules(['DRM', 'XORG']) |
if env['HAVE_KMS']: |
env.Append(CPPDEFINES = ['HAVE_LIBKMS']) |
env.PkgUseModules(['KMS']) |
conf = env.Configure() |
if conf.CheckHeader('X11/extensions/dpmsconst.h'): |
env.Append(CPPDEFINES = [('HAVE_XEXTPROTO_71', '1')]) |
conf.Finish() |
sources = [ |
'xorg_composite.c', |
'xorg_crtc.c', |
'xorg_dri2.c', |
'xorg_driver.c', |
'xorg_exa.c', |
'xorg_exa_tgsi.c', |
'xorg_output.c', |
'xorg_renderer.c', |
'xorg_xv.c', |
'xorg_xvmc.c', |
] |
st_xorg = env.ConvenienceLibrary( |
target = 'st_xorg', |
source = sources, |
) |
Export('st_xorg') |
/contrib/sdk/sources/Mesa/mesa-9.2.5/src/gallium/state_trackers/xorg/compat-api.h |
---|
0,0 → 1,99 |
/* |
* Copyright 2012 Red Hat, Inc. |
* |
* 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 (including the next |
* paragraph) 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. |
* |
* Author: Dave Airlie <airlied@redhat.com> |
*/ |
/* this file provides API compat between server post 1.13 and pre it, |
it should be reused inside as many drivers as possible */ |
#ifndef COMPAT_API_H |
#define COMPAT_API_H |
#ifndef GLYPH_HAS_GLYPH_PICTURE_ACCESSOR |
#define GetGlyphPicture(g, s) GlyphPicture((g))[(s)->myNum] |
#define SetGlyphPicture(g, s, p) GlyphPicture((g))[(s)->myNum] = p |
#endif |
#ifndef XF86_HAS_SCRN_CONV |
#define xf86ScreenToScrn(s) xf86Screens[(s)->myNum] |
#define xf86ScrnToScreen(s) screenInfo.screens[(s)->scrnIndex] |
#endif |
#ifndef XF86_SCRN_INTERFACE |
#define SCRN_ARG_TYPE int |
#define SCRN_INFO_PTR(arg1) ScrnInfoPtr pScrn = xf86Screens[(arg1)] |
#define SCREEN_ARG_TYPE int |
#define SCREEN_PTR(arg1) ScreenPtr pScreen = screenInfo.screens[(arg1)] |
#define SCREEN_INIT_ARGS_DECL int i, ScreenPtr pScreen, int argc, char **argv |
#define BLOCKHANDLER_ARGS_DECL int arg, pointer blockData, pointer pTimeout, pointer pReadmask |
#define BLOCKHANDLER_ARGS arg, blockData, pTimeout, pReadmask |
#define CLOSE_SCREEN_ARGS_DECL int scrnIndex, ScreenPtr pScreen |
#define CLOSE_SCREEN_ARGS scrnIndex, pScreen |
#define ADJUST_FRAME_ARGS_DECL int arg, int x, int y, int flags |
#define ADJUST_FRAME_ARGS(arg, x, y) (arg)->scrnIndex, x, y, 0 |
#define SWITCH_MODE_ARGS_DECL int arg, DisplayModePtr mode, int flags |
#define SWITCH_MODE_ARGS(arg, m) (arg)->scrnIndex, m, 0 |
#define FREE_SCREEN_ARGS_DECL int arg, int flags |
#define VT_FUNC_ARGS_DECL int arg, int flags |
#define VT_FUNC_ARGS pScrn->scrnIndex, 0 |
#define XF86_SCRN_ARG(x) ((x)->scrnIndex) |
#else |
#define SCRN_ARG_TYPE ScrnInfoPtr |
#define SCRN_INFO_PTR(arg1) ScrnInfoPtr pScrn = (arg1) |
#define SCREEN_ARG_TYPE ScreenPtr |
#define SCREEN_PTR(arg1) ScreenPtr pScreen = (arg1) |
#define SCREEN_INIT_ARGS_DECL ScreenPtr pScreen, int argc, char **argv |
#define BLOCKHANDLER_ARGS_DECL ScreenPtr arg, pointer pTimeout, pointer pReadmask |
#define BLOCKHANDLER_ARGS arg, pTimeout, pReadmask |
#define CLOSE_SCREEN_ARGS_DECL ScreenPtr pScreen |
#define CLOSE_SCREEN_ARGS pScreen |
#define ADJUST_FRAME_ARGS_DECL ScrnInfoPtr arg, int x, int y |
#define ADJUST_FRAME_ARGS(arg, x, y) arg, x, y |
#define SWITCH_MODE_ARGS_DECL ScrnInfoPtr arg, DisplayModePtr mode |
#define SWITCH_MODE_ARGS(arg, m) arg, m |
#define FREE_SCREEN_ARGS_DECL ScrnInfoPtr arg |
#define VT_FUNC_ARGS_DECL ScrnInfoPtr arg |
#define VT_FUNC_ARGS pScrn |
#define XF86_SCRN_ARG(x) (x) |
#endif |
#endif |
/contrib/sdk/sources/Mesa/mesa-9.2.5/src/gallium/state_trackers/xorg/xorg_composite.c |
---|
0,0 → 1,585 |
#include "xorg_composite.h" |
#include "xorg_renderer.h" |
#include "xorg_exa_tgsi.h" |
#include "cso_cache/cso_context.h" |
#include "util/u_format.h" |
#include "util/u_sampler.h" |
/*XXX also in Xrender.h but the including it here breaks compilition */ |
#define XFixedToDouble(f) (((double) (f)) / 65536.) |
struct xorg_composite_blend { |
int op : 8; |
unsigned alpha_dst : 4; |
unsigned alpha_src : 4; |
unsigned rgb_src : 8; /**< PIPE_BLENDFACTOR_x */ |
unsigned rgb_dst : 8; /**< PIPE_BLENDFACTOR_x */ |
}; |
#define BLEND_OP_OVER 3 |
static const struct xorg_composite_blend xorg_blends[] = { |
{ PictOpClear, |
0, 0, PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ZERO}, |
{ PictOpSrc, |
0, 0, PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_ZERO}, |
{ PictOpDst, |
0, 0, PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_ONE}, |
{ PictOpOver, |
0, 1, PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_INV_SRC_ALPHA}, |
{ PictOpOverReverse, |
1, 0, PIPE_BLENDFACTOR_INV_DST_ALPHA, PIPE_BLENDFACTOR_ONE}, |
{ PictOpIn, |
1, 0, PIPE_BLENDFACTOR_DST_ALPHA, PIPE_BLENDFACTOR_ZERO}, |
{ PictOpInReverse, |
0, 1, PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_SRC_ALPHA}, |
{ PictOpOut, |
1, 0, PIPE_BLENDFACTOR_INV_DST_ALPHA, PIPE_BLENDFACTOR_ZERO}, |
{ PictOpOutReverse, |
0, 1, PIPE_BLENDFACTOR_ZERO, PIPE_BLENDFACTOR_INV_SRC_ALPHA}, |
{ PictOpAtop, |
1, 1, PIPE_BLENDFACTOR_DST_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA}, |
{ PictOpAtopReverse, |
1, 1, PIPE_BLENDFACTOR_INV_DST_ALPHA, PIPE_BLENDFACTOR_SRC_ALPHA}, |
{ PictOpXor, |
1, 1, PIPE_BLENDFACTOR_INV_DST_ALPHA, PIPE_BLENDFACTOR_INV_SRC_ALPHA}, |
{ PictOpAdd, |
0, 0, PIPE_BLENDFACTOR_ONE, PIPE_BLENDFACTOR_ONE}, |
}; |
static INLINE void |
pixel_to_float4(Pixel pixel, float *color, enum pipe_format format) |
{ |
const struct util_format_description *format_desc; |
uint8_t packed[4]; |
format_desc = util_format_description(format); |
packed[0] = pixel; |
packed[1] = pixel >> 8; |
packed[2] = pixel >> 16; |
packed[3] = pixel >> 24; |
format_desc->unpack_rgba_float(color, 0, packed, 0, 1, 1); |
} |
static boolean |
blend_for_op(struct xorg_composite_blend *blend, |
int op, PicturePtr pSrcPicture, PicturePtr pMaskPicture, |
PicturePtr pDstPicture) |
{ |
const int num_blends = |
sizeof(xorg_blends)/sizeof(struct xorg_composite_blend); |
int i; |
boolean supported = FALSE; |
/* our default in case something goes wrong */ |
*blend = xorg_blends[BLEND_OP_OVER]; |
for (i = 0; i < num_blends; ++i) { |
if (xorg_blends[i].op == op) { |
*blend = xorg_blends[i]; |
supported = TRUE; |
} |
} |
/* If there's no dst alpha channel, adjust the blend op so that we'll treat |
* it as always 1. */ |
if (pDstPicture && |
PICT_FORMAT_A(pDstPicture->format) == 0 && blend->alpha_dst) { |
if (blend->rgb_src == PIPE_BLENDFACTOR_DST_ALPHA) |
blend->rgb_src = PIPE_BLENDFACTOR_ONE; |
else if (blend->rgb_src == PIPE_BLENDFACTOR_INV_DST_ALPHA) |
blend->rgb_src = PIPE_BLENDFACTOR_ZERO; |
} |
/* If the source alpha is being used, then we should only be in a case where |
* the source blend factor is 0, and the source blend value is the mask |
* channels multiplied by the source picture's alpha. */ |
if (pMaskPicture && pMaskPicture->componentAlpha && |
PICT_FORMAT_RGB(pMaskPicture->format) && blend->alpha_src) { |
if (blend->rgb_dst == PIPE_BLENDFACTOR_SRC_ALPHA) { |
blend->rgb_dst = PIPE_BLENDFACTOR_SRC_COLOR; |
} else if (blend->rgb_dst == PIPE_BLENDFACTOR_INV_SRC_ALPHA) { |
blend->rgb_dst = PIPE_BLENDFACTOR_INV_SRC_COLOR; |
} |
} |
return supported; |
} |
static INLINE int |
render_repeat_to_gallium(int mode) |
{ |
switch(mode) { |
case RepeatNone: |
return PIPE_TEX_WRAP_CLAMP_TO_BORDER; |
case RepeatNormal: |
return PIPE_TEX_WRAP_REPEAT; |
case RepeatReflect: |
return PIPE_TEX_WRAP_MIRROR_REPEAT; |
case RepeatPad: |
return PIPE_TEX_WRAP_CLAMP_TO_EDGE; |
default: |
debug_printf("Unsupported repeat mode\n"); |
} |
return PIPE_TEX_WRAP_REPEAT; |
} |
static INLINE boolean |
render_filter_to_gallium(int xrender_filter, int *out_filter) |
{ |
switch (xrender_filter) { |
case PictFilterNearest: |
*out_filter = PIPE_TEX_FILTER_NEAREST; |
break; |
case PictFilterBilinear: |
*out_filter = PIPE_TEX_FILTER_LINEAR; |
break; |
case PictFilterFast: |
*out_filter = PIPE_TEX_FILTER_NEAREST; |
break; |
case PictFilterGood: |
*out_filter = PIPE_TEX_FILTER_LINEAR; |
break; |
case PictFilterBest: |
*out_filter = PIPE_TEX_FILTER_LINEAR; |
break; |
case PictFilterConvolution: |
*out_filter = PIPE_TEX_FILTER_NEAREST; |
return FALSE; |
default: |
debug_printf("Unknown xrender filter\n"); |
*out_filter = PIPE_TEX_FILTER_NEAREST; |
return FALSE; |
} |
return TRUE; |
} |
static boolean is_filter_accelerated(PicturePtr pic) |
{ |
int filter; |
if (pic && !render_filter_to_gallium(pic->filter, &filter)) |
return FALSE; |
return TRUE; |
} |
boolean xorg_composite_accelerated(int op, |
PicturePtr pSrcPicture, |
PicturePtr pMaskPicture, |
PicturePtr pDstPicture) |
{ |
ScreenPtr pScreen = pDstPicture->pDrawable->pScreen; |
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); |
modesettingPtr ms = modesettingPTR(pScrn); |
struct xorg_composite_blend blend; |
if (!is_filter_accelerated(pSrcPicture) || |
!is_filter_accelerated(pMaskPicture)) { |
XORG_FALLBACK("Unsupported Xrender filter"); |
} |
if (pSrcPicture->pSourcePict) { |
if (pSrcPicture->pSourcePict->type != SourcePictTypeSolidFill) |
XORG_FALLBACK("Gradients not enabled (haven't been well tested)"); |
} |
if (blend_for_op(&blend, op, |
pSrcPicture, pMaskPicture, pDstPicture)) { |
/* Check for component alpha */ |
if (pMaskPicture && pMaskPicture->componentAlpha && |
PICT_FORMAT_RGB(pMaskPicture->format)) { |
if (blend.alpha_src && blend.rgb_src != PIPE_BLENDFACTOR_ZERO) { |
XORG_FALLBACK("Component alpha not supported with source " |
"alpha and source value blending. (op=%d)", |
op); |
} |
} |
return TRUE; |
} |
XORG_FALLBACK("Unsupported composition operation = %d", op); |
} |
static void |
bind_blend_state(struct exa_context *exa, int op, |
PicturePtr pSrcPicture, |
PicturePtr pMaskPicture, |
PicturePtr pDstPicture) |
{ |
struct xorg_composite_blend blend_opt; |
struct pipe_blend_state blend; |
blend_for_op(&blend_opt, op, pSrcPicture, pMaskPicture, pDstPicture); |
memset(&blend, 0, sizeof(struct pipe_blend_state)); |
blend.rt[0].blend_enable = 1; |
blend.rt[0].colormask = PIPE_MASK_RGBA; |
blend.rt[0].rgb_src_factor = blend_opt.rgb_src; |
blend.rt[0].alpha_src_factor = blend_opt.rgb_src; |
blend.rt[0].rgb_dst_factor = blend_opt.rgb_dst; |
blend.rt[0].alpha_dst_factor = blend_opt.rgb_dst; |
cso_set_blend(exa->renderer->cso, &blend); |
} |
static unsigned |
picture_format_fixups(struct exa_pixmap_priv *pSrc, PicturePtr pSrcPicture, boolean mask, |
PicturePtr pDstPicture) |
{ |
boolean set_alpha = FALSE; |
boolean swizzle = FALSE; |
unsigned ret = 0; |
if (pSrc && pSrc->picture_format == pSrcPicture->format) { |
if (pSrc->picture_format == PICT_a8) { |
if (mask) |
return FS_MASK_LUMINANCE; |
else if (pDstPicture->format != PICT_a8) { |
/* if both dst and src are luminance then |
* we don't want to swizzle the alpha (X) of the |
* source into W component of the dst because |
* it will break our destination */ |
return FS_SRC_LUMINANCE; |
} |
} |
return 0; |
} |
if (pSrc && pSrc->picture_format != PICT_a8r8g8b8) { |
assert(!"can not handle formats"); |
return 0; |
} |
/* pSrc->picture_format == PICT_a8r8g8b8 */ |
switch (pSrcPicture->format) { |
case PICT_x8b8g8r8: |
case PICT_b8g8r8: |
set_alpha = TRUE; /* fall trough */ |
case PICT_a8b8g8r8: |
swizzle = TRUE; |
break; |
case PICT_x8r8g8b8: |
case PICT_r8g8b8: |
set_alpha = TRUE; /* fall through */ |
case PICT_a8r8g8b8: |
break; |
#ifdef PICT_TYPE_BGRA |
case PICT_b8g8r8a8: |
case PICT_b8g8r8x8: |
case PICT_a2r10g10b10: |
case PICT_x2r10g10b10: |
case PICT_a2b10g10r10: |
case PICT_x2b10g10r10: |
#endif |
default: |
assert(!"can not handle formats"); |
return 0; |
} |
if (set_alpha) |
ret |= mask ? FS_MASK_SET_ALPHA : FS_SRC_SET_ALPHA; |
if (swizzle) |
ret |= mask ? FS_MASK_SWIZZLE_RGB : FS_SRC_SWIZZLE_RGB; |
return ret; |
} |
static void |
bind_shaders(struct exa_context *exa, int op, |
PicturePtr pSrcPicture, PicturePtr pMaskPicture, PicturePtr pDstPicture, |
struct exa_pixmap_priv *pSrc, struct exa_pixmap_priv *pMask) |
{ |
unsigned vs_traits = 0, fs_traits = 0; |
struct xorg_shader shader; |
exa->has_solid_color = FALSE; |
if (pSrcPicture) { |
if (pSrcPicture->repeatType == RepeatNone && pSrcPicture->transform) |
fs_traits |= FS_SRC_REPEAT_NONE; |
if (pSrcPicture->pSourcePict) { |
if (pSrcPicture->pSourcePict->type == SourcePictTypeSolidFill) { |
fs_traits |= FS_SOLID_FILL; |
vs_traits |= VS_SOLID_FILL; |
debug_assert(pSrcPicture->format == PICT_a8r8g8b8); |
pixel_to_float4(pSrcPicture->pSourcePict->solidFill.color, |
exa->solid_color, PIPE_FORMAT_B8G8R8A8_UNORM); |
exa->has_solid_color = TRUE; |
} else { |
debug_assert("!gradients not supported"); |
} |
} else { |
fs_traits |= FS_COMPOSITE; |
vs_traits |= VS_COMPOSITE; |
} |
fs_traits |= picture_format_fixups(pSrc, pSrcPicture, FALSE, pDstPicture); |
} |
if (pMaskPicture) { |
vs_traits |= VS_MASK; |
fs_traits |= FS_MASK; |
if (pMaskPicture->repeatType == RepeatNone && pMaskPicture->transform) |
fs_traits |= FS_MASK_REPEAT_NONE; |
if (pMaskPicture->componentAlpha) { |
struct xorg_composite_blend blend; |
blend_for_op(&blend, op, |
pSrcPicture, pMaskPicture, NULL); |
if (blend.alpha_src) { |
fs_traits |= FS_CA_SRCALPHA; |
} else |
fs_traits |= FS_CA_FULL; |
} |
fs_traits |= picture_format_fixups(pMask, pMaskPicture, TRUE, pDstPicture); |
} |
shader = xorg_shaders_get(exa->renderer->shaders, vs_traits, fs_traits); |
cso_set_vertex_shader_handle(exa->renderer->cso, shader.vs); |
cso_set_fragment_shader_handle(exa->renderer->cso, shader.fs); |
} |
static void |
bind_samplers(struct exa_context *exa, int op, |
PicturePtr pSrcPicture, PicturePtr pMaskPicture, |
PicturePtr pDstPicture, |
struct exa_pixmap_priv *pSrc, |
struct exa_pixmap_priv *pMask, |
struct exa_pixmap_priv *pDst) |
{ |
struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS] = {0}; |
struct pipe_sampler_state src_sampler, mask_sampler; |
struct pipe_sampler_view view_templ; |
struct pipe_sampler_view *src_view; |
struct pipe_context *pipe = exa->pipe; |
exa->num_bound_samplers = 0; |
memset(&src_sampler, 0, sizeof(struct pipe_sampler_state)); |
memset(&mask_sampler, 0, sizeof(struct pipe_sampler_state)); |
if (pSrcPicture && pSrc) { |
if (exa->has_solid_color) { |
debug_assert(!"solid color with textures"); |
samplers[0] = NULL; |
pipe_sampler_view_reference(&exa->bound_sampler_views[0], NULL); |
} else { |
unsigned src_wrap = render_repeat_to_gallium( |
pSrcPicture->repeatType); |
int filter; |
render_filter_to_gallium(pSrcPicture->filter, &filter); |
src_sampler.wrap_s = src_wrap; |
src_sampler.wrap_t = src_wrap; |
src_sampler.min_img_filter = filter; |
src_sampler.mag_img_filter = filter; |
src_sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST; |
src_sampler.normalized_coords = 1; |
samplers[0] = &src_sampler; |
exa->num_bound_samplers = 1; |
u_sampler_view_default_template(&view_templ, |
pSrc->tex, |
pSrc->tex->format); |
src_view = pipe->create_sampler_view(pipe, pSrc->tex, &view_templ); |
pipe_sampler_view_reference(&exa->bound_sampler_views[0], NULL); |
exa->bound_sampler_views[0] = src_view; |
} |
} |
if (pMaskPicture && pMask) { |
unsigned mask_wrap = render_repeat_to_gallium( |
pMaskPicture->repeatType); |
int filter; |
render_filter_to_gallium(pMaskPicture->filter, &filter); |
mask_sampler.wrap_s = mask_wrap; |
mask_sampler.wrap_t = mask_wrap; |
mask_sampler.min_img_filter = filter; |
mask_sampler.mag_img_filter = filter; |
src_sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST; |
mask_sampler.normalized_coords = 1; |
samplers[1] = &mask_sampler; |
exa->num_bound_samplers = 2; |
u_sampler_view_default_template(&view_templ, |
pMask->tex, |
pMask->tex->format); |
src_view = pipe->create_sampler_view(pipe, pMask->tex, &view_templ); |
pipe_sampler_view_reference(&exa->bound_sampler_views[1], NULL); |
exa->bound_sampler_views[1] = src_view; |
} |
cso_set_samplers(exa->renderer->cso, PIPE_SHADER_FRAGMENT, |
exa->num_bound_samplers, |
(const struct pipe_sampler_state **)samplers); |
cso_set_sampler_views(exa->renderer->cso, PIPE_SHADER_FRAGMENT, |
exa->num_bound_samplers, |
exa->bound_sampler_views); |
} |
static INLINE boolean matrix_from_pict_transform(PictTransform *trans, float *matrix) |
{ |
if (!trans) |
return FALSE; |
matrix[0] = XFixedToDouble(trans->matrix[0][0]); |
matrix[3] = XFixedToDouble(trans->matrix[0][1]); |
matrix[6] = XFixedToDouble(trans->matrix[0][2]); |
matrix[1] = XFixedToDouble(trans->matrix[1][0]); |
matrix[4] = XFixedToDouble(trans->matrix[1][1]); |
matrix[7] = XFixedToDouble(trans->matrix[1][2]); |
matrix[2] = XFixedToDouble(trans->matrix[2][0]); |
matrix[5] = XFixedToDouble(trans->matrix[2][1]); |
matrix[8] = XFixedToDouble(trans->matrix[2][2]); |
return TRUE; |
} |
static void |
setup_transforms(struct exa_context *exa, |
PicturePtr pSrcPicture, PicturePtr pMaskPicture) |
{ |
PictTransform *src_t = NULL; |
PictTransform *mask_t = NULL; |
if (pSrcPicture) |
src_t = pSrcPicture->transform; |
if (pMaskPicture) |
mask_t = pMaskPicture->transform; |
exa->transform.has_src = |
matrix_from_pict_transform(src_t, exa->transform.src); |
exa->transform.has_mask = |
matrix_from_pict_transform(mask_t, exa->transform.mask); |
} |
boolean xorg_composite_bind_state(struct exa_context *exa, |
int op, |
PicturePtr pSrcPicture, |
PicturePtr pMaskPicture, |
PicturePtr pDstPicture, |
struct exa_pixmap_priv *pSrc, |
struct exa_pixmap_priv *pMask, |
struct exa_pixmap_priv *pDst) |
{ |
struct pipe_surface *dst_surf = xorg_gpu_surface(exa->pipe, pDst); |
renderer_bind_destination(exa->renderer, dst_surf, |
pDst->width, |
pDst->height); |
bind_blend_state(exa, op, pSrcPicture, pMaskPicture, pDstPicture); |
bind_shaders(exa, op, pSrcPicture, pMaskPicture, pDstPicture, pSrc, pMask); |
bind_samplers(exa, op, pSrcPicture, pMaskPicture, |
pDstPicture, pSrc, pMask, pDst); |
setup_transforms(exa, pSrcPicture, pMaskPicture); |
if (exa->num_bound_samplers == 0 ) { /* solid fill */ |
renderer_begin_solid(exa->renderer); |
} else { |
renderer_begin_textures(exa->renderer, |
exa->num_bound_samplers); |
} |
pipe_surface_reference(&dst_surf, NULL); |
return TRUE; |
} |
void xorg_composite(struct exa_context *exa, |
struct exa_pixmap_priv *dst, |
int srcX, int srcY, int maskX, int maskY, |
int dstX, int dstY, int width, int height) |
{ |
if (exa->num_bound_samplers == 0 ) { /* solid fill */ |
renderer_solid(exa->renderer, |
dstX, dstY, dstX + width, dstY + height, |
exa->solid_color); |
} else { |
int pos[6] = {srcX, srcY, maskX, maskY, dstX, dstY}; |
float *src_matrix = NULL; |
float *mask_matrix = NULL; |
if (exa->transform.has_src) |
src_matrix = exa->transform.src; |
if (exa->transform.has_mask) |
mask_matrix = exa->transform.mask; |
renderer_texture(exa->renderer, |
pos, width, height, |
exa->bound_sampler_views, |
exa->num_bound_samplers, |
src_matrix, mask_matrix); |
} |
} |
boolean xorg_solid_bind_state(struct exa_context *exa, |
struct exa_pixmap_priv *pixmap, |
Pixel fg) |
{ |
struct pipe_surface *dst_surf = xorg_gpu_surface(exa->pipe, pixmap); |
unsigned vs_traits, fs_traits; |
struct xorg_shader shader; |
pixel_to_float4(fg, exa->solid_color, pixmap->tex->format); |
exa->has_solid_color = TRUE; |
#if 0 |
debug_printf("Color Pixel=(%d, %d, %d, %d), RGBA=(%f, %f, %f, %f)\n", |
(fg >> 24) & 0xff, (fg >> 16) & 0xff, |
(fg >> 8) & 0xff, (fg >> 0) & 0xff, |
exa->solid_color[0], exa->solid_color[1], |
exa->solid_color[2], exa->solid_color[3]); |
#endif |
vs_traits = VS_SOLID_FILL; |
fs_traits = FS_SOLID_FILL; |
renderer_bind_destination(exa->renderer, dst_surf, |
pixmap->width, pixmap->height); |
bind_blend_state(exa, PictOpSrc, NULL, NULL, NULL); |
cso_set_samplers(exa->renderer->cso, PIPE_SHADER_FRAGMENT, 0, NULL); |
cso_set_sampler_views(exa->renderer->cso, PIPE_SHADER_FRAGMENT, 0, NULL); |
shader = xorg_shaders_get(exa->renderer->shaders, vs_traits, fs_traits); |
cso_set_vertex_shader_handle(exa->renderer->cso, shader.vs); |
cso_set_fragment_shader_handle(exa->renderer->cso, shader.fs); |
renderer_begin_solid(exa->renderer); |
pipe_surface_reference(&dst_surf, NULL); |
return TRUE; |
} |
void xorg_solid(struct exa_context *exa, |
struct exa_pixmap_priv *pixmap, |
int x0, int y0, int x1, int y1) |
{ |
renderer_solid(exa->renderer, |
x0, y0, x1, y1, exa->solid_color); |
} |
void |
xorg_composite_done(struct exa_context *exa) |
{ |
renderer_draw_flush(exa->renderer); |
exa->transform.has_src = FALSE; |
exa->transform.has_mask = FALSE; |
exa->has_solid_color = FALSE; |
exa->num_bound_samplers = 0; |
} |
/contrib/sdk/sources/Mesa/mesa-9.2.5/src/gallium/state_trackers/xorg/xorg_composite.h |
---|
0,0 → 1,36 |
#ifndef XORG_COMPOSITE_H |
#define XORG_COMPOSITE_H |
#include "xorg_exa.h" |
boolean xorg_composite_accelerated(int op, |
PicturePtr pSrcPicture, |
PicturePtr pMaskPicture, |
PicturePtr pDstPicture); |
boolean xorg_composite_bind_state(struct exa_context *exa, |
int op, |
PicturePtr pSrcPicture, |
PicturePtr pMaskPicture, |
PicturePtr pDstPicture, |
struct exa_pixmap_priv *pSrc, |
struct exa_pixmap_priv *pMask, |
struct exa_pixmap_priv *pDst); |
void xorg_composite(struct exa_context *exa, |
struct exa_pixmap_priv *dst, |
int srcX, int srcY, int maskX, int maskY, |
int dstX, int dstY, int width, int height); |
boolean xorg_solid_bind_state(struct exa_context *exa, |
struct exa_pixmap_priv *pixmap, |
Pixel fg); |
void xorg_solid(struct exa_context *exa, |
struct exa_pixmap_priv *pixmap, |
int x0, int y0, int x1, int y1); |
void |
xorg_composite_done(struct exa_context *exa); |
#endif |
/contrib/sdk/sources/Mesa/mesa-9.2.5/src/gallium/state_trackers/xorg/xorg_crtc.c |
---|
0,0 → 1,447 |
/* |
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. |
* All Rights Reserved. |
* |
* 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, sub license, 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 (including the |
* next paragraph) 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 NON-INFRINGEMENT. |
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. |
* |
* |
* Author: Alan Hourihane <alanh@tungstengraphics.com> |
* Author: Jakob Bornecrantz <wallbraker@gmail.com> |
* |
*/ |
#include <unistd.h> |
#include <string.h> |
#include <assert.h> |
#include <stdlib.h> |
#include <math.h> |
#include <stdint.h> |
#include "xorg-server.h" |
#include <xf86.h> |
#include <xf86i2c.h> |
#include <xf86Crtc.h> |
#include <cursorstr.h> |
#include "xorg_tracker.h" |
#include "xf86Modes.h" |
#ifdef HAVE_XEXTPROTO_71 |
#include <X11/extensions/dpmsconst.h> |
#else |
#define DPMS_SERVER |
#include <X11/extensions/dpms.h> |
#endif |
#include "state_tracker/drm_driver.h" |
#include "util/u_inlines.h" |
#include "util/u_rect.h" |
#ifdef HAVE_LIBKMS |
#include "libkms/libkms.h" |
#endif |
struct crtc_private |
{ |
drmModeCrtcPtr drm_crtc; |
/* hwcursor */ |
struct pipe_resource *cursor_tex; |
struct kms_bo *cursor_bo; |
unsigned cursor_handle; |
}; |
static void |
crtc_dpms(xf86CrtcPtr crtc, int mode) |
{ |
/* ScrnInfoPtr pScrn = crtc->scrn; */ |
switch (mode) { |
case DPMSModeOn: |
case DPMSModeStandby: |
case DPMSModeSuspend: |
break; |
case DPMSModeOff: |
break; |
} |
} |
static Bool |
crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode, |
Rotation rotation, int x, int y) |
{ |
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(crtc->scrn); |
modesettingPtr ms = modesettingPTR(crtc->scrn); |
xf86OutputPtr output = NULL; |
struct crtc_private *crtcp = crtc->driver_private; |
drmModeCrtcPtr drm_crtc = crtcp->drm_crtc; |
drmModeModeInfo drm_mode; |
int i, ret; |
unsigned int connector_id; |
for (i = 0; i < config->num_output; output = NULL, i++) { |
output = config->output[i]; |
if (output->crtc == crtc) |
break; |
} |
if (!output) |
return FALSE; |
connector_id = xorg_output_get_id(output); |
drm_mode.clock = mode->Clock; |
drm_mode.hdisplay = mode->HDisplay; |
drm_mode.hsync_start = mode->HSyncStart; |
drm_mode.hsync_end = mode->HSyncEnd; |
drm_mode.htotal = mode->HTotal; |
drm_mode.vdisplay = mode->VDisplay; |
drm_mode.vsync_start = mode->VSyncStart; |
drm_mode.vsync_end = mode->VSyncEnd; |
drm_mode.vtotal = mode->VTotal; |
drm_mode.flags = mode->Flags; |
drm_mode.hskew = mode->HSkew; |
drm_mode.vscan = mode->VScan; |
drm_mode.vrefresh = mode->VRefresh; |
drm_mode.type = 0; |
if (!mode->name) |
xf86SetModeDefaultName(mode); |
strncpy(drm_mode.name, mode->name, DRM_DISPLAY_MODE_LEN - 1); |
drm_mode.name[DRM_DISPLAY_MODE_LEN - 1] = '\0'; |
ret = drmModeSetCrtc(ms->fd, drm_crtc->crtc_id, ms->fb_id, x, y, |
&connector_id, 1, &drm_mode); |
if (ret) |
return FALSE; |
/* Only set gamma when needed, to avoid unneeded delays. */ |
#if defined(XF86_CRTC_VERSION) && XF86_CRTC_VERSION >= 3 |
if (!crtc->active && crtc->version >= 3) |
crtc->funcs->gamma_set(crtc, crtc->gamma_red, crtc->gamma_green, |
crtc->gamma_blue, crtc->gamma_size); |
crtc->active = TRUE; |
#endif |
crtc->x = x; |
crtc->y = y; |
crtc->mode = *mode; |
crtc->rotation = rotation; |
return TRUE; |
} |
static void |
crtc_gamma_set(xf86CrtcPtr crtc, CARD16 * red, CARD16 * green, CARD16 * blue, |
int size) |
{ |
modesettingPtr ms = modesettingPTR(crtc->scrn); |
struct crtc_private *crtcp = crtc->driver_private; |
drmModeCrtcSetGamma(ms->fd, crtcp->drm_crtc->crtc_id, size, red, green, blue); |
} |
#if 0 /* Implement and enable to enable rotation and reflection. */ |
static void * |
crtc_shadow_allocate(xf86CrtcPtr crtc, int width, int height) |
{ |
/* ScrnInfoPtr pScrn = crtc->scrn; */ |
return NULL; |
} |
static PixmapPtr |
crtc_shadow_create(xf86CrtcPtr crtc, void *data, int width, int height) |
{ |
/* ScrnInfoPtr pScrn = crtc->scrn; */ |
return NULL; |
} |
static void |
crtc_shadow_destroy(xf86CrtcPtr crtc, PixmapPtr rotate_pixmap, void *data) |
{ |
/* ScrnInfoPtr pScrn = crtc->scrn; */ |
} |
#endif |
/* |
* Cursor functions |
*/ |
static void |
crtc_set_cursor_colors(xf86CrtcPtr crtc, int bg, int fg) |
{ |
/* XXX: See if this one is needed, as we only support ARGB cursors */ |
} |
static void |
crtc_set_cursor_position(xf86CrtcPtr crtc, int x, int y) |
{ |
modesettingPtr ms = modesettingPTR(crtc->scrn); |
struct crtc_private *crtcp = crtc->driver_private; |
drmModeMoveCursor(ms->fd, crtcp->drm_crtc->crtc_id, x, y); |
} |
static void |
crtc_load_cursor_argb_ga3d(xf86CrtcPtr crtc, CARD32 * image) |
{ |
unsigned char *ptr; |
modesettingPtr ms = modesettingPTR(crtc->scrn); |
struct crtc_private *crtcp = crtc->driver_private; |
struct pipe_transfer *transfer; |
struct pipe_fence_handle *fence = NULL; |
struct pipe_context *ctx = ms->ctx; |
struct pipe_screen *screen = ms->screen; |
if (!crtcp->cursor_tex) { |
struct pipe_resource templat; |
struct winsys_handle whandle; |
memset(&templat, 0, sizeof(templat)); |
templat.bind |= PIPE_BIND_RENDER_TARGET; |
templat.bind |= PIPE_BIND_SCANOUT; |
templat.bind |= PIPE_BIND_CURSOR; |
templat.target = PIPE_TEXTURE_2D; |
templat.last_level = 0; |
templat.depth0 = 1; |
templat.array_size = 1; |
templat.format = PIPE_FORMAT_B8G8R8A8_UNORM; |
templat.width0 = 64; |
templat.height0 = 64; |
memset(&whandle, 0, sizeof(whandle)); |
whandle.type = DRM_API_HANDLE_TYPE_KMS; |
crtcp->cursor_tex = screen->resource_create(screen, &templat); |
screen->resource_get_handle(screen, crtcp->cursor_tex, &whandle); |
crtcp->cursor_handle = whandle.handle; |
} |
ptr = pipe_transfer_map(ctx, crtcp->cursor_tex, |
0, 0, |
PIPE_TRANSFER_WRITE, |
0, 0, 64, 64, &transfer); |
util_copy_rect(ptr, crtcp->cursor_tex->format, |
transfer->stride, 0, 0, |
64, 64, (void*)image, 64 * 4, 0, 0); |
ctx->transfer_unmap(ctx, transfer); |
ctx->flush(ctx, &fence, 0); |
if (fence) { |
screen->fence_finish(screen, fence, PIPE_TIMEOUT_INFINITE); |
screen->fence_reference(screen, &fence, NULL); |
} |
if (crtc->cursor_shown) |
drmModeSetCursor(ms->fd, crtcp->drm_crtc->crtc_id, |
crtcp->cursor_handle, 64, 64); |
} |
#if HAVE_LIBKMS |
static void |
crtc_load_cursor_argb_kms(xf86CrtcPtr crtc, CARD32 * image) |
{ |
modesettingPtr ms = modesettingPTR(crtc->scrn); |
struct crtc_private *crtcp = crtc->driver_private; |
unsigned char *ptr; |
if (!crtcp->cursor_bo) { |
unsigned attr[8]; |
attr[0] = KMS_BO_TYPE; |
#ifdef KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8 |
attr[1] = KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8; |
#else |
attr[1] = KMS_BO_TYPE_CURSOR; |
#endif |
attr[2] = KMS_WIDTH; |
attr[3] = 64; |
attr[4] = KMS_HEIGHT; |
attr[5] = 64; |
attr[6] = 0; |
if (kms_bo_create(ms->kms, attr, &crtcp->cursor_bo)) |
return; |
if (kms_bo_get_prop(crtcp->cursor_bo, KMS_HANDLE, |
&crtcp->cursor_handle)) |
goto err_bo_destroy; |
} |
kms_bo_map(crtcp->cursor_bo, (void**)&ptr); |
memcpy(ptr, image, 64*64*4); |
kms_bo_unmap(crtcp->cursor_bo); |
if (crtc->cursor_shown) |
drmModeSetCursor(ms->fd, crtcp->drm_crtc->crtc_id, |
crtcp->cursor_handle, 64, 64); |
return; |
err_bo_destroy: |
kms_bo_destroy(&crtcp->cursor_bo); |
} |
#endif |
static void |
crtc_load_cursor_argb(xf86CrtcPtr crtc, CARD32 * image) |
{ |
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(crtc->scrn); |
modesettingPtr ms = modesettingPTR(crtc->scrn); |
/* Older X servers have cursor reference counting bugs leading to use of |
* freed memory and consequently random crashes. Should be fixed as of |
* xserver 1.8, but this workaround shouldn't hurt anyway. |
*/ |
if (config->cursor) |
config->cursor->refcnt++; |
if (ms->cursor) |
FreeCursor(ms->cursor, None); |
ms->cursor = config->cursor; |
if (ms->screen) |
crtc_load_cursor_argb_ga3d(crtc, image); |
#ifdef HAVE_LIBKMS |
else if (ms->kms) |
crtc_load_cursor_argb_kms(crtc, image); |
#endif |
} |
static void |
crtc_show_cursor(xf86CrtcPtr crtc) |
{ |
modesettingPtr ms = modesettingPTR(crtc->scrn); |
struct crtc_private *crtcp = crtc->driver_private; |
if (crtcp->cursor_tex || crtcp->cursor_bo) |
drmModeSetCursor(ms->fd, crtcp->drm_crtc->crtc_id, |
crtcp->cursor_handle, 64, 64); |
} |
static void |
crtc_hide_cursor(xf86CrtcPtr crtc) |
{ |
modesettingPtr ms = modesettingPTR(crtc->scrn); |
struct crtc_private *crtcp = crtc->driver_private; |
drmModeSetCursor(ms->fd, crtcp->drm_crtc->crtc_id, 0, 0, 0); |
} |
/** |
* Called at vt leave |
*/ |
void |
xorg_crtc_cursor_destroy(xf86CrtcPtr crtc) |
{ |
struct crtc_private *crtcp = crtc->driver_private; |
if (crtcp->cursor_tex) |
pipe_resource_reference(&crtcp->cursor_tex, NULL); |
#ifdef HAVE_LIBKMS |
if (crtcp->cursor_bo) |
kms_bo_destroy(&crtcp->cursor_bo); |
#endif |
} |
/* |
* Misc functions |
*/ |
static void |
crtc_destroy(xf86CrtcPtr crtc) |
{ |
struct crtc_private *crtcp = crtc->driver_private; |
xorg_crtc_cursor_destroy(crtc); |
drmModeFreeCrtc(crtcp->drm_crtc); |
free(crtcp); |
crtc->driver_private = NULL; |
} |
static const xf86CrtcFuncsRec crtc_funcs = { |
.dpms = crtc_dpms, |
.set_mode_major = crtc_set_mode_major, |
.set_cursor_colors = crtc_set_cursor_colors, |
.set_cursor_position = crtc_set_cursor_position, |
.show_cursor = crtc_show_cursor, |
.hide_cursor = crtc_hide_cursor, |
.load_cursor_argb = crtc_load_cursor_argb, |
.shadow_create = NULL, |
.shadow_allocate = NULL, |
.shadow_destroy = NULL, |
.gamma_set = crtc_gamma_set, |
.destroy = crtc_destroy, |
}; |
void |
xorg_crtc_init(ScrnInfoPtr pScrn) |
{ |
modesettingPtr ms = modesettingPTR(pScrn); |
xf86CrtcPtr crtc; |
drmModeResPtr res; |
drmModeCrtcPtr drm_crtc = NULL; |
struct crtc_private *crtcp; |
int c; |
res = drmModeGetResources(ms->fd); |
if (res == 0) { |
ErrorF("Failed drmModeGetResources %d\n", errno); |
return; |
} |
for (c = 0; c < res->count_crtcs; c++) { |
drm_crtc = drmModeGetCrtc(ms->fd, res->crtcs[c]); |
if (!drm_crtc) |
continue; |
crtc = xf86CrtcCreate(pScrn, &crtc_funcs); |
if (crtc == NULL) |
goto out; |
crtcp = calloc(1, sizeof(struct crtc_private)); |
if (!crtcp) { |
xf86CrtcDestroy(crtc); |
goto out; |
} |
crtcp->drm_crtc = drm_crtc; |
crtc->driver_private = crtcp; |
} |
out: |
drmModeFreeResources(res); |
} |
/* vim: set sw=4 ts=8 sts=4: */ |
/contrib/sdk/sources/Mesa/mesa-9.2.5/src/gallium/state_trackers/xorg/xorg_dri2.c |
---|
0,0 → 1,473 |
/* |
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. |
* All Rights Reserved. |
* |
* 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, sub license, 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 (including the |
* next paragraph) 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 NON-INFRINGEMENT. |
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. |
* |
* |
* Author: Alan Hourihane <alanh@tungstengraphics.com> |
* Author: Jakob Bornecrantz <wallbraker@gmail.com> |
* |
*/ |
#include "xorg-server.h" |
#include "xf86.h" |
#include "xf86_OSproc.h" |
#include "xorg_tracker.h" |
#include "xorg_exa.h" |
#include "dri2.h" |
#include "pipe/p_state.h" |
#include "util/u_inlines.h" |
#include "util/u_format.h" |
#include "state_tracker/drm_driver.h" |
/* Make all the #if cases in the code esier to read */ |
#ifndef DRI2INFOREC_VERSION |
#define DRI2INFOREC_VERSION 1 |
#endif |
#if DRI2INFOREC_VERSION == 2 |
static Bool set_format_in_do_create_buffer; |
#endif |
typedef struct { |
PixmapPtr pPixmap; |
struct pipe_resource *tex; |
struct pipe_fence_handle *fence; |
} *BufferPrivatePtr; |
static Bool |
dri2_do_create_buffer(DrawablePtr pDraw, DRI2BufferPtr buffer, unsigned int format) |
{ |
struct pipe_resource *tex = NULL; |
ScreenPtr pScreen = pDraw->pScreen; |
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); |
modesettingPtr ms = modesettingPTR(pScrn); |
struct exa_pixmap_priv *exa_priv; |
BufferPrivatePtr private = buffer->driverPrivate; |
PixmapPtr pPixmap; |
struct winsys_handle whandle; |
if (pDraw->type == DRAWABLE_PIXMAP) |
pPixmap = (PixmapPtr) pDraw; |
else |
pPixmap = (*pScreen->GetWindowPixmap)((WindowPtr) pDraw); |
exa_priv = exaGetPixmapDriverPrivate(pPixmap); |
switch (buffer->attachment) { |
default: |
if (buffer->attachment != DRI2BufferFakeFrontLeft || |
pDraw->type != DRAWABLE_PIXMAP) { |
private->pPixmap = (*pScreen->CreatePixmap)(pScreen, pDraw->width, |
pDraw->height, |
pDraw->depth, |
0); |
} |
break; |
case DRI2BufferFrontLeft: |
break; |
case DRI2BufferStencil: |
#if DRI2INFOREC_VERSION >= 3 |
case DRI2BufferDepthStencil: |
#else |
/* Works on old X servers because sanity checking is for the weak */ |
case 9: |
#endif |
if (exa_priv->depth_stencil_tex && |
!util_format_is_depth_or_stencil(exa_priv->depth_stencil_tex->format)) |
exa_priv->depth_stencil_tex = NULL; |
/* Fall through */ |
case DRI2BufferDepth: |
if (exa_priv->depth_stencil_tex) |
pipe_resource_reference(&tex, exa_priv->depth_stencil_tex); |
else { |
struct pipe_resource template; |
unsigned depthBits = (format != 0) ? format : pDraw->depth; |
memset(&template, 0, sizeof(template)); |
template.target = PIPE_TEXTURE_2D; |
if (buffer->attachment == DRI2BufferDepth) { |
switch(depthBits) { |
case 16: |
template.format = PIPE_FORMAT_Z16_UNORM; |
break; |
case 32: |
template.format = PIPE_FORMAT_Z32_UNORM; |
break; |
default: |
template.format = ms->ds_depth_bits_last ? |
PIPE_FORMAT_Z24X8_UNORM : PIPE_FORMAT_X8Z24_UNORM; |
break; |
} |
} else { |
template.format = ms->ds_depth_bits_last ? |
PIPE_FORMAT_Z24_UNORM_S8_UINT : PIPE_FORMAT_S8_UINT_Z24_UNORM; |
} |
template.width0 = pDraw->width; |
template.height0 = pDraw->height; |
template.depth0 = 1; |
template.array_size = 1; |
template.last_level = 0; |
template.bind = PIPE_BIND_DEPTH_STENCIL | |
PIPE_BIND_SHARED; |
tex = ms->screen->resource_create(ms->screen, &template); |
pipe_resource_reference(&exa_priv->depth_stencil_tex, tex); |
} |
break; |
} |
if (!private->pPixmap) { |
private->pPixmap = pPixmap; |
pPixmap->refcnt++; |
} |
if (!tex) { |
/* First call to make sure we have a pixmap private */ |
exaMoveInPixmap(private->pPixmap); |
xorg_exa_set_shared_usage(private->pPixmap); |
pScreen->ModifyPixmapHeader(private->pPixmap, 0, 0, 0, 0, 0, NULL); |
/* Second call to make sure texture has valid contents */ |
exaMoveInPixmap(private->pPixmap); |
tex = xorg_exa_get_texture(private->pPixmap); |
} |
if (!tex) |
FatalError("NO TEXTURE IN DRI2\n"); |
memset(&whandle, 0, sizeof(whandle)); |
whandle.type = DRM_API_HANDLE_TYPE_SHARED; |
ms->screen->resource_get_handle(ms->screen, tex, &whandle); |
buffer->name = whandle.handle; |
buffer->pitch = whandle.stride; |
buffer->cpp = 4; |
buffer->driverPrivate = private; |
buffer->flags = 0; /* not tiled */ |
#if DRI2INFOREC_VERSION == 2 |
/* ABI forwards/backwards compatibility */ |
if (set_format_in_do_create_buffer) |
((DRI2Buffer2Ptr)buffer)->format = 0; |
#elif DRI2INFOREC_VERSION >= 3 |
buffer->format = 0; |
#endif |
private->tex = tex; |
return TRUE; |
} |
static void |
dri2_do_destroy_buffer(DrawablePtr pDraw, DRI2BufferPtr buffer) |
{ |
ScreenPtr pScreen = pDraw->pScreen; |
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); |
modesettingPtr ms = modesettingPTR(pScrn); |
BufferPrivatePtr private = buffer->driverPrivate; |
struct exa_pixmap_priv *exa_priv = exaGetPixmapDriverPrivate(private->pPixmap); |
pipe_resource_reference(&private->tex, NULL); |
ms->screen->fence_reference(ms->screen, &private->fence, NULL); |
pipe_resource_reference(&exa_priv->depth_stencil_tex, NULL); |
(*pScreen->DestroyPixmap)(private->pPixmap); |
} |
#if DRI2INFOREC_VERSION >= 2 |
static DRI2Buffer2Ptr |
dri2_create_buffer(DrawablePtr pDraw, unsigned int attachment, unsigned int format) |
{ |
DRI2Buffer2Ptr buffer; |
BufferPrivatePtr private; |
buffer = calloc(1, sizeof *buffer); |
if (!buffer) |
return NULL; |
private = calloc(1, sizeof *private); |
if (!private) { |
goto fail; |
} |
buffer->attachment = attachment; |
buffer->driverPrivate = private; |
/* So far it is safe to downcast a DRI2Buffer2Ptr to DRI2BufferPtr */ |
if (dri2_do_create_buffer(pDraw, (DRI2BufferPtr)buffer, format)) |
return buffer; |
free(private); |
fail: |
free(buffer); |
return NULL; |
} |
static void |
dri2_destroy_buffer(DrawablePtr pDraw, DRI2Buffer2Ptr buffer) |
{ |
/* So far it is safe to downcast a DRI2Buffer2Ptr to DRI2BufferPtr */ |
dri2_do_destroy_buffer(pDraw, (DRI2BufferPtr)buffer); |
free(buffer->driverPrivate); |
free(buffer); |
} |
#endif /* DRI2INFOREC_VERSION >= 2 */ |
#if DRI2INFOREC_VERSION <= 2 |
static DRI2BufferPtr |
dri2_create_buffers(DrawablePtr pDraw, unsigned int *attachments, int count) |
{ |
BufferPrivatePtr privates; |
DRI2BufferPtr buffers; |
int i; |
buffers = calloc(count, sizeof *buffers); |
if (!buffers) |
goto fail_buffers; |
privates = calloc(count, sizeof *privates); |
if (!privates) |
goto fail_privates; |
for (i = 0; i < count; i++) { |
buffers[i].attachment = attachments[i]; |
buffers[i].driverPrivate = &privates[i]; |
if (!dri2_do_create_buffer(pDraw, &buffers[i], 0)) |
goto fail; |
} |
return buffers; |
fail: |
free(privates); |
fail_privates: |
free(buffers); |
fail_buffers: |
return NULL; |
} |
static void |
dri2_destroy_buffers(DrawablePtr pDraw, DRI2BufferPtr buffers, int count) |
{ |
int i; |
for (i = 0; i < count; i++) { |
dri2_do_destroy_buffer(pDraw, &buffers[i]); |
} |
if (buffers) { |
free(buffers[0].driverPrivate); |
free(buffers); |
} |
} |
#endif /* DRI2INFOREC_VERSION <= 2 */ |
static void |
dri2_copy_region(DrawablePtr pDraw, RegionPtr pRegion, |
DRI2BufferPtr pDestBuffer, DRI2BufferPtr pSrcBuffer) |
{ |
ScreenPtr pScreen = pDraw->pScreen; |
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); |
modesettingPtr ms = modesettingPTR(pScrn); |
BufferPrivatePtr dst_priv = pDestBuffer->driverPrivate; |
BufferPrivatePtr src_priv = pSrcBuffer->driverPrivate; |
DrawablePtr src_draw; |
DrawablePtr dst_draw; |
GCPtr gc; |
RegionPtr copy_clip; |
Bool save_accel; |
CustomizerPtr cust = ms->cust; |
/* |
* In driCreateBuffers we dewrap windows into the |
* backing pixmaps in order to get to the texture. |
* We need to use the real drawable in CopyArea |
* so that cliprects and offsets are correct. |
*/ |
src_draw = (pSrcBuffer->attachment == DRI2BufferFrontLeft) ? pDraw : |
&src_priv->pPixmap->drawable; |
dst_draw = (pDestBuffer->attachment == DRI2BufferFrontLeft) ? pDraw : |
&dst_priv->pPixmap->drawable; |
/* |
* The clients implements glXWaitX with a copy front to fake and then |
* waiting on the server to signal its completion of it. While |
* glXWaitGL is a client side flush and a copy from fake to front. |
* This is how it is done in the DRI2 protocol, how ever depending |
* which type of drawables the server does things a bit differently |
* then what the protocol says as the fake and front are the same. |
* |
* for pixmaps glXWaitX is a server flush. |
* for pixmaps glXWaitGL is a client flush. |
* for windows glXWaitX is a copy from front to fake then a server flush. |
* for windows glXWaitGL is a client flush then a copy from fake to front. |
* |
* XXX in the windows case this code always flushes but that isn't a |
* must in the glXWaitGL case but we don't know if this is a glXWaitGL |
* or a glFlush/glFinish call. |
*/ |
if (dst_priv->pPixmap == src_priv->pPixmap) { |
/* pixmap glXWaitX */ |
if (pSrcBuffer->attachment == DRI2BufferFrontLeft && |
pDestBuffer->attachment == DRI2BufferFakeFrontLeft) { |
ms->ctx->flush(ms->ctx, NULL, 0); |
return; |
} |
/* pixmap glXWaitGL */ |
if (pDestBuffer->attachment == DRI2BufferFrontLeft && |
pSrcBuffer->attachment == DRI2BufferFakeFrontLeft) { |
return; |
} else { |
xf86DrvMsg(pScrn->scrnIndex, X_WARNING, |
"copying between the same pixmap\n"); |
} |
} |
gc = GetScratchGC(pDraw->depth, pScreen); |
copy_clip = REGION_CREATE(pScreen, NULL, 0); |
REGION_COPY(pScreen, copy_clip, pRegion); |
(*gc->funcs->ChangeClip) (gc, CT_REGION, copy_clip, 0); |
ValidateGC(dst_draw, gc); |
/* If this is a full buffer swap, throttle on the previous one */ |
if (ms->swapThrottling && |
dst_priv->fence && REGION_NUM_RECTS(pRegion) == 1) { |
BoxPtr extents = REGION_EXTENTS(pScreen, pRegion); |
if (extents->x1 == 0 && extents->y1 == 0 && |
extents->x2 == pDraw->width && extents->y2 == pDraw->height) { |
ms->screen->fence_finish(ms->screen, dst_priv->fence, |
PIPE_TIMEOUT_INFINITE); |
ms->screen->fence_reference(ms->screen, &dst_priv->fence, NULL); |
} |
} |
/* Try to make sure the blit will be accelerated */ |
save_accel = ms->exa->accel; |
ms->exa->accel = TRUE; |
if (pSrcBuffer->attachment != DRI2BufferFrontLeft) { |
/* In case it won't be though, make sure the GPU copy contents of the |
* source pixmap will be used for the software fallback - presumably the |
* client modified them before calling in here. |
*/ |
exaMoveInPixmap(src_priv->pPixmap); |
DamageRegionAppend(src_draw, pRegion); |
DamageRegionProcessPending(src_draw); |
} |
if (cust && cust->winsys_context_throttle) |
cust->winsys_context_throttle(cust, ms->ctx, THROTTLE_SWAP); |
(*gc->ops->CopyArea)(src_draw, dst_draw, gc, |
0, 0, pDraw->width, pDraw->height, 0, 0); |
ms->exa->accel = save_accel; |
FreeScratchGC(gc); |
ms->ctx->flush(ms->ctx, |
(pDestBuffer->attachment == DRI2BufferFrontLeft |
&& ms->swapThrottling) ? |
&dst_priv->fence : NULL, 0); |
if (cust && cust->winsys_context_throttle) |
cust->winsys_context_throttle(cust, ms->ctx, THROTTLE_RENDER); |
} |
Bool |
xorg_dri2_init(ScreenPtr pScreen) |
{ |
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); |
modesettingPtr ms = modesettingPTR(pScrn); |
DRI2InfoRec dri2info; |
#if DRI2INFOREC_VERSION >= 2 |
int major, minor; |
if (xf86LoaderCheckSymbol("DRI2Version")) { |
DRI2Version(&major, &minor); |
} else { |
/* Assume version 1.0 */ |
major = 1; |
minor = 0; |
} |
#endif |
dri2info.version = min(DRI2INFOREC_VERSION, 3); |
dri2info.fd = ms->fd; |
dri2info.driverName = pScrn->driverName; |
dri2info.deviceName = "/dev/dri/card0"; /* FIXME */ |
#if DRI2INFOREC_VERSION >= 2 |
dri2info.CreateBuffer = dri2_create_buffer; |
dri2info.DestroyBuffer = dri2_destroy_buffer; |
#endif |
/* For X servers in the 1.6.x series there where two DRI2 version. |
* This allows us to build one binary that works on both servers. |
*/ |
#if DRI2INFOREC_VERSION == 2 |
if (minor == 0) { |
set_format_in_do_create_buffer = FALSE; |
dri2info.CreateBuffers = dri2_create_buffers; |
dri2info.DestroyBuffers = dri2_destroy_buffers; |
} else |
set_format_in_do_create_buffer = FALSE; |
#endif |
/* For version 1 set these unconditionaly. */ |
#if DRI2INFOREC_VERSION == 1 |
dri2info.CreateBuffers = dri2_create_buffers; |
dri2info.DestroyBuffers = dri2_destroy_buffers; |
#endif |
dri2info.CopyRegion = dri2_copy_region; |
dri2info.Wait = NULL; |
ms->d_depth_bits_last = |
ms->screen->is_format_supported(ms->screen, PIPE_FORMAT_Z24X8_UNORM, |
PIPE_TEXTURE_2D, |
0, |
PIPE_BIND_DEPTH_STENCIL); |
ms->ds_depth_bits_last = |
ms->screen->is_format_supported(ms->screen, PIPE_FORMAT_Z24_UNORM_S8_UINT, |
PIPE_TEXTURE_2D, |
0, |
PIPE_BIND_DEPTH_STENCIL); |
return DRI2ScreenInit(pScreen, &dri2info); |
} |
void |
xorg_dri2_close(ScreenPtr pScreen) |
{ |
DRI2CloseScreen(pScreen); |
} |
/* vim: set sw=4 ts=8 sts=4: */ |
/contrib/sdk/sources/Mesa/mesa-9.2.5/src/gallium/state_trackers/xorg/xorg_driver.c |
---|
0,0 → 1,1318 |
/* |
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. |
* All Rights Reserved. |
* |
* 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, sub license, 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 (including the |
* next paragraph) 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 NON-INFRINGEMENT. |
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. |
* |
* |
* Author: Alan Hourihane <alanh@tungstengraphics.com> |
* Author: Jakob Bornecrantz <wallbraker@gmail.com> |
* |
*/ |
#include "xorg-server.h" |
#include "xf86.h" |
#include "xf86_OSproc.h" |
#include "compiler.h" |
#include "xf86PciInfo.h" |
#include "xf86Pci.h" |
#include "mipointer.h" |
#include "micmap.h" |
#include <X11/extensions/randr.h> |
#include "fb.h" |
#include "edid.h" |
#include "xf86i2c.h" |
#include "xf86Crtc.h" |
#include "miscstruct.h" |
#include "dixstruct.h" |
#include "xf86cmap.h" |
#include "xf86xv.h" |
#include "xorgVersion.h" |
#ifndef XSERVER_LIBPCIACCESS |
#error "libpciaccess needed" |
#endif |
#include <pciaccess.h> |
#include "state_tracker/drm_driver.h" |
#include "pipe/p_context.h" |
#include "xorg_tracker.h" |
#include "xorg_winsys.h" |
#ifdef HAVE_LIBKMS |
#include "libkms/libkms.h" |
#endif |
#if XORG_VERSION_CURRENT >= XORG_VERSION_NUMERIC(1,14,99,2,0) |
#define DamageUnregister(d, dd) DamageUnregister(dd) |
#endif |
/* |
* Functions and symbols exported to Xorg via pointers. |
*/ |
static Bool drv_pre_init(ScrnInfoPtr pScrn, int flags); |
static Bool drv_screen_init(SCREEN_INIT_ARGS_DECL); |
static Bool drv_switch_mode(SWITCH_MODE_ARGS_DECL); |
static void drv_adjust_frame(ADJUST_FRAME_ARGS_DECL); |
static Bool drv_enter_vt(VT_FUNC_ARGS_DECL); |
static Bool drv_enter_vt_flags(ScrnInfoPtr pScrn, int flags); |
static void drv_leave_vt(VT_FUNC_ARGS_DECL); |
static void drv_free_screen(FREE_SCREEN_ARGS_DECL); |
static ModeStatus drv_valid_mode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, |
int flags); |
typedef enum |
{ |
OPTION_SW_CURSOR, |
OPTION_2D_ACCEL, |
OPTION_DEBUG_FALLBACK, |
OPTION_THROTTLE_SWAP, |
OPTION_THROTTLE_DIRTY, |
OPTION_3D_ACCEL |
} drv_option_enums; |
static const OptionInfoRec drv_options[] = { |
{OPTION_SW_CURSOR, "SWcursor", OPTV_BOOLEAN, {0}, FALSE}, |
{OPTION_2D_ACCEL, "2DAccel", OPTV_BOOLEAN, {0}, FALSE}, |
{OPTION_DEBUG_FALLBACK, "DebugFallback", OPTV_BOOLEAN, {0}, FALSE}, |
{OPTION_THROTTLE_SWAP, "SwapThrottling", OPTV_BOOLEAN, {0}, FALSE}, |
{OPTION_THROTTLE_DIRTY, "DirtyThrottling", OPTV_BOOLEAN, {0}, FALSE}, |
{OPTION_3D_ACCEL, "3DAccel", OPTV_BOOLEAN, {0}, FALSE}, |
{-1, NULL, OPTV_NONE, {0}, FALSE} |
}; |
/* |
* Exported Xorg driver functions to winsys |
*/ |
const OptionInfoRec * |
xorg_tracker_available_options(int chipid, int busid) |
{ |
return drv_options; |
} |
void |
xorg_tracker_set_functions(ScrnInfoPtr scrn) |
{ |
scrn->PreInit = drv_pre_init; |
scrn->ScreenInit = drv_screen_init; |
scrn->SwitchMode = drv_switch_mode; |
scrn->AdjustFrame = drv_adjust_frame; |
scrn->EnterVT = drv_enter_vt; |
scrn->LeaveVT = drv_leave_vt; |
scrn->FreeScreen = drv_free_screen; |
scrn->ValidMode = drv_valid_mode; |
} |
Bool |
xorg_tracker_have_modesetting(ScrnInfoPtr pScrn, struct pci_device *device) |
{ |
char *BusID = malloc(64); |
sprintf(BusID, "pci:%04x:%02x:%02x.%d", |
device->domain, device->bus, |
device->dev, device->func); |
if (drmCheckModesettingSupported(BusID)) { |
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 0, |
"Drm modesetting not supported %s\n", BusID); |
free(BusID); |
return FALSE; |
} |
xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 0, |
"Drm modesetting supported on %s\n", BusID); |
free(BusID); |
return TRUE; |
} |
/* |
* Internal function definitions |
*/ |
static Bool drv_init_front_buffer_functions(ScrnInfoPtr pScrn); |
static Bool drv_close_screen(CLOSE_SCREEN_ARGS_DECL); |
/* |
* Internal functions |
*/ |
static Bool |
drv_get_rec(ScrnInfoPtr pScrn) |
{ |
if (pScrn->driverPrivate) |
return TRUE; |
pScrn->driverPrivate = xnfcalloc(1, sizeof(modesettingRec)); |
return TRUE; |
} |
static void |
drv_free_rec(ScrnInfoPtr pScrn) |
{ |
if (!pScrn) |
return; |
if (!pScrn->driverPrivate) |
return; |
free(pScrn->driverPrivate); |
pScrn->driverPrivate = NULL; |
} |
static void |
drv_probe_ddc(ScrnInfoPtr pScrn, int index) |
{ |
ConfiguredMonitor = NULL; |
} |
static Bool |
drv_crtc_resize(ScrnInfoPtr pScrn, int width, int height) |
{ |
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); |
modesettingPtr ms = modesettingPTR(pScrn); |
CustomizerPtr cust = ms->cust; |
ScreenPtr pScreen = pScrn->pScreen; |
int old_width, old_height; |
PixmapPtr rootPixmap; |
int i; |
if (width == pScrn->virtualX && height == pScrn->virtualY) |
return TRUE; |
if (cust && cust->winsys_check_fb_size && |
!cust->winsys_check_fb_size(cust, width*pScrn->bitsPerPixel / 8, |
height)) { |
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
"Requested framebuffer size %dx%dx%d will not fit " |
"in display memory.\n", |
width, height, pScrn->bitsPerPixel); |
return FALSE; |
} |
old_width = pScrn->virtualX; |
old_height = pScrn->virtualY; |
pScrn->virtualX = width; |
pScrn->virtualY = height; |
/* ms->create_front_buffer will remove the old front buffer */ |
rootPixmap = pScreen->GetScreenPixmap(pScreen); |
if (!pScreen->ModifyPixmapHeader(rootPixmap, width, height, -1, -1, -1, NULL)) |
goto error_modify; |
pScrn->displayWidth = rootPixmap->devKind / (rootPixmap->drawable.bitsPerPixel / 8); |
if (!ms->create_front_buffer(pScrn) || !ms->bind_front_buffer(pScrn)) |
goto error_create; |
/* |
* create && bind will turn off all crtc(s) in the kernel so we need to |
* re-enable all the crtcs again. For real HW we might want to do this |
* before destroying the old framebuffer. |
*/ |
for (i = 0; i < xf86_config->num_crtc; i++) { |
xf86CrtcPtr crtc = xf86_config->crtc[i]; |
if (!crtc->enabled) |
continue; |
crtc->funcs->set_mode_major(crtc, &crtc->mode, crtc->rotation, crtc->x, crtc->y); |
} |
return TRUE; |
/* |
* This is the error recovery path. |
*/ |
error_create: |
if (!pScreen->ModifyPixmapHeader(rootPixmap, old_width, old_height, -1, -1, -1, NULL)) |
FatalError("failed to resize rootPixmap error path\n"); |
pScrn->displayWidth = rootPixmap->devKind / (rootPixmap->drawable.bitsPerPixel / 8); |
error_modify: |
pScrn->virtualX = old_width; |
pScrn->virtualY = old_height; |
if (ms->create_front_buffer(pScrn) && ms->bind_front_buffer(pScrn)) |
return FALSE; |
FatalError("failed to setup old framebuffer\n"); |
return FALSE; |
} |
static const xf86CrtcConfigFuncsRec crtc_config_funcs = { |
.resize = drv_crtc_resize |
}; |
static Bool |
drv_init_drm(ScrnInfoPtr pScrn) |
{ |
modesettingPtr ms = modesettingPTR(pScrn); |
/* deal with server regeneration */ |
if (ms->fd < 0) { |
char *BusID; |
BusID = malloc(64); |
sprintf(BusID, "PCI:%d:%d:%d", |
((ms->PciInfo->domain << 8) | ms->PciInfo->bus), |
ms->PciInfo->dev, ms->PciInfo->func |
); |
ms->fd = drmOpen(driver_descriptor.driver_name, BusID); |
ms->isMaster = TRUE; |
free(BusID); |
if (ms->fd >= 0) |
return TRUE; |
return FALSE; |
} |
return TRUE; |
} |
static Bool |
drv_init_resource_management(ScrnInfoPtr pScrn) |
{ |
modesettingPtr ms = modesettingPTR(pScrn); |
/* |
ScreenPtr pScreen = pScrn->pScreen; |
PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen); |
Bool fbAccessDisabled; |
CARD8 *fbstart; |
*/ |
if (ms->screen || ms->kms) |
return TRUE; |
if (!ms->no3D) |
ms->screen = driver_descriptor.create_screen(ms->fd); |
if (ms->screen) |
return TRUE; |
#ifdef HAVE_LIBKMS |
if (!kms_create(ms->fd, &ms->kms)) |
return TRUE; |
#endif |
return FALSE; |
} |
static void |
drv_cleanup_fences(ScrnInfoPtr pScrn) |
{ |
modesettingPtr ms = modesettingPTR(pScrn); |
int i; |
assert(ms->screen); |
for (i = 0; i < XORG_NR_FENCES; i++) { |
if (ms->fence[i]) { |
ms->screen->fence_finish(ms->screen, ms->fence[i], |
PIPE_TIMEOUT_INFINITE); |
ms->screen->fence_reference(ms->screen, &ms->fence[i], NULL); |
} |
} |
} |
static Bool |
drv_pre_init(ScrnInfoPtr pScrn, int flags) |
{ |
xf86CrtcConfigPtr xf86_config; |
modesettingPtr ms; |
rgb defaultWeight = { 0, 0, 0 }; |
EntityInfoPtr pEnt; |
EntPtr msEnt = NULL; |
CustomizerPtr cust; |
Bool use3D; |
if (pScrn->numEntities != 1) |
return FALSE; |
pEnt = xf86GetEntityInfo(pScrn->entityList[0]); |
if (flags & PROBE_DETECT) { |
drv_probe_ddc(pScrn, pEnt->index); |
return TRUE; |
} |
cust = (CustomizerPtr) pScrn->driverPrivate; |
pScrn->driverPrivate = NULL; |
/* Allocate driverPrivate */ |
if (!drv_get_rec(pScrn)) |
return FALSE; |
ms = modesettingPTR(pScrn); |
ms->pEnt = pEnt; |
ms->cust = cust; |
ms->fb_id = -1; |
pScrn->displayWidth = 640; /* default it */ |
if (ms->pEnt->location.type != BUS_PCI) |
return FALSE; |
ms->PciInfo = xf86GetPciInfoForEntity(ms->pEnt->index); |
/* Allocate an entity private if necessary */ |
if (xf86IsEntityShared(pScrn->entityList[0])) { |
FatalError("Entity"); |
#if 0 |
msEnt = xf86GetEntityPrivate(pScrn->entityList[0], |
modesettingEntityIndex)->ptr; |
ms->entityPrivate = msEnt; |
#else |
(void)msEnt; |
#endif |
} else |
ms->entityPrivate = NULL; |
if (xf86IsEntityShared(pScrn->entityList[0])) { |
if (xf86IsPrimInitDone(pScrn->entityList[0])) { |
/* do something */ |
} else { |
xf86SetPrimInitDone(pScrn->entityList[0]); |
} |
} |
ms->fd = -1; |
if (!drv_init_drm(pScrn)) |
return FALSE; |
pScrn->monitor = pScrn->confScreen->monitor; |
pScrn->progClock = TRUE; |
pScrn->rgbBits = 8; |
if (!xf86SetDepthBpp |
(pScrn, 0, 0, 0, |
PreferConvert24to32 | SupportConvert24to32 | Support32bppFb)) |
return FALSE; |
switch (pScrn->depth) { |
case 8: |
case 15: |
case 16: |
case 24: |
break; |
default: |
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
"Given depth (%d) is not supported by the driver\n", |
pScrn->depth); |
return FALSE; |
} |
xf86PrintDepthBpp(pScrn); |
if (!xf86SetWeight(pScrn, defaultWeight, defaultWeight)) |
return FALSE; |
if (!xf86SetDefaultVisual(pScrn, -1)) |
return FALSE; |
/* Process the options */ |
xf86CollectOptions(pScrn, NULL); |
if (!(ms->Options = malloc(sizeof(drv_options)))) |
return FALSE; |
memcpy(ms->Options, drv_options, sizeof(drv_options)); |
xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, ms->Options); |
use3D = cust ? !cust->no_3d : TRUE; |
ms->from_3D = xf86GetOptValBool(ms->Options, OPTION_3D_ACCEL, |
&use3D) ? |
X_CONFIG : X_PROBED; |
ms->no3D = !use3D; |
if (!drv_init_resource_management(pScrn)) { |
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Could not init " |
"Gallium3D or libKMS.\n"); |
return FALSE; |
} |
/* Allocate an xf86CrtcConfig */ |
xf86CrtcConfigInit(pScrn, &crtc_config_funcs); |
xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); |
/* get max width and height */ |
{ |
drmModeResPtr res; |
int max_width, max_height; |
res = drmModeGetResources(ms->fd); |
max_width = res->max_width; |
max_height = res->max_height; |
if (ms->screen) { |
int max; |
max = ms->screen->get_param(ms->screen, |
PIPE_CAP_MAX_TEXTURE_2D_LEVELS); |
max = 1 << (max - 1); |
max_width = max < max_width ? max : max_width; |
max_height = max < max_height ? max : max_height; |
} |
xf86CrtcSetSizeRange(pScrn, res->min_width, |
res->min_height, max_width, max_height); |
xf86DrvMsg(pScrn->scrnIndex, X_PROBED, |
"Min width %d, Max Width %d.\n", |
res->min_width, max_width); |
xf86DrvMsg(pScrn->scrnIndex, X_PROBED, |
"Min height %d, Max Height %d.\n", |
res->min_height, max_height); |
drmModeFreeResources(res); |
} |
if (xf86ReturnOptValBool(ms->Options, OPTION_SW_CURSOR, FALSE)) { |
ms->SWCursor = TRUE; |
} |
xorg_crtc_init(pScrn); |
xorg_output_init(pScrn); |
if (cust && cust->winsys_pre_init && !cust->winsys_pre_init(cust, ms->fd)) |
return FALSE; |
if (!xf86InitialConfiguration(pScrn, TRUE)) { |
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No valid modes.\n"); |
return FALSE; |
} |
/* |
* If the driver can do gamma correction, it should call xf86SetGamma() here. |
*/ |
{ |
Gamma zeros = { 0.0, 0.0, 0.0 }; |
if (!xf86SetGamma(pScrn, zeros)) { |
return FALSE; |
} |
} |
if (pScrn->modes == NULL) { |
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "No modes.\n"); |
return FALSE; |
} |
pScrn->currentMode = pScrn->modes; |
/* Set display resolution */ |
xf86SetDpi(pScrn, 0, 0); |
/* Load the required sub modules */ |
if (!xf86LoadSubModule(pScrn, "fb")) |
return FALSE; |
/* XXX: these aren't needed when we are using libkms */ |
if (!xf86LoadSubModule(pScrn, "exa")) |
return FALSE; |
#ifdef DRI2 |
if (!xf86LoadSubModule(pScrn, "dri2")) |
return FALSE; |
#endif |
return TRUE; |
} |
void xorg_flush(ScreenPtr pScreen) |
{ |
modesettingPtr ms = modesettingPTR(xf86ScreenToScrn(pScreen)); |
if (ms->ctx) { |
int j; |
ms->ctx->flush(ms->ctx, |
ms->dirtyThrottling ? |
&ms->fence[XORG_NR_FENCES-1] : |
NULL, 0); |
if (ms->dirtyThrottling) { |
if (ms->fence[0]) |
ms->ctx->screen->fence_finish(ms->ctx->screen, |
ms->fence[0], |
PIPE_TIMEOUT_INFINITE); |
/* The amount of rendering generated by a block handler can be |
* quite small. Let us get a fair way ahead of hardware before |
* throttling. |
*/ |
for (j = 0; j < XORG_NR_FENCES - 1; j++) |
ms->screen->fence_reference(ms->screen, |
&ms->fence[j], |
ms->fence[j+1]); |
ms->screen->fence_reference(ms->screen, |
&ms->fence[XORG_NR_FENCES-1], |
NULL); |
} |
} |
#ifdef DRM_MODE_FEATURE_DIRTYFB |
{ |
RegionPtr dirty = DamageRegion(ms->damage); |
unsigned num_cliprects = REGION_NUM_RECTS(dirty); |
if (num_cliprects) { |
drmModeClip *clip = alloca(num_cliprects * sizeof(drmModeClip)); |
BoxPtr rect = REGION_RECTS(dirty); |
int i, ret; |
/* XXX no need for copy? */ |
for (i = 0; i < num_cliprects; i++, rect++) { |
clip[i].x1 = rect->x1; |
clip[i].y1 = rect->y1; |
clip[i].x2 = rect->x2; |
clip[i].y2 = rect->y2; |
} |
/* TODO query connector property to see if this is needed */ |
ret = drmModeDirtyFB(ms->fd, ms->fb_id, clip, num_cliprects); |
if (ret) { |
debug_printf("%s: failed to send dirty (%i, %s)\n", |
__func__, ret, strerror(-ret)); |
} |
DamageEmpty(ms->damage); |
} |
} |
#endif |
} |
static void drv_block_handler(BLOCKHANDLER_ARGS_DECL) |
{ |
SCREEN_PTR(arg); |
modesettingPtr ms = modesettingPTR(xf86ScreenToScrn(pScreen)); |
pScreen->BlockHandler = ms->blockHandler; |
pScreen->BlockHandler(BLOCKHANDLER_ARGS); |
pScreen->BlockHandler = drv_block_handler; |
xorg_flush(pScreen); |
} |
static Bool |
drv_create_screen_resources(ScreenPtr pScreen) |
{ |
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); |
modesettingPtr ms = modesettingPTR(pScrn); |
PixmapPtr rootPixmap; |
Bool ret; |
ms->noEvict = TRUE; |
pScreen->CreateScreenResources = ms->createScreenResources; |
ret = pScreen->CreateScreenResources(pScreen); |
pScreen->CreateScreenResources = drv_create_screen_resources; |
ms->bind_front_buffer(pScrn); |
ms->noEvict = FALSE; |
drv_adjust_frame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0)); |
#ifdef DRM_MODE_FEATURE_DIRTYFB |
rootPixmap = pScreen->GetScreenPixmap(pScreen); |
ms->damage = DamageCreate(NULL, NULL, DamageReportNone, TRUE, |
pScreen, rootPixmap); |
if (ms->damage) { |
DamageRegister(&rootPixmap->drawable, ms->damage); |
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Damage tracking initialized\n"); |
} else { |
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
"Failed to create screen damage record\n"); |
return FALSE; |
} |
#else |
(void)rootPixmap; |
#endif |
return ret; |
} |
static Bool |
drv_set_master(ScrnInfoPtr pScrn) |
{ |
modesettingPtr ms = modesettingPTR(pScrn); |
if (!ms->isMaster && drmSetMaster(ms->fd) != 0) { |
if (errno == EINVAL) { |
xf86DrvMsg(pScrn->scrnIndex, X_WARNING, |
"drmSetMaster failed: 2.6.29 or newer kernel required for " |
"multi-server DRI\n"); |
} else { |
xf86DrvMsg(pScrn->scrnIndex, X_WARNING, |
"drmSetMaster failed: %s\n", strerror(errno)); |
} |
return FALSE; |
} |
ms->isMaster = TRUE; |
return TRUE; |
} |
static void drv_load_palette(ScrnInfoPtr pScrn, int numColors, |
int *indices, LOCO *colors, VisualPtr pVisual) |
{ |
xf86CrtcConfigPtr xf86_config = XF86_CRTC_CONFIG_PTR(pScrn); |
modesettingPtr ms = modesettingPTR(pScrn); |
int index, j, i; |
int c; |
switch(pScrn->depth) { |
case 15: |
for (i = 0; i < numColors; i++) { |
index = indices[i]; |
for (j = 0; j < 8; j++) { |
ms->lut_r[index * 8 + j] = colors[index].red << 8; |
ms->lut_g[index * 8 + j] = colors[index].green << 8; |
ms->lut_b[index * 8 + j] = colors[index].blue << 8; |
} |
} |
break; |
case 16: |
for (i = 0; i < numColors; i++) { |
index = indices[i]; |
if (index < 32) { |
for (j = 0; j < 8; j++) { |
ms->lut_r[index * 8 + j] = colors[index].red << 8; |
ms->lut_b[index * 8 + j] = colors[index].blue << 8; |
} |
} |
for (j = 0; j < 4; j++) { |
ms->lut_g[index * 4 + j] = colors[index].green << 8; |
} |
} |
break; |
default: |
for (i = 0; i < numColors; i++) { |
index = indices[i]; |
ms->lut_r[index] = colors[index].red << 8; |
ms->lut_g[index] = colors[index].green << 8; |
ms->lut_b[index] = colors[index].blue << 8; |
} |
break; |
} |
for (c = 0; c < xf86_config->num_crtc; c++) { |
xf86CrtcPtr crtc = xf86_config->crtc[c]; |
/* Make the change through RandR */ |
#ifdef RANDR_12_INTERFACE |
if (crtc->randr_crtc) |
RRCrtcGammaSet(crtc->randr_crtc, ms->lut_r, ms->lut_g, ms->lut_b); |
else |
#endif |
crtc->funcs->gamma_set(crtc, ms->lut_r, ms->lut_g, ms->lut_b, 256); |
} |
} |
static Bool |
drv_screen_init(SCREEN_INIT_ARGS_DECL) |
{ |
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); |
modesettingPtr ms = modesettingPTR(pScrn); |
VisualPtr visual; |
CustomizerPtr cust = ms->cust; |
MessageType from_st; |
MessageType from_dt; |
if (!drv_set_master(pScrn)) |
return FALSE; |
if (!drv_init_front_buffer_functions(pScrn)) { |
FatalError("Could not init front buffer manager"); |
return FALSE; |
} |
pScrn->pScreen = pScreen; |
/* HW dependent - FIXME */ |
pScrn->displayWidth = pScrn->virtualX; |
miClearVisualTypes(); |
if (!miSetVisualTypes(pScrn->depth, |
miGetDefaultVisualMask(pScrn->depth), |
pScrn->rgbBits, pScrn->defaultVisual)) |
return FALSE; |
if (!miSetPixmapDepths()) |
return FALSE; |
pScrn->memPhysBase = 0; |
pScrn->fbOffset = 0; |
if (!fbScreenInit(pScreen, NULL, |
pScrn->virtualX, pScrn->virtualY, |
pScrn->xDpi, pScrn->yDpi, |
pScrn->displayWidth, pScrn->bitsPerPixel)) |
return FALSE; |
if (pScrn->bitsPerPixel > 8) { |
/* Fixup RGB ordering */ |
visual = pScreen->visuals + pScreen->numVisuals; |
while (--visual >= pScreen->visuals) { |
if ((visual->class | DynamicClass) == DirectColor) { |
visual->offsetRed = pScrn->offset.red; |
visual->offsetGreen = pScrn->offset.green; |
visual->offsetBlue = pScrn->offset.blue; |
visual->redMask = pScrn->mask.red; |
visual->greenMask = pScrn->mask.green; |
visual->blueMask = pScrn->mask.blue; |
} |
} |
} |
fbPictureInit(pScreen, NULL, 0); |
ms->blockHandler = pScreen->BlockHandler; |
pScreen->BlockHandler = drv_block_handler; |
ms->createScreenResources = pScreen->CreateScreenResources; |
pScreen->CreateScreenResources = drv_create_screen_resources; |
xf86SetBlackWhitePixels(pScreen); |
ms->accelerate_2d = xf86ReturnOptValBool(ms->Options, OPTION_2D_ACCEL, FALSE); |
ms->debug_fallback = xf86ReturnOptValBool(ms->Options, OPTION_DEBUG_FALLBACK, ms->accelerate_2d); |
if (cust && cust->winsys_screen_init) |
cust->winsys_screen_init(cust); |
ms->swapThrottling = cust ? cust->swap_throttling : TRUE; |
from_st = xf86GetOptValBool(ms->Options, OPTION_THROTTLE_SWAP, |
&ms->swapThrottling) ? |
X_CONFIG : X_DEFAULT; |
ms->dirtyThrottling = cust ? cust->dirty_throttling : FALSE; |
from_dt = xf86GetOptValBool(ms->Options, OPTION_THROTTLE_DIRTY, |
&ms->dirtyThrottling) ? |
X_CONFIG : X_DEFAULT; |
if (ms->screen) { |
ms->exa = xorg_exa_init(pScrn, ms->accelerate_2d); |
xorg_xv_init(pScreen); |
#ifdef DRI2 |
xorg_dri2_init(pScreen); |
#endif |
} |
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "#################################\n"); |
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "# Useful debugging info follows #\n"); |
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "#################################\n"); |
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Using %s backend\n", |
ms->screen ? "Gallium3D" : "libkms"); |
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "2D Acceleration is %s\n", |
ms->screen && ms->accelerate_2d ? "enabled" : "disabled"); |
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "Fallback debugging is %s\n", |
ms->debug_fallback ? "enabled" : "disabled"); |
#ifdef DRI2 |
xf86DrvMsg(pScrn->scrnIndex, ms->from_3D, "3D Acceleration is %s\n", |
ms->screen ? "enabled" : "disabled"); |
#else |
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "3D Acceleration is disabled\n"); |
#endif |
xf86DrvMsg(pScrn->scrnIndex, from_st, "Swap Throttling is %s.\n", |
ms->swapThrottling ? "enabled" : "disabled"); |
xf86DrvMsg(pScrn->scrnIndex, from_dt, "Dirty Throttling is %s.\n", |
ms->dirtyThrottling ? "enabled" : "disabled"); |
xf86DrvMsg(pScrn->scrnIndex, X_INFO, "##################################\n"); |
xf86SetBackingStore(pScreen); |
xf86SetSilkenMouse(pScreen); |
miDCInitialize(pScreen, xf86GetPointerScreenFuncs()); |
/* Need to extend HWcursor support to handle mask interleave */ |
if (!ms->SWCursor) |
xf86_cursors_init(pScreen, 64, 64, |
HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 | |
HARDWARE_CURSOR_ARGB | |
((cust && cust->unhidden_hw_cursor_update) ? |
HARDWARE_CURSOR_UPDATE_UNHIDDEN : 0)); |
/* Must force it before EnterVT, so we are in control of VT and |
* later memory should be bound when allocating, e.g rotate_mem */ |
pScrn->vtSema = TRUE; |
pScreen->SaveScreen = xf86SaveScreen; |
ms->CloseScreen = pScreen->CloseScreen; |
pScreen->CloseScreen = drv_close_screen; |
if (!xf86CrtcScreenInit(pScreen)) |
return FALSE; |
if (!miCreateDefColormap(pScreen)) |
return FALSE; |
if (!xf86HandleColormaps(pScreen, 256, 8, drv_load_palette, NULL, |
CMAP_PALETTED_TRUECOLOR | |
CMAP_RELOAD_ON_MODE_SWITCH)) |
return FALSE; |
xf86DPMSInit(pScreen, xf86DPMSSet, 0); |
if (serverGeneration == 1) |
xf86ShowUnusedOptions(pScrn->scrnIndex, pScrn->options); |
return drv_enter_vt_flags(pScrn, 1); |
} |
static void |
drv_adjust_frame(ADJUST_FRAME_ARGS_DECL) |
{ |
SCRN_INFO_PTR(arg); |
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); |
xf86OutputPtr output = config->output[config->compat_output]; |
xf86CrtcPtr crtc = output->crtc; |
if (crtc && crtc->enabled) { |
crtc->funcs->set_mode_major(crtc, pScrn->currentMode, |
RR_Rotate_0, x, y); |
crtc->x = output->initial_x + x; |
crtc->y = output->initial_y + y; |
} |
} |
static void |
drv_free_screen(FREE_SCREEN_ARGS_DECL) |
{ |
SCRN_INFO_PTR(arg); |
drv_free_rec(pScrn); |
} |
static void |
drv_leave_vt(VT_FUNC_ARGS_DECL) |
{ |
SCRN_INFO_PTR(arg); |
modesettingPtr ms = modesettingPTR(pScrn); |
xf86CrtcConfigPtr config = XF86_CRTC_CONFIG_PTR(pScrn); |
CustomizerPtr cust = ms->cust; |
int o; |
if (cust && cust->winsys_leave_vt) |
cust->winsys_leave_vt(cust); |
for (o = 0; o < config->num_crtc; o++) { |
xf86CrtcPtr crtc = config->crtc[o]; |
xorg_crtc_cursor_destroy(crtc); |
if (crtc->rotatedPixmap || crtc->rotatedData) { |
crtc->funcs->shadow_destroy(crtc, crtc->rotatedPixmap, |
crtc->rotatedData); |
crtc->rotatedPixmap = NULL; |
crtc->rotatedData = NULL; |
} |
} |
if (ms->fb_id != -1) { |
drmModeRmFB(ms->fd, ms->fb_id); |
ms->fb_id = -1; |
} |
/* idle hardware */ |
if (!ms->kms) |
drv_cleanup_fences(pScrn); |
if (drmDropMaster(ms->fd)) |
xf86DrvMsg(pScrn->scrnIndex, X_WARNING, |
"drmDropMaster failed: %s\n", strerror(errno)); |
ms->isMaster = FALSE; |
pScrn->vtSema = FALSE; |
} |
/* |
* This gets called when gaining control of the VT, and from ScreenInit(). |
*/ |
static Bool |
drv_enter_vt_flags(ScrnInfoPtr pScrn, int flags) |
{ |
modesettingPtr ms = modesettingPTR(pScrn); |
CustomizerPtr cust = ms->cust; |
if (!drv_set_master(pScrn)) |
return FALSE; |
if (!ms->create_front_buffer(pScrn)) |
return FALSE; |
if (!flags && !ms->bind_front_buffer(pScrn)) |
return FALSE; |
if (!xf86SetDesiredModes(pScrn)) |
return FALSE; |
if (cust && cust->winsys_enter_vt) |
cust->winsys_enter_vt(cust); |
return TRUE; |
} |
static Bool |
drv_enter_vt(VT_FUNC_ARGS_DECL) |
{ |
SCRN_INFO_PTR(arg); |
return drv_enter_vt_flags(pScrn, 0); |
} |
static Bool |
drv_switch_mode(SWITCH_MODE_ARGS_DECL) |
{ |
SCRN_INFO_PTR(arg); |
return xf86SetSingleMode(pScrn, mode, RR_Rotate_0); |
} |
static Bool |
drv_close_screen(CLOSE_SCREEN_ARGS_DECL) |
{ |
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); |
modesettingPtr ms = modesettingPTR(pScrn); |
CustomizerPtr cust = ms->cust; |
if (ms->cursor) { |
FreeCursor(ms->cursor, None); |
ms->cursor = NULL; |
} |
if (cust && cust->winsys_screen_close) |
cust->winsys_screen_close(cust); |
#ifdef DRI2 |
if (ms->screen) |
xorg_dri2_close(pScreen); |
#endif |
pScreen->BlockHandler = ms->blockHandler; |
pScreen->CreateScreenResources = ms->createScreenResources; |
#ifdef DRM_MODE_FEATURE_DIRTYFB |
if (ms->damage) { |
DamageUnregister(&pScreen->GetScreenPixmap(pScreen)->drawable, ms->damage); |
DamageDestroy(ms->damage); |
ms->damage = NULL; |
} |
#endif |
ms->destroy_front_buffer(pScrn); |
if (ms->exa) |
xorg_exa_close(pScrn); |
ms->exa = NULL; |
/* calls drop master make sure we don't talk to 3D HW after that */ |
if (pScrn->vtSema) { |
drv_leave_vt(VT_FUNC_ARGS); |
} |
pScrn->vtSema = FALSE; |
pScreen->CloseScreen = ms->CloseScreen; |
return (*pScreen->CloseScreen) (CLOSE_SCREEN_ARGS); |
} |
static ModeStatus |
drv_valid_mode(SCRN_ARG_TYPE arg, DisplayModePtr mode, Bool verbose, int flags) |
{ |
return MODE_OK; |
} |
/* |
* Front buffer backing store functions. |
*/ |
static Bool |
drv_destroy_front_buffer_ga3d(ScrnInfoPtr pScrn) |
{ |
modesettingPtr ms = modesettingPTR(pScrn); |
if (!ms->root_texture) |
return TRUE; |
if (ms->fb_id != -1) { |
drmModeRmFB(ms->fd, ms->fb_id); |
ms->fb_id = -1; |
} |
pipe_resource_reference(&ms->root_texture, NULL); |
return TRUE; |
} |
static Bool |
drv_create_front_buffer_ga3d(ScrnInfoPtr pScrn) |
{ |
modesettingPtr ms = modesettingPTR(pScrn); |
struct pipe_resource *tex; |
struct winsys_handle whandle; |
unsigned fb_id; |
int ret; |
ms->noEvict = TRUE; |
tex = xorg_exa_create_root_texture(pScrn, pScrn->virtualX, pScrn->virtualY, |
pScrn->depth, pScrn->bitsPerPixel); |
if (!tex) |
return FALSE; |
memset(&whandle, 0, sizeof(whandle)); |
whandle.type = DRM_API_HANDLE_TYPE_KMS; |
if (!ms->screen->resource_get_handle(ms->screen, tex, &whandle)) |
goto err_destroy; |
ret = drmModeAddFB(ms->fd, |
pScrn->virtualX, |
pScrn->virtualY, |
pScrn->depth, |
pScrn->bitsPerPixel, |
whandle.stride, |
whandle.handle, |
&fb_id); |
if (ret) { |
debug_printf("%s: failed to create framebuffer (%i, %s)\n", |
__func__, ret, strerror(-ret)); |
goto err_destroy; |
} |
if (!drv_destroy_front_buffer_ga3d(pScrn)) |
FatalError("%s: failed to take down old framebuffer\n", __func__); |
pScrn->frameX0 = 0; |
pScrn->frameY0 = 0; |
drv_adjust_frame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0)); |
pipe_resource_reference(&ms->root_texture, tex); |
pipe_resource_reference(&tex, NULL); |
ms->fb_id = fb_id; |
return TRUE; |
err_destroy: |
pipe_resource_reference(&tex, NULL); |
return FALSE; |
} |
static Bool |
drv_bind_front_buffer_ga3d(ScrnInfoPtr pScrn) |
{ |
modesettingPtr ms = modesettingPTR(pScrn); |
ScreenPtr pScreen = pScrn->pScreen; |
PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen); |
struct pipe_resource *check; |
xorg_exa_set_displayed_usage(rootPixmap); |
xorg_exa_set_shared_usage(rootPixmap); |
xorg_exa_set_texture(rootPixmap, ms->root_texture); |
if (!pScreen->ModifyPixmapHeader(rootPixmap, -1, -1, -1, -1, -1, NULL)) |
FatalError("Couldn't adjust screen pixmap\n"); |
check = xorg_exa_get_texture(rootPixmap); |
if (ms->root_texture != check) |
FatalError("Created new root texture\n"); |
pipe_resource_reference(&check, NULL); |
return TRUE; |
} |
#ifdef HAVE_LIBKMS |
static Bool |
drv_destroy_front_buffer_kms(ScrnInfoPtr pScrn) |
{ |
modesettingPtr ms = modesettingPTR(pScrn); |
ScreenPtr pScreen = pScrn->pScreen; |
PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen); |
/* XXX Do something with the rootPixmap. |
* This currently works fine but if we are getting crashes in |
* the fb functions after VT switches maybe look more into it. |
*/ |
(void)rootPixmap; |
if (!ms->root_bo) |
return TRUE; |
if (ms->fb_id != -1) { |
drmModeRmFB(ms->fd, ms->fb_id); |
ms->fb_id = -1; |
} |
kms_bo_unmap(ms->root_bo); |
kms_bo_destroy(&ms->root_bo); |
return TRUE; |
} |
static Bool |
drv_create_front_buffer_kms(ScrnInfoPtr pScrn) |
{ |
modesettingPtr ms = modesettingPTR(pScrn); |
unsigned handle, stride; |
struct kms_bo *bo; |
unsigned attr[8]; |
unsigned fb_id; |
int ret; |
attr[0] = KMS_BO_TYPE; |
#ifdef KMS_BO_TYPE_SCANOUT_X8R8G8B8 |
attr[1] = KMS_BO_TYPE_SCANOUT_X8R8G8B8; |
#else |
attr[1] = KMS_BO_TYPE_SCANOUT; |
#endif |
attr[2] = KMS_WIDTH; |
attr[3] = pScrn->virtualX; |
attr[4] = KMS_HEIGHT; |
attr[5] = pScrn->virtualY; |
attr[6] = 0; |
if (kms_bo_create(ms->kms, attr, &bo)) |
return FALSE; |
if (kms_bo_get_prop(bo, KMS_PITCH, &stride)) |
goto err_destroy; |
if (kms_bo_get_prop(bo, KMS_HANDLE, &handle)) |
goto err_destroy; |
ret = drmModeAddFB(ms->fd, |
pScrn->virtualX, |
pScrn->virtualY, |
pScrn->depth, |
pScrn->bitsPerPixel, |
stride, |
handle, |
&fb_id); |
if (ret) { |
debug_printf("%s: failed to create framebuffer (%i, %s)", |
__func__, ret, strerror(-ret)); |
goto err_destroy; |
} |
if (!drv_destroy_front_buffer_kms(pScrn)) |
FatalError("%s: could not takedown old bo", __func__); |
pScrn->frameX0 = 0; |
pScrn->frameY0 = 0; |
drv_adjust_frame(ADJUST_FRAME_ARGS(pScrn, pScrn->frameX0, pScrn->frameY0)); |
ms->root_bo = bo; |
ms->fb_id = fb_id; |
return TRUE; |
err_destroy: |
kms_bo_destroy(&bo); |
return FALSE; |
} |
static Bool |
drv_bind_front_buffer_kms(ScrnInfoPtr pScrn) |
{ |
modesettingPtr ms = modesettingPTR(pScrn); |
ScreenPtr pScreen = pScrn->pScreen; |
PixmapPtr rootPixmap = pScreen->GetScreenPixmap(pScreen); |
unsigned stride; |
void *ptr; |
if (kms_bo_get_prop(ms->root_bo, KMS_PITCH, &stride)) |
return FALSE; |
if (kms_bo_map(ms->root_bo, &ptr)) |
goto err_destroy; |
pScreen->ModifyPixmapHeader(rootPixmap, |
pScrn->virtualX, |
pScrn->virtualY, |
pScreen->rootDepth, |
pScrn->bitsPerPixel, |
stride, |
ptr); |
#if (XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1, 9, 99, 1, 0)) |
/* This a hack to work around EnableDisableFBAccess setting the pointer |
* the real fix would be to replace pScrn->EnableDisableFBAccess hook |
* and set the rootPixmap->devPrivate.ptr to something valid before that. |
* |
* But in its infinit visdome something uses either this some times before |
* that, so our hook doesn't get called before the crash happens. |
*/ |
pScrn->pixmapPrivate.ptr = ptr; |
#endif |
return TRUE; |
err_destroy: |
kms_bo_destroy(&ms->root_bo); |
return FALSE; |
} |
#endif /* HAVE_LIBKMS */ |
static Bool drv_init_front_buffer_functions(ScrnInfoPtr pScrn) |
{ |
modesettingPtr ms = modesettingPTR(pScrn); |
if (ms->screen) { |
ms->destroy_front_buffer = drv_destroy_front_buffer_ga3d; |
ms->create_front_buffer = drv_create_front_buffer_ga3d; |
ms->bind_front_buffer = drv_bind_front_buffer_ga3d; |
#ifdef HAVE_LIBKMS |
} else if (ms->kms) { |
ms->destroy_front_buffer = drv_destroy_front_buffer_kms; |
ms->create_front_buffer = drv_create_front_buffer_kms; |
ms->bind_front_buffer = drv_bind_front_buffer_kms; |
#endif |
} else |
return FALSE; |
return TRUE; |
} |
CustomizerPtr xorg_customizer(ScrnInfoPtr pScrn) |
{ |
return modesettingPTR(pScrn)->cust; |
} |
Bool xorg_has_gallium(ScrnInfoPtr pScrn) |
{ |
return modesettingPTR(pScrn)->screen != NULL; |
} |
/* vim: set sw=4 ts=8 sts=4: */ |
/contrib/sdk/sources/Mesa/mesa-9.2.5/src/gallium/state_trackers/xorg/xorg_exa.c |
---|
0,0 → 1,1087 |
/* |
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. |
* All Rights Reserved. |
* |
* 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, sub license, 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 (including the |
* next paragraph) 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 NON-INFRINGEMENT. |
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. |
* |
* |
* Author: Alan Hourihane <alanh@tungstengraphics.com> |
* Author: Jakob Bornecrantz <wallbraker@gmail.com> |
* |
*/ |
#include "xorg_exa.h" |
#include "xorg_tracker.h" |
#include "xorg_composite.h" |
#include "xorg_exa_tgsi.h" |
#include <xorg-server.h> |
#include <xf86.h> |
#include <picturestr.h> |
#include <picture.h> |
#include "pipe/p_format.h" |
#include "pipe/p_context.h" |
#include "pipe/p_state.h" |
#include "util/u_rect.h" |
#include "util/u_math.h" |
#include "util/u_debug.h" |
#include "util/u_format.h" |
#include "util/u_box.h" |
#include "util/u_surface.h" |
#define ROUND_UP_TEXTURES 1 |
static INLINE void |
exa_debug_printf(const char *format, ...) _util_printf_format(1,2); |
static INLINE void |
exa_debug_printf(const char *format, ...) |
{ |
#if 0 |
va_list ap; |
va_start(ap, format); |
_debug_vprintf(format, ap); |
va_end(ap); |
#else |
(void) format; /* silence warning */ |
#endif |
} |
/* |
* Helper functions |
*/ |
struct render_format_str { |
int format; |
const char *name; |
}; |
static const struct render_format_str formats_info[] = |
{ |
{PICT_a8r8g8b8, "PICT_a8r8g8b8"}, |
{PICT_x8r8g8b8, "PICT_x8r8g8b8"}, |
{PICT_a8b8g8r8, "PICT_a8b8g8r8"}, |
{PICT_x8b8g8r8, "PICT_x8b8g8r8"}, |
#ifdef PICT_TYPE_BGRA |
{PICT_b8g8r8a8, "PICT_b8g8r8a8"}, |
{PICT_b8g8r8x8, "PICT_b8g8r8x8"}, |
{PICT_a2r10g10b10, "PICT_a2r10g10b10"}, |
{PICT_x2r10g10b10, "PICT_x2r10g10b10"}, |
{PICT_a2b10g10r10, "PICT_a2b10g10r10"}, |
{PICT_x2b10g10r10, "PICT_x2b10g10r10"}, |
#endif |
{PICT_r8g8b8, "PICT_r8g8b8"}, |
{PICT_b8g8r8, "PICT_b8g8r8"}, |
{PICT_r5g6b5, "PICT_r5g6b5"}, |
{PICT_b5g6r5, "PICT_b5g6r5"}, |
{PICT_a1r5g5b5, "PICT_a1r5g5b5"}, |
{PICT_x1r5g5b5, "PICT_x1r5g5b5"}, |
{PICT_a1b5g5r5, "PICT_a1b5g5r5"}, |
{PICT_x1b5g5r5, "PICT_x1b5g5r5"}, |
{PICT_a4r4g4b4, "PICT_a4r4g4b4"}, |
{PICT_x4r4g4b4, "PICT_x4r4g4b4"}, |
{PICT_a4b4g4r4, "PICT_a4b4g4r4"}, |
{PICT_x4b4g4r4, "PICT_x4b4g4r4"}, |
{PICT_a8, "PICT_a8"}, |
{PICT_r3g3b2, "PICT_r3g3b2"}, |
{PICT_b2g3r3, "PICT_b2g3r3"}, |
{PICT_a2r2g2b2, "PICT_a2r2g2b2"}, |
{PICT_a2b2g2r2, "PICT_a2b2g2r2"}, |
{PICT_c8, "PICT_c8"}, |
{PICT_g8, "PICT_g8"}, |
{PICT_x4a4, "PICT_x4a4"}, |
{PICT_x4c4, "PICT_x4c4"}, |
{PICT_x4g4, "PICT_x4g4"}, |
{PICT_a4, "PICT_a4"}, |
{PICT_r1g2b1, "PICT_r1g2b1"}, |
{PICT_b1g2r1, "PICT_b1g2r1"}, |
{PICT_a1r1g1b1, "PICT_a1r1g1b1"}, |
{PICT_a1b1g1r1, "PICT_a1b1g1r1"}, |
{PICT_c4, "PICT_c4"}, |
{PICT_g4, "PICT_g4"}, |
{PICT_a1, "PICT_a1"}, |
{PICT_g1, "PICT_g1"} |
}; |
static const char *render_format_name(int format) |
{ |
int i = 0; |
for (i = 0; i < sizeof(formats_info)/sizeof(formats_info[0]); ++i) { |
if (formats_info[i].format == format) |
return formats_info[i].name; |
} |
return NULL; |
} |
static void |
exa_get_pipe_format(int depth, enum pipe_format *format, int *bbp, int *picture_format) |
{ |
switch (depth) { |
case 32: |
*format = PIPE_FORMAT_B8G8R8A8_UNORM; |
*picture_format = PICT_a8r8g8b8; |
assert(*bbp == 32); |
break; |
case 24: |
*format = PIPE_FORMAT_B8G8R8X8_UNORM; |
*picture_format = PICT_x8r8g8b8; |
assert(*bbp == 32); |
break; |
case 16: |
*format = PIPE_FORMAT_B5G6R5_UNORM; |
*picture_format = PICT_r5g6b5; |
assert(*bbp == 16); |
break; |
case 15: |
*format = PIPE_FORMAT_B5G5R5A1_UNORM; |
*picture_format = PICT_x1r5g5b5; |
assert(*bbp == 16); |
break; |
case 8: |
*format = PIPE_FORMAT_L8_UNORM; |
*picture_format = PICT_a8; |
assert(*bbp == 8); |
break; |
case 4: |
case 1: |
*format = PIPE_FORMAT_B8G8R8A8_UNORM; /* bad bad bad */ |
break; |
default: |
assert(0); |
break; |
} |
} |
/* |
* Static exported EXA functions |
*/ |
static void |
ExaWaitMarker(ScreenPtr pScreen, int marker) |
{ |
/* Nothing to do, handled in the PrepareAccess hook */ |
} |
static int |
ExaMarkSync(ScreenPtr pScreen) |
{ |
return 1; |
} |
/*********************************************************************** |
* Screen upload/download |
*/ |
static Bool |
ExaDownloadFromScreen(PixmapPtr pPix, int x, int y, int w, int h, char *dst, |
int dst_pitch) |
{ |
ScreenPtr pScreen = pPix->drawable.pScreen; |
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); |
modesettingPtr ms = modesettingPTR(pScrn); |
struct exa_context *exa = ms->exa; |
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPix); |
struct pipe_transfer *transfer; |
void *map; |
if (!priv || !priv->tex) |
return FALSE; |
map = pipe_transfer_map(exa->pipe, priv->tex, 0, 0, |
PIPE_TRANSFER_READ, x, y, w, h, &transfer); |
if (!map) |
return FALSE; |
exa_debug_printf("------ ExaDownloadFromScreen(%d, %d, %d, %d, %d)\n", |
x, y, w, h, dst_pitch); |
util_copy_rect((unsigned char*)dst, priv->tex->format, dst_pitch, 0, 0, |
w, h, map, transfer->stride, 0, 0); |
exa->pipe->transfer_unmap(exa->pipe, transfer); |
return TRUE; |
} |
static Bool |
ExaUploadToScreen(PixmapPtr pPix, int x, int y, int w, int h, char *src, |
int src_pitch) |
{ |
ScreenPtr pScreen = pPix->drawable.pScreen; |
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); |
modesettingPtr ms = modesettingPTR(pScrn); |
struct exa_context *exa = ms->exa; |
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPix); |
struct pipe_transfer *transfer; |
void *map; |
if (!priv || !priv->tex) |
return FALSE; |
map = pipe_transfer_map(exa->pipe, priv->tex, 0, 0, |
PIPE_TRANSFER_WRITE, x, y, w, h, &transfer); |
if (!map) |
return FALSE; |
exa_debug_printf("++++++ ExaUploadToScreen(%d, %d, %d, %d, %d)\n", |
x, y, w, h, src_pitch); |
util_copy_rect(map, |
priv->tex->format, transfer->stride, 0, 0, w, h, |
(unsigned char*)src, src_pitch, 0, 0); |
exa->pipe->transfer_unmap(exa->pipe, transfer); |
return TRUE; |
} |
static Bool |
ExaPrepareAccess(PixmapPtr pPix, int index) |
{ |
ScreenPtr pScreen = pPix->drawable.pScreen; |
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); |
modesettingPtr ms = modesettingPTR(pScrn); |
struct exa_context *exa = ms->exa; |
struct exa_pixmap_priv *priv; |
priv = exaGetPixmapDriverPrivate(pPix); |
if (!priv) |
return FALSE; |
if (!priv->tex) |
return FALSE; |
exa_debug_printf("ExaPrepareAccess %d\n", index); |
if (priv->map_count == 0) |
{ |
assert(pPix->drawable.width <= priv->tex->width0); |
assert(pPix->drawable.height <= priv->tex->height0); |
pPix->devPrivate.ptr = |
pipe_transfer_map(exa->pipe, priv->tex, 0, 0, |
#ifdef EXA_MIXED_PIXMAPS |
PIPE_TRANSFER_MAP_DIRECTLY | |
#endif |
PIPE_TRANSFER_READ_WRITE, |
0, 0, |
pPix->drawable.width, |
pPix->drawable.height, |
&priv->map_transfer); |
if (!pPix->devPrivate.ptr) |
#ifdef EXA_MIXED_PIXMAPS |
return FALSE; |
#else |
FatalError("failed to create transfer\n"); |
#endif |
pPix->devKind = priv->map_transfer->stride; |
} |
priv->map_count++; |
exa_debug_printf("ExaPrepareAccess %d prepared\n", index); |
return TRUE; |
} |
static void |
ExaFinishAccess(PixmapPtr pPix, int index) |
{ |
ScreenPtr pScreen = pPix->drawable.pScreen; |
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); |
modesettingPtr ms = modesettingPTR(pScrn); |
struct exa_context *exa = ms->exa; |
struct exa_pixmap_priv *priv; |
priv = exaGetPixmapDriverPrivate(pPix); |
if (!priv) |
return; |
if (!priv->map_transfer) |
return; |
exa_debug_printf("ExaFinishAccess %d\n", index); |
if (--priv->map_count == 0) { |
assert(priv->map_transfer); |
exa->pipe->transfer_unmap(exa->pipe, priv->map_transfer); |
priv->map_transfer = NULL; |
pPix->devPrivate.ptr = NULL; |
} |
exa_debug_printf("ExaFinishAccess %d finished\n", index); |
} |
/*********************************************************************** |
* Solid Fills |
*/ |
static Bool |
ExaPrepareSolid(PixmapPtr pPixmap, int alu, Pixel planeMask, Pixel fg) |
{ |
ScrnInfoPtr pScrn = xf86ScreenToScrn(pPixmap->drawable.pScreen); |
modesettingPtr ms = modesettingPTR(pScrn); |
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap); |
struct exa_context *exa = ms->exa; |
exa_debug_printf("ExaPrepareSolid(0x%x)\n", fg); |
if (!exa->accel) |
return FALSE; |
if (!exa->pipe) |
XORG_FALLBACK("accel not enabled"); |
if (!priv || !priv->tex) |
XORG_FALLBACK("%s", !priv ? "!priv" : "!priv->tex"); |
if (!EXA_PM_IS_SOLID(&pPixmap->drawable, planeMask)) |
XORG_FALLBACK("planeMask is not solid"); |
if (alu != GXcopy) |
XORG_FALLBACK("not GXcopy"); |
if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format, |
priv->tex->target, 0, |
PIPE_BIND_RENDER_TARGET)) { |
XORG_FALLBACK("format %s", util_format_name(priv->tex->format)); |
} |
return xorg_solid_bind_state(exa, priv, fg); |
} |
static void |
ExaSolid(PixmapPtr pPixmap, int x0, int y0, int x1, int y1) |
{ |
ScrnInfoPtr pScrn = xf86ScreenToScrn(pPixmap->drawable.pScreen); |
modesettingPtr ms = modesettingPTR(pScrn); |
struct exa_context *exa = ms->exa; |
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap); |
exa_debug_printf("\tExaSolid(%d, %d, %d, %d)\n", x0, y0, x1, y1); |
if (x0 == 0 && y0 == 0 && |
x1 == pPixmap->drawable.width && y1 == pPixmap->drawable.height) { |
union pipe_color_union solid_color; |
solid_color.f[0] = exa->solid_color[0]; |
solid_color.f[1] = exa->solid_color[1]; |
solid_color.f[2] = exa->solid_color[2]; |
solid_color.f[3] = exa->solid_color[3]; |
exa->pipe->clear(exa->pipe, PIPE_CLEAR_COLOR, &solid_color, 0.0, 0); |
return; |
} |
xorg_solid(exa, priv, x0, y0, x1, y1) ; |
} |
static void |
ExaDoneSolid(PixmapPtr pPixmap) |
{ |
ScrnInfoPtr pScrn = xf86ScreenToScrn(pPixmap->drawable.pScreen); |
modesettingPtr ms = modesettingPTR(pScrn); |
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap); |
struct exa_context *exa = ms->exa; |
if (!priv) |
return; |
exa_debug_printf("ExaDoneSolid\n"); |
xorg_composite_done(exa); |
exa_debug_printf("ExaDoneSolid done\n"); |
} |
/*********************************************************************** |
* Copy Blits |
*/ |
static Bool |
ExaPrepareCopy(PixmapPtr pSrcPixmap, PixmapPtr pDstPixmap, int xdir, |
int ydir, int alu, Pixel planeMask) |
{ |
ScrnInfoPtr pScrn = xf86ScreenToScrn(pDstPixmap->drawable.pScreen); |
modesettingPtr ms = modesettingPTR(pScrn); |
struct exa_context *exa = ms->exa; |
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pDstPixmap); |
struct exa_pixmap_priv *src_priv = exaGetPixmapDriverPrivate(pSrcPixmap); |
exa_debug_printf("ExaPrepareCopy\n"); |
if (!exa->accel) |
return FALSE; |
if (!exa->pipe) |
XORG_FALLBACK("accel not enabled"); |
if (!priv || !priv->tex) |
XORG_FALLBACK("pDst %s", !priv ? "!priv" : "!priv->tex"); |
if (!src_priv || !src_priv->tex) |
XORG_FALLBACK("pSrc %s", !src_priv ? "!priv" : "!priv->tex"); |
if (!EXA_PM_IS_SOLID(&pSrcPixmap->drawable, planeMask)) |
XORG_FALLBACK("planeMask is not solid"); |
if (alu != GXcopy) |
XORG_FALLBACK("alu not GXcopy"); |
if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format, |
priv->tex->target, 0, |
PIPE_BIND_RENDER_TARGET)) |
XORG_FALLBACK("pDst format %s", util_format_name(priv->tex->format)); |
if (!exa->scrn->is_format_supported(exa->scrn, src_priv->tex->format, |
src_priv->tex->target, 0, |
PIPE_BIND_SAMPLER_VIEW)) |
XORG_FALLBACK("pSrc format %s", util_format_name(src_priv->tex->format)); |
exa->copy.src = src_priv; |
exa->copy.dst = priv; |
return TRUE; |
} |
static void |
ExaCopy(PixmapPtr pDstPixmap, int srcX, int srcY, int dstX, int dstY, |
int width, int height) |
{ |
ScrnInfoPtr pScrn = xf86ScreenToScrn(pDstPixmap->drawable.pScreen); |
modesettingPtr ms = modesettingPTR(pScrn); |
struct exa_context *exa = ms->exa; |
struct pipe_box src_box; |
exa_debug_printf("\tExaCopy(srcx=%d, srcy=%d, dstX=%d, dstY=%d, w=%d, h=%d)\n", |
srcX, srcY, dstX, dstY, width, height); |
debug_assert(exaGetPixmapDriverPrivate(pDstPixmap) == exa->copy.dst); |
u_box_2d(srcX, srcY, width, height, &src_box); |
/* If source and destination overlap, we have to copy to/from a scratch |
* pixmap. |
*/ |
if (exa->copy.dst == exa->copy.src && |
!((dstX + width) < srcX || dstX > (srcX + width) || |
(dstY + height) < srcY || dstY > (srcY + height))) { |
struct exa_pixmap_priv *tmp_priv; |
if (!exa->copy.tmp_pix) { |
exa->copy.tmp_pix = pScrn->pScreen->CreatePixmap(pScrn->pScreen, |
pDstPixmap->drawable.width, |
pDstPixmap->drawable.height, |
pDstPixmap->drawable.depth, |
pDstPixmap->drawable.width); |
exaMoveInPixmap(exa->copy.tmp_pix); |
} |
tmp_priv = exaGetPixmapDriverPrivate(exa->copy.tmp_pix); |
exa->pipe->resource_copy_region( exa->pipe, |
tmp_priv->tex, |
0, |
srcX, srcY, 0, |
exa->copy.src->tex, |
0, &src_box); |
exa->pipe->resource_copy_region( exa->pipe, |
exa->copy.dst->tex, |
0, |
dstX, dstY, 0, |
tmp_priv->tex, |
0, &src_box); |
} else |
exa->pipe->resource_copy_region( exa->pipe, |
exa->copy.dst->tex, |
0, |
dstX, dstY, 0, |
exa->copy.src->tex, |
0, &src_box); |
} |
static void |
ExaDoneCopy(PixmapPtr pPixmap) |
{ |
ScrnInfoPtr pScrn = xf86ScreenToScrn(pPixmap->drawable.pScreen); |
modesettingPtr ms = modesettingPTR(pScrn); |
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap); |
struct exa_context *exa = ms->exa; |
if (!priv) |
return; |
exa_debug_printf("ExaDoneCopy\n"); |
if (exa->copy.tmp_pix) { |
pScrn->pScreen->DestroyPixmap(exa->copy.tmp_pix); |
exa->copy.tmp_pix = NULL; |
} |
exa->copy.src = NULL; |
exa->copy.dst = NULL; |
exa_debug_printf("ExaDoneCopy done\n"); |
} |
static Bool |
picture_check_formats(struct exa_pixmap_priv *pSrc, PicturePtr pSrcPicture) |
{ |
if (pSrc->picture_format == pSrcPicture->format) |
return TRUE; |
if (pSrc->picture_format != PICT_a8r8g8b8) |
return FALSE; |
/* pSrc->picture_format == PICT_a8r8g8b8 */ |
switch (pSrcPicture->format) { |
case PICT_a8r8g8b8: |
case PICT_x8r8g8b8: |
case PICT_a8b8g8r8: |
case PICT_x8b8g8r8: |
/* just treat these two as x8... */ |
case PICT_r8g8b8: |
case PICT_b8g8r8: |
return TRUE; |
#ifdef PICT_TYPE_BGRA |
case PICT_b8g8r8a8: |
case PICT_b8g8r8x8: |
return FALSE; /* does not support swizzleing the alpha channel yet */ |
case PICT_a2r10g10b10: |
case PICT_x2r10g10b10: |
case PICT_a2b10g10r10: |
case PICT_x2b10g10r10: |
return FALSE; |
#endif |
default: |
return FALSE; |
} |
return FALSE; |
} |
/*********************************************************************** |
* Composite entrypoints |
*/ |
static Bool |
ExaCheckComposite(int op, |
PicturePtr pSrcPicture, PicturePtr pMaskPicture, |
PicturePtr pDstPicture) |
{ |
ScrnInfoPtr pScrn = xf86ScreenToScrn(pDstPicture->pDrawable->pScreen); |
modesettingPtr ms = modesettingPTR(pScrn); |
struct exa_context *exa = ms->exa; |
Bool accelerated = exa->accel && xorg_composite_accelerated(op, |
pSrcPicture, |
pMaskPicture, |
pDstPicture); |
exa_debug_printf("ExaCheckComposite(%d, %p, %p, %p) = %d\n", |
op, pSrcPicture, pMaskPicture, pDstPicture, accelerated); |
return accelerated; |
} |
static Bool |
ExaPrepareComposite(int op, PicturePtr pSrcPicture, |
PicturePtr pMaskPicture, PicturePtr pDstPicture, |
PixmapPtr pSrc, PixmapPtr pMask, PixmapPtr pDst) |
{ |
ScrnInfoPtr pScrn = xf86ScreenToScrn(pDst->drawable.pScreen); |
modesettingPtr ms = modesettingPTR(pScrn); |
struct exa_context *exa = ms->exa; |
struct exa_pixmap_priv *priv; |
if (!exa->accel) |
return FALSE; |
exa_debug_printf("ExaPrepareComposite(%d, src=0x%p, mask=0x%p, dst=0x%p)\n", |
op, pSrcPicture, pMaskPicture, pDstPicture); |
exa_debug_printf("\tFormats: src(%s), mask(%s), dst(%s)\n", |
pSrcPicture ? render_format_name(pSrcPicture->format) : "none", |
pMaskPicture ? render_format_name(pMaskPicture->format) : "none", |
pDstPicture ? render_format_name(pDstPicture->format) : "none"); |
if (!exa->pipe) |
XORG_FALLBACK("accel not enabled"); |
priv = exaGetPixmapDriverPrivate(pDst); |
if (!priv || !priv->tex) |
XORG_FALLBACK("pDst %s", !priv ? "!priv" : "!priv->tex"); |
if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format, |
priv->tex->target, 0, |
PIPE_BIND_RENDER_TARGET)) |
XORG_FALLBACK("pDst format: %s", util_format_name(priv->tex->format)); |
if (priv->picture_format != pDstPicture->format) |
XORG_FALLBACK("pDst pic_format: %s != %s", |
render_format_name(priv->picture_format), |
render_format_name(pDstPicture->format)); |
if (pSrc) { |
priv = exaGetPixmapDriverPrivate(pSrc); |
if (!priv || !priv->tex) |
XORG_FALLBACK("pSrc %s", !priv ? "!priv" : "!priv->tex"); |
if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format, |
priv->tex->target, 0, |
PIPE_BIND_SAMPLER_VIEW)) |
XORG_FALLBACK("pSrc format: %s", util_format_name(priv->tex->format)); |
if (!picture_check_formats(priv, pSrcPicture)) |
XORG_FALLBACK("pSrc pic_format: %s != %s", |
render_format_name(priv->picture_format), |
render_format_name(pSrcPicture->format)); |
} |
if (pMask) { |
priv = exaGetPixmapDriverPrivate(pMask); |
if (!priv || !priv->tex) |
XORG_FALLBACK("pMask %s", !priv ? "!priv" : "!priv->tex"); |
if (!exa->scrn->is_format_supported(exa->scrn, priv->tex->format, |
priv->tex->target, 0, |
PIPE_BIND_SAMPLER_VIEW)) |
XORG_FALLBACK("pMask format: %s", util_format_name(priv->tex->format)); |
if (!picture_check_formats(priv, pMaskPicture)) |
XORG_FALLBACK("pMask pic_format: %s != %s", |
render_format_name(priv->picture_format), |
render_format_name(pMaskPicture->format)); |
} |
return xorg_composite_bind_state(exa, op, pSrcPicture, pMaskPicture, |
pDstPicture, |
pSrc ? exaGetPixmapDriverPrivate(pSrc) : NULL, |
pMask ? exaGetPixmapDriverPrivate(pMask) : NULL, |
exaGetPixmapDriverPrivate(pDst)); |
} |
static void |
ExaComposite(PixmapPtr pDst, int srcX, int srcY, int maskX, int maskY, |
int dstX, int dstY, int width, int height) |
{ |
ScrnInfoPtr pScrn = xf86ScreenToScrn(pDst->drawable.pScreen); |
modesettingPtr ms = modesettingPTR(pScrn); |
struct exa_context *exa = ms->exa; |
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pDst); |
exa_debug_printf("\tExaComposite(src[%d,%d], mask=[%d, %d], dst=[%d, %d], dim=[%d, %d])\n", |
srcX, srcY, maskX, maskY, dstX, dstY, width, height); |
exa_debug_printf("\t Num bound samplers = %d\n", |
exa->num_bound_samplers); |
xorg_composite(exa, priv, srcX, srcY, maskX, maskY, |
dstX, dstY, width, height); |
} |
static void |
ExaDoneComposite(PixmapPtr pPixmap) |
{ |
ScrnInfoPtr pScrn = xf86ScreenToScrn(pPixmap->drawable.pScreen); |
modesettingPtr ms = modesettingPTR(pScrn); |
struct exa_context *exa = ms->exa; |
xorg_composite_done(exa); |
} |
/*********************************************************************** |
* Pixmaps |
*/ |
static void * |
ExaCreatePixmap(ScreenPtr pScreen, int size, int align) |
{ |
struct exa_pixmap_priv *priv; |
priv = calloc(1, sizeof(struct exa_pixmap_priv)); |
if (!priv) |
return NULL; |
return priv; |
} |
static void |
ExaDestroyPixmap(ScreenPtr pScreen, void *dPriv) |
{ |
struct exa_pixmap_priv *priv = (struct exa_pixmap_priv *)dPriv; |
if (!priv) |
return; |
pipe_resource_reference(&priv->tex, NULL); |
free(priv); |
} |
static Bool |
ExaPixmapIsOffscreen(PixmapPtr pPixmap) |
{ |
struct exa_pixmap_priv *priv; |
priv = exaGetPixmapDriverPrivate(pPixmap); |
if (!priv) |
return FALSE; |
if (priv->tex) |
return TRUE; |
return FALSE; |
} |
int |
xorg_exa_set_displayed_usage(PixmapPtr pPixmap) |
{ |
struct exa_pixmap_priv *priv; |
priv = exaGetPixmapDriverPrivate(pPixmap); |
if (!priv) { |
FatalError("NO PIXMAP PRIVATE\n"); |
return 0; |
} |
priv->flags |= PIPE_BIND_SCANOUT; |
return 0; |
} |
int |
xorg_exa_set_shared_usage(PixmapPtr pPixmap) |
{ |
struct exa_pixmap_priv *priv; |
priv = exaGetPixmapDriverPrivate(pPixmap); |
if (!priv) { |
FatalError("NO PIXMAP PRIVATE\n"); |
return 0; |
} |
priv->flags |= PIPE_BIND_SHARED; |
return 0; |
} |
static Bool |
size_match( int width, int tex_width ) |
{ |
#if ROUND_UP_TEXTURES |
if (width > tex_width) |
return FALSE; |
if (width * 2 < tex_width) |
return FALSE; |
return TRUE; |
#else |
return width == tex_width; |
#endif |
} |
static Bool |
ExaModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, |
int depth, int bitsPerPixel, int devKind, |
pointer pPixData) |
{ |
ScreenPtr pScreen = pPixmap->drawable.pScreen; |
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); |
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap); |
modesettingPtr ms = modesettingPTR(pScrn); |
struct exa_context *exa = ms->exa; |
if (!priv || pPixData) |
return FALSE; |
if (0) { |
debug_printf("%s pixmap %p sz %dx%dx%d devKind %d\n", |
__FUNCTION__, pPixmap, width, height, bitsPerPixel, devKind); |
if (priv->tex) |
debug_printf(" ==> old texture %dx%d\n", |
priv->tex->width0, |
priv->tex->height0); |
} |
if (depth <= 0) |
depth = pPixmap->drawable.depth; |
if (bitsPerPixel <= 0) |
bitsPerPixel = pPixmap->drawable.bitsPerPixel; |
if (width <= 0) |
width = pPixmap->drawable.width; |
if (height <= 0) |
height = pPixmap->drawable.height; |
if (width <= 0 || height <= 0 || depth <= 0) |
return FALSE; |
miModifyPixmapHeader(pPixmap, width, height, depth, |
bitsPerPixel, devKind, NULL); |
priv->width = width; |
priv->height = height; |
/* Deal with screen resize */ |
if ((exa->accel || priv->flags) && |
(!priv->tex || |
!size_match(width, priv->tex->width0) || |
!size_match(height, priv->tex->height0) || |
priv->tex_flags != priv->flags)) { |
struct pipe_resource *texture = NULL; |
struct pipe_resource template; |
memset(&template, 0, sizeof(template)); |
template.target = PIPE_TEXTURE_2D; |
exa_get_pipe_format(depth, &template.format, &bitsPerPixel, &priv->picture_format); |
if (ROUND_UP_TEXTURES && priv->flags == 0) { |
template.width0 = util_next_power_of_two(width); |
template.height0 = util_next_power_of_two(height); |
} |
else { |
template.width0 = width; |
template.height0 = height; |
} |
template.depth0 = 1; |
template.array_size = 1; |
template.last_level = 0; |
template.bind = PIPE_BIND_RENDER_TARGET | priv->flags; |
priv->tex_flags = priv->flags; |
texture = exa->scrn->resource_create(exa->scrn, &template); |
if (priv->tex) { |
struct pipe_box src_box; |
u_box_origin_2d(min(width, texture->width0), |
min(height, texture->height0), |
&src_box); |
exa->pipe->resource_copy_region(exa->pipe, texture, |
0, 0, 0, 0, |
priv->tex, |
0, &src_box); |
} |
pipe_resource_reference(&priv->tex, texture); |
/* the texture we create has one reference */ |
pipe_resource_reference(&texture, NULL); |
} |
return TRUE; |
} |
struct pipe_resource * |
xorg_exa_get_texture(PixmapPtr pPixmap) |
{ |
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap); |
struct pipe_resource *tex = NULL; |
pipe_resource_reference(&tex, priv->tex); |
return tex; |
} |
Bool |
xorg_exa_set_texture(PixmapPtr pPixmap, struct pipe_resource *tex) |
{ |
struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap); |
int mask = PIPE_BIND_SHARED | PIPE_BIND_SCANOUT; |
if (!priv) |
return FALSE; |
if (pPixmap->drawable.width != tex->width0 || |
pPixmap->drawable.height != tex->height0) |
return FALSE; |
pipe_resource_reference(&priv->tex, tex); |
priv->tex_flags = tex->bind & mask; |
return TRUE; |
} |
struct pipe_resource * |
xorg_exa_create_root_texture(ScrnInfoPtr pScrn, |
int width, int height, |
int depth, int bitsPerPixel) |
{ |
modesettingPtr ms = modesettingPTR(pScrn); |
struct exa_context *exa = ms->exa; |
struct pipe_resource template; |
int dummy; |
memset(&template, 0, sizeof(template)); |
template.target = PIPE_TEXTURE_2D; |
exa_get_pipe_format(depth, &template.format, &bitsPerPixel, &dummy); |
template.width0 = width; |
template.height0 = height; |
template.depth0 = 1; |
template.array_size = 1; |
template.last_level = 0; |
template.bind |= PIPE_BIND_RENDER_TARGET; |
template.bind |= PIPE_BIND_SCANOUT; |
template.bind |= PIPE_BIND_SHARED; |
return exa->scrn->resource_create(exa->scrn, &template); |
} |
void |
xorg_exa_close(ScrnInfoPtr pScrn) |
{ |
modesettingPtr ms = modesettingPTR(pScrn); |
struct exa_context *exa = ms->exa; |
pipe_sampler_view_reference(&exa->bound_sampler_views[0], NULL); |
pipe_sampler_view_reference(&exa->bound_sampler_views[1], NULL); |
renderer_destroy(exa->renderer); |
xorg_exa_finish(exa); |
if (exa->pipe) |
exa->pipe->destroy(exa->pipe); |
exa->pipe = NULL; |
/* Since this was shared be proper with the pointer */ |
ms->ctx = NULL; |
exaDriverFini(pScrn->pScreen); |
free(exa); |
ms->exa = NULL; |
} |
void * |
xorg_exa_init(ScrnInfoPtr pScrn, Bool accel) |
{ |
modesettingPtr ms = modesettingPTR(pScrn); |
struct exa_context *exa; |
ExaDriverPtr pExa; |
CustomizerPtr cust = ms->cust; |
exa = calloc(1, sizeof(struct exa_context)); |
if (!exa) |
return NULL; |
exa->scrn = ms->screen; |
exa->pipe = exa->scrn->context_create(exa->scrn, NULL); |
if (exa->pipe == NULL) |
goto out_err; |
pExa = exaDriverAlloc(); |
if (!pExa) { |
goto out_err; |
} |
pExa->exa_major = 2; |
pExa->exa_minor = 2; |
pExa->memoryBase = 0; |
pExa->memorySize = 0; |
pExa->offScreenBase = 0; |
pExa->pixmapOffsetAlign = 0; |
pExa->pixmapPitchAlign = 1; |
pExa->flags = EXA_OFFSCREEN_PIXMAPS | EXA_HANDLES_PIXMAPS; |
#ifdef EXA_SUPPORTS_PREPARE_AUX |
pExa->flags |= EXA_SUPPORTS_PREPARE_AUX; |
#endif |
#ifdef EXA_MIXED_PIXMAPS |
pExa->flags |= EXA_MIXED_PIXMAPS; |
#endif |
pExa->maxX = pExa->maxY = |
1 << (exa->scrn->get_param(exa->scrn, PIPE_CAP_MAX_TEXTURE_2D_LEVELS) - 1); |
pExa->WaitMarker = ExaWaitMarker; |
pExa->MarkSync = ExaMarkSync; |
pExa->PrepareSolid = ExaPrepareSolid; |
pExa->Solid = ExaSolid; |
pExa->DoneSolid = ExaDoneSolid; |
pExa->PrepareCopy = ExaPrepareCopy; |
pExa->Copy = ExaCopy; |
pExa->DoneCopy = ExaDoneCopy; |
pExa->CheckComposite = ExaCheckComposite; |
pExa->PrepareComposite = ExaPrepareComposite; |
pExa->Composite = ExaComposite; |
pExa->DoneComposite = ExaDoneComposite; |
pExa->PixmapIsOffscreen = ExaPixmapIsOffscreen; |
pExa->DownloadFromScreen = ExaDownloadFromScreen; |
pExa->UploadToScreen = ExaUploadToScreen; |
pExa->PrepareAccess = ExaPrepareAccess; |
pExa->FinishAccess = ExaFinishAccess; |
pExa->CreatePixmap = ExaCreatePixmap; |
pExa->DestroyPixmap = ExaDestroyPixmap; |
pExa->ModifyPixmapHeader = ExaModifyPixmapHeader; |
if (!exaDriverInit(pScrn->pScreen, pExa)) { |
goto out_err; |
} |
/* Share context with DRI */ |
ms->ctx = exa->pipe; |
if (cust && cust->winsys_context_throttle) |
cust->winsys_context_throttle(cust, ms->ctx, THROTTLE_RENDER); |
exa->renderer = renderer_create(exa->pipe); |
exa->accel = accel; |
return (void *)exa; |
out_err: |
xorg_exa_close(pScrn); |
free(exa); |
return NULL; |
} |
struct pipe_surface * |
xorg_gpu_surface(struct pipe_context *pipe, struct exa_pixmap_priv *priv) |
{ |
struct pipe_surface surf_tmpl; |
u_surface_default_template(&surf_tmpl, priv->tex); |
return pipe->create_surface(pipe, priv->tex, &surf_tmpl); |
} |
void xorg_exa_flush(struct exa_context *exa, |
struct pipe_fence_handle **fence) |
{ |
exa->pipe->flush(exa->pipe, fence, 0); |
} |
void xorg_exa_finish(struct exa_context *exa) |
{ |
struct pipe_fence_handle *fence = NULL; |
xorg_exa_flush(exa, &fence); |
exa->pipe->screen->fence_finish(exa->pipe->screen, fence, |
PIPE_TIMEOUT_INFINITE); |
exa->pipe->screen->fence_reference(exa->pipe->screen, &fence, NULL); |
} |
/contrib/sdk/sources/Mesa/mesa-9.2.5/src/gallium/state_trackers/xorg/xorg_exa.h |
---|
0,0 → 1,76 |
#ifndef XORG_EXA_H |
#define XORG_EXA_H |
#include "xorg_tracker.h" |
#include "pipe/p_state.h" |
struct cso_context; |
struct xorg_shaders; |
/* src + mask + dst */ |
#define MAX_EXA_SAMPLERS 3 |
struct exa_context |
{ |
ExaDriverPtr pExa; |
struct pipe_context *pipe; |
struct pipe_screen *scrn; |
struct xorg_renderer *renderer; |
struct pipe_sampler_view *bound_sampler_views[MAX_EXA_SAMPLERS]; |
int num_bound_samplers; |
float solid_color[4]; |
boolean has_solid_color; |
boolean accel; |
/* float[9] projective matrix bound to pictures */ |
struct { |
float src[9]; |
float mask[9]; |
boolean has_src; |
boolean has_mask; |
} transform; |
struct { |
struct exa_pixmap_priv *src; |
struct exa_pixmap_priv *dst; |
PixmapPtr tmp_pix; |
} copy; |
}; |
struct exa_pixmap_priv |
{ |
int width, height; |
int flags; |
int tex_flags; |
int picture_format; |
struct pipe_resource *tex; |
struct pipe_resource *depth_stencil_tex; |
struct pipe_transfer *map_transfer; |
unsigned map_count; |
}; |
#define XORG_FALLBACK(s, arg...) \ |
do { \ |
if (ms->debug_fallback) { \ |
xf86DrvMsg(pScrn->scrnIndex, X_INFO, \ |
"%s fallback " s "\n", __FUNCTION__, ##arg); \ |
} \ |
return FALSE; \ |
} while(0) |
struct pipe_surface * |
xorg_gpu_surface(struct pipe_context *pipe, struct exa_pixmap_priv *priv); |
void xorg_exa_flush(struct exa_context *exa, |
struct pipe_fence_handle **fence); |
void xorg_exa_finish(struct exa_context *exa); |
#endif |
/contrib/sdk/sources/Mesa/mesa-9.2.5/src/gallium/state_trackers/xorg/xorg_exa_tgsi.c |
---|
0,0 → 1,690 |
#include "xorg_exa_tgsi.h" |
/*### stupidity defined in X11/extensions/XI.h */ |
#undef Absolute |
#include "pipe/p_format.h" |
#include "pipe/p_context.h" |
#include "pipe/p_state.h" |
#include "pipe/p_shader_tokens.h" |
#include "util/u_memory.h" |
#include "tgsi/tgsi_ureg.h" |
#include "cso_cache/cso_context.h" |
#include "cso_cache/cso_hash.h" |
/* Vertex shader: |
* IN[0] = vertex pos |
* IN[1] = src tex coord | solid fill color |
* IN[2] = mask tex coord |
* IN[3] = dst tex coord |
* CONST[0] = (2/dst_width, 2/dst_height, 1, 1) |
* CONST[1] = (-1, -1, 0, 0) |
* |
* OUT[0] = vertex pos |
* OUT[1] = src tex coord | solid fill color |
* OUT[2] = mask tex coord |
* OUT[3] = dst tex coord |
*/ |
/* Fragment shader: |
* SAMP[0] = src |
* SAMP[1] = mask |
* SAMP[2] = dst |
* IN[0] = pos src | solid fill color |
* IN[1] = pos mask |
* IN[2] = pos dst |
* CONST[0] = (0, 0, 0, 1) |
* |
* OUT[0] = color |
*/ |
static void |
print_fs_traits(int fs_traits) |
{ |
const char *strings[] = { |
"FS_COMPOSITE", /* = 1 << 0, */ |
"FS_MASK", /* = 1 << 1, */ |
"FS_SOLID_FILL", /* = 1 << 2, */ |
"FS_LINGRAD_FILL", /* = 1 << 3, */ |
"FS_RADGRAD_FILL", /* = 1 << 4, */ |
"FS_CA_FULL", /* = 1 << 5, */ /* src.rgba * mask.rgba */ |
"FS_CA_SRCALPHA", /* = 1 << 6, */ /* src.aaaa * mask.rgba */ |
"FS_YUV", /* = 1 << 7, */ |
"FS_SRC_REPEAT_NONE", /* = 1 << 8, */ |
"FS_MASK_REPEAT_NONE",/* = 1 << 9, */ |
"FS_SRC_SWIZZLE_RGB", /* = 1 << 10, */ |
"FS_MASK_SWIZZLE_RGB",/* = 1 << 11, */ |
"FS_SRC_SET_ALPHA", /* = 1 << 12, */ |
"FS_MASK_SET_ALPHA", /* = 1 << 13, */ |
"FS_SRC_LUMINANCE", /* = 1 << 14, */ |
"FS_MASK_LUMINANCE", /* = 1 << 15, */ |
}; |
int i, k; |
debug_printf("%s: ", __func__); |
for (i = 0, k = 1; k < (1 << 16); i++, k <<= 1) { |
if (fs_traits & k) |
debug_printf("%s, ", strings[i]); |
} |
debug_printf("\n"); |
} |
struct xorg_shaders { |
struct xorg_renderer *r; |
struct cso_hash *vs_hash; |
struct cso_hash *fs_hash; |
}; |
static INLINE void |
src_in_mask(struct ureg_program *ureg, |
struct ureg_dst dst, |
struct ureg_src src, |
struct ureg_src mask, |
unsigned component_alpha, |
unsigned mask_luminance) |
{ |
if (component_alpha == FS_CA_FULL) { |
ureg_MUL(ureg, dst, src, mask); |
} else if (component_alpha == FS_CA_SRCALPHA) { |
ureg_MUL(ureg, dst, |
ureg_scalar(src, TGSI_SWIZZLE_W), mask); |
} |
else { |
if (mask_luminance) |
ureg_MUL(ureg, dst, src, |
ureg_scalar(mask, TGSI_SWIZZLE_X)); |
else |
ureg_MUL(ureg, dst, src, |
ureg_scalar(mask, TGSI_SWIZZLE_W)); |
} |
} |
static struct ureg_src |
vs_normalize_coords(struct ureg_program *ureg, struct ureg_src coords, |
struct ureg_src const0, struct ureg_src const1) |
{ |
struct ureg_dst tmp = ureg_DECL_temporary(ureg); |
struct ureg_src ret; |
ureg_MAD(ureg, tmp, coords, const0, const1); |
ret = ureg_src(tmp); |
ureg_release_temporary(ureg, tmp); |
return ret; |
} |
static void |
linear_gradient(struct ureg_program *ureg, |
struct ureg_dst out, |
struct ureg_src pos, |
struct ureg_src sampler, |
struct ureg_src coords, |
struct ureg_src const0124, |
struct ureg_src matrow0, |
struct ureg_src matrow1, |
struct ureg_src matrow2) |
{ |
struct ureg_dst temp0 = ureg_DECL_temporary(ureg); |
struct ureg_dst temp1 = ureg_DECL_temporary(ureg); |
struct ureg_dst temp2 = ureg_DECL_temporary(ureg); |
struct ureg_dst temp3 = ureg_DECL_temporary(ureg); |
struct ureg_dst temp4 = ureg_DECL_temporary(ureg); |
struct ureg_dst temp5 = ureg_DECL_temporary(ureg); |
ureg_MOV(ureg, |
ureg_writemask(temp0, TGSI_WRITEMASK_XY), pos); |
ureg_MOV(ureg, |
ureg_writemask(temp0, TGSI_WRITEMASK_Z), |
ureg_scalar(const0124, TGSI_SWIZZLE_Y)); |
ureg_DP3(ureg, temp1, matrow0, ureg_src(temp0)); |
ureg_DP3(ureg, temp2, matrow1, ureg_src(temp0)); |
ureg_DP3(ureg, temp3, matrow2, ureg_src(temp0)); |
ureg_RCP(ureg, temp3, ureg_src(temp3)); |
ureg_MUL(ureg, temp1, ureg_src(temp1), ureg_src(temp3)); |
ureg_MUL(ureg, temp2, ureg_src(temp2), ureg_src(temp3)); |
ureg_MOV(ureg, ureg_writemask(temp4, TGSI_WRITEMASK_X), |
ureg_src(temp1)); |
ureg_MOV(ureg, ureg_writemask(temp4, TGSI_WRITEMASK_Y), |
ureg_src(temp2)); |
ureg_MUL(ureg, temp0, |
ureg_scalar(coords, TGSI_SWIZZLE_Y), |
ureg_scalar(ureg_src(temp4), TGSI_SWIZZLE_Y)); |
ureg_MAD(ureg, temp1, |
ureg_scalar(coords, TGSI_SWIZZLE_X), |
ureg_scalar(ureg_src(temp4), TGSI_SWIZZLE_X), |
ureg_src(temp0)); |
ureg_MUL(ureg, temp2, |
ureg_src(temp1), |
ureg_scalar(coords, TGSI_SWIZZLE_Z)); |
ureg_TEX(ureg, out, |
TGSI_TEXTURE_1D, ureg_src(temp2), sampler); |
ureg_release_temporary(ureg, temp0); |
ureg_release_temporary(ureg, temp1); |
ureg_release_temporary(ureg, temp2); |
ureg_release_temporary(ureg, temp3); |
ureg_release_temporary(ureg, temp4); |
ureg_release_temporary(ureg, temp5); |
} |
static void |
radial_gradient(struct ureg_program *ureg, |
struct ureg_dst out, |
struct ureg_src pos, |
struct ureg_src sampler, |
struct ureg_src coords, |
struct ureg_src const0124, |
struct ureg_src matrow0, |
struct ureg_src matrow1, |
struct ureg_src matrow2) |
{ |
struct ureg_dst temp0 = ureg_DECL_temporary(ureg); |
struct ureg_dst temp1 = ureg_DECL_temporary(ureg); |
struct ureg_dst temp2 = ureg_DECL_temporary(ureg); |
struct ureg_dst temp3 = ureg_DECL_temporary(ureg); |
struct ureg_dst temp4 = ureg_DECL_temporary(ureg); |
struct ureg_dst temp5 = ureg_DECL_temporary(ureg); |
ureg_MOV(ureg, |
ureg_writemask(temp0, TGSI_WRITEMASK_XY), |
pos); |
ureg_MOV(ureg, |
ureg_writemask(temp0, TGSI_WRITEMASK_Z), |
ureg_scalar(const0124, TGSI_SWIZZLE_Y)); |
ureg_DP3(ureg, temp1, matrow0, ureg_src(temp0)); |
ureg_DP3(ureg, temp2, matrow1, ureg_src(temp0)); |
ureg_DP3(ureg, temp3, matrow2, ureg_src(temp0)); |
ureg_RCP(ureg, temp3, ureg_src(temp3)); |
ureg_MUL(ureg, temp1, ureg_src(temp1), ureg_src(temp3)); |
ureg_MUL(ureg, temp2, ureg_src(temp2), ureg_src(temp3)); |
ureg_MOV(ureg, ureg_writemask(temp5, TGSI_WRITEMASK_X), |
ureg_src(temp1)); |
ureg_MOV(ureg, ureg_writemask(temp5, TGSI_WRITEMASK_Y), |
ureg_src(temp2)); |
ureg_MUL(ureg, temp0, ureg_scalar(coords, TGSI_SWIZZLE_Y), |
ureg_scalar(ureg_src(temp5), TGSI_SWIZZLE_Y)); |
ureg_MAD(ureg, temp1, |
ureg_scalar(coords, TGSI_SWIZZLE_X), |
ureg_scalar(ureg_src(temp5), TGSI_SWIZZLE_X), |
ureg_src(temp0)); |
ureg_ADD(ureg, temp1, |
ureg_src(temp1), ureg_src(temp1)); |
ureg_MUL(ureg, temp3, |
ureg_scalar(ureg_src(temp5), TGSI_SWIZZLE_Y), |
ureg_scalar(ureg_src(temp5), TGSI_SWIZZLE_Y)); |
ureg_MAD(ureg, temp4, |
ureg_scalar(ureg_src(temp5), TGSI_SWIZZLE_X), |
ureg_scalar(ureg_src(temp5), TGSI_SWIZZLE_X), |
ureg_src(temp3)); |
ureg_MOV(ureg, temp4, ureg_negate(ureg_src(temp4))); |
ureg_MUL(ureg, temp2, |
ureg_scalar(coords, TGSI_SWIZZLE_Z), |
ureg_src(temp4)); |
ureg_MUL(ureg, temp0, |
ureg_scalar(const0124, TGSI_SWIZZLE_W), |
ureg_src(temp2)); |
ureg_MUL(ureg, temp3, |
ureg_src(temp1), ureg_src(temp1)); |
ureg_SUB(ureg, temp2, |
ureg_src(temp3), ureg_src(temp0)); |
ureg_RSQ(ureg, temp2, ureg_abs(ureg_src(temp2))); |
ureg_RCP(ureg, temp2, ureg_src(temp2)); |
ureg_SUB(ureg, temp1, |
ureg_src(temp2), ureg_src(temp1)); |
ureg_ADD(ureg, temp0, |
ureg_scalar(coords, TGSI_SWIZZLE_Z), |
ureg_scalar(coords, TGSI_SWIZZLE_Z)); |
ureg_RCP(ureg, temp0, ureg_src(temp0)); |
ureg_MUL(ureg, temp2, |
ureg_src(temp1), ureg_src(temp0)); |
ureg_TEX(ureg, out, TGSI_TEXTURE_1D, |
ureg_src(temp2), sampler); |
ureg_release_temporary(ureg, temp0); |
ureg_release_temporary(ureg, temp1); |
ureg_release_temporary(ureg, temp2); |
ureg_release_temporary(ureg, temp3); |
ureg_release_temporary(ureg, temp4); |
ureg_release_temporary(ureg, temp5); |
} |
static void * |
create_vs(struct pipe_context *pipe, |
unsigned vs_traits) |
{ |
struct ureg_program *ureg; |
struct ureg_src src; |
struct ureg_dst dst; |
struct ureg_src const0, const1; |
boolean is_fill = (vs_traits & VS_FILL) != 0; |
boolean is_composite = (vs_traits & VS_COMPOSITE) != 0; |
boolean has_mask = (vs_traits & VS_MASK) != 0; |
boolean is_yuv = (vs_traits & VS_YUV) != 0; |
unsigned input_slot = 0; |
ureg = ureg_create(TGSI_PROCESSOR_VERTEX); |
if (ureg == NULL) |
return 0; |
const0 = ureg_DECL_constant(ureg, 0); |
const1 = ureg_DECL_constant(ureg, 1); |
/* it has to be either a fill or a composite op */ |
debug_assert((is_fill ^ is_composite) ^ is_yuv); |
src = ureg_DECL_vs_input(ureg, input_slot++); |
dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_POSITION, 0); |
src = vs_normalize_coords(ureg, src, |
const0, const1); |
ureg_MOV(ureg, dst, src); |
if (is_yuv) { |
src = ureg_DECL_vs_input(ureg, input_slot++); |
dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_GENERIC, 0); |
ureg_MOV(ureg, dst, src); |
} |
if (is_composite) { |
src = ureg_DECL_vs_input(ureg, input_slot++); |
dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_GENERIC, 0); |
ureg_MOV(ureg, dst, src); |
} |
if (is_fill) { |
src = ureg_DECL_vs_input(ureg, input_slot++); |
dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_COLOR, 0); |
ureg_MOV(ureg, dst, src); |
} |
if (has_mask) { |
src = ureg_DECL_vs_input(ureg, input_slot++); |
dst = ureg_DECL_output(ureg, TGSI_SEMANTIC_GENERIC, 1); |
ureg_MOV(ureg, dst, src); |
} |
ureg_END(ureg); |
return ureg_create_shader_and_destroy(ureg, pipe); |
} |
static void * |
create_yuv_shader(struct pipe_context *pipe, struct ureg_program *ureg) |
{ |
struct ureg_src y_sampler, u_sampler, v_sampler; |
struct ureg_src pos; |
struct ureg_src matrow0, matrow1, matrow2; |
struct ureg_dst y, u, v, rgb; |
struct ureg_dst out = ureg_DECL_output(ureg, |
TGSI_SEMANTIC_COLOR, |
0); |
pos = ureg_DECL_fs_input(ureg, |
TGSI_SEMANTIC_GENERIC, |
0, |
TGSI_INTERPOLATE_PERSPECTIVE); |
rgb = ureg_DECL_temporary(ureg); |
y = ureg_DECL_temporary(ureg); |
u = ureg_DECL_temporary(ureg); |
v = ureg_DECL_temporary(ureg); |
y_sampler = ureg_DECL_sampler(ureg, 0); |
u_sampler = ureg_DECL_sampler(ureg, 1); |
v_sampler = ureg_DECL_sampler(ureg, 2); |
matrow0 = ureg_DECL_constant(ureg, 0); |
matrow1 = ureg_DECL_constant(ureg, 1); |
matrow2 = ureg_DECL_constant(ureg, 2); |
ureg_TEX(ureg, y, |
TGSI_TEXTURE_2D, pos, y_sampler); |
ureg_TEX(ureg, u, |
TGSI_TEXTURE_2D, pos, u_sampler); |
ureg_TEX(ureg, v, |
TGSI_TEXTURE_2D, pos, v_sampler); |
ureg_SUB(ureg, u, ureg_src(u), |
ureg_scalar(matrow0, TGSI_SWIZZLE_W)); |
ureg_SUB(ureg, v, ureg_src(v), |
ureg_scalar(matrow0, TGSI_SWIZZLE_W)); |
ureg_MUL(ureg, rgb, |
ureg_scalar(ureg_src(y), TGSI_SWIZZLE_X), |
matrow0); |
ureg_MAD(ureg, rgb, |
ureg_scalar(ureg_src(u), TGSI_SWIZZLE_X), |
matrow1, |
ureg_src(rgb)); |
ureg_MAD(ureg, rgb, |
ureg_scalar(ureg_src(v), TGSI_SWIZZLE_X), |
matrow2, |
ureg_src(rgb)); |
/* rgb.a = 1; */ |
ureg_MOV(ureg, ureg_writemask(rgb, TGSI_WRITEMASK_W), |
ureg_scalar(matrow0, TGSI_SWIZZLE_X)); |
ureg_MOV(ureg, out, ureg_src(rgb)); |
ureg_release_temporary(ureg, rgb); |
ureg_release_temporary(ureg, y); |
ureg_release_temporary(ureg, u); |
ureg_release_temporary(ureg, v); |
ureg_END(ureg); |
return ureg_create_shader_and_destroy(ureg, pipe); |
} |
static INLINE void |
xrender_tex(struct ureg_program *ureg, |
struct ureg_dst dst, |
struct ureg_src coords, |
struct ureg_src sampler, |
struct ureg_src imm0, |
boolean repeat_none, |
boolean swizzle, |
boolean set_alpha) |
{ |
if (repeat_none) { |
struct ureg_dst tmp0 = ureg_DECL_temporary(ureg); |
struct ureg_dst tmp1 = ureg_DECL_temporary(ureg); |
ureg_SGT(ureg, tmp1, ureg_swizzle(coords, |
TGSI_SWIZZLE_X, |
TGSI_SWIZZLE_Y, |
TGSI_SWIZZLE_X, |
TGSI_SWIZZLE_Y), |
ureg_scalar(imm0, TGSI_SWIZZLE_X)); |
ureg_SLT(ureg, tmp0, ureg_swizzle(coords, |
TGSI_SWIZZLE_X, |
TGSI_SWIZZLE_Y, |
TGSI_SWIZZLE_X, |
TGSI_SWIZZLE_Y), |
ureg_scalar(imm0, TGSI_SWIZZLE_W)); |
ureg_MIN(ureg, tmp0, ureg_src(tmp0), ureg_src(tmp1)); |
ureg_MIN(ureg, tmp0, ureg_scalar(ureg_src(tmp0), TGSI_SWIZZLE_X), |
ureg_scalar(ureg_src(tmp0), TGSI_SWIZZLE_Y)); |
ureg_TEX(ureg, tmp1, TGSI_TEXTURE_2D, coords, sampler); |
if (swizzle) |
ureg_MOV(ureg, tmp1, ureg_swizzle(ureg_src(tmp1), |
TGSI_SWIZZLE_Z, |
TGSI_SWIZZLE_Y, |
TGSI_SWIZZLE_X, |
TGSI_SWIZZLE_W)); |
if (set_alpha) |
ureg_MOV(ureg, |
ureg_writemask(tmp1, TGSI_WRITEMASK_W), |
ureg_scalar(imm0, TGSI_SWIZZLE_W)); |
ureg_MUL(ureg, dst, ureg_src(tmp1), ureg_src(tmp0)); |
ureg_release_temporary(ureg, tmp0); |
ureg_release_temporary(ureg, tmp1); |
} else { |
if (swizzle) { |
struct ureg_dst tmp = ureg_DECL_temporary(ureg); |
ureg_TEX(ureg, tmp, TGSI_TEXTURE_2D, coords, sampler); |
ureg_MOV(ureg, dst, ureg_swizzle(ureg_src(tmp), |
TGSI_SWIZZLE_Z, |
TGSI_SWIZZLE_Y, |
TGSI_SWIZZLE_X, |
TGSI_SWIZZLE_W)); |
ureg_release_temporary(ureg, tmp); |
} else { |
ureg_TEX(ureg, dst, TGSI_TEXTURE_2D, coords, sampler); |
} |
if (set_alpha) |
ureg_MOV(ureg, |
ureg_writemask(dst, TGSI_WRITEMASK_W), |
ureg_scalar(imm0, TGSI_SWIZZLE_W)); |
} |
} |
static void * |
create_fs(struct pipe_context *pipe, |
unsigned fs_traits) |
{ |
struct ureg_program *ureg; |
struct ureg_src /*dst_sampler,*/ src_sampler, mask_sampler; |
struct ureg_src /*dst_pos,*/ src_input, mask_pos; |
struct ureg_dst src, mask; |
struct ureg_dst out; |
struct ureg_src imm0 = { 0 }; |
unsigned has_mask = (fs_traits & FS_MASK) != 0; |
unsigned is_fill = (fs_traits & FS_FILL) != 0; |
unsigned is_composite = (fs_traits & FS_COMPOSITE) != 0; |
unsigned is_solid = (fs_traits & FS_SOLID_FILL) != 0; |
unsigned is_lingrad = (fs_traits & FS_LINGRAD_FILL) != 0; |
unsigned is_radgrad = (fs_traits & FS_RADGRAD_FILL) != 0; |
unsigned comp_alpha_mask = fs_traits & FS_COMPONENT_ALPHA; |
unsigned is_yuv = (fs_traits & FS_YUV) != 0; |
unsigned src_repeat_none = (fs_traits & FS_SRC_REPEAT_NONE) != 0; |
unsigned mask_repeat_none = (fs_traits & FS_MASK_REPEAT_NONE) != 0; |
unsigned src_swizzle = (fs_traits & FS_SRC_SWIZZLE_RGB) != 0; |
unsigned mask_swizzle = (fs_traits & FS_MASK_SWIZZLE_RGB) != 0; |
unsigned src_set_alpha = (fs_traits & FS_SRC_SET_ALPHA) != 0; |
unsigned mask_set_alpha = (fs_traits & FS_MASK_SET_ALPHA) != 0; |
unsigned src_luminance = (fs_traits & FS_SRC_LUMINANCE) != 0; |
unsigned mask_luminance = (fs_traits & FS_MASK_LUMINANCE) != 0; |
#if 0 |
print_fs_traits(fs_traits); |
#else |
(void)print_fs_traits; |
#endif |
ureg = ureg_create(TGSI_PROCESSOR_FRAGMENT); |
if (ureg == NULL) |
return 0; |
/* it has to be either a fill, a composite op or a yuv conversion */ |
debug_assert((is_fill ^ is_composite) ^ is_yuv); |
(void) is_yuv; |
out = ureg_DECL_output(ureg, |
TGSI_SEMANTIC_COLOR, |
0); |
if (src_repeat_none || mask_repeat_none || |
src_set_alpha || mask_set_alpha || |
src_luminance) { |
imm0 = ureg_imm4f(ureg, 0, 0, 0, 1); |
} |
if (is_composite) { |
src_sampler = ureg_DECL_sampler(ureg, 0); |
src_input = ureg_DECL_fs_input(ureg, |
TGSI_SEMANTIC_GENERIC, |
0, |
TGSI_INTERPOLATE_PERSPECTIVE); |
} else if (is_fill) { |
if (is_solid) |
src_input = ureg_DECL_fs_input(ureg, |
TGSI_SEMANTIC_COLOR, |
0, |
TGSI_INTERPOLATE_PERSPECTIVE); |
else |
src_input = ureg_DECL_fs_input(ureg, |
TGSI_SEMANTIC_POSITION, |
0, |
TGSI_INTERPOLATE_PERSPECTIVE); |
} else { |
debug_assert(is_yuv); |
return create_yuv_shader(pipe, ureg); |
} |
if (has_mask) { |
mask_sampler = ureg_DECL_sampler(ureg, 1); |
mask_pos = ureg_DECL_fs_input(ureg, |
TGSI_SEMANTIC_GENERIC, |
1, |
TGSI_INTERPOLATE_PERSPECTIVE); |
} |
#if 0 /* unused right now */ |
dst_sampler = ureg_DECL_sampler(ureg, 2); |
dst_pos = ureg_DECL_fs_input(ureg, |
TGSI_SEMANTIC_POSITION, |
2, |
TGSI_INTERPOLATE_PERSPECTIVE); |
#endif |
if (is_composite) { |
if (has_mask || src_luminance) |
src = ureg_DECL_temporary(ureg); |
else |
src = out; |
xrender_tex(ureg, src, src_input, src_sampler, imm0, |
src_repeat_none, src_swizzle, src_set_alpha); |
} else if (is_fill) { |
if (is_solid) { |
if (has_mask || src_luminance) |
src = ureg_dst(src_input); |
else |
ureg_MOV(ureg, out, src_input); |
} else if (is_lingrad || is_radgrad) { |
struct ureg_src coords, const0124, |
matrow0, matrow1, matrow2; |
if (has_mask || src_luminance) |
src = ureg_DECL_temporary(ureg); |
else |
src = out; |
coords = ureg_DECL_constant(ureg, 0); |
const0124 = ureg_DECL_constant(ureg, 1); |
matrow0 = ureg_DECL_constant(ureg, 2); |
matrow1 = ureg_DECL_constant(ureg, 3); |
matrow2 = ureg_DECL_constant(ureg, 4); |
if (is_lingrad) { |
linear_gradient(ureg, src, |
src_input, src_sampler, |
coords, const0124, |
matrow0, matrow1, matrow2); |
} else if (is_radgrad) { |
radial_gradient(ureg, src, |
src_input, src_sampler, |
coords, const0124, |
matrow0, matrow1, matrow2); |
} |
} else |
debug_assert(!"Unknown fill type!"); |
} |
if (src_luminance) { |
ureg_MOV(ureg, src, |
ureg_scalar(ureg_src(src), TGSI_SWIZZLE_X)); |
ureg_MOV(ureg, ureg_writemask(src, TGSI_WRITEMASK_XYZ), |
ureg_scalar(imm0, TGSI_SWIZZLE_X)); |
if (!has_mask) |
ureg_MOV(ureg, out, ureg_src(src)); |
} |
if (has_mask) { |
mask = ureg_DECL_temporary(ureg); |
xrender_tex(ureg, mask, mask_pos, mask_sampler, imm0, |
mask_repeat_none, mask_swizzle, mask_set_alpha); |
/* src IN mask */ |
src_in_mask(ureg, out, ureg_src(src), ureg_src(mask), |
comp_alpha_mask, mask_luminance); |
ureg_release_temporary(ureg, mask); |
} |
ureg_END(ureg); |
return ureg_create_shader_and_destroy(ureg, pipe); |
} |
struct xorg_shaders * xorg_shaders_create(struct xorg_renderer *r) |
{ |
struct xorg_shaders *sc = CALLOC_STRUCT(xorg_shaders); |
sc->r = r; |
sc->vs_hash = cso_hash_create(); |
sc->fs_hash = cso_hash_create(); |
return sc; |
} |
static void |
cache_destroy(struct cso_context *cso, |
struct cso_hash *hash, |
unsigned processor) |
{ |
struct cso_hash_iter iter = cso_hash_first_node(hash); |
while (!cso_hash_iter_is_null(iter)) { |
void *shader = (void *)cso_hash_iter_data(iter); |
if (processor == PIPE_SHADER_FRAGMENT) { |
cso_delete_fragment_shader(cso, shader); |
} else if (processor == PIPE_SHADER_VERTEX) { |
cso_delete_vertex_shader(cso, shader); |
} |
iter = cso_hash_erase(hash, iter); |
} |
cso_hash_delete(hash); |
} |
void xorg_shaders_destroy(struct xorg_shaders *sc) |
{ |
cache_destroy(sc->r->cso, sc->vs_hash, |
PIPE_SHADER_VERTEX); |
cache_destroy(sc->r->cso, sc->fs_hash, |
PIPE_SHADER_FRAGMENT); |
FREE(sc); |
} |
static INLINE void * |
shader_from_cache(struct pipe_context *pipe, |
unsigned type, |
struct cso_hash *hash, |
unsigned key) |
{ |
void *shader = 0; |
struct cso_hash_iter iter = cso_hash_find(hash, key); |
if (cso_hash_iter_is_null(iter)) { |
if (type == PIPE_SHADER_VERTEX) |
shader = create_vs(pipe, key); |
else |
shader = create_fs(pipe, key); |
cso_hash_insert(hash, key, shader); |
} else |
shader = (void *)cso_hash_iter_data(iter); |
return shader; |
} |
struct xorg_shader xorg_shaders_get(struct xorg_shaders *sc, |
unsigned vs_traits, |
unsigned fs_traits) |
{ |
struct xorg_shader shader = { NULL, NULL }; |
void *vs, *fs; |
vs = shader_from_cache(sc->r->pipe, PIPE_SHADER_VERTEX, |
sc->vs_hash, vs_traits); |
fs = shader_from_cache(sc->r->pipe, PIPE_SHADER_FRAGMENT, |
sc->fs_hash, fs_traits); |
debug_assert(vs && fs); |
if (!vs || !fs) |
return shader; |
shader.vs = vs; |
shader.fs = fs; |
return shader; |
} |
/contrib/sdk/sources/Mesa/mesa-9.2.5/src/gallium/state_trackers/xorg/xorg_exa_tgsi.h |
---|
0,0 → 1,59 |
#ifndef XORG_EXA_TGSI_H |
#define XORG_EXA_TGSI_H |
#include "xorg_renderer.h" |
enum xorg_vs_traits { |
VS_COMPOSITE = 1 << 0, |
VS_MASK = 1 << 1, |
VS_SOLID_FILL = 1 << 2, |
VS_LINGRAD_FILL = 1 << 3, |
VS_RADGRAD_FILL = 1 << 4, |
VS_YUV = 1 << 5, |
VS_FILL = (VS_SOLID_FILL | |
VS_LINGRAD_FILL | |
VS_RADGRAD_FILL) |
}; |
enum xorg_fs_traits { |
FS_COMPOSITE = 1 << 0, |
FS_MASK = 1 << 1, |
FS_SOLID_FILL = 1 << 2, |
FS_LINGRAD_FILL = 1 << 3, |
FS_RADGRAD_FILL = 1 << 4, |
FS_CA_FULL = 1 << 5, /* src.rgba * mask.rgba */ |
FS_CA_SRCALPHA = 1 << 6, /* src.aaaa * mask.rgba */ |
FS_YUV = 1 << 7, |
FS_SRC_REPEAT_NONE = 1 << 8, |
FS_MASK_REPEAT_NONE = 1 << 9, |
FS_SRC_SWIZZLE_RGB = 1 << 10, |
FS_MASK_SWIZZLE_RGB = 1 << 11, |
FS_SRC_SET_ALPHA = 1 << 12, |
FS_MASK_SET_ALPHA = 1 << 13, |
FS_SRC_LUMINANCE = 1 << 14, |
FS_MASK_LUMINANCE = 1 << 15, |
FS_FILL = (FS_SOLID_FILL | |
FS_LINGRAD_FILL | |
FS_RADGRAD_FILL), |
FS_COMPONENT_ALPHA = (FS_CA_FULL | |
FS_CA_SRCALPHA) |
}; |
struct xorg_shader { |
void *fs; |
void *vs; |
}; |
struct xorg_shaders; |
struct xorg_shaders *xorg_shaders_create(struct xorg_renderer *renderer); |
void xorg_shaders_destroy(struct xorg_shaders *shaders); |
struct xorg_shader xorg_shaders_get(struct xorg_shaders *shaders, |
unsigned vs_traits, |
unsigned fs_traits); |
#endif |
/contrib/sdk/sources/Mesa/mesa-9.2.5/src/gallium/state_trackers/xorg/xorg_output.c |
---|
0,0 → 1,338 |
/* |
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. |
* All Rights Reserved. |
* |
* 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, sub license, 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 (including the |
* next paragraph) 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 NON-INFRINGEMENT. |
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. |
* |
* |
* Author: Alan Hourihane <alanh@tungstengraphics.com> |
* Author: Jakob Bornecrantz <wallbraker@gmail.com> |
* |
*/ |
#include "xorg-server.h" |
#include <xf86.h> |
#include <xf86i2c.h> |
#include <xf86Crtc.h> |
#include <xf86DDC.h> |
#include <errno.h> |
#include <fcntl.h> |
#include <unistd.h> |
#include <stdio.h> |
#include <stdlib.h> |
#include <stdint.h> |
#include <string.h> |
#include <sys/stat.h> |
#include <sys/types.h> |
#ifdef HAVE_XEXTPROTO_71 |
#include <X11/extensions/dpmsconst.h> |
#else |
#define DPMS_SERVER |
#include <X11/extensions/dpms.h> |
#endif |
#include "xorg_tracker.h" |
struct output_private |
{ |
drmModeConnectorPtr drm_connector; |
drmModePropertyBlobPtr edid_blob; |
int fd; |
int c; |
}; |
static char *output_enum_list[] = { |
"Unknown", |
"VGA", |
"DVI", |
"DVI", |
"DVI", |
"Composite", |
"SVIDEO", |
"LVDS", |
"CTV", |
"DIN", |
"DP", |
"HDMI", |
"HDMI", |
}; |
static void |
output_create_resources(xf86OutputPtr output) |
{ |
#ifdef RANDR_12_INTERFACE |
#endif /* RANDR_12_INTERFACE */ |
} |
static void |
output_dpms(xf86OutputPtr output, int mode) |
{ |
} |
static xf86OutputStatus |
output_detect(xf86OutputPtr output) |
{ |
modesettingPtr ms = modesettingPTR(output->scrn); |
struct output_private *priv = output->driver_private; |
drmModeConnectorPtr drm_connector; |
xf86OutputStatus status; |
drm_connector = drmModeGetConnector(ms->fd, priv->drm_connector->connector_id); |
if (drm_connector) { |
drmModeFreeConnector(priv->drm_connector); |
priv->drm_connector = drm_connector; |
} else { |
drm_connector = priv->drm_connector; |
} |
switch (drm_connector->connection) { |
case DRM_MODE_CONNECTED: |
status = XF86OutputStatusConnected; |
break; |
case DRM_MODE_DISCONNECTED: |
status = XF86OutputStatusDisconnected; |
break; |
default: |
status = XF86OutputStatusUnknown; |
} |
return status; |
} |
static DisplayModePtr |
output_get_modes(xf86OutputPtr output) |
{ |
struct output_private *priv = output->driver_private; |
drmModeConnectorPtr drm_connector = priv->drm_connector; |
drmModeModeInfoPtr drm_mode = NULL; |
drmModePropertyPtr props = NULL; |
xf86MonPtr ddc_mon = NULL; |
DisplayModePtr modes = NULL, mode = NULL; |
int i; |
for (i = 0; i < drm_connector->count_props; i++) { |
props = drmModeGetProperty(priv->fd, drm_connector->props[i]); |
if (!props) |
continue; |
if (!(props->flags & DRM_MODE_PROP_BLOB)) |
goto out_free; |
if (!strcmp(props->name, "EDID")) { |
if (priv->edid_blob) |
drmModeFreePropertyBlob(priv->edid_blob); |
priv->edid_blob = drmModeGetPropertyBlob(priv->fd, |
drm_connector->prop_values[i]); |
} |
out_free: |
drmModeFreeProperty(props); |
} |
if (priv->edid_blob) { |
ddc_mon = xf86InterpretEDID(output->scrn->scrnIndex, |
priv->edid_blob->data); |
if (ddc_mon && priv->edid_blob->length > 128) |
ddc_mon->flags |= MONITOR_EDID_COMPLETE_RAWDATA; |
} |
xf86OutputSetEDID(output, ddc_mon); |
for (i = 0; i < drm_connector->count_modes; i++) { |
drm_mode = &drm_connector->modes[i]; |
if (drm_mode) { |
mode = calloc(1, sizeof(DisplayModeRec)); |
if (!mode) |
continue; |
mode->Clock = drm_mode->clock; |
mode->HDisplay = drm_mode->hdisplay; |
mode->HSyncStart = drm_mode->hsync_start; |
mode->HSyncEnd = drm_mode->hsync_end; |
mode->HTotal = drm_mode->htotal; |
mode->VDisplay = drm_mode->vdisplay; |
mode->VSyncStart = drm_mode->vsync_start; |
mode->VSyncEnd = drm_mode->vsync_end; |
mode->VTotal = drm_mode->vtotal; |
mode->Flags = drm_mode->flags; |
mode->HSkew = drm_mode->hskew; |
mode->VScan = drm_mode->vscan; |
mode->VRefresh = xf86ModeVRefresh(mode); |
mode->Private = (void *)drm_mode; |
mode->type = 0; |
if (drm_mode->type & DRM_MODE_TYPE_PREFERRED) |
mode->type |= M_T_PREFERRED; |
if (drm_mode->type & DRM_MODE_TYPE_DRIVER) |
mode->type |= M_T_DRIVER; |
xf86SetModeDefaultName(mode); |
modes = xf86ModesAdd(modes, mode); |
xf86PrintModeline(0, mode); |
} |
} |
return modes; |
} |
static int |
output_mode_valid(xf86OutputPtr output, DisplayModePtr pMode) |
{ |
modesettingPtr ms = modesettingPTR(output->scrn); |
CustomizerPtr cust = ms->cust; |
if (cust && cust->winsys_check_fb_size && |
!cust->winsys_check_fb_size(cust, pMode->HDisplay * |
output->scrn->bitsPerPixel / 8, |
pMode->VDisplay)) |
return MODE_BAD; |
return MODE_OK; |
} |
#ifdef RANDR_12_INTERFACE |
static Bool |
output_set_property(xf86OutputPtr output, Atom property, RRPropertyValuePtr value) |
{ |
return TRUE; |
} |
#endif /* RANDR_12_INTERFACE */ |
#ifdef RANDR_13_INTERFACE |
static Bool |
output_get_property(xf86OutputPtr output, Atom property) |
{ |
return TRUE; |
} |
#endif /* RANDR_13_INTERFACE */ |
static void |
output_destroy(xf86OutputPtr output) |
{ |
struct output_private *priv = output->driver_private; |
if (priv->edid_blob) |
drmModeFreePropertyBlob(priv->edid_blob); |
drmModeFreeConnector(priv->drm_connector); |
free(priv); |
output->driver_private = NULL; |
} |
static const xf86OutputFuncsRec output_funcs = { |
.create_resources = output_create_resources, |
#ifdef RANDR_12_INTERFACE |
.set_property = output_set_property, |
#endif |
#ifdef RANDR_13_INTERFACE |
.get_property = output_get_property, |
#endif |
.dpms = output_dpms, |
.detect = output_detect, |
.get_modes = output_get_modes, |
.mode_valid = output_mode_valid, |
.destroy = output_destroy, |
}; |
void |
xorg_output_init(ScrnInfoPtr pScrn) |
{ |
modesettingPtr ms = modesettingPTR(pScrn); |
xf86OutputPtr output; |
drmModeResPtr res; |
drmModeConnectorPtr drm_connector = NULL; |
drmModeEncoderPtr drm_encoder = NULL; |
struct output_private *priv; |
char name[32]; |
int c, v, p; |
res = drmModeGetResources(ms->fd); |
if (res == 0) { |
DRV_ERROR("Failed drmModeGetResources\n"); |
return; |
} |
for (c = 0; c < res->count_connectors; c++) { |
drm_connector = drmModeGetConnector(ms->fd, res->connectors[c]); |
if (!drm_connector) |
goto out; |
#if 0 |
for (p = 0; p < drm_connector->count_props; p++) { |
drmModePropertyPtr prop; |
prop = drmModeGetProperty(ms->fd, drm_connector->props[p]); |
name = NULL; |
if (prop) { |
ErrorF("VALUES %d\n", prop->count_values); |
for (v = 0; v < prop->count_values; v++) |
ErrorF("%s %lld\n", prop->name, prop->values[v]); |
} |
} |
#else |
(void)p; |
(void)v; |
#endif |
snprintf(name, 32, "%s%d", |
output_enum_list[drm_connector->connector_type], |
drm_connector->connector_type_id); |
priv = calloc(sizeof(*priv), 1); |
if (!priv) { |
continue; |
} |
output = xf86OutputCreate(pScrn, &output_funcs, name); |
if (!output) { |
free(priv); |
continue; |
} |
drm_encoder = drmModeGetEncoder(ms->fd, drm_connector->encoders[0]); |
if (drm_encoder) { |
output->possible_crtcs = drm_encoder->possible_crtcs; |
output->possible_clones = drm_encoder->possible_clones; |
} else { |
output->possible_crtcs = 0; |
output->possible_clones = 0; |
} |
priv->c = c; |
priv->drm_connector = drm_connector; |
priv->fd = ms->fd; |
output->driver_private = priv; |
output->subpixel_order = SubPixelHorizontalRGB; |
output->interlaceAllowed = FALSE; |
output->doubleScanAllowed = FALSE; |
} |
out: |
drmModeFreeResources(res); |
} |
unsigned |
xorg_output_get_id(xf86OutputPtr output) |
{ |
struct output_private *priv = output->driver_private; |
return priv->drm_connector->connector_id; |
} |
/* vim: set sw=4 ts=8 sts=4: */ |
/contrib/sdk/sources/Mesa/mesa-9.2.5/src/gallium/state_trackers/xorg/xorg_renderer.c |
---|
0,0 → 1,547 |
#include "xorg_exa.h" |
#include "xorg_renderer.h" |
#include "xorg_exa_tgsi.h" |
#include "cso_cache/cso_context.h" |
#include "util/u_draw_quad.h" |
#include "util/u_math.h" |
#include "util/u_memory.h" |
#include "util/u_sampler.h" |
#include "util/u_inlines.h" |
#include "util/u_box.h" |
#include <math.h> |
#define floatsEqual(x, y) (fabs(x - y) <= 0.00001f * MIN2(fabs(x), fabs(y))) |
#define floatIsZero(x) (floatsEqual((x) + 1, 1)) |
#define NUM_COMPONENTS 4 |
static INLINE boolean is_affine(float *matrix) |
{ |
return floatIsZero(matrix[2]) && floatIsZero(matrix[5]) |
&& floatsEqual(matrix[8], 1); |
} |
static INLINE void map_point(float *mat, float x, float y, |
float *out_x, float *out_y) |
{ |
if (!mat) { |
*out_x = x; |
*out_y = y; |
return; |
} |
*out_x = mat[0]*x + mat[3]*y + mat[6]; |
*out_y = mat[1]*x + mat[4]*y + mat[7]; |
if (!is_affine(mat)) { |
float w = 1/(mat[2]*x + mat[5]*y + mat[8]); |
*out_x *= w; |
*out_y *= w; |
} |
} |
static INLINE void |
renderer_draw(struct xorg_renderer *r) |
{ |
int num_verts = r->buffer_size/(r->attrs_per_vertex * NUM_COMPONENTS); |
if (!r->buffer_size) |
return; |
cso_set_vertex_elements(r->cso, r->attrs_per_vertex, r->velems); |
util_draw_user_vertex_buffer(r->cso, r->buffer, PIPE_PRIM_QUADS, |
num_verts, r->attrs_per_vertex); |
r->buffer_size = 0; |
} |
static INLINE void |
renderer_draw_conditional(struct xorg_renderer *r, |
int next_batch) |
{ |
if (r->buffer_size + next_batch >= BUF_SIZE || |
(next_batch == 0 && r->buffer_size)) { |
renderer_draw(r); |
} |
} |
static void |
renderer_init_state(struct xorg_renderer *r) |
{ |
struct pipe_depth_stencil_alpha_state dsa; |
struct pipe_rasterizer_state raster; |
unsigned i; |
/* set common initial clip state */ |
memset(&dsa, 0, sizeof(struct pipe_depth_stencil_alpha_state)); |
cso_set_depth_stencil_alpha(r->cso, &dsa); |
/* XXX: move to renderer_init_state? */ |
memset(&raster, 0, sizeof(struct pipe_rasterizer_state)); |
raster.half_pixel_center = 1; |
raster.bottom_edge_rule = 1; |
raster.depth_clip = 1; |
cso_set_rasterizer(r->cso, &raster); |
/* vertex elements state */ |
memset(&r->velems[0], 0, sizeof(r->velems[0]) * 3); |
for (i = 0; i < 3; i++) { |
r->velems[i].src_offset = i * 4 * sizeof(float); |
r->velems[i].instance_divisor = 0; |
r->velems[i].vertex_buffer_index = 0; |
r->velems[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT; |
} |
} |
static INLINE void |
add_vertex_color(struct xorg_renderer *r, |
float x, float y, |
float color[4]) |
{ |
float *vertex = r->buffer + r->buffer_size; |
vertex[0] = x; |
vertex[1] = y; |
vertex[2] = 0.f; /*z*/ |
vertex[3] = 1.f; /*w*/ |
vertex[4] = color[0]; /*r*/ |
vertex[5] = color[1]; /*g*/ |
vertex[6] = color[2]; /*b*/ |
vertex[7] = color[3]; /*a*/ |
r->buffer_size += 8; |
} |
static INLINE void |
add_vertex_1tex(struct xorg_renderer *r, |
float x, float y, float s, float t) |
{ |
float *vertex = r->buffer + r->buffer_size; |
vertex[0] = x; |
vertex[1] = y; |
vertex[2] = 0.f; /*z*/ |
vertex[3] = 1.f; /*w*/ |
vertex[4] = s; /*s*/ |
vertex[5] = t; /*t*/ |
vertex[6] = 0.f; /*r*/ |
vertex[7] = 1.f; /*q*/ |
r->buffer_size += 8; |
} |
static void |
add_vertex_data1(struct xorg_renderer *r, |
float srcX, float srcY, float dstX, float dstY, |
float width, float height, |
struct pipe_resource *src, float *src_matrix) |
{ |
float s0, t0, s1, t1, s2, t2, s3, t3; |
float pt0[2], pt1[2], pt2[2], pt3[2]; |
pt0[0] = srcX; |
pt0[1] = srcY; |
pt1[0] = (srcX + width); |
pt1[1] = srcY; |
pt2[0] = (srcX + width); |
pt2[1] = (srcY + height); |
pt3[0] = srcX; |
pt3[1] = (srcY + height); |
if (src_matrix) { |
map_point(src_matrix, pt0[0], pt0[1], &pt0[0], &pt0[1]); |
map_point(src_matrix, pt1[0], pt1[1], &pt1[0], &pt1[1]); |
map_point(src_matrix, pt2[0], pt2[1], &pt2[0], &pt2[1]); |
map_point(src_matrix, pt3[0], pt3[1], &pt3[0], &pt3[1]); |
} |
s0 = pt0[0] / src->width0; |
s1 = pt1[0] / src->width0; |
s2 = pt2[0] / src->width0; |
s3 = pt3[0] / src->width0; |
t0 = pt0[1] / src->height0; |
t1 = pt1[1] / src->height0; |
t2 = pt2[1] / src->height0; |
t3 = pt3[1] / src->height0; |
/* 1st vertex */ |
add_vertex_1tex(r, dstX, dstY, s0, t0); |
/* 2nd vertex */ |
add_vertex_1tex(r, dstX + width, dstY, s1, t1); |
/* 3rd vertex */ |
add_vertex_1tex(r, dstX + width, dstY + height, s2, t2); |
/* 4th vertex */ |
add_vertex_1tex(r, dstX, dstY + height, s3, t3); |
} |
static INLINE void |
add_vertex_2tex(struct xorg_renderer *r, |
float x, float y, |
float s0, float t0, float s1, float t1) |
{ |
float *vertex = r->buffer + r->buffer_size; |
vertex[0] = x; |
vertex[1] = y; |
vertex[2] = 0.f; /*z*/ |
vertex[3] = 1.f; /*w*/ |
vertex[4] = s0; /*s*/ |
vertex[5] = t0; /*t*/ |
vertex[6] = 0.f; /*r*/ |
vertex[7] = 1.f; /*q*/ |
vertex[8] = s1; /*s*/ |
vertex[9] = t1; /*t*/ |
vertex[10] = 0.f; /*r*/ |
vertex[11] = 1.f; /*q*/ |
r->buffer_size += 12; |
} |
static void |
add_vertex_data2(struct xorg_renderer *r, |
float srcX, float srcY, float maskX, float maskY, |
float dstX, float dstY, float width, float height, |
struct pipe_resource *src, |
struct pipe_resource *mask, |
float *src_matrix, float *mask_matrix) |
{ |
float src_s0, src_t0, src_s1, src_t1, src_s2, src_t2, src_s3, src_t3; |
float mask_s0, mask_t0, mask_s1, mask_t1, mask_s2, mask_t2, mask_s3, mask_t3; |
float spt0[2], spt1[2], spt2[2], spt3[2]; |
float mpt0[2], mpt1[2], mpt2[2], mpt3[2]; |
spt0[0] = srcX; |
spt0[1] = srcY; |
spt1[0] = (srcX + width); |
spt1[1] = srcY; |
spt2[0] = (srcX + width); |
spt2[1] = (srcY + height); |
spt3[0] = srcX; |
spt3[1] = (srcY + height); |
mpt0[0] = maskX; |
mpt0[1] = maskY; |
mpt1[0] = (maskX + width); |
mpt1[1] = maskY; |
mpt2[0] = (maskX + width); |
mpt2[1] = (maskY + height); |
mpt3[0] = maskX; |
mpt3[1] = (maskY + height); |
if (src_matrix) { |
map_point(src_matrix, spt0[0], spt0[1], &spt0[0], &spt0[1]); |
map_point(src_matrix, spt1[0], spt1[1], &spt1[0], &spt1[1]); |
map_point(src_matrix, spt2[0], spt2[1], &spt2[0], &spt2[1]); |
map_point(src_matrix, spt3[0], spt3[1], &spt3[0], &spt3[1]); |
} |
if (mask_matrix) { |
map_point(mask_matrix, mpt0[0], mpt0[1], &mpt0[0], &mpt0[1]); |
map_point(mask_matrix, mpt1[0], mpt1[1], &mpt1[0], &mpt1[1]); |
map_point(mask_matrix, mpt2[0], mpt2[1], &mpt2[0], &mpt2[1]); |
map_point(mask_matrix, mpt3[0], mpt3[1], &mpt3[0], &mpt3[1]); |
} |
src_s0 = spt0[0] / src->width0; |
src_s1 = spt1[0] / src->width0; |
src_s2 = spt2[0] / src->width0; |
src_s3 = spt3[0] / src->width0; |
src_t0 = spt0[1] / src->height0; |
src_t1 = spt1[1] / src->height0; |
src_t2 = spt2[1] / src->height0; |
src_t3 = spt3[1] / src->height0; |
mask_s0 = mpt0[0] / mask->width0; |
mask_s1 = mpt1[0] / mask->width0; |
mask_s2 = mpt2[0] / mask->width0; |
mask_s3 = mpt3[0] / mask->width0; |
mask_t0 = mpt0[1] / mask->height0; |
mask_t1 = mpt1[1] / mask->height0; |
mask_t2 = mpt2[1] / mask->height0; |
mask_t3 = mpt3[1] / mask->height0; |
/* 1st vertex */ |
add_vertex_2tex(r, dstX, dstY, |
src_s0, src_t0, mask_s0, mask_t0); |
/* 2nd vertex */ |
add_vertex_2tex(r, dstX + width, dstY, |
src_s1, src_t1, mask_s1, mask_t1); |
/* 3rd vertex */ |
add_vertex_2tex(r, dstX + width, dstY + height, |
src_s2, src_t2, mask_s2, mask_t2); |
/* 4th vertex */ |
add_vertex_2tex(r, dstX, dstY + height, |
src_s3, src_t3, mask_s3, mask_t3); |
} |
static void |
setup_vertex_data_yuv(struct xorg_renderer *r, |
float srcX, float srcY, float srcW, float srcH, |
float dstX, float dstY, float dstW, float dstH, |
struct pipe_resource **tex) |
{ |
float s0, t0, s1, t1; |
float spt0[2], spt1[2]; |
spt0[0] = srcX; |
spt0[1] = srcY; |
spt1[0] = srcX + srcW; |
spt1[1] = srcY + srcH; |
s0 = spt0[0] / tex[0]->width0; |
t0 = spt0[1] / tex[0]->height0; |
s1 = spt1[0] / tex[0]->width0; |
t1 = spt1[1] / tex[0]->height0; |
/* 1st vertex */ |
add_vertex_1tex(r, dstX, dstY, s0, t0); |
/* 2nd vertex */ |
add_vertex_1tex(r, dstX + dstW, dstY, |
s1, t0); |
/* 3rd vertex */ |
add_vertex_1tex(r, dstX + dstW, dstY + dstH, |
s1, t1); |
/* 4th vertex */ |
add_vertex_1tex(r, dstX, dstY + dstH, |
s0, t1); |
} |
/* Set up framebuffer, viewport and vertex shader constant buffer |
* state for a particular destinaton surface. In all our rendering, |
* these concepts are linked. |
*/ |
void renderer_bind_destination(struct xorg_renderer *r, |
struct pipe_surface *surface, |
int width, |
int height ) |
{ |
struct pipe_framebuffer_state fb; |
struct pipe_viewport_state viewport; |
/* Framebuffer uses actual surface width/height |
*/ |
memset(&fb, 0, sizeof fb); |
fb.width = surface->width; |
fb.height = surface->height; |
fb.nr_cbufs = 1; |
fb.cbufs[0] = surface; |
fb.zsbuf = 0; |
/* Viewport just touches the bit we're interested in: |
*/ |
viewport.scale[0] = width / 2.f; |
viewport.scale[1] = height / 2.f; |
viewport.scale[2] = 1.0; |
viewport.scale[3] = 1.0; |
viewport.translate[0] = width / 2.f; |
viewport.translate[1] = height / 2.f; |
viewport.translate[2] = 0.0; |
viewport.translate[3] = 0.0; |
/* Constant buffer set up to match viewport dimensions: |
*/ |
if (r->fb_width != width || |
r->fb_height != height) |
{ |
float vs_consts[8] = { |
2.f/width, 2.f/height, 1, 1, |
-1, -1, 0, 0 |
}; |
r->fb_width = width; |
r->fb_height = height; |
renderer_set_constants(r, PIPE_SHADER_VERTEX, |
vs_consts, sizeof vs_consts); |
} |
cso_set_framebuffer(r->cso, &fb); |
cso_set_viewport(r->cso, &viewport); |
} |
struct xorg_renderer * renderer_create(struct pipe_context *pipe) |
{ |
struct xorg_renderer *renderer = CALLOC_STRUCT(xorg_renderer); |
renderer->pipe = pipe; |
renderer->cso = cso_create_context(pipe); |
renderer->shaders = xorg_shaders_create(renderer); |
renderer_init_state(renderer); |
return renderer; |
} |
void renderer_destroy(struct xorg_renderer *r) |
{ |
struct pipe_resource **vsbuf = &r->vs_const_buffer; |
struct pipe_resource **fsbuf = &r->fs_const_buffer; |
if (*vsbuf) |
pipe_resource_reference(vsbuf, NULL); |
if (*fsbuf) |
pipe_resource_reference(fsbuf, NULL); |
if (r->shaders) { |
xorg_shaders_destroy(r->shaders); |
r->shaders = NULL; |
} |
if (r->cso) { |
cso_release_all(r->cso); |
cso_destroy_context(r->cso); |
r->cso = NULL; |
} |
} |
void renderer_set_constants(struct xorg_renderer *r, |
int shader_type, |
const float *params, |
int param_bytes) |
{ |
struct pipe_resource **cbuf = |
(shader_type == PIPE_SHADER_VERTEX) ? &r->vs_const_buffer : |
&r->fs_const_buffer; |
pipe_resource_reference(cbuf, NULL); |
*cbuf = pipe_buffer_create(r->pipe->screen, |
PIPE_BIND_CONSTANT_BUFFER, |
PIPE_USAGE_STATIC, |
param_bytes); |
if (*cbuf) { |
pipe_buffer_write(r->pipe, *cbuf, |
0, param_bytes, params); |
} |
pipe_set_constant_buffer(r->pipe, shader_type, 0, *cbuf); |
} |
void renderer_draw_yuv(struct xorg_renderer *r, |
float src_x, float src_y, float src_w, float src_h, |
int dst_x, int dst_y, int dst_w, int dst_h, |
struct pipe_resource **textures) |
{ |
const int num_attribs = 2; /*pos + tex coord*/ |
setup_vertex_data_yuv(r, |
src_x, src_y, src_w, src_h, |
dst_x, dst_y, dst_w, dst_h, |
textures); |
cso_set_vertex_elements(r->cso, num_attribs, r->velems); |
util_draw_user_vertex_buffer(r->cso, r->buffer, |
PIPE_PRIM_QUADS, |
4, /* verts */ |
num_attribs); /* attribs/vert */ |
r->buffer_size = 0; |
} |
void renderer_begin_solid(struct xorg_renderer *r) |
{ |
r->buffer_size = 0; |
r->attrs_per_vertex = 2; |
} |
void renderer_solid(struct xorg_renderer *r, |
int x0, int y0, |
int x1, int y1, |
float *color) |
{ |
/* |
debug_printf("solid rect[(%d, %d), (%d, %d)], rgba[%f, %f, %f, %f]\n", |
x0, y0, x1, y1, color[0], color[1], color[2], color[3]);*/ |
renderer_draw_conditional(r, 4 * 8); |
/* 1st vertex */ |
add_vertex_color(r, x0, y0, color); |
/* 2nd vertex */ |
add_vertex_color(r, x1, y0, color); |
/* 3rd vertex */ |
add_vertex_color(r, x1, y1, color); |
/* 4th vertex */ |
add_vertex_color(r, x0, y1, color); |
} |
void renderer_draw_flush(struct xorg_renderer *r) |
{ |
renderer_draw_conditional(r, 0); |
} |
void renderer_begin_textures(struct xorg_renderer *r, |
int num_textures) |
{ |
r->attrs_per_vertex = 1 + num_textures; |
r->buffer_size = 0; |
} |
void renderer_texture(struct xorg_renderer *r, |
int *pos, |
int width, int height, |
struct pipe_sampler_view **sampler_view, |
int num_textures, |
float *src_matrix, |
float *mask_matrix) |
{ |
#if 0 |
if (src_matrix) { |
debug_printf("src_matrix = \n"); |
debug_printf("%f, %f, %f\n", src_matrix[0], src_matrix[1], src_matrix[2]); |
debug_printf("%f, %f, %f\n", src_matrix[3], src_matrix[4], src_matrix[5]); |
debug_printf("%f, %f, %f\n", src_matrix[6], src_matrix[7], src_matrix[8]); |
} |
if (mask_matrix) { |
debug_printf("mask_matrix = \n"); |
debug_printf("%f, %f, %f\n", mask_matrix[0], mask_matrix[1], mask_matrix[2]); |
debug_printf("%f, %f, %f\n", mask_matrix[3], mask_matrix[4], mask_matrix[5]); |
debug_printf("%f, %f, %f\n", mask_matrix[6], mask_matrix[7], mask_matrix[8]); |
} |
#endif |
switch(r->attrs_per_vertex) { |
case 2: |
renderer_draw_conditional(r, 4 * 8); |
add_vertex_data1(r, |
pos[0], pos[1], /* src */ |
pos[4], pos[5], /* dst */ |
width, height, |
sampler_view[0]->texture, src_matrix); |
break; |
case 3: |
renderer_draw_conditional(r, 4 * 12); |
add_vertex_data2(r, |
pos[0], pos[1], /* src */ |
pos[2], pos[3], /* mask */ |
pos[4], pos[5], /* dst */ |
width, height, |
sampler_view[0]->texture, sampler_view[1]->texture, |
src_matrix, mask_matrix); |
break; |
default: |
debug_assert(!"Unsupported number of textures"); |
break; |
} |
} |
/contrib/sdk/sources/Mesa/mesa-9.2.5/src/gallium/state_trackers/xorg/xorg_renderer.h |
---|
0,0 → 1,81 |
#ifndef XORG_RENDERER_H |
#define XORG_RENDERER_H |
#include "pipe/p_context.h" |
#include "pipe/p_state.h" |
struct xorg_shaders; |
struct exa_pixmap_priv; |
/* max number of vertices * |
* max number of attributes per vertex * |
* max number of components per attribute |
* |
* currently the max is 100 quads |
*/ |
#define BUF_SIZE (100 * 4 * 3 * 4) |
struct xorg_renderer { |
struct pipe_context *pipe; |
struct cso_context *cso; |
struct xorg_shaders *shaders; |
int fb_width; |
int fb_height; |
struct pipe_resource *vs_const_buffer; |
struct pipe_resource *fs_const_buffer; |
float buffer[BUF_SIZE]; |
int buffer_size; |
struct pipe_vertex_element velems[3]; |
/* number of attributes per vertex for the current |
* draw operation */ |
int attrs_per_vertex; |
}; |
struct xorg_renderer *renderer_create(struct pipe_context *pipe); |
void renderer_destroy(struct xorg_renderer *renderer); |
void renderer_bind_destination(struct xorg_renderer *r, |
struct pipe_surface *surface, |
int width, |
int height ); |
void renderer_bind_framebuffer(struct xorg_renderer *r, |
struct exa_pixmap_priv *priv); |
void renderer_bind_viewport(struct xorg_renderer *r, |
struct exa_pixmap_priv *dst); |
void renderer_set_constants(struct xorg_renderer *r, |
int shader_type, |
const float *buffer, |
int size); |
void renderer_draw_yuv(struct xorg_renderer *r, |
float src_x, float src_y, float src_w, float src_h, |
int dst_x, int dst_y, int dst_w, int dst_h, |
struct pipe_resource **textures); |
void renderer_begin_solid(struct xorg_renderer *r); |
void renderer_solid(struct xorg_renderer *r, |
int x0, int y0, |
int x1, int y1, |
float *color); |
void renderer_begin_textures(struct xorg_renderer *r, |
int num_textures); |
void renderer_texture(struct xorg_renderer *r, |
int *pos, |
int width, int height, |
struct pipe_sampler_view **textures, |
int num_textures, |
float *src_matrix, |
float *mask_matrix); |
void renderer_draw_flush(struct xorg_renderer *r); |
#endif |
/contrib/sdk/sources/Mesa/mesa-9.2.5/src/gallium/state_trackers/xorg/xorg_tracker.h |
---|
0,0 → 1,236 |
/* |
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. |
* All Rights Reserved. |
* |
* 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, sub license, 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 (including the |
* next paragraph) 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 NON-INFRINGEMENT. |
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. |
* |
* |
* Author: Alan Hourihane <alanh@tungstengraphics.com> |
* Author: Jakob Bornecrantz <wallbraker@gmail.com> |
* |
*/ |
#ifndef _XORG_TRACKER_H_ |
#define _XORG_TRACKER_H_ |
#include <stddef.h> |
#include <stdint.h> |
#include <errno.h> |
#include <drm.h> |
#include <xf86drm.h> |
#include <xf86drmMode.h> |
#include <xorg-server.h> |
#include <xf86.h> |
#include "xf86Crtc.h" |
#include <exa.h> |
#ifdef DRM_MODE_FEATURE_DIRTYFB |
#include <damage.h> |
#endif |
/* Prevent symbol clash */ |
#undef Absolute |
#include "compat-api.h" |
#include "pipe/p_screen.h" |
#include "util/u_inlines.h" |
#include "util/u_debug.h" |
#define DRV_ERROR(msg) xf86DrvMsg(pScrn->scrnIndex, X_ERROR, msg); |
struct kms_bo; |
struct kms_driver; |
struct exa_context; |
typedef struct |
{ |
int lastInstance; |
int refCount; |
ScrnInfoPtr pScrn_1; |
ScrnInfoPtr pScrn_2; |
} EntRec, *EntPtr; |
#define XORG_NR_FENCES 3 |
enum xorg_throttling_reason { |
THROTTLE_RENDER, |
THROTTLE_SWAP |
}; |
typedef struct _CustomizerRec |
{ |
Bool dirty_throttling; |
Bool swap_throttling; |
Bool no_3d; |
Bool unhidden_hw_cursor_update; |
Bool (*winsys_pre_init) (struct _CustomizerRec *cust, int fd); |
Bool (*winsys_screen_init)(struct _CustomizerRec *cust); |
Bool (*winsys_screen_close)(struct _CustomizerRec *cust); |
Bool (*winsys_enter_vt)(struct _CustomizerRec *cust); |
Bool (*winsys_leave_vt)(struct _CustomizerRec *cust); |
void (*winsys_context_throttle)(struct _CustomizerRec *cust, |
struct pipe_context *pipe, |
enum xorg_throttling_reason reason); |
Bool (*winsys_check_fb_size) (struct _CustomizerRec *cust, |
unsigned long pitch, |
unsigned long height); |
} CustomizerRec, *CustomizerPtr; |
typedef struct _modesettingRec |
{ |
/* drm */ |
int fd; |
unsigned fb_id; |
/* X */ |
EntPtr entityPrivate; |
int Chipset; |
EntityInfoPtr pEnt; |
struct pci_device *PciInfo; |
Bool noAccel; |
Bool SWCursor; |
CursorPtr cursor; |
Bool swapThrottling; |
Bool dirtyThrottling; |
CloseScreenProcPtr CloseScreen; |
Bool no3D; |
Bool from_3D; |
Bool isMaster; |
/* Broken-out options. */ |
OptionInfoPtr Options; |
void (*blockHandler)(BLOCKHANDLER_ARGS_DECL); |
struct pipe_fence_handle *fence[XORG_NR_FENCES]; |
CreateScreenResourcesProcPtr createScreenResources; |
/* for frontbuffer backing store */ |
Bool (*destroy_front_buffer)(ScrnInfoPtr pScrn); |
Bool (*create_front_buffer)(ScrnInfoPtr pScrn); |
Bool (*bind_front_buffer)(ScrnInfoPtr pScrn); |
/* kms */ |
struct kms_driver *kms; |
struct kms_bo *root_bo; |
uint16_t lut_r[256], lut_g[256], lut_b[256]; |
/* gallium */ |
struct pipe_screen *screen; |
struct pipe_context *ctx; |
boolean d_depth_bits_last; |
boolean ds_depth_bits_last; |
struct pipe_resource *root_texture; |
/* exa */ |
struct exa_context *exa; |
Bool noEvict; |
Bool accelerate_2d; |
Bool debug_fallback; |
CustomizerPtr cust; |
#ifdef DRM_MODE_FEATURE_DIRTYFB |
DamagePtr damage; |
#endif |
} modesettingRec, *modesettingPtr; |
#define modesettingPTR(p) ((modesettingPtr)((p)->driverPrivate)) |
CustomizerPtr xorg_customizer(ScrnInfoPtr pScrn); |
Bool xorg_has_gallium(ScrnInfoPtr pScrn); |
void xorg_flush(ScreenPtr pScreen); |
/*********************************************************************** |
* xorg_exa.c |
*/ |
struct pipe_resource * |
xorg_exa_get_texture(PixmapPtr pPixmap); |
int |
xorg_exa_set_displayed_usage(PixmapPtr pPixmap); |
int |
xorg_exa_set_shared_usage(PixmapPtr pPixmap); |
Bool |
xorg_exa_set_texture(PixmapPtr pPixmap, struct pipe_resource *tex); |
struct pipe_resource * |
xorg_exa_create_root_texture(ScrnInfoPtr pScrn, |
int width, int height, |
int depth, int bpp); |
void * |
xorg_exa_init(ScrnInfoPtr pScrn, Bool accel); |
void |
xorg_exa_close(ScrnInfoPtr pScrn); |
/*********************************************************************** |
* xorg_dri2.c |
*/ |
Bool |
xorg_dri2_init(ScreenPtr pScreen); |
void |
xorg_dri2_close(ScreenPtr pScreen); |
/*********************************************************************** |
* xorg_crtc.c |
*/ |
void |
xorg_crtc_init(ScrnInfoPtr pScrn); |
void |
xorg_crtc_cursor_destroy(xf86CrtcPtr crtc); |
/*********************************************************************** |
* xorg_output.c |
*/ |
void |
xorg_output_init(ScrnInfoPtr pScrn); |
unsigned |
xorg_output_get_id(xf86OutputPtr output); |
/*********************************************************************** |
* xorg_xv.c |
*/ |
void |
xorg_xv_init(ScreenPtr pScreen); |
/*********************************************************************** |
* xorg_xvmc.c |
*/ |
void |
xorg_xvmc_init(ScreenPtr pScreen, char *name); |
#endif /* _XORG_TRACKER_H_ */ |
/contrib/sdk/sources/Mesa/mesa-9.2.5/src/gallium/state_trackers/xorg/xorg_winsys.h |
---|
0,0 → 1,50 |
/* |
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. |
* All Rights Reserved. |
* |
* 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, sub license, 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 (including the |
* next paragraph) 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 NON-INFRINGEMENT. |
* IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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. |
* |
* |
* Author: Alan Hourihane <alanh@tungstengraphics.com> |
* Author: Jakob Bornecrantz <wallbraker@gmail.com> |
* |
*/ |
/* |
* File with all the junk needed to personalize the a xorg driver. |
*/ |
#ifndef _XORG_WINSYS_H_ |
#define _XORG_WINSYS_H_ |
#include "xorg-server.h" |
#include "xf86.h" |
#include "pciaccess.h" |
#ifndef XSERVER_LIBPCIACCESS |
#error "libpciaccess needed" |
#endif |
void xorg_tracker_set_functions(ScrnInfoPtr scrn); |
const OptionInfoRec * xorg_tracker_available_options(int chipid, int busid); |
Bool xorg_tracker_have_modesetting(ScrnInfoPtr pScrn, struct pci_device *device); |
#endif |
/contrib/sdk/sources/Mesa/mesa-9.2.5/src/gallium/state_trackers/xorg/xorg_xv.c |
---|
0,0 → 1,754 |
#include "xorg_tracker.h" |
#include <xf86xv.h> |
#include <X11/extensions/Xv.h> |
#include <fourcc.h> |
#include "xorg_exa.h" |
#include "xorg_renderer.h" |
#include "xorg_exa_tgsi.h" |
#include "cso_cache/cso_context.h" |
#include "util/u_sampler.h" |
#include "pipe/p_screen.h" |
/*XXX get these from pipe's texture limits */ |
#define IMAGE_MAX_WIDTH 2048 |
#define IMAGE_MAX_HEIGHT 2048 |
#define RES_720P_X 1280 |
#define RES_720P_Y 720 |
/* The ITU-R BT.601 conversion matrix for SDTV. */ |
/* original, matrix, but we transpose it to |
* make the shader easier |
static const float bt_601[] = { |
1.0, 0.0, 1.4075, , |
1.0, -0.3455, -0.7169, 0, |
1.0, 1.7790, 0., 0, |
};*/ |
static const float bt_601[] = { |
1.0, 1.0, 1.0, 0.5, |
0.0, -0.3455, 1.7790, 0, |
1.4075, -0.7169, 0., 0, |
}; |
/* The ITU-R BT.709 conversion matrix for HDTV. */ |
/* original, but we transpose to make the conversion |
* in the shader easier |
static const float bt_709[] = { |
1.0, 0.0, 1.581, 0, |
1.0, -0.1881, -0.47, 0, |
1.0, 1.8629, 0., 0, |
};*/ |
static const float bt_709[] = { |
1.0, 1.0, 1.0, 0.5, |
0.0, -0.1881, 1.8629, 0, |
1.581,-0.47 , 0.0, 0, |
}; |
#define MAKE_ATOM(a) MakeAtom(a, sizeof(a) - 1, TRUE) |
static Atom xvBrightness, xvContrast; |
#define NUM_TEXTURED_ATTRIBUTES 2 |
static XF86AttributeRec TexturedAttributes[NUM_TEXTURED_ATTRIBUTES] = { |
{XvSettable | XvGettable, -128, 127, "XV_BRIGHTNESS"}, |
{XvSettable | XvGettable, 0, 255, "XV_CONTRAST"} |
}; |
#define NUM_FORMATS 3 |
static XF86VideoFormatRec Formats[NUM_FORMATS] = { |
{15, TrueColor}, {16, TrueColor}, {24, TrueColor} |
}; |
static XF86VideoEncodingRec DummyEncoding[1] = { |
{ |
0, |
"XV_IMAGE", |
IMAGE_MAX_WIDTH, IMAGE_MAX_HEIGHT, |
{1, 1} |
} |
}; |
#define NUM_IMAGES 3 |
static XF86ImageRec Images[NUM_IMAGES] = { |
XVIMAGE_UYVY, |
XVIMAGE_YUY2, |
XVIMAGE_YV12, |
}; |
struct xorg_xv_port_priv { |
struct xorg_renderer *r; |
RegionRec clip; |
int brightness; |
int contrast; |
int current_set; |
/* juggle two sets of seperate Y, U and V |
* textures */ |
struct pipe_resource *yuv[2][3]; |
struct pipe_sampler_view *yuv_views[2][3]; |
}; |
static void |
stop_video(ScrnInfoPtr pScrn, pointer data, Bool shutdown) |
{ |
struct xorg_xv_port_priv *priv = (struct xorg_xv_port_priv *)data; |
REGION_EMPTY(pScrn->pScreen, &priv->clip); |
} |
static int |
set_port_attribute(ScrnInfoPtr pScrn, |
Atom attribute, INT32 value, pointer data) |
{ |
struct xorg_xv_port_priv *priv = (struct xorg_xv_port_priv *)data; |
if (attribute == xvBrightness) { |
if ((value < -128) || (value > 127)) |
return BadValue; |
priv->brightness = value; |
} else if (attribute == xvContrast) { |
if ((value < 0) || (value > 255)) |
return BadValue; |
priv->contrast = value; |
} else |
return BadMatch; |
return Success; |
} |
static int |
get_port_attribute(ScrnInfoPtr pScrn, |
Atom attribute, INT32 * value, pointer data) |
{ |
struct xorg_xv_port_priv *priv = (struct xorg_xv_port_priv *)data; |
if (attribute == xvBrightness) |
*value = priv->brightness; |
else if (attribute == xvContrast) |
*value = priv->contrast; |
else |
return BadMatch; |
return Success; |
} |
static void |
query_best_size(ScrnInfoPtr pScrn, |
Bool motion, |
short vid_w, short vid_h, |
short drw_w, short drw_h, |
unsigned int *p_w, unsigned int *p_h, pointer data) |
{ |
if (vid_w > (drw_w << 1)) |
drw_w = vid_w >> 1; |
if (vid_h > (drw_h << 1)) |
drw_h = vid_h >> 1; |
*p_w = drw_w; |
*p_h = drw_h; |
} |
static INLINE struct pipe_resource * |
create_component_texture(struct pipe_context *pipe, |
int width, int height) |
{ |
struct pipe_screen *screen = pipe->screen; |
struct pipe_resource *tex = 0; |
struct pipe_resource templ; |
memset(&templ, 0, sizeof(templ)); |
templ.target = PIPE_TEXTURE_2D; |
templ.format = PIPE_FORMAT_L8_UNORM; |
templ.last_level = 0; |
templ.width0 = width; |
templ.height0 = height; |
templ.depth0 = 1; |
templ.array_size = 1; |
templ.bind = PIPE_BIND_SAMPLER_VIEW; |
tex = screen->resource_create(screen, &templ); |
return tex; |
} |
static int |
check_yuv_textures(struct xorg_xv_port_priv *priv, int width, int height) |
{ |
struct pipe_resource **dst = priv->yuv[priv->current_set]; |
struct pipe_sampler_view **dst_view = priv->yuv_views[priv->current_set]; |
struct pipe_sampler_view view_templ; |
struct pipe_context *pipe = priv->r->pipe; |
if (!dst[0] || |
dst[0]->width0 != width || |
dst[0]->height0 != height) { |
pipe_resource_reference(&dst[0], NULL); |
pipe_sampler_view_reference(&dst_view[0], NULL); |
} |
if (!dst[1] || |
dst[1]->width0 != width || |
dst[1]->height0 != height) { |
pipe_resource_reference(&dst[1], NULL); |
pipe_sampler_view_reference(&dst_view[1], NULL); |
} |
if (!dst[2] || |
dst[2]->width0 != width || |
dst[2]->height0 != height) { |
pipe_resource_reference(&dst[2], NULL); |
pipe_sampler_view_reference(&dst_view[2], NULL); |
} |
if (!dst[0]) { |
dst[0] = create_component_texture(priv->r->pipe, width, height); |
if (dst[0]) { |
u_sampler_view_default_template(&view_templ, |
dst[0], |
dst[0]->format); |
dst_view[0] = pipe->create_sampler_view(pipe, dst[0], &view_templ); |
} |
} |
if (!dst[1]) { |
dst[1] = create_component_texture(priv->r->pipe, width, height); |
if (dst[1]) { |
u_sampler_view_default_template(&view_templ, |
dst[1], |
dst[1]->format); |
dst_view[1] = pipe->create_sampler_view(pipe, dst[1], &view_templ); |
} |
} |
if (!dst[2]) { |
dst[2] = create_component_texture(priv->r->pipe, width, height); |
if (dst[2]) { |
u_sampler_view_default_template(&view_templ, |
dst[2], |
dst[2]->format); |
dst_view[2] = pipe->create_sampler_view(pipe, dst[2], &view_templ); |
} |
} |
if (!dst[0] || !dst[1] || !dst[2] || !dst_view[0] || !dst_view[1] || !dst_view[2] ) |
return BadAlloc; |
return Success; |
} |
static int |
query_image_attributes(ScrnInfoPtr pScrn, |
int id, |
unsigned short *w, unsigned short *h, |
int *pitches, int *offsets) |
{ |
int size, tmp; |
if (*w > IMAGE_MAX_WIDTH) |
*w = IMAGE_MAX_WIDTH; |
if (*h > IMAGE_MAX_HEIGHT) |
*h = IMAGE_MAX_HEIGHT; |
*w = (*w + 1) & ~1; |
if (offsets) |
offsets[0] = 0; |
switch (id) { |
case FOURCC_YV12: |
*h = (*h + 1) & ~1; |
size = (*w + 3) & ~3; |
if (pitches) { |
pitches[0] = size; |
} |
size *= *h; |
if (offsets) { |
offsets[1] = size; |
} |
tmp = ((*w >> 1) + 3) & ~3; |
if (pitches) { |
pitches[1] = pitches[2] = tmp; |
} |
tmp *= (*h >> 1); |
size += tmp; |
if (offsets) { |
offsets[2] = size; |
} |
size += tmp; |
break; |
case FOURCC_UYVY: |
case FOURCC_YUY2: |
default: |
size = *w << 1; |
if (pitches) |
pitches[0] = size; |
size *= *h; |
break; |
} |
return size; |
} |
static void |
copy_packed_data(ScrnInfoPtr pScrn, |
struct xorg_xv_port_priv *port, |
int id, |
unsigned char *buf, |
int left, |
int top, |
unsigned short w, unsigned short h) |
{ |
int i, j; |
struct pipe_resource **dst = port->yuv[port->current_set]; |
struct pipe_transfer *ytrans, *utrans, *vtrans; |
struct pipe_context *pipe = port->r->pipe; |
char *ymap, *vmap, *umap; |
unsigned char y1, y2, u, v; |
int yidx, uidx, vidx; |
int y_array_size = w * h; |
ymap = pipe_transfer_map(pipe, dst[0], |
0, 0, |
PIPE_TRANSFER_WRITE, |
left, top, w, h, &ytrans); |
umap = pipe_transfer_map(pipe, dst[1], |
0, 0, |
PIPE_TRANSFER_WRITE, |
left, top, w, h, &utrans); |
vmap = pipe_transfer_map(pipe, dst[2], |
0, 0, |
PIPE_TRANSFER_WRITE, |
left, top, w, h, &vtrans); |
yidx = uidx = vidx = 0; |
switch (id) { |
case FOURCC_YV12: { |
int pitches[3], offsets[3]; |
unsigned char *y, *u, *v; |
query_image_attributes(pScrn, FOURCC_YV12, |
&w, &h, pitches, offsets); |
y = buf + offsets[0]; |
v = buf + offsets[1]; |
u = buf + offsets[2]; |
for (i = 0; i < h; ++i) { |
for (j = 0; j < w; ++j) { |
int yoffset = (w*i+j); |
int ii = (i|1), jj = (j|1); |
int vuoffset = (w/2)*(ii/2) + (jj/2); |
ymap[yidx++] = y[yoffset]; |
umap[uidx++] = u[vuoffset]; |
vmap[vidx++] = v[vuoffset]; |
} |
} |
} |
break; |
case FOURCC_UYVY: |
for (i = 0; i < y_array_size; i +=2 ) { |
/* extracting two pixels */ |
u = buf[0]; |
y1 = buf[1]; |
v = buf[2]; |
y2 = buf[3]; |
buf += 4; |
ymap[yidx++] = y1; |
ymap[yidx++] = y2; |
umap[uidx++] = u; |
umap[uidx++] = u; |
vmap[vidx++] = v; |
vmap[vidx++] = v; |
} |
break; |
case FOURCC_YUY2: |
for (i = 0; i < y_array_size; i +=2 ) { |
/* extracting two pixels */ |
y1 = buf[0]; |
u = buf[1]; |
y2 = buf[2]; |
v = buf[3]; |
buf += 4; |
ymap[yidx++] = y1; |
ymap[yidx++] = y2; |
umap[uidx++] = u; |
umap[uidx++] = u; |
vmap[vidx++] = v; |
vmap[vidx++] = v; |
} |
break; |
default: |
debug_assert(!"Unsupported yuv format!"); |
break; |
} |
pipe->transfer_unmap(pipe, ytrans); |
pipe->transfer_unmap(pipe, utrans); |
pipe->transfer_unmap(pipe, vtrans); |
} |
static void |
setup_fs_video_constants(struct xorg_renderer *r, boolean hdtv) |
{ |
const int param_bytes = 12 * sizeof(float); |
const float *video_constants = (hdtv) ? bt_709 : bt_601; |
renderer_set_constants(r, PIPE_SHADER_FRAGMENT, |
video_constants, param_bytes); |
} |
static void |
draw_yuv(struct xorg_xv_port_priv *port, |
float src_x, float src_y, float src_w, float src_h, |
int dst_x, int dst_y, int dst_w, int dst_h) |
{ |
struct pipe_resource **textures = port->yuv[port->current_set]; |
/*debug_printf(" draw_yuv([%d, %d, %d ,%d], [%d, %d, %d, %d])\n", |
src_x, src_y, src_w, src_h, |
dst_x, dst_y, dst_w, dst_h);*/ |
renderer_draw_yuv(port->r, |
src_x, src_y, src_w, src_h, |
dst_x, dst_y, dst_w, dst_h, |
textures); |
} |
static void |
bind_blend_state(struct xorg_xv_port_priv *port) |
{ |
struct pipe_blend_state blend; |
memset(&blend, 0, sizeof(struct pipe_blend_state)); |
blend.rt[0].blend_enable = 0; |
blend.rt[0].colormask = PIPE_MASK_RGBA; |
/* porter&duff src */ |
blend.rt[0].rgb_src_factor = PIPE_BLENDFACTOR_ONE; |
blend.rt[0].alpha_src_factor = PIPE_BLENDFACTOR_ONE; |
blend.rt[0].rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; |
blend.rt[0].alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; |
cso_set_blend(port->r->cso, &blend); |
} |
static void |
bind_shaders(struct xorg_xv_port_priv *port) |
{ |
unsigned vs_traits = 0, fs_traits = 0; |
struct xorg_shader shader; |
vs_traits |= VS_YUV; |
fs_traits |= FS_YUV; |
shader = xorg_shaders_get(port->r->shaders, vs_traits, fs_traits); |
cso_set_vertex_shader_handle(port->r->cso, shader.vs); |
cso_set_fragment_shader_handle(port->r->cso, shader.fs); |
} |
static void |
bind_samplers(struct xorg_xv_port_priv *port) |
{ |
struct pipe_sampler_state *samplers[PIPE_MAX_SAMPLERS]; |
struct pipe_sampler_state sampler; |
struct pipe_sampler_view **dst_views = port->yuv_views[port->current_set]; |
memset(&sampler, 0, sizeof(struct pipe_sampler_state)); |
sampler.wrap_s = PIPE_TEX_WRAP_CLAMP; |
sampler.wrap_t = PIPE_TEX_WRAP_CLAMP; |
sampler.min_img_filter = PIPE_TEX_FILTER_LINEAR; |
sampler.mag_img_filter = PIPE_TEX_FILTER_LINEAR; |
sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NEAREST; |
sampler.normalized_coords = 1; |
samplers[0] = &sampler; |
samplers[1] = &sampler; |
samplers[2] = &sampler; |
cso_set_samplers(port->r->cso, PIPE_SHADER_FRAGMENT, 3, |
(const struct pipe_sampler_state **)samplers); |
cso_set_sampler_views(port->r->cso, PIPE_SHADER_FRAGMENT, 3, dst_views); |
} |
static int |
display_video(ScrnInfoPtr pScrn, struct xorg_xv_port_priv *pPriv, int id, |
RegionPtr dstRegion, |
int src_x, int src_y, int src_w, int src_h, |
int dstX, int dstY, int dst_w, int dst_h, |
PixmapPtr pPixmap) |
{ |
modesettingPtr ms = modesettingPTR(pScrn); |
BoxPtr pbox; |
int nbox; |
int dxo, dyo; |
Bool hdtv; |
int x, y, w, h; |
struct exa_pixmap_priv *dst; |
struct pipe_surface *dst_surf = NULL; |
exaMoveInPixmap(pPixmap); |
dst = exaGetPixmapDriverPrivate(pPixmap); |
/*debug_printf("display_video([%d, %d, %d, %d], [%d, %d, %d, %d])\n", |
src_x, src_y, src_w, src_h, dstX, dstY, dst_w, dst_h);*/ |
if (dst && !dst->tex) { |
xorg_exa_set_shared_usage(pPixmap); |
pScrn->pScreen->ModifyPixmapHeader(pPixmap, 0, 0, 0, 0, 0, NULL); |
} |
if (!dst || !dst->tex) |
XORG_FALLBACK("Xv destination %s", !dst ? "!dst" : "!dst->tex"); |
dst_surf = xorg_gpu_surface(pPriv->r->pipe, dst); |
hdtv = ((src_w >= RES_720P_X) && (src_h >= RES_720P_Y)); |
#ifdef COMPOSITE |
REGION_TRANSLATE(pScrn->pScreen, dstRegion, -pPixmap->screen_x, |
-pPixmap->screen_y); |
#endif |
dxo = dstRegion->extents.x1; |
dyo = dstRegion->extents.y1; |
pbox = REGION_RECTS(dstRegion); |
nbox = REGION_NUM_RECTS(dstRegion); |
renderer_bind_destination(pPriv->r, dst_surf, |
dst_surf->width, dst_surf->height); |
bind_blend_state(pPriv); |
bind_shaders(pPriv); |
bind_samplers(pPriv); |
setup_fs_video_constants(pPriv->r, hdtv); |
DamageDamageRegion(&pPixmap->drawable, dstRegion); |
while (nbox--) { |
int box_x1 = pbox->x1; |
int box_y1 = pbox->y1; |
int box_x2 = pbox->x2; |
int box_y2 = pbox->y2; |
float diff_x = (float)src_w / (float)dst_w; |
float diff_y = (float)src_h / (float)dst_h; |
float offset_x = box_x1 - dstX; |
float offset_y = box_y1 - dstY; |
float offset_w; |
float offset_h; |
#ifdef COMPOSITE |
offset_x += pPixmap->screen_x; |
offset_y += pPixmap->screen_y; |
#endif |
x = box_x1; |
y = box_y1; |
w = box_x2 - box_x1; |
h = box_y2 - box_y1; |
offset_w = dst_w - w; |
offset_h = dst_h - h; |
draw_yuv(pPriv, |
(float) src_x + offset_x*diff_x, (float) src_y + offset_y*diff_y, |
(float) src_w - offset_w*diff_x, (float) src_h - offset_h*diff_y, |
x, y, w, h); |
pbox++; |
} |
DamageRegionProcessPending(&pPixmap->drawable); |
pipe_surface_reference(&dst_surf, NULL); |
return TRUE; |
} |
static int |
put_image(ScrnInfoPtr pScrn, |
short src_x, short src_y, |
short drw_x, short drw_y, |
short src_w, short src_h, |
short drw_w, short drw_h, |
int id, unsigned char *buf, |
short width, short height, |
Bool sync, RegionPtr clipBoxes, pointer data, |
DrawablePtr pDraw) |
{ |
struct xorg_xv_port_priv *pPriv = (struct xorg_xv_port_priv *) data; |
ScreenPtr pScreen = xf86ScrnToScreen(pScrn); |
PixmapPtr pPixmap; |
INT32 x1, x2, y1, y2; |
BoxRec dstBox; |
int ret; |
/* Clip */ |
x1 = src_x; |
x2 = src_x + src_w; |
y1 = src_y; |
y2 = src_y + src_h; |
dstBox.x1 = drw_x; |
dstBox.x2 = drw_x + drw_w; |
dstBox.y1 = drw_y; |
dstBox.y2 = drw_y + drw_h; |
if (!xf86XVClipVideoHelper(&dstBox, &x1, &x2, &y1, &y2, clipBoxes, |
width, height)) |
return Success; |
ret = check_yuv_textures(pPriv, width, height); |
if (ret) |
return ret; |
copy_packed_data(pScrn, pPriv, id, buf, |
src_x, src_y, width, height); |
if (pDraw->type == DRAWABLE_WINDOW) { |
pPixmap = (*pScreen->GetWindowPixmap)((WindowPtr)pDraw); |
} else { |
pPixmap = (PixmapPtr)pDraw; |
} |
display_video(pScrn, pPriv, id, clipBoxes, |
src_x, src_y, src_w, src_h, |
drw_x, drw_y, |
drw_w, drw_h, pPixmap); |
pPriv->current_set = (pPriv->current_set + 1) & 1; |
return Success; |
} |
static struct xorg_xv_port_priv * |
port_priv_create(struct xorg_renderer *r) |
{ |
struct xorg_xv_port_priv *priv = NULL; |
priv = calloc(1, sizeof(struct xorg_xv_port_priv)); |
if (!priv) |
return NULL; |
priv->r = r; |
REGION_NULL(pScreen, &priv->clip); |
debug_assert(priv && priv->r); |
return priv; |
} |
static XF86VideoAdaptorPtr |
xorg_setup_textured_adapter(ScreenPtr pScreen) |
{ |
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); |
modesettingPtr ms = modesettingPTR(pScrn); |
XF86VideoAdaptorPtr adapt; |
XF86AttributePtr attrs; |
DevUnion *dev_unions; |
int nports = 16, i; |
int nattributes; |
nattributes = NUM_TEXTURED_ATTRIBUTES; |
debug_assert(ms->exa); |
debug_assert(ms->exa->renderer); |
adapt = calloc(1, sizeof(XF86VideoAdaptorRec)); |
dev_unions = calloc(nports, sizeof(DevUnion)); |
attrs = calloc(nattributes, sizeof(XF86AttributeRec)); |
if (adapt == NULL || dev_unions == NULL || attrs == NULL) { |
free(adapt); |
free(dev_unions); |
free(attrs); |
return NULL; |
} |
adapt->type = XvWindowMask | XvInputMask | XvImageMask; |
adapt->flags = 0; |
adapt->name = "Gallium3D Textured Video"; |
adapt->nEncodings = 1; |
adapt->pEncodings = DummyEncoding; |
adapt->nFormats = NUM_FORMATS; |
adapt->pFormats = Formats; |
adapt->nPorts = 0; |
adapt->pPortPrivates = dev_unions; |
adapt->nAttributes = nattributes; |
adapt->pAttributes = attrs; |
memcpy(attrs, TexturedAttributes, nattributes * sizeof(XF86AttributeRec)); |
adapt->nImages = NUM_IMAGES; |
adapt->pImages = Images; |
adapt->PutVideo = NULL; |
adapt->PutStill = NULL; |
adapt->GetVideo = NULL; |
adapt->GetStill = NULL; |
adapt->StopVideo = stop_video; |
adapt->SetPortAttribute = set_port_attribute; |
adapt->GetPortAttribute = get_port_attribute; |
adapt->QueryBestSize = query_best_size; |
adapt->PutImage = put_image; |
adapt->QueryImageAttributes = query_image_attributes; |
for (i = 0; i < nports; i++) { |
struct xorg_xv_port_priv *priv = |
port_priv_create(ms->exa->renderer); |
adapt->pPortPrivates[i].ptr = (pointer) (priv); |
adapt->nPorts++; |
} |
return adapt; |
} |
void |
xorg_xv_init(ScreenPtr pScreen) |
{ |
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); |
/*modesettingPtr ms = modesettingPTR(pScrn);*/ |
XF86VideoAdaptorPtr *adaptors, *new_adaptors = NULL; |
XF86VideoAdaptorPtr textured_adapter; |
int num_adaptors; |
num_adaptors = xf86XVListGenericAdaptors(pScrn, &adaptors); |
new_adaptors = malloc((num_adaptors + 1) * sizeof(XF86VideoAdaptorPtr *)); |
if (new_adaptors == NULL) |
return; |
memcpy(new_adaptors, adaptors, num_adaptors * sizeof(XF86VideoAdaptorPtr)); |
adaptors = new_adaptors; |
/* Add the adaptors supported by our hardware. First, set up the atoms |
* that will be used by both output adaptors. |
*/ |
xvBrightness = MAKE_ATOM("XV_BRIGHTNESS"); |
xvContrast = MAKE_ATOM("XV_CONTRAST"); |
textured_adapter = xorg_setup_textured_adapter(pScreen); |
debug_assert(textured_adapter); |
if (textured_adapter) { |
adaptors[num_adaptors++] = textured_adapter; |
} |
if (num_adaptors) { |
xf86XVScreenInit(pScreen, adaptors, num_adaptors); |
if (textured_adapter) |
xorg_xvmc_init(pScreen, textured_adapter->name); |
} else { |
xf86DrvMsg(pScrn->scrnIndex, X_WARNING, |
"Disabling Xv because no adaptors could be initialized.\n"); |
} |
free(adaptors); |
} |
/contrib/sdk/sources/Mesa/mesa-9.2.5/src/gallium/state_trackers/xorg/xorg_xvmc.c |
---|
0,0 → 1,119 |
#include "xorg_tracker.h" |
#include <xf86.h> |
#include <xf86xv.h> |
#include <xf86xvmc.h> |
#include <X11/extensions/Xv.h> |
#include <X11/extensions/XvMC.h> |
#include <fourcc.h> |
#define FOURCC_RGB 0x0000003 |
#define XVIMAGE_RGB \ |
{ \ |
FOURCC_RGB, \ |
XvRGB, \ |
LSBFirst, \ |
{ \ |
'R', 'G', 'B', 0x00, \ |
0x00,0x00,0x00,0x10,0x80,0x00,0x00,0xAA,0x00,0x38,0x9B,0x71 \ |
}, \ |
32, \ |
XvPacked, \ |
1, \ |
24, 0x00FF0000, 0x0000FF00, 0x000000FF, \ |
0, 0, 0, \ |
0, 0, 0, \ |
0, 0, 0, \ |
{ \ |
'B','G','R','X', \ |
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 \ |
}, \ |
XvTopToBottom \ |
} |
static int subpicture_index_list[] = { |
FOURCC_RGB, |
FOURCC_IA44, |
FOURCC_AI44 |
}; |
static XF86MCImageIDList subpicture_list = |
{ |
sizeof(subpicture_index_list)/sizeof(*subpicture_index_list), |
subpicture_index_list |
}; |
static XF86MCSurfaceInfoRec yv12_mpeg2_surface = |
{ |
FOURCC_I420, |
XVMC_CHROMA_FORMAT_420, |
0, |
2048, 2048, 2048, 2048, |
XVMC_IDCT | XVMC_MPEG_2, |
XVMC_SUBPICTURE_INDEPENDENT_SCALING | XVMC_BACKEND_SUBPICTURE, |
&subpicture_list |
}; |
static const XF86MCSurfaceInfoRec uyvy_mpeg2_surface = |
{ |
FOURCC_UYVY, |
XVMC_CHROMA_FORMAT_422, |
0, |
2048, 2048, 2048, 2048, |
XVMC_IDCT | XVMC_MPEG_2, |
XVMC_SUBPICTURE_INDEPENDENT_SCALING | XVMC_BACKEND_SUBPICTURE, |
&subpicture_list |
}; |
static XF86MCSurfaceInfoPtr surfaces[] = |
{ |
(XF86MCSurfaceInfoPtr)&yv12_mpeg2_surface, |
(XF86MCSurfaceInfoPtr)&uyvy_mpeg2_surface |
}; |
static const XF86ImageRec rgb_subpicture = XVIMAGE_RGB; |
static const XF86ImageRec ia44_subpicture = XVIMAGE_IA44; |
static const XF86ImageRec ai44_subpicture = XVIMAGE_AI44; |
static XF86ImagePtr subpictures[] = |
{ |
(XF86ImagePtr)&rgb_subpicture, |
(XF86ImagePtr)&ia44_subpicture, |
(XF86ImagePtr)&ai44_subpicture |
}; |
static const XF86MCAdaptorRec adaptor_template = |
{ |
"", |
sizeof(surfaces)/sizeof(*surfaces), |
surfaces, |
sizeof(subpictures)/sizeof(*subpictures), |
subpictures, |
(xf86XvMCCreateContextProcPtr)NULL, |
(xf86XvMCDestroyContextProcPtr)NULL, |
(xf86XvMCCreateSurfaceProcPtr)NULL, |
(xf86XvMCDestroySurfaceProcPtr)NULL, |
(xf86XvMCCreateSubpictureProcPtr)NULL, |
(xf86XvMCDestroySubpictureProcPtr)NULL |
}; |
void |
xorg_xvmc_init(ScreenPtr pScreen, char *name) |
{ |
ScrnInfoPtr pScrn = xf86ScreenToScrn(pScreen); |
XF86MCAdaptorPtr adaptorXvMC = xf86XvMCCreateAdaptorRec(); |
if (!adaptorXvMC) |
return; |
*adaptorXvMC = adaptor_template; |
adaptorXvMC->name = name; |
xf86DrvMsg(pScrn->scrnIndex, X_INFO, |
"[XvMC] Associated with %s.\n", name); |
if (!xf86XvMCScreenInit(pScreen, 1, &adaptorXvMC)) |
xf86DrvMsg(pScrn->scrnIndex, X_ERROR, |
"[XvMC] Failed to initialize extension.\n"); |
else |
xf86DrvMsg(pScrn->scrnIndex, X_INFO, |
"[XvMC] Extension initialized.\n"); |
xf86XvMCDestroyAdaptorRec(adaptorXvMC); |
} |