mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-05-08 05:38:02 +02:00
Remove cairo-drm
The DRM backend has always been a science experiment, but now it hasn't been built in more than 10 years, and it's completely broken.
This commit is contained in:
parent
64db153c43
commit
1409079eef
51 changed files with 1 additions and 27194 deletions
|
|
@ -72,7 +72,6 @@ fedora image:
|
|||
glib2-devel
|
||||
librsvg2-devel
|
||||
gtk2-devel
|
||||
libdrm-devel
|
||||
poppler-glib-devel
|
||||
pixman-devel
|
||||
cogl-devel
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ cairo_boilerplate_private = \
|
|||
$(NULL)
|
||||
|
||||
cairo_boilerplate_directfb_sources = cairo-boilerplate-directfb.c
|
||||
cairo_boilerplate_drm_sources = cairo-boilerplate-drm.c
|
||||
cairo_boilerplate_glx_sources = cairo-boilerplate-glx.c
|
||||
cairo_boilerplate_wgl_sources = cairo-boilerplate-wgl.c
|
||||
cairo_boilerplate_egl_sources = cairo-boilerplate-egl.c
|
||||
|
|
|
|||
|
|
@ -117,26 +117,6 @@ enabled_cairo_boilerplate_private += $(cairo_boilerplate_win32_font_private)
|
|||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_win32_font_sources)
|
||||
endif
|
||||
|
||||
unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_drm_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_drm_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_drm_private)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_drm_sources)
|
||||
ifeq ($(CAIRO_HAS_DRM_SURFACE),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_drm_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_drm_private)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_drm_sources)
|
||||
endif
|
||||
|
||||
unsupported_cairo_boilerplate_headers += $(cairo_boilerplate_gallium_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_gallium_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_gallium_private)
|
||||
all_cairo_boilerplate_sources += $(cairo_boilerplate_gallium_sources)
|
||||
ifeq ($(CAIRO_HAS_GALLIUM_SURFACE),1)
|
||||
enabled_cairo_boilerplate_headers += $(cairo_boilerplate_gallium_headers)
|
||||
enabled_cairo_boilerplate_private += $(cairo_boilerplate_gallium_private)
|
||||
enabled_cairo_boilerplate_sources += $(cairo_boilerplate_gallium_sources)
|
||||
endif
|
||||
|
||||
supported_cairo_boilerplate_headers += $(cairo_boilerplate_png_headers)
|
||||
all_cairo_boilerplate_headers += $(cairo_boilerplate_png_headers)
|
||||
all_cairo_boilerplate_private += $(cairo_boilerplate_png_private)
|
||||
|
|
|
|||
|
|
@ -1,112 +0,0 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Chris Wilson.
|
||||
*/
|
||||
|
||||
#include "cairo-boilerplate-private.h"
|
||||
|
||||
#include <cairo-drm.h>
|
||||
|
||||
static cairo_surface_t *
|
||||
_cairo_boilerplate_drm_create_surface (const char *name,
|
||||
cairo_content_t content,
|
||||
double width,
|
||||
double height,
|
||||
double max_width,
|
||||
double max_height,
|
||||
cairo_boilerplate_mode_t mode,
|
||||
void **closure)
|
||||
{
|
||||
cairo_device_t *device;
|
||||
cairo_format_t format;
|
||||
|
||||
device = cairo_drm_device_default ();
|
||||
if (device == NULL)
|
||||
return NULL; /* skip tests if no supported h/w found */
|
||||
|
||||
switch (content) {
|
||||
case CAIRO_CONTENT_ALPHA:
|
||||
format = CAIRO_FORMAT_A8;
|
||||
break;
|
||||
case CAIRO_CONTENT_COLOR:
|
||||
format = CAIRO_FORMAT_RGB24;
|
||||
break;
|
||||
case CAIRO_CONTENT_COLOR_ALPHA:
|
||||
default:
|
||||
format = CAIRO_FORMAT_ARGB32;
|
||||
break;
|
||||
}
|
||||
|
||||
return *closure = cairo_drm_surface_create (device, format, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
_cairo_boilerplate_drm_synchronize (void *closure)
|
||||
{
|
||||
cairo_surface_t *image;
|
||||
|
||||
image = cairo_drm_surface_map_to_image (closure);
|
||||
if (cairo_surface_status (image) == CAIRO_STATUS_SUCCESS)
|
||||
cairo_drm_surface_unmap (closure, image);
|
||||
}
|
||||
|
||||
static const cairo_boilerplate_target_t targets[] = {
|
||||
/* Acceleration architectures may make the results differ by a
|
||||
* bit, so we set the error tolerance to 1. */
|
||||
{
|
||||
"drm", "drm", NULL, NULL,
|
||||
CAIRO_SURFACE_TYPE_DRM, CAIRO_CONTENT_COLOR_ALPHA, 1,
|
||||
"cairo_drm_surface_create",
|
||||
_cairo_boilerplate_drm_create_surface,
|
||||
cairo_surface_create_similar,
|
||||
NULL, NULL,
|
||||
_cairo_boilerplate_get_image_surface,
|
||||
cairo_surface_write_to_png,
|
||||
NULL,
|
||||
_cairo_boilerplate_drm_synchronize,
|
||||
NULL,
|
||||
TRUE, FALSE, FALSE
|
||||
},
|
||||
{
|
||||
"drm", "drm", NULL, NULL,
|
||||
CAIRO_SURFACE_TYPE_DRM, CAIRO_CONTENT_COLOR, 1,
|
||||
"cairo_drm_surface_create",
|
||||
_cairo_boilerplate_drm_create_surface,
|
||||
cairo_surface_create_similar,
|
||||
NULL, NULL,
|
||||
_cairo_boilerplate_get_image_surface,
|
||||
cairo_surface_write_to_png,
|
||||
NULL,
|
||||
_cairo_boilerplate_drm_synchronize,
|
||||
NULL,
|
||||
FALSE, FALSE, FALSE
|
||||
},
|
||||
};
|
||||
CAIRO_BOILERPLATE (drm, targets)
|
||||
|
|
@ -9,7 +9,6 @@ cairo_boilerplate_feature_sources = {
|
|||
'cairo-quartz': ['cairo-boilerplate-quartz.c'],
|
||||
'cairo-xcb': ['cairo-boilerplate-xcb.c'],
|
||||
'cairo-win32': ['cairo-boilerplate-win32.c', 'cairo-boilerplate-win32-printing.c'],
|
||||
'cairo-drm': ['cairo-boilerplate-drm.c'],
|
||||
'cairo-cogl': ['cairo-boilerplate-cogl.c'],
|
||||
'cairo-directfb': ['cairo-boilerplate-directfb.c'],
|
||||
'cairo-pdf': ['cairo-boilerplate-pdf.c'],
|
||||
|
|
|
|||
|
|
@ -10,8 +10,6 @@ CAIRO_HAS_QUARTZ_FONT=0
|
|||
CAIRO_HAS_QUARTZ_IMAGE_SURFACE=0
|
||||
CAIRO_HAS_WIN32_SURFACE=1
|
||||
CAIRO_HAS_WIN32_FONT=1
|
||||
CAIRO_HAS_DRM_SURFACE=0
|
||||
CAIRO_HAS_GALLIUM_SURFACE=0
|
||||
CAIRO_HAS_PNG_FUNCTIONS=1
|
||||
CAIRO_HAS_GL_SURFACE=0
|
||||
CAIRO_HAS_GLESV2_SURFACE=0
|
||||
|
|
|
|||
|
|
@ -35,12 +35,6 @@ endif
|
|||
ifeq ($(CAIRO_HAS_WIN32_FONT),1)
|
||||
@echo "#define CAIRO_HAS_WIN32_FONT 1" >> $(top_srcdir)/src/cairo-features.h
|
||||
endif
|
||||
ifeq ($(CAIRO_HAS_DRM_SURFACE),1)
|
||||
@echo "#define CAIRO_HAS_DRM_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
|
||||
endif
|
||||
ifeq ($(CAIRO_HAS_GALLIUM_SURFACE),1)
|
||||
@echo "#define CAIRO_HAS_GALLIUM_SURFACE 1" >> $(top_srcdir)/src/cairo-features.h
|
||||
endif
|
||||
ifeq ($(CAIRO_HAS_PNG_FUNCTIONS),1)
|
||||
@echo "#define CAIRO_HAS_PNG_FUNCTIONS 1" >> $(top_srcdir)/src/cairo-features.h
|
||||
endif
|
||||
|
|
|
|||
|
|
@ -380,7 +380,6 @@ AC_DEFUN([CAIRO_REPORT],
|
|||
echo " OpenGL ES 3.0: $use_glesv3"
|
||||
echo " DirectFB: $use_directfb"
|
||||
echo " OpenVG: $use_vg"
|
||||
echo " DRM: $use_drm"
|
||||
echo " Cogl: $use_cogl"
|
||||
echo ""
|
||||
echo "The following font backends:"
|
||||
|
|
|
|||
26
configure.ac
26
configure.ac
|
|
@ -239,32 +239,6 @@ AM_CONDITIONAL(CAIRO_CAN_TEST_WIN32_PRINTING_SURFACE, test "x$test_win32_printin
|
|||
|
||||
dnl ===========================================================================
|
||||
|
||||
CAIRO_ENABLE_SURFACE_BACKEND(drm, DRM, no, [
|
||||
dnl Keep in sync with meson.build!
|
||||
drm_REQUIRES="libudev >= 136, libdrm >= 2.4"
|
||||
PKG_CHECK_MODULES(drm, $drm_REQUIRES, ,
|
||||
[use_drm="no (requires $drm_REQUIRES, udev is available from git://git.kernel.org/pub/scm/linux/hotplug/udev.git)"])
|
||||
])
|
||||
|
||||
CAIRO_ENABLE_SURFACE_BACKEND(gallium, Gallium3D, no, [
|
||||
if test "x$use_drm" = "xyes"; then
|
||||
AC_ARG_WITH([gallium],
|
||||
[AS_HELP_STRING([--with-gallium=/path/to/mesa],
|
||||
[directory to find gallium enabled mesa])],
|
||||
[mesa_DIR="$withval"],
|
||||
[mesa_DIR="`pwd`/../mesa"])
|
||||
gallium_DIR="$mesa_DIR/src/gallium"
|
||||
gallium_NONPKGCONFIG_CFLAGS="-I$mesa_DIR/include -I$mesa_DIR/src/mesa -I$gallium_DIR/include -I$gallium_DIR/auxiliary"
|
||||
gallium_NONPKGCONFIG_LIBS="-lGL"
|
||||
AC_SUBST(mesa_DIR)
|
||||
AC_SUBST(gallium_DIR)
|
||||
else
|
||||
use_gallium="no (requires --enable-drm)"
|
||||
fi
|
||||
])
|
||||
|
||||
dnl ===========================================================================
|
||||
|
||||
CAIRO_ENABLE_FUNCTIONS(png, PNG, yes, [
|
||||
use_png=no
|
||||
AC_ARG_VAR([png_REQUIRES], [module name for libpng to search for using pkg-config])
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ EXTRA_HFILES=$(top_builddir)/src/cairo-supported-features.h
|
|||
|
||||
# Headers to ignore
|
||||
IGNORE_HFILES= \
|
||||
drm \
|
||||
cairo-features.h \
|
||||
cairo-features-win32.h \
|
||||
$(all_cairo_private) \
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ gnome = import('gnome')
|
|||
|
||||
ignore_headers = [
|
||||
# Sub-directories
|
||||
'drm',
|
||||
'win32',
|
||||
|
||||
# Internal headers
|
||||
|
|
|
|||
20
meson.build
20
meson.build
|
|
@ -11,7 +11,6 @@ xrender_required_version = '>= 0.6'
|
|||
xcb_required_version = '>= 1.6'
|
||||
xcb_render_required_version = '>= 1.6'
|
||||
libudev_required_version = '>= 136'
|
||||
libdrm_required_version = '>= 2.4'
|
||||
glib_required_version = '>= 2.14'
|
||||
|
||||
# library versioning
|
||||
|
|
@ -504,24 +503,6 @@ if host_machine.system() == 'windows'
|
|||
]
|
||||
endif
|
||||
|
||||
# FIXME: Doesn't build since at least 2011
|
||||
libudev_dep = dependency('libudev', required: get_option('drm'),
|
||||
version: libudev_required_version)
|
||||
libdrm_dep = dependency('libdrm', required: get_option('drm'),
|
||||
version: libdrm_required_version)
|
||||
if libudev_dep.found() and libdrm_dep.found() and false
|
||||
deps += [libudev_dep, libdrm_dep]
|
||||
|
||||
feature_conf.set('CAIRO_HAS_DRM_SURFACE', 1)
|
||||
built_features += [{
|
||||
'name': 'cairo-drm',
|
||||
'description': 'DRM surface backend',
|
||||
'deps': [libudev_dep, libdrm_dep],
|
||||
}]
|
||||
endif
|
||||
|
||||
# Not even trying to port gallium as it depends on drm
|
||||
|
||||
# GL / GLESV2 / GLESV3 are mutually exclusive
|
||||
gl_backend = get_option('gl-backend')
|
||||
need_egl_functions = false
|
||||
|
|
@ -999,7 +980,6 @@ summary({
|
|||
'OpenGL ES 3.0': feature_conf.get('CAIRO_HAS_GLESV3_SURFACE', 0) == 1,
|
||||
'DirectFB': feature_conf.get('CAIRO_HAS_DIRECTFB_SURFACE', 0) == 1,
|
||||
'OpenVG': feature_conf.get('CAIRO_HAS_VG_SURFACE', 0) == 1,
|
||||
'DRM': feature_conf.get('CAIRO_HAS_DRM_SURFACE', 0) == 1,
|
||||
'Cogl': feature_conf.get('CAIRO_HAS_COGL_SURFACE', 0) == 1,
|
||||
}, section: 'Surface Backends', bool_yn: true)
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ option('gl-backend', type : 'combo', value : 'disabled',
|
|||
choices : ['auto', 'gl', 'glesv2', 'glesv3', 'disabled'])
|
||||
option('glesv2', type : 'feature', value : 'disabled')
|
||||
option('glesv3', type : 'feature', value : 'disabled')
|
||||
option('drm', type : 'feature', value : 'disabled')
|
||||
option('openvg', type : 'feature', value : 'disabled')
|
||||
option('png', type : 'feature', value : 'auto') # png and svg surfaces
|
||||
option('quartz', type : 'feature', value : 'auto')
|
||||
|
|
|
|||
|
|
@ -396,38 +396,6 @@ cairo_wgl_sources += cairo-wgl-context.c
|
|||
cairo_directfb_headers = cairo-directfb.h
|
||||
cairo_directfb_sources = cairo-directfb-surface.c
|
||||
|
||||
cairo_drm_headers = cairo-drm.h
|
||||
cairo_drm_private = drm/cairo-drm-private.h \
|
||||
drm/cairo-drm-intel-private.h \
|
||||
drm/cairo-drm-intel-brw-defines.h \
|
||||
drm/cairo-drm-intel-brw-structs.h \
|
||||
drm/cairo-drm-intel-brw-eu.h \
|
||||
drm/cairo-drm-intel-command-private.h \
|
||||
drm/cairo-drm-intel-ioctl-private.h \
|
||||
drm/cairo-drm-i915-private.h \
|
||||
drm/cairo-drm-i965-private.h \
|
||||
drm/cairo-drm-radeon-private.h
|
||||
cairo_drm_sources = drm/cairo-drm.c \
|
||||
drm/cairo-drm-bo.c \
|
||||
drm/cairo-drm-surface.c \
|
||||
drm/cairo-drm-intel.c \
|
||||
drm/cairo-drm-intel-debug.c \
|
||||
drm/cairo-drm-intel-surface.c \
|
||||
drm/cairo-drm-i915-surface.c \
|
||||
drm/cairo-drm-i915-glyphs.c \
|
||||
drm/cairo-drm-i915-shader.c \
|
||||
drm/cairo-drm-i915-spans.c \
|
||||
drm/cairo-drm-i965-surface.c \
|
||||
drm/cairo-drm-i965-glyphs.c \
|
||||
drm/cairo-drm-i965-shader.c \
|
||||
drm/cairo-drm-i965-spans.c \
|
||||
drm/cairo-drm-intel-brw-eu.c \
|
||||
drm/cairo-drm-intel-brw-eu-emit.c \
|
||||
drm/cairo-drm-intel-brw-eu-util.c \
|
||||
drm/cairo-drm-radeon.c \
|
||||
drm/cairo-drm-radeon-surface.c
|
||||
cairo_gallium_sources = drm/cairo-drm-gallium-surface.c
|
||||
|
||||
cairo_script_headers = cairo-script.h
|
||||
cairo_script_private = cairo-script-private.h
|
||||
cairo_script_sources = cairo-script-surface.c
|
||||
|
|
|
|||
|
|
@ -159,34 +159,6 @@ ifeq ($(CAIRO_HAS_WIN32_FONT),1)
|
|||
enabled_cairo_pkgconf += cairo-win32-font.pc
|
||||
endif
|
||||
|
||||
unsupported_cairo_headers += $(cairo_drm_headers)
|
||||
all_cairo_headers += $(cairo_drm_headers)
|
||||
all_cairo_private += $(cairo_drm_private)
|
||||
all_cairo_sources += $(cairo_drm_sources)
|
||||
ifeq ($(CAIRO_HAS_DRM_SURFACE),1)
|
||||
enabled_cairo_headers += $(cairo_drm_headers)
|
||||
enabled_cairo_private += $(cairo_drm_private)
|
||||
enabled_cairo_sources += $(cairo_drm_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-drm.pc
|
||||
ifeq ($(CAIRO_HAS_DRM_SURFACE),1)
|
||||
enabled_cairo_pkgconf += cairo-drm.pc
|
||||
endif
|
||||
|
||||
unsupported_cairo_headers += $(cairo_gallium_headers)
|
||||
all_cairo_headers += $(cairo_gallium_headers)
|
||||
all_cairo_private += $(cairo_gallium_private)
|
||||
all_cairo_sources += $(cairo_gallium_sources)
|
||||
ifeq ($(CAIRO_HAS_GALLIUM_SURFACE),1)
|
||||
enabled_cairo_headers += $(cairo_gallium_headers)
|
||||
enabled_cairo_private += $(cairo_gallium_private)
|
||||
enabled_cairo_sources += $(cairo_gallium_sources)
|
||||
endif
|
||||
all_cairo_pkgconf += cairo-gallium.pc
|
||||
ifeq ($(CAIRO_HAS_GALLIUM_SURFACE),1)
|
||||
enabled_cairo_pkgconf += cairo-gallium.pc
|
||||
endif
|
||||
|
||||
supported_cairo_headers += $(cairo_png_headers)
|
||||
all_cairo_headers += $(cairo_png_headers)
|
||||
all_cairo_private += $(cairo_png_private)
|
||||
|
|
|
|||
|
|
@ -88,10 +88,6 @@ cairo_debug_reset_static_data (void)
|
|||
|
||||
_cairo_image_compositor_reset_static_data ();
|
||||
|
||||
#if CAIRO_HAS_DRM_SURFACE
|
||||
_cairo_drm_device_reset_static_data ();
|
||||
#endif
|
||||
|
||||
_cairo_default_context_reset_static_data ();
|
||||
|
||||
CAIRO_MUTEX_FINALIZE ();
|
||||
|
|
|
|||
120
src/cairo-drm.h
120
src/cairo-drm.h
|
|
@ -1,120 +0,0 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Chris Wilson.
|
||||
*/
|
||||
|
||||
#ifndef CAIRO_DRM_H
|
||||
#define CAIRO_DRM_H
|
||||
|
||||
#include "cairo.h"
|
||||
|
||||
#if CAIRO_HAS_DRM_SURFACE
|
||||
|
||||
CAIRO_BEGIN_DECLS
|
||||
|
||||
struct udev_device;
|
||||
|
||||
cairo_public cairo_device_t *
|
||||
cairo_drm_device_get (struct udev_device *device);
|
||||
|
||||
cairo_public cairo_device_t *
|
||||
cairo_drm_device_get_for_fd (int fd);
|
||||
|
||||
cairo_public cairo_device_t *
|
||||
cairo_drm_device_default (void);
|
||||
|
||||
cairo_public int
|
||||
cairo_drm_device_get_fd (cairo_device_t *device);
|
||||
|
||||
cairo_public void
|
||||
cairo_drm_device_throttle (cairo_device_t *device);
|
||||
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_drm_surface_create (cairo_device_t *device,
|
||||
cairo_format_t format,
|
||||
int width, int height);
|
||||
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_drm_surface_create_for_name (cairo_device_t *device,
|
||||
unsigned int name,
|
||||
cairo_format_t format,
|
||||
int width, int height, int stride);
|
||||
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_drm_surface_create_from_cacheable_image (cairo_device_t *device,
|
||||
cairo_surface_t *surface);
|
||||
|
||||
cairo_public cairo_status_t
|
||||
cairo_drm_surface_enable_scan_out (cairo_surface_t *surface);
|
||||
|
||||
cairo_public unsigned int
|
||||
cairo_drm_surface_get_handle (cairo_surface_t *surface);
|
||||
|
||||
cairo_public unsigned int
|
||||
cairo_drm_surface_get_name (cairo_surface_t *surface);
|
||||
|
||||
cairo_public cairo_format_t
|
||||
cairo_drm_surface_get_format (cairo_surface_t *surface);
|
||||
|
||||
cairo_public int
|
||||
cairo_drm_surface_get_width (cairo_surface_t *surface);
|
||||
|
||||
cairo_public int
|
||||
cairo_drm_surface_get_height (cairo_surface_t *surface);
|
||||
|
||||
cairo_public int
|
||||
cairo_drm_surface_get_stride (cairo_surface_t *surface);
|
||||
|
||||
/* XXX map/unmap, general surface layer? */
|
||||
|
||||
/* Rough outline, culled from a conversation on IRC:
|
||||
* map() returns an image-surface representation of the drm-surface,
|
||||
* which you unmap() when you are finished, i.e. map() pulls the buffer back
|
||||
* from the GPU, maps it into the CPU domain and gives you direct access to
|
||||
* the pixels. With the unmap(), the buffer is ready to be used again by the
|
||||
* GPU and *until* the unmap(), all operations will be done in software.
|
||||
*
|
||||
* (Technically calling cairo_surface_flush() on the underlying drm-surface
|
||||
* will also disassociate the mapping.)
|
||||
*/
|
||||
cairo_public cairo_surface_t *
|
||||
cairo_drm_surface_map_to_image (cairo_surface_t *surface);
|
||||
|
||||
cairo_public void
|
||||
cairo_drm_surface_unmap (cairo_surface_t *drm_surface,
|
||||
cairo_surface_t *image_surface);
|
||||
|
||||
CAIRO_END_DECLS
|
||||
|
||||
#else /* CAIRO_HAS_DRM_SURFACE */
|
||||
# error Cairo was not compiled with support for the DRM backend
|
||||
#endif /* CAIRO_HAS_DRM_SURFACE */
|
||||
|
||||
#endif /* CAIRO_DRM_H */
|
||||
|
|
@ -72,8 +72,5 @@ CAIRO_MUTEX_DECLARE (_cairo_gl_context_mutex)
|
|||
CAIRO_MUTEX_DECLARE (_cairo_atomic_mutex)
|
||||
#endif
|
||||
|
||||
#if CAIRO_HAS_DRM_SURFACE
|
||||
CAIRO_MUTEX_DECLARE (_cairo_drm_device_mutex)
|
||||
#endif
|
||||
/* Undefine, to err on unintended inclusion */
|
||||
#undef CAIRO_MUTEX_DECLARE
|
||||
|
|
|
|||
|
|
@ -1895,13 +1895,6 @@ _cairo_trapezoid_array_translate_and_scale (cairo_trapezoid_t *offset_traps,
|
|||
double tx, double ty,
|
||||
double sx, double sy);
|
||||
|
||||
#if CAIRO_HAS_DRM_SURFACE
|
||||
|
||||
cairo_private void
|
||||
_cairo_drm_device_reset_static_data (void);
|
||||
|
||||
#endif
|
||||
|
||||
cairo_private void
|
||||
_cairo_clip_reset_static_data (void);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ echo Checking public headers for missing cairo_public decorators
|
|||
cd "$srcdir"
|
||||
FILES=$all_cairo_headers
|
||||
if test "x$FILES" = x; then
|
||||
FILES=`find . -name 'cairo*.h' ! -name '*-private.h' ! -name 'cairoint.h' ! -name '*-inline.h' ! -name cairo-drm-intel-brw-eu.h`
|
||||
FILES=`find . -name 'cairo*.h' ! -name '*-private.h' ! -name 'cairoint.h' ! -name '*-inline.h'`
|
||||
fi
|
||||
|
||||
grep -B 1 '^cairo_.*[ ]\+(' /dev/null $FILES |
|
||||
|
|
|
|||
|
|
@ -1,99 +0,0 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
#include "cairo-drm-private.h"
|
||||
#include "cairo-error-private.h"
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <errno.h>
|
||||
#include <libdrm/drm.h>
|
||||
|
||||
#define ERR_DEBUG(x) x
|
||||
|
||||
cairo_status_t
|
||||
_cairo_drm_bo_open_for_name (const cairo_drm_device_t *dev,
|
||||
cairo_drm_bo_t *bo,
|
||||
uint32_t name)
|
||||
{
|
||||
struct drm_gem_open open;
|
||||
int ret;
|
||||
|
||||
open.name = name;
|
||||
open.handle = 0;
|
||||
open.size = 0;
|
||||
do {
|
||||
ret = ioctl (dev->fd, DRM_IOCTL_GEM_OPEN, &open);
|
||||
} while (ret == -1 && errno == EINTR);
|
||||
if (ret == -1) {
|
||||
ERR_DEBUG((fprintf (stderr, "Failed to open bo for name %d: %s\n",
|
||||
name, strerror (errno))));
|
||||
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
}
|
||||
|
||||
bo->name = name;
|
||||
bo->size = open.size;
|
||||
bo->handle = open.handle;
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
cairo_status_t
|
||||
_cairo_drm_bo_flink (const cairo_drm_device_t *dev,
|
||||
cairo_drm_bo_t *bo)
|
||||
{
|
||||
struct drm_gem_flink flink;
|
||||
int ret;
|
||||
|
||||
memset (&flink, 0, sizeof (flink));
|
||||
flink.handle = bo->handle;
|
||||
ret = ioctl (dev->fd, DRM_IOCTL_GEM_FLINK, &flink);
|
||||
if (ret == -1) {
|
||||
ERR_DEBUG((fprintf (stderr, "Failed to flink bo: %s\n",
|
||||
strerror (errno))));
|
||||
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
}
|
||||
|
||||
bo->name = flink.name;
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
_cairo_drm_bo_close (const cairo_drm_device_t *dev,
|
||||
cairo_drm_bo_t *bo)
|
||||
{
|
||||
struct drm_gem_close close;
|
||||
int ret;
|
||||
|
||||
close.handle = bo->handle;
|
||||
do {
|
||||
ret = ioctl (dev->fd, DRM_IOCTL_GEM_CLOSE, &close);
|
||||
} while (ret == -1 && errno == EINTR);
|
||||
}
|
||||
|
|
@ -1,826 +0,0 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
* Copyright © 2009 Eric Anholt
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Chris Wilson.
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
|
||||
#include "cairo-drm-private.h"
|
||||
#include "cairo-default-context-private.h"
|
||||
#include "cairo-error-private.h"
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include <state_tracker/drm_api.h>
|
||||
#include <pipe/p_format.h>
|
||||
#include <pipe/p_screen.h>
|
||||
#include <pipe/p_context.h>
|
||||
#include <pipe/p_state.h>
|
||||
|
||||
#include <util/u_inlines.h>
|
||||
|
||||
typedef struct _gallium_surface gallium_surface_t;
|
||||
typedef struct _gallium_device gallium_device_t;
|
||||
|
||||
struct _gallium_device {
|
||||
cairo_drm_device_t drm;
|
||||
|
||||
void *dlhandle;
|
||||
struct drm_api *api;
|
||||
|
||||
struct pipe_screen *screen;
|
||||
struct pipe_context *pipe;
|
||||
|
||||
int max_size;
|
||||
};
|
||||
|
||||
struct _gallium_surface {
|
||||
cairo_drm_surface_t drm;
|
||||
|
||||
enum pipe_format pipe_format;
|
||||
|
||||
struct pipe_resource *texture;
|
||||
struct pipe_transfer *map_transfer;
|
||||
|
||||
cairo_surface_t *fallback;
|
||||
};
|
||||
|
||||
static cairo_surface_t *
|
||||
gallium_surface_create_internal (gallium_device_t *device,
|
||||
enum pipe_format format,
|
||||
int width, int height);
|
||||
|
||||
static inline gallium_device_t *
|
||||
gallium_device (gallium_surface_t *surface)
|
||||
{
|
||||
return (gallium_device_t *) surface->drm.base.device;
|
||||
}
|
||||
|
||||
static cairo_format_t
|
||||
_cairo_format_from_pipe_format (enum pipe_format format)
|
||||
{
|
||||
switch ((int) format) {
|
||||
case PIPE_FORMAT_A8_UNORM:
|
||||
return CAIRO_FORMAT_A8;
|
||||
case PIPE_FORMAT_A8R8G8B8_UNORM:
|
||||
return CAIRO_FORMAT_ARGB32;
|
||||
default:
|
||||
return CAIRO_FORMAT_INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
static enum pipe_format
|
||||
pipe_format_from_format (cairo_format_t format)
|
||||
{
|
||||
switch ((int) format) {
|
||||
case CAIRO_FORMAT_A8:
|
||||
return PIPE_FORMAT_A8_UNORM;
|
||||
case CAIRO_FORMAT_ARGB32:
|
||||
return PIPE_FORMAT_A8R8G8B8_UNORM;
|
||||
default:
|
||||
return (enum pipe_format) -1;
|
||||
}
|
||||
}
|
||||
|
||||
static enum pipe_format
|
||||
pipe_format_from_content (cairo_content_t content)
|
||||
{
|
||||
if (content == CAIRO_CONTENT_ALPHA)
|
||||
return PIPE_FORMAT_A8_UNORM;
|
||||
else
|
||||
return PIPE_FORMAT_A8R8G8B8_UNORM;
|
||||
}
|
||||
|
||||
static cairo_bool_t
|
||||
format_is_supported_destination (gallium_device_t *device,
|
||||
enum pipe_format format)
|
||||
{
|
||||
if (format == (enum pipe_format) -1)
|
||||
return FALSE;
|
||||
|
||||
return device->screen->is_format_supported (device->screen,
|
||||
format,
|
||||
0,
|
||||
PIPE_BIND_RENDER_TARGET,
|
||||
0);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static cairo_bool_t
|
||||
format_is_supported_source (gallium_device_t *device,
|
||||
enum pipe_format format)
|
||||
{
|
||||
return device->screen->is_format_supported (device->screen,
|
||||
format,
|
||||
0,
|
||||
PIPE_BIND_SAMPLER_VIEW,
|
||||
0);
|
||||
}
|
||||
#endif
|
||||
|
||||
static cairo_surface_t *
|
||||
gallium_surface_create_similar (void *abstract_src,
|
||||
cairo_content_t content,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
gallium_surface_t *other = abstract_src;
|
||||
gallium_device_t *device = gallium_device (other);
|
||||
enum pipe_format pipe_format;
|
||||
cairo_surface_t *surface = NULL;
|
||||
cairo_status_t status;
|
||||
|
||||
status = cairo_device_acquire (&device->drm.base);
|
||||
if (unlikely (status))
|
||||
return _cairo_surface_create_in_error (status);
|
||||
|
||||
if (MAX (width, height) > device->max_size)
|
||||
goto RELEASE;
|
||||
|
||||
if (content == other->drm.base.content)
|
||||
pipe_format = other->pipe_format;
|
||||
else
|
||||
pipe_format = pipe_format_from_content (content);
|
||||
|
||||
if (! format_is_supported_destination (device, pipe_format))
|
||||
goto RELEASE;
|
||||
|
||||
surface = gallium_surface_create_internal (device,
|
||||
pipe_format,
|
||||
width, height);
|
||||
|
||||
RELEASE:
|
||||
cairo_device_release (&device->drm.base);
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
gallium_surface_finish (void *abstract_surface)
|
||||
{
|
||||
gallium_surface_t *surface = abstract_surface;
|
||||
gallium_device_t *device = gallium_device (surface);
|
||||
cairo_status_t status;
|
||||
|
||||
status = cairo_device_acquire (&device->drm.base);
|
||||
if (likely (status == CAIRO_STATUS_SUCCESS)) {
|
||||
pipe_resource_reference (&surface->texture, NULL);
|
||||
cairo_device_release (&device->drm.base);
|
||||
}
|
||||
|
||||
return _cairo_drm_surface_finish (&surface->drm);
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
gallium_surface_map_to_image (gallium_surface_t *surface)
|
||||
{
|
||||
gallium_device_t *device = gallium_device (surface);
|
||||
cairo_status_t status;
|
||||
void *ptr = NULL;
|
||||
|
||||
status = cairo_device_acquire (&device->drm.base);
|
||||
if (unlikely (status))
|
||||
return _cairo_surface_create_in_error (status);
|
||||
|
||||
surface->map_transfer =
|
||||
pipe_get_transfer (device->pipe,
|
||||
surface->texture, 0, 0, 0,
|
||||
PIPE_TRANSFER_MAP_DIRECTLY |
|
||||
PIPE_TRANSFER_READ_WRITE,
|
||||
0, 0,
|
||||
surface->drm.width,
|
||||
surface->drm.height);
|
||||
if (likely (surface->map_transfer != NULL))
|
||||
ptr = device->pipe->transfer_map (device->pipe, surface->map_transfer);
|
||||
|
||||
cairo_device_release (&device->drm.base);
|
||||
|
||||
if (unlikely (ptr == NULL)) {
|
||||
if (surface->map_transfer != NULL) {
|
||||
device->pipe->transfer_destroy (device->pipe,
|
||||
surface->map_transfer);
|
||||
surface->map_transfer = NULL;
|
||||
}
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
}
|
||||
|
||||
return cairo_image_surface_create_for_data (ptr,
|
||||
surface->drm.format,
|
||||
surface->drm.width,
|
||||
surface->drm.height,
|
||||
surface->map_transfer->stride);
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
gallium_surface_acquire_source_image (void *abstract_surface,
|
||||
cairo_image_surface_t **image_out,
|
||||
void **image_extra)
|
||||
{
|
||||
gallium_surface_t *surface = abstract_surface;
|
||||
gallium_device_t *device = gallium_device (surface);
|
||||
cairo_format_t format;
|
||||
cairo_surface_t *image;
|
||||
cairo_status_t status;
|
||||
struct pipe_transfer *transfer;
|
||||
void *ptr;
|
||||
|
||||
if (surface->fallback != NULL) {
|
||||
*image_out = (cairo_image_surface_t *)
|
||||
cairo_surface_reference (surface->fallback);
|
||||
*image_extra = NULL;
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (unlikely (surface->drm.width == 0 || surface->drm.height == 0)) {
|
||||
image = cairo_image_surface_create (surface->drm.format, 0, 0);
|
||||
if (unlikely (image->status))
|
||||
return image->status;
|
||||
|
||||
*image_out = (cairo_image_surface_t *) image;
|
||||
*image_extra = NULL;
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
format = _cairo_format_from_pipe_format (surface->pipe_format);
|
||||
if (format == CAIRO_FORMAT_INVALID)
|
||||
return CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
|
||||
status = cairo_device_acquire (&device->drm.base);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
|
||||
transfer = pipe_get_transfer (device->pipe,
|
||||
surface->texture, 0, 0, 0,
|
||||
PIPE_TRANSFER_READ,
|
||||
0, 0,
|
||||
surface->drm.width,
|
||||
surface->drm.height);
|
||||
ptr = device->pipe->transfer_map (device->pipe, transfer);
|
||||
cairo_device_release (&device->drm.base);
|
||||
|
||||
image = cairo_image_surface_create_for_data (ptr, format,
|
||||
surface->drm.width,
|
||||
surface->drm.height,
|
||||
surface->drm.stride);
|
||||
if (unlikely (image->status))
|
||||
return image->status;
|
||||
|
||||
*image_out = (cairo_image_surface_t *) image;
|
||||
*image_extra = transfer;
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
gallium_surface_release_source_image (void *abstract_surface,
|
||||
cairo_image_surface_t *image,
|
||||
void *image_extra)
|
||||
{
|
||||
cairo_surface_destroy (&image->base);
|
||||
|
||||
if (image_extra != NULL) {
|
||||
gallium_device_t *device = gallium_device (abstract_surface);
|
||||
|
||||
device->pipe->transfer_unmap (device->pipe, image_extra);
|
||||
device->pipe->transfer_destroy (device->pipe, image_extra);
|
||||
}
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
gallium_surface_flush (void *abstract_surface,
|
||||
unsigned flags)
|
||||
{
|
||||
gallium_surface_t *surface = abstract_surface;
|
||||
gallium_device_t *device = gallium_device (surface);
|
||||
cairo_status_t status;
|
||||
|
||||
if (flags)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
if (surface->fallback == NULL) {
|
||||
device->pipe->flush (device->pipe,
|
||||
PIPE_FLUSH_RENDER_CACHE,
|
||||
NULL);
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* kill any outstanding maps */
|
||||
cairo_surface_finish (surface->fallback);
|
||||
|
||||
status = cairo_device_acquire (&device->drm.base);
|
||||
if (likely (status == CAIRO_STATUS_SUCCESS)) {
|
||||
device->pipe->transfer_unmap (device->pipe,
|
||||
surface->map_transfer);
|
||||
device->pipe->transfer_destroy (device->pipe,
|
||||
surface->map_transfer);
|
||||
surface->map_transfer = NULL;
|
||||
cairo_device_release (&device->drm.base);
|
||||
}
|
||||
|
||||
status = cairo_surface_status (surface->fallback);
|
||||
cairo_surface_destroy (surface->fallback);
|
||||
surface->fallback = NULL;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
gallium_surface_paint (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_clip_t *clip)
|
||||
{
|
||||
gallium_surface_t *surface = abstract_surface;
|
||||
|
||||
if (surface->fallback == NULL) {
|
||||
/* XXX insert magic */
|
||||
surface->fallback = gallium_surface_map_to_image (surface);
|
||||
}
|
||||
|
||||
return _cairo_surface_paint (surface->fallback, op, source, clip);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
gallium_surface_mask (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
const cairo_pattern_t *mask,
|
||||
cairo_clip_t *clip)
|
||||
{
|
||||
gallium_surface_t *surface = abstract_surface;
|
||||
|
||||
if (surface->fallback == NULL) {
|
||||
/* XXX insert magic */
|
||||
surface->fallback = gallium_surface_map_to_image (surface);
|
||||
}
|
||||
|
||||
return _cairo_surface_mask (surface->fallback,
|
||||
op, source, mask,
|
||||
clip);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
gallium_surface_stroke (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_path_fixed_t *path,
|
||||
const cairo_stroke_style_t *style,
|
||||
const cairo_matrix_t *ctm,
|
||||
const cairo_matrix_t *ctm_inverse,
|
||||
double tolerance,
|
||||
cairo_antialias_t antialias,
|
||||
cairo_clip_t *clip)
|
||||
{
|
||||
gallium_surface_t *surface = abstract_surface;
|
||||
|
||||
if (surface->fallback == NULL) {
|
||||
/* XXX insert magic */
|
||||
surface->fallback = gallium_surface_map_to_image (surface);
|
||||
}
|
||||
|
||||
return _cairo_surface_stroke (surface->fallback,
|
||||
op, source,
|
||||
path, style,
|
||||
ctm, ctm_inverse,
|
||||
tolerance, antialias,
|
||||
clip);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
gallium_surface_fill (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_path_fixed_t *path,
|
||||
cairo_fill_rule_t fill_rule,
|
||||
double tolerance,
|
||||
cairo_antialias_t antialias,
|
||||
cairo_clip_t *clip)
|
||||
{
|
||||
gallium_surface_t *surface = abstract_surface;
|
||||
|
||||
if (surface->fallback == NULL) {
|
||||
/* XXX insert magic */
|
||||
surface->fallback = gallium_surface_map_to_image (surface);
|
||||
}
|
||||
|
||||
return _cairo_surface_fill (surface->fallback,
|
||||
op, source,
|
||||
path, fill_rule,
|
||||
tolerance, antialias,
|
||||
clip);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
gallium_surface_glyphs (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font,
|
||||
cairo_clip_t *clip,
|
||||
int *num_remaining)
|
||||
{
|
||||
gallium_surface_t *surface = abstract_surface;
|
||||
|
||||
*num_remaining = 0;
|
||||
|
||||
if (surface->fallback == NULL) {
|
||||
/* XXX insert magic */
|
||||
surface->fallback = gallium_surface_map_to_image (surface);
|
||||
}
|
||||
|
||||
return _cairo_surface_show_text_glyphs (surface->fallback,
|
||||
op, source,
|
||||
NULL, 0,
|
||||
glyphs, num_glyphs,
|
||||
NULL, 0, 0,
|
||||
scaled_font,
|
||||
clip);
|
||||
}
|
||||
|
||||
static const cairo_surface_backend_t gallium_surface_backend = {
|
||||
CAIRO_SURFACE_TYPE_DRM,
|
||||
_cairo_default_context_create,
|
||||
|
||||
gallium_surface_create_similar,
|
||||
gallium_surface_finish,
|
||||
|
||||
NULL,
|
||||
gallium_surface_acquire_source_image,
|
||||
gallium_surface_release_source_image,
|
||||
|
||||
NULL, //gallium_surface_acquire_dest_image,
|
||||
NULL, //gallium_surface_release_dest_image,
|
||||
NULL, //gallium_surface_clone_similar,
|
||||
NULL, //gallium_surface_composite,
|
||||
NULL, //gallium_surface_fill_rectangles,
|
||||
NULL, //gallium_surface_composite_trapezoids,
|
||||
NULL, //gallium_surface_create_span_renderer,
|
||||
NULL, //gallium_surface_check_span_renderer,
|
||||
NULL, /* copy_page */
|
||||
NULL, /* show_page */
|
||||
_cairo_drm_surface_get_extents,
|
||||
NULL, /* old_show_glyphs */
|
||||
_cairo_drm_surface_get_font_options,
|
||||
gallium_surface_flush,
|
||||
NULL, /* mark_dirty_rectangle */
|
||||
NULL, //gallium_surface_scaled_font_fini,
|
||||
NULL, //gallium_surface_scaled_glyph_fini,
|
||||
|
||||
gallium_surface_paint,
|
||||
gallium_surface_mask,
|
||||
gallium_surface_stroke,
|
||||
gallium_surface_fill,
|
||||
gallium_surface_glyphs,
|
||||
|
||||
NULL, /* snapshot */
|
||||
|
||||
NULL, /* is_similar */
|
||||
|
||||
NULL, /* reset */
|
||||
};
|
||||
|
||||
static int
|
||||
gallium_format_stride_for_width (enum pipe_format format, int width)
|
||||
{
|
||||
int stride;
|
||||
|
||||
stride = 1024; /* XXX fugly */
|
||||
while (stride < width)
|
||||
stride *= 2;
|
||||
|
||||
if (format == PIPE_FORMAT_A8R8G8B8_UNORM)
|
||||
stride *= 4;
|
||||
|
||||
return stride;
|
||||
}
|
||||
|
||||
static cairo_drm_bo_t *
|
||||
_gallium_fake_bo_create (uint32_t size, uint32_t name)
|
||||
{
|
||||
cairo_drm_bo_t *bo;
|
||||
|
||||
/* XXX integrate with winsys handle */
|
||||
|
||||
bo = _cairo_malloc (sizeof (cairo_drm_bo_t));
|
||||
|
||||
CAIRO_REFERENCE_COUNT_INIT (&bo->ref_count, 1);
|
||||
bo->name = name;
|
||||
bo->handle = 0;
|
||||
bo->size = size;
|
||||
|
||||
return bo;
|
||||
}
|
||||
|
||||
static void
|
||||
_gallium_fake_bo_release (void *dev, void *bo)
|
||||
{
|
||||
free (bo);
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
gallium_surface_create_internal (gallium_device_t *device,
|
||||
enum pipe_format pipe_format,
|
||||
int width, int height)
|
||||
{
|
||||
gallium_surface_t *surface;
|
||||
struct pipe_resource template;
|
||||
cairo_status_t status;
|
||||
cairo_format_t format;
|
||||
int stride, size;
|
||||
|
||||
surface = _cairo_malloc (sizeof (gallium_surface_t));
|
||||
if (unlikely (surface == NULL))
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
|
||||
format = _cairo_format_from_pipe_format (pipe_format);
|
||||
_cairo_surface_init (&surface->drm.base,
|
||||
&gallium_surface_backend,
|
||||
&device->drm.base,
|
||||
_cairo_content_from_format (format));
|
||||
_cairo_drm_surface_init (&surface->drm, format, width, height);
|
||||
|
||||
stride = gallium_format_stride_for_width (pipe_format, width);
|
||||
size = stride * height;
|
||||
|
||||
surface->drm.stride = stride;
|
||||
surface->drm.bo = _gallium_fake_bo_create (size, 0);
|
||||
|
||||
memset(&template, 0, sizeof(template));
|
||||
template.target = PIPE_TEXTURE_2D;
|
||||
template.format = pipe_format;
|
||||
template.width0 = width;
|
||||
template.height0 = height;
|
||||
template.depth0 = 1;
|
||||
template.last_level = 0;
|
||||
template.bind = PIPE_BIND_RENDER_TARGET;
|
||||
surface->texture = device->screen->resource_create (device->screen,
|
||||
&template);
|
||||
|
||||
if (unlikely (surface->texture == NULL)) {
|
||||
status = _cairo_drm_surface_finish (&surface->drm);
|
||||
free (surface);
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
}
|
||||
|
||||
surface->pipe_format = pipe_format;
|
||||
surface->texture = NULL;
|
||||
|
||||
return &surface->drm.base;
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
gallium_surface_create (cairo_drm_device_t *base_dev,
|
||||
cairo_format_t format,
|
||||
int width, int height)
|
||||
{
|
||||
gallium_device_t *device = (gallium_device_t *) base_dev;
|
||||
cairo_surface_t *surface;
|
||||
enum pipe_format pipe_format;
|
||||
cairo_status_t status;
|
||||
|
||||
status = cairo_device_acquire (&device->drm.base);
|
||||
|
||||
if (MAX (width, height) > device->max_size) {
|
||||
surface = _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE));
|
||||
goto RELEASE;
|
||||
}
|
||||
|
||||
pipe_format = pipe_format_from_format (format);
|
||||
if (! format_is_supported_destination (device, pipe_format)) {
|
||||
surface = _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
|
||||
goto RELEASE;
|
||||
}
|
||||
|
||||
surface = gallium_surface_create_internal (device,
|
||||
pipe_format,
|
||||
width, height);
|
||||
|
||||
RELEASE:
|
||||
cairo_device_release (&device->drm.base);
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static cairo_surface_t *
|
||||
gallium_surface_create_for_name (cairo_drm_device_t *base_dev,
|
||||
unsigned int name,
|
||||
cairo_format_t format,
|
||||
int width, int height, int stride)
|
||||
{
|
||||
gallium_device_t *device;
|
||||
gallium_surface_t *surface;
|
||||
cairo_status_t status;
|
||||
cairo_content_t content;
|
||||
|
||||
surface = _cairo_malloc (sizeof (gallium_surface_t));
|
||||
if (unlikely (surface == NULL))
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
|
||||
switch (format) {
|
||||
default:
|
||||
case CAIRO_FORMAT_INVALID:
|
||||
case CAIRO_FORMAT_A1:
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
|
||||
case CAIRO_FORMAT_A8:
|
||||
surface->pipe_format = PIPE_FORMAT_A8_UNORM;
|
||||
break;
|
||||
case CAIRO_FORMAT_RGB24:
|
||||
case CAIRO_FORMAT_ARGB32:
|
||||
surface->pipe_format = PIPE_FORMAT_A8R8G8B8_UNORM;
|
||||
break;
|
||||
}
|
||||
|
||||
status = cairo_device_acquire (&device->drm.base);
|
||||
|
||||
if (MAX (width, height) > device->max_size) {
|
||||
cairo_device_release (&device->drm.base);
|
||||
free (surface);
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE));
|
||||
}
|
||||
|
||||
if (! format_is_supported_destination (device, surface->pipe_format)) {
|
||||
cairo_device_release (&device->drm.base);
|
||||
free (surface);
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
|
||||
}
|
||||
|
||||
content = _cairo_content_from_format (format);
|
||||
_cairo_surface_init (&surface->drm.base,
|
||||
&gallium_surface_backend,
|
||||
content);
|
||||
_cairo_drm_surface_init (&surface->drm, base_dev);
|
||||
|
||||
surface->drm.bo = _gallium_fake_bo_create (height * stride, name);
|
||||
|
||||
surface->drm.width = width;
|
||||
surface->drm.height = height;
|
||||
surface->drm.stride = stride;
|
||||
|
||||
#if 0
|
||||
/* XXX screen->create_from_handle */
|
||||
surface->buffer = device->api->buffer_from_handle (device->api,
|
||||
device->screen,
|
||||
"cairo-gallium alien",
|
||||
name);
|
||||
if (unlikely (surface->buffer == NULL)) {
|
||||
status = _cairo_drm_surface_finish (&surface->drm);
|
||||
cairo_device_release (&device->drm.base);
|
||||
free (surface);
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
}
|
||||
#endif
|
||||
|
||||
surface->texture = NULL;
|
||||
|
||||
surface->fallback = NULL;
|
||||
|
||||
cairo_device_release (&device->drm.base);
|
||||
|
||||
return &surface->drm.base;
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
gallium_surface_flink (void *abstract_surface)
|
||||
{
|
||||
gallium_surface_t *surface = abstract_surface;
|
||||
gallium_device_t *device;
|
||||
cairo_status_t status = CAIRO_STATUS_SUCCESS;
|
||||
|
||||
status = cairo_device_acquire (&device->drm.base);
|
||||
if (! device->api->global_handle_from_buffer (device->api,
|
||||
device->screen,
|
||||
surface->buffer,
|
||||
&surface->drm.bo->name))
|
||||
{
|
||||
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
}
|
||||
cairo_device_release (&device->drm.base);
|
||||
|
||||
return status;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void
|
||||
gallium_device_destroy (void *abstract_device)
|
||||
{
|
||||
gallium_device_t *device = abstract_device;
|
||||
|
||||
device->pipe->destroy (device->pipe);
|
||||
device->screen->destroy (device->screen);
|
||||
device->api->destroy (device->api);
|
||||
|
||||
dlclose (device->dlhandle);
|
||||
free (device);
|
||||
}
|
||||
|
||||
cairo_drm_device_t *
|
||||
_cairo_drm_gallium_device_create (int fd, dev_t dev, int vendor_id, int chip_id)
|
||||
{
|
||||
gallium_device_t *device;
|
||||
cairo_status_t status;
|
||||
void *handle;
|
||||
const char *libdir;
|
||||
char buf[4096];
|
||||
struct drm_api *(*ctor) (void);
|
||||
|
||||
/* XXX need search path + probe */
|
||||
libdir = getenv ("CAIRO_GALLIUM_LIBDIR");
|
||||
if (libdir == NULL)
|
||||
libdir = "/usr/lib/dri";
|
||||
buf[snprintf (buf, sizeof (buf)-1, "%s/i915_dri.so", libdir)] = '\0';
|
||||
|
||||
handle = dlopen (buf, RTLD_LAZY);
|
||||
if (handle == NULL)
|
||||
return NULL;
|
||||
|
||||
ctor = dlsym (handle, "drm_api_create");
|
||||
if (ctor == NULL) {
|
||||
dlclose (handle);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
device = _cairo_malloc (sizeof (gallium_device_t));
|
||||
if (device == NULL) {
|
||||
dlclose (handle);
|
||||
return _cairo_drm_device_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
}
|
||||
|
||||
device->dlhandle = handle;
|
||||
|
||||
device->drm.surface.create = gallium_surface_create;
|
||||
device->drm.surface.create_for_name = NULL;
|
||||
//device->drm.surface.create_for_name = gallium_surface_create_for_name;
|
||||
device->drm.surface.enable_scan_out = NULL;
|
||||
//device->drm.surface.flink = gallium_surface_flink;
|
||||
device->drm.surface.flink = NULL;
|
||||
|
||||
device->drm.device.flush = NULL;
|
||||
device->drm.device.throttle = NULL;
|
||||
device->drm.device.destroy = gallium_device_destroy;
|
||||
|
||||
device->drm.bo.release = _gallium_fake_bo_release;
|
||||
|
||||
device->api = ctor ();
|
||||
if (device->api == NULL) {
|
||||
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
goto CLEANUP;
|
||||
}
|
||||
|
||||
device->screen = device->api->create_screen (device->api, fd, NULL);
|
||||
if (device->screen == NULL) {
|
||||
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
goto CLEANUP_API;
|
||||
}
|
||||
|
||||
device->max_size = 1 << device->screen->get_param (device->screen,
|
||||
PIPE_CAP_MAX_TEXTURE_2D_LEVELS);
|
||||
|
||||
device->pipe = device->screen->context_create (device->screen, device);
|
||||
if (device->pipe == NULL) {
|
||||
status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
goto CLEANUP_SCREEN;
|
||||
}
|
||||
|
||||
return _cairo_drm_device_init (&device->drm,
|
||||
fd, dev,
|
||||
0, 0,
|
||||
device->max_size);
|
||||
|
||||
CLEANUP_SCREEN:
|
||||
device->screen->destroy (device->screen);
|
||||
CLEANUP_API:
|
||||
device->api->destroy (device->api);
|
||||
CLEANUP:
|
||||
free (device);
|
||||
dlclose (handle);
|
||||
return _cairo_drm_device_create_in_error (status);
|
||||
}
|
||||
|
|
@ -1,566 +0,0 @@
|
|||
/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
|
||||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Intel Corporation
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Red Hat, Inc.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Chris Wilson <chris@chris-wilson.co.uk>
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
|
||||
#include "cairo-composite-rectangles-private.h"
|
||||
#include "cairo-drm-i915-private.h"
|
||||
#include "cairo-error-private.h"
|
||||
#include "cairo-rtree-private.h"
|
||||
#include "cairo-clip-inline.h"
|
||||
|
||||
static void
|
||||
i915_emit_glyph_rectangle_zero (i915_device_t *device,
|
||||
i915_shader_t *shader,
|
||||
int x1, int y1,
|
||||
int x2, int y2,
|
||||
intel_glyph_t *glyph)
|
||||
{
|
||||
float *v;
|
||||
|
||||
/* Each vertex is:
|
||||
* 2 vertex coordinates
|
||||
*/
|
||||
|
||||
v = i915_add_rectangle (device);
|
||||
*v++ = x2; *v++ = y2;
|
||||
*v++ = x1; *v++ = y2;
|
||||
*v++ = x1; *v++ = y1;
|
||||
}
|
||||
|
||||
static void
|
||||
i915_emit_glyph_rectangle_constant (i915_device_t *device,
|
||||
i915_shader_t *shader,
|
||||
int x1, int y1,
|
||||
int x2, int y2,
|
||||
intel_glyph_t *glyph)
|
||||
{
|
||||
float *v;
|
||||
|
||||
/* Each vertex is:
|
||||
* 2 vertex coordinates
|
||||
* 2 glyph texture coordinates
|
||||
*/
|
||||
|
||||
v = i915_add_rectangle (device);
|
||||
|
||||
/* bottom right */
|
||||
*v++ = x2; *v++ = y2;
|
||||
*v++ = glyph->texcoord[0];
|
||||
|
||||
/* bottom left */
|
||||
*v++ = x1; *v++ = y2;
|
||||
*v++ = glyph->texcoord[1];
|
||||
|
||||
/* top left */
|
||||
*v++ = x1; *v++ = y1;
|
||||
*v++ = glyph->texcoord[2];
|
||||
}
|
||||
|
||||
static void
|
||||
i915_emit_glyph_rectangle_general (i915_device_t *device,
|
||||
i915_shader_t *shader,
|
||||
int x1, int y1,
|
||||
int x2, int y2,
|
||||
intel_glyph_t *glyph)
|
||||
{
|
||||
double s, t;
|
||||
float *v;
|
||||
|
||||
/* Each vertex is:
|
||||
* 2 vertex coordinates
|
||||
* [0-2] source texture coordinates
|
||||
* 2 glyph texture coordinates
|
||||
*/
|
||||
|
||||
v = i915_add_rectangle (device);
|
||||
|
||||
/* bottom right */
|
||||
*v++ = x2; *v++ = y2;
|
||||
s = x2, t = y2;
|
||||
switch (shader->source.type.vertex) {
|
||||
case VS_ZERO:
|
||||
case VS_CONSTANT:
|
||||
break;
|
||||
case VS_LINEAR:
|
||||
*v++ = i915_shader_linear_texcoord (&shader->source.linear, s, t);
|
||||
break;
|
||||
case VS_TEXTURE:
|
||||
cairo_matrix_transform_point (&shader->source.base.matrix, &s, &t);
|
||||
*v++ = s; *v++ = t;
|
||||
break;
|
||||
case VS_TEXTURE_16:
|
||||
cairo_matrix_transform_point (&shader->source.base.matrix, &s, &t);
|
||||
*v++ = texcoord_2d_16 (s, t);
|
||||
break;
|
||||
}
|
||||
*v++ = glyph->texcoord[0];
|
||||
|
||||
/* bottom left */
|
||||
*v++ = x1; *v++ = y2;
|
||||
s = x1, t = y2;
|
||||
switch (shader->source.type.vertex) {
|
||||
case VS_ZERO:
|
||||
case VS_CONSTANT:
|
||||
break;
|
||||
case VS_LINEAR:
|
||||
*v++ = i915_shader_linear_texcoord (&shader->source.linear, s, t);
|
||||
break;
|
||||
case VS_TEXTURE:
|
||||
cairo_matrix_transform_point (&shader->source.base.matrix, &s, &t);
|
||||
*v++ = s; *v++ = t;
|
||||
break;
|
||||
case VS_TEXTURE_16:
|
||||
cairo_matrix_transform_point (&shader->source.base.matrix, &s, &t);
|
||||
*v++ = texcoord_2d_16 (s, t);
|
||||
break;
|
||||
}
|
||||
*v++ = glyph->texcoord[1];
|
||||
|
||||
/* top left */
|
||||
*v++ = x1; *v++ = y1;
|
||||
s = x1, t = y2;
|
||||
switch (shader->source.type.vertex) {
|
||||
case VS_ZERO:
|
||||
case VS_CONSTANT:
|
||||
break;
|
||||
case VS_LINEAR:
|
||||
*v++ = i915_shader_linear_texcoord (&shader->source.linear, s, t);
|
||||
break;
|
||||
case VS_TEXTURE:
|
||||
cairo_matrix_transform_point (&shader->source.base.matrix, &s, &t);
|
||||
*v++ = s; *v++ = t;
|
||||
break;
|
||||
case VS_TEXTURE_16:
|
||||
cairo_matrix_transform_point (&shader->source.base.matrix, &s, &t);
|
||||
*v++ = texcoord_2d_16 (s, t);
|
||||
break;
|
||||
}
|
||||
*v++ = glyph->texcoord[2];
|
||||
}
|
||||
|
||||
typedef void
|
||||
(*i915_emit_glyph_rectangle_func_t) (i915_device_t *device,
|
||||
i915_shader_t *shader,
|
||||
int x1, int y1,
|
||||
int x2, int y2,
|
||||
intel_glyph_t *glyph);
|
||||
|
||||
static cairo_status_t
|
||||
i915_surface_mask_internal (i915_surface_t *dst,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
i915_surface_t *mask,
|
||||
cairo_clip_t *clip,
|
||||
const cairo_composite_rectangles_t *extents)
|
||||
{
|
||||
i915_device_t *device;
|
||||
i915_shader_t shader;
|
||||
cairo_region_t *clip_region = NULL;
|
||||
cairo_status_t status;
|
||||
|
||||
i915_shader_init (&shader, dst, op, 1.);
|
||||
|
||||
status = i915_shader_acquire_pattern (&shader, &shader.source,
|
||||
source, &extents->bounded);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
|
||||
shader.mask.type.vertex = VS_TEXTURE_16;
|
||||
shader.mask.type.pattern = PATTERN_TEXTURE;
|
||||
shader.mask.type.fragment = FS_TEXTURE;
|
||||
shader.mask.base.content = mask->intel.drm.base.content;
|
||||
shader.mask.base.texfmt = TEXCOORDFMT_2D_16;
|
||||
shader.mask.base.n_samplers = 1;
|
||||
shader.mask.base.sampler[0] =
|
||||
(MIPFILTER_NONE << SS2_MIP_FILTER_SHIFT) |
|
||||
i915_texture_filter (CAIRO_FILTER_NEAREST);
|
||||
shader.mask.base.sampler[1] =
|
||||
SS3_NORMALIZED_COORDS |
|
||||
i915_texture_extend (CAIRO_EXTEND_NONE);
|
||||
|
||||
cairo_matrix_init_translate (&shader.mask.base.matrix,
|
||||
-extents->bounded.x,
|
||||
-extents->bounded.y);
|
||||
cairo_matrix_scale (&shader.mask.base.matrix,
|
||||
1. / mask->intel.drm.width,
|
||||
1. / mask->intel.drm.height);
|
||||
|
||||
shader.mask.base.bo = intel_bo_reference (to_intel_bo (mask->intel.drm.bo));
|
||||
shader.mask.base.offset[0] = 0;
|
||||
shader.mask.base.map[0] = mask->map0;
|
||||
shader.mask.base.map[1] = mask->map1;
|
||||
|
||||
if (clip != NULL) {
|
||||
status = _cairo_clip_get_region (clip, &clip_region);
|
||||
|
||||
if (clip_region != NULL && cairo_region_num_rectangles (clip_region) == 1)
|
||||
clip_region = NULL;
|
||||
|
||||
if (status == CAIRO_INT_STATUS_UNSUPPORTED)
|
||||
i915_shader_set_clip (&shader, clip);
|
||||
}
|
||||
|
||||
status = cairo_device_acquire (dst->intel.drm.base.device);
|
||||
if (unlikely (status))
|
||||
goto CLEANUP_SHADER;
|
||||
|
||||
device = i915_device (dst);
|
||||
|
||||
status = i915_shader_commit (&shader, device);
|
||||
if (unlikely (status))
|
||||
goto CLEANUP_DEVICE;
|
||||
|
||||
if (clip_region != NULL) {
|
||||
unsigned int n, num_rectangles;
|
||||
|
||||
num_rectangles = cairo_region_num_rectangles (clip_region);
|
||||
for (n = 0; n < num_rectangles; n++) {
|
||||
cairo_rectangle_int_t rect;
|
||||
|
||||
cairo_region_get_rectangle (clip_region, n, &rect);
|
||||
|
||||
shader.add_rectangle (&shader,
|
||||
rect.x, rect.y,
|
||||
rect.x + rect.width, rect.y + rect.height);
|
||||
}
|
||||
} else {
|
||||
shader.add_rectangle (&shader,
|
||||
extents->bounded.x, extents->bounded.y,
|
||||
extents->bounded.x + extents->bounded.width,
|
||||
extents->bounded.y + extents->bounded.height);
|
||||
}
|
||||
|
||||
if (! extents->is_bounded)
|
||||
status = i915_fixup_unbounded (dst, extents, clip);
|
||||
|
||||
CLEANUP_DEVICE:
|
||||
cairo_device_release (&device->intel.base.base);
|
||||
CLEANUP_SHADER:
|
||||
i915_shader_fini (&shader);
|
||||
return status;
|
||||
}
|
||||
|
||||
cairo_int_status_t
|
||||
i915_surface_glyphs (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font,
|
||||
cairo_clip_t *clip,
|
||||
int *num_remaining)
|
||||
{
|
||||
i915_surface_t *surface = abstract_surface;
|
||||
i915_surface_t *mask = NULL;
|
||||
i915_device_t *device;
|
||||
i915_shader_t shader;
|
||||
cairo_composite_rectangles_t extents;
|
||||
cairo_clip_t local_clip;
|
||||
cairo_bool_t have_clip = FALSE;
|
||||
cairo_bool_t overlap;
|
||||
cairo_region_t *clip_region = NULL;
|
||||
intel_bo_t *last_bo = NULL;
|
||||
i915_emit_glyph_rectangle_func_t emit_func;
|
||||
cairo_scaled_glyph_t *glyph_cache[64];
|
||||
cairo_status_t status;
|
||||
int mask_x = 0, mask_y = 0;
|
||||
int i = 0;
|
||||
|
||||
*num_remaining = 0;
|
||||
status = _cairo_composite_rectangles_init_for_glyphs (&extents,
|
||||
surface->intel.drm.width,
|
||||
surface->intel.drm.height,
|
||||
op, source,
|
||||
scaled_font,
|
||||
glyphs, num_glyphs,
|
||||
clip,
|
||||
&overlap);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
|
||||
if (_cairo_clip_contains_rectangle (clip, &extents.mask))
|
||||
clip = NULL;
|
||||
|
||||
if (clip != NULL && extents.is_bounded) {
|
||||
clip = _cairo_clip_init_copy (&local_clip, clip);
|
||||
status = _cairo_clip_rectangle (clip, &extents.bounded);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
|
||||
have_clip = TRUE;
|
||||
}
|
||||
|
||||
if (clip != NULL) {
|
||||
status = _cairo_clip_get_region (clip, &clip_region);
|
||||
if (unlikely (_cairo_status_is_error (status) ||
|
||||
status == CAIRO_INT_STATUS_NOTHING_TO_DO))
|
||||
{
|
||||
if (have_clip)
|
||||
_cairo_clip_fini (&local_clip);
|
||||
return status;
|
||||
}
|
||||
}
|
||||
|
||||
if (i915_surface_needs_tiling (surface)) {
|
||||
ASSERT_NOT_REACHED;
|
||||
return CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
}
|
||||
|
||||
if (overlap || ! extents.is_bounded) {
|
||||
cairo_format_t format;
|
||||
|
||||
format = CAIRO_FORMAT_A8;
|
||||
if (scaled_font->options.antialias == CAIRO_ANTIALIAS_SUBPIXEL)
|
||||
format = CAIRO_FORMAT_ARGB32;
|
||||
|
||||
mask = (i915_surface_t *)
|
||||
i915_surface_create_internal (&i915_device (surface)->intel.base,
|
||||
format,
|
||||
extents.bounded.width,
|
||||
extents.bounded.height,
|
||||
I915_TILING_DEFAULT,
|
||||
TRUE);
|
||||
if (unlikely (mask->intel.drm.base.status))
|
||||
return mask->intel.drm.base.status;
|
||||
|
||||
status = i915_surface_clear (mask);
|
||||
if (unlikely (status)) {
|
||||
cairo_surface_destroy (&mask->intel.drm.base);
|
||||
return status;
|
||||
}
|
||||
|
||||
i915_shader_init (&shader, mask, CAIRO_OPERATOR_ADD, 1.);
|
||||
|
||||
status = i915_shader_acquire_pattern (&shader, &shader.source,
|
||||
&_cairo_pattern_white.base,
|
||||
&extents.bounded);
|
||||
if (unlikely (status)) {
|
||||
cairo_surface_destroy (&mask->intel.drm.base);
|
||||
return status;
|
||||
}
|
||||
|
||||
mask_x = -extents.bounded.x;
|
||||
mask_y = -extents.bounded.y;
|
||||
} else {
|
||||
i915_shader_init (&shader, surface, op, 1.);
|
||||
|
||||
status = i915_shader_acquire_pattern (&shader, &shader.source,
|
||||
source, &extents.bounded);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
|
||||
if (clip != NULL) {
|
||||
status = _cairo_clip_get_region (clip, &clip_region);
|
||||
|
||||
if (clip_region != NULL && cairo_region_num_rectangles (clip_region) == 1)
|
||||
clip_region = NULL;
|
||||
|
||||
if (status == CAIRO_INT_STATUS_UNSUPPORTED)
|
||||
i915_shader_set_clip (&shader, clip);
|
||||
}
|
||||
}
|
||||
|
||||
shader.mask.type.fragment = FS_TEXTURE;
|
||||
shader.mask.base.content = CAIRO_CONTENT_ALPHA; /* XXX */
|
||||
shader.mask.base.texfmt = TEXCOORDFMT_2D_16;
|
||||
shader.mask.base.n_samplers = 1;
|
||||
shader.mask.base.sampler[0] =
|
||||
(MIPFILTER_NONE << SS2_MIP_FILTER_SHIFT) |
|
||||
i915_texture_filter (CAIRO_FILTER_NEAREST);
|
||||
shader.mask.base.sampler[1] =
|
||||
SS3_NORMALIZED_COORDS |
|
||||
i915_texture_extend (CAIRO_EXTEND_NONE);
|
||||
|
||||
switch (shader.source.type.vertex) {
|
||||
case VS_ZERO:
|
||||
emit_func = i915_emit_glyph_rectangle_zero;
|
||||
break;
|
||||
case VS_CONSTANT:
|
||||
emit_func = i915_emit_glyph_rectangle_constant;
|
||||
break;
|
||||
default:
|
||||
case VS_LINEAR:
|
||||
case VS_TEXTURE:
|
||||
case VS_TEXTURE_16:
|
||||
emit_func = i915_emit_glyph_rectangle_general;
|
||||
break;
|
||||
}
|
||||
|
||||
status = cairo_device_acquire (surface->intel.drm.base.device);
|
||||
if (unlikely (status))
|
||||
goto CLEANUP_SHADER;
|
||||
|
||||
device = i915_device (surface);
|
||||
|
||||
_cairo_scaled_font_freeze_cache (scaled_font);
|
||||
if (scaled_font->surface_private == NULL) {
|
||||
scaled_font->surface_private = device;
|
||||
scaled_font->surface_backend = surface->intel.drm.base.backend;
|
||||
cairo_list_add (&scaled_font->link, &device->intel.fonts);
|
||||
}
|
||||
|
||||
memset (glyph_cache, 0, sizeof (glyph_cache));
|
||||
|
||||
for (i = 0; i < num_glyphs; i++) {
|
||||
cairo_scaled_glyph_t *scaled_glyph;
|
||||
int x, y, x1, x2, y1, y2;
|
||||
int cache_index = glyphs[i].index % ARRAY_LENGTH (glyph_cache);
|
||||
intel_glyph_t *glyph;
|
||||
|
||||
scaled_glyph = glyph_cache[cache_index];
|
||||
if (scaled_glyph == NULL ||
|
||||
_cairo_scaled_glyph_index (scaled_glyph) != glyphs[i].index)
|
||||
{
|
||||
status = _cairo_scaled_glyph_lookup (scaled_font,
|
||||
glyphs[i].index,
|
||||
CAIRO_SCALED_GLYPH_INFO_METRICS,
|
||||
NULL, /* foreground color */
|
||||
&scaled_glyph);
|
||||
if (unlikely (status))
|
||||
goto FINISH;
|
||||
|
||||
glyph_cache[cache_index] = scaled_glyph;
|
||||
}
|
||||
|
||||
if (unlikely (scaled_glyph->metrics.width == 0 ||
|
||||
scaled_glyph->metrics.height == 0))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* XXX glyph images are snapped to pixel locations */
|
||||
x = _cairo_lround (glyphs[i].x);
|
||||
y = _cairo_lround (glyphs[i].y);
|
||||
|
||||
x1 = x + _cairo_fixed_integer_floor (scaled_glyph->bbox.p1.x);
|
||||
y1 = y + _cairo_fixed_integer_floor (scaled_glyph->bbox.p1.y);
|
||||
x2 = x + _cairo_fixed_integer_ceil (scaled_glyph->bbox.p2.x);
|
||||
y2 = y + _cairo_fixed_integer_ceil (scaled_glyph->bbox.p2.y);
|
||||
|
||||
if (x2 < extents.bounded.x ||
|
||||
y2 < extents.bounded.y ||
|
||||
x1 > extents.bounded.x + extents.bounded.width ||
|
||||
y1 > extents.bounded.y + extents.bounded.height)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (scaled_glyph->surface_private == NULL) {
|
||||
status = intel_get_glyph (&device->intel, scaled_font, scaled_glyph);
|
||||
if (unlikely (status == CAIRO_INT_STATUS_NOTHING_TO_DO)) {
|
||||
status = CAIRO_STATUS_SUCCESS;
|
||||
continue;
|
||||
}
|
||||
if (unlikely (status))
|
||||
goto FINISH;
|
||||
}
|
||||
|
||||
glyph = intel_glyph_pin (scaled_glyph->surface_private);
|
||||
if (glyph->cache->buffer.bo != last_bo) {
|
||||
intel_buffer_cache_t *cache = glyph->cache;
|
||||
|
||||
shader.mask.base.bo = cache->buffer.bo;
|
||||
shader.mask.base.offset[0] = cache->buffer.offset;
|
||||
shader.mask.base.map[0] = cache->buffer.map0;
|
||||
shader.mask.base.map[1] = cache->buffer.map1;
|
||||
shader.mask.base.content = CAIRO_CONTENT_ALPHA; /* XXX */
|
||||
|
||||
status = i915_shader_commit (&shader, device);
|
||||
if (unlikely (status))
|
||||
goto FINISH;
|
||||
|
||||
last_bo = cache->buffer.bo;
|
||||
}
|
||||
|
||||
x2 = x1 + glyph->width;
|
||||
y2 = y1 + glyph->height;
|
||||
|
||||
if (mask_x)
|
||||
x1 += mask_x, x2 += mask_x;
|
||||
if (mask_y)
|
||||
y1 += mask_y, y2 += mask_y;
|
||||
|
||||
/* XXX clip glyph */
|
||||
emit_func (device, &shader, x1, y1, x2, y2, glyph);
|
||||
}
|
||||
|
||||
status = CAIRO_STATUS_SUCCESS;
|
||||
FINISH:
|
||||
_cairo_scaled_font_thaw_cache (scaled_font);
|
||||
cairo_device_release (surface->intel.drm.base.device);
|
||||
CLEANUP_SHADER:
|
||||
i915_shader_fini (&shader);
|
||||
|
||||
if (unlikely (status == CAIRO_INT_STATUS_UNSUPPORTED)) {
|
||||
cairo_path_fixed_t path;
|
||||
|
||||
_cairo_path_fixed_init (&path);
|
||||
status = _cairo_scaled_font_glyph_path (scaled_font,
|
||||
glyphs + i, num_glyphs - i,
|
||||
&path);
|
||||
if (mask_x | mask_y) {
|
||||
_cairo_path_fixed_translate (&path,
|
||||
_cairo_fixed_from_int (mask_x),
|
||||
_cairo_fixed_from_int (mask_y));
|
||||
}
|
||||
if (likely (status == CAIRO_STATUS_SUCCESS)) {
|
||||
status = surface->intel.drm.base.backend->fill (shader.target,
|
||||
shader.op,
|
||||
mask != NULL ? &_cairo_pattern_white.base : source,
|
||||
&path,
|
||||
CAIRO_FILL_RULE_WINDING,
|
||||
0,
|
||||
scaled_font->options.antialias,
|
||||
clip);
|
||||
}
|
||||
_cairo_path_fixed_fini (&path);
|
||||
}
|
||||
|
||||
if (mask != NULL) {
|
||||
if (likely (status == CAIRO_STATUS_SUCCESS)) {
|
||||
status = i915_surface_mask_internal (surface, op, source, mask,
|
||||
clip, &extents);
|
||||
}
|
||||
cairo_surface_finish (&mask->intel.drm.base);
|
||||
cairo_surface_destroy (&mask->intel.drm.base);
|
||||
}
|
||||
|
||||
if (have_clip)
|
||||
_cairo_clip_fini (&local_clip);
|
||||
|
||||
return status;
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,799 +0,0 @@
|
|||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Intel Corporation
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Red Hat, Inc.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Chris Wilson <chris@chris-wilson.co.uk>
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
|
||||
#include "cairo-composite-rectangles-private.h"
|
||||
#include "cairo-boxes-private.h"
|
||||
#include "cairo-error-private.h"
|
||||
#include "cairo-drm-i915-private.h"
|
||||
|
||||
/* Operates in either immediate or retained mode.
|
||||
* When given a clip region we record the sequence of vbo and then
|
||||
* replay them for each clip rectangle, otherwise we simply emit
|
||||
* the vbo straight into the command stream.
|
||||
*/
|
||||
|
||||
typedef struct _i915_spans i915_spans_t;
|
||||
|
||||
typedef float *
|
||||
(*i915_get_rectangle_func_t) (i915_spans_t *spans);
|
||||
|
||||
typedef void
|
||||
(*i915_span_func_t) (i915_spans_t *spans,
|
||||
int x0, int x1, int y0, int y1,
|
||||
int alpha);
|
||||
|
||||
struct _i915_spans {
|
||||
cairo_span_renderer_t renderer;
|
||||
|
||||
i915_device_t *device;
|
||||
|
||||
int xmin, xmax;
|
||||
cairo_bool_t is_bounded;
|
||||
const cairo_rectangle_int_t *extents;
|
||||
|
||||
i915_get_rectangle_func_t get_rectangle;
|
||||
i915_span_func_t span;
|
||||
i915_shader_t shader;
|
||||
|
||||
cairo_region_t *clip_region;
|
||||
cairo_bool_t need_clip_surface;
|
||||
|
||||
struct vbo {
|
||||
struct vbo *next;
|
||||
intel_bo_t *bo;
|
||||
unsigned int count;
|
||||
} head, *tail;
|
||||
|
||||
unsigned int vbo_offset;
|
||||
float *vbo_base;
|
||||
};
|
||||
|
||||
static float *
|
||||
i915_emit_rectangle (i915_spans_t *spans)
|
||||
{
|
||||
return i915_add_rectangle (spans->device);
|
||||
}
|
||||
|
||||
static float *
|
||||
i915_accumulate_rectangle (i915_spans_t *spans)
|
||||
{
|
||||
float *vertices;
|
||||
uint32_t size;
|
||||
|
||||
size = spans->device->rectangle_size;
|
||||
if (unlikely (spans->vbo_offset + size > I915_VBO_SIZE)) {
|
||||
struct vbo *vbo;
|
||||
|
||||
vbo = _cairo_malloc (sizeof (struct vbo));
|
||||
if (unlikely (vbo == NULL)) {
|
||||
/* throw error! */
|
||||
}
|
||||
|
||||
spans->tail->next = vbo;
|
||||
spans->tail = vbo;
|
||||
|
||||
vbo->next = NULL;
|
||||
vbo->bo = intel_bo_create (&spans->device->intel,
|
||||
I915_VBO_SIZE, I915_VBO_SIZE,
|
||||
FALSE, I915_TILING_NONE, 0);
|
||||
vbo->count = 0;
|
||||
|
||||
spans->vbo_offset = 0;
|
||||
spans->vbo_base = intel_bo_map (&spans->device->intel, vbo->bo);
|
||||
}
|
||||
|
||||
vertices = spans->vbo_base + spans->vbo_offset;
|
||||
spans->vbo_offset += size;
|
||||
spans->tail->count += 3;
|
||||
|
||||
return vertices;
|
||||
}
|
||||
|
||||
static void
|
||||
i915_span_zero (i915_spans_t *spans,
|
||||
int x0, int x1, int y0, int y1,
|
||||
int alpha)
|
||||
{
|
||||
float *vertices;
|
||||
|
||||
vertices = spans->get_rectangle (spans);
|
||||
|
||||
*vertices++ = x1;
|
||||
*vertices++ = y1;
|
||||
|
||||
*vertices++ = x0;
|
||||
*vertices++ = y1;
|
||||
|
||||
*vertices++ = x0;
|
||||
*vertices++ = y0;
|
||||
}
|
||||
|
||||
static void
|
||||
i915_span_constant (i915_spans_t *spans,
|
||||
int x0, int x1, int y0, int y1,
|
||||
int alpha)
|
||||
{
|
||||
float *vertices;
|
||||
float a = alpha / 255.;
|
||||
|
||||
vertices = spans->get_rectangle (spans);
|
||||
|
||||
*vertices++ = x1;
|
||||
*vertices++ = y1;
|
||||
*vertices++ = a;
|
||||
|
||||
*vertices++ = x0;
|
||||
*vertices++ = y1;
|
||||
*vertices++ = a;
|
||||
|
||||
*vertices++ = x0;
|
||||
*vertices++ = y0;
|
||||
*vertices++ = a;
|
||||
}
|
||||
|
||||
static void
|
||||
i915_span_linear (i915_spans_t *spans,
|
||||
int x0, int x1, int y0, int y1,
|
||||
int alpha)
|
||||
{
|
||||
float *vertices;
|
||||
float a = alpha / 255.;
|
||||
double s, t;
|
||||
|
||||
vertices = spans->get_rectangle (spans);
|
||||
|
||||
*vertices++ = x1;
|
||||
*vertices++ = y1;
|
||||
s = x0, t = y0;
|
||||
*vertices++ = i915_shader_linear_texcoord (&spans->shader.source.linear, s, t);
|
||||
*vertices++ = a;
|
||||
|
||||
*vertices++ = x0;
|
||||
*vertices++ = y1;
|
||||
s = x1, t = y0;
|
||||
*vertices++ = i915_shader_linear_texcoord (&spans->shader.source.linear, s, t);
|
||||
*vertices++ = a;
|
||||
|
||||
*vertices++ = x0;
|
||||
*vertices++ = y0;
|
||||
s = x1, t = y1;
|
||||
*vertices++ = i915_shader_linear_texcoord (&spans->shader.source.linear, s, t);
|
||||
*vertices++ = a;
|
||||
}
|
||||
|
||||
static void
|
||||
i915_span_texture (i915_spans_t *spans,
|
||||
int x0, int x1, int y0, int y1,
|
||||
int alpha)
|
||||
{
|
||||
float *vertices;
|
||||
float a = alpha / 255.;
|
||||
double s, t;
|
||||
|
||||
vertices = spans->get_rectangle (spans);
|
||||
|
||||
*vertices++ = x1;
|
||||
*vertices++ = y1;
|
||||
s = x0, t = y0;
|
||||
cairo_matrix_transform_point (&spans->shader.source.base.matrix, &s, &t);
|
||||
*vertices++ = s; *vertices++ = t;
|
||||
*vertices++ = a;
|
||||
|
||||
*vertices++ = x0;
|
||||
*vertices++ = y1;
|
||||
s = x1, t = y0;
|
||||
cairo_matrix_transform_point (&spans->shader.source.base.matrix, &s, &t);
|
||||
*vertices++ = s; *vertices++ = t;
|
||||
*vertices++ = a;
|
||||
|
||||
*vertices++ = x0;
|
||||
*vertices++ = y0;
|
||||
s = x1, t = y1;
|
||||
cairo_matrix_transform_point (&spans->shader.source.base.matrix, &s, &t);
|
||||
*vertices++ = s; *vertices++ = t;
|
||||
*vertices++ = a;
|
||||
}
|
||||
|
||||
static void
|
||||
i915_span_texture16 (i915_spans_t *spans,
|
||||
int x0, int x1, int y0, int y1, int alpha)
|
||||
{
|
||||
float *vertices;
|
||||
float a = alpha / 255.;
|
||||
double s, t;
|
||||
|
||||
vertices = spans->get_rectangle (spans);
|
||||
|
||||
*vertices++ = x1;
|
||||
*vertices++ = y1;
|
||||
s = x0, t = y0;
|
||||
cairo_matrix_transform_point (&spans->shader.source.base.matrix, &s, &t);
|
||||
*vertices++ = texcoord_2d_16 (s, t);
|
||||
*vertices++ = a;
|
||||
|
||||
*vertices++ = x0;
|
||||
*vertices++ = y1;
|
||||
s = x1, t = y0;
|
||||
cairo_matrix_transform_point (&spans->shader.source.base.matrix, &s, &t);
|
||||
*vertices++ = texcoord_2d_16 (s, t);
|
||||
*vertices++ = a;
|
||||
|
||||
*vertices++ = x0;
|
||||
*vertices++ = y0;
|
||||
s = x1, t = y1;
|
||||
cairo_matrix_transform_point (&spans->shader.source.base.matrix, &s, &t);
|
||||
*vertices++ = texcoord_2d_16 (s, t);
|
||||
*vertices++ = a;
|
||||
}
|
||||
|
||||
static void
|
||||
i915_span_generic (i915_spans_t *spans,
|
||||
int x0, int x1, int y0, int y1, int alpha)
|
||||
{
|
||||
double s, t;
|
||||
float *vertices;
|
||||
float a = alpha / 255.;
|
||||
|
||||
/* Each vertex is:
|
||||
* 2 vertex coordinates
|
||||
* [0-2] source texture coordinates
|
||||
* 1 alpha value.
|
||||
* [0,2] clip mask coordinates
|
||||
*/
|
||||
|
||||
vertices = spans->get_rectangle (spans);
|
||||
|
||||
/* bottom right */
|
||||
*vertices++ = x1; *vertices++ = y1;
|
||||
s = x1, t = y1;
|
||||
switch (spans->shader.source.type.vertex) {
|
||||
case VS_ZERO:
|
||||
case VS_CONSTANT:
|
||||
break;
|
||||
case VS_LINEAR:
|
||||
*vertices++ = i915_shader_linear_texcoord (&spans->shader.source.linear, s, t);
|
||||
break;
|
||||
case VS_TEXTURE:
|
||||
cairo_matrix_transform_point (&spans->shader.source.base.matrix, &s, &t);
|
||||
*vertices++ = s; *vertices++ = t;
|
||||
break;
|
||||
case VS_TEXTURE_16:
|
||||
cairo_matrix_transform_point (&spans->shader.source.base.matrix, &s, &t);
|
||||
*vertices++ = texcoord_2d_16 (s, t);
|
||||
break;
|
||||
}
|
||||
*vertices++ = a;
|
||||
if (spans->need_clip_surface) {
|
||||
s = x1, t = y1;
|
||||
cairo_matrix_transform_point (&spans->shader.clip.base.matrix, &s, &t);
|
||||
*vertices++ = texcoord_2d_16 (s, t);
|
||||
}
|
||||
if (spans->shader.need_combine) {
|
||||
s = x1, t = y1;
|
||||
cairo_matrix_transform_point (&spans->shader.dst.base.matrix, &s, &t);
|
||||
*vertices++ = texcoord_2d_16 (s, t);
|
||||
}
|
||||
|
||||
/* bottom left */
|
||||
*vertices++ = x0; *vertices++ = y1;
|
||||
s = x0, t = y1;
|
||||
switch (spans->shader.source.type.vertex) {
|
||||
case VS_ZERO:
|
||||
case VS_CONSTANT:
|
||||
break;
|
||||
case VS_LINEAR:
|
||||
*vertices++ = i915_shader_linear_texcoord (&spans->shader.source.linear, s, t);
|
||||
break;
|
||||
case VS_TEXTURE:
|
||||
cairo_matrix_transform_point (&spans->shader.source.base.matrix, &s, &t);
|
||||
*vertices++ = s; *vertices++ = t;
|
||||
break;
|
||||
case VS_TEXTURE_16:
|
||||
cairo_matrix_transform_point (&spans->shader.source.base.matrix, &s, &t);
|
||||
*vertices++ = texcoord_2d_16 (s, t);
|
||||
break;
|
||||
}
|
||||
*vertices++ = a;
|
||||
if (spans->need_clip_surface) {
|
||||
s = x0, t = y1;
|
||||
cairo_matrix_transform_point (&spans->shader.clip.base.matrix, &s, &t);
|
||||
*vertices++ = texcoord_2d_16 (s, t);
|
||||
}
|
||||
if (spans->shader.need_combine) {
|
||||
s = x0, t = y1;
|
||||
cairo_matrix_transform_point (&spans->shader.dst.base.matrix, &s, &t);
|
||||
*vertices++ = texcoord_2d_16 (s, t);
|
||||
}
|
||||
|
||||
/* top left */
|
||||
*vertices++ = x0; *vertices++ = y0;
|
||||
s = x0, t = y0;
|
||||
switch (spans->shader.source.type.vertex) {
|
||||
case VS_ZERO:
|
||||
case VS_CONSTANT:
|
||||
break;
|
||||
case VS_LINEAR:
|
||||
*vertices++ = i915_shader_linear_texcoord (&spans->shader.source.linear, s, t);
|
||||
break;
|
||||
case VS_TEXTURE:
|
||||
cairo_matrix_transform_point (&spans->shader.source.base.matrix, &s, &t);
|
||||
*vertices++ = s; *vertices++ = t;
|
||||
break;
|
||||
case VS_TEXTURE_16:
|
||||
cairo_matrix_transform_point (&spans->shader.source.base.matrix, &s, &t);
|
||||
*vertices++ = texcoord_2d_16 (s, t);
|
||||
break;
|
||||
}
|
||||
*vertices++ = a;
|
||||
if (spans->need_clip_surface) {
|
||||
s = x0, t = y0;
|
||||
cairo_matrix_transform_point (&spans->shader.clip.base.matrix, &s, &t);
|
||||
*vertices++ = texcoord_2d_16 (s, t);
|
||||
}
|
||||
if (spans->shader.need_combine) {
|
||||
s = x0, t = y0;
|
||||
cairo_matrix_transform_point (&spans->shader.dst.base.matrix, &s, &t);
|
||||
*vertices++ = texcoord_2d_16 (s, t);
|
||||
}
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
i915_zero_spans_mono (void *abstract_renderer,
|
||||
int y, int height,
|
||||
const cairo_half_open_span_t *half,
|
||||
unsigned num_spans)
|
||||
{
|
||||
i915_spans_t *spans = abstract_renderer;
|
||||
int x0, x1;
|
||||
|
||||
if (num_spans == 0)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
do {
|
||||
while (num_spans && half[0].coverage < 128)
|
||||
half++, num_spans--;
|
||||
if (num_spans == 0)
|
||||
break;
|
||||
|
||||
x0 = x1 = half[0].x;
|
||||
while (num_spans--) {
|
||||
half++;
|
||||
|
||||
x1 = half[0].x;
|
||||
if (half[0].coverage < 128)
|
||||
break;
|
||||
}
|
||||
|
||||
i915_span_zero (spans,
|
||||
x0, x1,
|
||||
y, y + height,
|
||||
0);
|
||||
} while (num_spans);
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
i915_zero_spans (void *abstract_renderer,
|
||||
int y, int height,
|
||||
const cairo_half_open_span_t *half,
|
||||
unsigned num_spans)
|
||||
{
|
||||
i915_spans_t *spans = abstract_renderer;
|
||||
int x0, x1;
|
||||
|
||||
if (num_spans == 0)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
do {
|
||||
while (num_spans && half[0].coverage == 0)
|
||||
half++, num_spans--;
|
||||
if (num_spans == 0)
|
||||
break;
|
||||
|
||||
x0 = x1 = half[0].x;
|
||||
while (num_spans--) {
|
||||
half++;
|
||||
|
||||
x1 = half[0].x;
|
||||
if (half[0].coverage == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
i915_span_zero (spans,
|
||||
x0, x1,
|
||||
y, y + height,
|
||||
0);
|
||||
} while (num_spans);
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
i915_bounded_spans_mono (void *abstract_renderer,
|
||||
int y, int height,
|
||||
const cairo_half_open_span_t *half,
|
||||
unsigned num_spans)
|
||||
{
|
||||
i915_spans_t *spans = abstract_renderer;
|
||||
|
||||
if (num_spans == 0)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
do {
|
||||
if (half[0].coverage >= 128) {
|
||||
spans->span (spans,
|
||||
half[0].x, half[1].x,
|
||||
y, y + height,
|
||||
255);
|
||||
}
|
||||
half++;
|
||||
} while (--num_spans > 1);
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
i915_bounded_spans (void *abstract_renderer,
|
||||
int y, int height,
|
||||
const cairo_half_open_span_t *half,
|
||||
unsigned num_spans)
|
||||
{
|
||||
i915_spans_t *spans = abstract_renderer;
|
||||
|
||||
if (num_spans == 0)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
do {
|
||||
if (half[0].coverage) {
|
||||
spans->span (spans,
|
||||
half[0].x, half[1].x,
|
||||
y, y + height,
|
||||
half[0].coverage);
|
||||
}
|
||||
half++;
|
||||
} while (--num_spans > 1);
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
i915_unbounded_spans (void *abstract_renderer,
|
||||
int y, int height,
|
||||
const cairo_half_open_span_t *half,
|
||||
unsigned num_spans)
|
||||
{
|
||||
i915_spans_t *spans = abstract_renderer;
|
||||
|
||||
if (num_spans == 0) {
|
||||
spans->span (spans,
|
||||
spans->xmin, spans->xmax,
|
||||
y, y + height,
|
||||
0);
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (half[0].x != spans->xmin) {
|
||||
spans->span (spans,
|
||||
spans->xmin, half[0].x,
|
||||
y, y + height,
|
||||
0);
|
||||
}
|
||||
|
||||
do {
|
||||
spans->span (spans,
|
||||
half[0].x, half[1].x,
|
||||
y, y + height,
|
||||
half[0].coverage);
|
||||
half++;
|
||||
} while (--num_spans > 1);
|
||||
|
||||
if (half[0].x != spans->xmax) {
|
||||
spans->span (spans,
|
||||
half[0].x, spans->xmax,
|
||||
y, y + height,
|
||||
0);
|
||||
}
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
i915_unbounded_spans_mono (void *abstract_renderer,
|
||||
int y, int height,
|
||||
const cairo_half_open_span_t *half,
|
||||
unsigned num_spans)
|
||||
{
|
||||
i915_spans_t *spans = abstract_renderer;
|
||||
|
||||
if (num_spans == 0) {
|
||||
spans->span (spans,
|
||||
spans->xmin, spans->xmax,
|
||||
y, y + height,
|
||||
0);
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (half[0].x != spans->xmin) {
|
||||
spans->span (spans,
|
||||
spans->xmin, half[0].x,
|
||||
y, y + height,
|
||||
0);
|
||||
}
|
||||
|
||||
do {
|
||||
int alpha = 0;
|
||||
if (half[0].coverage >= 128)
|
||||
alpha = 255;
|
||||
spans->span (spans,
|
||||
half[0].x, half[1].x,
|
||||
y, y + height,
|
||||
alpha);
|
||||
half++;
|
||||
} while (--num_spans > 1);
|
||||
|
||||
if (half[0].x != spans->xmax) {
|
||||
spans->span (spans,
|
||||
half[0].x, spans->xmax,
|
||||
y, y + height,
|
||||
0);
|
||||
}
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
i915_spans_init (i915_spans_t *spans,
|
||||
i915_surface_t *dst,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *pattern,
|
||||
cairo_antialias_t antialias,
|
||||
cairo_clip_t *clip,
|
||||
double opacity,
|
||||
const cairo_composite_rectangles_t *extents)
|
||||
{
|
||||
cairo_status_t status;
|
||||
|
||||
spans->device = (i915_device_t *) dst->intel.drm.base.device;
|
||||
|
||||
spans->is_bounded = extents->is_bounded;
|
||||
if (extents->is_bounded) {
|
||||
if (antialias == CAIRO_ANTIALIAS_NONE)
|
||||
spans->renderer.render_rows = i915_bounded_spans_mono;
|
||||
else
|
||||
spans->renderer.render_rows = i915_bounded_spans;
|
||||
|
||||
spans->extents = &extents->bounded;
|
||||
} else {
|
||||
if (antialias == CAIRO_ANTIALIAS_NONE)
|
||||
spans->renderer.render_rows = i915_unbounded_spans_mono;
|
||||
else
|
||||
spans->renderer.render_rows = i915_unbounded_spans;
|
||||
|
||||
spans->extents = &extents->unbounded;
|
||||
}
|
||||
spans->xmin = spans->extents->x;
|
||||
spans->xmax = spans->extents->x + spans->extents->width;
|
||||
|
||||
spans->clip_region = NULL;
|
||||
spans->need_clip_surface = FALSE;
|
||||
if (clip != NULL) {
|
||||
cairo_region_t *clip_region = NULL;
|
||||
|
||||
status = _cairo_clip_get_region (clip, &clip_region);
|
||||
assert (status == CAIRO_STATUS_SUCCESS || status == CAIRO_INT_STATUS_UNSUPPORTED);
|
||||
|
||||
if (clip_region != NULL && cairo_region_num_rectangles (clip_region) == 1)
|
||||
clip_region = NULL;
|
||||
|
||||
spans->clip_region = clip_region;
|
||||
spans->need_clip_surface = status == CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
}
|
||||
|
||||
spans->head.next = NULL;
|
||||
spans->head.bo = NULL;
|
||||
spans->head.count = 0;
|
||||
spans->tail = &spans->head;
|
||||
|
||||
if (spans->clip_region == NULL) {
|
||||
spans->get_rectangle = i915_emit_rectangle;
|
||||
} else {
|
||||
assert (! extents->is_bounded);
|
||||
spans->get_rectangle = i915_accumulate_rectangle;
|
||||
spans->head.bo = intel_bo_create (&spans->device->intel,
|
||||
I915_VBO_SIZE, I915_VBO_SIZE,
|
||||
FALSE, I915_TILING_NONE, 0);
|
||||
if (unlikely (spans->head.bo == NULL))
|
||||
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
spans->vbo_base = intel_bo_map (&spans->device->intel, spans->head.bo);
|
||||
}
|
||||
spans->vbo_offset = 0;
|
||||
|
||||
i915_shader_init (&spans->shader, dst, op, opacity);
|
||||
if (spans->need_clip_surface)
|
||||
i915_shader_set_clip (&spans->shader, clip);
|
||||
|
||||
status = i915_shader_acquire_pattern (&spans->shader, &spans->shader.source,
|
||||
pattern, &extents->bounded);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
i915_spans_fini (i915_spans_t *spans)
|
||||
{
|
||||
i915_shader_fini (&spans->shader);
|
||||
|
||||
if (spans->head.bo != NULL) {
|
||||
struct vbo *vbo, *next;
|
||||
|
||||
intel_bo_destroy (&spans->device->intel, spans->head.bo);
|
||||
for (vbo = spans->head.next; vbo != NULL; vbo = next) {
|
||||
next = vbo->next;
|
||||
intel_bo_destroy (&spans->device->intel, vbo->bo);
|
||||
free (vbo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cairo_status_t
|
||||
i915_clip_and_composite_spans (i915_surface_t *dst,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *pattern,
|
||||
cairo_antialias_t antialias,
|
||||
i915_spans_func_t draw_func,
|
||||
void *draw_closure,
|
||||
const cairo_composite_rectangles_t*extents,
|
||||
cairo_clip_t *clip,
|
||||
double opacity)
|
||||
{
|
||||
i915_spans_t spans;
|
||||
i915_device_t *device;
|
||||
cairo_status_t status;
|
||||
struct vbo *vbo;
|
||||
|
||||
if (i915_surface_needs_tiling (dst)) {
|
||||
ASSERT_NOT_REACHED;
|
||||
return CAIRO_INT_STATUS_UNSUPPORTED;
|
||||
}
|
||||
|
||||
if (op == CAIRO_OPERATOR_CLEAR) {
|
||||
pattern = &_cairo_pattern_white.base;
|
||||
op = CAIRO_OPERATOR_DEST_OUT;
|
||||
}
|
||||
|
||||
status = i915_spans_init (&spans, dst, op, pattern, antialias, clip, opacity, extents);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
|
||||
spans.shader.mask.base.texfmt = TEXCOORDFMT_1D;
|
||||
spans.shader.mask.base.content = CAIRO_CONTENT_ALPHA;
|
||||
spans.shader.mask.type.fragment = FS_SPANS;
|
||||
|
||||
status = cairo_device_acquire (dst->intel.drm.base.device);
|
||||
if (unlikely (status))
|
||||
goto CLEANUP_SPANS;
|
||||
|
||||
if (dst->deferred_clear) {
|
||||
status = i915_surface_clear (dst);
|
||||
if (unlikely (status))
|
||||
goto CLEANUP_SPANS;
|
||||
}
|
||||
|
||||
device = i915_device (dst);
|
||||
status = i915_shader_commit (&spans.shader, device);
|
||||
if (unlikely (status))
|
||||
goto CLEANUP_DEVICE;
|
||||
|
||||
if (! spans.shader.need_combine && ! spans.need_clip_surface) {
|
||||
switch (spans.shader.source.type.vertex) {
|
||||
case VS_ZERO:
|
||||
spans.span = i915_span_zero;
|
||||
if (extents->is_bounded) {
|
||||
if (antialias == CAIRO_ANTIALIAS_NONE)
|
||||
spans.renderer.render_rows = i915_zero_spans_mono;
|
||||
else
|
||||
spans.renderer.render_rows = i915_zero_spans;
|
||||
}
|
||||
break;
|
||||
case VS_CONSTANT:
|
||||
spans.span = i915_span_constant;
|
||||
break;
|
||||
case VS_LINEAR:
|
||||
spans.span = i915_span_linear;
|
||||
break;
|
||||
case VS_TEXTURE:
|
||||
spans.span = i915_span_texture;
|
||||
break;
|
||||
case VS_TEXTURE_16:
|
||||
spans.span = i915_span_texture16;
|
||||
break;
|
||||
default:
|
||||
spans.span = i915_span_generic;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
spans.span = i915_span_generic;
|
||||
}
|
||||
|
||||
status = draw_func (draw_closure, &spans.renderer, spans.extents);
|
||||
if (spans.clip_region != NULL && status == CAIRO_STATUS_SUCCESS) {
|
||||
i915_vbo_finish (device);
|
||||
|
||||
OUT_DWORD (_3DSTATE_SCISSOR_ENABLE_CMD | ENABLE_SCISSOR_RECT);
|
||||
for (vbo = &spans.head; vbo != NULL; vbo = vbo->next) {
|
||||
int i, num_rectangles;
|
||||
|
||||
/* XXX require_space & batch_flush */
|
||||
|
||||
OUT_DWORD (_3DSTATE_LOAD_STATE_IMMEDIATE_1 | I1_LOAD_S (0) | I1_LOAD_S (1) | 1);
|
||||
i915_batch_emit_reloc (device, vbo->bo, 0,
|
||||
I915_GEM_DOMAIN_VERTEX, 0,
|
||||
FALSE);
|
||||
OUT_DWORD ((device->floats_per_vertex << S1_VERTEX_WIDTH_SHIFT) |
|
||||
(device->floats_per_vertex << S1_VERTEX_PITCH_SHIFT) |
|
||||
vbo->count);
|
||||
|
||||
num_rectangles = cairo_region_num_rectangles (spans.clip_region);
|
||||
for (i = 0; i < num_rectangles; i++) {
|
||||
cairo_rectangle_int_t rect;
|
||||
|
||||
cairo_region_get_rectangle (spans.clip_region, i, &rect);
|
||||
|
||||
OUT_DWORD (_3DSTATE_SCISSOR_RECT_0_CMD);
|
||||
OUT_DWORD (SCISSOR_RECT_0_XMIN (rect.x) |
|
||||
SCISSOR_RECT_0_YMIN (rect.y));
|
||||
OUT_DWORD (SCISSOR_RECT_0_XMAX (rect.x + rect.width) |
|
||||
SCISSOR_RECT_0_YMAX (rect.y + rect.height));
|
||||
|
||||
OUT_DWORD (PRIM3D_RECTLIST | PRIM3D_INDIRECT_SEQUENTIAL | vbo->count);
|
||||
OUT_DWORD (0);
|
||||
}
|
||||
}
|
||||
OUT_DWORD (_3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT);
|
||||
}
|
||||
|
||||
CLEANUP_DEVICE:
|
||||
cairo_device_release (dst->intel.drm.base.device);
|
||||
CLEANUP_SPANS:
|
||||
i915_spans_fini (&spans);
|
||||
|
||||
return status;
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,506 +0,0 @@
|
|||
/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
|
||||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Intel Corporation
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Red Hat, Inc.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Chris Wilson <chris@chris-wilson.co.uk>
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
|
||||
#include "cairo-composite-rectangles-private.h"
|
||||
#include "cairo-drm-i965-private.h"
|
||||
#include "cairo-error-private.h"
|
||||
#include "cairo-rtree-private.h"
|
||||
|
||||
typedef struct _i965_glyphs i965_glyphs_t;
|
||||
|
||||
typedef float *
|
||||
(*i965_get_rectangle_func_t) (i965_glyphs_t *glyphs);
|
||||
|
||||
struct _i965_glyphs {
|
||||
i965_get_rectangle_func_t get_rectangle;
|
||||
i965_shader_t shader;
|
||||
|
||||
struct i965_vbo head, *tail;
|
||||
|
||||
unsigned int vbo_offset;
|
||||
float *vbo_base;
|
||||
};
|
||||
|
||||
static float *
|
||||
i965_glyphs_emit_rectangle (i965_glyphs_t *glyphs)
|
||||
{
|
||||
return i965_add_rectangle (glyphs->shader.device);
|
||||
}
|
||||
|
||||
static float *
|
||||
i965_glyphs_accumulate_rectangle (i965_glyphs_t *glyphs)
|
||||
{
|
||||
float *vertices;
|
||||
uint32_t size;
|
||||
|
||||
size = glyphs->shader.device->rectangle_size;
|
||||
if (unlikely (glyphs->vbo_offset + size > I965_VERTEX_SIZE)) {
|
||||
struct i965_vbo *vbo;
|
||||
|
||||
vbo = _cairo_malloc (sizeof (struct i965_vbo));
|
||||
if (unlikely (vbo == NULL)) {
|
||||
/* throw error! */
|
||||
}
|
||||
|
||||
glyphs->tail->next = vbo;
|
||||
glyphs->tail = vbo;
|
||||
|
||||
vbo->next = NULL;
|
||||
vbo->bo = intel_bo_create (&glyphs->shader.device->intel,
|
||||
I965_VERTEX_SIZE, I965_VERTEX_SIZE,
|
||||
FALSE, I915_TILING_NONE, 0);
|
||||
vbo->count = 0;
|
||||
|
||||
glyphs->vbo_offset = 0;
|
||||
glyphs->vbo_base = intel_bo_map (&glyphs->shader.device->intel, vbo->bo);
|
||||
}
|
||||
|
||||
vertices = glyphs->vbo_base + glyphs->vbo_offset;
|
||||
glyphs->vbo_offset += size;
|
||||
glyphs->tail->count += 3;
|
||||
|
||||
return vertices;
|
||||
}
|
||||
|
||||
static void
|
||||
i965_add_glyph_rectangle (i965_glyphs_t *glyphs,
|
||||
int x1, int y1,
|
||||
int x2, int y2,
|
||||
intel_glyph_t *glyph)
|
||||
{
|
||||
float *v;
|
||||
|
||||
/* Each vertex is:
|
||||
* 2 vertex coordinates
|
||||
* 1 glyph texture coordinate
|
||||
*/
|
||||
|
||||
v = glyphs->get_rectangle (glyphs);
|
||||
|
||||
/* bottom right */
|
||||
*v++ = x2; *v++ = y2;
|
||||
*v++ = glyph->texcoord[0];
|
||||
|
||||
/* bottom left */
|
||||
*v++ = x1; *v++ = y2;
|
||||
*v++ = glyph->texcoord[1];
|
||||
|
||||
/* top left */
|
||||
*v++ = x1; *v++ = y1;
|
||||
*v++ = glyph->texcoord[2];
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
i965_surface_mask_internal (i965_surface_t *dst,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
i965_surface_t *mask,
|
||||
cairo_clip_t *clip,
|
||||
const cairo_composite_rectangles_t *extents)
|
||||
{
|
||||
i965_device_t *device;
|
||||
i965_shader_t shader;
|
||||
cairo_region_t *clip_region = NULL;
|
||||
cairo_status_t status;
|
||||
|
||||
i965_shader_init (&shader, dst, op);
|
||||
|
||||
status = i965_shader_acquire_pattern (&shader, &shader.source,
|
||||
source, &extents->bounded);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
|
||||
shader.mask.type.vertex = VS_NONE;
|
||||
shader.mask.type.fragment = FS_SURFACE;
|
||||
shader.mask.base.content = mask->intel.drm.base.content;
|
||||
shader.mask.base.filter = i965_filter (CAIRO_FILTER_NEAREST);
|
||||
shader.mask.base.extend = i965_extend (CAIRO_EXTEND_NONE);
|
||||
|
||||
cairo_matrix_init_translate (&shader.mask.base.matrix,
|
||||
-extents->bounded.x,
|
||||
-extents->bounded.y);
|
||||
cairo_matrix_scale (&shader.mask.base.matrix,
|
||||
1. / mask->intel.drm.width,
|
||||
1. / mask->intel.drm.height);
|
||||
|
||||
shader.mask.base.bo = to_intel_bo (mask->intel.drm.bo);
|
||||
shader.mask.base.format = mask->intel.drm.format;
|
||||
shader.mask.base.width = mask->intel.drm.width;
|
||||
shader.mask.base.height = mask->intel.drm.height;
|
||||
shader.mask.base.stride = mask->intel.drm.stride;
|
||||
|
||||
if (clip != NULL) {
|
||||
status = _cairo_clip_get_region (clip, &clip_region);
|
||||
assert (status == CAIRO_STATUS_SUCCESS || status == CAIRO_INT_STATUS_UNSUPPORTED);
|
||||
|
||||
if (clip_region != NULL && cairo_region_num_rectangles (clip_region) == 1)
|
||||
clip_region = NULL;
|
||||
|
||||
if (status == CAIRO_INT_STATUS_UNSUPPORTED)
|
||||
i965_shader_set_clip (&shader, clip);
|
||||
}
|
||||
|
||||
status = cairo_device_acquire (dst->intel.drm.base.device);
|
||||
if (unlikely (status))
|
||||
goto CLEANUP_SHADER;
|
||||
|
||||
device = i965_device (dst);
|
||||
|
||||
status = i965_shader_commit (&shader, device);
|
||||
if (unlikely (status))
|
||||
goto CLEANUP_DEVICE;
|
||||
|
||||
if (clip_region != NULL) {
|
||||
unsigned int n, num_rectangles;
|
||||
|
||||
num_rectangles = cairo_region_num_rectangles (clip_region);
|
||||
for (n = 0; n < num_rectangles; n++) {
|
||||
cairo_rectangle_int_t rect;
|
||||
|
||||
cairo_region_get_rectangle (clip_region, n, &rect);
|
||||
|
||||
i965_shader_add_rectangle (&shader,
|
||||
rect.x, rect.y,
|
||||
rect.width, rect.height);
|
||||
}
|
||||
} else {
|
||||
i965_shader_add_rectangle (&shader,
|
||||
extents->bounded.x,
|
||||
extents->bounded.y,
|
||||
extents->bounded.width,
|
||||
extents->bounded.height);
|
||||
}
|
||||
|
||||
if (! extents->is_bounded)
|
||||
status = i965_fixup_unbounded (dst, extents, clip);
|
||||
|
||||
CLEANUP_DEVICE:
|
||||
cairo_device_release (&device->intel.base.base);
|
||||
CLEANUP_SHADER:
|
||||
i965_shader_fini (&shader);
|
||||
return status;
|
||||
}
|
||||
|
||||
cairo_int_status_t
|
||||
i965_surface_glyphs (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_glyph_t *g,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font,
|
||||
cairo_clip_t *clip,
|
||||
int *num_remaining)
|
||||
{
|
||||
i965_surface_t *surface = abstract_surface;
|
||||
i965_surface_t *mask = NULL;
|
||||
i965_device_t *device;
|
||||
i965_glyphs_t glyphs;
|
||||
cairo_composite_rectangles_t extents;
|
||||
cairo_clip_t local_clip;
|
||||
cairo_bool_t have_clip = FALSE;
|
||||
cairo_bool_t overlap;
|
||||
cairo_region_t *clip_region = NULL;
|
||||
intel_bo_t *last_bo = NULL;
|
||||
cairo_scaled_glyph_t *glyph_cache[64];
|
||||
cairo_status_t status;
|
||||
int mask_x = 0, mask_y = 0;
|
||||
int i = 0;
|
||||
|
||||
*num_remaining = 0;
|
||||
status = _cairo_composite_rectangles_init_for_glyphs (&extents,
|
||||
surface->intel.drm.width,
|
||||
surface->intel.drm.height,
|
||||
op, source,
|
||||
scaled_font,
|
||||
g, num_glyphs,
|
||||
clip,
|
||||
&overlap);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
|
||||
if (clip != NULL && _cairo_clip_contains_rectangle (clip, &extents.mask))
|
||||
clip = NULL;
|
||||
|
||||
if (clip != NULL && extents.is_bounded) {
|
||||
clip = _cairo_clip_init_copy (&local_clip, clip);
|
||||
status = _cairo_clip_rectangle (clip, &extents.bounded);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
|
||||
have_clip = TRUE;
|
||||
}
|
||||
|
||||
if (overlap || ! extents.is_bounded) {
|
||||
cairo_format_t format;
|
||||
|
||||
format = CAIRO_FORMAT_A8;
|
||||
if (scaled_font->options.antialias == CAIRO_ANTIALIAS_SUBPIXEL)
|
||||
format = CAIRO_FORMAT_ARGB32;
|
||||
|
||||
mask = (i965_surface_t *)
|
||||
i965_surface_create_internal (&i965_device (surface)->intel.base,
|
||||
format,
|
||||
extents.bounded.width,
|
||||
extents.bounded.height,
|
||||
I965_TILING_DEFAULT,
|
||||
TRUE);
|
||||
if (unlikely (mask->intel.drm.base.status))
|
||||
return mask->intel.drm.base.status;
|
||||
|
||||
status = _cairo_surface_paint (&mask->intel.drm.base,
|
||||
CAIRO_OPERATOR_CLEAR,
|
||||
&_cairo_pattern_clear.base,
|
||||
NULL);
|
||||
if (unlikely (status)) {
|
||||
cairo_surface_destroy (&mask->intel.drm.base);
|
||||
return status;
|
||||
}
|
||||
|
||||
i965_shader_init (&glyphs.shader, mask, CAIRO_OPERATOR_ADD);
|
||||
|
||||
status = i965_shader_acquire_pattern (&glyphs.shader, &glyphs.shader.source,
|
||||
&_cairo_pattern_white.base,
|
||||
&extents.bounded);
|
||||
if (unlikely (status)) {
|
||||
cairo_surface_destroy (&mask->intel.drm.base);
|
||||
return status;
|
||||
}
|
||||
|
||||
mask_x = -extents.bounded.x;
|
||||
mask_y = -extents.bounded.y;
|
||||
} else {
|
||||
i965_shader_init (&glyphs.shader, surface, op);
|
||||
|
||||
status = i965_shader_acquire_pattern (&glyphs.shader, &glyphs.shader.source,
|
||||
source, &extents.bounded);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
|
||||
if (clip != NULL) {
|
||||
status = _cairo_clip_get_region (clip, &clip_region);
|
||||
assert (status == CAIRO_STATUS_SUCCESS || status == CAIRO_INT_STATUS_UNSUPPORTED);
|
||||
|
||||
if (status == CAIRO_INT_STATUS_UNSUPPORTED)
|
||||
i965_shader_set_clip (&glyphs.shader, clip);
|
||||
}
|
||||
}
|
||||
|
||||
glyphs.head.next = NULL;
|
||||
glyphs.head.bo = NULL;
|
||||
glyphs.head.count = 0;
|
||||
glyphs.tail = &glyphs.head;
|
||||
|
||||
device = i965_device (surface);
|
||||
if (mask != NULL || clip_region == NULL) {
|
||||
glyphs.get_rectangle = i965_glyphs_emit_rectangle;
|
||||
} else {
|
||||
glyphs.get_rectangle = i965_glyphs_accumulate_rectangle;
|
||||
glyphs.head.bo = intel_bo_create (&device->intel,
|
||||
I965_VERTEX_SIZE, I965_VERTEX_SIZE,
|
||||
FALSE, I915_TILING_NONE, 0);
|
||||
if (unlikely (glyphs.head.bo == NULL))
|
||||
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
glyphs.vbo_base = intel_bo_map (&device->intel, glyphs.head.bo);
|
||||
}
|
||||
glyphs.vbo_offset = 0;
|
||||
|
||||
status = cairo_device_acquire (&device->intel.base.base);
|
||||
if (unlikely (status))
|
||||
goto CLEANUP_GLYPHS;
|
||||
|
||||
_cairo_scaled_font_freeze_cache (scaled_font);
|
||||
//private = _cairo_scaled_font_get_device (scaled_font, device);
|
||||
if (scaled_font->surface_private == NULL) {
|
||||
scaled_font->surface_private = device;
|
||||
scaled_font->surface_backend = surface->intel.drm.base.backend;
|
||||
cairo_list_add (&scaled_font->link, &device->intel.fonts);
|
||||
}
|
||||
|
||||
memset (glyph_cache, 0, sizeof (glyph_cache));
|
||||
|
||||
for (i = 0; i < num_glyphs; i++) {
|
||||
cairo_scaled_glyph_t *scaled_glyph;
|
||||
int x, y, x1, x2, y1, y2;
|
||||
int cache_index = g[i].index % ARRAY_LENGTH (glyph_cache);
|
||||
intel_glyph_t *glyph;
|
||||
|
||||
scaled_glyph = glyph_cache[cache_index];
|
||||
if (scaled_glyph == NULL ||
|
||||
_cairo_scaled_glyph_index (scaled_glyph) != g[i].index)
|
||||
{
|
||||
status = _cairo_scaled_glyph_lookup (scaled_font,
|
||||
g[i].index,
|
||||
CAIRO_SCALED_GLYPH_INFO_METRICS,
|
||||
NULL, /* foreground color */
|
||||
&scaled_glyph);
|
||||
if (unlikely (status))
|
||||
goto FINISH;
|
||||
|
||||
glyph_cache[cache_index] = scaled_glyph;
|
||||
}
|
||||
|
||||
if (unlikely (scaled_glyph->metrics.width == 0 ||
|
||||
scaled_glyph->metrics.height == 0))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
/* XXX glyph images are snapped to pixel locations */
|
||||
x = _cairo_lround (g[i].x);
|
||||
y = _cairo_lround (g[i].y);
|
||||
|
||||
x1 = x + _cairo_fixed_integer_floor (scaled_glyph->bbox.p1.x);
|
||||
y1 = y + _cairo_fixed_integer_floor (scaled_glyph->bbox.p1.y);
|
||||
x2 = x + _cairo_fixed_integer_ceil (scaled_glyph->bbox.p2.x);
|
||||
y2 = y + _cairo_fixed_integer_ceil (scaled_glyph->bbox.p2.y);
|
||||
|
||||
if (x2 < extents.bounded.x ||
|
||||
y2 < extents.bounded.y ||
|
||||
x1 > extents.bounded.x + extents.bounded.width ||
|
||||
y1 > extents.bounded.y + extents.bounded.height)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (scaled_glyph->surface_private == NULL) {
|
||||
status = intel_get_glyph (&device->intel, scaled_font, scaled_glyph);
|
||||
if (unlikely (status == CAIRO_INT_STATUS_NOTHING_TO_DO)) {
|
||||
status = CAIRO_STATUS_SUCCESS;
|
||||
continue;
|
||||
}
|
||||
if (unlikely (status))
|
||||
goto FINISH;
|
||||
}
|
||||
glyph = intel_glyph_pin (scaled_glyph->surface_private);
|
||||
|
||||
if (glyph->cache->buffer.bo != last_bo) {
|
||||
intel_buffer_cache_t *cache = glyph->cache;
|
||||
|
||||
glyphs.shader.mask.type.vertex = VS_GLYPHS;
|
||||
glyphs.shader.mask.type.fragment = FS_GLYPHS;
|
||||
glyphs.shader.mask.type.pattern = PATTERN_BASE;
|
||||
|
||||
glyphs.shader.mask.base.bo = cache->buffer.bo;
|
||||
glyphs.shader.mask.base.format = cache->buffer.format;
|
||||
glyphs.shader.mask.base.width = cache->buffer.width;
|
||||
glyphs.shader.mask.base.height = cache->buffer.height;
|
||||
glyphs.shader.mask.base.stride = cache->buffer.stride;
|
||||
glyphs.shader.mask.base.filter = i965_filter (CAIRO_FILTER_NEAREST);
|
||||
glyphs.shader.mask.base.extend = i965_extend (CAIRO_EXTEND_NONE);
|
||||
glyphs.shader.mask.base.content = CAIRO_CONTENT_ALPHA; /* XXX */
|
||||
|
||||
glyphs.shader.committed = FALSE;
|
||||
status = i965_shader_commit (&glyphs.shader, device);
|
||||
if (unlikely (status))
|
||||
goto FINISH;
|
||||
|
||||
last_bo = cache->buffer.bo;
|
||||
}
|
||||
|
||||
x2 = x1 + glyph->width;
|
||||
y2 = y1 + glyph->height;
|
||||
|
||||
if (mask_x)
|
||||
x1 += mask_x, x2 += mask_x;
|
||||
if (mask_y)
|
||||
y1 += mask_y, y2 += mask_y;
|
||||
|
||||
i965_add_glyph_rectangle (&glyphs, x1, y1, x2, y2, glyph);
|
||||
}
|
||||
|
||||
if (mask != NULL && clip_region != NULL)
|
||||
i965_clipped_vertices (device, &glyphs.head, clip_region);
|
||||
|
||||
status = CAIRO_STATUS_SUCCESS;
|
||||
FINISH:
|
||||
_cairo_scaled_font_thaw_cache (scaled_font);
|
||||
cairo_device_release (surface->intel.drm.base.device);
|
||||
CLEANUP_GLYPHS:
|
||||
i965_shader_fini (&glyphs.shader);
|
||||
|
||||
if (glyphs.head.bo != NULL) {
|
||||
struct i965_vbo *vbo, *next;
|
||||
|
||||
intel_bo_destroy (&device->intel, glyphs.head.bo);
|
||||
for (vbo = glyphs.head.next; vbo != NULL; vbo = next) {
|
||||
next = vbo->next;
|
||||
intel_bo_destroy (&device->intel, vbo->bo);
|
||||
free (vbo);
|
||||
}
|
||||
}
|
||||
|
||||
if (unlikely (status == CAIRO_INT_STATUS_UNSUPPORTED)) {
|
||||
cairo_path_fixed_t path;
|
||||
|
||||
_cairo_path_fixed_init (&path);
|
||||
status = _cairo_scaled_font_glyph_path (scaled_font,
|
||||
g + i, num_glyphs - i,
|
||||
&path);
|
||||
if (mask_x | mask_y) {
|
||||
_cairo_path_fixed_translate (&path,
|
||||
_cairo_fixed_from_int (mask_x),
|
||||
_cairo_fixed_from_int (mask_y));
|
||||
}
|
||||
if (likely (status == CAIRO_STATUS_SUCCESS)) {
|
||||
status = surface->intel.drm.base.backend->fill (glyphs.shader.target,
|
||||
glyphs.shader.op,
|
||||
mask != NULL ? &_cairo_pattern_white.base : source,
|
||||
&path,
|
||||
CAIRO_FILL_RULE_WINDING,
|
||||
0,
|
||||
scaled_font->options.antialias,
|
||||
clip);
|
||||
}
|
||||
_cairo_path_fixed_fini (&path);
|
||||
}
|
||||
|
||||
if (mask != NULL) {
|
||||
if (likely (status == CAIRO_STATUS_SUCCESS)) {
|
||||
status = i965_surface_mask_internal (surface, op, source, mask,
|
||||
clip, &extents);
|
||||
}
|
||||
cairo_surface_finish (&mask->intel.drm.base);
|
||||
cairo_surface_destroy (&mask->intel.drm.base);
|
||||
}
|
||||
|
||||
if (have_clip)
|
||||
_cairo_clip_fini (&local_clip);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
|
@ -1,737 +0,0 @@
|
|||
#ifndef CAIRO_DRM_I965_PRIVATE_H
|
||||
#define CAIRO_DRM_I965_PRIVATE_H
|
||||
|
||||
#include "cairo-drm-intel-private.h"
|
||||
|
||||
#include "cairo-hash-private.h"
|
||||
#include "cairo-freelist-private.h"
|
||||
|
||||
#include "cairo-drm-intel-brw-defines.h"
|
||||
|
||||
#include <setjmp.h>
|
||||
|
||||
#define BRW_MI_GLOBAL_SNAPSHOT_RESET (1 << 3)
|
||||
|
||||
/*
|
||||
* New regs for broadwater -- we need to split this file up sensibly somehow.
|
||||
*/
|
||||
#define BRW_3D(Pipeline,Opcode,Subopcode) ((3 << 29) | \
|
||||
((Pipeline) << 27) | \
|
||||
((Opcode) << 24) | \
|
||||
((Subopcode) << 16))
|
||||
|
||||
#define BRW_URB_FENCE BRW_3D(0, 0, 0)
|
||||
#define BRW_CS_URB_STATE BRW_3D(0, 0, 1)
|
||||
#define BRW_CONSTANT_BUFFER BRW_3D(0, 0, 2)
|
||||
#define BRW_STATE_PREFETCH BRW_3D(0, 0, 3)
|
||||
|
||||
#define BRW_STATE_BASE_ADDRESS BRW_3D(0, 1, 1)
|
||||
#define BRW_STATE_SIP BRW_3D(0, 1, 2)
|
||||
#define BRW_PIPELINE_SELECT BRW_3D(0, 1, 4)
|
||||
|
||||
#define NEW_PIPELINE_SELECT BRW_3D(1, 1, 4)
|
||||
|
||||
#define BRW_MEDIA_STATE_POINTERS BRW_3D(2, 0, 0)
|
||||
#define BRW_MEDIA_OBJECT BRW_3D(2, 1, 0)
|
||||
|
||||
#define BRW_3DSTATE_PIPELINED_POINTERS BRW_3D(3, 0, 0)
|
||||
#define BRW_3DSTATE_BINDING_TABLE_POINTERS BRW_3D(3, 0, 1)
|
||||
#define BRW_3DSTATE_VERTEX_BUFFERS BRW_3D(3, 0, 8)
|
||||
#define BRW_3DSTATE_VERTEX_ELEMENTS BRW_3D(3, 0, 9)
|
||||
#define BRW_3DSTATE_INDEX_BUFFER BRW_3D(3, 0, 0xa)
|
||||
#define BRW_3DSTATE_VF_STATISTICS BRW_3D(3, 0, 0xb)
|
||||
|
||||
#define BRW_3DSTATE_DRAWING_RECTANGLE BRW_3D(3, 1, 0)
|
||||
#define BRW_3DSTATE_CONSTANT_COLOR BRW_3D(3, 1, 1)
|
||||
#define BRW_3DSTATE_SAMPLER_PALETTE_LOAD BRW_3D(3, 1, 2)
|
||||
#define BRW_3DSTATE_CHROMA_KEY BRW_3D(3, 1, 4)
|
||||
#define BRW_3DSTATE_DEPTH_BUFFER BRW_3D(3, 1, 5)
|
||||
#define BRW_3DSTATE_POLY_STIPPLE_OFFSET BRW_3D(3, 1, 6)
|
||||
#define BRW_3DSTATE_POLY_STIPPLE_PATTERN BRW_3D(3, 1, 7)
|
||||
#define BRW_3DSTATE_LINE_STIPPLE BRW_3D(3, 1, 8)
|
||||
#define BRW_3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP BRW_3D(3, 1, 9)
|
||||
/* These two are BLC and CTG only, not BW or CL */
|
||||
#define BRW_3DSTATE_AA_LINE_PARAMS BRW_3D(3, 1, 0xa)
|
||||
#define BRW_3DSTATE_GS_SVB_INDEX BRW_3D(3, 1, 0xb)
|
||||
|
||||
#define BRW_PIPE_CONTROL BRW_3D(3, 2, 0)
|
||||
|
||||
#define BRW_3DPRIMITIVE BRW_3D(3, 3, 0)
|
||||
|
||||
#define PIPELINE_SELECT_3D 0
|
||||
#define PIPELINE_SELECT_MEDIA 1
|
||||
|
||||
#define UF0_CS_REALLOC (1 << 13)
|
||||
#define UF0_VFE_REALLOC (1 << 12)
|
||||
#define UF0_SF_REALLOC (1 << 11)
|
||||
#define UF0_CLIP_REALLOC (1 << 10)
|
||||
#define UF0_GS_REALLOC (1 << 9)
|
||||
#define UF0_VS_REALLOC (1 << 8)
|
||||
#define UF1_CLIP_FENCE_SHIFT 20
|
||||
#define UF1_GS_FENCE_SHIFT 10
|
||||
#define UF1_VS_FENCE_SHIFT 0
|
||||
#define UF2_CS_FENCE_SHIFT 20
|
||||
#define UF2_VFE_FENCE_SHIFT 10
|
||||
#define UF2_SF_FENCE_SHIFT 0
|
||||
|
||||
/* for BRW_STATE_BASE_ADDRESS */
|
||||
#define BASE_ADDRESS_MODIFY (1 << 0)
|
||||
|
||||
/* for BRW_3DSTATE_PIPELINED_POINTERS */
|
||||
#define BRW_GS_DISABLE 0
|
||||
#define BRW_GS_ENABLE 1
|
||||
#define BRW_CLIP_DISABLE 0
|
||||
#define BRW_CLIP_ENABLE 1
|
||||
|
||||
/* for BRW_PIPE_CONTROL */
|
||||
#define BRW_PIPE_CONTROL_NOWRITE (0 << 14)
|
||||
#define BRW_PIPE_CONTROL_WRITE_QWORD (1 << 14)
|
||||
#define BRW_PIPE_CONTROL_WRITE_DEPTH (2 << 14)
|
||||
#define BRW_PIPE_CONTROL_WRITE_TIME (3 << 14)
|
||||
#define BRW_PIPE_CONTROL_DEPTH_STALL (1 << 13)
|
||||
#define BRW_PIPE_CONTROL_WC_FLUSH (1 << 12)
|
||||
#define BRW_PIPE_CONTROL_IS_FLUSH (1 << 11)
|
||||
#define BRW_PIPE_CONTROL_NOTIFY_ENABLE (1 << 8)
|
||||
#define BRW_PIPE_CONTROL_GLOBAL_GTT (1 << 2)
|
||||
#define BRW_PIPE_CONTROL_LOCAL_PGTT (0 << 2)
|
||||
|
||||
/* VERTEX_BUFFER_STATE Structure */
|
||||
#define VB0_BUFFER_INDEX_SHIFT 27
|
||||
#define VB0_VERTEXDATA (0 << 26)
|
||||
#define VB0_INSTANCEDATA (1 << 26)
|
||||
#define VB0_BUFFER_PITCH_SHIFT 0
|
||||
|
||||
/* VERTEX_ELEMENT_STATE Structure */
|
||||
#define VE0_VERTEX_BUFFER_INDEX_SHIFT 27
|
||||
#define VE0_VALID (1 << 26)
|
||||
#define VE0_FORMAT_SHIFT 16
|
||||
#define VE0_OFFSET_SHIFT 0
|
||||
#define VE1_VFCOMPONENT_0_SHIFT 28
|
||||
#define VE1_VFCOMPONENT_1_SHIFT 24
|
||||
#define VE1_VFCOMPONENT_2_SHIFT 20
|
||||
#define VE1_VFCOMPONENT_3_SHIFT 16
|
||||
#define VE1_DESTINATION_ELEMENT_OFFSET_SHIFT 0
|
||||
|
||||
/* 3DPRIMITIVE bits */
|
||||
#define BRW_3DPRIMITIVE_VERTEX_SEQUENTIAL (0 << 15)
|
||||
#define BRW_3DPRIMITIVE_VERTEX_RANDOM (1 << 15)
|
||||
/* Primitive types are in brw_defines.h */
|
||||
#define BRW_3DPRIMITIVE_TOPOLOGY_SHIFT 10
|
||||
|
||||
#define BRW_SVG_CTL 0x7400
|
||||
|
||||
#define BRW_SVG_CTL_GS_BA (0 << 8)
|
||||
#define BRW_SVG_CTL_SS_BA (1 << 8)
|
||||
#define BRW_SVG_CTL_IO_BA (2 << 8)
|
||||
#define BRW_SVG_CTL_GS_AUB (3 << 8)
|
||||
#define BRW_SVG_CTL_IO_AUB (4 << 8)
|
||||
#define BRW_SVG_CTL_SIP (5 << 8)
|
||||
|
||||
#define BRW_SVG_RDATA 0x7404
|
||||
#define BRW_SVG_WORK_CTL 0x7408
|
||||
|
||||
#define BRW_VF_CTL 0x7500
|
||||
|
||||
#define BRW_VF_CTL_SNAPSHOT_COMPLETE (1 << 31)
|
||||
#define BRW_VF_CTL_SNAPSHOT_MUX_SELECT_THREADID (0 << 8)
|
||||
#define BRW_VF_CTL_SNAPSHOT_MUX_SELECT_VF_DEBUG (1 << 8)
|
||||
#define BRW_VF_CTL_SNAPSHOT_TYPE_VERTEX_SEQUENCE (0 << 4)
|
||||
#define BRW_VF_CTL_SNAPSHOT_TYPE_VERTEX_INDEX (1 << 4)
|
||||
#define BRW_VF_CTL_SKIP_INITIAL_PRIMITIVES (1 << 3)
|
||||
#define BRW_VF_CTL_MAX_PRIMITIVES_LIMIT_ENABLE (1 << 2)
|
||||
#define BRW_VF_CTL_VERTEX_RANGE_LIMIT_ENABLE (1 << 1)
|
||||
#define BRW_VF_CTL_SNAPSHOT_ENABLE (1 << 0)
|
||||
|
||||
#define BRW_VF_STRG_VAL 0x7504
|
||||
#define BRW_VF_STR_VL_OVR 0x7508
|
||||
#define BRW_VF_VC_OVR 0x750c
|
||||
#define BRW_VF_STR_PSKIP 0x7510
|
||||
#define BRW_VF_MAX_PRIM 0x7514
|
||||
#define BRW_VF_RDATA 0x7518
|
||||
|
||||
#define BRW_VS_CTL 0x7600
|
||||
#define BRW_VS_CTL_SNAPSHOT_COMPLETE (1 << 31)
|
||||
#define BRW_VS_CTL_SNAPSHOT_MUX_VERTEX_0 (0 << 8)
|
||||
#define BRW_VS_CTL_SNAPSHOT_MUX_VERTEX_1 (1 << 8)
|
||||
#define BRW_VS_CTL_SNAPSHOT_MUX_VALID_COUNT (2 << 8)
|
||||
#define BRW_VS_CTL_SNAPSHOT_MUX_VS_KERNEL_POINTER (3 << 8)
|
||||
#define BRW_VS_CTL_SNAPSHOT_ALL_THREADS (1 << 2)
|
||||
#define BRW_VS_CTL_THREAD_SNAPSHOT_ENABLE (1 << 1)
|
||||
#define BRW_VS_CTL_SNAPSHOT_ENABLE (1 << 0)
|
||||
|
||||
#define BRW_VS_STRG_VAL 0x7604
|
||||
#define BRW_VS_RDATA 0x7608
|
||||
|
||||
#define BRW_SF_CTL 0x7b00
|
||||
#define BRW_SF_CTL_SNAPSHOT_COMPLETE (1 << 31)
|
||||
#define BRW_SF_CTL_SNAPSHOT_MUX_VERTEX_0_FF_ID (0 << 8)
|
||||
#define BRW_SF_CTL_SNAPSHOT_MUX_VERTEX_0_REL_COUNT (1 << 8)
|
||||
#define BRW_SF_CTL_SNAPSHOT_MUX_VERTEX_1_FF_ID (2 << 8)
|
||||
#define BRW_SF_CTL_SNAPSHOT_MUX_VERTEX_1_REL_COUNT (3 << 8)
|
||||
#define BRW_SF_CTL_SNAPSHOT_MUX_VERTEX_2_FF_ID (4 << 8)
|
||||
#define BRW_SF_CTL_SNAPSHOT_MUX_VERTEX_2_REL_COUNT (5 << 8)
|
||||
#define BRW_SF_CTL_SNAPSHOT_MUX_VERTEX_COUNT (6 << 8)
|
||||
#define BRW_SF_CTL_SNAPSHOT_MUX_SF_KERNEL_POINTER (7 << 8)
|
||||
#define BRW_SF_CTL_MIN_MAX_PRIMITIVE_RANGE_ENABLE (1 << 4)
|
||||
#define BRW_SF_CTL_DEBUG_CLIP_RECTANGLE_ENABLE (1 << 3)
|
||||
#define BRW_SF_CTL_SNAPSHOT_ALL_THREADS (1 << 2)
|
||||
#define BRW_SF_CTL_THREAD_SNAPSHOT_ENABLE (1 << 1)
|
||||
#define BRW_SF_CTL_SNAPSHOT_ENABLE (1 << 0)
|
||||
|
||||
#define BRW_SF_STRG_VAL 0x7b04
|
||||
#define BRW_SF_RDATA 0x7b18
|
||||
|
||||
#define BRW_WIZ_CTL 0x7c00
|
||||
#define BRW_WIZ_CTL_SNAPSHOT_COMPLETE (1 << 31)
|
||||
#define BRW_WIZ_CTL_SUBSPAN_INSTANCE_SHIFT 16
|
||||
#define BRW_WIZ_CTL_SNAPSHOT_MUX_WIZ_KERNEL_POINTER (0 << 8)
|
||||
#define BRW_WIZ_CTL_SNAPSHOT_MUX_SUBSPAN_INSTANCE (1 << 8)
|
||||
#define BRW_WIZ_CTL_SNAPSHOT_MUX_PRIMITIVE_SEQUENCE (2 << 8)
|
||||
#define BRW_WIZ_CTL_SINGLE_SUBSPAN_DISPATCH (1 << 6)
|
||||
#define BRW_WIZ_CTL_IGNORE_COLOR_SCOREBOARD_STALLS (1 << 5)
|
||||
#define BRW_WIZ_CTL_ENABLE_SUBSPAN_INSTANCE_COMPARE (1 << 4)
|
||||
#define BRW_WIZ_CTL_USE_UPSTREAM_SNAPSHOT_FLAG (1 << 3)
|
||||
#define BRW_WIZ_CTL_SNAPSHOT_ALL_THREADS (1 << 2)
|
||||
#define BRW_WIZ_CTL_THREAD_SNAPSHOT_ENABLE (1 << 1)
|
||||
#define BRW_WIZ_CTL_SNAPSHOT_ENABLE (1 << 0)
|
||||
|
||||
#define BRW_WIZ_STRG_VAL 0x7c04
|
||||
#define BRW_WIZ_RDATA 0x7c18
|
||||
|
||||
#define BRW_TS_CTL 0x7e00
|
||||
#define BRW_TS_CTL_SNAPSHOT_COMPLETE (1 << 31)
|
||||
#define BRW_TS_CTL_SNAPSHOT_MESSAGE_ERROR (0 << 8)
|
||||
#define BRW_TS_CTL_SNAPSHOT_INTERFACE_DESCRIPTOR (3 << 8)
|
||||
#define BRW_TS_CTL_SNAPSHOT_ALL_CHILD_THREADS (1 << 2)
|
||||
#define BRW_TS_CTL_SNAPSHOT_ALL_ROOT_THREADS (1 << 1)
|
||||
#define BRW_TS_CTL_SNAPSHOT_ENABLE (1 << 0)
|
||||
|
||||
#define BRW_TS_STRG_VAL 0x7e04
|
||||
#define BRW_TS_RDATA 0x7e08
|
||||
|
||||
#define BRW_TD_CTL 0x8000
|
||||
#define BRW_TD_CTL_MUX_SHIFT 8
|
||||
#define BRW_TD_CTL_EXTERNAL_HALT_R0_DEBUG_MATCH (1 << 7)
|
||||
#define BRW_TD_CTL_FORCE_EXTERNAL_HALT (1 << 6)
|
||||
#define BRW_TD_CTL_EXCEPTION_MASK_OVERRIDE (1 << 5)
|
||||
#define BRW_TD_CTL_FORCE_THREAD_BREAKPOINT_ENABLE (1 << 4)
|
||||
#define BRW_TD_CTL_BREAKPOINT_ENABLE (1 << 2)
|
||||
#define BRW_TD_CTL2 0x8004
|
||||
#define BRW_TD_CTL2_ILLEGAL_OPCODE_EXCEPTION_OVERRIDE (1 << 28)
|
||||
#define BRW_TD_CTL2_MASKSTACK_EXCEPTION_OVERRIDE (1 << 26)
|
||||
#define BRW_TD_CTL2_SOFTWARE_EXCEPTION_OVERRIDE (1 << 25)
|
||||
#define BRW_TD_CTL2_ACTIVE_THREAD_LIMIT_SHIFT 16
|
||||
#define BRW_TD_CTL2_ACTIVE_THREAD_LIMIT_ENABLE (1 << 8)
|
||||
#define BRW_TD_CTL2_THREAD_SPAWNER_EXECUTION_MASK_ENABLE (1 << 7)
|
||||
#define BRW_TD_CTL2_WIZ_EXECUTION_MASK_ENABLE (1 << 6)
|
||||
#define BRW_TD_CTL2_SF_EXECUTION_MASK_ENABLE (1 << 5)
|
||||
#define BRW_TD_CTL2_CLIPPER_EXECUTION_MASK_ENABLE (1 << 4)
|
||||
#define BRW_TD_CTL2_GS_EXECUTION_MASK_ENABLE (1 << 3)
|
||||
#define BRW_TD_CTL2_VS_EXECUTION_MASK_ENABLE (1 << 0)
|
||||
#define BRW_TD_VF_VS_EMSK 0x8008
|
||||
#define BRW_TD_GS_EMSK 0x800c
|
||||
#define BRW_TD_CLIP_EMSK 0x8010
|
||||
#define BRW_TD_SF_EMSK 0x8014
|
||||
#define BRW_TD_WIZ_EMSK 0x8018
|
||||
#define BRW_TD_0_6_EHTRG_VAL 0x801c
|
||||
#define BRW_TD_0_7_EHTRG_VAL 0x8020
|
||||
#define BRW_TD_0_6_EHTRG_MSK 0x8024
|
||||
#define BRW_TD_0_7_EHTRG_MSK 0x8028
|
||||
#define BRW_TD_RDATA 0x802c
|
||||
#define BRW_TD_TS_EMSK 0x8030
|
||||
|
||||
#define BRW_EU_CTL 0x8800
|
||||
#define BRW_EU_CTL_SELECT_SHIFT 16
|
||||
#define BRW_EU_CTL_DATA_MUX_SHIFT 8
|
||||
#define BRW_EU_ATT_0 0x8810
|
||||
#define BRW_EU_ATT_1 0x8814
|
||||
#define BRW_EU_ATT_DATA_0 0x8820
|
||||
#define BRW_EU_ATT_DATA_1 0x8824
|
||||
#define BRW_EU_ATT_CLR_0 0x8830
|
||||
#define BRW_EU_ATT_CLR_1 0x8834
|
||||
#define BRW_EU_RDATA 0x8840
|
||||
|
||||
typedef struct i965_device i965_device_t;
|
||||
typedef struct i965_surface i965_surface_t;
|
||||
typedef struct i965_shader i965_shader_t;
|
||||
typedef struct i965_stream i965_stream_t;
|
||||
|
||||
struct i965_sf_state {
|
||||
cairo_hash_entry_t entry;
|
||||
uint32_t offset;
|
||||
};
|
||||
|
||||
cairo_private cairo_bool_t
|
||||
i965_sf_state_equal (const void *, const void *);
|
||||
|
||||
struct i965_cc_state {
|
||||
cairo_hash_entry_t entry;
|
||||
uint32_t offset;
|
||||
};
|
||||
|
||||
cairo_private cairo_bool_t
|
||||
i965_cc_state_equal (const void *, const void *);
|
||||
|
||||
struct i965_wm_kernel {
|
||||
cairo_hash_entry_t entry;
|
||||
uint32_t offset;
|
||||
};
|
||||
|
||||
struct i965_wm_state {
|
||||
cairo_hash_entry_t entry;
|
||||
uint32_t kernel;
|
||||
uint32_t sampler;
|
||||
uint32_t offset;
|
||||
};
|
||||
|
||||
cairo_private cairo_bool_t
|
||||
i965_wm_state_equal (const void *, const void *);
|
||||
|
||||
struct i965_wm_binding {
|
||||
cairo_hash_entry_t entry;
|
||||
uint32_t table[4];
|
||||
int size;
|
||||
uint32_t offset;
|
||||
};
|
||||
|
||||
cairo_private cairo_bool_t
|
||||
i965_wm_binding_equal (const void *, const void *);
|
||||
|
||||
struct i965_sampler {
|
||||
cairo_hash_entry_t entry;
|
||||
uint32_t offset;
|
||||
};
|
||||
|
||||
struct i965_vbo {
|
||||
struct i965_vbo *next;
|
||||
intel_bo_t *bo;
|
||||
unsigned int count;
|
||||
};
|
||||
|
||||
struct i965_surface {
|
||||
intel_surface_t intel;
|
||||
|
||||
uint32_t stream;
|
||||
uint32_t offset;
|
||||
};
|
||||
|
||||
struct i965_pending_relocation {
|
||||
uint32_t offset;
|
||||
uint32_t read_domains;
|
||||
uint32_t write_domain;
|
||||
uint32_t delta;
|
||||
};
|
||||
|
||||
struct i965_stream {
|
||||
uint32_t used;
|
||||
uint32_t committed;
|
||||
uint32_t size;
|
||||
uint8_t *data;
|
||||
uint32_t serial;
|
||||
|
||||
int num_pending_relocations;
|
||||
int max_pending_relocations;
|
||||
struct i965_pending_relocation *pending_relocations;
|
||||
|
||||
int num_relocations;
|
||||
int max_relocations;
|
||||
struct drm_i915_gem_relocation_entry *relocations;
|
||||
};
|
||||
|
||||
#define I965_BATCH_SIZE (16 * 4096)
|
||||
#define I965_GENERAL_SIZE (16 * 4096)
|
||||
#define I965_SURFACE_SIZE (32 * 4096)
|
||||
#define I965_VERTEX_SIZE (128 * 4096)
|
||||
|
||||
#define I965_TILING_DEFAULT I915_TILING_Y
|
||||
|
||||
|
||||
struct i965_device {
|
||||
intel_device_t intel;
|
||||
|
||||
cairo_bool_t is_g4x;
|
||||
|
||||
i965_shader_t *shader; /* note: only valid during geometry emission */
|
||||
|
||||
/* track state changes */
|
||||
struct i965_sf_state sf_state;
|
||||
struct i965_cc_state cc_state;
|
||||
struct i965_wm_state wm_state;
|
||||
struct i965_wm_binding wm_binding;
|
||||
|
||||
i965_surface_t *target;
|
||||
uint32_t target_offset;
|
||||
|
||||
intel_bo_t *source;
|
||||
uint32_t source_offset;
|
||||
|
||||
intel_bo_t *mask;
|
||||
uint32_t mask_offset;
|
||||
|
||||
intel_bo_t *clip;
|
||||
uint32_t clip_offset;
|
||||
|
||||
uint32_t draw_rectangle;
|
||||
|
||||
uint32_t vs_offset;
|
||||
uint32_t border_color_offset;
|
||||
cairo_hash_table_t *sf_states;
|
||||
cairo_hash_table_t *cc_states;
|
||||
cairo_hash_table_t *wm_kernels;
|
||||
cairo_hash_table_t *wm_states;
|
||||
cairo_hash_table_t *wm_bindings;
|
||||
cairo_hash_table_t *samplers;
|
||||
intel_bo_t *general_state;
|
||||
|
||||
cairo_freelist_t sf_freelist;
|
||||
cairo_freelist_t cc_freelist;
|
||||
cairo_freelist_t wm_kernel_freelist;
|
||||
cairo_freelist_t wm_state_freelist;
|
||||
cairo_freelist_t wm_binding_freelist;
|
||||
cairo_freelist_t sampler_freelist;
|
||||
|
||||
uint32_t vertex_type;
|
||||
uint32_t vertex_size;
|
||||
uint32_t rectangle_size;
|
||||
uint32_t last_vertex_size;
|
||||
|
||||
float *constants; /* 4 x matrix + 2 x source */
|
||||
unsigned constants_size;
|
||||
cairo_bool_t have_urb_fences;
|
||||
|
||||
i965_stream_t batch;
|
||||
uint8_t batch_base[I965_BATCH_SIZE];
|
||||
struct drm_i915_gem_relocation_entry batch_relocations[2048];
|
||||
|
||||
i965_stream_t surface;
|
||||
uint8_t surface_base[I965_SURFACE_SIZE];
|
||||
struct i965_pending_relocation surface_pending_relocations[1];
|
||||
struct drm_i915_gem_relocation_entry surface_relocations[1024];
|
||||
|
||||
i965_stream_t general;
|
||||
uint8_t general_base[I965_GENERAL_SIZE];
|
||||
struct i965_pending_relocation general_pending_relocations[1];
|
||||
|
||||
i965_stream_t vertex;
|
||||
uint8_t vertex_base[I965_VERTEX_SIZE];
|
||||
struct i965_pending_relocation vertex_pending_relocations[512];
|
||||
|
||||
struct {
|
||||
size_t gtt_size;
|
||||
|
||||
intel_bo_t *bo[1024];
|
||||
int count;
|
||||
|
||||
struct drm_i915_gem_exec_object2 exec[1024];
|
||||
} exec;
|
||||
cairo_list_t flush;
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
VS_NONE = 0,
|
||||
VS_GLYPHS,
|
||||
VS_SPANS,
|
||||
} i965_vertex_shader_t;
|
||||
|
||||
typedef enum {
|
||||
FS_NONE = 0,
|
||||
FS_CONSTANT,
|
||||
FS_LINEAR,
|
||||
FS_RADIAL,
|
||||
FS_SURFACE,
|
||||
FS_GLYPHS,
|
||||
FS_SPANS,
|
||||
} i965_fragment_shader_t;
|
||||
|
||||
typedef enum {
|
||||
PATTERN_BASE,
|
||||
PATTERN_SOLID,
|
||||
PATTERN_LINEAR,
|
||||
PATTERN_RADIAL,
|
||||
PATTERN_SURFACE,
|
||||
} i965_shader_channel_t;
|
||||
#define PATTERN_NONE (i965_shader_channel_t)-1
|
||||
|
||||
struct i965_shader {
|
||||
i965_device_t *device;
|
||||
i965_surface_t *target;
|
||||
|
||||
cairo_operator_t op;
|
||||
|
||||
cairo_bool_t committed;
|
||||
cairo_bool_t need_combine;
|
||||
|
||||
float constants[4*8 + 2*8]; /* 4 x matrix + 2 x source */
|
||||
unsigned constants_size;
|
||||
|
||||
union i965_shader_channel {
|
||||
struct {
|
||||
i965_vertex_shader_t vertex;
|
||||
i965_fragment_shader_t fragment;
|
||||
i965_shader_channel_t pattern;
|
||||
} type;
|
||||
struct i965_shader_base {
|
||||
i965_vertex_shader_t vertex;
|
||||
i965_fragment_shader_t fragment;
|
||||
i965_shader_channel_t pattern;
|
||||
|
||||
uint32_t mode;
|
||||
|
||||
float constants[8];
|
||||
unsigned constants_size;
|
||||
|
||||
intel_bo_t *bo;
|
||||
cairo_format_t format;
|
||||
cairo_content_t content;
|
||||
int width, height, stride;
|
||||
int filter, extend;
|
||||
cairo_matrix_t matrix;
|
||||
cairo_bool_t has_component_alpha;
|
||||
} base;
|
||||
struct i965_shader_solid {
|
||||
struct i965_shader_base base;
|
||||
} solid;
|
||||
struct i965_shader_linear {
|
||||
struct i965_shader_base base;
|
||||
} linear;
|
||||
struct i965_shader_radial {
|
||||
struct i965_shader_base base;
|
||||
} radial;
|
||||
struct i965_shader_surface {
|
||||
struct i965_shader_base base;
|
||||
cairo_surface_t *surface;
|
||||
} surface;
|
||||
} source, mask, clip, dst;
|
||||
|
||||
jmp_buf unwind;
|
||||
};
|
||||
|
||||
enum i965_shader_linear_mode {
|
||||
/* XXX REFLECT */
|
||||
LINEAR_TEXTURE,
|
||||
LINEAR_NONE,
|
||||
LINEAR_REPEAT,
|
||||
LINEAR_PAD,
|
||||
};
|
||||
|
||||
enum i965_shader_radial_mode {
|
||||
RADIAL_ONE,
|
||||
RADIAL_TWO
|
||||
};
|
||||
|
||||
typedef cairo_status_t
|
||||
(*i965_spans_func_t) (void *closure,
|
||||
cairo_span_renderer_t *renderer,
|
||||
const cairo_rectangle_int_t *extents);
|
||||
|
||||
static inline i965_device_t *
|
||||
i965_device (i965_surface_t *surface)
|
||||
{
|
||||
return (i965_device_t *) surface->intel.drm.base.device;
|
||||
}
|
||||
|
||||
cairo_private void
|
||||
i965_emit_relocation (i965_device_t *device,
|
||||
i965_stream_t *stream,
|
||||
intel_bo_t *target,
|
||||
uint32_t target_offset,
|
||||
uint32_t read_domains,
|
||||
uint32_t write_domain,
|
||||
uint32_t offset);
|
||||
|
||||
static cairo_always_inline uint32_t
|
||||
i965_stream_emit (i965_stream_t *stream, const void *data, size_t size)
|
||||
{
|
||||
uint32_t offset;
|
||||
|
||||
offset = stream->used;
|
||||
assert (offset + size <= stream->size);
|
||||
memcpy (stream->data + offset, data, size);
|
||||
stream->used += size;
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
static cairo_always_inline void
|
||||
i965_stream_align (i965_stream_t *stream, uint32_t size)
|
||||
{
|
||||
stream->used = (stream->used + size - 1) & -size;
|
||||
}
|
||||
|
||||
static cairo_always_inline void *
|
||||
i965_stream_alloc (i965_stream_t *stream, uint32_t align, uint32_t size)
|
||||
{
|
||||
void *ptr;
|
||||
|
||||
if (align)
|
||||
i965_stream_align (stream, align);
|
||||
|
||||
assert (stream->used + size <= stream->size);
|
||||
ptr = stream->data + stream->used;
|
||||
stream->used += size;
|
||||
|
||||
return ptr;
|
||||
}
|
||||
|
||||
static cairo_always_inline uint32_t
|
||||
i965_stream_offsetof (i965_stream_t *stream, const void *ptr)
|
||||
{
|
||||
return (char *) ptr - (char *) stream->data;
|
||||
}
|
||||
|
||||
cairo_private void
|
||||
i965_stream_commit (i965_device_t *device,
|
||||
i965_stream_t *stream);
|
||||
|
||||
cairo_private void
|
||||
i965_general_state_reset (i965_device_t *device);
|
||||
|
||||
static inline void
|
||||
i965_batch_emit_dword (i965_device_t *device, uint32_t dword)
|
||||
{
|
||||
*(uint32_t *) (device->batch.data + device->batch.used) = dword;
|
||||
device->batch.used += 4;
|
||||
}
|
||||
|
||||
#define OUT_BATCH(dword) i965_batch_emit_dword(device, dword)
|
||||
|
||||
cairo_private void
|
||||
i965_clipped_vertices (i965_device_t *device,
|
||||
struct i965_vbo *vbo,
|
||||
cairo_region_t *clip_region);
|
||||
|
||||
cairo_private void
|
||||
i965_flush_vertices (i965_device_t *device);
|
||||
|
||||
cairo_private void
|
||||
i965_finish_vertices (i965_device_t *device);
|
||||
|
||||
static inline float *
|
||||
i965_add_rectangle (i965_device_t *device)
|
||||
{
|
||||
float *vertices;
|
||||
uint32_t size;
|
||||
|
||||
size = device->rectangle_size;
|
||||
if (unlikely (device->vertex.used + size > device->vertex.size))
|
||||
i965_finish_vertices (device);
|
||||
|
||||
vertices = (float *) (device->vertex.data + device->vertex.used);
|
||||
device->vertex.used += size;
|
||||
|
||||
return vertices;
|
||||
}
|
||||
|
||||
static inline void
|
||||
i965_shader_add_rectangle (const i965_shader_t *shader,
|
||||
int x, int y,
|
||||
int w, int h)
|
||||
{
|
||||
float *v;
|
||||
|
||||
v= i965_add_rectangle (shader->device);
|
||||
|
||||
/* bottom-right */
|
||||
*v++ = x + w;
|
||||
*v++ = y + h;
|
||||
|
||||
/* bottom-left */
|
||||
*v++ = x;
|
||||
*v++ = y + h;
|
||||
|
||||
/* top-left */
|
||||
*v++ = x;
|
||||
*v++ = y;
|
||||
}
|
||||
|
||||
cairo_private cairo_surface_t *
|
||||
i965_surface_create_internal (cairo_drm_device_t *base_dev,
|
||||
cairo_format_t format,
|
||||
int width, int height,
|
||||
uint32_t tiling,
|
||||
cairo_bool_t gpu_target);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
i965_clip_and_composite_spans (i965_surface_t *dst,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *pattern,
|
||||
cairo_antialias_t antialias,
|
||||
i965_spans_func_t draw_func,
|
||||
void *draw_closure,
|
||||
const cairo_composite_rectangles_t*extents,
|
||||
cairo_clip_t *clip);
|
||||
|
||||
cairo_private cairo_int_status_t
|
||||
i965_surface_glyphs (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font,
|
||||
cairo_clip_t *clip,
|
||||
int *num_remaining);
|
||||
|
||||
cairo_private void
|
||||
i965_shader_init (i965_shader_t *shader,
|
||||
i965_surface_t *dst,
|
||||
cairo_operator_t op);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
i965_shader_acquire_pattern (i965_shader_t *shader,
|
||||
union i965_shader_channel *src,
|
||||
const cairo_pattern_t *pattern,
|
||||
const cairo_rectangle_int_t *extents);
|
||||
|
||||
cairo_private void
|
||||
i965_shader_set_clip (i965_shader_t *shader,
|
||||
cairo_clip_t *clip);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
i965_shader_commit (i965_shader_t *shader,
|
||||
i965_device_t *device);
|
||||
|
||||
cairo_private void
|
||||
i965_shader_fini (i965_shader_t *shader);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
i965_device_flush (i965_device_t *device);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
i965_fixup_unbounded (i965_surface_t *dst,
|
||||
const cairo_composite_rectangles_t *extents,
|
||||
cairo_clip_t *clip);
|
||||
|
||||
static inline int
|
||||
i965_filter (cairo_filter_t filter)
|
||||
{
|
||||
switch (filter) {
|
||||
default:
|
||||
case CAIRO_FILTER_FAST:
|
||||
case CAIRO_FILTER_NEAREST:
|
||||
return BRW_MAPFILTER_NEAREST;
|
||||
|
||||
case CAIRO_FILTER_GOOD:
|
||||
case CAIRO_FILTER_BEST:
|
||||
case CAIRO_FILTER_BILINEAR:
|
||||
case CAIRO_FILTER_GAUSSIAN:
|
||||
return BRW_MAPFILTER_LINEAR;
|
||||
}
|
||||
}
|
||||
|
||||
static inline int
|
||||
i965_extend (cairo_extend_t extend)
|
||||
{
|
||||
switch (extend) {
|
||||
default:
|
||||
case CAIRO_EXTEND_NONE:
|
||||
return BRW_TEXCOORDMODE_CLAMP_BORDER;
|
||||
case CAIRO_EXTEND_REPEAT:
|
||||
return BRW_TEXCOORDMODE_WRAP;
|
||||
case CAIRO_EXTEND_PAD:
|
||||
return BRW_TEXCOORDMODE_CLAMP;
|
||||
case CAIRO_EXTEND_REFLECT:
|
||||
return BRW_TEXCOORDMODE_MIRROR;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* CAIRO_DRM_I965_PRIVATE_H */
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,407 +0,0 @@
|
|||
/* cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Intel Corporation
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Red Hat, Inc.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Chris Wilson <chris@chris-wilson.co.uk>
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
|
||||
#include "cairo-composite-rectangles-private.h"
|
||||
#include "cairo-boxes-private.h"
|
||||
#include "cairo-error-private.h"
|
||||
#include "cairo-drm-i965-private.h"
|
||||
|
||||
/* Operates in either immediate or retained mode.
|
||||
* When given a clip region we record the sequence of vbo and then
|
||||
* replay them for each clip rectangle, otherwise we simply emit
|
||||
* the vbo straight into the command stream.
|
||||
*/
|
||||
|
||||
typedef struct _i965_spans i965_spans_t;
|
||||
|
||||
typedef float *
|
||||
(*i965_get_rectangle_func_t) (i965_spans_t *spans);
|
||||
|
||||
struct _i965_spans {
|
||||
cairo_span_renderer_t renderer;
|
||||
|
||||
i965_device_t *device;
|
||||
|
||||
int xmin, xmax;
|
||||
cairo_bool_t is_bounded;
|
||||
const cairo_rectangle_int_t *extents;
|
||||
|
||||
i965_get_rectangle_func_t get_rectangle;
|
||||
i965_shader_t shader;
|
||||
|
||||
cairo_region_t *clip_region;
|
||||
|
||||
struct i965_vbo head, *tail;
|
||||
|
||||
unsigned int vbo_offset;
|
||||
float *vbo_base;
|
||||
};
|
||||
|
||||
static float *
|
||||
i965_spans_emit_rectangle (i965_spans_t *spans)
|
||||
{
|
||||
return i965_add_rectangle (spans->device);
|
||||
}
|
||||
|
||||
static float *
|
||||
i965_spans_accumulate_rectangle (i965_spans_t *spans)
|
||||
{
|
||||
float *vertices;
|
||||
uint32_t size;
|
||||
|
||||
size = spans->device->rectangle_size;
|
||||
if (unlikely (spans->vbo_offset + size > I965_VERTEX_SIZE)) {
|
||||
struct i965_vbo *vbo;
|
||||
|
||||
vbo = _cairo_malloc (sizeof (struct i965_vbo));
|
||||
if (unlikely (vbo == NULL)) {
|
||||
/* throw error! */
|
||||
}
|
||||
|
||||
spans->tail->next = vbo;
|
||||
spans->tail = vbo;
|
||||
|
||||
vbo->next = NULL;
|
||||
vbo->bo = intel_bo_create (&spans->device->intel,
|
||||
I965_VERTEX_SIZE, I965_VERTEX_SIZE,
|
||||
FALSE, I915_TILING_NONE, 0);
|
||||
vbo->count = 0;
|
||||
|
||||
spans->vbo_offset = 0;
|
||||
spans->vbo_base = intel_bo_map (&spans->device->intel, vbo->bo);
|
||||
}
|
||||
|
||||
vertices = spans->vbo_base + spans->vbo_offset;
|
||||
spans->vbo_offset += size;
|
||||
spans->tail->count += 3;
|
||||
|
||||
return vertices;
|
||||
}
|
||||
|
||||
static void
|
||||
i965_span_rectangle (i965_spans_t *spans,
|
||||
int x0, int x1, int y0, int y1,
|
||||
int alpha)
|
||||
{
|
||||
float *vertices;
|
||||
float a = alpha / 255.;
|
||||
|
||||
vertices = spans->get_rectangle (spans);
|
||||
|
||||
*vertices++ = x1;
|
||||
*vertices++ = y1;
|
||||
*vertices++ = a;
|
||||
|
||||
*vertices++ = x0;
|
||||
*vertices++ = y1;
|
||||
*vertices++ = a;
|
||||
|
||||
*vertices++ = x0;
|
||||
*vertices++ = y0;
|
||||
*vertices++ = a;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
i965_bounded_spans_mono (void *abstract_renderer,
|
||||
int y, int height,
|
||||
const cairo_half_open_span_t *half,
|
||||
unsigned num_spans)
|
||||
{
|
||||
i965_spans_t *spans = abstract_renderer;
|
||||
|
||||
if (num_spans == 0)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
do {
|
||||
if (half[0].coverage >= 128) {
|
||||
i965_span_rectangle (spans,
|
||||
half[0].x, half[1].x,
|
||||
y, y + height,
|
||||
255);
|
||||
}
|
||||
half++;
|
||||
} while (--num_spans > 1);
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
i965_bounded_spans (void *abstract_renderer,
|
||||
int y, int height,
|
||||
const cairo_half_open_span_t *half,
|
||||
unsigned num_spans)
|
||||
{
|
||||
i965_spans_t *spans = abstract_renderer;
|
||||
|
||||
if (num_spans == 0)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
do {
|
||||
if (half[0].coverage) {
|
||||
i965_span_rectangle (spans,
|
||||
half[0].x, half[1].x,
|
||||
y, y + height,
|
||||
half[0].coverage);
|
||||
}
|
||||
half++;
|
||||
} while (--num_spans > 1);
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
i965_unbounded_spans (void *abstract_renderer,
|
||||
int y, int height,
|
||||
const cairo_half_open_span_t *half,
|
||||
unsigned num_spans)
|
||||
{
|
||||
i965_spans_t *spans = abstract_renderer;
|
||||
|
||||
if (num_spans == 0) {
|
||||
i965_span_rectangle (spans,
|
||||
spans->xmin, spans->xmax,
|
||||
y, y + height,
|
||||
0);
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (half[0].x != spans->xmin) {
|
||||
i965_span_rectangle (spans,
|
||||
spans->xmin, half[0].x,
|
||||
y, y + height,
|
||||
0);
|
||||
}
|
||||
|
||||
do {
|
||||
i965_span_rectangle (spans,
|
||||
half[0].x, half[1].x,
|
||||
y, y + height,
|
||||
half[0].coverage);
|
||||
half++;
|
||||
} while (--num_spans > 1);
|
||||
|
||||
if (half[0].x != spans->xmax) {
|
||||
i965_span_rectangle (spans,
|
||||
half[0].x, spans->xmax,
|
||||
y, y + height,
|
||||
0);
|
||||
}
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
i965_unbounded_spans_mono (void *abstract_renderer,
|
||||
int y, int height,
|
||||
const cairo_half_open_span_t *half,
|
||||
unsigned num_spans)
|
||||
{
|
||||
i965_spans_t *spans = abstract_renderer;
|
||||
|
||||
if (num_spans == 0) {
|
||||
i965_span_rectangle (spans,
|
||||
spans->xmin, spans->xmax,
|
||||
y, y + height,
|
||||
0);
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
if (half[0].x != spans->xmin) {
|
||||
i965_span_rectangle (spans,
|
||||
spans->xmin, half[0].x,
|
||||
y, y + height,
|
||||
0);
|
||||
}
|
||||
|
||||
do {
|
||||
int alpha = 0;
|
||||
if (half[0].coverage >= 128)
|
||||
alpha = 255;
|
||||
i965_span_rectangle (spans,
|
||||
half[0].x, half[1].x,
|
||||
y, y + height,
|
||||
alpha);
|
||||
half++;
|
||||
} while (--num_spans > 1);
|
||||
|
||||
if (half[0].x != spans->xmax) {
|
||||
i965_span_rectangle (spans,
|
||||
half[0].x, spans->xmax,
|
||||
y, y + height,
|
||||
0);
|
||||
}
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
i965_spans_init (i965_spans_t *spans,
|
||||
i965_surface_t *dst,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *pattern,
|
||||
cairo_antialias_t antialias,
|
||||
cairo_clip_t *clip,
|
||||
const cairo_composite_rectangles_t *extents)
|
||||
{
|
||||
cairo_status_t status;
|
||||
|
||||
spans->device = i965_device (dst);
|
||||
i965_shader_init (&spans->shader, dst, op);
|
||||
|
||||
spans->is_bounded = extents->is_bounded;
|
||||
if (extents->is_bounded) {
|
||||
if (antialias == CAIRO_ANTIALIAS_NONE)
|
||||
spans->renderer.render_rows = i965_bounded_spans_mono;
|
||||
else
|
||||
spans->renderer.render_rows = i965_bounded_spans;
|
||||
|
||||
spans->extents = &extents->bounded;
|
||||
} else {
|
||||
if (antialias == CAIRO_ANTIALIAS_NONE)
|
||||
spans->renderer.render_rows = i965_unbounded_spans_mono;
|
||||
else
|
||||
spans->renderer.render_rows = i965_unbounded_spans;
|
||||
|
||||
spans->extents = &extents->unbounded;
|
||||
}
|
||||
spans->xmin = spans->extents->x;
|
||||
spans->xmax = spans->extents->x + spans->extents->width;
|
||||
|
||||
spans->clip_region = NULL;
|
||||
if (clip != NULL) {
|
||||
cairo_region_t *clip_region = NULL;
|
||||
|
||||
status = _cairo_clip_get_region (clip, &clip_region);
|
||||
assert (status == CAIRO_STATUS_SUCCESS || status == CAIRO_INT_STATUS_UNSUPPORTED);
|
||||
|
||||
if (clip_region != NULL && cairo_region_num_rectangles (clip_region) == 1)
|
||||
clip_region = NULL;
|
||||
|
||||
spans->clip_region = clip_region;
|
||||
if (status == CAIRO_INT_STATUS_UNSUPPORTED)
|
||||
i965_shader_set_clip (&spans->shader, clip);
|
||||
}
|
||||
|
||||
spans->head.next = NULL;
|
||||
spans->head.bo = NULL;
|
||||
spans->head.count = 0;
|
||||
spans->tail = &spans->head;
|
||||
|
||||
if (spans->clip_region == NULL) {
|
||||
spans->get_rectangle = i965_spans_emit_rectangle;
|
||||
} else {
|
||||
spans->get_rectangle = i965_spans_accumulate_rectangle;
|
||||
spans->head.bo = intel_bo_create (&spans->device->intel,
|
||||
I965_VERTEX_SIZE, I965_VERTEX_SIZE,
|
||||
FALSE, I915_TILING_NONE, 0);
|
||||
if (unlikely (spans->head.bo == NULL))
|
||||
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
spans->vbo_base = intel_bo_map (&spans->device->intel, spans->head.bo);
|
||||
}
|
||||
spans->vbo_offset = 0;
|
||||
|
||||
return i965_shader_acquire_pattern (&spans->shader,
|
||||
&spans->shader.source,
|
||||
pattern, &extents->bounded);
|
||||
}
|
||||
|
||||
static void
|
||||
i965_spans_fini (i965_spans_t *spans)
|
||||
{
|
||||
i965_shader_fini (&spans->shader);
|
||||
|
||||
if (spans->head.bo != NULL) {
|
||||
struct i965_vbo *vbo, *next;
|
||||
|
||||
intel_bo_destroy (&spans->device->intel, spans->head.bo);
|
||||
for (vbo = spans->head.next; vbo != NULL; vbo = next) {
|
||||
next = vbo->next;
|
||||
intel_bo_destroy (&spans->device->intel, vbo->bo);
|
||||
free (vbo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cairo_status_t
|
||||
i965_clip_and_composite_spans (i965_surface_t *dst,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *pattern,
|
||||
cairo_antialias_t antialias,
|
||||
i965_spans_func_t draw_func,
|
||||
void *draw_closure,
|
||||
const cairo_composite_rectangles_t*extents,
|
||||
cairo_clip_t *clip)
|
||||
{
|
||||
i965_spans_t spans;
|
||||
i965_device_t *device;
|
||||
cairo_status_t status;
|
||||
|
||||
if (op == CAIRO_OPERATOR_CLEAR) {
|
||||
pattern = &_cairo_pattern_white.base;
|
||||
op = CAIRO_OPERATOR_DEST_OUT;
|
||||
}
|
||||
|
||||
status = i965_spans_init (&spans, dst, op, pattern, antialias, clip, extents);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
|
||||
spans.shader.mask.base.content = CAIRO_CONTENT_ALPHA;
|
||||
spans.shader.mask.type.fragment = FS_SPANS;
|
||||
spans.shader.mask.type.vertex = VS_SPANS;
|
||||
spans.shader.mask.type.pattern = PATTERN_BASE;
|
||||
|
||||
status = cairo_device_acquire (dst->intel.drm.base.device);
|
||||
if (unlikely (status))
|
||||
goto CLEANUP_SPANS;
|
||||
|
||||
device = i965_device (dst);
|
||||
status = i965_shader_commit (&spans.shader, device);
|
||||
if (unlikely (status))
|
||||
goto CLEANUP_DEVICE;
|
||||
|
||||
status = draw_func (draw_closure, &spans.renderer, spans.extents);
|
||||
if (spans.clip_region != NULL && status == CAIRO_STATUS_SUCCESS)
|
||||
i965_clipped_vertices (device, &spans.head, spans.clip_region);
|
||||
|
||||
CLEANUP_DEVICE:
|
||||
cairo_device_release (dst->intel.drm.base.device);
|
||||
CLEANUP_SPANS:
|
||||
i965_spans_fini (&spans);
|
||||
|
||||
return status;
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,824 +0,0 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2005 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.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef CAIRO_DRM_INTEL_BRW_DEFINES_H
|
||||
#define CAIRO_DRM_INTEL_BRW_DEFINES_H
|
||||
|
||||
/* 3D state: */
|
||||
#define _3DOP_3DSTATE_PIPELINED 0x0
|
||||
#define _3DOP_3DSTATE_NONPIPELINED 0x1
|
||||
#define _3DOP_3DCONTROL 0x2
|
||||
#define _3DOP_3DPRIMITIVE 0x3
|
||||
|
||||
#define _3DSTATE_PIPELINED_POINTERS 0x00
|
||||
#define _3DSTATE_BINDING_TABLE_POINTERS 0x01
|
||||
#define _3DSTATE_VERTEX_BUFFERS 0x08
|
||||
#define _3DSTATE_VERTEX_ELEMENTS 0x09
|
||||
#define _3DSTATE_INDEX_BUFFER 0x0A
|
||||
#define _3DSTATE_VF_STATISTICS 0x0B
|
||||
#define _3DSTATE_DRAWING_RECTANGLE 0x00
|
||||
#define _3DSTATE_CONSTANT_COLOR 0x01
|
||||
#define _3DSTATE_SAMPLER_PALETTE_LOAD 0x02
|
||||
#define _3DSTATE_CHROMA_KEY 0x04
|
||||
#define _3DSTATE_DEPTH_BUFFER 0x05
|
||||
#define _3DSTATE_POLY_STIPPLE_OFFSET 0x06
|
||||
#define _3DSTATE_POLY_STIPPLE_PATTERN 0x07
|
||||
#define _3DSTATE_LINE_STIPPLE 0x08
|
||||
#define _3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP 0x09
|
||||
#define _3DCONTROL 0x00
|
||||
#define _3DPRIMITIVE 0x00
|
||||
|
||||
#define PIPE_CONTROL_NOWRITE 0x00
|
||||
#define PIPE_CONTROL_WRITEIMMEDIATE 0x01
|
||||
#define PIPE_CONTROL_WRITEDEPTH 0x02
|
||||
#define PIPE_CONTROL_WRITETIMESTAMP 0x03
|
||||
|
||||
#define PIPE_CONTROL_GTTWRITE_PROCESS_LOCAL 0x00
|
||||
#define PIPE_CONTROL_GTTWRITE_GLOBAL 0x01
|
||||
|
||||
#define BRW_3D(Pipeline,Opcode,Subopcode) ((3 << 29) | \
|
||||
((Pipeline) << 27) | \
|
||||
((Opcode) << 24) | \
|
||||
((Subopcode) << 16))
|
||||
|
||||
#define BRW_PIPE_CONTROL BRW_3D(3, 2, 0)
|
||||
#define BRW_PIPE_CONTROL_NOWRITE (0 << 14)
|
||||
#define BRW_PIPE_CONTROL_WRITE_QWORD (1 << 14)
|
||||
#define BRW_PIPE_CONTROL_WRITE_DEPTH (2 << 14)
|
||||
#define BRW_PIPE_CONTROL_WRITE_TIME (3 << 14)
|
||||
#define BRW_PIPE_CONTROL_DEPTH_STALL (1 << 13)
|
||||
#define BRW_PIPE_CONTROL_WC_FLUSH (1 << 12)
|
||||
#define BRW_PIPE_CONTROL_IS_FLUSH (1 << 11)
|
||||
#define BRW_PIPE_CONTROL_NOTIFY_ENABLE (1 << 8)
|
||||
#define BRW_PIPE_CONTROL_GLOBAL_GTT (1 << 2)
|
||||
#define BRW_PIPE_CONTROL_LOCAL_PGTT (0 << 2)
|
||||
|
||||
#define _3DPRIM_POINTLIST 0x01
|
||||
#define _3DPRIM_LINELIST 0x02
|
||||
#define _3DPRIM_LINESTRIP 0x03
|
||||
#define _3DPRIM_TRILIST 0x04
|
||||
#define _3DPRIM_TRISTRIP 0x05
|
||||
#define _3DPRIM_TRIFAN 0x06
|
||||
#define _3DPRIM_QUADLIST 0x07
|
||||
#define _3DPRIM_QUADSTRIP 0x08
|
||||
#define _3DPRIM_LINELIST_ADJ 0x09
|
||||
#define _3DPRIM_LINESTRIP_ADJ 0x0A
|
||||
#define _3DPRIM_TRILIST_ADJ 0x0B
|
||||
#define _3DPRIM_TRISTRIP_ADJ 0x0C
|
||||
#define _3DPRIM_TRISTRIP_REVERSE 0x0D
|
||||
#define _3DPRIM_POLYGON 0x0E
|
||||
#define _3DPRIM_RECTLIST 0x0F
|
||||
#define _3DPRIM_LINELOOP 0x10
|
||||
#define _3DPRIM_POINTLIST_BF 0x11
|
||||
#define _3DPRIM_LINESTRIP_CONT 0x12
|
||||
#define _3DPRIM_LINESTRIP_BF 0x13
|
||||
#define _3DPRIM_LINESTRIP_CONT_BF 0x14
|
||||
#define _3DPRIM_TRIFAN_NOSTIPPLE 0x15
|
||||
|
||||
#define _3DPRIM_VERTEXBUFFER_ACCESS_SEQUENTIAL 0
|
||||
#define _3DPRIM_VERTEXBUFFER_ACCESS_RANDOM 1
|
||||
|
||||
#define BRW_ANISORATIO_2 0
|
||||
#define BRW_ANISORATIO_4 1
|
||||
#define BRW_ANISORATIO_6 2
|
||||
#define BRW_ANISORATIO_8 3
|
||||
#define BRW_ANISORATIO_10 4
|
||||
#define BRW_ANISORATIO_12 5
|
||||
#define BRW_ANISORATIO_14 6
|
||||
#define BRW_ANISORATIO_16 7
|
||||
|
||||
#define BRW_BLENDFACTOR_ONE 0x1
|
||||
#define BRW_BLENDFACTOR_SRC_COLOR 0x2
|
||||
#define BRW_BLENDFACTOR_SRC_ALPHA 0x3
|
||||
#define BRW_BLENDFACTOR_DST_ALPHA 0x4
|
||||
#define BRW_BLENDFACTOR_DST_COLOR 0x5
|
||||
#define BRW_BLENDFACTOR_SRC_ALPHA_SATURATE 0x6
|
||||
#define BRW_BLENDFACTOR_CONST_COLOR 0x7
|
||||
#define BRW_BLENDFACTOR_CONST_ALPHA 0x8
|
||||
#define BRW_BLENDFACTOR_SRC1_COLOR 0x9
|
||||
#define BRW_BLENDFACTOR_SRC1_ALPHA 0x0A
|
||||
#define BRW_BLENDFACTOR_ZERO 0x11
|
||||
#define BRW_BLENDFACTOR_INV_SRC_COLOR 0x12
|
||||
#define BRW_BLENDFACTOR_INV_SRC_ALPHA 0x13
|
||||
#define BRW_BLENDFACTOR_INV_DST_ALPHA 0x14
|
||||
#define BRW_BLENDFACTOR_INV_DST_COLOR 0x15
|
||||
#define BRW_BLENDFACTOR_INV_CONST_COLOR 0x17
|
||||
#define BRW_BLENDFACTOR_INV_CONST_ALPHA 0x18
|
||||
#define BRW_BLENDFACTOR_INV_SRC1_COLOR 0x19
|
||||
#define BRW_BLENDFACTOR_INV_SRC1_ALPHA 0x1A
|
||||
|
||||
#define BRW_BLENDFUNCTION_ADD 0
|
||||
#define BRW_BLENDFUNCTION_SUBTRACT 1
|
||||
#define BRW_BLENDFUNCTION_REVERSE_SUBTRACT 2
|
||||
#define BRW_BLENDFUNCTION_MIN 3
|
||||
#define BRW_BLENDFUNCTION_MAX 4
|
||||
|
||||
#define BRW_ALPHATEST_FORMAT_UNORM8 0
|
||||
#define BRW_ALPHATEST_FORMAT_FLOAT32 1
|
||||
|
||||
#define BRW_CHROMAKEY_KILL_ON_ANY_MATCH 0
|
||||
#define BRW_CHROMAKEY_REPLACE_BLACK 1
|
||||
|
||||
#define BRW_CLIP_API_OGL 0
|
||||
#define BRW_CLIP_API_DX 1
|
||||
|
||||
#define BRW_CLIPMODE_NORMAL 0
|
||||
#define BRW_CLIPMODE_CLIP_ALL 1
|
||||
#define BRW_CLIPMODE_CLIP_NON_REJECTED 2
|
||||
#define BRW_CLIPMODE_REJECT_ALL 3
|
||||
#define BRW_CLIPMODE_ACCEPT_ALL 4
|
||||
|
||||
#define BRW_CLIP_NDCSPACE 0
|
||||
#define BRW_CLIP_SCREENSPACE 1
|
||||
|
||||
#define BRW_COMPAREFUNCTION_ALWAYS 0
|
||||
#define BRW_COMPAREFUNCTION_NEVER 1
|
||||
#define BRW_COMPAREFUNCTION_LESS 2
|
||||
#define BRW_COMPAREFUNCTION_EQUAL 3
|
||||
#define BRW_COMPAREFUNCTION_LEQUAL 4
|
||||
#define BRW_COMPAREFUNCTION_GREATER 5
|
||||
#define BRW_COMPAREFUNCTION_NOTEQUAL 6
|
||||
#define BRW_COMPAREFUNCTION_GEQUAL 7
|
||||
|
||||
#define BRW_COVERAGE_PIXELS_HALF 0
|
||||
#define BRW_COVERAGE_PIXELS_1 1
|
||||
#define BRW_COVERAGE_PIXELS_2 2
|
||||
#define BRW_COVERAGE_PIXELS_4 3
|
||||
|
||||
#define BRW_CULLMODE_BOTH 0
|
||||
#define BRW_CULLMODE_NONE 1
|
||||
#define BRW_CULLMODE_FRONT 2
|
||||
#define BRW_CULLMODE_BACK 3
|
||||
|
||||
#define BRW_DEFAULTCOLOR_R8G8B8A8_UNORM 0
|
||||
#define BRW_DEFAULTCOLOR_R32G32B32A32_FLOAT 1
|
||||
|
||||
#define BRW_DEPTHFORMAT_D32_FLOAT_S8X24_UINT 0
|
||||
#define BRW_DEPTHFORMAT_D32_FLOAT 1
|
||||
#define BRW_DEPTHFORMAT_D24_UNORM_S8_UINT 2
|
||||
#define BRW_DEPTHFORMAT_D16_UNORM 5
|
||||
|
||||
#define BRW_FLOATING_POINT_IEEE_754 0
|
||||
#define BRW_FLOATING_POINT_NON_IEEE_754 1
|
||||
|
||||
#define BRW_FRONTWINDING_CW 0
|
||||
#define BRW_FRONTWINDING_CCW 1
|
||||
|
||||
#define BRW_INDEX_BYTE 0
|
||||
#define BRW_INDEX_WORD 1
|
||||
#define BRW_INDEX_DWORD 2
|
||||
|
||||
#define BRW_LOGICOPFUNCTION_CLEAR 0
|
||||
#define BRW_LOGICOPFUNCTION_NOR 1
|
||||
#define BRW_LOGICOPFUNCTION_AND_INVERTED 2
|
||||
#define BRW_LOGICOPFUNCTION_COPY_INVERTED 3
|
||||
#define BRW_LOGICOPFUNCTION_AND_REVERSE 4
|
||||
#define BRW_LOGICOPFUNCTION_INVERT 5
|
||||
#define BRW_LOGICOPFUNCTION_XOR 6
|
||||
#define BRW_LOGICOPFUNCTION_NAND 7
|
||||
#define BRW_LOGICOPFUNCTION_AND 8
|
||||
#define BRW_LOGICOPFUNCTION_EQUIV 9
|
||||
#define BRW_LOGICOPFUNCTION_NOOP 10
|
||||
#define BRW_LOGICOPFUNCTION_OR_INVERTED 11
|
||||
#define BRW_LOGICOPFUNCTION_COPY 12
|
||||
#define BRW_LOGICOPFUNCTION_OR_REVERSE 13
|
||||
#define BRW_LOGICOPFUNCTION_OR 14
|
||||
#define BRW_LOGICOPFUNCTION_SET 15
|
||||
|
||||
#define BRW_MAPFILTER_NEAREST 0x0
|
||||
#define BRW_MAPFILTER_LINEAR 0x1
|
||||
#define BRW_MAPFILTER_ANISOTROPIC 0x2
|
||||
|
||||
#define BRW_MIPFILTER_NONE 0
|
||||
#define BRW_MIPFILTER_NEAREST 1
|
||||
#define BRW_MIPFILTER_LINEAR 3
|
||||
|
||||
#define BRW_POLYGON_FRONT_FACING 0
|
||||
#define BRW_POLYGON_BACK_FACING 1
|
||||
|
||||
#define BRW_PREFILTER_ALWAYS 0x0
|
||||
#define BRW_PREFILTER_NEVER 0x1
|
||||
#define BRW_PREFILTER_LESS 0x2
|
||||
#define BRW_PREFILTER_EQUAL 0x3
|
||||
#define BRW_PREFILTER_LEQUAL 0x4
|
||||
#define BRW_PREFILTER_GREATER 0x5
|
||||
#define BRW_PREFILTER_NOTEQUAL 0x6
|
||||
#define BRW_PREFILTER_GEQUAL 0x7
|
||||
|
||||
#define BRW_PROVOKING_VERTEX_0 0
|
||||
#define BRW_PROVOKING_VERTEX_1 1
|
||||
#define BRW_PROVOKING_VERTEX_2 2
|
||||
|
||||
#define BRW_RASTRULE_UPPER_LEFT 0
|
||||
#define BRW_RASTRULE_UPPER_RIGHT 1
|
||||
|
||||
#define BRW_RENDERTARGET_CLAMPRANGE_UNORM 0
|
||||
#define BRW_RENDERTARGET_CLAMPRANGE_SNORM 1
|
||||
#define BRW_RENDERTARGET_CLAMPRANGE_FORMAT 2
|
||||
|
||||
#define BRW_STENCILOP_KEEP 0
|
||||
#define BRW_STENCILOP_ZERO 1
|
||||
#define BRW_STENCILOP_REPLACE 2
|
||||
#define BRW_STENCILOP_INCRSAT 3
|
||||
#define BRW_STENCILOP_DECRSAT 4
|
||||
#define BRW_STENCILOP_INCR 5
|
||||
#define BRW_STENCILOP_DECR 6
|
||||
#define BRW_STENCILOP_INVERT 7
|
||||
|
||||
#define BRW_SURFACE_MIPMAPLAYOUT_BELOW 0
|
||||
#define BRW_SURFACE_MIPMAPLAYOUT_RIGHT 1
|
||||
|
||||
#define BRW_SURFACEFORMAT_R32G32B32A32_FLOAT 0x000
|
||||
#define BRW_SURFACEFORMAT_R32G32B32A32_SINT 0x001
|
||||
#define BRW_SURFACEFORMAT_R32G32B32A32_UINT 0x002
|
||||
#define BRW_SURFACEFORMAT_R32G32B32A32_UNORM 0x003
|
||||
#define BRW_SURFACEFORMAT_R32G32B32A32_SNORM 0x004
|
||||
#define BRW_SURFACEFORMAT_R64G64_FLOAT 0x005
|
||||
#define BRW_SURFACEFORMAT_R32G32B32X32_FLOAT 0x006
|
||||
#define BRW_SURFACEFORMAT_R32G32B32A32_SSCALED 0x007
|
||||
#define BRW_SURFACEFORMAT_R32G32B32A32_USCALED 0x008
|
||||
#define BRW_SURFACEFORMAT_R32G32B32_FLOAT 0x040
|
||||
#define BRW_SURFACEFORMAT_R32G32B32_SINT 0x041
|
||||
#define BRW_SURFACEFORMAT_R32G32B32_UINT 0x042
|
||||
#define BRW_SURFACEFORMAT_R32G32B32_UNORM 0x043
|
||||
#define BRW_SURFACEFORMAT_R32G32B32_SNORM 0x044
|
||||
#define BRW_SURFACEFORMAT_R32G32B32_SSCALED 0x045
|
||||
#define BRW_SURFACEFORMAT_R32G32B32_USCALED 0x046
|
||||
#define BRW_SURFACEFORMAT_R16G16B16A16_UNORM 0x080
|
||||
#define BRW_SURFACEFORMAT_R16G16B16A16_SNORM 0x081
|
||||
#define BRW_SURFACEFORMAT_R16G16B16A16_SINT 0x082
|
||||
#define BRW_SURFACEFORMAT_R16G16B16A16_UINT 0x083
|
||||
#define BRW_SURFACEFORMAT_R16G16B16A16_FLOAT 0x084
|
||||
#define BRW_SURFACEFORMAT_R32G32_FLOAT 0x085
|
||||
#define BRW_SURFACEFORMAT_R32G32_SINT 0x086
|
||||
#define BRW_SURFACEFORMAT_R32G32_UINT 0x087
|
||||
#define BRW_SURFACEFORMAT_R32_FLOAT_X8X24_TYPELESS 0x088
|
||||
#define BRW_SURFACEFORMAT_X32_TYPELESS_G8X24_UINT 0x089
|
||||
#define BRW_SURFACEFORMAT_L32A32_FLOAT 0x08A
|
||||
#define BRW_SURFACEFORMAT_R32G32_UNORM 0x08B
|
||||
#define BRW_SURFACEFORMAT_R32G32_SNORM 0x08C
|
||||
#define BRW_SURFACEFORMAT_R64_FLOAT 0x08D
|
||||
#define BRW_SURFACEFORMAT_R16G16B16X16_UNORM 0x08E
|
||||
#define BRW_SURFACEFORMAT_R16G16B16X16_FLOAT 0x08F
|
||||
#define BRW_SURFACEFORMAT_A32X32_FLOAT 0x090
|
||||
#define BRW_SURFACEFORMAT_L32X32_FLOAT 0x091
|
||||
#define BRW_SURFACEFORMAT_I32X32_FLOAT 0x092
|
||||
#define BRW_SURFACEFORMAT_R16G16B16A16_SSCALED 0x093
|
||||
#define BRW_SURFACEFORMAT_R16G16B16A16_USCALED 0x094
|
||||
#define BRW_SURFACEFORMAT_R32G32_SSCALED 0x095
|
||||
#define BRW_SURFACEFORMAT_R32G32_USCALED 0x096
|
||||
#define BRW_SURFACEFORMAT_B8G8R8A8_UNORM 0x0C0
|
||||
#define BRW_SURFACEFORMAT_B8G8R8A8_UNORM_SRGB 0x0C1
|
||||
#define BRW_SURFACEFORMAT_R10G10B10A2_UNORM 0x0C2
|
||||
#define BRW_SURFACEFORMAT_R10G10B10A2_UNORM_SRGB 0x0C3
|
||||
#define BRW_SURFACEFORMAT_R10G10B10A2_UINT 0x0C4
|
||||
#define BRW_SURFACEFORMAT_R10G10B10_SNORM_A2_UNORM 0x0C5
|
||||
#define BRW_SURFACEFORMAT_R8G8B8A8_UNORM 0x0C7
|
||||
#define BRW_SURFACEFORMAT_R8G8B8A8_UNORM_SRGB 0x0C8
|
||||
#define BRW_SURFACEFORMAT_R8G8B8A8_SNORM 0x0C9
|
||||
#define BRW_SURFACEFORMAT_R8G8B8A8_SINT 0x0CA
|
||||
#define BRW_SURFACEFORMAT_R8G8B8A8_UINT 0x0CB
|
||||
#define BRW_SURFACEFORMAT_R16G16_UNORM 0x0CC
|
||||
#define BRW_SURFACEFORMAT_R16G16_SNORM 0x0CD
|
||||
#define BRW_SURFACEFORMAT_R16G16_SINT 0x0CE
|
||||
#define BRW_SURFACEFORMAT_R16G16_UINT 0x0CF
|
||||
#define BRW_SURFACEFORMAT_R16G16_FLOAT 0x0D0
|
||||
#define BRW_SURFACEFORMAT_B10G10R10A2_UNORM 0x0D1
|
||||
#define BRW_SURFACEFORMAT_B10G10R10A2_UNORM_SRGB 0x0D2
|
||||
#define BRW_SURFACEFORMAT_R11G11B10_FLOAT 0x0D3
|
||||
#define BRW_SURFACEFORMAT_R32_SINT 0x0D6
|
||||
#define BRW_SURFACEFORMAT_R32_UINT 0x0D7
|
||||
#define BRW_SURFACEFORMAT_R32_FLOAT 0x0D8
|
||||
#define BRW_SURFACEFORMAT_R24_UNORM_X8_TYPELESS 0x0D9
|
||||
#define BRW_SURFACEFORMAT_X24_TYPELESS_G8_UINT 0x0DA
|
||||
#define BRW_SURFACEFORMAT_L16A16_UNORM 0x0DF
|
||||
#define BRW_SURFACEFORMAT_I24X8_UNORM 0x0E0
|
||||
#define BRW_SURFACEFORMAT_L24X8_UNORM 0x0E1
|
||||
#define BRW_SURFACEFORMAT_A24X8_UNORM 0x0E2
|
||||
#define BRW_SURFACEFORMAT_I32_FLOAT 0x0E3
|
||||
#define BRW_SURFACEFORMAT_L32_FLOAT 0x0E4
|
||||
#define BRW_SURFACEFORMAT_A32_FLOAT 0x0E5
|
||||
#define BRW_SURFACEFORMAT_B8G8R8X8_UNORM 0x0E9
|
||||
#define BRW_SURFACEFORMAT_B8G8R8X8_UNORM_SRGB 0x0EA
|
||||
#define BRW_SURFACEFORMAT_R8G8B8X8_UNORM 0x0EB
|
||||
#define BRW_SURFACEFORMAT_R8G8B8X8_UNORM_SRGB 0x0EC
|
||||
#define BRW_SURFACEFORMAT_R9G9B9E5_SHAREDEXP 0x0ED
|
||||
#define BRW_SURFACEFORMAT_B10G10R10X2_UNORM 0x0EE
|
||||
#define BRW_SURFACEFORMAT_L16A16_FLOAT 0x0F0
|
||||
#define BRW_SURFACEFORMAT_R32_UNORM 0x0F1
|
||||
#define BRW_SURFACEFORMAT_R32_SNORM 0x0F2
|
||||
#define BRW_SURFACEFORMAT_R10G10B10X2_USCALED 0x0F3
|
||||
#define BRW_SURFACEFORMAT_R8G8B8A8_SSCALED 0x0F4
|
||||
#define BRW_SURFACEFORMAT_R8G8B8A8_USCALED 0x0F5
|
||||
#define BRW_SURFACEFORMAT_R16G16_SSCALED 0x0F6
|
||||
#define BRW_SURFACEFORMAT_R16G16_USCALED 0x0F7
|
||||
#define BRW_SURFACEFORMAT_R32_SSCALED 0x0F8
|
||||
#define BRW_SURFACEFORMAT_R32_USCALED 0x0F9
|
||||
#define BRW_SURFACEFORMAT_B5G6R5_UNORM 0x100
|
||||
#define BRW_SURFACEFORMAT_B5G6R5_UNORM_SRGB 0x101
|
||||
#define BRW_SURFACEFORMAT_B5G5R5A1_UNORM 0x102
|
||||
#define BRW_SURFACEFORMAT_B5G5R5A1_UNORM_SRGB 0x103
|
||||
#define BRW_SURFACEFORMAT_B4G4R4A4_UNORM 0x104
|
||||
#define BRW_SURFACEFORMAT_B4G4R4A4_UNORM_SRGB 0x105
|
||||
#define BRW_SURFACEFORMAT_R8G8_UNORM 0x106
|
||||
#define BRW_SURFACEFORMAT_R8G8_SNORM 0x107
|
||||
#define BRW_SURFACEFORMAT_R8G8_SINT 0x108
|
||||
#define BRW_SURFACEFORMAT_R8G8_UINT 0x109
|
||||
#define BRW_SURFACEFORMAT_R16_UNORM 0x10A
|
||||
#define BRW_SURFACEFORMAT_R16_SNORM 0x10B
|
||||
#define BRW_SURFACEFORMAT_R16_SINT 0x10C
|
||||
#define BRW_SURFACEFORMAT_R16_UINT 0x10D
|
||||
#define BRW_SURFACEFORMAT_R16_FLOAT 0x10E
|
||||
#define BRW_SURFACEFORMAT_I16_UNORM 0x111
|
||||
#define BRW_SURFACEFORMAT_L16_UNORM 0x112
|
||||
#define BRW_SURFACEFORMAT_A16_UNORM 0x113
|
||||
#define BRW_SURFACEFORMAT_L8A8_UNORM 0x114
|
||||
#define BRW_SURFACEFORMAT_I16_FLOAT 0x115
|
||||
#define BRW_SURFACEFORMAT_L16_FLOAT 0x116
|
||||
#define BRW_SURFACEFORMAT_A16_FLOAT 0x117
|
||||
#define BRW_SURFACEFORMAT_R5G5_SNORM_B6_UNORM 0x119
|
||||
#define BRW_SURFACEFORMAT_B5G5R5X1_UNORM 0x11A
|
||||
#define BRW_SURFACEFORMAT_B5G5R5X1_UNORM_SRGB 0x11B
|
||||
#define BRW_SURFACEFORMAT_R8G8_SSCALED 0x11C
|
||||
#define BRW_SURFACEFORMAT_R8G8_USCALED 0x11D
|
||||
#define BRW_SURFACEFORMAT_R16_SSCALED 0x11E
|
||||
#define BRW_SURFACEFORMAT_R16_USCALED 0x11F
|
||||
#define BRW_SURFACEFORMAT_R8_UNORM 0x140
|
||||
#define BRW_SURFACEFORMAT_R8_SNORM 0x141
|
||||
#define BRW_SURFACEFORMAT_R8_SINT 0x142
|
||||
#define BRW_SURFACEFORMAT_R8_UINT 0x143
|
||||
#define BRW_SURFACEFORMAT_A8_UNORM 0x144
|
||||
#define BRW_SURFACEFORMAT_I8_UNORM 0x145
|
||||
#define BRW_SURFACEFORMAT_L8_UNORM 0x146
|
||||
#define BRW_SURFACEFORMAT_P4A4_UNORM 0x147
|
||||
#define BRW_SURFACEFORMAT_A4P4_UNORM 0x148
|
||||
#define BRW_SURFACEFORMAT_R8_SSCALED 0x149
|
||||
#define BRW_SURFACEFORMAT_R8_USCALED 0x14A
|
||||
#define BRW_SURFACEFORMAT_R1_UINT 0x181
|
||||
#define BRW_SURFACEFORMAT_YCRCB_NORMAL 0x182
|
||||
#define BRW_SURFACEFORMAT_YCRCB_SWAPUVY 0x183
|
||||
#define BRW_SURFACEFORMAT_BC1_UNORM 0x186
|
||||
#define BRW_SURFACEFORMAT_BC2_UNORM 0x187
|
||||
#define BRW_SURFACEFORMAT_BC3_UNORM 0x188
|
||||
#define BRW_SURFACEFORMAT_BC4_UNORM 0x189
|
||||
#define BRW_SURFACEFORMAT_BC5_UNORM 0x18A
|
||||
#define BRW_SURFACEFORMAT_BC1_UNORM_SRGB 0x18B
|
||||
#define BRW_SURFACEFORMAT_BC2_UNORM_SRGB 0x18C
|
||||
#define BRW_SURFACEFORMAT_BC3_UNORM_SRGB 0x18D
|
||||
#define BRW_SURFACEFORMAT_MONO8 0x18E
|
||||
#define BRW_SURFACEFORMAT_YCRCB_SWAPUV 0x18F
|
||||
#define BRW_SURFACEFORMAT_YCRCB_SWAPY 0x190
|
||||
#define BRW_SURFACEFORMAT_DXT1_RGB 0x191
|
||||
#define BRW_SURFACEFORMAT_FXT1 0x192
|
||||
#define BRW_SURFACEFORMAT_R8G8B8_UNORM 0x193
|
||||
#define BRW_SURFACEFORMAT_R8G8B8_SNORM 0x194
|
||||
#define BRW_SURFACEFORMAT_R8G8B8_SSCALED 0x195
|
||||
#define BRW_SURFACEFORMAT_R8G8B8_USCALED 0x196
|
||||
#define BRW_SURFACEFORMAT_R64G64B64A64_FLOAT 0x197
|
||||
#define BRW_SURFACEFORMAT_R64G64B64_FLOAT 0x198
|
||||
#define BRW_SURFACEFORMAT_BC4_SNORM 0x199
|
||||
#define BRW_SURFACEFORMAT_BC5_SNORM 0x19A
|
||||
#define BRW_SURFACEFORMAT_R16G16B16_UNORM 0x19C
|
||||
#define BRW_SURFACEFORMAT_R16G16B16_SNORM 0x19D
|
||||
#define BRW_SURFACEFORMAT_R16G16B16_SSCALED 0x19E
|
||||
#define BRW_SURFACEFORMAT_R16G16B16_USCALED 0x19F
|
||||
|
||||
#define BRW_SURFACERETURNFORMAT_FLOAT32 0
|
||||
#define BRW_SURFACERETURNFORMAT_S1 1
|
||||
|
||||
#define BRW_SURFACE_1D 0
|
||||
#define BRW_SURFACE_2D 1
|
||||
#define BRW_SURFACE_3D 2
|
||||
#define BRW_SURFACE_CUBE 3
|
||||
#define BRW_SURFACE_BUFFER 4
|
||||
#define BRW_SURFACE_NULL 7
|
||||
|
||||
#define BRW_BORDER_COLOR_MODE_DEFAULT 0
|
||||
#define BRW_BORDER_COLOR_MODE_LEGACY 1
|
||||
|
||||
#define BRW_TEXCOORDMODE_WRAP 0
|
||||
#define BRW_TEXCOORDMODE_MIRROR 1
|
||||
#define BRW_TEXCOORDMODE_CLAMP 2
|
||||
#define BRW_TEXCOORDMODE_CUBE 3
|
||||
#define BRW_TEXCOORDMODE_CLAMP_BORDER 4
|
||||
#define BRW_TEXCOORDMODE_MIRROR_ONCE 5
|
||||
|
||||
#define BRW_THREAD_PRIORITY_NORMAL 0
|
||||
#define BRW_THREAD_PRIORITY_HIGH 1
|
||||
|
||||
#define BRW_TILEWALK_XMAJOR 0
|
||||
#define BRW_TILEWALK_YMAJOR 1
|
||||
|
||||
#define BRW_VERTEX_SUBPIXEL_PRECISION_8BITS 0
|
||||
#define BRW_VERTEX_SUBPIXEL_PRECISION_4BITS 1
|
||||
|
||||
#define BRW_VERTEXBUFFER_ACCESS_VERTEXDATA 0
|
||||
#define BRW_VERTEXBUFFER_ACCESS_INSTANCEDATA 1
|
||||
|
||||
#define BRW_VFCOMPONENT_NOSTORE 0
|
||||
#define BRW_VFCOMPONENT_STORE_SRC 1
|
||||
#define BRW_VFCOMPONENT_STORE_0 2
|
||||
#define BRW_VFCOMPONENT_STORE_1_FLT 3
|
||||
#define BRW_VFCOMPONENT_STORE_1_INT 4
|
||||
#define BRW_VFCOMPONENT_STORE_VID 5
|
||||
#define BRW_VFCOMPONENT_STORE_IID 6
|
||||
#define BRW_VFCOMPONENT_STORE_PID 7
|
||||
|
||||
|
||||
|
||||
/* Execution Unit (EU) defines */
|
||||
|
||||
#define BRW_ALIGN_1 0
|
||||
#define BRW_ALIGN_16 1
|
||||
|
||||
#define BRW_ADDRESS_DIRECT 0
|
||||
#define BRW_ADDRESS_REGISTER_INDIRECT_REGISTER 1
|
||||
|
||||
#define BRW_CHANNEL_X 0
|
||||
#define BRW_CHANNEL_Y 1
|
||||
#define BRW_CHANNEL_Z 2
|
||||
#define BRW_CHANNEL_W 3
|
||||
|
||||
#define BRW_COMPRESSION_NONE 0
|
||||
#define BRW_COMPRESSION_2NDHALF 1
|
||||
#define BRW_COMPRESSION_COMPRESSED 2
|
||||
|
||||
#define BRW_CONDITIONAL_NONE 0
|
||||
#define BRW_CONDITIONAL_Z 1
|
||||
#define BRW_CONDITIONAL_NZ 2
|
||||
#define BRW_CONDITIONAL_EQ 1 /* Z */
|
||||
#define BRW_CONDITIONAL_NEQ 2 /* NZ */
|
||||
#define BRW_CONDITIONAL_G 3
|
||||
#define BRW_CONDITIONAL_GE 4
|
||||
#define BRW_CONDITIONAL_L 5
|
||||
#define BRW_CONDITIONAL_LE 6
|
||||
#define BRW_CONDITIONAL_C 7
|
||||
#define BRW_CONDITIONAL_O 8
|
||||
|
||||
#define BRW_DEBUG_NONE 0
|
||||
#define BRW_DEBUG_BREAKPOINT 1
|
||||
|
||||
#define BRW_DEPENDENCY_NORMAL 0
|
||||
#define BRW_DEPENDENCY_NOTCLEARED 1
|
||||
#define BRW_DEPENDENCY_NOTCHECKED 2
|
||||
#define BRW_DEPENDENCY_DISABLE 3
|
||||
|
||||
#define BRW_EXECUTE_1 0
|
||||
#define BRW_EXECUTE_2 1
|
||||
#define BRW_EXECUTE_4 2
|
||||
#define BRW_EXECUTE_8 3
|
||||
#define BRW_EXECUTE_16 4
|
||||
#define BRW_EXECUTE_32 5
|
||||
|
||||
#define BRW_HORIZONTAL_STRIDE_0 0
|
||||
#define BRW_HORIZONTAL_STRIDE_1 1
|
||||
#define BRW_HORIZONTAL_STRIDE_2 2
|
||||
#define BRW_HORIZONTAL_STRIDE_4 3
|
||||
|
||||
#define BRW_INSTRUCTION_NORMAL 0
|
||||
#define BRW_INSTRUCTION_SATURATE 1
|
||||
|
||||
#define BRW_MASK_ENABLE 0
|
||||
#define BRW_MASK_DISABLE 1
|
||||
|
||||
#define BRW_OPCODE_MOV 1
|
||||
#define BRW_OPCODE_SEL 2
|
||||
#define BRW_OPCODE_NOT 4
|
||||
#define BRW_OPCODE_AND 5
|
||||
#define BRW_OPCODE_OR 6
|
||||
#define BRW_OPCODE_XOR 7
|
||||
#define BRW_OPCODE_SHR 8
|
||||
#define BRW_OPCODE_SHL 9
|
||||
#define BRW_OPCODE_RSR 10
|
||||
#define BRW_OPCODE_RSL 11
|
||||
#define BRW_OPCODE_ASR 12
|
||||
#define BRW_OPCODE_CMP 16
|
||||
#define BRW_OPCODE_JMPI 32
|
||||
#define BRW_OPCODE_IF 34
|
||||
#define BRW_OPCODE_IFF 35
|
||||
#define BRW_OPCODE_ELSE 36
|
||||
#define BRW_OPCODE_ENDIF 37
|
||||
#define BRW_OPCODE_DO 38
|
||||
#define BRW_OPCODE_WHILE 39
|
||||
#define BRW_OPCODE_BREAK 40
|
||||
#define BRW_OPCODE_CONTINUE 41
|
||||
#define BRW_OPCODE_HALT 42
|
||||
#define BRW_OPCODE_MSAVE 44
|
||||
#define BRW_OPCODE_MRESTORE 45
|
||||
#define BRW_OPCODE_PUSH 46
|
||||
#define BRW_OPCODE_POP 47
|
||||
#define BRW_OPCODE_WAIT 48
|
||||
#define BRW_OPCODE_SEND 49
|
||||
#define BRW_OPCODE_ADD 64
|
||||
#define BRW_OPCODE_MUL 65
|
||||
#define BRW_OPCODE_AVG 66
|
||||
#define BRW_OPCODE_FRC 67
|
||||
#define BRW_OPCODE_RNDU 68
|
||||
#define BRW_OPCODE_RNDD 69
|
||||
#define BRW_OPCODE_RNDE 70
|
||||
#define BRW_OPCODE_RNDZ 71
|
||||
#define BRW_OPCODE_MAC 72
|
||||
#define BRW_OPCODE_MACH 73
|
||||
#define BRW_OPCODE_LZD 74
|
||||
#define BRW_OPCODE_SAD2 80
|
||||
#define BRW_OPCODE_SADA2 81
|
||||
#define BRW_OPCODE_DP4 84
|
||||
#define BRW_OPCODE_DPH 85
|
||||
#define BRW_OPCODE_DP3 86
|
||||
#define BRW_OPCODE_DP2 87
|
||||
#define BRW_OPCODE_DPA2 88
|
||||
#define BRW_OPCODE_LINE 89
|
||||
#define BRW_OPCODE_NOP 126
|
||||
|
||||
#define BRW_PREDICATE_NONE 0
|
||||
#define BRW_PREDICATE_NORMAL 1
|
||||
#define BRW_PREDICATE_ALIGN1_ANYV 2
|
||||
#define BRW_PREDICATE_ALIGN1_ALLV 3
|
||||
#define BRW_PREDICATE_ALIGN1_ANY2H 4
|
||||
#define BRW_PREDICATE_ALIGN1_ALL2H 5
|
||||
#define BRW_PREDICATE_ALIGN1_ANY4H 6
|
||||
#define BRW_PREDICATE_ALIGN1_ALL4H 7
|
||||
#define BRW_PREDICATE_ALIGN1_ANY8H 8
|
||||
#define BRW_PREDICATE_ALIGN1_ALL8H 9
|
||||
#define BRW_PREDICATE_ALIGN1_ANY16H 10
|
||||
#define BRW_PREDICATE_ALIGN1_ALL16H 11
|
||||
#define BRW_PREDICATE_ALIGN16_REPLICATE_X 2
|
||||
#define BRW_PREDICATE_ALIGN16_REPLICATE_Y 3
|
||||
#define BRW_PREDICATE_ALIGN16_REPLICATE_Z 4
|
||||
#define BRW_PREDICATE_ALIGN16_REPLICATE_W 5
|
||||
#define BRW_PREDICATE_ALIGN16_ANY4H 6
|
||||
#define BRW_PREDICATE_ALIGN16_ALL4H 7
|
||||
|
||||
#define BRW_ARCHITECTURE_REGISTER_FILE 0
|
||||
#define BRW_GENERAL_REGISTER_FILE 1
|
||||
#define BRW_MESSAGE_REGISTER_FILE 2
|
||||
#define BRW_IMMEDIATE_VALUE 3
|
||||
|
||||
#define BRW_REGISTER_TYPE_UD 0
|
||||
#define BRW_REGISTER_TYPE_D 1
|
||||
#define BRW_REGISTER_TYPE_UW 2
|
||||
#define BRW_REGISTER_TYPE_W 3
|
||||
#define BRW_REGISTER_TYPE_UB 4
|
||||
#define BRW_REGISTER_TYPE_B 5
|
||||
#define BRW_REGISTER_TYPE_VF 5 /* packed float vector, immediates only? */
|
||||
#define BRW_REGISTER_TYPE_HF 6
|
||||
#define BRW_REGISTER_TYPE_V 6 /* packed int vector, immediates only, uword dest only */
|
||||
#define BRW_REGISTER_TYPE_F 7
|
||||
|
||||
#define BRW_ARF_NULL 0x00
|
||||
#define BRW_ARF_ADDRESS 0x10
|
||||
#define BRW_ARF_ACCUMULATOR 0x20
|
||||
#define BRW_ARF_FLAG 0x30
|
||||
#define BRW_ARF_MASK 0x40
|
||||
#define BRW_ARF_MASK_STACK 0x50
|
||||
#define BRW_ARF_MASK_STACK_DEPTH 0x60
|
||||
#define BRW_ARF_STATE 0x70
|
||||
#define BRW_ARF_CONTROL 0x80
|
||||
#define BRW_ARF_NOTIFICATION_COUNT 0x90
|
||||
#define BRW_ARF_IP 0xA0
|
||||
|
||||
#define BRW_AMASK 0
|
||||
#define BRW_IMASK 1
|
||||
#define BRW_LMASK 2
|
||||
#define BRW_CMASK 3
|
||||
|
||||
|
||||
|
||||
#define BRW_THREAD_NORMAL 0
|
||||
#define BRW_THREAD_ATOMIC 1
|
||||
#define BRW_THREAD_SWITCH 2
|
||||
|
||||
#define BRW_VERTICAL_STRIDE_0 0
|
||||
#define BRW_VERTICAL_STRIDE_1 1
|
||||
#define BRW_VERTICAL_STRIDE_2 2
|
||||
#define BRW_VERTICAL_STRIDE_4 3
|
||||
#define BRW_VERTICAL_STRIDE_8 4
|
||||
#define BRW_VERTICAL_STRIDE_16 5
|
||||
#define BRW_VERTICAL_STRIDE_32 6
|
||||
#define BRW_VERTICAL_STRIDE_64 7
|
||||
#define BRW_VERTICAL_STRIDE_128 8
|
||||
#define BRW_VERTICAL_STRIDE_256 9
|
||||
#define BRW_VERTICAL_STRIDE_ONE_DIMENSIONAL 0xF
|
||||
|
||||
#define BRW_WIDTH_1 0
|
||||
#define BRW_WIDTH_2 1
|
||||
#define BRW_WIDTH_4 2
|
||||
#define BRW_WIDTH_8 3
|
||||
#define BRW_WIDTH_16 4
|
||||
|
||||
#define BRW_STATELESS_BUFFER_BOUNDARY_1K 0
|
||||
#define BRW_STATELESS_BUFFER_BOUNDARY_2K 1
|
||||
#define BRW_STATELESS_BUFFER_BOUNDARY_4K 2
|
||||
#define BRW_STATELESS_BUFFER_BOUNDARY_8K 3
|
||||
#define BRW_STATELESS_BUFFER_BOUNDARY_16K 4
|
||||
#define BRW_STATELESS_BUFFER_BOUNDARY_32K 5
|
||||
#define BRW_STATELESS_BUFFER_BOUNDARY_64K 6
|
||||
#define BRW_STATELESS_BUFFER_BOUNDARY_128K 7
|
||||
#define BRW_STATELESS_BUFFER_BOUNDARY_256K 8
|
||||
#define BRW_STATELESS_BUFFER_BOUNDARY_512K 9
|
||||
#define BRW_STATELESS_BUFFER_BOUNDARY_1M 10
|
||||
#define BRW_STATELESS_BUFFER_BOUNDARY_2M 11
|
||||
|
||||
#define BRW_POLYGON_FACING_FRONT 0
|
||||
#define BRW_POLYGON_FACING_BACK 1
|
||||
|
||||
#define BRW_MESSAGE_TARGET_NULL 0
|
||||
#define BRW_MESSAGE_TARGET_MATH 1
|
||||
#define BRW_MESSAGE_TARGET_SAMPLER 2
|
||||
#define BRW_MESSAGE_TARGET_GATEWAY 3
|
||||
#define BRW_MESSAGE_TARGET_DATAPORT_READ 4
|
||||
#define BRW_MESSAGE_TARGET_DATAPORT_WRITE 5
|
||||
#define BRW_MESSAGE_TARGET_URB 6
|
||||
#define BRW_MESSAGE_TARGET_THREAD_SPAWNER 7
|
||||
|
||||
#define BRW_SAMPLER_RETURN_FORMAT_FLOAT32 0
|
||||
#define BRW_SAMPLER_RETURN_FORMAT_UINT32 2
|
||||
#define BRW_SAMPLER_RETURN_FORMAT_SINT32 3
|
||||
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE 0
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE 0
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_BIAS 0
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD8_KILLPIX 1
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_LOD 1
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_LOD 1
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_GRADIENTS 2
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_GRADIENTS 2
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_COMPARE 0
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_COMPARE 2
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD4X2_RESINFO 2
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD8_RESINFO 2
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD16_RESINFO 2
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD4X2_LD 3
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD8_LD 3
|
||||
#define BRW_SAMPLER_MESSAGE_SIMD16_LD 3
|
||||
|
||||
#define BRW_DATAPORT_OWORD_BLOCK_1_OWORDLOW 0
|
||||
#define BRW_DATAPORT_OWORD_BLOCK_1_OWORDHIGH 1
|
||||
#define BRW_DATAPORT_OWORD_BLOCK_2_OWORDS 2
|
||||
#define BRW_DATAPORT_OWORD_BLOCK_4_OWORDS 3
|
||||
#define BRW_DATAPORT_OWORD_BLOCK_8_OWORDS 4
|
||||
|
||||
#define BRW_DATAPORT_OWORD_DUAL_BLOCK_1OWORD 0
|
||||
#define BRW_DATAPORT_OWORD_DUAL_BLOCK_4OWORDS 2
|
||||
|
||||
#define BRW_DATAPORT_DWORD_SCATTERED_BLOCK_8DWORDS 2
|
||||
#define BRW_DATAPORT_DWORD_SCATTERED_BLOCK_16DWORDS 3
|
||||
|
||||
#define BRW_DATAPORT_READ_MESSAGE_OWORD_BLOCK_READ 0
|
||||
#define BRW_DATAPORT_READ_MESSAGE_OWORD_DUAL_BLOCK_READ 1
|
||||
#define BRW_DATAPORT_READ_MESSAGE_DWORD_BLOCK_READ 2
|
||||
#define BRW_DATAPORT_READ_MESSAGE_DWORD_SCATTERED_READ 3
|
||||
|
||||
#define BRW_DATAPORT_READ_TARGET_DATA_CACHE 0
|
||||
#define BRW_DATAPORT_READ_TARGET_RENDER_CACHE 1
|
||||
#define BRW_DATAPORT_READ_TARGET_SAMPLER_CACHE 2
|
||||
|
||||
#define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE 0
|
||||
#define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE_REPLICATED 1
|
||||
#define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_DUAL_SOURCE_SUBSPAN01 2
|
||||
#define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_DUAL_SOURCE_SUBSPAN23 3
|
||||
#define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_SINGLE_SOURCE_SUBSPAN01 4
|
||||
|
||||
#define BRW_DATAPORT_WRITE_MESSAGE_OWORD_BLOCK_WRITE 0
|
||||
#define BRW_DATAPORT_WRITE_MESSAGE_OWORD_DUAL_BLOCK_WRITE 1
|
||||
#define BRW_DATAPORT_WRITE_MESSAGE_DWORD_BLOCK_WRITE 2
|
||||
#define BRW_DATAPORT_WRITE_MESSAGE_DWORD_SCATTERED_WRITE 3
|
||||
#define BRW_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE 4
|
||||
#define BRW_DATAPORT_WRITE_MESSAGE_STREAMED_VERTEX_BUFFER_WRITE 5
|
||||
#define BRW_DATAPORT_WRITE_MESSAGE_FLUSH_RENDER_CACHE 7
|
||||
|
||||
#define BRW_MATH_FUNCTION_INV 1
|
||||
#define BRW_MATH_FUNCTION_LOG 2
|
||||
#define BRW_MATH_FUNCTION_EXP 3
|
||||
#define BRW_MATH_FUNCTION_SQRT 4
|
||||
#define BRW_MATH_FUNCTION_RSQ 5
|
||||
#define BRW_MATH_FUNCTION_SIN 6 /* was 7 */
|
||||
#define BRW_MATH_FUNCTION_COS 7 /* was 8 */
|
||||
#define BRW_MATH_FUNCTION_SINCOS 8 /* was 6 */
|
||||
#define BRW_MATH_FUNCTION_TAN 9
|
||||
#define BRW_MATH_FUNCTION_POW 10
|
||||
#define BRW_MATH_FUNCTION_INT_DIV_QUOTIENT_AND_REMAINDER 11
|
||||
#define BRW_MATH_FUNCTION_INT_DIV_QUOTIENT 12
|
||||
#define BRW_MATH_FUNCTION_INT_DIV_REMAINDER 13
|
||||
|
||||
#define BRW_MATH_INTEGER_UNSIGNED 0
|
||||
#define BRW_MATH_INTEGER_SIGNED 1
|
||||
|
||||
#define BRW_MATH_PRECISION_FULL 0
|
||||
#define BRW_MATH_PRECISION_PARTIAL 1
|
||||
|
||||
#define BRW_MATH_SATURATE_NONE 0
|
||||
#define BRW_MATH_SATURATE_SATURATE 1
|
||||
|
||||
#define BRW_MATH_DATA_VECTOR 0
|
||||
#define BRW_MATH_DATA_SCALAR 1
|
||||
|
||||
#define BRW_URB_OPCODE_WRITE 0
|
||||
|
||||
#define BRW_URB_SWIZZLE_NONE 0
|
||||
#define BRW_URB_SWIZZLE_INTERLEAVE 1
|
||||
#define BRW_URB_SWIZZLE_TRANSPOSE 2
|
||||
|
||||
#define BRW_SCRATCH_SPACE_SIZE_1K 0
|
||||
#define BRW_SCRATCH_SPACE_SIZE_2K 1
|
||||
#define BRW_SCRATCH_SPACE_SIZE_4K 2
|
||||
#define BRW_SCRATCH_SPACE_SIZE_8K 3
|
||||
#define BRW_SCRATCH_SPACE_SIZE_16K 4
|
||||
#define BRW_SCRATCH_SPACE_SIZE_32K 5
|
||||
#define BRW_SCRATCH_SPACE_SIZE_64K 6
|
||||
#define BRW_SCRATCH_SPACE_SIZE_128K 7
|
||||
#define BRW_SCRATCH_SPACE_SIZE_256K 8
|
||||
#define BRW_SCRATCH_SPACE_SIZE_512K 9
|
||||
#define BRW_SCRATCH_SPACE_SIZE_1M 10
|
||||
#define BRW_SCRATCH_SPACE_SIZE_2M 11
|
||||
|
||||
|
||||
|
||||
|
||||
#define CMD_URB_FENCE 0x6000
|
||||
#define CMD_CONST_BUFFER_STATE 0x6001
|
||||
#define CMD_CONST_BUFFER 0x6002
|
||||
|
||||
#define CMD_STATE_BASE_ADDRESS 0x6101
|
||||
#define CMD_STATE_INSN_POINTER 0x6102
|
||||
#define CMD_PIPELINE_SELECT 0x6104
|
||||
|
||||
#define CMD_PIPELINED_STATE_POINTERS 0x7800
|
||||
#define CMD_BINDING_TABLE_PTRS 0x7801
|
||||
#define CMD_VERTEX_BUFFER 0x7808
|
||||
#define CMD_VERTEX_ELEMENT 0x7809
|
||||
#define CMD_INDEX_BUFFER 0x780a
|
||||
#define CMD_VF_STATISTICS 0x780b
|
||||
|
||||
#define CMD_DRAW_RECT 0x7900
|
||||
#define CMD_BLEND_CONSTANT_COLOR 0x7901
|
||||
#define CMD_CHROMA_KEY 0x7904
|
||||
#define CMD_DEPTH_BUFFER 0x7905
|
||||
#define CMD_POLY_STIPPLE_OFFSET 0x7906
|
||||
#define CMD_POLY_STIPPLE_PATTERN 0x7907
|
||||
#define CMD_LINE_STIPPLE_PATTERN 0x7908
|
||||
#define CMD_GLOBAL_DEPTH_OFFSET_CLAMP 0x7908
|
||||
|
||||
#define CMD_PIPE_CONTROL 0x7a00
|
||||
|
||||
#define CMD_3D_PRIM 0x7b00
|
||||
|
||||
#define CMD_MI_FLUSH 0x0200
|
||||
|
||||
|
||||
/* Various values from the R0 vertex header:
|
||||
*/
|
||||
#define R02_PRIM_END 0x1
|
||||
#define R02_PRIM_START 0x2
|
||||
|
||||
/* media pipeline */
|
||||
|
||||
#define BRW_VFE_MODE_GENERIC 0x0
|
||||
#define BRW_VFE_MODE_VLD_MPEG2 0x1
|
||||
#define BRW_VFE_MODE_IS 0x2
|
||||
#define BRW_VFE_MODE_AVC_MC 0x4
|
||||
#define BRW_VFE_MODE_AVC_IT 0x7
|
||||
#define BRW_VFE_MODE_VC1_IT 0xB
|
||||
|
||||
#define BRW_VFE_DEBUG_COUNTER_FREE 0
|
||||
#define BRW_VFE_DEBUG_COUNTER_FROZEN 1
|
||||
#define BRW_VFE_DEBUG_COUNTER_ONCE 2
|
||||
#define BRW_VFE_DEBUG_COUNTER_ALWAYS 3
|
||||
|
||||
/* VLD_STATE */
|
||||
#define BRW_MPEG_TOP_FIELD 1
|
||||
#define BRW_MPEG_BOTTOM_FIELD 2
|
||||
#define BRW_MPEG_FRAME 3
|
||||
#define BRW_MPEG_QSCALE_LINEAR 0
|
||||
#define BRW_MPEG_QSCALE_NONLINEAR 1
|
||||
#define BRW_MPEG_ZIGZAG_SCAN 0
|
||||
#define BRW_MPEG_ALTER_VERTICAL_SCAN 1
|
||||
#define BRW_MPEG_I_PICTURE 1
|
||||
#define BRW_MPEG_P_PICTURE 2
|
||||
#define BRW_MPEG_B_PICTURE 3
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,121 +0,0 @@
|
|||
/*
|
||||
Copyright (C) Intel Corp. 2006. All Rights Reserved.
|
||||
Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
|
||||
develop this 3D driver.
|
||||
|
||||
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 COPYRIGHT OWNER(S) 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.
|
||||
|
||||
**********************************************************************/
|
||||
/*
|
||||
* Authors:
|
||||
* Keith Whitwell <keith@tungstengraphics.com>
|
||||
*/
|
||||
|
||||
|
||||
#include "cairoint.h"
|
||||
#include "cairo-drm-intel-brw-eu.h"
|
||||
|
||||
|
||||
void brw_math_invert( struct brw_compile *p,
|
||||
struct brw_reg dst,
|
||||
struct brw_reg src)
|
||||
{
|
||||
brw_math( p,
|
||||
dst,
|
||||
BRW_MATH_FUNCTION_INV,
|
||||
BRW_MATH_SATURATE_NONE,
|
||||
0,
|
||||
src,
|
||||
BRW_MATH_PRECISION_FULL,
|
||||
BRW_MATH_DATA_VECTOR );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void brw_copy4(struct brw_compile *p,
|
||||
struct brw_reg dst,
|
||||
struct brw_reg src,
|
||||
uint32_t count)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
dst = vec4(dst);
|
||||
src = vec4(src);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
uint32_t delta = i*32;
|
||||
brw_MOV(p, byte_offset(dst, delta), byte_offset(src, delta));
|
||||
brw_MOV(p, byte_offset(dst, delta+16), byte_offset(src, delta+16));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void brw_copy8(struct brw_compile *p,
|
||||
struct brw_reg dst,
|
||||
struct brw_reg src,
|
||||
uint32_t count)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
dst = vec8(dst);
|
||||
src = vec8(src);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
uint32_t delta = i*32;
|
||||
brw_MOV(p, byte_offset(dst, delta), byte_offset(src, delta));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void brw_copy_indirect_to_indirect(struct brw_compile *p,
|
||||
struct brw_indirect dst_ptr,
|
||||
struct brw_indirect src_ptr,
|
||||
uint32_t count)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
uint32_t delta = i*32;
|
||||
brw_MOV(p, deref_4f(dst_ptr, delta), deref_4f(src_ptr, delta));
|
||||
brw_MOV(p, deref_4f(dst_ptr, delta+16), deref_4f(src_ptr, delta+16));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void brw_copy_from_indirect(struct brw_compile *p,
|
||||
struct brw_reg dst,
|
||||
struct brw_indirect ptr,
|
||||
uint32_t count)
|
||||
{
|
||||
uint32_t i;
|
||||
|
||||
dst = vec4(dst);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
uint32_t delta = i*32;
|
||||
brw_MOV(p, byte_offset(dst, delta), deref_4f(ptr, delta));
|
||||
brw_MOV(p, byte_offset(dst, delta+16), deref_4f(ptr, delta+16));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,250 +0,0 @@
|
|||
/*
|
||||
Copyright (C) Intel Corp. 2006. All Rights Reserved.
|
||||
Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
|
||||
develop this 3D driver.
|
||||
|
||||
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 COPYRIGHT OWNER(S) 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.
|
||||
|
||||
**********************************************************************/
|
||||
/*
|
||||
* Authors:
|
||||
* Keith Whitwell <keith@tungstengraphics.com>
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
#include "cairo-drm-intel-brw-eu.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
/* How does predicate control work when execution_size != 8? Do I
|
||||
* need to test/set for 0xffff when execution_size is 16?
|
||||
*/
|
||||
void brw_set_predicate_control_flag_value( struct brw_compile *p, uint32_t value )
|
||||
{
|
||||
p->current->header.predicate_control = BRW_PREDICATE_NONE;
|
||||
|
||||
if (value != 0xff) {
|
||||
if (value != p->flag_value) {
|
||||
brw_push_insn_state(p);
|
||||
brw_MOV(p, brw_flag_reg(), brw_imm_uw(value));
|
||||
p->flag_value = value;
|
||||
brw_pop_insn_state(p);
|
||||
}
|
||||
|
||||
p->current->header.predicate_control = BRW_PREDICATE_NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
void brw_set_predicate_control( struct brw_compile *p, uint32_t pc )
|
||||
{
|
||||
p->current->header.predicate_control = pc;
|
||||
}
|
||||
|
||||
void brw_set_conditionalmod( struct brw_compile *p, uint32_t conditional )
|
||||
{
|
||||
p->current->header.destreg__conditonalmod = conditional;
|
||||
}
|
||||
|
||||
void brw_set_access_mode( struct brw_compile *p, uint32_t access_mode )
|
||||
{
|
||||
p->current->header.access_mode = access_mode;
|
||||
}
|
||||
|
||||
void brw_set_compression_control( struct brw_compile *p, int compression_control )
|
||||
{
|
||||
p->current->header.compression_control = compression_control;
|
||||
}
|
||||
|
||||
void brw_set_mask_control( struct brw_compile *p, uint32_t value )
|
||||
{
|
||||
p->current->header.mask_control = value;
|
||||
}
|
||||
|
||||
void brw_set_saturate( struct brw_compile *p, uint32_t value )
|
||||
{
|
||||
p->current->header.saturate = value;
|
||||
}
|
||||
|
||||
void brw_push_insn_state( struct brw_compile *p )
|
||||
{
|
||||
assert(p->current != &p->stack[BRW_EU_MAX_INSN_STACK-1]);
|
||||
memcpy(p->current+1, p->current, sizeof(struct brw_instruction));
|
||||
p->current++;
|
||||
}
|
||||
|
||||
void brw_pop_insn_state( struct brw_compile *p )
|
||||
{
|
||||
assert(p->current != p->stack);
|
||||
p->current--;
|
||||
}
|
||||
|
||||
/************************************************************************/
|
||||
void
|
||||
brw_compile_init (struct brw_compile *p,
|
||||
cairo_bool_t is_g4x)
|
||||
{
|
||||
p->nr_insn = 0;
|
||||
p->current = p->stack;
|
||||
memset (p->current, 0, sizeof (p->current[0]));
|
||||
|
||||
p->is_g4x = is_g4x;
|
||||
|
||||
/* Some defaults? */
|
||||
brw_set_mask_control (p, BRW_MASK_ENABLE); /* what does this do? */
|
||||
brw_set_saturate (p, 0);
|
||||
brw_set_compression_control (p, BRW_COMPRESSION_NONE);
|
||||
brw_set_predicate_control_flag_value (p, 0xff);
|
||||
}
|
||||
|
||||
const uint32_t *
|
||||
brw_get_program (struct brw_compile *p,
|
||||
uint32_t *sz)
|
||||
{
|
||||
*sz = p->nr_insn * sizeof (struct brw_instruction);
|
||||
return (const uint32_t *)p->store;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Subroutine calls require special attention.
|
||||
* Mesa instructions may be expanded into multiple hardware instructions
|
||||
* so the prog_instruction::BranchTarget field can't be used as an index
|
||||
* into the hardware instructions.
|
||||
*
|
||||
* The BranchTarget field isn't needed, however. Mesa's GLSL compiler
|
||||
* emits CAL and BGNSUB instructions with labels that can be used to map
|
||||
* subroutine calls to actual subroutine code blocks.
|
||||
*
|
||||
* The structures and function here implement patching of CAL instructions
|
||||
* so they jump to the right subroutine code...
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* For each OPCODE_BGNSUB we create one of these.
|
||||
*/
|
||||
struct brw_glsl_label
|
||||
{
|
||||
const char *name; /*< the label string */
|
||||
uint32_t position; /*< the position of the brw instruction for this label */
|
||||
struct brw_glsl_label *next; /*< next in linked list */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* For each OPCODE_CAL we create one of these.
|
||||
*/
|
||||
struct brw_glsl_call
|
||||
{
|
||||
uint32_t call_inst_pos; /*< location of the CAL instruction */
|
||||
const char *sub_name; /*< name of subroutine to call */
|
||||
struct brw_glsl_call *next; /*< next in linked list */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Called for each OPCODE_BGNSUB.
|
||||
*/
|
||||
void
|
||||
brw_save_label(struct brw_compile *c, const char *name, uint32_t position)
|
||||
{
|
||||
struct brw_glsl_label *label = calloc(1, sizeof *label);
|
||||
label->name = name;
|
||||
label->position = position;
|
||||
label->next = c->first_label;
|
||||
c->first_label = label;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Called for each OPCODE_CAL.
|
||||
*/
|
||||
void
|
||||
brw_save_call(struct brw_compile *c, const char *name, uint32_t call_pos)
|
||||
{
|
||||
struct brw_glsl_call *call = calloc(1, sizeof *call);
|
||||
call->call_inst_pos = call_pos;
|
||||
call->sub_name = name;
|
||||
call->next = c->first_call;
|
||||
c->first_call = call;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Lookup a label, return label's position/offset.
|
||||
*/
|
||||
static uint32_t
|
||||
brw_lookup_label(struct brw_compile *c, const char *name)
|
||||
{
|
||||
const struct brw_glsl_label *label;
|
||||
for (label = c->first_label; label; label = label->next) {
|
||||
if (strcmp(name, label->name) == 0) {
|
||||
return label->position;
|
||||
}
|
||||
}
|
||||
abort(); /* should never happen */
|
||||
return ~0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* When we're done generating code, this function is called to resolve
|
||||
* subroutine calls.
|
||||
*/
|
||||
void
|
||||
brw_resolve_cals(struct brw_compile *c)
|
||||
{
|
||||
const struct brw_glsl_call *call;
|
||||
|
||||
for (call = c->first_call; call; call = call->next) {
|
||||
const uint32_t sub_loc = brw_lookup_label(c, call->sub_name);
|
||||
struct brw_instruction *brw_call_inst = &c->store[call->call_inst_pos];
|
||||
struct brw_instruction *brw_sub_inst = &c->store[sub_loc];
|
||||
int32_t offset = brw_sub_inst - brw_call_inst;
|
||||
|
||||
/* patch brw_inst1 to point to brw_inst2 */
|
||||
brw_set_src1(brw_call_inst, brw_imm_d(offset * 16));
|
||||
}
|
||||
|
||||
/* free linked list of calls */
|
||||
{
|
||||
struct brw_glsl_call *call, *next;
|
||||
for (call = c->first_call; call; call = next) {
|
||||
next = call->next;
|
||||
free(call);
|
||||
}
|
||||
c->first_call = NULL;
|
||||
}
|
||||
|
||||
/* free linked list of labels */
|
||||
{
|
||||
struct brw_glsl_label *label, *next;
|
||||
for (label = c->first_label; label; label = next) {
|
||||
next = label->next;
|
||||
free(label);
|
||||
}
|
||||
c->first_label = NULL;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,909 +0,0 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2003 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.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef CAIRO_DRM_INTEL_COMMAND_PRIVATE_H
|
||||
#define CAIRO_DRM_INTEL_COMMAND_PRIVATE_H
|
||||
|
||||
#include "cairo-types-private.h"
|
||||
|
||||
#define CMD_MI (0x0 << 29)
|
||||
#define CMD_misc (0x1 << 29)
|
||||
#define CMD_2D (0x2 << 29)
|
||||
#define CMD_3D (0x3 << 29)
|
||||
/* 4-7 reserved */
|
||||
|
||||
#define MI_NOOP (CMD_MI | 0)
|
||||
/* Batch */
|
||||
#define MI_BATCH_BUFFER (CMD_MI | (0x30 << 23) | 1)
|
||||
#define MI_BATCH_BUFFER_START (CMD_MI | (0x31 << 23))
|
||||
#define MI_BATCH_BUFFER_END (CMD_MI | (0x0a << 23))
|
||||
#define MI_BATCH_NON_SECURE (1)
|
||||
#define MI_BATCH_NON_SECURE_I965 (1 << 8)
|
||||
/* Flush */
|
||||
#define MI_FLUSH (CMD_MI | (0x04 << 23))
|
||||
#define MI_WRITE_DIRTY_STATE (1<<4)
|
||||
#define MI_END_SCENE (1<<3)
|
||||
#define MI_GLOBAL_SNAPSHOT_COUNT_RESET (1<<3)
|
||||
#define MI_INHIBIT_RENDER_CACHE_FLUSH (1<<2)
|
||||
#define MI_STATE_INSTRUCTION_CACHE_FLUSH (1<<1)
|
||||
#define MI_INVALIDATE_MAP_CACHE (1<<0)
|
||||
|
||||
#define PRIM3D (CMD_3D | (0x1f<<24))
|
||||
#define PRIM3D_TRILIST (PRIM3D | (0x0<<18))
|
||||
#define PRIM3D_TRISTRIP (PRIM3D | (0x1<<18))
|
||||
#define PRIM3D_TRISTRIP_RVRSE (PRIM3D | (0x2<<18))
|
||||
#define PRIM3D_TRIFAN (PRIM3D | (0x3<<18))
|
||||
#define PRIM3D_POLY (PRIM3D | (0x4<<18))
|
||||
#define PRIM3D_LINELIST (PRIM3D | (0x5<<18))
|
||||
#define PRIM3D_LINESTRIP (PRIM3D | (0x6<<18))
|
||||
#define PRIM3D_RECTLIST (PRIM3D | (0x7<<18))
|
||||
#define PRIM3D_POINTLIST (PRIM3D | (0x8<<18))
|
||||
#define PRIM3D_DIB (PRIM3D | (0x9<<18))
|
||||
#define PRIM3D_CLEAR_RECT (PRIM3D | (0xa<<18))
|
||||
#define PRIM3D_ZONE_INIT (PRIM3D | (0xd<<18))
|
||||
#define PRIM3D_MASK (0x1f<<18)
|
||||
#define PRIM3D_INDIRECT_SEQUENTIAL ((1<<23) | (0<<17))
|
||||
#define PRIM3D_INDIRECT_ELTS ((1<<23) | (1<<17))
|
||||
|
||||
/* p137 */
|
||||
#define _3DSTATE_AA_CMD (CMD_3D | (0x06<<24))
|
||||
#define AA_LINE_ECAAR_WIDTH_ENABLE (1<<16)
|
||||
#define AA_LINE_ECAAR_WIDTH_0_5 0
|
||||
#define AA_LINE_ECAAR_WIDTH_1_0 (1<<14)
|
||||
#define AA_LINE_ECAAR_WIDTH_2_0 (2<<14)
|
||||
#define AA_LINE_ECAAR_WIDTH_4_0 (3<<14)
|
||||
#define AA_LINE_REGION_WIDTH_ENABLE (1<<8)
|
||||
#define AA_LINE_REGION_WIDTH_0_5 0
|
||||
#define AA_LINE_REGION_WIDTH_1_0 (1<<6)
|
||||
#define AA_LINE_REGION_WIDTH_2_0 (2<<6)
|
||||
#define AA_LINE_REGION_WIDTH_4_0 (3<<6)
|
||||
|
||||
/* 3DSTATE_BACKFACE_STENCIL_OPS, p138*/
|
||||
#define _3DSTATE_BACKFACE_STENCIL_OPS (CMD_3D | (0x8<<24))
|
||||
#define BFO_ENABLE_STENCIL_REF (1<<23)
|
||||
#define BFO_STENCIL_REF_SHIFT 15
|
||||
#define BFO_STENCIL_REF_MASK (0xff<<15)
|
||||
#define BFO_ENABLE_STENCIL_FUNCS (1<<14)
|
||||
#define BFO_STENCIL_TEST_SHIFT 11
|
||||
#define BFO_STENCIL_TEST_MASK (0x7<<11)
|
||||
#define BFO_STENCIL_FAIL_SHIFT 8
|
||||
#define BFO_STENCIL_FAIL_MASK (0x7<<8)
|
||||
#define BFO_STENCIL_PASS_Z_FAIL_SHIFT 5
|
||||
#define BFO_STENCIL_PASS_Z_FAIL_MASK (0x7<<5)
|
||||
#define BFO_STENCIL_PASS_Z_PASS_SHIFT 2
|
||||
#define BFO_STENCIL_PASS_Z_PASS_MASK (0x7<<2)
|
||||
#define BFO_ENABLE_STENCIL_TWO_SIDE (1<<1)
|
||||
#define BFO_STENCIL_TWO_SIDE (1<<0)
|
||||
|
||||
/* 3DSTATE_BACKFACE_STENCIL_MASKS, p140 */
|
||||
#define _3DSTATE_BACKFACE_STENCIL_MASKS (CMD_3D | (0x9<<24))
|
||||
#define BFM_ENABLE_STENCIL_TEST_MASK (1<<17)
|
||||
#define BFM_ENABLE_STENCIL_WRITE_MASK (1<<16)
|
||||
#define BFM_STENCIL_TEST_MASK_SHIFT 8
|
||||
#define BFM_STENCIL_TEST_MASK_MASK (0xff<<8)
|
||||
#define BFM_STENCIL_WRITE_MASK_SHIFT 0
|
||||
#define BFM_STENCIL_WRITE_MASK_MASK (0xff<<0)
|
||||
|
||||
/* 3DSTATE_BIN_CONTROL p141 */
|
||||
|
||||
/* p143 */
|
||||
#define _3DSTATE_BUF_INFO_CMD (CMD_3D | (0x1d<<24) | (0x8e<<16) | 1)
|
||||
/* Dword 1 */
|
||||
#define BUF_3D_ID_COLOR_BACK (0x3<<24)
|
||||
#define BUF_3D_ID_DEPTH (0x7<<24)
|
||||
#define BUF_3D_USE_FENCE (1<<23)
|
||||
#define BUF_3D_TILED_SURFACE (1<<22)
|
||||
#define BUF_3D_TILE_WALK_X 0
|
||||
#define BUF_3D_TILE_WALK_Y (1<<21)
|
||||
#define BUF_3D_PITCH(x) (x)
|
||||
/* Dword 2 */
|
||||
#define BUF_3D_ADDR(x) ((x) & ~0x3)
|
||||
|
||||
/* 3DSTATE_CHROMA_KEY */
|
||||
|
||||
/* 3DSTATE_CLEAR_PARAMETERS, p150 */
|
||||
#define _3DSTATE_CLEAR_PARAMETERS (CMD_3D | (0x1d<<24) | (0x9c<<16) | 5)
|
||||
/* Dword 1 */
|
||||
#define CLEARPARAM_CLEAR_RECT (1 << 16)
|
||||
#define CLEARPARAM_ZONE_INIT (0 << 16)
|
||||
#define CLEARPARAM_WRITE_COLOR (1 << 2)
|
||||
#define CLEARPARAM_WRITE_DEPTH (1 << 1)
|
||||
#define CLEARPARAM_WRITE_STENCIL (1 << 0)
|
||||
|
||||
/* 3DSTATE_CONSTANT_BLEND_COLOR, p153 */
|
||||
#define _3DSTATE_CONST_BLEND_COLOR_CMD (CMD_3D | (0x1d<<24) | (0x88<<16))
|
||||
|
||||
/* 3DSTATE_COORD_SET_BINDINGS, p154 */
|
||||
#define _3DSTATE_COORD_SET_BINDINGS (CMD_3D | (0x16<<24))
|
||||
#define CSB_TCB(iunit, eunit) ((eunit)<<(iunit*3))
|
||||
|
||||
/* p156 */
|
||||
#define _3DSTATE_DFLT_DIFFUSE_CMD (CMD_3D | (0x1d<<24) | (0x99<<16))
|
||||
|
||||
/* p157 */
|
||||
#define _3DSTATE_DFLT_SPEC_CMD (CMD_3D | (0x1d<<24) | (0x9a<<16))
|
||||
|
||||
/* p158 */
|
||||
#define _3DSTATE_DFLT_Z_CMD (CMD_3D | (0x1d<<24) | (0x98<<16))
|
||||
|
||||
/* 3DSTATE_DEPTH_OFFSET_SCALE, p159 */
|
||||
#define _3DSTATE_DEPTH_OFFSET_SCALE (CMD_3D | (0x1d<<24) | (0x97<<16))
|
||||
/* scale in dword 1 */
|
||||
|
||||
/* The depth subrectangle is not supported, but must be disabled. */
|
||||
/* 3DSTATE_DEPTH_SUBRECT_DISABLE, p160 */
|
||||
#define _3DSTATE_DEPTH_SUBRECT_DISABLE (CMD_3D | (0x1c<<24) | (0x11<<19) | (1 << 1) | (0 << 0))
|
||||
|
||||
/* p161 */
|
||||
#define _3DSTATE_DST_BUF_VARS_CMD (CMD_3D | (0x1d<<24) | (0x85<<16))
|
||||
/* Dword 1 */
|
||||
#define TEX_DEFAULT_COLOR_OGL (0<<30)
|
||||
#define TEX_DEFAULT_COLOR_D3D (1<<30)
|
||||
#define ZR_EARLY_DEPTH (1<<29)
|
||||
#define LOD_PRECLAMP_OGL (1<<28)
|
||||
#define LOD_PRECLAMP_D3D (0<<28)
|
||||
#define DITHER_FULL_ALWAYS (0<<26)
|
||||
#define DITHER_FULL_ON_FB_BLEND (1<<26)
|
||||
#define DITHER_CLAMPED_ALWAYS (2<<26)
|
||||
#define LINEAR_GAMMA_BLEND_32BPP (1<<25)
|
||||
#define DEBUG_DISABLE_ENH_DITHER (1<<24)
|
||||
#define DSTORG_HORT_BIAS(x) ((x)<<20)
|
||||
#define DSTORG_VERT_BIAS(x) ((x)<<16)
|
||||
#define COLOR_4_2_2_CHNL_WRT_ALL 0
|
||||
#define COLOR_4_2_2_CHNL_WRT_Y (1<<12)
|
||||
#define COLOR_4_2_2_CHNL_WRT_CR (2<<12)
|
||||
#define COLOR_4_2_2_CHNL_WRT_CB (3<<12)
|
||||
#define COLOR_4_2_2_CHNL_WRT_CRCB (4<<12)
|
||||
#define COLR_BUF_8BIT 0
|
||||
#define COLR_BUF_RGB555 (1<<8)
|
||||
#define COLR_BUF_RGB565 (2<<8)
|
||||
#define COLR_BUF_ARGB8888 (3<<8)
|
||||
#define COLR_BUF_ARGB4444 (8<<8)
|
||||
#define COLR_BUF_ARGB1555 (9<<8)
|
||||
#define COLR_BUF_ARGB2AAA (0xa<<8)
|
||||
#define DEPTH_FRMT_16_FIXED 0
|
||||
#define DEPTH_FRMT_16_FLOAT (1<<2)
|
||||
#define DEPTH_FRMT_24_FIXED_8_OTHER (2<<2)
|
||||
#define VERT_LINE_STRIDE_1 (1<<1)
|
||||
#define VERT_LINE_STRIDE_0 (0<<1)
|
||||
#define VERT_LINE_STRIDE_OFS_1 1
|
||||
#define VERT_LINE_STRIDE_OFS_0 0
|
||||
|
||||
/* p166 */
|
||||
#define _3DSTATE_DRAW_RECT_CMD (CMD_3D|(0x1d<<24)|(0x80<<16)|3)
|
||||
/* Dword 1 */
|
||||
#define DRAW_RECT_DIS_DEPTH_OFS (1<<30)
|
||||
#define DRAW_DITHER_OFS_X(x) ((x)<<26)
|
||||
#define DRAW_DITHER_OFS_Y(x) ((x)<<24)
|
||||
/* Dword 2 */
|
||||
#define DRAW_YMIN(x) ((x)<<16)
|
||||
#define DRAW_XMIN(x) (x)
|
||||
/* Dword 3 */
|
||||
#define DRAW_YMAX(x) ((x-1)<<16)
|
||||
#define DRAW_XMAX(x) (x-1)
|
||||
/* Dword 4 */
|
||||
#define DRAW_YORG(x) ((x)<<16)
|
||||
#define DRAW_XORG(x) (x)
|
||||
|
||||
/* 3DSTATE_FILTER_COEFFICIENTS_4X4, p170 */
|
||||
|
||||
/* 3DSTATE_FILTER_COEFFICIENTS_6X5, p172 */
|
||||
|
||||
/* _3DSTATE_FOG_COLOR, p173 */
|
||||
#define _3DSTATE_FOG_COLOR_CMD (CMD_3D|(0x15<<24))
|
||||
#define FOG_COLOR_RED(x) ((x)<<16)
|
||||
#define FOG_COLOR_GREEN(x) ((x)<<8)
|
||||
#define FOG_COLOR_BLUE(x) (x)
|
||||
|
||||
/* _3DSTATE_FOG_MODE, p174 */
|
||||
#define _3DSTATE_FOG_MODE_CMD (CMD_3D|(0x1d<<24)|(0x89<<16)|2)
|
||||
/* Dword 1 */
|
||||
#define FMC1_FOGFUNC_MODIFY_ENABLE (1<<31)
|
||||
#define FMC1_FOGFUNC_VERTEX (0<<28)
|
||||
#define FMC1_FOGFUNC_PIXEL_EXP (1<<28)
|
||||
#define FMC1_FOGFUNC_PIXEL_EXP2 (2<<28)
|
||||
#define FMC1_FOGFUNC_PIXEL_LINEAR (3<<28)
|
||||
#define FMC1_FOGFUNC_MASK (3<<28)
|
||||
#define FMC1_FOGINDEX_MODIFY_ENABLE (1<<27)
|
||||
#define FMC1_FOGINDEX_Z (0<<25)
|
||||
#define FMC1_FOGINDEX_W (1<<25)
|
||||
#define FMC1_C1_C2_MODIFY_ENABLE (1<<24)
|
||||
#define FMC1_DENSITY_MODIFY_ENABLE (1<<23)
|
||||
#define FMC1_C1_ONE (1<<13)
|
||||
#define FMC1_C1_MASK (0xffff<<4)
|
||||
/* Dword 2 */
|
||||
#define FMC2_C2_ONE (1<<16)
|
||||
/* Dword 3 */
|
||||
#define FMC3_D_ONE (1<<16)
|
||||
|
||||
/* _3DSTATE_INDEPENDENT_ALPHA_BLEND, p177 */
|
||||
#define _3DSTATE_INDEPENDENT_ALPHA_BLEND_CMD (CMD_3D|(0x0b<<24))
|
||||
#define IAB_MODIFY_ENABLE (1<<23)
|
||||
#define IAB_ENABLE (1<<22)
|
||||
#define IAB_MODIFY_FUNC (1<<21)
|
||||
#define IAB_FUNC_SHIFT 16
|
||||
#define IAB_MODIFY_SRC_FACTOR (1<<11)
|
||||
#define IAB_SRC_FACTOR_SHIFT 6
|
||||
#define IAB_SRC_FACTOR_MASK (BLENDFACT_MASK<<6)
|
||||
#define IAB_MODIFY_DST_FACTOR (1<<5)
|
||||
#define IAB_DST_FACTOR_SHIFT 0
|
||||
#define IAB_DST_FACTOR_MASK (BLENDFACT_MASK<<0)
|
||||
|
||||
#define BLENDFACT_ZERO 0x01
|
||||
#define BLENDFACT_ONE 0x02
|
||||
#define BLENDFACT_SRC_COLR 0x03
|
||||
#define BLENDFACT_INV_SRC_COLR 0x04
|
||||
#define BLENDFACT_SRC_ALPHA 0x05
|
||||
#define BLENDFACT_INV_SRC_ALPHA 0x06
|
||||
#define BLENDFACT_DST_ALPHA 0x07
|
||||
#define BLENDFACT_INV_DST_ALPHA 0x08
|
||||
#define BLENDFACT_DST_COLR 0x09
|
||||
#define BLENDFACT_INV_DST_COLR 0x0a
|
||||
#define BLENDFACT_SRC_ALPHA_SATURATE 0x0b
|
||||
#define BLENDFACT_CONST_COLOR 0x0c
|
||||
#define BLENDFACT_INV_CONST_COLOR 0x0d
|
||||
#define BLENDFACT_CONST_ALPHA 0x0e
|
||||
#define BLENDFACT_INV_CONST_ALPHA 0x0f
|
||||
#define BLENDFACT_MASK 0x0f
|
||||
|
||||
#define BLENDFUNC_ADD 0x0
|
||||
#define BLENDFUNC_SUBTRACT 0x1
|
||||
#define BLENDFUNC_REVERSE_SUBTRACT 0x2
|
||||
#define BLENDFUNC_MIN 0x3
|
||||
#define BLENDFUNC_MAX 0x4
|
||||
#define BLENDFUNC_MASK 0x7
|
||||
|
||||
/* 3DSTATE_LOAD_INDIRECT, p180 */
|
||||
|
||||
#define _3DSTATE_LOAD_INDIRECT (CMD_3D|(0x1d<<24)|(0x7<<16))
|
||||
#define LI0_STATE_STATIC_INDIRECT (0x01<<8)
|
||||
#define LI0_STATE_DYNAMIC_INDIRECT (0x02<<8)
|
||||
#define LI0_STATE_SAMPLER (0x04<<8)
|
||||
#define LI0_STATE_MAP (0x08<<8)
|
||||
#define LI0_STATE_PROGRAM (0x10<<8)
|
||||
#define LI0_STATE_CONSTANTS (0x20<<8)
|
||||
|
||||
#define SIS0_BUFFER_ADDRESS(x) ((x)&~0x3)
|
||||
#define SIS0_FORCE_LOAD (1<<1)
|
||||
#define SIS0_BUFFER_VALID (1<<0)
|
||||
#define SIS1_BUFFER_LENGTH(x) ((x)&0xff)
|
||||
|
||||
#define DIS0_BUFFER_ADDRESS(x) ((x)&~0x3)
|
||||
#define DIS0_BUFFER_RESET (1<<1)
|
||||
#define DIS0_BUFFER_VALID (1<<0)
|
||||
|
||||
#define SSB0_BUFFER_ADDRESS(x) ((x)&~0x3)
|
||||
#define SSB0_FORCE_LOAD (1<<1)
|
||||
#define SSB0_BUFFER_VALID (1<<0)
|
||||
#define SSB1_BUFFER_LENGTH(x) ((x)&0xff)
|
||||
|
||||
#define MSB0_BUFFER_ADDRESS(x) ((x)&~0x3)
|
||||
#define MSB0_FORCE_LOAD (1<<1)
|
||||
#define MSB0_BUFFER_VALID (1<<0)
|
||||
#define MSB1_BUFFER_LENGTH(x) ((x)&0xff)
|
||||
|
||||
#define PSP0_BUFFER_ADDRESS(x) ((x)&~0x3)
|
||||
#define PSP0_FORCE_LOAD (1<<1)
|
||||
#define PSP0_BUFFER_VALID (1<<0)
|
||||
#define PSP1_BUFFER_LENGTH(x) ((x)&0xff)
|
||||
|
||||
#define PSC0_BUFFER_ADDRESS(x) ((x)&~0x3)
|
||||
#define PSC0_FORCE_LOAD (1<<1)
|
||||
#define PSC0_BUFFER_VALID (1<<0)
|
||||
#define PSC1_BUFFER_LENGTH(x) ((x)&0xff)
|
||||
|
||||
/* _3DSTATE_RASTERIZATION_RULES */
|
||||
#define _3DSTATE_RASTER_RULES_CMD (CMD_3D|(0x07<<24))
|
||||
#define ENABLE_POINT_RASTER_RULE (1<<15)
|
||||
#define OGL_POINT_RASTER_RULE (1<<13)
|
||||
#define ENABLE_TEXKILL_3D_4D (1<<10)
|
||||
#define TEXKILL_3D (0<<9)
|
||||
#define TEXKILL_4D (1<<9)
|
||||
#define ENABLE_LINE_STRIP_PROVOKE_VRTX (1<<8)
|
||||
#define ENABLE_TRI_FAN_PROVOKE_VRTX (1<<5)
|
||||
#define LINE_STRIP_PROVOKE_VRTX(x) ((x)<<6)
|
||||
#define TRI_FAN_PROVOKE_VRTX(x) ((x)<<3)
|
||||
|
||||
/* _3DSTATE_SCISSOR_ENABLE, p256 */
|
||||
#define _3DSTATE_SCISSOR_ENABLE_CMD (CMD_3D|(0x1c<<24)|(0x10<<19))
|
||||
#define ENABLE_SCISSOR_RECT ((1<<1) | 1)
|
||||
#define DISABLE_SCISSOR_RECT (1<<1)
|
||||
|
||||
/* _3DSTATE_SCISSOR_RECTANGLE_0, p257 */
|
||||
#define _3DSTATE_SCISSOR_RECT_0_CMD (CMD_3D|(0x1d<<24)|(0x81<<16)|1)
|
||||
/* Dword 1 */
|
||||
#define SCISSOR_RECT_0_YMIN(x) ((x)<<16)
|
||||
#define SCISSOR_RECT_0_XMIN(x) (x)
|
||||
/* Dword 2 */
|
||||
#define SCISSOR_RECT_0_YMAX(x) ((x)<<16)
|
||||
#define SCISSOR_RECT_0_XMAX(x) (x)
|
||||
|
||||
/* p189 */
|
||||
#define _3DSTATE_LOAD_STATE_IMMEDIATE_1 (CMD_3D | (0x1d<<24) | (0x04<<16))
|
||||
#define I1_LOAD_S(n) (1<<(4+n))
|
||||
|
||||
#define S0_VB_OFFSET_MASK 0xffffffc
|
||||
#define S0_AUTO_CACHE_INV_DISABLE (1<<0)
|
||||
|
||||
#define S1_VERTEX_WIDTH_SHIFT 24
|
||||
#define S1_VERTEX_WIDTH_MASK (0x3f<<24)
|
||||
#define S1_VERTEX_PITCH_SHIFT 16
|
||||
#define S1_VERTEX_PITCH_MASK (0x3f<<16)
|
||||
|
||||
#define TEXCOORDFMT_2D 0x0
|
||||
#define TEXCOORDFMT_3D 0x1
|
||||
#define TEXCOORDFMT_4D 0x2
|
||||
#define TEXCOORDFMT_1D 0x3
|
||||
#define TEXCOORDFMT_2D_16 0x4
|
||||
#define TEXCOORDFMT_4D_16 0x5
|
||||
#define TEXCOORDFMT_NOT_PRESENT 0xf
|
||||
#define S2_TEXCOORD_FMT0_MASK 0xf
|
||||
#define S2_TEXCOORD_FMT1_SHIFT 4
|
||||
#define S2_TEXCOORD_FMT(unit, type) ((type)<<(unit*4))
|
||||
#define S2_TEXCOORD_NONE (~0U)
|
||||
|
||||
#define TEXCOORD_WRAP_SHORTEST_TCX 8
|
||||
#define TEXCOORD_WRAP_SHORTEST_TCY 4
|
||||
#define TEXCOORD_WRAP_SHORTEST_TCZ 2
|
||||
#define TEXCOORD_PERSPECTIVE_DISABLE 1
|
||||
|
||||
#define S3_WRAP_SHORTEST_TCX(unit) (TEXCOORD_WRAP_SHORTEST_TCX << ((unit) * 4))
|
||||
#define S3_WRAP_SHORTEST_TCY(unit) (TEXCOORD_WRAP_SHORTEST_TCY << ((unit) * 4))
|
||||
#define S3_WRAP_SHORTEST_TCZ(unit) (TEXCOORD_WRAP_SHORTEST_TCZ << ((unit) * 4))
|
||||
#define S3_PERSPECTIVE_DISABLE(unit) (TEXCOORD_PERSPECTIVE_DISABLE << ((unit) * 4))
|
||||
|
||||
/* S3 not interesting */
|
||||
|
||||
#define S4_POINT_WIDTH_SHIFT 23
|
||||
#define S4_POINT_WIDTH_MASK (0x1ff<<23)
|
||||
#define S4_LINE_WIDTH_SHIFT 19
|
||||
#define S4_LINE_WIDTH_ONE (0x2<<19)
|
||||
#define S4_LINE_WIDTH_MASK (0xf<<19)
|
||||
#define S4_FLATSHADE_ALPHA (1<<18)
|
||||
#define S4_FLATSHADE_FOG (1<<17)
|
||||
#define S4_FLATSHADE_SPECULAR (1<<16)
|
||||
#define S4_FLATSHADE_COLOR (1<<15)
|
||||
#define S4_CULLMODE_BOTH (0<<13)
|
||||
#define S4_CULLMODE_NONE (1<<13)
|
||||
#define S4_CULLMODE_CW (2<<13)
|
||||
#define S4_CULLMODE_CCW (3<<13)
|
||||
#define S4_CULLMODE_MASK (3<<13)
|
||||
#define S4_VFMT_POINT_WIDTH (1<<12)
|
||||
#define S4_VFMT_SPEC_FOG (1<<11)
|
||||
#define S4_VFMT_COLOR (1<<10)
|
||||
#define S4_VFMT_DEPTH_OFFSET (1<<9)
|
||||
#define S4_VFMT_XYZ (1<<6)
|
||||
#define S4_VFMT_XYZW (2<<6)
|
||||
#define S4_VFMT_XY (3<<6)
|
||||
#define S4_VFMT_XYW (4<<6)
|
||||
#define S4_VFMT_XYZW_MASK (7<<6)
|
||||
#define S4_FORCE_DEFAULT_DIFFUSE (1<<5)
|
||||
#define S4_FORCE_DEFAULT_SPECULAR (1<<4)
|
||||
#define S4_LOCAL_DEPTH_OFFSET_ENABLE (1<<3)
|
||||
#define S4_VFMT_FOG_PARAM (1<<2)
|
||||
#define S4_SPRITE_POINT_ENABLE (1<<1)
|
||||
#define S4_LINE_ANTIALIAS_ENABLE (1<<0)
|
||||
|
||||
#define S4_VFMT_MASK (S4_VFMT_POINT_WIDTH | \
|
||||
S4_VFMT_SPEC_FOG | \
|
||||
S4_VFMT_COLOR | \
|
||||
S4_VFMT_DEPTH_OFFSET | \
|
||||
S4_VFMT_XYZW_MASK | \
|
||||
S4_VFMT_FOG_PARAM)
|
||||
|
||||
#define S5_WRITEDISABLE_ALPHA (1<<31)
|
||||
#define S5_WRITEDISABLE_RED (1<<30)
|
||||
#define S5_WRITEDISABLE_GREEN (1<<29)
|
||||
#define S5_WRITEDISABLE_BLUE (1<<28)
|
||||
#define S5_WRITEDISABLE_MASK (0xf<<28)
|
||||
#define S5_FORCE_DEFAULT_POINT_SIZE (1<<27)
|
||||
#define S5_LAST_PIXEL_ENABLE (1<<26)
|
||||
#define S5_GLOBAL_DEPTH_OFFSET_ENABLE (1<<25)
|
||||
#define S5_FOG_ENABLE (1<<24)
|
||||
#define S5_STENCIL_REF_SHIFT 16
|
||||
#define S5_STENCIL_REF_MASK (0xff<<16)
|
||||
#define S5_STENCIL_TEST_FUNC_SHIFT 13
|
||||
#define S5_STENCIL_TEST_FUNC_MASK (0x7<<13)
|
||||
#define S5_STENCIL_FAIL_SHIFT 10
|
||||
#define S5_STENCIL_FAIL_MASK (0x7<<10)
|
||||
#define S5_STENCIL_PASS_Z_FAIL_SHIFT 7
|
||||
#define S5_STENCIL_PASS_Z_FAIL_MASK (0x7<<7)
|
||||
#define S5_STENCIL_PASS_Z_PASS_SHIFT 4
|
||||
#define S5_STENCIL_PASS_Z_PASS_MASK (0x7<<4)
|
||||
#define S5_STENCIL_WRITE_ENABLE (1<<3)
|
||||
#define S5_STENCIL_TEST_ENABLE (1<<2)
|
||||
#define S5_COLOR_DITHER_ENABLE (1<<1)
|
||||
#define S5_LOGICOP_ENABLE (1<<0)
|
||||
|
||||
#define COMPAREFUNC_ALWAYS 0
|
||||
#define COMPAREFUNC_NEVER 0x1
|
||||
#define COMPAREFUNC_LESS 0x2
|
||||
#define COMPAREFUNC_EQUAL 0x3
|
||||
#define COMPAREFUNC_LEQUAL 0x4
|
||||
#define COMPAREFUNC_GREATER 0x5
|
||||
#define COMPAREFUNC_NOTEQUAL 0x6
|
||||
#define COMPAREFUNC_GEQUAL 0x7
|
||||
|
||||
#define STENCILOP_KEEP 0
|
||||
#define STENCILOP_ZERO 0x1
|
||||
#define STENCILOP_REPLACE 0x2
|
||||
#define STENCILOP_INCRSAT 0x3
|
||||
#define STENCILOP_DECRSAT 0x4
|
||||
#define STENCILOP_INCR 0x5
|
||||
#define STENCILOP_DECR 0x6
|
||||
#define STENCILOP_INVERT 0x7
|
||||
|
||||
#define S6_ALPHA_TEST_ENABLE (1<<31)
|
||||
#define S6_ALPHA_TEST_FUNC_SHIFT 28
|
||||
#define S6_ALPHA_TEST_FUNC_MASK (0x7<<28)
|
||||
#define S6_ALPHA_REF_SHIFT 20
|
||||
#define S6_ALPHA_REF_MASK (0xff<<20)
|
||||
#define S6_DEPTH_TEST_ENABLE (1<<19)
|
||||
#define S6_DEPTH_TEST_FUNC_SHIFT 16
|
||||
#define S6_DEPTH_TEST_FUNC_MASK (0x7<<16)
|
||||
#define S6_CBUF_BLEND_ENABLE (1<<15)
|
||||
#define S6_CBUF_BLEND_FUNC_SHIFT 12
|
||||
#define S6_CBUF_BLEND_FUNC_MASK (0x7<<12)
|
||||
#define S6_CBUF_SRC_BLEND_FACT_SHIFT 8
|
||||
#define S6_CBUF_SRC_BLEND_FACT_MASK (0xf<<8)
|
||||
#define S6_CBUF_DST_BLEND_FACT_SHIFT 4
|
||||
#define S6_CBUF_DST_BLEND_FACT_MASK (0xf<<4)
|
||||
#define S6_DEPTH_WRITE_ENABLE (1<<3)
|
||||
#define S6_COLOR_WRITE_ENABLE (1<<2)
|
||||
#define S6_TRISTRIP_PV_SHIFT 0
|
||||
#define S6_TRISTRIP_PV_MASK (0x3<<0)
|
||||
|
||||
#define S7_DEPTH_OFFSET_CONST_MASK ~0
|
||||
|
||||
/* 3DSTATE_MAP_DEINTERLACER_PARAMETERS */
|
||||
/* 3DSTATE_MAP_PALETTE_LOAD_32, p206 */
|
||||
|
||||
/* _3DSTATE_MODES_4, p218 */
|
||||
#define _3DSTATE_MODES_4_CMD (CMD_3D|(0x0d<<24))
|
||||
#define ENABLE_LOGIC_OP_FUNC (1<<23)
|
||||
#define LOGIC_OP_FUNC(x) ((x)<<18)
|
||||
#define LOGICOP_MASK (0xf<<18)
|
||||
#define LOGICOP_COPY 0xc
|
||||
#define MODE4_ENABLE_STENCIL_TEST_MASK ((1<<17)|(0xff00))
|
||||
#define ENABLE_STENCIL_TEST_MASK (1<<17)
|
||||
#define STENCIL_TEST_MASK(x) ((x)<<8)
|
||||
#define MODE4_ENABLE_STENCIL_WRITE_MASK ((1<<16)|(0x00ff))
|
||||
#define ENABLE_STENCIL_WRITE_MASK (1<<16)
|
||||
#define STENCIL_WRITE_MASK(x) ((x)&0xff)
|
||||
|
||||
/* _3DSTATE_MODES_5, p220 */
|
||||
#define _3DSTATE_MODES_5_CMD (CMD_3D|(0x0c<<24))
|
||||
#define PIPELINE_FLUSH_RENDER_CACHE (1<<18)
|
||||
#define PIPELINE_FLUSH_TEXTURE_CACHE (1<<16)
|
||||
|
||||
/* p221 */
|
||||
#define _3DSTATE_PIXEL_SHADER_CONSTANTS (CMD_3D|(0x1d<<24)|(0x6<<16))
|
||||
#define PS1_REG(n) (1<<(n))
|
||||
#define PS2_CONST_X(n) (n)
|
||||
#define PS3_CONST_Y(n) (n)
|
||||
#define PS4_CONST_Z(n) (n)
|
||||
#define PS5_CONST_W(n) (n)
|
||||
|
||||
/* p222 */
|
||||
|
||||
#define I915_MAX_TEX_INDIRECT 4
|
||||
#define I915_MAX_TEX_INSN 32
|
||||
#define I915_MAX_ALU_INSN 64
|
||||
#define I915_MAX_DECL_INSN 27
|
||||
#define I915_MAX_TEMPORARY 16
|
||||
|
||||
/* Each instruction is 3 dwords long, though most don't require all
|
||||
* this space. Maximum of 123 instructions. Smaller maxes per insn
|
||||
* type.
|
||||
*/
|
||||
#define _3DSTATE_PIXEL_SHADER_PROGRAM (CMD_3D|(0x1d<<24)|(0x5<<16))
|
||||
|
||||
#define REG_TYPE_R 0 /* temporary regs, no need to
|
||||
* dcl, must be written before
|
||||
* read -- Preserved between
|
||||
* phases.
|
||||
*/
|
||||
#define REG_TYPE_T 1 /* Interpolated values, must be
|
||||
* dcl'ed before use.
|
||||
*
|
||||
* 0..7: texture coord,
|
||||
* 8: diffuse spec,
|
||||
* 9: specular color,
|
||||
* 10: fog parameter in w.
|
||||
*/
|
||||
#define REG_TYPE_CONST 2 /* Restriction: only one const
|
||||
* can be referenced per
|
||||
* instruction, though it may be
|
||||
* selected for multiple inputs.
|
||||
* Constants not initialized
|
||||
* default to zero.
|
||||
*/
|
||||
#define REG_TYPE_S 3 /* sampler */
|
||||
#define REG_TYPE_OC 4 /* output color (rgba) */
|
||||
#define REG_TYPE_OD 5 /* output depth (w), xyz are
|
||||
* temporaries. If not written,
|
||||
* interpolated depth is used?
|
||||
*/
|
||||
#define REG_TYPE_U 6 /* unpreserved temporaries */
|
||||
#define REG_TYPE_MASK 0x7
|
||||
#define REG_NR_MASK 0xf
|
||||
|
||||
/* REG_TYPE_T:
|
||||
*/
|
||||
#define T_TEX0 0
|
||||
#define T_TEX1 1
|
||||
#define T_TEX2 2
|
||||
#define T_TEX3 3
|
||||
#define T_TEX4 4
|
||||
#define T_TEX5 5
|
||||
#define T_TEX6 6
|
||||
#define T_TEX7 7
|
||||
#define T_DIFFUSE 8
|
||||
#define T_SPECULAR 9
|
||||
#define T_FOG_W 10 /* interpolated fog is in W coord */
|
||||
|
||||
/* Arithmetic instructions */
|
||||
|
||||
/* .replicate_swizzle == selection and replication of a particular
|
||||
* scalar channel, ie., .xxxx, .yyyy, .zzzz or .wwww
|
||||
*/
|
||||
#define A0_NOP (0x0<<24) /* no operation */
|
||||
#define A0_ADD (0x1<<24) /* dst = src0 + src1 */
|
||||
#define A0_MOV (0x2<<24) /* dst = src0 */
|
||||
#define A0_MUL (0x3<<24) /* dst = src0 * src1 */
|
||||
#define A0_MAD (0x4<<24) /* dst = src0 * src1 + src2 */
|
||||
#define A0_DP2ADD (0x5<<24) /* dst.xyzw = src0.xy dot src1.xy + src2.replicate_swizzle */
|
||||
#define A0_DP3 (0x6<<24) /* dst.xyzw = src0.xyz dot src1.xyz */
|
||||
#define A0_DP4 (0x7<<24) /* dst.xyzw = src0.xyzw dot src1.xyzw */
|
||||
#define A0_FRC (0x8<<24) /* dst = src0 - floor(src0) */
|
||||
#define A0_RCP (0x9<<24) /* dst.xyzw = 1/(src0.replicate_swizzle) */
|
||||
#define A0_RSQ (0xa<<24) /* dst.xyzw = 1/(sqrt(abs(src0.replicate_swizzle))) */
|
||||
#define A0_EXP (0xb<<24) /* dst.xyzw = exp2(src0.replicate_swizzle) */
|
||||
#define A0_LOG (0xc<<24) /* dst.xyzw = log2(abs(src0.replicate_swizzle)) */
|
||||
#define A0_CMP (0xd<<24) /* dst = (src0 >= 0.0) ? src1 : src2 */
|
||||
#define A0_MIN (0xe<<24) /* dst = (src0 < src1) ? src0 : src1 */
|
||||
#define A0_MAX (0xf<<24) /* dst = (src0 >= src1) ? src0 : src1 */
|
||||
#define A0_FLR (0x10<<24) /* dst = floor(src0) */
|
||||
#define A0_MOD (0x11<<24) /* dst = src0 fmod 1.0 */
|
||||
#define A0_TRC (0x12<<24) /* dst = int(src0) */
|
||||
#define A0_SGE (0x13<<24) /* dst = src0 >= src1 ? 1.0 : 0.0 */
|
||||
#define A0_SLT (0x14<<24) /* dst = src0 < src1 ? 1.0 : 0.0 */
|
||||
#define A0_DEST_SATURATE (1<<22)
|
||||
#define A0_DEST_TYPE_SHIFT 19
|
||||
/* Allow: R, OC, OD, U */
|
||||
#define A0_DEST_NR_SHIFT 14
|
||||
/* Allow R: 0..15, OC,OD: 0..0, U: 0..2 */
|
||||
#define A0_DEST_CHANNEL_X (1<<10)
|
||||
#define A0_DEST_CHANNEL_Y (2<<10)
|
||||
#define A0_DEST_CHANNEL_Z (4<<10)
|
||||
#define A0_DEST_CHANNEL_W (8<<10)
|
||||
#define A0_DEST_CHANNEL_ALL (0xf<<10)
|
||||
#define A0_DEST_CHANNEL_SHIFT 10
|
||||
#define A0_SRC0_TYPE_SHIFT 7
|
||||
#define A0_SRC0_NR_SHIFT 2
|
||||
|
||||
#define A0_DEST_CHANNEL_XY (A0_DEST_CHANNEL_X|A0_DEST_CHANNEL_Y)
|
||||
#define A0_DEST_CHANNEL_XYZ (A0_DEST_CHANNEL_XY|A0_DEST_CHANNEL_Z)
|
||||
|
||||
#define SRC_X 0
|
||||
#define SRC_Y 1
|
||||
#define SRC_Z 2
|
||||
#define SRC_W 3
|
||||
#define SRC_ZERO 4
|
||||
#define SRC_ONE 5
|
||||
|
||||
#define A1_SRC0_CHANNEL_X_NEGATE (1<<31)
|
||||
#define A1_SRC0_CHANNEL_X_SHIFT 28
|
||||
#define A1_SRC0_CHANNEL_Y_NEGATE (1<<27)
|
||||
#define A1_SRC0_CHANNEL_Y_SHIFT 24
|
||||
#define A1_SRC0_CHANNEL_Z_NEGATE (1<<23)
|
||||
#define A1_SRC0_CHANNEL_Z_SHIFT 20
|
||||
#define A1_SRC0_CHANNEL_W_NEGATE (1<<19)
|
||||
#define A1_SRC0_CHANNEL_W_SHIFT 16
|
||||
#define A1_SRC1_TYPE_SHIFT 13
|
||||
#define A1_SRC1_NR_SHIFT 8
|
||||
#define A1_SRC1_CHANNEL_X_NEGATE (1<<7)
|
||||
#define A1_SRC1_CHANNEL_X_SHIFT 4
|
||||
#define A1_SRC1_CHANNEL_Y_NEGATE (1<<3)
|
||||
#define A1_SRC1_CHANNEL_Y_SHIFT 0
|
||||
|
||||
#define A2_SRC1_CHANNEL_Z_NEGATE (1<<31)
|
||||
#define A2_SRC1_CHANNEL_Z_SHIFT 28
|
||||
#define A2_SRC1_CHANNEL_W_NEGATE (1<<27)
|
||||
#define A2_SRC1_CHANNEL_W_SHIFT 24
|
||||
#define A2_SRC2_TYPE_SHIFT 21
|
||||
#define A2_SRC2_NR_SHIFT 16
|
||||
#define A2_SRC2_CHANNEL_X_NEGATE (1<<15)
|
||||
#define A2_SRC2_CHANNEL_X_SHIFT 12
|
||||
#define A2_SRC2_CHANNEL_Y_NEGATE (1<<11)
|
||||
#define A2_SRC2_CHANNEL_Y_SHIFT 8
|
||||
#define A2_SRC2_CHANNEL_Z_NEGATE (1<<7)
|
||||
#define A2_SRC2_CHANNEL_Z_SHIFT 4
|
||||
#define A2_SRC2_CHANNEL_W_NEGATE (1<<3)
|
||||
#define A2_SRC2_CHANNEL_W_SHIFT 0
|
||||
|
||||
/* Texture instructions */
|
||||
#define T0_TEXLD (0x15<<24) /* Sample texture using predeclared
|
||||
* sampler and address, and output
|
||||
* filtered texel data to destination
|
||||
* register */
|
||||
#define T0_TEXLDP (0x16<<24) /* Same as texld but performs a
|
||||
* perspective divide of the texture
|
||||
* coordinate .xyz values by .w before
|
||||
* sampling. */
|
||||
#define T0_TEXLDB (0x17<<24) /* Same as texld but biases the
|
||||
* computed LOD by w. Only S4.6 two's
|
||||
* comp is used. This implies that a
|
||||
* float to fixed conversion is
|
||||
* done. */
|
||||
#define T0_TEXKILL (0x18<<24) /* Does not perform a sampling
|
||||
* operation. Simply kills the pixel
|
||||
* if any channel of the address
|
||||
* register is < 0.0. */
|
||||
#define T0_DEST_TYPE_SHIFT 19
|
||||
/* Allow: R, OC, OD, U */
|
||||
/* Note: U (unpreserved) regs do not retain their values between
|
||||
* phases (cannot be used for feedback)
|
||||
*
|
||||
* Note: oC and OD registers can only be used as the destination of a
|
||||
* texture instruction once per phase (this is an implementation
|
||||
* restriction).
|
||||
*/
|
||||
#define T0_DEST_NR_SHIFT 14
|
||||
/* Allow R: 0..15, OC,OD: 0..0, U: 0..2 */
|
||||
#define T0_SAMPLER_NR_SHIFT 0 /* This field ignored for TEXKILL */
|
||||
#define T0_SAMPLER_NR_MASK (0xf<<0)
|
||||
|
||||
#define T1_ADDRESS_REG_TYPE_SHIFT 24 /* Reg to use as texture coord */
|
||||
/* Allow R, T, OC, OD -- R, OC, OD are 'dependent' reads, new program phase */
|
||||
#define T1_ADDRESS_REG_NR_SHIFT 17
|
||||
#define T2_MBZ 0
|
||||
|
||||
/* Declaration instructions */
|
||||
#define D0_DCL (0x19<<24) /* Declare a t (interpolated attrib)
|
||||
* register or an s (sampler)
|
||||
* register. */
|
||||
#define D0_SAMPLE_TYPE_SHIFT 22
|
||||
#define D0_SAMPLE_TYPE_2D (0x0<<22)
|
||||
#define D0_SAMPLE_TYPE_CUBE (0x1<<22)
|
||||
#define D0_SAMPLE_TYPE_VOLUME (0x2<<22)
|
||||
#define D0_SAMPLE_TYPE_MASK (0x3<<22)
|
||||
|
||||
#define D0_TYPE_SHIFT 19
|
||||
/* Allow: T, S */
|
||||
#define D0_NR_SHIFT 14
|
||||
/* Allow T: 0..10, S: 0..15 */
|
||||
#define D0_CHANNEL_X (1<<10)
|
||||
#define D0_CHANNEL_Y (2<<10)
|
||||
#define D0_CHANNEL_Z (4<<10)
|
||||
#define D0_CHANNEL_W (8<<10)
|
||||
#define D0_CHANNEL_ALL (0xf<<10)
|
||||
#define D0_CHANNEL_NONE (0<<10)
|
||||
|
||||
#define D0_CHANNEL_XY (D0_CHANNEL_X|D0_CHANNEL_Y)
|
||||
#define D0_CHANNEL_XYZ (D0_CHANNEL_XY|D0_CHANNEL_Z)
|
||||
|
||||
/* I915 Errata: Do not allow (xz), (xw), (xzw) combinations for diffuse
|
||||
* or specular declarations.
|
||||
*
|
||||
* For T dcls, only allow: (x), (xy), (xyz), (w), (xyzw)
|
||||
*
|
||||
* Must be zero for S (sampler) dcls
|
||||
*/
|
||||
#define D1_MBZ 0
|
||||
#define D2_MBZ 0
|
||||
|
||||
/* p207.
|
||||
* The DWORD count is 3 times the number of bits set in MS1_MAPMASK_MASK
|
||||
*/
|
||||
#define _3DSTATE_MAP_STATE (CMD_3D|(0x1d<<24)|(0x0<<16))
|
||||
|
||||
#define MS1_MAPMASK_SHIFT 0
|
||||
#define MS1_MAPMASK_MASK (0x8fff<<0)
|
||||
|
||||
#define MS2_UNTRUSTED_SURFACE (1<<31)
|
||||
#define MS2_ADDRESS_MASK 0xfffffffc
|
||||
#define MS2_VERTICAL_LINE_STRIDE (1<<1)
|
||||
#define MS2_VERTICAL_OFFSET (1<<1)
|
||||
|
||||
#define MS3_HEIGHT_SHIFT 21
|
||||
#define MS3_WIDTH_SHIFT 10
|
||||
#define MS3_PALETTE_SELECT (1<<9)
|
||||
#define MS3_MAPSURF_FORMAT_SHIFT 7
|
||||
#define MS3_MAPSURF_FORMAT_MASK (0x7<<7)
|
||||
#define MAPSURF_8BIT (1<<7)
|
||||
#define MAPSURF_16BIT (2<<7)
|
||||
#define MAPSURF_32BIT (3<<7)
|
||||
#define MAPSURF_422 (5<<7)
|
||||
#define MAPSURF_COMPRESSED (6<<7)
|
||||
#define MAPSURF_4BIT_INDEXED (7<<7)
|
||||
#define MS3_MT_FORMAT_MASK (0x7 << 3)
|
||||
#define MS3_MT_FORMAT_SHIFT 3
|
||||
#define MT_4BIT_IDX_ARGB8888 (7<<3) /* SURFACE_4BIT_INDEXED */
|
||||
#define MT_8BIT_I8 (0<<3) /* SURFACE_8BIT */
|
||||
#define MT_8BIT_L8 (1<<3)
|
||||
#define MT_8BIT_A8 (4<<3)
|
||||
#define MT_8BIT_MONO8 (5<<3)
|
||||
#define MT_16BIT_RGB565 (0<<3) /* SURFACE_16BIT */
|
||||
#define MT_16BIT_ARGB1555 (1<<3)
|
||||
#define MT_16BIT_ARGB4444 (2<<3)
|
||||
#define MT_16BIT_AY88 (3<<3)
|
||||
#define MT_16BIT_88DVDU (5<<3)
|
||||
#define MT_16BIT_BUMP_655LDVDU (6<<3)
|
||||
#define MT_16BIT_I16 (7<<3)
|
||||
#define MT_16BIT_L16 (8<<3)
|
||||
#define MT_16BIT_A16 (9<<3)
|
||||
#define MT_32BIT_ARGB8888 (0<<3) /* SURFACE_32BIT */
|
||||
#define MT_32BIT_ABGR8888 (1<<3)
|
||||
#define MT_32BIT_XRGB8888 (2<<3)
|
||||
#define MT_32BIT_XBGR8888 (3<<3)
|
||||
#define MT_32BIT_QWVU8888 (4<<3)
|
||||
#define MT_32BIT_AXVU8888 (5<<3)
|
||||
#define MT_32BIT_LXVU8888 (6<<3)
|
||||
#define MT_32BIT_XLVU8888 (7<<3)
|
||||
#define MT_32BIT_ARGB2101010 (8<<3)
|
||||
#define MT_32BIT_ABGR2101010 (9<<3)
|
||||
#define MT_32BIT_AWVU2101010 (0xA<<3)
|
||||
#define MT_32BIT_GR1616 (0xB<<3)
|
||||
#define MT_32BIT_VU1616 (0xC<<3)
|
||||
#define MT_32BIT_xI824 (0xD<<3)
|
||||
#define MT_32BIT_xA824 (0xE<<3)
|
||||
#define MT_32BIT_xL824 (0xF<<3)
|
||||
#define MT_422_YCRCB_SWAPY (0<<3) /* SURFACE_422 */
|
||||
#define MT_422_YCRCB_NORMAL (1<<3)
|
||||
#define MT_422_YCRCB_SWAPUV (2<<3)
|
||||
#define MT_422_YCRCB_SWAPUVY (3<<3)
|
||||
#define MT_COMPRESS_DXT1 (0<<3) /* SURFACE_COMPRESSED */
|
||||
#define MT_COMPRESS_DXT2_3 (1<<3)
|
||||
#define MT_COMPRESS_DXT4_5 (2<<3)
|
||||
#define MT_COMPRESS_FXT1 (3<<3)
|
||||
#define MT_COMPRESS_DXT1_RGB (4<<3)
|
||||
#define MS3_USE_FENCE_REGS (1<<2)
|
||||
#define MS3_TILED_SURFACE (1<<1)
|
||||
#define MS3_TILE_WALK (1<<0)
|
||||
|
||||
/* The pitch is the pitch measured in DWORDS, minus 1 */
|
||||
#define MS4_PITCH_SHIFT 21
|
||||
#define MS4_CUBE_FACE_ENA_NEGX (1<<20)
|
||||
#define MS4_CUBE_FACE_ENA_POSX (1<<19)
|
||||
#define MS4_CUBE_FACE_ENA_NEGY (1<<18)
|
||||
#define MS4_CUBE_FACE_ENA_POSY (1<<17)
|
||||
#define MS4_CUBE_FACE_ENA_NEGZ (1<<16)
|
||||
#define MS4_CUBE_FACE_ENA_POSZ (1<<15)
|
||||
#define MS4_CUBE_FACE_ENA_MASK (0x3f<<15)
|
||||
#define MS4_MAX_LOD_SHIFT 9
|
||||
#define MS4_MAX_LOD_MASK (0x3f<<9)
|
||||
#define MS4_MIP_LAYOUT_LEGACY (0<<8)
|
||||
#define MS4_MIP_LAYOUT_BELOW_LPT (0<<8)
|
||||
#define MS4_MIP_LAYOUT_RIGHT_LPT (1<<8)
|
||||
#define MS4_VOLUME_DEPTH_SHIFT 0
|
||||
#define MS4_VOLUME_DEPTH_MASK (0xff<<0)
|
||||
|
||||
/* p244.
|
||||
* The DWORD count is 3 times the number of bits set in SS1_MAPMASK_MASK.
|
||||
*/
|
||||
#define _3DSTATE_SAMPLER_STATE (CMD_3D|(0x1d<<24)|(0x1<<16))
|
||||
|
||||
#define SS1_MAPMASK_SHIFT 0
|
||||
#define SS1_MAPMASK_MASK (0x8fff<<0)
|
||||
|
||||
#define SS2_REVERSE_GAMMA_ENABLE (1<<31)
|
||||
#define SS2_PACKED_TO_PLANAR_ENABLE (1<<30)
|
||||
#define SS2_COLORSPACE_CONVERSION (1<<29)
|
||||
#define SS2_CHROMAKEY_SHIFT 27
|
||||
#define SS2_BASE_MIP_LEVEL_SHIFT 22
|
||||
#define SS2_BASE_MIP_LEVEL_MASK (0x1f<<22)
|
||||
#define SS2_MIP_FILTER_SHIFT 20
|
||||
#define SS2_MIP_FILTER_MASK (0x3<<20)
|
||||
#define MIPFILTER_NONE 0
|
||||
#define MIPFILTER_NEAREST 1
|
||||
#define MIPFILTER_LINEAR 3
|
||||
#define SS2_MAG_FILTER_SHIFT 17
|
||||
#define SS2_MAG_FILTER_MASK (0x7<<17)
|
||||
#define FILTER_NEAREST 0
|
||||
#define FILTER_LINEAR 1
|
||||
#define FILTER_ANISOTROPIC 2
|
||||
#define FILTER_4X4_1 3
|
||||
#define FILTER_4X4_2 4
|
||||
#define FILTER_4X4_FLAT 5
|
||||
#define FILTER_6X5_MONO 6 /* XXX - check */
|
||||
#define SS2_MIN_FILTER_SHIFT 14
|
||||
#define SS2_MIN_FILTER_MASK (0x7<<14)
|
||||
#define SS2_LOD_BIAS_SHIFT 5
|
||||
#define SS2_LOD_BIAS_ONE (0x10<<5)
|
||||
#define SS2_LOD_BIAS_MASK (0x1ff<<5)
|
||||
/* Shadow requires:
|
||||
* MT_X8{I,L,A}24 or MT_{I,L,A}16 texture format
|
||||
* FILTER_4X4_x MIN and MAG filters
|
||||
*/
|
||||
#define SS2_SHADOW_ENABLE (1<<4)
|
||||
#define SS2_MAX_ANISO_MASK (1<<3)
|
||||
#define SS2_MAX_ANISO_2 (0<<3)
|
||||
#define SS2_MAX_ANISO_4 (1<<3)
|
||||
#define SS2_SHADOW_FUNC_SHIFT 0
|
||||
#define SS2_SHADOW_FUNC_MASK (0x7<<0)
|
||||
/* SS2_SHADOW_FUNC values: see COMPAREFUNC_* */
|
||||
|
||||
#define SS3_MIN_LOD_SHIFT 24
|
||||
#define SS3_MIN_LOD_ONE (0x10<<24)
|
||||
#define SS3_MIN_LOD_MASK (0xff<<24)
|
||||
#define SS3_KILL_PIXEL_ENABLE (1<<17)
|
||||
#define SS3_TCX_ADDR_MODE_SHIFT 12
|
||||
#define SS3_TCX_ADDR_MODE_MASK (0x7<<12)
|
||||
#define TEXCOORDMODE_WRAP 0
|
||||
#define TEXCOORDMODE_MIRROR 1
|
||||
#define TEXCOORDMODE_CLAMP_EDGE 2
|
||||
#define TEXCOORDMODE_CUBE 3
|
||||
#define TEXCOORDMODE_CLAMP_BORDER 4
|
||||
#define TEXCOORDMODE_MIRROR_ONCE 5
|
||||
#define SS3_TCY_ADDR_MODE_SHIFT 9
|
||||
#define SS3_TCY_ADDR_MODE_MASK (0x7<<9)
|
||||
#define SS3_TCZ_ADDR_MODE_SHIFT 6
|
||||
#define SS3_TCZ_ADDR_MODE_MASK (0x7<<6)
|
||||
#define SS3_NORMALIZED_COORDS (1<<5)
|
||||
#define SS3_TEXTUREMAP_INDEX_SHIFT 1
|
||||
#define SS3_TEXTUREMAP_INDEX_MASK (0xf<<1)
|
||||
#define SS3_DEINTERLACER_ENABLE (1<<0)
|
||||
|
||||
#define SS4_BORDER_COLOR_MASK (~0)
|
||||
|
||||
/* 3DSTATE_SPAN_STIPPLE, p258
|
||||
*/
|
||||
#define _3DSTATE_STIPPLE ((0x3<<29)|(0x1d<<24)|(0x83<<16))
|
||||
#define ST1_ENABLE (1<<16)
|
||||
#define ST1_MASK (0xffff)
|
||||
|
||||
#define FLUSH_MAP_CACHE (1<<0)
|
||||
#define FLUSH_RENDER_CACHE (1<<1)
|
||||
|
||||
/* BLT commands */
|
||||
#define COLOR_BLT_CMD (CMD_2D | (0x40 << 22) | 3)
|
||||
#define XY_COLOR_BLT_CMD (CMD_2D | (0x50 << 22) | 4)
|
||||
#define XY_SETUP_CLIP_BLT_CMD (CMD_2D | (0x03 << 22) | 1)
|
||||
#define XY_SRC_COPY_BLT_CMD (CMD_2D | (0x53 << 22) | 6)
|
||||
#define SRC_COPY_BLT_CMD (CMD_2D | (0x43 << 22) | 4)
|
||||
|
||||
#define XY_MONO_PAT_BLT_CMD (CMD_2D | (0x52<<22)|0x7)
|
||||
#define XY_MONO_PAT_VERT_SEED ((1<<10) | (1<<9)|(1<<8))
|
||||
#define XY_MONO_PAT_HORT_SEED ((1<<14) | (1<<13)|(1<<12))
|
||||
#define XY_MONO_SRC_BLT_CMD (CMD_2D | (0x54<<22)|(0x6))
|
||||
|
||||
#define XY_SETUP_BLT_CMD (CMD_2D | (0x01 << 22) | 6)
|
||||
#define XY_TEXT_IMMEDIATE_BLIT_CMD (CMD_2D | (0x31 << 22))
|
||||
#define XY_TEXT_BYTE_PACKED (1 << 16)
|
||||
|
||||
/* BR00 */
|
||||
#define XY_BLT_WRITE_ALPHA (1 << 21)
|
||||
#define XY_BLT_WRITE_RGB (1 << 20)
|
||||
#define XY_SRC_TILED (1 << 15)
|
||||
#define XY_DST_TILED (1 << 11)
|
||||
|
||||
/* BR13 */
|
||||
#define BR13_565 (0x1 << 24)
|
||||
#define BR13_8888 (0x3 << 24)
|
||||
|
||||
#endif /* CAIRO_DRM_INTEL_COMMAND_PRIVATE_H */
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,45 +0,0 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CAIRO_DRM_INTEL_IOCTL_PRIVATE_H
|
||||
#define CAIRO_DRM_INTEL_IOCTL_PRIVATE_H
|
||||
|
||||
#include "cairo-drm-intel-command-private.h"
|
||||
|
||||
#include <drm/i915_drm.h>
|
||||
|
||||
struct drm_i915_gem_real_size {
|
||||
uint32_t handle;
|
||||
uint64_t size;
|
||||
};
|
||||
|
||||
#define DRM_I915_GEM_REAL_SIZE 0x2a
|
||||
#define DRM_IOCTL_I915_GEM_REAL_SIZE DRM_IOWR (DRM_COMMAND_BASE + DRM_I915_GEM_REAL_SIZE, struct drm_i915_gem_real_size)
|
||||
|
||||
#endif /* CAIRO_DRM_INTEL_IOCTL_PRIVATE_H */
|
||||
|
|
@ -1,515 +0,0 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CAIRO_DRM_INTEL_PRIVATE_H
|
||||
#define CAIRO_DRM_INTEL_PRIVATE_H
|
||||
|
||||
#include "cairoint.h"
|
||||
#include "cairo-cache-private.h"
|
||||
#include "cairo-compiler-private.h"
|
||||
#include "cairo-drm-private.h"
|
||||
#include "cairo-freelist-private.h"
|
||||
#include "cairo-list-private.h"
|
||||
#include "cairo-mutex-private.h"
|
||||
#include "cairo-rtree-private.h"
|
||||
#include "cairo-types-private.h"
|
||||
#include "cairo-pattern-private.h"
|
||||
|
||||
#include "cairo-drm-intel-ioctl-private.h"
|
||||
|
||||
#define INTEL_TILING_DEFAULT I915_TILING_Y
|
||||
|
||||
#define INTEL_BO_CACHE_BUCKETS 12 /* cache surfaces up to 16 MiB */
|
||||
|
||||
#define INTEL_GLYPH_CACHE_WIDTH 1024
|
||||
#define INTEL_GLYPH_CACHE_HEIGHT 1024
|
||||
#define INTEL_GLYPH_CACHE_MIN_SIZE 1
|
||||
#define INTEL_GLYPH_CACHE_MAX_SIZE 128
|
||||
|
||||
typedef struct _intel_bo {
|
||||
cairo_drm_bo_t base;
|
||||
|
||||
cairo_list_t link;
|
||||
cairo_list_t cache_list;
|
||||
|
||||
uint32_t offset;
|
||||
uint32_t batch_read_domains;
|
||||
uint32_t batch_write_domain;
|
||||
|
||||
uint32_t opaque0;
|
||||
uint32_t opaque1;
|
||||
|
||||
uint32_t full_size;
|
||||
uint16_t stride;
|
||||
uint16_t _stride;
|
||||
uint32_t tiling :4;
|
||||
uint32_t _tiling :4;
|
||||
uint32_t purgeable :1;
|
||||
uint32_t busy :1;
|
||||
uint32_t cpu :1;
|
||||
|
||||
struct drm_i915_gem_exec_object2 *exec;
|
||||
void *virtual;
|
||||
} intel_bo_t;
|
||||
|
||||
#define INTEL_BATCH_SIZE (64*1024)
|
||||
#define INTEL_VERTEX_BUFFER_SIZE (512*1024)
|
||||
#define INTEL_MAX_RELOCS 2048
|
||||
|
||||
static inline void
|
||||
intel_bo_mark_purgeable (intel_bo_t *bo)
|
||||
{
|
||||
if (bo->base.name == 0)
|
||||
bo->purgeable = 1;
|
||||
}
|
||||
|
||||
typedef struct _intel_vertex_buffer intel_vertex_buffer_t;
|
||||
|
||||
typedef void (*intel_vertex_buffer_new_func_t) (intel_vertex_buffer_t *vertex_buffer);
|
||||
typedef void (*intel_vertex_buffer_start_rectangles_func_t) (intel_vertex_buffer_t *vertex_buffer,
|
||||
uint32_t floats_per_vertex);
|
||||
typedef void (*intel_vertex_buffer_flush_func_t) (intel_vertex_buffer_t *vertex_buffer);
|
||||
typedef void (*intel_vertex_buffer_finish_func_t) (intel_vertex_buffer_t *vertex_buffer);
|
||||
|
||||
struct _intel_vertex_buffer {
|
||||
uint32_t vbo_batch; /* reloc position in batch, 0 -> not yet allocated */
|
||||
uint32_t vbo_offset;
|
||||
uint32_t vbo_used;
|
||||
|
||||
uint32_t vertex_index;
|
||||
uint32_t vertex_count;
|
||||
|
||||
uint32_t floats_per_vertex;
|
||||
uint32_t rectangle_size;
|
||||
|
||||
intel_bo_t *last_vbo;
|
||||
uint32_t last_vbo_offset;
|
||||
uint32_t last_vbo_space;
|
||||
|
||||
intel_vertex_buffer_new_func_t new;
|
||||
intel_vertex_buffer_start_rectangles_func_t start_rectangles;
|
||||
intel_vertex_buffer_flush_func_t flush;
|
||||
intel_vertex_buffer_finish_func_t finish;
|
||||
|
||||
uint32_t base[INTEL_VERTEX_BUFFER_SIZE / sizeof (uint32_t)];
|
||||
};
|
||||
|
||||
typedef struct _intel_batch intel_batch_t;
|
||||
|
||||
typedef void (*intel_batch_commit_func_t) (intel_batch_t *batch);
|
||||
typedef void (*intel_batch_reset_func_t) (intel_batch_t *batch);
|
||||
|
||||
struct _intel_batch {
|
||||
size_t gtt_size;
|
||||
size_t gtt_avail_size;
|
||||
|
||||
intel_batch_commit_func_t commit;
|
||||
intel_batch_reset_func_t reset;
|
||||
|
||||
uint16_t exec_count;
|
||||
uint16_t reloc_count;
|
||||
uint16_t used;
|
||||
uint16_t header;
|
||||
|
||||
intel_bo_t *target_bo[INTEL_MAX_RELOCS];
|
||||
struct drm_i915_gem_exec_object2 exec[INTEL_MAX_RELOCS];
|
||||
struct drm_i915_gem_relocation_entry reloc[INTEL_MAX_RELOCS];
|
||||
|
||||
uint32_t base[INTEL_BATCH_SIZE / sizeof (uint32_t)];
|
||||
|
||||
intel_vertex_buffer_t vertex_buffer;
|
||||
};
|
||||
|
||||
typedef struct _intel_buffer {
|
||||
intel_bo_t *bo;
|
||||
uint32_t offset;
|
||||
cairo_format_t format;
|
||||
uint32_t map0, map1;
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t stride;
|
||||
} intel_buffer_t;
|
||||
|
||||
typedef struct _intel_buffer_cache {
|
||||
int ref_count;
|
||||
intel_buffer_t buffer;
|
||||
cairo_rtree_t rtree;
|
||||
cairo_list_t link;
|
||||
} intel_buffer_cache_t;
|
||||
|
||||
typedef struct _intel_glyph {
|
||||
cairo_rtree_node_t node;
|
||||
intel_buffer_cache_t *cache;
|
||||
void **owner;
|
||||
float texcoord[3];
|
||||
int width, height;
|
||||
} intel_glyph_t;
|
||||
|
||||
typedef struct _intel_gradient_cache {
|
||||
cairo_pattern_union_t pattern;
|
||||
intel_buffer_t buffer;
|
||||
} intel_gradient_cache_t;
|
||||
#define GRADIENT_CACHE_SIZE 16
|
||||
|
||||
typedef struct _intel_surface {
|
||||
cairo_drm_surface_t drm;
|
||||
|
||||
cairo_cache_entry_t snapshot_cache_entry;
|
||||
} intel_surface_t;
|
||||
|
||||
typedef void (*intel_reset_context_func_t) (void *device);
|
||||
|
||||
typedef struct _intel_device {
|
||||
cairo_drm_device_t base;
|
||||
|
||||
size_t gtt_max_size;
|
||||
size_t gtt_avail_size;
|
||||
|
||||
cairo_freepool_t bo_pool;
|
||||
cairo_list_t bo_in_flight;
|
||||
|
||||
cairo_mutex_t mutex;
|
||||
intel_batch_t batch;
|
||||
|
||||
intel_buffer_cache_t glyph_cache[2];
|
||||
cairo_list_t fonts;
|
||||
|
||||
struct {
|
||||
intel_gradient_cache_t cache[GRADIENT_CACHE_SIZE];
|
||||
unsigned int size;
|
||||
} gradient_cache;
|
||||
|
||||
cairo_cache_t snapshot_cache;
|
||||
size_t snapshot_cache_max_size;
|
||||
|
||||
intel_reset_context_func_t reset_context;
|
||||
|
||||
cairo_status_t (*flush) (struct _intel_device *);
|
||||
} intel_device_t;
|
||||
|
||||
static inline intel_device_t *
|
||||
to_intel_device (cairo_device_t *base)
|
||||
{
|
||||
return (intel_device_t *) base;
|
||||
}
|
||||
|
||||
static inline intel_bo_t *
|
||||
to_intel_bo (cairo_drm_bo_t *base)
|
||||
{
|
||||
return (intel_bo_t *) base;
|
||||
}
|
||||
|
||||
static inline intel_bo_t *
|
||||
intel_bo_reference (intel_bo_t *bo)
|
||||
{
|
||||
return to_intel_bo (cairo_drm_bo_reference (&bo->base));
|
||||
}
|
||||
|
||||
cairo_private cairo_bool_t
|
||||
intel_bo_madvise (intel_device_t *device, intel_bo_t *bo, int madv);
|
||||
|
||||
static cairo_always_inline void
|
||||
intel_bo_destroy (intel_device_t *device, intel_bo_t *bo)
|
||||
{
|
||||
cairo_drm_bo_destroy (&device->base.base, &bo->base);
|
||||
}
|
||||
|
||||
static inline void
|
||||
intel_bo_in_flight_add (intel_device_t *device,
|
||||
intel_bo_t *bo)
|
||||
{
|
||||
if (bo->base.name == 0 && bo->exec != NULL && cairo_list_is_empty (&bo->cache_list))
|
||||
cairo_list_add (&bo->cache_list, &device->bo_in_flight);
|
||||
}
|
||||
|
||||
cairo_private int
|
||||
intel_get (int fd, int param);
|
||||
|
||||
cairo_private cairo_bool_t
|
||||
intel_info (int fd, uint64_t *gtt_size);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
intel_device_init (intel_device_t *device, int fd);
|
||||
|
||||
cairo_private void
|
||||
intel_device_fini (intel_device_t *dev);
|
||||
|
||||
cairo_private intel_bo_t *
|
||||
intel_bo_create (intel_device_t *dev,
|
||||
uint32_t max_size,
|
||||
uint32_t real_size,
|
||||
cairo_bool_t gpu_target,
|
||||
uint32_t tiling,
|
||||
uint32_t stride);
|
||||
|
||||
cairo_private intel_bo_t *
|
||||
intel_bo_create_for_name (intel_device_t *dev, uint32_t name);
|
||||
|
||||
cairo_private void
|
||||
intel_bo_set_tiling (const intel_device_t *dev,
|
||||
intel_bo_t *bo);
|
||||
|
||||
cairo_private cairo_bool_t
|
||||
intel_bo_is_inactive (const intel_device_t *device,
|
||||
intel_bo_t *bo);
|
||||
|
||||
cairo_private cairo_bool_t
|
||||
intel_bo_wait (const intel_device_t *device, const intel_bo_t *bo);
|
||||
|
||||
cairo_private void
|
||||
intel_bo_write (const intel_device_t *dev,
|
||||
intel_bo_t *bo,
|
||||
unsigned long offset,
|
||||
unsigned long size,
|
||||
const void *data);
|
||||
|
||||
cairo_private void
|
||||
intel_bo_read (const intel_device_t *dev,
|
||||
intel_bo_t *bo,
|
||||
unsigned long offset,
|
||||
unsigned long size,
|
||||
void *data);
|
||||
|
||||
cairo_private void *
|
||||
intel_bo_map (const intel_device_t *dev, intel_bo_t *bo);
|
||||
|
||||
cairo_private void
|
||||
intel_bo_unmap (intel_bo_t *bo);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
intel_bo_init (const intel_device_t *dev,
|
||||
intel_bo_t *bo,
|
||||
uint32_t size,
|
||||
uint32_t initial_domain);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
intel_bo_init_for_name (const intel_device_t *dev,
|
||||
intel_bo_t *bo,
|
||||
uint32_t size,
|
||||
uint32_t name);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
intel_bo_put_image (intel_device_t *dev,
|
||||
intel_bo_t *bo,
|
||||
cairo_image_surface_t *src,
|
||||
int src_x, int src_y,
|
||||
int width, int height,
|
||||
int dst_x, int dst_y);
|
||||
|
||||
cairo_private void
|
||||
intel_surface_init (intel_surface_t *surface,
|
||||
const cairo_surface_backend_t *backend,
|
||||
cairo_drm_device_t *device,
|
||||
cairo_format_t format,
|
||||
int width, int height);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
intel_buffer_cache_init (intel_buffer_cache_t *cache,
|
||||
intel_device_t *device,
|
||||
cairo_format_t format,
|
||||
int width, int height);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
intel_gradient_render (intel_device_t *device,
|
||||
const cairo_gradient_pattern_t *pattern,
|
||||
intel_buffer_t *buffer);
|
||||
|
||||
cairo_private cairo_int_status_t
|
||||
intel_get_glyph (intel_device_t *device,
|
||||
cairo_scaled_font_t *scaled_font,
|
||||
cairo_scaled_glyph_t *scaled_glyph);
|
||||
|
||||
cairo_private void
|
||||
intel_scaled_glyph_fini (cairo_scaled_glyph_t *scaled_glyph,
|
||||
cairo_scaled_font_t *scaled_font);
|
||||
|
||||
cairo_private void
|
||||
intel_scaled_font_fini (cairo_scaled_font_t *scaled_font);
|
||||
|
||||
cairo_private void
|
||||
intel_glyph_cache_unpin (intel_device_t *device);
|
||||
|
||||
static inline intel_glyph_t *
|
||||
intel_glyph_pin (intel_glyph_t *glyph)
|
||||
{
|
||||
cairo_rtree_node_t *node = &glyph->node;
|
||||
if (unlikely (node->pinned == 0))
|
||||
return _cairo_rtree_pin (&glyph->cache->rtree, node);
|
||||
return glyph;
|
||||
}
|
||||
|
||||
cairo_private cairo_status_t
|
||||
intel_snapshot_cache_insert (intel_device_t *device,
|
||||
intel_surface_t *surface);
|
||||
|
||||
cairo_private void
|
||||
intel_surface_detach_snapshot (cairo_surface_t *abstract_surface);
|
||||
|
||||
cairo_private void
|
||||
intel_snapshot_cache_thaw (intel_device_t *device);
|
||||
|
||||
cairo_private void
|
||||
intel_throttle (intel_device_t *device);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
intel_surface_acquire_source_image (void *abstract_surface,
|
||||
cairo_image_surface_t **image_out,
|
||||
void **image_extra);
|
||||
|
||||
cairo_private void
|
||||
intel_surface_release_source_image (void *abstract_surface,
|
||||
cairo_image_surface_t *image,
|
||||
void *image_extra);
|
||||
cairo_private cairo_surface_t *
|
||||
intel_surface_map_to_image (void *abstract_surface);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
intel_surface_flush (void *abstract_surface,
|
||||
unsigned flags);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
intel_surface_finish (void *abstract_surface);
|
||||
|
||||
cairo_private void
|
||||
intel_dump_batchbuffer (const void *batch,
|
||||
uint32_t length,
|
||||
int devid);
|
||||
|
||||
static inline uint32_t cairo_const
|
||||
MS3_tiling (uint32_t tiling)
|
||||
{
|
||||
switch (tiling) {
|
||||
default:
|
||||
case I915_TILING_NONE: return 0;
|
||||
case I915_TILING_X: return MS3_TILED_SURFACE;
|
||||
case I915_TILING_Y: return MS3_TILED_SURFACE | MS3_TILE_WALK;
|
||||
}
|
||||
}
|
||||
|
||||
static inline float cairo_const
|
||||
texcoord_2d_16 (double x, double y)
|
||||
{
|
||||
union {
|
||||
uint32_t ui;
|
||||
float f;
|
||||
} u;
|
||||
u.ui = (_cairo_half_from_float (y) << 16) | _cairo_half_from_float (x);
|
||||
return u.f;
|
||||
}
|
||||
|
||||
#define PCI_CHIP_I810 0x7121
|
||||
#define PCI_CHIP_I810_DC100 0x7123
|
||||
#define PCI_CHIP_I810_E 0x7125
|
||||
#define PCI_CHIP_I815 0x1132
|
||||
|
||||
#define PCI_CHIP_I830_M 0x3577
|
||||
#define PCI_CHIP_845_G 0x2562
|
||||
#define PCI_CHIP_I855_GM 0x3582
|
||||
#define PCI_CHIP_I865_G 0x2572
|
||||
|
||||
#define PCI_CHIP_I915_G 0x2582
|
||||
#define PCI_CHIP_E7221_G 0x258A
|
||||
#define PCI_CHIP_I915_GM 0x2592
|
||||
#define PCI_CHIP_I945_G 0x2772
|
||||
#define PCI_CHIP_I945_GM 0x27A2
|
||||
#define PCI_CHIP_I945_GME 0x27AE
|
||||
|
||||
#define PCI_CHIP_Q35_G 0x29B2
|
||||
#define PCI_CHIP_G33_G 0x29C2
|
||||
#define PCI_CHIP_Q33_G 0x29D2
|
||||
|
||||
#define PCI_CHIP_IGD_GM 0xA011
|
||||
#define PCI_CHIP_IGD_G 0xA001
|
||||
|
||||
#define IS_IGDGM(devid) (devid == PCI_CHIP_IGD_GM)
|
||||
#define IS_IGDG(devid) (devid == PCI_CHIP_IGD_G)
|
||||
#define IS_IGD(devid) (IS_IGDG(devid) || IS_IGDGM(devid))
|
||||
|
||||
#define PCI_CHIP_I965_G 0x29A2
|
||||
#define PCI_CHIP_I965_Q 0x2992
|
||||
#define PCI_CHIP_I965_G_1 0x2982
|
||||
#define PCI_CHIP_I946_GZ 0x2972
|
||||
#define PCI_CHIP_I965_GM 0x2A02
|
||||
#define PCI_CHIP_I965_GME 0x2A12
|
||||
|
||||
#define PCI_CHIP_GM45_GM 0x2A42
|
||||
|
||||
#define PCI_CHIP_IGD_E_G 0x2E02
|
||||
#define PCI_CHIP_Q45_G 0x2E12
|
||||
#define PCI_CHIP_G45_G 0x2E22
|
||||
#define PCI_CHIP_G41_G 0x2E32
|
||||
|
||||
#define PCI_CHIP_ILD_G 0x0042
|
||||
#define PCI_CHIP_ILM_G 0x0046
|
||||
|
||||
#define IS_MOBILE(devid) (devid == PCI_CHIP_I855_GM || \
|
||||
devid == PCI_CHIP_I915_GM || \
|
||||
devid == PCI_CHIP_I945_GM || \
|
||||
devid == PCI_CHIP_I945_GME || \
|
||||
devid == PCI_CHIP_I965_GM || \
|
||||
devid == PCI_CHIP_I965_GME || \
|
||||
devid == PCI_CHIP_GM45_GM || IS_IGD(devid))
|
||||
|
||||
#define IS_G45(devid) (devid == PCI_CHIP_IGD_E_G || \
|
||||
devid == PCI_CHIP_Q45_G || \
|
||||
devid == PCI_CHIP_G45_G || \
|
||||
devid == PCI_CHIP_G41_G)
|
||||
#define IS_GM45(devid) (devid == PCI_CHIP_GM45_GM)
|
||||
#define IS_G4X(devid) (IS_G45(devid) || IS_GM45(devid))
|
||||
|
||||
#define IS_ILD(devid) (devid == PCI_CHIP_ILD_G)
|
||||
#define IS_ILM(devid) (devid == PCI_CHIP_ILM_G)
|
||||
#define IS_IRONLAKE(devid) (IS_ILD(devid) || IS_ILM(devid))
|
||||
|
||||
#define IS_915(devid) (devid == PCI_CHIP_I915_G || \
|
||||
devid == PCI_CHIP_E7221_G || \
|
||||
devid == PCI_CHIP_I915_GM)
|
||||
|
||||
#define IS_945(devid) (devid == PCI_CHIP_I945_G || \
|
||||
devid == PCI_CHIP_I945_GM || \
|
||||
devid == PCI_CHIP_I945_GME || \
|
||||
devid == PCI_CHIP_G33_G || \
|
||||
devid == PCI_CHIP_Q33_G || \
|
||||
devid == PCI_CHIP_Q35_G || IS_IGD(devid))
|
||||
|
||||
#define IS_965(devid) (devid == PCI_CHIP_I965_G || \
|
||||
devid == PCI_CHIP_I965_Q || \
|
||||
devid == PCI_CHIP_I965_G_1 || \
|
||||
devid == PCI_CHIP_I965_GM || \
|
||||
devid == PCI_CHIP_I965_GME || \
|
||||
devid == PCI_CHIP_I946_GZ || \
|
||||
IS_G4X(devid) || \
|
||||
IS_IRONLAKE(devid))
|
||||
|
||||
#define IS_9XX(devid) (IS_915(devid) || \
|
||||
IS_945(devid) || \
|
||||
IS_965(devid))
|
||||
|
||||
|
||||
#endif /* CAIRO_DRM_INTEL_PRIVATE_H */
|
||||
|
|
@ -1,454 +0,0 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
|
||||
#include "cairo-drm-private.h"
|
||||
#include "cairo-drm-intel-private.h"
|
||||
|
||||
#include "cairo-default-context-private.h"
|
||||
#include "cairo-error-private.h"
|
||||
#include "cairo-image-surface-private.h"
|
||||
|
||||
/* Basic generic/stub surface for intel chipsets */
|
||||
|
||||
#define MAX_SIZE 2048
|
||||
|
||||
static cairo_surface_t *
|
||||
intel_surface_create_similar (void *abstract_surface,
|
||||
cairo_content_t content,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
return cairo_image_surface_create (_cairo_format_from_content (content),
|
||||
width, height);
|
||||
}
|
||||
|
||||
cairo_status_t
|
||||
intel_surface_finish (void *abstract_surface)
|
||||
{
|
||||
intel_surface_t *surface = abstract_surface;
|
||||
|
||||
intel_bo_in_flight_add (to_intel_device (surface->drm.base.device),
|
||||
to_intel_bo (surface->drm.bo));
|
||||
return _cairo_drm_surface_finish (&surface->drm);
|
||||
}
|
||||
|
||||
static void
|
||||
surface_finish_and_destroy (cairo_surface_t *surface)
|
||||
{
|
||||
cairo_surface_finish (surface);
|
||||
cairo_surface_destroy (surface);
|
||||
}
|
||||
|
||||
cairo_status_t
|
||||
intel_surface_acquire_source_image (void *abstract_surface,
|
||||
cairo_image_surface_t **image_out,
|
||||
void **image_extra)
|
||||
{
|
||||
intel_surface_t *surface = abstract_surface;
|
||||
cairo_surface_t *image;
|
||||
cairo_status_t status;
|
||||
void *ptr;
|
||||
|
||||
if (surface->drm.fallback != NULL) {
|
||||
image = surface->drm.fallback;
|
||||
goto DONE;
|
||||
}
|
||||
|
||||
image = _cairo_surface_has_snapshot (&surface->drm.base,
|
||||
&_cairo_image_surface_backend);
|
||||
if (image != NULL)
|
||||
goto DONE;
|
||||
|
||||
if (surface->drm.base.backend->flush != NULL) {
|
||||
status = surface->drm.base.backend->flush (surface);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
}
|
||||
|
||||
ptr = intel_bo_map (to_intel_device (surface->drm.base.device),
|
||||
to_intel_bo (surface->drm.bo));
|
||||
if (unlikely (ptr == NULL))
|
||||
return _cairo_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
image = cairo_image_surface_create_for_data (ptr,
|
||||
surface->drm.format,
|
||||
surface->drm.width,
|
||||
surface->drm.height,
|
||||
surface->drm.stride);
|
||||
if (unlikely (image->status))
|
||||
return image->status;
|
||||
|
||||
_cairo_surface_attach_snapshot (&surface->drm.base, image, surface_finish_and_destroy);
|
||||
|
||||
DONE:
|
||||
*image_out = (cairo_image_surface_t *) cairo_surface_reference (image);
|
||||
*image_extra = NULL;
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
intel_surface_release_source_image (void *abstract_surface,
|
||||
cairo_image_surface_t *image,
|
||||
void *image_extra)
|
||||
{
|
||||
cairo_surface_destroy (&image->base);
|
||||
}
|
||||
|
||||
cairo_surface_t *
|
||||
intel_surface_map_to_image (void *abstract_surface)
|
||||
{
|
||||
intel_surface_t *surface = abstract_surface;
|
||||
|
||||
if (surface->drm.fallback == NULL) {
|
||||
cairo_surface_t *image;
|
||||
cairo_status_t status;
|
||||
void *ptr;
|
||||
|
||||
if (surface->drm.base.backend->flush != NULL) {
|
||||
status = surface->drm.base.backend->flush (surface);
|
||||
if (unlikely (status))
|
||||
return _cairo_surface_create_in_error (status);
|
||||
}
|
||||
|
||||
ptr = intel_bo_map (to_intel_device (surface->drm.base.device),
|
||||
to_intel_bo (surface->drm.bo));
|
||||
if (unlikely (ptr == NULL))
|
||||
return _cairo_surface_create_in_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
image = cairo_image_surface_create_for_data (ptr,
|
||||
surface->drm.format,
|
||||
surface->drm.width,
|
||||
surface->drm.height,
|
||||
surface->drm.stride);
|
||||
if (unlikely (image->status))
|
||||
return image;
|
||||
|
||||
surface->drm.fallback = image;
|
||||
}
|
||||
|
||||
return surface->drm.fallback;
|
||||
}
|
||||
|
||||
cairo_status_t
|
||||
intel_surface_flush (void *abstract_surface, unsigned flags)
|
||||
{
|
||||
intel_surface_t *surface = abstract_surface;
|
||||
cairo_status_t status;
|
||||
|
||||
if (flags)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
if (surface->drm.fallback == NULL)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
/* kill any outstanding maps */
|
||||
cairo_surface_finish (surface->drm.fallback);
|
||||
|
||||
status = cairo_surface_status (surface->drm.fallback);
|
||||
cairo_surface_destroy (surface->drm.fallback);
|
||||
surface->drm.fallback = NULL;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
intel_surface_paint (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_clip_t *clip)
|
||||
{
|
||||
return _cairo_surface_paint (intel_surface_map_to_image (abstract_surface),
|
||||
op, source, clip);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
intel_surface_mask (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
const cairo_pattern_t *mask,
|
||||
cairo_clip_t *clip)
|
||||
{
|
||||
return _cairo_surface_mask (intel_surface_map_to_image (abstract_surface),
|
||||
op, source, mask, clip);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
intel_surface_stroke (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_path_fixed_t *path,
|
||||
const cairo_stroke_style_t *stroke_style,
|
||||
const cairo_matrix_t *ctm,
|
||||
const cairo_matrix_t *ctm_inverse,
|
||||
double tolerance,
|
||||
cairo_antialias_t antialias,
|
||||
cairo_clip_t *clip)
|
||||
{
|
||||
return _cairo_surface_stroke (intel_surface_map_to_image (abstract_surface),
|
||||
op, source, path, stroke_style, ctm, ctm_inverse,
|
||||
tolerance, antialias, clip);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
intel_surface_fill (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_path_fixed_t *path,
|
||||
cairo_fill_rule_t fill_rule,
|
||||
double tolerance,
|
||||
cairo_antialias_t antialias,
|
||||
cairo_clip_t *clip)
|
||||
{
|
||||
return _cairo_surface_fill (intel_surface_map_to_image (abstract_surface),
|
||||
op, source, path, fill_rule,
|
||||
tolerance, antialias, clip);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
intel_surface_glyphs (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font,
|
||||
cairo_clip_t *clip,
|
||||
int *num_remaining)
|
||||
{
|
||||
*num_remaining = 0;
|
||||
return _cairo_surface_show_text_glyphs (intel_surface_map_to_image (abstract_surface),
|
||||
op, source,
|
||||
NULL, 0,
|
||||
glyphs, num_glyphs,
|
||||
NULL, 0, 0,
|
||||
scaled_font, clip);
|
||||
}
|
||||
|
||||
static const cairo_surface_backend_t intel_surface_backend = {
|
||||
CAIRO_SURFACE_TYPE_DRM,
|
||||
_cairo_default_context_create,
|
||||
|
||||
intel_surface_create_similar,
|
||||
intel_surface_finish,
|
||||
|
||||
NULL,
|
||||
intel_surface_acquire_source_image,
|
||||
intel_surface_release_source_image,
|
||||
|
||||
NULL, NULL, NULL,
|
||||
NULL, /* composite */
|
||||
NULL, /* fill */
|
||||
NULL, /* trapezoids */
|
||||
NULL, /* span */
|
||||
NULL, /* check-span */
|
||||
|
||||
NULL, /* copy_page */
|
||||
NULL, /* show_page */
|
||||
_cairo_drm_surface_get_extents,
|
||||
NULL, /* old-glyphs */
|
||||
_cairo_drm_surface_get_font_options,
|
||||
|
||||
intel_surface_flush,
|
||||
NULL, /* mark dirty */
|
||||
NULL, NULL, /* font/glyph fini */
|
||||
|
||||
intel_surface_paint,
|
||||
intel_surface_mask,
|
||||
intel_surface_stroke,
|
||||
intel_surface_fill,
|
||||
intel_surface_glyphs,
|
||||
};
|
||||
|
||||
void
|
||||
intel_surface_init (intel_surface_t *surface,
|
||||
const cairo_surface_backend_t *backend,
|
||||
cairo_drm_device_t *device,
|
||||
cairo_format_t format,
|
||||
int width, int height)
|
||||
{
|
||||
_cairo_surface_init (&surface->drm.base,
|
||||
backend,
|
||||
&device->base,
|
||||
_cairo_content_from_format (format),
|
||||
FALSE);
|
||||
|
||||
_cairo_drm_surface_init (&surface->drm, format, width, height);
|
||||
|
||||
surface->snapshot_cache_entry.hash = 0;
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
intel_surface_create (cairo_drm_device_t *device,
|
||||
cairo_format_t format,
|
||||
int width, int height)
|
||||
{
|
||||
intel_surface_t *surface;
|
||||
cairo_status_t status;
|
||||
|
||||
surface = _cairo_malloc (sizeof (intel_surface_t));
|
||||
if (unlikely (surface == NULL))
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
|
||||
intel_surface_init (surface, &intel_surface_backend, device,
|
||||
format, width, height);
|
||||
|
||||
if (width && height) {
|
||||
/* Vol I, p134: size restrictions for textures */
|
||||
width = (width + 3) & -4;
|
||||
height = (height + 1) & -2;
|
||||
surface->drm.stride =
|
||||
cairo_format_stride_for_width (surface->drm.format, width);
|
||||
surface->drm.bo = &intel_bo_create (to_intel_device (&device->base),
|
||||
surface->drm.stride * height,
|
||||
surface->drm.stride * height,
|
||||
TRUE, I915_TILING_NONE, surface->drm.stride)->base;
|
||||
if (surface->drm.bo == NULL) {
|
||||
status = _cairo_drm_surface_finish (&surface->drm);
|
||||
free (surface);
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
}
|
||||
}
|
||||
|
||||
return &surface->drm.base;
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
intel_surface_create_for_name (cairo_drm_device_t *device,
|
||||
unsigned int name,
|
||||
cairo_format_t format,
|
||||
int width, int height, int stride)
|
||||
{
|
||||
intel_surface_t *surface;
|
||||
cairo_status_t status;
|
||||
|
||||
switch (format) {
|
||||
default:
|
||||
case CAIRO_FORMAT_INVALID:
|
||||
case CAIRO_FORMAT_A1:
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
|
||||
case CAIRO_FORMAT_ARGB32:
|
||||
case CAIRO_FORMAT_RGB16_565:
|
||||
case CAIRO_FORMAT_RGB24:
|
||||
case CAIRO_FORMAT_A8:
|
||||
break;
|
||||
}
|
||||
|
||||
if (stride < cairo_format_stride_for_width (format, width))
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_STRIDE));
|
||||
|
||||
surface = _cairo_malloc (sizeof (intel_surface_t));
|
||||
if (unlikely (surface == NULL))
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
|
||||
intel_surface_init (surface, &intel_surface_backend,
|
||||
device, format, width, height);
|
||||
|
||||
if (width && height) {
|
||||
surface->drm.stride = stride;
|
||||
|
||||
surface->drm.bo = &intel_bo_create_for_name (to_intel_device (&device->base),
|
||||
name)->base;
|
||||
if (unlikely (surface->drm.bo == NULL)) {
|
||||
status = _cairo_drm_surface_finish (&surface->drm);
|
||||
free (surface);
|
||||
return _cairo_surface_create_in_error (_cairo_error
|
||||
(CAIRO_STATUS_NO_MEMORY));
|
||||
}
|
||||
}
|
||||
|
||||
return &surface->drm.base;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
intel_surface_enable_scan_out (void *abstract_surface)
|
||||
{
|
||||
intel_surface_t *surface = abstract_surface;
|
||||
|
||||
if (unlikely (surface->drm.bo == NULL))
|
||||
return _cairo_error (CAIRO_STATUS_INVALID_SIZE);
|
||||
|
||||
to_intel_bo (surface->drm.bo)->tiling = I915_TILING_X;
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
intel_device_throttle (cairo_drm_device_t *device)
|
||||
{
|
||||
intel_throttle (to_intel_device (&device->base));
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
intel_device_destroy (void *data)
|
||||
{
|
||||
intel_device_t *device = data;
|
||||
|
||||
intel_device_fini (device);
|
||||
|
||||
free (data);
|
||||
}
|
||||
|
||||
cairo_drm_device_t *
|
||||
_cairo_drm_intel_device_create (int fd, dev_t dev, int vendor_id, int chip_id)
|
||||
{
|
||||
intel_device_t *device;
|
||||
cairo_status_t status;
|
||||
|
||||
if (! intel_info (fd, NULL))
|
||||
return NULL;
|
||||
|
||||
device = _cairo_malloc (sizeof (intel_device_t));
|
||||
if (unlikely (device == NULL))
|
||||
return (cairo_drm_device_t *) _cairo_device_create_in_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
status = intel_device_init (device, fd);
|
||||
if (unlikely (status)) {
|
||||
free (device);
|
||||
return (cairo_drm_device_t *) _cairo_device_create_in_error (status);
|
||||
}
|
||||
|
||||
device->base.surface.create = intel_surface_create;
|
||||
device->base.surface.create_for_name = intel_surface_create_for_name;
|
||||
device->base.surface.create_from_cacheable_image = NULL;
|
||||
device->base.surface.flink = _cairo_drm_surface_flink;
|
||||
device->base.surface.enable_scan_out = intel_surface_enable_scan_out;
|
||||
|
||||
device->base.surface.map_to_image = intel_surface_map_to_image;
|
||||
|
||||
device->base.device.flush = NULL;
|
||||
device->base.device.throttle = intel_device_throttle;
|
||||
device->base.device.destroy = intel_device_destroy;
|
||||
|
||||
return _cairo_drm_device_init (&device->base,
|
||||
fd, dev,
|
||||
vendor_id, chip_id,
|
||||
MAX_SIZE);
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,238 +0,0 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Chris Wilson.
|
||||
*
|
||||
* Contributors(s):
|
||||
* Chris Wilson <chris@chris-wilson.co.uk>
|
||||
*/
|
||||
|
||||
#ifndef CAIRO_DRM_PRIVATE_H
|
||||
#define CAIRO_DRM_PRIVATE_H
|
||||
|
||||
#include "cairo-drm.h"
|
||||
|
||||
#include "cairo-device-private.h"
|
||||
#include "cairo-reference-count-private.h"
|
||||
#include "cairo-surface-private.h"
|
||||
|
||||
#include <sys/types.h> /* dev_t */
|
||||
|
||||
typedef struct _cairo_drm_device cairo_drm_device_t;
|
||||
|
||||
typedef cairo_drm_device_t *
|
||||
(*cairo_drm_device_create_func_t) (int fd,
|
||||
dev_t dev,
|
||||
int vendor_id,
|
||||
int chip_id);
|
||||
|
||||
typedef cairo_int_status_t
|
||||
(*cairo_drm_device_flush_func_t) (cairo_drm_device_t *device);
|
||||
|
||||
typedef cairo_int_status_t
|
||||
(*cairo_drm_device_throttle_func_t) (cairo_drm_device_t *device);
|
||||
|
||||
typedef void
|
||||
(*cairo_drm_device_destroy_func_t) (void *data);
|
||||
|
||||
typedef cairo_surface_t *
|
||||
(*cairo_drm_surface_create_func_t) (cairo_drm_device_t *device,
|
||||
cairo_format_t format,
|
||||
int width, int height);
|
||||
|
||||
typedef cairo_surface_t *
|
||||
(*cairo_drm_surface_create_for_name_func_t) (cairo_drm_device_t *device,
|
||||
unsigned int name,
|
||||
cairo_format_t format,
|
||||
int width, int height, int stride);
|
||||
|
||||
typedef cairo_surface_t *
|
||||
(*cairo_drm_surface_create_from_cacheable_image_func_t)
|
||||
(cairo_drm_device_t *device, cairo_surface_t *image);
|
||||
|
||||
typedef cairo_int_status_t
|
||||
(*cairo_drm_surface_flink_func_t) (void *surface);
|
||||
|
||||
typedef cairo_status_t
|
||||
(*cairo_drm_surface_enable_scan_out_func_t) (void *surface);
|
||||
|
||||
typedef cairo_surface_t *
|
||||
(*cairo_drm_surface_map_to_image_func_t) (void *surface);
|
||||
|
||||
typedef struct _cairo_drm_bo_backend {
|
||||
void (*release) (void *device, void *bo);
|
||||
} cairo_drm_bo_backend_t;
|
||||
|
||||
typedef struct _cairo_drm_device_backend {
|
||||
cairo_drm_device_flush_func_t flush;
|
||||
cairo_drm_device_throttle_func_t throttle;
|
||||
cairo_drm_device_destroy_func_t destroy;
|
||||
} cairo_drm_device_backend_t;
|
||||
|
||||
typedef struct _cairo_drm_surface_backend {
|
||||
cairo_drm_surface_create_func_t create;
|
||||
cairo_drm_surface_create_for_name_func_t create_for_name;
|
||||
cairo_drm_surface_create_from_cacheable_image_func_t create_from_cacheable_image;
|
||||
cairo_drm_surface_flink_func_t flink;
|
||||
cairo_drm_surface_enable_scan_out_func_t enable_scan_out;
|
||||
cairo_drm_surface_map_to_image_func_t map_to_image;
|
||||
} cairo_drm_surface_backend_t;
|
||||
|
||||
typedef struct _cairo_drm_bo {
|
||||
cairo_reference_count_t ref_count;
|
||||
uint32_t name;
|
||||
uint32_t handle;
|
||||
uint32_t size;
|
||||
} cairo_drm_bo_t;
|
||||
|
||||
struct _cairo_drm_device {
|
||||
cairo_device_t base;
|
||||
|
||||
int vendor_id;
|
||||
int chip_id;
|
||||
dev_t id;
|
||||
int fd;
|
||||
|
||||
int max_surface_size;
|
||||
|
||||
cairo_drm_bo_backend_t bo;
|
||||
cairo_drm_surface_backend_t surface;
|
||||
cairo_drm_device_backend_t device;
|
||||
|
||||
cairo_drm_device_t *next, *prev;
|
||||
};
|
||||
|
||||
typedef struct _cairo_drm_surface {
|
||||
cairo_surface_t base;
|
||||
|
||||
cairo_drm_bo_t *bo;
|
||||
|
||||
cairo_format_t format;
|
||||
int width, height, stride;
|
||||
|
||||
cairo_surface_t *fallback;
|
||||
uint32_t map_count;
|
||||
} cairo_drm_surface_t;
|
||||
|
||||
static inline cairo_drm_bo_t *
|
||||
cairo_drm_bo_reference (cairo_drm_bo_t *bo)
|
||||
{
|
||||
_cairo_reference_count_inc (&bo->ref_count);
|
||||
return bo;
|
||||
}
|
||||
|
||||
static cairo_always_inline void
|
||||
cairo_drm_bo_destroy (cairo_device_t *abstract_device,
|
||||
cairo_drm_bo_t *bo)
|
||||
{
|
||||
if (_cairo_reference_count_dec_and_test (&bo->ref_count)) {
|
||||
cairo_drm_device_t *device = (cairo_drm_device_t *) abstract_device;
|
||||
device->bo.release (device, bo);
|
||||
}
|
||||
}
|
||||
|
||||
cairo_private cairo_status_t
|
||||
_cairo_drm_bo_open_for_name (const cairo_drm_device_t *dev,
|
||||
cairo_drm_bo_t *bo,
|
||||
uint32_t name);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
_cairo_drm_bo_flink (const cairo_drm_device_t *dev,
|
||||
cairo_drm_bo_t *bo);
|
||||
|
||||
cairo_private void
|
||||
_cairo_drm_bo_close (const cairo_drm_device_t *dev,
|
||||
cairo_drm_bo_t *bo);
|
||||
|
||||
cairo_private void
|
||||
_cairo_drm_surface_init (cairo_drm_surface_t *surface,
|
||||
cairo_format_t format,
|
||||
int width, int height);
|
||||
|
||||
cairo_private cairo_status_t
|
||||
_cairo_drm_surface_finish (cairo_drm_surface_t *surface);
|
||||
|
||||
cairo_private void
|
||||
_cairo_drm_surface_get_font_options (void *abstract_surface,
|
||||
cairo_font_options_t *options);
|
||||
|
||||
cairo_private cairo_bool_t
|
||||
_cairo_drm_surface_get_extents (void *abstract_surface,
|
||||
cairo_rectangle_int_t *rectangle);
|
||||
|
||||
cairo_private cairo_int_status_t
|
||||
_cairo_drm_surface_flink (void *abstract_surface);
|
||||
|
||||
static inline cairo_drm_device_t *
|
||||
_cairo_drm_device_create_in_error (cairo_status_t status)
|
||||
{
|
||||
return (cairo_drm_device_t *) _cairo_device_create_in_error (CAIRO_STATUS_NO_MEMORY);
|
||||
}
|
||||
|
||||
cairo_private cairo_drm_device_t *
|
||||
_cairo_drm_device_init (cairo_drm_device_t *device,
|
||||
int fd,
|
||||
dev_t devid,
|
||||
int vendor_id,
|
||||
int chip_id,
|
||||
int max_surface_size);
|
||||
|
||||
cairo_private void
|
||||
_cairo_drm_device_fini (cairo_drm_device_t *device);
|
||||
|
||||
/* h/w specific backends */
|
||||
|
||||
cairo_private cairo_drm_device_t *
|
||||
_cairo_drm_intel_device_create (int fd, dev_t dev, int vendor_id, int chip_id);
|
||||
|
||||
cairo_private cairo_drm_device_t *
|
||||
_cairo_drm_i915_device_create (int fd, dev_t dev, int vendor_id, int chip_id);
|
||||
|
||||
cairo_private cairo_drm_device_t *
|
||||
_cairo_drm_i965_device_create (int fd, dev_t dev, int vendor_id, int chip_id);
|
||||
|
||||
cairo_private cairo_drm_device_t *
|
||||
_cairo_drm_radeon_device_create (int fd, dev_t dev, int vendor_id, int chip_id);
|
||||
|
||||
#if CAIRO_HAS_GALLIUM_SURFACE
|
||||
cairo_private cairo_drm_device_t *
|
||||
_cairo_drm_gallium_device_create (int fd, dev_t dev, int vendor_id, int chip_id);
|
||||
#endif
|
||||
|
||||
slim_hidden_proto (cairo_drm_device_default);
|
||||
slim_hidden_proto (cairo_drm_device_get);
|
||||
slim_hidden_proto (cairo_drm_device_get_for_fd);
|
||||
|
||||
slim_hidden_proto (cairo_drm_surface_create_for_name);
|
||||
|
||||
cairo_private cairo_bool_t
|
||||
_cairo_drm_size_is_valid (cairo_device_t *abstract_device,
|
||||
int width, int height);
|
||||
|
||||
#endif /* CAIRO_DRM_PRIVATE_H */
|
||||
|
|
@ -1,103 +0,0 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CAIRO_DRM_RADEON_PRIVATE_H
|
||||
#define CAIRO_DRM_RADEON_PRIVATE_H
|
||||
|
||||
#include "cairo-compiler-private.h"
|
||||
#include "cairo-types-private.h"
|
||||
#include "cairo-drm-private.h"
|
||||
#include "cairo-freelist-private.h"
|
||||
|
||||
typedef struct _radeon_bo {
|
||||
cairo_drm_bo_t base;
|
||||
|
||||
void *virtual;
|
||||
|
||||
cairo_bool_t in_batch;
|
||||
uint32_t read_domains;
|
||||
uint32_t write_domain;
|
||||
} radeon_bo_t;
|
||||
|
||||
typedef struct _radeon_device {
|
||||
cairo_drm_device_t base;
|
||||
cairo_freepool_t bo_pool;
|
||||
|
||||
uint64_t vram_limit;
|
||||
uint64_t gart_limit;
|
||||
} radeon_device_t;
|
||||
|
||||
cairo_private cairo_status_t
|
||||
radeon_device_init (radeon_device_t *device, int fd);
|
||||
|
||||
cairo_private void
|
||||
radeon_device_fini (radeon_device_t *device);
|
||||
|
||||
cairo_private cairo_bool_t
|
||||
radeon_info (int fd,
|
||||
uint64_t *gart_size,
|
||||
uint64_t *vram_size);
|
||||
|
||||
cairo_private void
|
||||
radeon_bo_write (const radeon_device_t *dev,
|
||||
radeon_bo_t *bo,
|
||||
unsigned long offset,
|
||||
unsigned long size,
|
||||
const void *data);
|
||||
|
||||
cairo_private void
|
||||
radeon_bo_read (const radeon_device_t *dev,
|
||||
radeon_bo_t *bo,
|
||||
unsigned long offset,
|
||||
unsigned long size,
|
||||
void *data);
|
||||
|
||||
cairo_private void
|
||||
radeon_bo_wait (const radeon_device_t *dev, radeon_bo_t *bo);
|
||||
|
||||
cairo_private void *
|
||||
radeon_bo_map (const radeon_device_t *dev, radeon_bo_t *bo);
|
||||
|
||||
cairo_private void
|
||||
radeon_bo_unmap (radeon_bo_t *bo);
|
||||
|
||||
cairo_private cairo_drm_bo_t *
|
||||
radeon_bo_create (radeon_device_t *dev,
|
||||
uint32_t size,
|
||||
uint32_t initial_domain);
|
||||
|
||||
cairo_private cairo_drm_bo_t *
|
||||
radeon_bo_create_for_name (radeon_device_t *dev, uint32_t name);
|
||||
|
||||
cairo_private cairo_surface_t *
|
||||
radeon_bo_get_image (const radeon_device_t *device,
|
||||
radeon_bo_t *bo,
|
||||
const cairo_drm_surface_t *surface);
|
||||
|
||||
#endif /* CAIRO_DRM_RADEON_PRIVATE_H */
|
||||
|
|
@ -1,454 +0,0 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
|
||||
#include "cairo-drm-private.h"
|
||||
#include "cairo-drm-radeon-private.h"
|
||||
|
||||
#include "cairo-default-context-private.h"
|
||||
#include "cairo-error-private.h"
|
||||
#include "cairo-image-surface-private.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <inttypes.h> /* workaround for broken <drm/radeon_drm.h> */
|
||||
#include <drm/radeon_drm.h>
|
||||
|
||||
/* Basic stub surface for radeon chipsets */
|
||||
|
||||
#define MAX_SIZE 2048
|
||||
|
||||
typedef struct _radeon_surface {
|
||||
cairo_drm_surface_t base;
|
||||
} radeon_surface_t;
|
||||
|
||||
static inline radeon_device_t *
|
||||
to_radeon_device (cairo_device_t *device)
|
||||
{
|
||||
return (radeon_device_t *) device;
|
||||
}
|
||||
|
||||
static inline radeon_bo_t *
|
||||
to_radeon_bo (cairo_drm_bo_t *bo)
|
||||
{
|
||||
return (radeon_bo_t *) bo;
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
radeon_surface_create_similar (void *abstract_surface,
|
||||
cairo_content_t content,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
return cairo_image_surface_create (_cairo_format_from_content (content),
|
||||
width, height);
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
radeon_surface_finish (void *abstract_surface)
|
||||
{
|
||||
radeon_surface_t *surface = abstract_surface;
|
||||
|
||||
return _cairo_drm_surface_finish (&surface->base);
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
radeon_surface_acquire_source_image (void *abstract_surface,
|
||||
cairo_image_surface_t **image_out,
|
||||
void **image_extra)
|
||||
{
|
||||
radeon_surface_t *surface = abstract_surface;
|
||||
cairo_surface_t *image;
|
||||
cairo_status_t status;
|
||||
|
||||
/* XXX batch flush */
|
||||
|
||||
if (surface->base.fallback != NULL) {
|
||||
image = surface->base.fallback;
|
||||
goto DONE;
|
||||
}
|
||||
|
||||
image = _cairo_surface_has_snapshot (&surface->base.base,
|
||||
&_cairo_image_surface_backend);
|
||||
if (image != NULL)
|
||||
goto DONE;
|
||||
|
||||
if (surface->base.base.backend->flush != NULL) {
|
||||
status = surface->base.base.backend->flush (surface);
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
}
|
||||
|
||||
image = radeon_bo_get_image (to_radeon_device (surface->base.base.device),
|
||||
to_radeon_bo (surface->base.bo),
|
||||
&surface->base);
|
||||
status = image->status;
|
||||
if (unlikely (status))
|
||||
return status;
|
||||
|
||||
_cairo_surface_attach_snapshot (&surface->base.base, image, cairo_surface_destroy);
|
||||
|
||||
DONE:
|
||||
*image_out = (cairo_image_surface_t *) cairo_surface_reference (image);
|
||||
*image_extra = NULL;
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
radeon_surface_release_source_image (void *abstract_surface,
|
||||
cairo_image_surface_t *image,
|
||||
void *image_extra)
|
||||
{
|
||||
cairo_surface_destroy (&image->base);
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
radeon_surface_map_to_image (radeon_surface_t *surface)
|
||||
{
|
||||
if (surface->base.fallback == NULL) {
|
||||
cairo_surface_t *image;
|
||||
cairo_status_t status;
|
||||
void *ptr;
|
||||
|
||||
if (surface->base.base.backend->flush != NULL) {
|
||||
status = surface->base.base.backend->flush (surface);
|
||||
if (unlikely (status))
|
||||
return _cairo_surface_create_in_error (status);
|
||||
}
|
||||
|
||||
ptr = radeon_bo_map (to_radeon_device (surface->base.base.device),
|
||||
to_radeon_bo (surface->base.bo));
|
||||
if (unlikely (ptr == NULL))
|
||||
return _cairo_surface_create_in_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
image = cairo_image_surface_create_for_data (ptr,
|
||||
surface->base.format,
|
||||
surface->base.width,
|
||||
surface->base.height,
|
||||
surface->base.stride);
|
||||
if (unlikely (image->status)) {
|
||||
radeon_bo_unmap (to_radeon_bo (surface->base.bo));
|
||||
return image;
|
||||
}
|
||||
|
||||
surface->base.fallback = image;
|
||||
}
|
||||
|
||||
return surface->base.fallback;
|
||||
}
|
||||
|
||||
static cairo_status_t
|
||||
radeon_surface_flush (void *abstract_surface,
|
||||
unsigned flags)
|
||||
{
|
||||
radeon_surface_t *surface = abstract_surface;
|
||||
cairo_status_t status;
|
||||
|
||||
if (flags)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
if (surface->base.fallback == NULL)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
/* kill any outstanding maps */
|
||||
cairo_surface_finish (surface->base.fallback);
|
||||
|
||||
status = cairo_surface_status (surface->base.fallback);
|
||||
cairo_surface_destroy (surface->base.fallback);
|
||||
surface->base.fallback = NULL;
|
||||
|
||||
radeon_bo_unmap (to_radeon_bo (surface->base.bo));
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
radeon_surface_paint (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_clip_t *clip)
|
||||
{
|
||||
return _cairo_surface_paint (radeon_surface_map_to_image (abstract_surface),
|
||||
op, source, clip);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
radeon_surface_mask (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
const cairo_pattern_t *mask,
|
||||
cairo_clip_t *clip)
|
||||
{
|
||||
return _cairo_surface_mask (radeon_surface_map_to_image (abstract_surface),
|
||||
op, source, mask, clip);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
radeon_surface_stroke (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_path_fixed_t *path,
|
||||
const cairo_stroke_style_t *stroke_style,
|
||||
const cairo_matrix_t *ctm,
|
||||
const cairo_matrix_t *ctm_inverse,
|
||||
double tolerance,
|
||||
cairo_antialias_t antialias,
|
||||
cairo_clip_t *clip)
|
||||
{
|
||||
return _cairo_surface_stroke (radeon_surface_map_to_image (abstract_surface),
|
||||
op, source, path, stroke_style, ctm, ctm_inverse,
|
||||
tolerance, antialias, clip);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
radeon_surface_fill (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_path_fixed_t *path,
|
||||
cairo_fill_rule_t fill_rule,
|
||||
double tolerance,
|
||||
cairo_antialias_t antialias,
|
||||
cairo_clip_t *clip)
|
||||
{
|
||||
return _cairo_surface_fill (radeon_surface_map_to_image (abstract_surface),
|
||||
op, source, path, fill_rule,
|
||||
tolerance, antialias, clip);
|
||||
}
|
||||
|
||||
static cairo_int_status_t
|
||||
radeon_surface_glyphs (void *abstract_surface,
|
||||
cairo_operator_t op,
|
||||
const cairo_pattern_t *source,
|
||||
cairo_glyph_t *glyphs,
|
||||
int num_glyphs,
|
||||
cairo_scaled_font_t *scaled_font,
|
||||
cairo_clip_t *clip,
|
||||
int *num_remaining)
|
||||
{
|
||||
*num_remaining = 0;
|
||||
return _cairo_surface_show_text_glyphs (radeon_surface_map_to_image (abstract_surface),
|
||||
op, source,
|
||||
NULL, 0,
|
||||
glyphs, num_glyphs,
|
||||
NULL, 0, 0,
|
||||
scaled_font, clip);
|
||||
}
|
||||
|
||||
static const cairo_surface_backend_t radeon_surface_backend = {
|
||||
CAIRO_SURFACE_TYPE_DRM,
|
||||
_cairo_default_context_create,
|
||||
|
||||
radeon_surface_create_similar,
|
||||
radeon_surface_finish,
|
||||
|
||||
NULL,
|
||||
radeon_surface_acquire_source_image,
|
||||
radeon_surface_release_source_image,
|
||||
|
||||
NULL, NULL, NULL,
|
||||
NULL, /* composite */
|
||||
NULL, /* fill */
|
||||
NULL, /* trapezoids */
|
||||
NULL, /* span */
|
||||
NULL, /* check-span */
|
||||
|
||||
NULL, /* copy_page */
|
||||
NULL, /* show_page */
|
||||
_cairo_drm_surface_get_extents,
|
||||
NULL, /* old-glyphs */
|
||||
_cairo_drm_surface_get_font_options,
|
||||
|
||||
radeon_surface_flush,
|
||||
NULL, /* mark dirty */
|
||||
NULL, NULL, /* font/glyph fini */
|
||||
|
||||
radeon_surface_paint,
|
||||
radeon_surface_mask,
|
||||
radeon_surface_stroke,
|
||||
radeon_surface_fill,
|
||||
radeon_surface_glyphs,
|
||||
};
|
||||
|
||||
static void
|
||||
radeon_surface_init (radeon_surface_t *surface,
|
||||
cairo_drm_device_t *device,
|
||||
cairo_format_t format,
|
||||
int width, int height)
|
||||
{
|
||||
_cairo_surface_init (&surface->base.base,
|
||||
&radeon_surface_backend,
|
||||
&device->base,
|
||||
_cairo_content_from_format (format),
|
||||
FALSE);
|
||||
_cairo_drm_surface_init (&surface->base, format, width, height);
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
radeon_surface_create_internal (cairo_drm_device_t *device,
|
||||
cairo_format_t format,
|
||||
int width, int height)
|
||||
{
|
||||
radeon_surface_t *surface;
|
||||
cairo_status_t status;
|
||||
|
||||
surface = _cairo_malloc (sizeof (radeon_surface_t));
|
||||
if (unlikely (surface == NULL))
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
|
||||
radeon_surface_init (surface, device, format, width, height);
|
||||
|
||||
if (width && height) {
|
||||
surface->base.stride =
|
||||
cairo_format_stride_for_width (surface->base.format, width);
|
||||
|
||||
surface->base.bo = radeon_bo_create (to_radeon_device (&device->base),
|
||||
surface->base.stride * height,
|
||||
RADEON_GEM_DOMAIN_GTT);
|
||||
|
||||
if (unlikely (surface->base.bo == NULL)) {
|
||||
status = _cairo_drm_surface_finish (&surface->base);
|
||||
free (surface);
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
}
|
||||
}
|
||||
|
||||
return &surface->base.base;
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
radeon_surface_create (cairo_drm_device_t *device,
|
||||
cairo_format_t format,
|
||||
int width, int height)
|
||||
{
|
||||
switch (format) {
|
||||
default:
|
||||
case CAIRO_FORMAT_INVALID:
|
||||
case CAIRO_FORMAT_A1:
|
||||
case CAIRO_FORMAT_RGB16_565:
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
|
||||
case CAIRO_FORMAT_ARGB32:
|
||||
case CAIRO_FORMAT_RGB24:
|
||||
case CAIRO_FORMAT_A8:
|
||||
break;
|
||||
}
|
||||
|
||||
return radeon_surface_create_internal (device, format, width, height);
|
||||
}
|
||||
|
||||
static cairo_surface_t *
|
||||
radeon_surface_create_for_name (cairo_drm_device_t *device,
|
||||
unsigned int name,
|
||||
cairo_format_t format,
|
||||
int width, int height, int stride)
|
||||
{
|
||||
radeon_surface_t *surface;
|
||||
cairo_status_t status;
|
||||
|
||||
switch (format) {
|
||||
default:
|
||||
case CAIRO_FORMAT_INVALID:
|
||||
case CAIRO_FORMAT_A1:
|
||||
case CAIRO_FORMAT_RGB16_565:
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
|
||||
case CAIRO_FORMAT_ARGB32:
|
||||
case CAIRO_FORMAT_RGB24:
|
||||
case CAIRO_FORMAT_A8:
|
||||
break;
|
||||
}
|
||||
|
||||
if (stride < cairo_format_stride_for_width (format, width))
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_STRIDE));
|
||||
|
||||
surface = _cairo_malloc (sizeof (radeon_surface_t));
|
||||
if (unlikely (surface == NULL))
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
|
||||
radeon_surface_init (surface, device, format, width, height);
|
||||
|
||||
if (width && height) {
|
||||
surface->base.stride = stride;
|
||||
|
||||
surface->base.bo = radeon_bo_create_for_name (to_radeon_device (&device->base),
|
||||
name);
|
||||
|
||||
if (unlikely (surface->base.bo == NULL)) {
|
||||
status = _cairo_drm_surface_finish (&surface->base);
|
||||
free (surface);
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_NO_MEMORY));
|
||||
}
|
||||
}
|
||||
|
||||
return &surface->base.base;
|
||||
}
|
||||
|
||||
static void
|
||||
radeon_device_destroy (void *data)
|
||||
{
|
||||
radeon_device_t *device = data;
|
||||
|
||||
radeon_device_fini (device);
|
||||
|
||||
free (data);
|
||||
}
|
||||
|
||||
cairo_drm_device_t *
|
||||
_cairo_drm_radeon_device_create (int fd, dev_t dev, int vendor_id, int chip_id)
|
||||
{
|
||||
radeon_device_t *device;
|
||||
uint64_t gart_size, vram_size;
|
||||
cairo_status_t status;
|
||||
|
||||
if (! radeon_info (fd, &gart_size, &vram_size))
|
||||
return NULL;
|
||||
|
||||
device = _cairo_malloc (sizeof (radeon_device_t));
|
||||
if (device == NULL)
|
||||
return _cairo_drm_device_create_in_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
status = radeon_device_init (device, fd);
|
||||
if (unlikely (status)) {
|
||||
free (device);
|
||||
return _cairo_drm_device_create_in_error (status);
|
||||
}
|
||||
|
||||
device->base.surface.create = radeon_surface_create;
|
||||
device->base.surface.create_for_name = radeon_surface_create_for_name;
|
||||
device->base.surface.create_from_cacheable_image = NULL;
|
||||
device->base.surface.flink = _cairo_drm_surface_flink;
|
||||
device->base.surface.enable_scan_out = NULL;
|
||||
|
||||
device->base.device.flush = NULL;
|
||||
device->base.device.throttle = NULL;
|
||||
device->base.device.destroy = radeon_device_destroy;
|
||||
|
||||
device->vram_limit = vram_size;
|
||||
device->gart_limit = gart_size;
|
||||
|
||||
return _cairo_drm_device_init (&device->base, fd, dev, vendor_id, chip_id, MAX_SIZE);
|
||||
}
|
||||
|
|
@ -1,331 +0,0 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
|
||||
#include "cairo-drm-private.h"
|
||||
#include "cairo-drm-radeon-private.h"
|
||||
|
||||
#include "cairo-error-private.h"
|
||||
#include "cairo-image-surface-private.h"
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <errno.h>
|
||||
#include <drm/radeon_drm.h>
|
||||
|
||||
cairo_bool_t
|
||||
radeon_info (int fd,
|
||||
uint64_t *gart_size,
|
||||
uint64_t *vram_size)
|
||||
{
|
||||
struct drm_radeon_gem_info info;
|
||||
int ret;
|
||||
|
||||
ret = ioctl (fd, DRM_IOCTL_RADEON_GEM_INFO, &info);
|
||||
if (ret == -1)
|
||||
return FALSE;
|
||||
|
||||
if (gart_size != NULL)
|
||||
*gart_size = info.gart_size;
|
||||
|
||||
if (vram_size != NULL)
|
||||
*vram_size = info.vram_size;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
radeon_bo_write (const radeon_device_t *device,
|
||||
radeon_bo_t *bo,
|
||||
unsigned long offset,
|
||||
unsigned long size,
|
||||
const void *data)
|
||||
{
|
||||
struct drm_radeon_gem_pwrite pwrite;
|
||||
int ret;
|
||||
|
||||
memset (&pwrite, 0, sizeof (pwrite));
|
||||
pwrite.handle = bo->base.handle;
|
||||
pwrite.offset = offset;
|
||||
pwrite.size = size;
|
||||
pwrite.data_ptr = (uint64_t) (uintptr_t) data;
|
||||
do {
|
||||
ret = ioctl (device->base.fd, DRM_IOCTL_RADEON_GEM_PWRITE, &pwrite);
|
||||
} while (ret == -1 && errno == EINTR);
|
||||
|
||||
/* XXX temporary workaround */
|
||||
if (ret == -1 && errno == ENOSYS) {
|
||||
uint8_t *ptr;
|
||||
|
||||
ptr = radeon_bo_map (device, bo);
|
||||
if (ptr != NULL) {
|
||||
memcpy (ptr + offset, data, size);
|
||||
radeon_bo_unmap (bo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
radeon_bo_read (const radeon_device_t *device,
|
||||
radeon_bo_t *bo,
|
||||
unsigned long offset,
|
||||
unsigned long size,
|
||||
void *data)
|
||||
{
|
||||
struct drm_radeon_gem_pread pread;
|
||||
int ret;
|
||||
|
||||
memset (&pread, 0, sizeof (pread));
|
||||
pread.handle = bo->base.handle;
|
||||
pread.offset = offset;
|
||||
pread.size = size;
|
||||
pread.data_ptr = (uint64_t) (uintptr_t) data;
|
||||
do {
|
||||
ret = ioctl (device->base.fd, DRM_IOCTL_RADEON_GEM_PREAD, &pread);
|
||||
} while (ret == -1 && errno == EINTR);
|
||||
|
||||
/* XXX temporary workaround */
|
||||
if (ret == -1 && errno == ENOSYS) {
|
||||
uint8_t *ptr;
|
||||
|
||||
ptr = radeon_bo_map (device, bo);
|
||||
if (ptr != NULL) {
|
||||
memcpy (data, ptr + offset, size);
|
||||
radeon_bo_unmap (bo);
|
||||
}
|
||||
}
|
||||
|
||||
VG (VALGRIND_MAKE_MEM_DEFINED (data, size));
|
||||
}
|
||||
|
||||
void
|
||||
radeon_bo_wait (const radeon_device_t *device, radeon_bo_t *bo)
|
||||
{
|
||||
struct drm_radeon_gem_wait_idle wait;
|
||||
int ret;
|
||||
|
||||
wait.handle = bo->base.handle;
|
||||
do {
|
||||
ret = ioctl (device->base.fd, DRM_IOCTL_RADEON_GEM_WAIT_IDLE, &wait);
|
||||
} while (ret == -1 && (errno == EINTR || errno == EBUSY));
|
||||
}
|
||||
|
||||
void *
|
||||
radeon_bo_map (const radeon_device_t *device, radeon_bo_t *bo)
|
||||
{
|
||||
struct drm_radeon_gem_mmap mmap_arg;
|
||||
void *ptr;
|
||||
int ret;
|
||||
|
||||
assert (bo->virtual == NULL);
|
||||
|
||||
memset (&mmap_arg, 0, sizeof (mmap_arg));
|
||||
mmap_arg.handle = bo->base.handle;
|
||||
mmap_arg.offset = 0;
|
||||
mmap_arg.size = bo->base.size;
|
||||
|
||||
do {
|
||||
ret = ioctl (device->base.fd, DRM_IOCTL_RADEON_GEM_MMAP, &mmap_arg);
|
||||
} while (ret == -1 && errno == EINTR);
|
||||
if (unlikely (ret != 0)) {
|
||||
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
VG (VALGRIND_MAKE_MEM_DEFINED (&mmap_arg, sizeof (mmap_arg)));
|
||||
|
||||
/* and mmap it */
|
||||
ptr = mmap (0, bo->base.size, PROT_READ | PROT_WRITE,
|
||||
MAP_SHARED, device->base.fd,
|
||||
mmap_arg.addr_ptr);
|
||||
if (unlikely (ptr == MAP_FAILED)) {
|
||||
_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bo->virtual = ptr;
|
||||
|
||||
/* XXX set_domain? */
|
||||
return bo->virtual;
|
||||
}
|
||||
|
||||
void
|
||||
radeon_bo_unmap (radeon_bo_t *bo)
|
||||
{
|
||||
assert (bo->virtual != NULL);
|
||||
|
||||
munmap (bo->virtual, bo->base.size);
|
||||
bo->virtual = NULL;
|
||||
}
|
||||
|
||||
cairo_drm_bo_t *
|
||||
radeon_bo_create (radeon_device_t *device,
|
||||
uint32_t size,
|
||||
uint32_t initial_domain)
|
||||
{
|
||||
struct drm_radeon_gem_create create;
|
||||
radeon_bo_t *bo;
|
||||
int ret;
|
||||
|
||||
bo = _cairo_freepool_alloc (&device->bo_pool);
|
||||
if (unlikely (bo == NULL))
|
||||
return NULL;
|
||||
|
||||
create.size = size;
|
||||
create.alignment = 0;
|
||||
create.initial_domain = initial_domain;
|
||||
create.flags = 0;
|
||||
create.handle = 0;
|
||||
|
||||
do {
|
||||
ret = ioctl (device->base.fd, DRM_IOCTL_RADEON_GEM_CREATE, &create);
|
||||
} while (ret == -1 && errno == EINTR);
|
||||
if (ret == -1) {
|
||||
_cairo_freepool_free (&device->bo_pool, bo);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bo->base.handle = create.handle;
|
||||
bo->base.size = size;
|
||||
|
||||
bo->virtual = NULL;
|
||||
|
||||
bo->in_batch = FALSE;
|
||||
bo->read_domains = 0;
|
||||
bo->write_domain = 0;
|
||||
|
||||
CAIRO_REFERENCE_COUNT_INIT (&bo->base.ref_count, 1);
|
||||
return &bo->base;
|
||||
}
|
||||
|
||||
cairo_drm_bo_t *
|
||||
radeon_bo_create_for_name (radeon_device_t *device,
|
||||
uint32_t name)
|
||||
{
|
||||
radeon_bo_t *bo;
|
||||
cairo_status_t status;
|
||||
|
||||
bo = _cairo_freepool_alloc (&device->bo_pool);
|
||||
if (unlikely (bo == NULL))
|
||||
return NULL;
|
||||
|
||||
status = _cairo_drm_bo_open_for_name (&device->base, &bo->base, name);
|
||||
if (unlikely (status)) {
|
||||
_cairo_freepool_free (&device->bo_pool, bo);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bo->virtual = NULL;
|
||||
|
||||
bo->in_batch = FALSE;
|
||||
bo->read_domains = 0;
|
||||
bo->write_domain = 0;
|
||||
|
||||
CAIRO_REFERENCE_COUNT_INIT (&bo->base.ref_count, 1);
|
||||
return &bo->base;
|
||||
}
|
||||
|
||||
static void
|
||||
radeon_bo_release (void *_dev, void *_bo)
|
||||
{
|
||||
radeon_device_t *device = _dev;
|
||||
radeon_bo_t *bo = _bo;
|
||||
|
||||
_cairo_drm_bo_close (&device->base, &bo->base);
|
||||
_cairo_freepool_free (&device->bo_pool, bo);
|
||||
}
|
||||
|
||||
cairo_surface_t *
|
||||
radeon_bo_get_image (const radeon_device_t *device,
|
||||
radeon_bo_t *bo,
|
||||
const cairo_drm_surface_t *surface)
|
||||
{
|
||||
cairo_image_surface_t *image;
|
||||
uint8_t *dst;
|
||||
int size, row;
|
||||
|
||||
image = (cairo_image_surface_t *)
|
||||
cairo_image_surface_create (surface->format,
|
||||
surface->width,
|
||||
surface->height);
|
||||
if (unlikely (image->base.status))
|
||||
return &image->base;
|
||||
|
||||
if (image->stride == surface->stride) {
|
||||
size = surface->stride * surface->height;
|
||||
radeon_bo_read (device, bo, 0, size, image->data);
|
||||
} else {
|
||||
int offset;
|
||||
|
||||
size = surface->width;
|
||||
if (surface->format != CAIRO_FORMAT_A8)
|
||||
size *= 4;
|
||||
|
||||
offset = 0;
|
||||
row = surface->height;
|
||||
dst = image->data;
|
||||
while (row--) {
|
||||
radeon_bo_read (device, bo, offset, size, dst);
|
||||
offset += surface->stride;
|
||||
dst += image->stride;
|
||||
}
|
||||
}
|
||||
|
||||
return &image->base;
|
||||
}
|
||||
|
||||
static void
|
||||
_radeon_device_init_bo_cache (radeon_device_t *device)
|
||||
{
|
||||
_cairo_freepool_init (&device->bo_pool, sizeof (radeon_bo_t));
|
||||
}
|
||||
|
||||
cairo_status_t
|
||||
radeon_device_init (radeon_device_t *device, int fd)
|
||||
{
|
||||
_radeon_device_init_bo_cache (device);
|
||||
|
||||
device->base.bo.release = radeon_bo_release;
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static void
|
||||
_radeon_bo_cache_fini (radeon_device_t *device)
|
||||
{
|
||||
_cairo_freepool_fini (&device->bo_pool);
|
||||
}
|
||||
|
||||
void
|
||||
radeon_device_fini (radeon_device_t *device)
|
||||
{
|
||||
_radeon_bo_cache_fini (device);
|
||||
_cairo_drm_device_fini (&device->base);
|
||||
}
|
||||
|
|
@ -1,369 +0,0 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Chris Wilson.
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
|
||||
#include "cairo-drm-private.h"
|
||||
|
||||
#include "cairo-error-private.h"
|
||||
#include "cairo-image-surface-inline.h"
|
||||
|
||||
void
|
||||
_cairo_drm_surface_init (cairo_drm_surface_t *surface,
|
||||
cairo_format_t format,
|
||||
int width, int height)
|
||||
{
|
||||
surface->bo = NULL;
|
||||
surface->format = format;
|
||||
surface->width = width;
|
||||
surface->height = height;
|
||||
surface->stride = 0;
|
||||
|
||||
surface->fallback = NULL;
|
||||
surface->map_count = 0;
|
||||
}
|
||||
|
||||
cairo_status_t
|
||||
_cairo_drm_surface_finish (cairo_drm_surface_t *surface)
|
||||
{
|
||||
assert (surface->fallback == NULL);
|
||||
|
||||
if (surface->bo != NULL)
|
||||
cairo_drm_bo_destroy (surface->base.device, surface->bo);
|
||||
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
_cairo_drm_surface_get_font_options (void *abstract_surface,
|
||||
cairo_font_options_t *options)
|
||||
{
|
||||
_cairo_font_options_init_default (options);
|
||||
|
||||
cairo_font_options_set_hint_metrics (options, CAIRO_HINT_METRICS_ON);
|
||||
}
|
||||
|
||||
cairo_bool_t
|
||||
_cairo_drm_surface_get_extents (void *abstract_surface,
|
||||
cairo_rectangle_int_t *rectangle)
|
||||
{
|
||||
cairo_drm_surface_t *surface = abstract_surface;
|
||||
|
||||
rectangle->x = 0;
|
||||
rectangle->y = 0;
|
||||
rectangle->width = surface->width;
|
||||
rectangle->height = surface->height;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
cairo_surface_t *
|
||||
cairo_drm_surface_create (cairo_device_t *abstract_device,
|
||||
cairo_format_t format,
|
||||
int width, int height)
|
||||
{
|
||||
cairo_drm_device_t *device = (cairo_drm_device_t *) abstract_device;
|
||||
cairo_surface_t *surface;
|
||||
|
||||
if (device != NULL && device->base.status)
|
||||
{
|
||||
surface = _cairo_surface_create_in_error (device->base.status);
|
||||
}
|
||||
else if (device == NULL ||
|
||||
device->surface.create == NULL ||
|
||||
width == 0 || width > device->max_surface_size ||
|
||||
height == 0 || height > device->max_surface_size)
|
||||
{
|
||||
surface = cairo_image_surface_create (format, width, height);
|
||||
}
|
||||
else if (device->base.finished)
|
||||
{
|
||||
surface = _cairo_surface_create_in_error (CAIRO_STATUS_SURFACE_FINISHED);
|
||||
}
|
||||
else
|
||||
{
|
||||
surface = device->surface.create (device, format, width, height);
|
||||
if (surface->status == CAIRO_STATUS_INVALID_SIZE)
|
||||
surface = cairo_image_surface_create (format, width, height);
|
||||
}
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
cairo_surface_t *
|
||||
cairo_drm_surface_create_for_name (cairo_device_t *abstract_device,
|
||||
unsigned int name,
|
||||
cairo_format_t format,
|
||||
int width, int height, int stride)
|
||||
{
|
||||
cairo_drm_device_t *device = (cairo_drm_device_t *) abstract_device;
|
||||
cairo_surface_t *surface;
|
||||
|
||||
if (! CAIRO_FORMAT_VALID (format))
|
||||
return _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
|
||||
|
||||
if (device != NULL && device->base.status)
|
||||
{
|
||||
surface = _cairo_surface_create_in_error (device->base.status);
|
||||
}
|
||||
else if (device == NULL || device->surface.create_for_name == NULL)
|
||||
{
|
||||
/* XXX invalid device! */
|
||||
surface = _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
|
||||
}
|
||||
else if (width == 0 || width > device->max_surface_size ||
|
||||
height == 0 || height > device->max_surface_size)
|
||||
{
|
||||
surface = _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_SIZE));
|
||||
}
|
||||
else if (device->base.finished)
|
||||
{
|
||||
surface = _cairo_surface_create_in_error (CAIRO_STATUS_SURFACE_FINISHED);
|
||||
}
|
||||
else
|
||||
{
|
||||
surface = device->surface.create_for_name (device,
|
||||
name, format,
|
||||
width, height, stride);
|
||||
}
|
||||
|
||||
return surface;
|
||||
}
|
||||
slim_hidden_def (cairo_drm_surface_create_for_name);
|
||||
|
||||
cairo_surface_t *
|
||||
cairo_drm_surface_create_from_cacheable_image (cairo_device_t *abstract_device,
|
||||
cairo_surface_t *surface)
|
||||
{
|
||||
cairo_drm_device_t *device = (cairo_drm_device_t *) abstract_device;
|
||||
|
||||
if (surface->status) {
|
||||
surface = _cairo_surface_create_in_error (surface->status);
|
||||
} else if (device != NULL && device->base.status) {
|
||||
surface = _cairo_surface_create_in_error (device->base.status);
|
||||
} else if (device == NULL || device->surface.create_from_cacheable_image == NULL) {
|
||||
/* XXX invalid device! */
|
||||
surface = _cairo_surface_create_in_error (_cairo_error (CAIRO_STATUS_INVALID_FORMAT));
|
||||
} else if (device->base.finished) {
|
||||
surface = _cairo_surface_create_in_error (CAIRO_STATUS_SURFACE_FINISHED);
|
||||
} else {
|
||||
surface = device->surface.create_from_cacheable_image (device, surface);
|
||||
}
|
||||
|
||||
return surface;
|
||||
}
|
||||
|
||||
static cairo_drm_surface_t *
|
||||
_cairo_surface_as_drm (cairo_surface_t *abstract_surface)
|
||||
{
|
||||
if (unlikely (abstract_surface->status))
|
||||
return NULL;
|
||||
|
||||
if (abstract_surface->type != CAIRO_SURFACE_TYPE_DRM)
|
||||
return NULL;
|
||||
|
||||
return (cairo_drm_surface_t *) abstract_surface;
|
||||
}
|
||||
|
||||
cairo_status_t
|
||||
cairo_drm_surface_enable_scan_out (cairo_surface_t *abstract_surface)
|
||||
{
|
||||
cairo_drm_surface_t *surface;
|
||||
cairo_drm_device_t *device;
|
||||
|
||||
surface = _cairo_surface_as_drm (abstract_surface);
|
||||
if (unlikely (surface == NULL))
|
||||
return _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
|
||||
if (unlikely (surface->base.finished))
|
||||
return _cairo_error (CAIRO_STATUS_SURFACE_FINISHED);
|
||||
|
||||
device = (cairo_drm_device_t *) surface->base.device;
|
||||
if (device->surface.enable_scan_out == NULL)
|
||||
return CAIRO_STATUS_SUCCESS;
|
||||
|
||||
if (unlikely (device->base.finished))
|
||||
return _cairo_error (CAIRO_STATUS_SURFACE_FINISHED);
|
||||
|
||||
return device->surface.enable_scan_out (abstract_surface);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
cairo_drm_surface_get_handle (cairo_surface_t *abstract_surface)
|
||||
{
|
||||
cairo_drm_surface_t *surface;
|
||||
|
||||
surface = _cairo_surface_as_drm (abstract_surface);
|
||||
if (surface == NULL) {
|
||||
_cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return surface->bo->handle;
|
||||
}
|
||||
|
||||
cairo_int_status_t
|
||||
_cairo_drm_surface_flink (void *abstract_surface)
|
||||
{
|
||||
cairo_drm_surface_t *surface = abstract_surface;
|
||||
|
||||
return _cairo_drm_bo_flink ((cairo_drm_device_t *) surface->base.device,
|
||||
surface->bo);
|
||||
}
|
||||
|
||||
unsigned int
|
||||
cairo_drm_surface_get_name (cairo_surface_t *abstract_surface)
|
||||
{
|
||||
cairo_drm_surface_t *surface;
|
||||
cairo_drm_device_t *device;
|
||||
cairo_status_t status;
|
||||
|
||||
surface = _cairo_surface_as_drm (abstract_surface);
|
||||
if (surface == NULL) {
|
||||
_cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (surface->bo->name)
|
||||
return surface->bo->name;
|
||||
|
||||
device = (cairo_drm_device_t *) surface->base.device;
|
||||
if (device->surface.flink == NULL)
|
||||
return 0;
|
||||
|
||||
status = device->surface.flink (abstract_surface);
|
||||
if (status) {
|
||||
if (_cairo_status_is_error (status))
|
||||
status = _cairo_surface_set_error (abstract_surface, status);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
return surface->bo->name;
|
||||
}
|
||||
|
||||
cairo_format_t
|
||||
cairo_drm_surface_get_format (cairo_surface_t *abstract_surface)
|
||||
{
|
||||
cairo_drm_surface_t *surface;
|
||||
|
||||
surface = _cairo_surface_as_drm (abstract_surface);
|
||||
if (surface == NULL)
|
||||
return cairo_image_surface_get_format (abstract_surface);
|
||||
|
||||
return surface->format;
|
||||
}
|
||||
|
||||
int
|
||||
cairo_drm_surface_get_width (cairo_surface_t *abstract_surface)
|
||||
{
|
||||
cairo_drm_surface_t *surface;
|
||||
|
||||
surface = _cairo_surface_as_drm (abstract_surface);
|
||||
if (surface == NULL)
|
||||
return cairo_image_surface_get_width (abstract_surface);
|
||||
|
||||
return surface->width;
|
||||
}
|
||||
|
||||
int
|
||||
cairo_drm_surface_get_height (cairo_surface_t *abstract_surface)
|
||||
{
|
||||
cairo_drm_surface_t *surface;
|
||||
|
||||
surface = _cairo_surface_as_drm (abstract_surface);
|
||||
if (surface == NULL)
|
||||
return cairo_image_surface_get_height (abstract_surface);
|
||||
|
||||
return surface->height;
|
||||
}
|
||||
|
||||
int
|
||||
cairo_drm_surface_get_stride (cairo_surface_t *abstract_surface)
|
||||
{
|
||||
cairo_drm_surface_t *surface;
|
||||
|
||||
surface = _cairo_surface_as_drm (abstract_surface);
|
||||
if (surface == NULL)
|
||||
return cairo_image_surface_get_stride (abstract_surface);
|
||||
|
||||
return surface->stride;
|
||||
}
|
||||
|
||||
/* XXX drm or general surface layer? naming? */
|
||||
cairo_surface_t *
|
||||
cairo_drm_surface_map_to_image (cairo_surface_t *abstract_surface)
|
||||
{
|
||||
cairo_drm_surface_t *surface;
|
||||
cairo_drm_device_t *device;
|
||||
cairo_status_t status;
|
||||
|
||||
if (unlikely (abstract_surface->status))
|
||||
return _cairo_surface_create_in_error (abstract_surface->status);
|
||||
|
||||
surface = _cairo_surface_as_drm (abstract_surface);
|
||||
if (surface == NULL) {
|
||||
if (_cairo_surface_is_image (abstract_surface))
|
||||
return cairo_surface_reference (abstract_surface);
|
||||
|
||||
status = _cairo_surface_set_error (abstract_surface,
|
||||
CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
|
||||
return _cairo_surface_create_in_error (status);
|
||||
}
|
||||
|
||||
surface->map_count++;
|
||||
device = (cairo_drm_device_t *) surface->base.device;
|
||||
return cairo_surface_reference (device->surface.map_to_image (surface));
|
||||
}
|
||||
|
||||
void
|
||||
cairo_drm_surface_unmap (cairo_surface_t *abstract_surface,
|
||||
cairo_surface_t *image)
|
||||
{
|
||||
cairo_drm_surface_t *surface;
|
||||
|
||||
surface = _cairo_surface_as_drm (abstract_surface);
|
||||
if (surface == NULL) {
|
||||
if (_cairo_surface_is_image (abstract_surface))
|
||||
cairo_surface_destroy (image);
|
||||
else
|
||||
_cairo_error_throw (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
|
||||
return;
|
||||
}
|
||||
|
||||
/* XXX assert image belongs to drm */
|
||||
//assert (image == drm->fallback);
|
||||
cairo_surface_destroy (image);
|
||||
|
||||
assert (surface->map_count > 0);
|
||||
if (--surface->map_count == 0)
|
||||
cairo_surface_flush (&surface->base);
|
||||
}
|
||||
|
|
@ -1,390 +0,0 @@
|
|||
/* Cairo - a vector graphics library with display and print output
|
||||
*
|
||||
* Copyright © 2009 Chris Wilson
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it either under the terms of the GNU Lesser General Public
|
||||
* License version 2.1 as published by the Free Software Foundation
|
||||
* (the "LGPL") or, at your option, under the terms of the Mozilla
|
||||
* Public License Version 1.1 (the "MPL"). If you do not alter this
|
||||
* notice, a recipient may use your version of this file under either
|
||||
* the MPL or the LGPL.
|
||||
*
|
||||
* You should have received a copy of the LGPL along with this library
|
||||
* in the file COPYING-LGPL-2.1; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
|
||||
* You should have received a copy of the MPL along with this library
|
||||
* in the file COPYING-MPL-1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License
|
||||
* Version 1.1 (the "License"); you may not use this file except in
|
||||
* compliance with the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
|
||||
* OF ANY KIND, either express or implied. See the LGPL or the MPL for
|
||||
* the specific language governing rights and limitations.
|
||||
*
|
||||
* The Original Code is the cairo graphics library.
|
||||
*
|
||||
* The Initial Developer of the Original Code is Chris Wilson.
|
||||
*/
|
||||
|
||||
#include "cairoint.h"
|
||||
|
||||
#include "cairo-drm-private.h"
|
||||
|
||||
#include "cairo-device-private.h"
|
||||
#include "cairo-error-private.h"
|
||||
|
||||
#define LIBUDEV_I_KNOW_THE_API_IS_SUBJECT_TO_CHANGE
|
||||
#include <libudev.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h> /* open(), close() */
|
||||
|
||||
static cairo_drm_device_t *_cairo_drm_known_devices;
|
||||
static cairo_drm_device_t *_cairo_drm_default_device;
|
||||
|
||||
static const char *
|
||||
get_udev_property(struct udev_device *device, const char *name)
|
||||
{
|
||||
struct udev_list_entry *entry;
|
||||
|
||||
udev_list_entry_foreach (entry,
|
||||
udev_device_get_properties_list_entry (device))
|
||||
{
|
||||
if (strcmp (udev_list_entry_get_name (entry), name) == 0)
|
||||
return udev_list_entry_get_value (entry);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_device_flush (void *abstract_device)
|
||||
{
|
||||
cairo_drm_device_t *device = abstract_device;
|
||||
|
||||
device->device.flush (device);
|
||||
}
|
||||
|
||||
static void
|
||||
_device_finish (void *abstract_device)
|
||||
{
|
||||
cairo_drm_device_t *device = abstract_device;
|
||||
|
||||
CAIRO_MUTEX_LOCK (_cairo_drm_device_mutex);
|
||||
if (device->prev != NULL)
|
||||
device->prev->next = device->next;
|
||||
else
|
||||
_cairo_drm_known_devices = device->next;
|
||||
if (device->next != NULL)
|
||||
device->next->prev = device->prev;
|
||||
|
||||
CAIRO_MUTEX_UNLOCK (_cairo_drm_device_mutex);
|
||||
|
||||
if (_cairo_atomic_ptr_cmpxchg (&_cairo_drm_default_device,
|
||||
device, NULL))
|
||||
{
|
||||
cairo_device_destroy (&device->base);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_device_destroy (void *abstract_device)
|
||||
{
|
||||
cairo_drm_device_t *device = abstract_device;
|
||||
|
||||
device->device.destroy (device);
|
||||
}
|
||||
|
||||
static const cairo_device_backend_t _cairo_drm_device_backend = {
|
||||
CAIRO_DEVICE_TYPE_DRM,
|
||||
|
||||
NULL, NULL, /* lock, unlock */
|
||||
|
||||
_device_flush,
|
||||
_device_finish,
|
||||
_device_destroy,
|
||||
};
|
||||
|
||||
cairo_drm_device_t *
|
||||
_cairo_drm_device_init (cairo_drm_device_t *dev,
|
||||
int fd,
|
||||
dev_t devid,
|
||||
int vendor_id,
|
||||
int chip_id,
|
||||
int max_surface_size)
|
||||
{
|
||||
assert (CAIRO_MUTEX_IS_LOCKED (_cairo_drm_device_mutex));
|
||||
|
||||
_cairo_device_init (&dev->base, &_cairo_drm_device_backend);
|
||||
|
||||
dev->id = devid;
|
||||
dev->vendor_id = vendor_id;
|
||||
dev->chip_id = chip_id;
|
||||
dev->fd = fd;
|
||||
|
||||
dev->max_surface_size = max_surface_size;
|
||||
|
||||
dev->prev = NULL;
|
||||
dev->next = _cairo_drm_known_devices;
|
||||
if (_cairo_drm_known_devices != NULL)
|
||||
_cairo_drm_known_devices->prev = dev;
|
||||
_cairo_drm_known_devices = dev;
|
||||
|
||||
if (_cairo_drm_default_device == NULL)
|
||||
_cairo_drm_default_device = (cairo_drm_device_t *) cairo_device_reference (&dev->base);
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
cairo_device_t *
|
||||
cairo_drm_device_get (struct udev_device *device)
|
||||
{
|
||||
static const struct dri_driver_entry {
|
||||
uint32_t vendor_id;
|
||||
uint32_t chip_id;
|
||||
cairo_drm_device_create_func_t create_func;
|
||||
} driver_map[] = {
|
||||
{ 0x8086, 0x29a2, _cairo_drm_i965_device_create }, /* I965_G */
|
||||
{ 0x8086, 0x2982, _cairo_drm_i965_device_create }, /* G35_G */
|
||||
{ 0x8086, 0x2992, _cairo_drm_i965_device_create }, /* I965_Q */
|
||||
{ 0x8086, 0x2972, _cairo_drm_i965_device_create }, /* I946_GZ */
|
||||
{ 0x8086, 0x2a02, _cairo_drm_i965_device_create }, /* I965_GM */
|
||||
{ 0x8086, 0x2a12, _cairo_drm_i965_device_create }, /* I965_GME */
|
||||
{ 0x8086, 0x2e02, _cairo_drm_i965_device_create }, /* IGD_E_G */
|
||||
{ 0x8086, 0x2e22, _cairo_drm_i965_device_create }, /* G45_G */
|
||||
{ 0x8086, 0x2e12, _cairo_drm_i965_device_create }, /* Q45_G */
|
||||
{ 0x8086, 0x2e32, _cairo_drm_i965_device_create }, /* G41_G */
|
||||
{ 0x8086, 0x2a42, _cairo_drm_i965_device_create }, /* GM45_GM */
|
||||
|
||||
{ 0x8086, 0x2582, _cairo_drm_i915_device_create }, /* I915_G */
|
||||
{ 0x8086, 0x2592, _cairo_drm_i915_device_create }, /* I915_GM */
|
||||
{ 0x8086, 0x258a, _cairo_drm_i915_device_create }, /* E7221_G */
|
||||
{ 0x8086, 0x2772, _cairo_drm_i915_device_create }, /* I945_G */
|
||||
{ 0x8086, 0x27a2, _cairo_drm_i915_device_create }, /* I945_GM */
|
||||
{ 0x8086, 0x27ae, _cairo_drm_i915_device_create }, /* I945_GME */
|
||||
{ 0x8086, 0x29c2, _cairo_drm_i915_device_create }, /* G33_G */
|
||||
{ 0x8086, 0x29b2, _cairo_drm_i915_device_create }, /* Q35_G */
|
||||
{ 0x8086, 0x29d2, _cairo_drm_i915_device_create }, /* Q33_G */
|
||||
{ 0x8086, 0xa011, _cairo_drm_i915_device_create }, /* IGD_GM */
|
||||
{ 0x8086, 0xa001, _cairo_drm_i915_device_create }, /* IGD_G */
|
||||
|
||||
/* XXX i830 */
|
||||
|
||||
{ 0x8086, ~0, _cairo_drm_intel_device_create },
|
||||
|
||||
{ 0x1002, ~0, _cairo_drm_radeon_device_create },
|
||||
#if CAIRO_HAS_GALLIUM_SURFACE
|
||||
{ ~0, ~0, _cairo_drm_gallium_device_create },
|
||||
#endif
|
||||
};
|
||||
|
||||
cairo_drm_device_t *dev;
|
||||
dev_t devid;
|
||||
struct udev_device *parent;
|
||||
const char *pci_id;
|
||||
uint32_t vendor_id, chip_id;
|
||||
const char *path;
|
||||
int i, fd;
|
||||
|
||||
devid = udev_device_get_devnum (device);
|
||||
|
||||
CAIRO_MUTEX_LOCK (_cairo_drm_device_mutex);
|
||||
for (dev = _cairo_drm_known_devices; dev != NULL; dev = dev->next) {
|
||||
if (dev->id == devid) {
|
||||
dev = (cairo_drm_device_t *) cairo_device_reference (&dev->base);
|
||||
goto DONE;
|
||||
}
|
||||
}
|
||||
|
||||
parent = udev_device_get_parent (device);
|
||||
pci_id = get_udev_property (parent, "PCI_ID");
|
||||
if (pci_id == NULL || sscanf (pci_id, "%x:%x", &vendor_id, &chip_id) != 2) {
|
||||
dev = NULL;
|
||||
goto DONE;
|
||||
}
|
||||
|
||||
#if CAIRO_HAS_GALLIUM_SURFACE
|
||||
if (getenv ("CAIRO_GALLIUM_FORCE"))
|
||||
{
|
||||
i = ARRAY_LENGTH (driver_map) - 1;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
for (i = 0; i < ARRAY_LENGTH (driver_map); i++) {
|
||||
if (driver_map[i].vendor_id == ~0U)
|
||||
break;
|
||||
|
||||
if (driver_map[i].vendor_id == vendor_id &&
|
||||
(driver_map[i].chip_id == ~0U || driver_map[i].chip_id == chip_id))
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == ARRAY_LENGTH (driver_map)) {
|
||||
dev = (cairo_drm_device_t *)
|
||||
_cairo_device_create_in_error (CAIRO_STATUS_DEVICE_ERROR);
|
||||
goto DONE;
|
||||
}
|
||||
}
|
||||
|
||||
path = udev_device_get_devnode (device);
|
||||
if (path == NULL)
|
||||
path = "/dev/dri/card0"; /* XXX buggy udev? */
|
||||
|
||||
fd = open (path, O_RDWR);
|
||||
if (fd == -1) {
|
||||
/* XXX more likely to be a permissions issue... */
|
||||
_cairo_error_throw (CAIRO_STATUS_FILE_NOT_FOUND);
|
||||
dev = NULL;
|
||||
goto DONE;
|
||||
}
|
||||
|
||||
dev = driver_map[i].create_func (fd, devid, vendor_id, chip_id);
|
||||
if (dev == NULL)
|
||||
close (fd);
|
||||
|
||||
DONE:
|
||||
CAIRO_MUTEX_UNLOCK (_cairo_drm_device_mutex);
|
||||
|
||||
if (dev == NULL)
|
||||
return _cairo_device_create_in_error (CAIRO_STATUS_DEVICE_ERROR);
|
||||
else
|
||||
return &dev->base;
|
||||
}
|
||||
slim_hidden_def (cairo_drm_device_get);
|
||||
|
||||
cairo_device_t *
|
||||
cairo_drm_device_get_for_fd (int fd)
|
||||
{
|
||||
struct stat st;
|
||||
struct udev *udev;
|
||||
struct udev_device *device;
|
||||
cairo_device_t *dev = NULL;
|
||||
|
||||
if (fstat (fd, &st) < 0 || ! S_ISCHR (st.st_mode)) {
|
||||
//_cairo_error_throw (CAIRO_STATUS_INVALID_DEVICE);
|
||||
return _cairo_device_create_in_error (CAIRO_STATUS_NO_MEMORY);
|
||||
}
|
||||
|
||||
udev = udev_new ();
|
||||
|
||||
device = udev_device_new_from_devnum (udev, 'c', st.st_rdev);
|
||||
if (device != NULL) {
|
||||
dev = cairo_drm_device_get (device);
|
||||
udev_device_unref (device);
|
||||
}
|
||||
|
||||
udev_unref (udev);
|
||||
|
||||
return dev;
|
||||
}
|
||||
slim_hidden_def (cairo_drm_device_get_for_fd);
|
||||
|
||||
cairo_device_t *
|
||||
cairo_drm_device_default (void)
|
||||
{
|
||||
struct udev *udev;
|
||||
struct udev_enumerate *e;
|
||||
struct udev_list_entry *entry;
|
||||
cairo_device_t *dev;
|
||||
|
||||
/* optimistic atomic pointer read */
|
||||
dev = &_cairo_drm_default_device->base;
|
||||
if (dev != NULL)
|
||||
return dev;
|
||||
|
||||
udev = udev_new();
|
||||
if (udev == NULL)
|
||||
return _cairo_device_create_in_error (CAIRO_STATUS_NO_MEMORY);
|
||||
|
||||
e = udev_enumerate_new (udev);
|
||||
udev_enumerate_add_match_subsystem (e, "drm");
|
||||
udev_enumerate_scan_devices (e);
|
||||
udev_list_entry_foreach (entry, udev_enumerate_get_list_entry (e)) {
|
||||
struct udev_device *device;
|
||||
|
||||
device =
|
||||
udev_device_new_from_syspath (udev,
|
||||
udev_list_entry_get_name (entry));
|
||||
|
||||
dev = cairo_drm_device_get (device);
|
||||
|
||||
udev_device_unref (device);
|
||||
|
||||
if (dev != NULL) {
|
||||
if (((cairo_drm_device_t *) dev)->fd == -1) {
|
||||
/* try again, we may find a usable card */
|
||||
cairo_device_destroy (dev);
|
||||
dev = NULL;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
}
|
||||
udev_enumerate_unref (e);
|
||||
udev_unref (udev);
|
||||
|
||||
cairo_device_destroy (dev); /* owned by _cairo_drm_default_device */
|
||||
return dev;
|
||||
}
|
||||
slim_hidden_def (cairo_drm_device_default);
|
||||
|
||||
void
|
||||
_cairo_drm_device_reset_static_data (void)
|
||||
{
|
||||
if (_cairo_drm_default_device != NULL) {
|
||||
cairo_device_t *device = &_cairo_drm_default_device->base;
|
||||
_cairo_drm_default_device = NULL;
|
||||
cairo_device_destroy (device);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
cairo_drm_device_get_fd (cairo_device_t *abstract_device)
|
||||
{
|
||||
cairo_drm_device_t *device = (cairo_drm_device_t *) abstract_device;
|
||||
|
||||
if (device->base.status)
|
||||
return -1;
|
||||
|
||||
return device->fd;
|
||||
}
|
||||
|
||||
void
|
||||
_cairo_drm_device_fini (cairo_drm_device_t *device)
|
||||
{
|
||||
if (device->fd != -1)
|
||||
close (device->fd);
|
||||
}
|
||||
|
||||
void
|
||||
cairo_drm_device_throttle (cairo_device_t *abstract_device)
|
||||
{
|
||||
cairo_drm_device_t *device = (cairo_drm_device_t *) abstract_device;
|
||||
cairo_status_t status;
|
||||
|
||||
if (unlikely (device->base.status))
|
||||
return;
|
||||
|
||||
if (device->device.throttle == NULL)
|
||||
return;
|
||||
|
||||
status = device->device.throttle (device);
|
||||
if (unlikely (status))
|
||||
_cairo_status_set_error (&device->base.status, status);
|
||||
}
|
||||
|
||||
cairo_bool_t
|
||||
_cairo_drm_size_is_valid (cairo_device_t *abstract_device,
|
||||
int width, int height)
|
||||
{
|
||||
cairo_drm_device_t *device = (cairo_drm_device_t *) abstract_device;
|
||||
|
||||
if (unlikely (device->base.status))
|
||||
return FALSE;
|
||||
|
||||
return width <= device->max_surface_size &&
|
||||
height <= device->max_surface_size;
|
||||
}
|
||||
|
|
@ -177,27 +177,6 @@ cairo_feature_sources = {
|
|||
'cairo-win32-font': [
|
||||
'win32/cairo-win32-font.c',
|
||||
],
|
||||
'cairo-drm': [
|
||||
'drm/cairo-drm.c',
|
||||
'drm/cairo-drm-bo.c',
|
||||
'drm/cairo-drm-surface.c',
|
||||
'drm/cairo-drm-intel.c',
|
||||
'drm/cairo-drm-intel-debug.c',
|
||||
'drm/cairo-drm-intel-surface.c',
|
||||
'drm/cairo-drm-i915-surface.c',
|
||||
'drm/cairo-drm-i915-glyphs.c',
|
||||
'drm/cairo-drm-i915-shader.c',
|
||||
'drm/cairo-drm-i915-spans.c',
|
||||
'drm/cairo-drm-i965-surface.c',
|
||||
'drm/cairo-drm-i965-glyphs.c',
|
||||
'drm/cairo-drm-i965-shader.c',
|
||||
'drm/cairo-drm-i965-spans.c',
|
||||
'drm/cairo-drm-intel-brw-eu.c',
|
||||
'drm/cairo-drm-intel-brw-eu-emit.c',
|
||||
'drm/cairo-drm-intel-brw-eu-util.c',
|
||||
'drm/cairo-drm-radeon.c',
|
||||
'drm/cairo-drm-radeon-surface.c',
|
||||
],
|
||||
'cairo-gl': [
|
||||
'cairo-gl-composite.c',
|
||||
'cairo-gl-device.c',
|
||||
|
|
@ -266,7 +245,6 @@ cairo_feature_headers = {
|
|||
'cairo-win32': ['cairo-win32.h'],
|
||||
'cairo-gl': ['cairo-gl.h'],
|
||||
'cairo-directfb': ['cairo-directfb.h'],
|
||||
'cairo-drm': ['cairo-drm.h'],
|
||||
'cairo-script': ['cairo-script.h'],
|
||||
'cairo-tee': ['cairo-tee.h'],
|
||||
'cairo-xml': ['cairo-xml.h'],
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue