mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 00:00:11 +01:00
Merge remote branch 'origin/master' into lp-binning
Conflicts: src/gallium/drivers/llvmpipe/lp_quad.h src/gallium/drivers/llvmpipe/lp_setup.c
This commit is contained in:
commit
ba5d600c90
334 changed files with 12709 additions and 2120 deletions
|
|
@ -97,6 +97,9 @@ env.Append(CPPPATH = [
|
|||
'#/src/gallium/drivers',
|
||||
])
|
||||
|
||||
if env['msvc']:
|
||||
env.Append(CPPPATH = ['#include/c99'])
|
||||
|
||||
|
||||
# Posix
|
||||
if platform in ('posix', 'linux', 'freebsd', 'darwin'):
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ GLU_LIB_NAME = @GLU_LIB_NAME@
|
|||
GLUT_LIB_NAME = @GLUT_LIB_NAME@
|
||||
GLW_LIB_NAME = @GLW_LIB_NAME@
|
||||
OSMESA_LIB_NAME = @OSMESA_LIB_NAME@
|
||||
EGL_LIB_NAME = @EGL_LIB_NAME@
|
||||
|
||||
# Globs used to install the lib and all symlinks
|
||||
GL_LIB_GLOB = @GL_LIB_GLOB@
|
||||
|
|
@ -61,12 +62,14 @@ GLU_LIB_GLOB = @GLU_LIB_GLOB@
|
|||
GLUT_LIB_GLOB = @GLUT_LIB_GLOB@
|
||||
GLW_LIB_GLOB = @GLW_LIB_GLOB@
|
||||
OSMESA_LIB_GLOB = @OSMESA_LIB_GLOB@
|
||||
EGL_LIB_GLOB = @EGL_LIB_GLOB@
|
||||
|
||||
# Directories to build
|
||||
LIB_DIR = @LIB_DIR@
|
||||
SRC_DIRS = @SRC_DIRS@
|
||||
GLU_DIRS = @GLU_DIRS@
|
||||
DRIVER_DIRS = @DRIVER_DIRS@
|
||||
EGL_DRIVERS_DIRS = @EGL_DRIVERS_DIRS@
|
||||
GALLIUM_DIRS = @GALLIUM_DIRS@
|
||||
GALLIUM_DRIVERS_DIRS = @GALLIUM_DRIVERS_DIRS@
|
||||
GALLIUM_WINSYS_DIRS = @GALLIUM_WINSYS_DIRS@
|
||||
|
|
@ -81,6 +84,7 @@ PROGRAM_DIRS = @PROGRAM_DIRS@
|
|||
# Driver specific build vars
|
||||
DRI_DIRS = @DRI_DIRS@
|
||||
WINDOW_SYSTEM = @WINDOW_SYSTEM@
|
||||
EGL_DISPLAYS = @EGL_DISPLAYS@
|
||||
USING_EGL = @USING_EGL@
|
||||
|
||||
# Dependencies
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ GLUT_LIB = glut
|
|||
GLEW_LIB = GLEW
|
||||
GLW_LIB = GLw
|
||||
OSMESA_LIB = OSMesa
|
||||
EGL_LIB = EGL
|
||||
|
||||
|
||||
# Library names (actual file names)
|
||||
|
|
@ -64,6 +65,7 @@ GLUT_LIB_NAME = lib$(GLUT_LIB).so
|
|||
GLEW_LIB_NAME = lib$(GLEW_LIB).a
|
||||
GLW_LIB_NAME = lib$(GLW_LIB).so
|
||||
OSMESA_LIB_NAME = lib$(OSMESA_LIB).so
|
||||
EGL_LIB_NAME = lib$(EGL_LIB).so
|
||||
|
||||
# globs used to install the lib and all symlinks
|
||||
GL_LIB_GLOB = $(GL_LIB_NAME)*
|
||||
|
|
@ -71,6 +73,7 @@ GLU_LIB_GLOB = $(GLU_LIB_NAME)*
|
|||
GLUT_LIB_GLOB = $(GLUT_LIB_NAME)*
|
||||
GLW_LIB_GLOB = $(GLW_LIB_NAME)*
|
||||
OSMESA_LIB_GLOB = $(OSMESA_LIB_NAME)*
|
||||
EGL_LIB_GLOB = $(EGL_LIB_NAME)*
|
||||
|
||||
# Optional assembly language optimization files for libGL
|
||||
MESA_ASM_SOURCES =
|
||||
|
|
@ -89,18 +92,20 @@ DRIVER_DIRS = x11 osmesa
|
|||
# Which subdirs under $(TOP)/progs/ to enter:
|
||||
PROGRAM_DIRS = demos redbook samples glsl objviewer xdemos
|
||||
|
||||
# EGL directories
|
||||
# EGL drivers to build
|
||||
EGL_DRIVERS_DIRS = demo
|
||||
|
||||
# Gallium directories and
|
||||
GALLIUM_DIRS = auxiliary drivers state_trackers
|
||||
GALLIUM_AUXILIARIES = $(TOP)/src/gallium/auxiliary/libgallium.a
|
||||
GALLIUM_DRIVERS_DIRS = softpipe failover svga i915 i965 trace identity
|
||||
GALLIUM_DRIVERS_DIRS = softpipe failover svga i915 i965 r300 trace identity
|
||||
GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a)
|
||||
GALLIUM_WINSYS_DIRS = xlib egl_xlib
|
||||
GALLIUM_WINSYS_DRM_DIRS =
|
||||
GALLIUM_STATE_TRACKERS_DIRS = glx
|
||||
|
||||
# native displays EGL should support
|
||||
EGL_DISPLAYS = x11
|
||||
|
||||
# Library dependencies
|
||||
#EXTRA_LIB_PATH ?=
|
||||
|
|
|
|||
|
|
@ -5,5 +5,5 @@ include $(TOP)/configs/linux
|
|||
CONFIG_NAME = linux-debug
|
||||
|
||||
OPT_FLAGS = -g
|
||||
CFLAGS += -ansi -pedantic
|
||||
CFLAGS += -pedantic
|
||||
DEFINES += -DDEBUG -DDEBUG_MATH
|
||||
|
|
|
|||
59
configure.ac
59
configure.ac
|
|
@ -20,7 +20,8 @@ AC_CANONICAL_HOST
|
|||
dnl Versions for external dependencies
|
||||
LIBDRM_REQUIRED=2.4.15
|
||||
LIBDRM_RADEON_REQUIRED=2.4.17
|
||||
DRI2PROTO_REQUIRED=1.99.3
|
||||
DRI2PROTO_REQUIRED=2.2
|
||||
GLPROTO_REQUIRED=1.4.11
|
||||
|
||||
dnl Check for progs
|
||||
AC_PROG_CPP
|
||||
|
|
@ -243,24 +244,28 @@ GLU_LIB_NAME='lib$(GLU_LIB).'${LIB_EXTENSION}
|
|||
GLUT_LIB_NAME='lib$(GLUT_LIB).'${LIB_EXTENSION}
|
||||
GLW_LIB_NAME='lib$(GLW_LIB).'${LIB_EXTENSION}
|
||||
OSMESA_LIB_NAME='lib$(OSMESA_LIB).'${LIB_EXTENSION}
|
||||
EGL_LIB_NAME='lib$(EGL_LIB).'${LIB_EXTENSION}
|
||||
|
||||
GL_LIB_GLOB='lib$(GL_LIB).*'${LIB_EXTENSION}'*'
|
||||
GLU_LIB_GLOB='lib$(GLU_LIB).*'${LIB_EXTENSION}'*'
|
||||
GLUT_LIB_GLOB='lib$(GLUT_LIB).*'${LIB_EXTENSION}'*'
|
||||
GLW_LIB_GLOB='lib$(GLW_LIB).*'${LIB_EXTENSION}'*'
|
||||
OSMESA_LIB_GLOB='lib$(OSMESA_LIB).*'${LIB_EXTENSION}'*'
|
||||
EGL_LIB_GLOB='lib$(EGL_LIB).*'${LIB_EXTENSION}'*'
|
||||
|
||||
AC_SUBST([GL_LIB_NAME])
|
||||
AC_SUBST([GLU_LIB_NAME])
|
||||
AC_SUBST([GLUT_LIB_NAME])
|
||||
AC_SUBST([GLW_LIB_NAME])
|
||||
AC_SUBST([OSMESA_LIB_NAME])
|
||||
AC_SUBST([EGL_LIB_NAME])
|
||||
|
||||
AC_SUBST([GL_LIB_GLOB])
|
||||
AC_SUBST([GLU_LIB_GLOB])
|
||||
AC_SUBST([GLUT_LIB_GLOB])
|
||||
AC_SUBST([GLW_LIB_GLOB])
|
||||
AC_SUBST([OSMESA_LIB_GLOB])
|
||||
AC_SUBST([EGL_LIB_GLOB])
|
||||
|
||||
dnl
|
||||
dnl Arch/platform-specific settings
|
||||
|
|
@ -571,7 +576,8 @@ dri)
|
|||
# Check for libdrm
|
||||
PKG_CHECK_MODULES([LIBDRM], [libdrm >= $LIBDRM_REQUIRED])
|
||||
PKG_CHECK_MODULES([DRI2PROTO], [dri2proto >= $DRI2PROTO_REQUIRED])
|
||||
GL_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED dri2proto >= $DRI2PROTO_REQUIRED"
|
||||
PKG_CHECK_MODULES([GLPROTO], [glproto >= $GLPROTO_REQUIRED])
|
||||
GL_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED dri2proto >= $DRI2PROTO_REQUIRED glproto >= $GLPROTO_REQUIRED"
|
||||
DRI_PC_REQ_PRIV="libdrm >= $LIBDRM_REQUIRED"
|
||||
|
||||
# find the DRI deps for libGL
|
||||
|
|
@ -900,17 +906,15 @@ AC_ARG_ENABLE([egl],
|
|||
[enable_egl=yes])
|
||||
if test "x$enable_egl" = xyes; then
|
||||
SRC_DIRS="$SRC_DIRS egl"
|
||||
|
||||
if test "$x11_pkgconfig" = yes; then
|
||||
PKG_CHECK_MODULES([EGL], [x11])
|
||||
EGL_LIB_DEPS="$EGL_LIBS"
|
||||
else
|
||||
# should check these...
|
||||
EGL_LIB_DEPS="$X_LIBS -lX11"
|
||||
EGL_LIB_DEPS="$DLOPEN_LIBS -lpthread"
|
||||
EGL_DRIVERS_DIRS=""
|
||||
if test "$enable_static" != yes && test "$mesa_driver" != osmesa; then
|
||||
# build egl_glx when libGL is built
|
||||
EGL_DRIVERS_DIRS="glx"
|
||||
fi
|
||||
EGL_LIB_DEPS="$EGL_LIB_DEPS $DLOPEN_LIBS"
|
||||
fi
|
||||
AC_SUBST([EGL_LIB_DEPS])
|
||||
AC_SUBST([EGL_DRIVERS_DIRS])
|
||||
|
||||
dnl
|
||||
dnl GLU configuration
|
||||
|
|
@ -1158,7 +1162,7 @@ yes)
|
|||
dri)
|
||||
GALLIUM_STATE_TRACKERS_DIRS="dri"
|
||||
if test "x$enable_egl" = xyes; then
|
||||
GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS egl"
|
||||
GALLIUM_STATE_TRACKERS_DIRS="$GALLIUM_STATE_TRACKERS_DIRS egl egl_g3d"
|
||||
fi
|
||||
# Have only tested st/xorg on 1.6.0 servers
|
||||
PKG_CHECK_MODULES(XORG, [xorg-server >= 1.6.0],
|
||||
|
|
@ -1187,6 +1191,35 @@ yes)
|
|||
;;
|
||||
esac
|
||||
|
||||
AC_ARG_WITH([egl-displays],
|
||||
[AS_HELP_STRING([--with-egl-displays@<:@=DIRS...@:>@],
|
||||
[comma delimited native displays libEGL supports, e.g.
|
||||
"x11,kms" @<:@default=auto@:>@])],
|
||||
[with_egl_displays="$withval"],
|
||||
[with_egl_displays=yes])
|
||||
|
||||
EGL_DISPLAYS=""
|
||||
case "$with_egl_displays" in
|
||||
yes)
|
||||
if test "x$enable_egl" = xyes && test "x$mesa_driver" != xosmesa; then
|
||||
EGL_DISPLAYS="x11"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
if test "x$enable_egl" != xyes; then
|
||||
AC_MSG_ERROR([cannot build egl state tracker without EGL library])
|
||||
fi
|
||||
# verify the requested driver directories exist
|
||||
egl_displays=`IFS=', '; echo $with_egl_displays`
|
||||
for dpy in $egl_displays; do
|
||||
test -d "$srcdir/src/gallium/state_trackers/egl_g3d/$dpy" || \
|
||||
AC_MSG_ERROR([EGL display '$dpy' does't exist])
|
||||
done
|
||||
EGL_DISPLAYS="$egl_displays"
|
||||
;;
|
||||
esac
|
||||
AC_SUBST([EGL_DISPLAYS])
|
||||
|
||||
AC_ARG_WITH([xorg-driver-dir],
|
||||
[AS_HELP_STRING([--with-xorg-driver-dir=DIR],
|
||||
[Default xorg driver directory[[default=${libdir}/xorg/modules/drivers]]])],
|
||||
|
|
@ -1246,10 +1279,12 @@ AC_ARG_ENABLE([gallium-radeon],
|
|||
[AS_HELP_STRING([--enable-gallium-radeon],
|
||||
[build gallium radeon @<:@default=disabled@:>@])],
|
||||
[enable_gallium_radeon="$enableval"],
|
||||
[enable_gallium_radeon=no])
|
||||
[enable_gallium_radeon=auto])
|
||||
if test "x$enable_gallium_radeon" = xyes; then
|
||||
GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS radeon"
|
||||
GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300"
|
||||
elif test "x$enable_gallium_radeon" = xauto; then
|
||||
GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS r300"
|
||||
fi
|
||||
|
||||
dnl
|
||||
|
|
|
|||
|
|
@ -41,6 +41,8 @@ tbd
|
|||
<li>Assorted fixes to VMware SVGA gallium driver.
|
||||
<li>Fixed broken blending to multiple color buffers in swrast driver.
|
||||
<li>Allocate constants more tightly in GL_ARB_vertex/fragment parser.
|
||||
<li>Fixed mipmap generation bug caused by invalid viewport state.
|
||||
<li>Gallium SSE codegen for XPD didn't always work.
|
||||
</ul>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -186,6 +186,16 @@ typedef XID GLXWindow;
|
|||
typedef XID GLXPbuffer;
|
||||
|
||||
|
||||
/*
|
||||
** Events.
|
||||
** __GLX_NUMBER_EVENTS is set to 17 to account for the BufferClobberSGIX
|
||||
** event - this helps initialization if the server supports the pbuffer
|
||||
** extension and the client doesn't.
|
||||
*/
|
||||
#define GLX_PbufferClobber 0
|
||||
#define GLX_BufferSwapComplete 1
|
||||
|
||||
#define __GLX_NUMBER_EVENTS 17
|
||||
|
||||
extern XVisualInfo* glXChooseVisual( Display *dpy, int screen,
|
||||
int *attribList );
|
||||
|
|
@ -507,8 +517,17 @@ typedef struct {
|
|||
int count; /* if nonzero, at least this many more */
|
||||
} GLXPbufferClobberEvent;
|
||||
|
||||
typedef struct {
|
||||
int event_type;
|
||||
GLXDrawable drawable;
|
||||
int64_t ust;
|
||||
int64_t msc;
|
||||
int64_t sbc;
|
||||
} GLXBufferSwapComplete;
|
||||
|
||||
typedef union __GLXEvent {
|
||||
GLXPbufferClobberEvent glxpbufferclobber;
|
||||
GLXBufferSwapComplete glxbufferswapcomplete;
|
||||
long pad[24];
|
||||
} GLXEvent;
|
||||
|
||||
|
|
|
|||
|
|
@ -696,6 +696,14 @@ extern void glXJoinSwapGroupSGIX (Display *, GLXDrawable, GLXDrawable);
|
|||
typedef void ( * PFNGLXJOINSWAPGROUPSGIXPROC) (Display *dpy, GLXDrawable drawable, GLXDrawable member);
|
||||
#endif
|
||||
|
||||
#ifndef GLX_INTEL_swap_event
|
||||
#define GLX_INTEL_swap_event
|
||||
#define GLX_BUFFER_SWAP_COMPLETE_MASK 0x10000000
|
||||
#define GLX_EXCHANGE_COMPLETE 0x8024
|
||||
#define GLX_BLIT_COMPLETE 0x8025
|
||||
#define GLX_FLIP_COMPLETE 0x8026
|
||||
#endif
|
||||
|
||||
#ifndef GLX_SGIX_swap_barrier
|
||||
#define GLX_SGIX_swap_barrier 1
|
||||
#ifdef GLX_GLXEXT_PROTOTYPES
|
||||
|
|
|
|||
|
|
@ -262,10 +262,22 @@ struct __DRItexBufferExtensionRec {
|
|||
* Used by drivers that implement DRI2
|
||||
*/
|
||||
#define __DRI2_FLUSH "DRI2_Flush"
|
||||
#define __DRI2_FLUSH_VERSION 1
|
||||
#define __DRI2_FLUSH_VERSION 2
|
||||
struct __DRI2flushExtensionRec {
|
||||
__DRIextension base;
|
||||
void (*flush)(__DRIdrawable *drawable);
|
||||
|
||||
/**
|
||||
* Flush all rendering queue in the driver to the drm and
|
||||
* invalidate all buffers. The driver will call out to
|
||||
* getBuffers/getBuffersWithFormat before it starts rendering
|
||||
* again.
|
||||
*
|
||||
* \param drawable the drawable to flush and invalidate
|
||||
*
|
||||
* \since 2
|
||||
*/
|
||||
void (*flushInvalidate)(__DRIdrawable *drawable);
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,11 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
|
||||
# define VG_API_CALL __attribute__((visibility("default")))
|
||||
# define VGU_API_CALL __attribute__((visibility("default")))
|
||||
#endif
|
||||
|
||||
#ifndef VG_API_CALL
|
||||
#if defined(OPENVG_STATIC_LIBRARY)
|
||||
# define VG_API_CALL
|
||||
|
|
|
|||
46
include/c99/stdbool.h
Normal file
46
include/c99/stdbool.h
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2007-2010 VMware, Inc.
|
||||
* 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 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
|
||||
* THE COPYRIGHT HOLDERS, AUTHORS 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.
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
#ifndef _STDBOOL_H_
|
||||
#define _STDBOOL_H_
|
||||
|
||||
#ifndef __cplusplus
|
||||
|
||||
#define false 0
|
||||
#define true 1
|
||||
#define bool _Bool
|
||||
|
||||
/* For compilers that don't have the builtin _Bool type. */
|
||||
#if defined(_MSC_VER) || (__STDC_VERSION__ < 199901L && __GNUC__ < 3)
|
||||
typedef unsigned char _Bool;
|
||||
#endif
|
||||
|
||||
#endif /* !__cplusplus */
|
||||
|
||||
#define __bool_true_false_are_defined 1
|
||||
|
||||
#endif /* !_STDBOOL_H_ */
|
||||
119
include/c99/stdint.h
Normal file
119
include/c99/stdint.h
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
/**************************************************************************
|
||||
*
|
||||
* Copyright 2007-2010 VMware, Inc.
|
||||
* 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 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
|
||||
* THE COPYRIGHT HOLDERS, AUTHORS 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.
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the
|
||||
* next paragraph) shall be included in all copies or substantial portions
|
||||
* of the Software.
|
||||
*
|
||||
**************************************************************************/
|
||||
|
||||
/*
|
||||
* stdint.h --
|
||||
*
|
||||
* Portable subset of C99's stdint.h.
|
||||
*
|
||||
* At the moment it only supports MSVC, given all other mainstream compilers
|
||||
* already support C99. If this is necessary for other compilers then it
|
||||
* might be worth to replace this with
|
||||
* http://www.azillionmonkeys.com/qed/pstdint.h.
|
||||
*/
|
||||
|
||||
#ifndef _STDINT_H_
|
||||
#define _STDINT_H_
|
||||
|
||||
|
||||
#ifndef INT8_MAX
|
||||
#define INT8_MAX 127
|
||||
#endif
|
||||
#ifndef INT8_MIN
|
||||
#define INT8_MIN -128
|
||||
#endif
|
||||
#ifndef UINT8_MAX
|
||||
#define UINT8_MAX 255
|
||||
#endif
|
||||
#ifndef INT16_MAX
|
||||
#define INT16_MAX 32767
|
||||
#endif
|
||||
#ifndef INT16_MIN
|
||||
#define INT16_MIN -32768
|
||||
#endif
|
||||
#ifndef UINT16_MAX
|
||||
#define UINT16_MAX 65535
|
||||
#endif
|
||||
#ifndef INT32_MAX
|
||||
#define INT32_MAX 2147483647
|
||||
#endif
|
||||
#ifndef INT32_MIN
|
||||
#define INT32_MIN -2147483648
|
||||
#endif
|
||||
#ifndef UINT32_MAX
|
||||
#define UINT32_MAX 4294967295U
|
||||
#endif
|
||||
|
||||
#ifndef INT8_C
|
||||
#define INT8_C(__val) __val
|
||||
#endif
|
||||
#ifndef UINT8_C
|
||||
#define UINT8_C(__val) __val
|
||||
#endif
|
||||
#ifndef INT16_C
|
||||
#define INT16_C(__val) __val
|
||||
#endif
|
||||
#ifndef UINT16_C
|
||||
#define UINT16_C(__val) __val
|
||||
#endif
|
||||
#ifndef INT32_C
|
||||
#define INT32_C(__val) __val
|
||||
#endif
|
||||
#ifndef UINT32_C
|
||||
#define UINT32_C(__val) __val##U
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
|
||||
typedef __int8 int8_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
#ifndef __eglplatform_h_
|
||||
typedef __int32 int32_t;
|
||||
#endif
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
|
||||
#if defined(_WIN64)
|
||||
typedef __int64 intptr_t;
|
||||
typedef unsigned __int64 uintptr_t;
|
||||
#else
|
||||
typedef __int32 intptr_t;
|
||||
typedef unsigned __int32 uintptr_t;
|
||||
#endif
|
||||
|
||||
#define INT64_C(__val) __val##i64
|
||||
#define UINT64_C(__val) __val##ui64
|
||||
|
||||
#else
|
||||
#error "Unsupported compiler"
|
||||
#endif
|
||||
|
||||
#endif /* _STDINT_H_ */
|
||||
|
|
@ -120,7 +120,11 @@ static Engine Engines[NUM_ENGINES] =
|
|||
0.3, /* CrankJournalRadius */
|
||||
0.4, /* CrankJournalLength */
|
||||
1.5, /* ConnectingRodLength */
|
||||
0.1 /* ConnectingRodThickness */
|
||||
0.1, /* ConnectingRodThickness */
|
||||
0, /* CrankList */
|
||||
0, /* ConnRodList */
|
||||
0, /* PistonList */
|
||||
0 /* BlockList */
|
||||
},
|
||||
{
|
||||
"Inline-4",
|
||||
|
|
@ -136,7 +140,11 @@ static Engine Engines[NUM_ENGINES] =
|
|||
0.3, /* CrankJournalRadius */
|
||||
0.4, /* CrankJournalLength */
|
||||
1.5, /* ConnectingRodLength */
|
||||
0.1 /* ConnectingRodThickness */
|
||||
0.1, /* ConnectingRodThickness */
|
||||
0, /* CrankList */
|
||||
0, /* ConnRodList */
|
||||
0, /* PistonList */
|
||||
0 /* BlockList */
|
||||
},
|
||||
{
|
||||
"Boxer-6",
|
||||
|
|
@ -152,7 +160,11 @@ static Engine Engines[NUM_ENGINES] =
|
|||
0.3, /* CrankJournalRadius */
|
||||
0.4, /* CrankJournalLength */
|
||||
1.5, /* ConnectingRodLength */
|
||||
0.1 /* ConnectingRodThickness */
|
||||
0.1, /* ConnectingRodThickness */
|
||||
0, /* CrankList */
|
||||
0, /* ConnRodList */
|
||||
0, /* PistonList */
|
||||
0 /* BlockList */
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include "extfuncs.h"
|
||||
|
||||
/* For debug */
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
* Humanware s.r.l.
|
||||
*/
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
|
@ -725,8 +726,13 @@ main(int ac, char **av)
|
|||
|
||||
maxage = 1.0 / dt;
|
||||
|
||||
if (ac == 2)
|
||||
if (ac == 2) {
|
||||
np = atoi(av[1]);
|
||||
if (np <= 0 || np > 1000000) {
|
||||
fprintf(stderr, "Invalid input.\n");
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
if (ac == 4) {
|
||||
WIDTH = atoi(av[2]);
|
||||
|
|
@ -758,7 +764,9 @@ main(int ac, char **av)
|
|||
glFogfv(GL_FOG_COLOR, fogcolor);
|
||||
glFogf(GL_FOG_DENSITY, 0.1);
|
||||
|
||||
assert(np > 0);
|
||||
p = (part *) malloc(sizeof(part) * np);
|
||||
assert(p);
|
||||
|
||||
for (i = 0; i < np; i++)
|
||||
setnewpart(&p[i]);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
|
|
|
|||
|
|
@ -137,7 +137,6 @@ So the angle is:
|
|||
#endif
|
||||
#include <GL/glut.h>
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#define Scale 0.3
|
||||
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ main(int argc, char *argv[])
|
|||
|
||||
PrintConfigs(d, configs, numConfigs);
|
||||
|
||||
eglBindAPI(EGL_OPENGL_API);
|
||||
ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL);
|
||||
if (ctx == EGL_NO_CONTEXT) {
|
||||
printf("failed to create context\n");
|
||||
|
|
|
|||
|
|
@ -111,11 +111,7 @@ main(int argc, char *argv[])
|
|||
EGL_HEIGHT, 500,
|
||||
EGL_NONE
|
||||
};
|
||||
const EGLint screenAttribs[] = {
|
||||
EGL_WIDTH, 1024,
|
||||
EGL_HEIGHT, 768,
|
||||
EGL_NONE
|
||||
};
|
||||
EGLint screenAttribs[32];
|
||||
EGLModeMESA mode;
|
||||
EGLScreenMESA screen;
|
||||
EGLint count;
|
||||
|
|
@ -149,6 +145,7 @@ main(int argc, char *argv[])
|
|||
eglGetScreensMESA(d, &screen, 1, &count);
|
||||
eglGetModesMESA(d, screen, &mode, 1, &count);
|
||||
|
||||
eglBindAPI(EGL_OPENGL_API);
|
||||
ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL);
|
||||
if (ctx == EGL_NO_CONTEXT) {
|
||||
printf("failed to create context\n");
|
||||
|
|
@ -169,6 +166,13 @@ main(int argc, char *argv[])
|
|||
|
||||
b = eglMakeCurrent(d, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
|
||||
i = 0;
|
||||
screenAttribs[i++] = EGL_WIDTH;
|
||||
eglGetModeAttribMESA(d, mode, EGL_WIDTH, &screenAttribs[i++]);
|
||||
screenAttribs[i++] = EGL_HEIGHT;
|
||||
eglGetModeAttribMESA(d, mode, EGL_HEIGHT, &screenAttribs[i++]);
|
||||
screenAttribs[i] = EGL_NONE;
|
||||
|
||||
screen_surf = eglCreateScreenSurfaceMESA(d, configs[0], screenAttribs);
|
||||
if (screen_surf == EGL_NO_SURFACE) {
|
||||
printf("failed to create screen surface\n");
|
||||
|
|
|
|||
|
|
@ -564,11 +564,8 @@ main(int argc, char *argv[])
|
|||
EGLint numConfigs, count;
|
||||
EGLBoolean b;
|
||||
const GLubyte *bitmap;
|
||||
const EGLint screenAttribs[] = {
|
||||
EGL_WIDTH, 1024,
|
||||
EGL_HEIGHT, 768,
|
||||
EGL_NONE
|
||||
};
|
||||
EGLint screenAttribs[32];
|
||||
EGLint i;
|
||||
|
||||
EGLDisplay d = eglGetDisplay(EGL_DEFAULT_DISPLAY);
|
||||
assert(d);
|
||||
|
|
@ -590,12 +587,20 @@ main(int argc, char *argv[])
|
|||
eglGetScreensMESA(d, &screen, 1, &count);
|
||||
eglGetModesMESA(d, screen, &mode, 1, &count);
|
||||
|
||||
eglBindAPI(EGL_OPENGL_API);
|
||||
ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL);
|
||||
if (ctx == EGL_NO_CONTEXT) {
|
||||
printf("failed to create context\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
screenAttribs[i++] = EGL_WIDTH;
|
||||
eglGetModeAttribMESA(d, mode, EGL_WIDTH, &screenAttribs[i++]);
|
||||
screenAttribs[i++] = EGL_HEIGHT;
|
||||
eglGetModeAttribMESA(d, mode, EGL_HEIGHT, &screenAttribs[i++]);
|
||||
screenAttribs[i] = EGL_NONE;
|
||||
|
||||
screen_surf = eglCreateScreenSurfaceMESA(d, configs[0], screenAttribs);
|
||||
if (screen_surf == EGL_NO_SURFACE) {
|
||||
printf("failed to create screen surface\n");
|
||||
|
|
|
|||
|
|
@ -426,6 +426,7 @@ main(int argc, char *argv[])
|
|||
}
|
||||
printf("eglgears: Using screen mode/size %d: %d x %d\n", chosenMode, width, height);
|
||||
|
||||
eglBindAPI(EGL_OPENGL_API);
|
||||
ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL);
|
||||
if (ctx == EGL_NO_CONTEXT) {
|
||||
printf("eglgears: failed to create context\n");
|
||||
|
|
|
|||
|
|
@ -208,6 +208,7 @@ int main(int argc, char *argv[])
|
|||
}
|
||||
printf("egltri: Using screen mode/size %d: %d x %d\n", chosenMode, width, height);
|
||||
|
||||
eglBindAPI(EGL_OPENGL_API);
|
||||
ctx = eglCreateContext(d, configs[0], EGL_NO_CONTEXT, NULL);
|
||||
if (ctx == EGL_NO_CONTEXT) {
|
||||
printf("egltri: failed to create context\n");
|
||||
|
|
|
|||
|
|
@ -120,6 +120,7 @@ make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
|
|||
EGL_GREEN_SIZE, 1,
|
||||
EGL_BLUE_SIZE, 1,
|
||||
EGL_DEPTH_SIZE, 1,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
|
|
@ -138,7 +139,8 @@ make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
|
|||
scrnum = DefaultScreen( x_dpy );
|
||||
root = RootWindow( x_dpy, scrnum );
|
||||
|
||||
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) {
|
||||
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs) ||
|
||||
!num_configs) {
|
||||
printf("Error: couldn't get an EGL visual config\n");
|
||||
exit(1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ make_pbuffer(int width, int height)
|
|||
EGL_GREEN_SIZE, 8,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_BIND_TO_TEXTURE_RGB, EGL_TRUE,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
||||
EGL_NONE
|
||||
};
|
||||
EGLint pbuf_attribs[] = {
|
||||
|
|
@ -65,7 +66,8 @@ make_pbuffer(int width, int height)
|
|||
EGLConfig config;
|
||||
EGLint num_configs;
|
||||
|
||||
if (!eglChooseConfig(dpy, config_attribs, &config, 1, &num_configs)) {
|
||||
if (!eglChooseConfig(dpy, config_attribs, &config, 1, &num_configs) ||
|
||||
!num_configs) {
|
||||
printf("Error: couldn't get an EGL visual config for pbuffer\n");
|
||||
exit(1);
|
||||
}
|
||||
|
|
@ -77,8 +79,6 @@ make_pbuffer(int width, int height)
|
|||
printf("failed to allocate pbuffer\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glGenTextures(1, &tex_pbuf);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -112,6 +112,8 @@ use_pbuffer(void)
|
|||
glTranslatef(0.0, 0.0, -5.0);
|
||||
|
||||
glClearColor(0.2, 0.2, 0.2, 0.0);
|
||||
|
||||
glGenTextures(1, &tex_pbuf);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -126,6 +128,7 @@ make_window(Display *x_dpy, const char *name,
|
|||
EGL_BLUE_SIZE, 8,
|
||||
EGL_ALPHA_SIZE, 8,
|
||||
EGL_DEPTH_SIZE, 8,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
|
|
@ -142,7 +145,8 @@ make_window(Display *x_dpy, const char *name,
|
|||
scrnum = DefaultScreen( x_dpy );
|
||||
root = RootWindow( x_dpy, scrnum );
|
||||
|
||||
if (!eglChooseConfig(dpy, attribs, &config, 1, &num_configs)) {
|
||||
if (!eglChooseConfig(dpy, attribs, &config, 1, &num_configs) ||
|
||||
!num_configs) {
|
||||
printf("Error: couldn't get an EGL visual config\n");
|
||||
exit(1);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -467,6 +467,7 @@ create_window(struct winthread *wt, EGLContext shareCtx)
|
|||
EGL_GREEN_SIZE, 1,
|
||||
EGL_BLUE_SIZE, 1,
|
||||
EGL_DEPTH_SIZE, 1,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
|
||||
EGL_NONE };
|
||||
EGLConfig config;
|
||||
EGLint num_configs;
|
||||
|
|
@ -484,7 +485,8 @@ create_window(struct winthread *wt, EGLContext shareCtx)
|
|||
scrnum = DefaultScreen(wt->Dpy);
|
||||
root = RootWindow(wt->Dpy, scrnum);
|
||||
|
||||
if (!eglChooseConfig(wt->Display, attribs, &config, 1, &num_configs)) {
|
||||
if (!eglChooseConfig(wt->Display, attribs, &config, 1, &num_configs) ||
|
||||
!num_configs) {
|
||||
Error("Unable to choose an EGL config");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ SOURCES = \
|
|||
tri-depth2.c \
|
||||
tri-depthwrite.c \
|
||||
tri-depthwrite2.c \
|
||||
tri-inv.c \
|
||||
tri-param.c \
|
||||
fp-tri.c
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ progs = [
|
|||
'tri-depth2',
|
||||
'tri-depthwrite',
|
||||
'tri-depthwrite2',
|
||||
'tri-inv',
|
||||
'tri-param',
|
||||
'tri-tex',
|
||||
'point-position',
|
||||
|
|
|
|||
|
|
@ -1,111 +0,0 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
|
||||
static void Init( void )
|
||||
{
|
||||
static const char *modulate2D =
|
||||
"!!ARBfp1.0\n"
|
||||
"TEMP R0;\n"
|
||||
"INV result.color, fragment.color; \n"
|
||||
"END"
|
||||
;
|
||||
GLuint modulateProg;
|
||||
|
||||
if (!GLEW_ARB_fragment_program) {
|
||||
printf("Error: GL_ARB_fragment_program not supported!\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
/* Setup the fragment program */
|
||||
glGenProgramsARB(1, &modulateProg);
|
||||
glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, modulateProg);
|
||||
glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
|
||||
strlen(modulate2D), (const GLubyte *)modulate2D);
|
||||
|
||||
printf("glGetError = 0x%x\n", (int) glGetError());
|
||||
printf("glError(GL_PROGRAM_ERROR_STRING_ARB) = %s\n",
|
||||
(char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
|
||||
|
||||
glEnable(GL_FRAGMENT_PROGRAM_ARB);
|
||||
|
||||
glClearColor(.3, .3, .3, 0);
|
||||
}
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
static void Key(unsigned char key, int x, int y)
|
||||
{
|
||||
|
||||
switch (key) {
|
||||
case 27:
|
||||
exit(1);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
static void Draw(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(0,0,1);
|
||||
glVertex3f( 0.9, -0.9, -30.0);
|
||||
glColor3f(1,0,0);
|
||||
glVertex3f( 0.9, 0.9, -30.0);
|
||||
glColor3f(0,1,0);
|
||||
glVertex3f(-0.9, 0.0, -30.0);
|
||||
glEnd();
|
||||
|
||||
glFlush();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
GLenum type;
|
||||
|
||||
glutInit(&argc, argv);
|
||||
|
||||
|
||||
|
||||
glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
|
||||
|
||||
type = GLUT_RGB;
|
||||
type |= GLUT_SINGLE;
|
||||
glutInitDisplayMode(type);
|
||||
|
||||
if (glutCreateWindow("First Tri") == GL_FALSE) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glewInit();
|
||||
|
||||
Init();
|
||||
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -182,7 +182,7 @@ static void fillConvolution(GLint *k,
|
|||
static void setupConvolution()
|
||||
{
|
||||
GLint *kernel = (GLint*)malloc(sizeof(GLint) * 9);
|
||||
GLfloat scale;
|
||||
GLfloat scale = 0.0;
|
||||
GLfloat *vecKer = (GLfloat*)malloc(sizeof(GLfloat) * 9 * 4);
|
||||
GLuint loc;
|
||||
GLuint i;
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@
|
|||
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
|
@ -549,6 +548,10 @@ ReadConfigFile(const char *filename, struct config_file *conf)
|
|||
|
||||
type = TypeFromName(typeName);
|
||||
|
||||
if (strlen(name) + 1 > sizeof(conf->uniforms[conf->num_uniforms].name)) {
|
||||
fprintf(stderr, "string overflow\n");
|
||||
exit(1);
|
||||
}
|
||||
strcpy(conf->uniforms[conf->num_uniforms].name, name);
|
||||
conf->uniforms[conf->num_uniforms].value[0] = v1;
|
||||
conf->uniforms[conf->num_uniforms].value[1] = v2;
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
|
|||
EGL_RED_SIZE, 1,
|
||||
EGL_GREEN_SIZE, 1,
|
||||
EGL_BLUE_SIZE, 1,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
|
|
@ -60,13 +61,13 @@ make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
|
|||
scrnum = DefaultScreen( x_dpy );
|
||||
root = RootWindow( x_dpy, scrnum );
|
||||
|
||||
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) {
|
||||
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs) ||
|
||||
!num_configs) {
|
||||
printf("Error: couldn't get an EGL visual config\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
assert(config);
|
||||
assert(num_configs > 0);
|
||||
|
||||
if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
|
||||
printf("Error: eglGetConfigAttrib() failed\n");
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
|
|||
EGL_RED_SIZE, 1,
|
||||
EGL_GREEN_SIZE, 1,
|
||||
EGL_BLUE_SIZE, 1,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
|
|
@ -85,13 +86,13 @@ make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
|
|||
scrnum = DefaultScreen( x_dpy );
|
||||
root = RootWindow( x_dpy, scrnum );
|
||||
|
||||
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) {
|
||||
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs) ||
|
||||
!num_configs) {
|
||||
printf("Error: couldn't get an EGL visual config\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
assert(config);
|
||||
assert(num_configs > 0);
|
||||
|
||||
if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
|
||||
printf("Error: eglGetConfigAttrib() failed\n");
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
|
|||
EGL_RED_SIZE, 1,
|
||||
EGL_GREEN_SIZE, 1,
|
||||
EGL_BLUE_SIZE, 1,
|
||||
EGL_RENDERABLE_TYPE, EGL_OPENVG_BIT,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
|
|
@ -60,13 +61,13 @@ make_x_window(Display *x_dpy, EGLDisplay egl_dpy,
|
|||
scrnum = DefaultScreen( x_dpy );
|
||||
root = RootWindow( x_dpy, scrnum );
|
||||
|
||||
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs)) {
|
||||
if (!eglChooseConfig( egl_dpy, attribs, &config, 1, &num_configs) ||
|
||||
!num_configs) {
|
||||
printf("Error: couldn't get an EGL visual config\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
assert(config);
|
||||
assert(num_configs > 0);
|
||||
|
||||
if (!eglGetConfigAttrib(egl_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
|
||||
printf("Error: eglGetConfigAttrib() failed\n");
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@
|
|||
#include <GL/glut.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
GLboolean polySmooth = GL_TRUE;
|
||||
|
||||
|
|
|
|||
|
|
@ -660,8 +660,8 @@ exercise_CompressedTextures(GLenum dimension)
|
|||
glGetTexLevelParameteriv(dimension, 0, GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB,
|
||||
&queryCompressedSize);
|
||||
if (queryCompressedSize != sizeof(compressedTexture)) {
|
||||
fprintf(stderr, "%s: compressed 3D texture changed size: expected %d, actual %d\n",
|
||||
__FUNCTION__, sizeof(compressedTexture), queryCompressedSize);
|
||||
fprintf(stderr, "%s: compressed 3D texture changed size: expected %lu, actual %d\n",
|
||||
__FUNCTION__, (unsigned long) sizeof(compressedTexture), queryCompressedSize);
|
||||
return GL_FALSE;
|
||||
}
|
||||
(*GetCompressedTexImageARB)(dimension, 0, queryCompressedData);
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ static const unsigned indicies[12] = {
|
|||
1, 4, 2
|
||||
};
|
||||
|
||||
#define NONE { NULL, 0, 0, 0 }
|
||||
#define NONE { NULL, 0, 0, 0, sizeof( NULL ) }
|
||||
#define V2F { v, 2, 2 * sizeof( GLfloat ), GL_FLOAT, sizeof( v[0] ) }
|
||||
#define V3F { v, 3, 3 * sizeof( GLfloat ), GL_FLOAT, sizeof( v[0] ) }
|
||||
#define V4F { v, 4, 4 * sizeof( GLfloat ), GL_FLOAT, sizeof( v[0] ) }
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ static struct wrap_mode modes[] = {
|
|||
WRAP_EXT ( GL_MIRROR_CLAMP_TO_EDGE_EXT, "GL_ATI_texture_mirror_once",
|
||||
"GL_EXT_texture_mirror_clamp",
|
||||
999.0 ),
|
||||
{ 0 }
|
||||
{ 0, NULL, GL_FALSE, 0.0, { NULL, NULL } }
|
||||
};
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
|
@ -183,7 +182,7 @@ static void init_program(void)
|
|||
static const GLfloat bias[4] = {1.0, 1.0, 1.0, 0.0};
|
||||
|
||||
if (!glutExtensionSupported("GL_NV_vertex_program")) {
|
||||
printf("Sorry, this program requires GL_NV_vertex_program");
|
||||
printf("Sorry, this program requires GL_NV_vertex_program\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -121,6 +121,7 @@ SOURCES = \
|
|||
tri-lit-material.c \
|
||||
tri-mask-tri.c \
|
||||
tri-orig.c \
|
||||
tri-point-line-clipped.c \
|
||||
tri-query.c \
|
||||
tri-repeat.c \
|
||||
tri-scissor-tri.c \
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ progs = [
|
|||
'tri-logicop-xor',
|
||||
'tri-mask-tri',
|
||||
'tri-orig',
|
||||
'tri-point-line-clipped',
|
||||
'tri-query',
|
||||
'tri-repeat',
|
||||
'tri-scissor-tri',
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
/* For debug */
|
||||
|
|
|
|||
|
|
@ -6,8 +6,6 @@
|
|||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
/* For debug */
|
||||
|
||||
|
|
|
|||
116
progs/trivial/tri-point-line-clipped.c
Normal file
116
progs/trivial/tri-point-line-clipped.c
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
/**
|
||||
* Test frustum/user clipping w/ glPolygonMode LINE/POINT.
|
||||
*
|
||||
* The bottom/left and bottom/right verts are outside the frustum and clipped.
|
||||
* The top vertex is clipped by a user clipping plane.
|
||||
*
|
||||
* A filled gray reference triangle is shown underneath the points/lines.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
||||
static int win;
|
||||
|
||||
|
||||
static void
|
||||
ColorTri(void)
|
||||
{
|
||||
glBegin(GL_TRIANGLES);
|
||||
glColor3f(1, 0, 0); glVertex3f(-1.5, -0.8, 0.0);
|
||||
glColor3f(0, 1, 0); glVertex3f( 1.5, -0.8, 0.0);
|
||||
glColor3f(0, 0, 1); glVertex3f( 0.0, 0.9, 0.0);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
GrayTri(void)
|
||||
{
|
||||
glColor3f(0.3, 0.3, 0.3);
|
||||
glBegin(GL_TRIANGLES);
|
||||
glVertex3f(-1.5, -0.8, 0.0);
|
||||
glVertex3f( 1.5, -0.8, 0.0);
|
||||
glVertex3f( 0.0, 0.9, 0.0);
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Draw(void)
|
||||
{
|
||||
static const GLdouble plane[4] = { 0, -1.0, 0, 0.5 };
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glPointSize(13.0);
|
||||
glLineWidth(5.0);
|
||||
|
||||
glClipPlane(GL_CLIP_PLANE0, plane);
|
||||
glEnable(GL_CLIP_PLANE0);
|
||||
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
|
||||
GrayTri();
|
||||
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
|
||||
ColorTri();
|
||||
|
||||
glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
|
||||
ColorTri();
|
||||
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
static void Reshape(int width, int height)
|
||||
{
|
||||
glViewport(0, 0, (GLint)width, (GLint)height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Key(unsigned char key, int x, int y)
|
||||
{
|
||||
if (key == 27) {
|
||||
glutDestroyWindow(win);
|
||||
exit(0);
|
||||
}
|
||||
else {
|
||||
glutPostRedisplay();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Init(void)
|
||||
{
|
||||
fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||
fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||
fflush(stderr);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
glutInitWindowSize(300, 300);
|
||||
glutInit(&argc, argv);
|
||||
glutInitDisplayMode(GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(*argv);
|
||||
if (!win) {
|
||||
return 1;
|
||||
}
|
||||
Init();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutDisplayFunc(Draw);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
||||
1
progs/xdemos/.gitignore
vendored
1
progs/xdemos/.gitignore
vendored
|
|
@ -26,3 +26,4 @@ xdemo
|
|||
xfont
|
||||
xrotfontdemo
|
||||
yuvrect_client
|
||||
msctest
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ PROGS = \
|
|||
glxsnoop \
|
||||
glxswapcontrol \
|
||||
manywin \
|
||||
msctest \
|
||||
multictx \
|
||||
offset \
|
||||
overlay \
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@
|
|||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <unistd.h>
|
||||
#include "ipc.h"
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@
|
|||
|
||||
void (*video_sync_get)();
|
||||
void (*video_sync)();
|
||||
void (*swap_interval)();
|
||||
|
||||
static int GLXExtensionSupported(Display *dpy, const char *extension)
|
||||
{
|
||||
|
|
@ -84,12 +85,12 @@ static int GLXExtensionSupported(Display *dpy, const char *extension)
|
|||
|
||||
extern char *optarg;
|
||||
extern int optind, opterr, optopt;
|
||||
static char optstr[] = "w:h:s:v";
|
||||
static char optstr[] = "w:h:s:vi:";
|
||||
|
||||
enum sync_type {
|
||||
none = 0,
|
||||
sgi_video_sync,
|
||||
buffer_swap,
|
||||
buffer_swap
|
||||
};
|
||||
|
||||
static void usage(char *name)
|
||||
|
|
@ -100,6 +101,7 @@ static void usage(char *name)
|
|||
printf("\t\tn: none\n");
|
||||
printf("\t\ts: SGI video sync extension\n");
|
||||
printf("\t\tb: buffer swap\n");
|
||||
printf("\t-i<swap interval>\n");
|
||||
printf("\t-v: verbose (print count)\n");
|
||||
exit(-1);
|
||||
}
|
||||
|
|
@ -109,16 +111,28 @@ int main(int argc, char *argv[])
|
|||
Display *disp;
|
||||
XVisualInfo *pvi;
|
||||
XSetWindowAttributes swa;
|
||||
int attrib[14];
|
||||
GLint last_val = -1, count = 0;
|
||||
Window winGL;
|
||||
GLXContext context;
|
||||
int dummy;
|
||||
Atom wmDelete;
|
||||
enum sync_type waitforsync = none;
|
||||
int width = 500, height = 500, verbose = 0,
|
||||
countonly = 0;
|
||||
int width = 500, height = 500, verbose = 0, interval = 1;
|
||||
int c, i = 1;
|
||||
int ret;
|
||||
int attribs[] = { GLX_RGBA,
|
||||
GLX_RED_SIZE, 1,
|
||||
GLX_GREEN_SIZE, 1,
|
||||
GLX_BLUE_SIZE, 1,
|
||||
None };
|
||||
int db_attribs[] = { GLX_RGBA,
|
||||
GLX_RED_SIZE, 1,
|
||||
GLX_GREEN_SIZE, 1,
|
||||
GLX_BLUE_SIZE, 1,
|
||||
GLX_DOUBLEBUFFER,
|
||||
GLX_DEPTH_SIZE, 1,
|
||||
None };
|
||||
XSizeHints sizehints;
|
||||
|
||||
opterr = 0;
|
||||
while ((c = getopt(argc, argv, optstr)) != -1) {
|
||||
|
|
@ -148,6 +162,9 @@ int main(int argc, char *argv[])
|
|||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
case 'i':
|
||||
interval = atoi(optarg);
|
||||
break;
|
||||
default:
|
||||
usage(argv[0]);
|
||||
break;
|
||||
|
|
@ -170,34 +187,17 @@ int main(int argc, char *argv[])
|
|||
return -1;
|
||||
}
|
||||
|
||||
attrib[0] = GLX_RGBA;
|
||||
attrib[1] = 1;
|
||||
attrib[2] = GLX_RED_SIZE;
|
||||
attrib[3] = 1;
|
||||
attrib[4] = GLX_GREEN_SIZE;
|
||||
attrib[5] = 1;
|
||||
attrib[6] = GLX_BLUE_SIZE;
|
||||
attrib[7] = 1;
|
||||
if (waitforsync != buffer_swap)
|
||||
attrib[8] = None;
|
||||
else {
|
||||
attrib[8] = GLX_DOUBLEBUFFER;
|
||||
attrib[9] = 1;
|
||||
attrib[10] = None;
|
||||
if (waitforsync != buffer_swap) {
|
||||
pvi = glXChooseVisual(disp, DefaultScreen(disp), attribs);
|
||||
} else {
|
||||
pvi = glXChooseVisual(disp, DefaultScreen(disp), db_attribs);
|
||||
}
|
||||
|
||||
pvi = glXChooseVisual(disp, DefaultScreen(disp), attrib);
|
||||
if (!pvi) {
|
||||
fprintf(stderr, "failed to choose visual, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
context = glXCreateContext(disp, pvi, None, GL_TRUE);
|
||||
if (!context) {
|
||||
fprintf(stderr, "failed to create glx context\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
pvi->screen = DefaultScreen(disp);
|
||||
|
||||
swa.colormap = XCreateColormap(disp, RootWindow(disp, pvi->screen),
|
||||
|
|
@ -217,24 +217,58 @@ int main(int argc, char *argv[])
|
|||
wmDelete = XInternAtom(disp, "WM_DELETE_WINDOW", True);
|
||||
XSetWMProtocols(disp, winGL, &wmDelete, 1);
|
||||
|
||||
sizehints.x = 0;
|
||||
sizehints.y = 0;
|
||||
sizehints.width = width;
|
||||
sizehints.height = height;
|
||||
sizehints.flags = USSize | USPosition;
|
||||
|
||||
XSetNormalHints(disp, winGL, &sizehints);
|
||||
XSetStandardProperties(disp, winGL, "glsync test", "glsync text",
|
||||
None, NULL, 0, NULL);
|
||||
None, NULL, 0, &sizehints);
|
||||
|
||||
XMapRaised(disp, winGL);
|
||||
context = glXCreateContext(disp, pvi, NULL, GL_TRUE);
|
||||
if (!context) {
|
||||
fprintf(stderr, "failed to create glx context\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
glXMakeCurrent(disp, winGL, context);
|
||||
XMapWindow(disp, winGL);
|
||||
ret = glXMakeCurrent(disp, winGL, context);
|
||||
if (ret) {
|
||||
fprintf(stderr, "failed to make context current: %d\n", ret);
|
||||
}
|
||||
|
||||
video_sync_get = glXGetProcAddress((unsigned char *)"glXGetVideoSyncSGI");
|
||||
video_sync = glXGetProcAddress((unsigned char *)"glXWaitVideoSyncSGI");
|
||||
|
||||
if (!video_sync_get || !video_sync) {
|
||||
swap_interval = glXGetProcAddress((unsigned char *)"glXSwapIntervalSGI");
|
||||
|
||||
if (!video_sync_get || !video_sync || !swap_interval) {
|
||||
fprintf(stderr, "failed to get sync functions\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (waitforsync == buffer_swap) {
|
||||
swap_interval(interval);
|
||||
fprintf(stderr, "set swap interval to %d\n", interval);
|
||||
}
|
||||
video_sync_get(&count);
|
||||
count++;
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
while (i++) {
|
||||
/* Alternate colors to make tearing obvious */
|
||||
if (i & 1) {
|
||||
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
glColor3f(1.0f, 1.0f, 1.0f);
|
||||
} else {
|
||||
glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
|
||||
glColor3f(1.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glRectf(0, 0, width, height);
|
||||
|
||||
/* Wait for vsync */
|
||||
if (waitforsync == sgi_video_sync) {
|
||||
if (verbose)
|
||||
|
|
@ -245,24 +279,19 @@ int main(int argc, char *argv[])
|
|||
if (count == last_val)
|
||||
fprintf(stderr, "error: count didn't change: %d\n", count);
|
||||
last_val = count;
|
||||
glFlush();
|
||||
} else if (waitforsync == buffer_swap) {
|
||||
glXSwapBuffers(disp, winGL);
|
||||
}
|
||||
|
||||
if (countonly) {
|
||||
video_sync(2, 1, &count);
|
||||
fprintf(stderr, "current count: %d\n", count);
|
||||
} else {
|
||||
video_sync_get(&count);
|
||||
sleep(1);
|
||||
continue;
|
||||
glFinish();
|
||||
}
|
||||
|
||||
/* Alternate colors to make tearing obvious */
|
||||
if (i & 1)
|
||||
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
else
|
||||
glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glFlush();
|
||||
if (verbose) {
|
||||
video_sync_get(&count);
|
||||
fprintf(stderr, "current count: %d\n", count);
|
||||
}
|
||||
}
|
||||
|
||||
XDestroyWindow(disp, winGL);
|
||||
|
|
|
|||
|
|
@ -145,14 +145,40 @@ AddHead(const char *displayName)
|
|||
/* save the info for this head */
|
||||
{
|
||||
struct head *h = &Heads[NumHeads];
|
||||
const char * tmp;
|
||||
|
||||
if (strlen(displayName) + 1 > sizeof(h->DisplayName)) {
|
||||
Error(displayName, "displayName string length overflow");
|
||||
return NULL;
|
||||
}
|
||||
strcpy(h->DisplayName, displayName);
|
||||
|
||||
h->Dpy = dpy;
|
||||
h->Win = win;
|
||||
h->Context = ctx;
|
||||
h->Angle = 0.0;
|
||||
strcpy(h->Version, (char *) glGetString(GL_VERSION));
|
||||
strcpy(h->Vendor, (char *) glGetString(GL_VENDOR));
|
||||
strcpy(h->Renderer, (char *) glGetString(GL_RENDERER));
|
||||
|
||||
tmp = (char *) glGetString(GL_VERSION);
|
||||
if (strlen(tmp) + 1 > sizeof(h->Version)) {
|
||||
Error(displayName, "GL_VERSION string length overflow");
|
||||
return NULL;
|
||||
}
|
||||
strcpy(h->Version, tmp);
|
||||
|
||||
tmp = (char *) glGetString(GL_VENDOR);
|
||||
if (strlen(tmp) + 1 > sizeof(h->Vendor)) {
|
||||
Error(displayName, "GL_VENDOR string length overflow");
|
||||
return NULL;
|
||||
}
|
||||
strcpy(h->Vendor, tmp);
|
||||
|
||||
tmp = (char *) glGetString(GL_RENDERER);
|
||||
if (strlen(tmp) + 1 > sizeof(h->Renderer)) {
|
||||
Error(displayName, "GL_RENDERER string length overflow");
|
||||
return NULL;
|
||||
}
|
||||
strcpy(h->Renderer, tmp);
|
||||
|
||||
NumHeads++;
|
||||
return &Heads[NumHeads-1];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -177,14 +177,40 @@ AddHead(const char *displayName, const char *name)
|
|||
/* save the info for this head */
|
||||
{
|
||||
struct head *h = &Heads[NumHeads];
|
||||
const char * tmp;
|
||||
|
||||
if (strlen(name) + 1 > sizeof(h->DisplayName)) {
|
||||
Error(displayName, "name string overflow");
|
||||
return NULL;
|
||||
}
|
||||
strcpy(h->DisplayName, name);
|
||||
|
||||
h->Dpy = dpy;
|
||||
h->Win = win;
|
||||
h->Context = ctx;
|
||||
h->Angle = 0.0;
|
||||
strcpy(h->Version, (char *) glGetString(GL_VERSION));
|
||||
strcpy(h->Vendor, (char *) glGetString(GL_VENDOR));
|
||||
strcpy(h->Renderer, (char *) glGetString(GL_RENDERER));
|
||||
|
||||
tmp = (char *) glGetString(GL_VERSION);
|
||||
if (strlen(tmp) + 1 > sizeof(h->Version)) {
|
||||
Error(displayName, "GL_VERSION string overflow");
|
||||
return NULL;
|
||||
}
|
||||
strcpy(h->Version, tmp);
|
||||
|
||||
tmp = (char *) glGetString(GL_VENDOR);
|
||||
if (strlen(tmp) + 1 > sizeof(h->Vendor)) {
|
||||
Error(displayName, "GL_VENDOR string overflow");
|
||||
return NULL;
|
||||
}
|
||||
strcpy(h->Vendor, tmp);
|
||||
|
||||
tmp = (char *) glGetString(GL_RENDERER);
|
||||
if (strlen(tmp) + 1 > sizeof(h->Renderer)) {
|
||||
Error(displayName, "GL_RENDERER string overflow");
|
||||
return NULL;
|
||||
}
|
||||
strcpy(h->Renderer, tmp);
|
||||
|
||||
NumHeads++;
|
||||
return &Heads[NumHeads-1];
|
||||
}
|
||||
|
|
@ -374,6 +400,8 @@ main(int argc, char *argv[])
|
|||
}
|
||||
if (n < 1)
|
||||
n = 1;
|
||||
if (n > MAX_HEADS)
|
||||
n = MAX_HEADS;
|
||||
|
||||
printf("%d windows\n", n);
|
||||
for (i = 0; i < n; i++) {
|
||||
|
|
|
|||
202
progs/xdemos/msctest.c
Normal file
202
progs/xdemos/msctest.c
Normal file
|
|
@ -0,0 +1,202 @@
|
|||
/*
|
||||
* Copyright © 2009 Intel Corporation
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*
|
||||
* Authors:
|
||||
* Jesse Barnes <jesse.barnes@intel.com>
|
||||
*
|
||||
*/
|
||||
|
||||
/** @file msctest.c
|
||||
* Simple test for MSC functionality.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glu.h>
|
||||
#include <GL/glx.h>
|
||||
#include <GL/glxext.h>
|
||||
#include <X11/X.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
void (*get_sync_values)(Display *dpy, Window winGL, int64_t *ust, int64_t *msc, int64_t *sbc);
|
||||
void (*wait_sync)(Display *dpy, Window winGL, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t *ust, int64_t *msc, int64_t *sbc);
|
||||
|
||||
static int GLXExtensionSupported(Display *dpy, const char *extension)
|
||||
{
|
||||
const char *extensionsString, *client_extensions, *pos;
|
||||
|
||||
extensionsString = glXQueryExtensionsString(dpy, DefaultScreen(dpy));
|
||||
client_extensions = glXGetClientString(dpy, GLX_EXTENSIONS);
|
||||
|
||||
pos = strstr(extensionsString, extension);
|
||||
|
||||
if (pos != NULL && (pos == extensionsString || pos[-1] == ' ') &&
|
||||
(pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0'))
|
||||
return 1;
|
||||
|
||||
pos = strstr(client_extensions, extension);
|
||||
|
||||
if (pos != NULL && (pos == extensionsString || pos[-1] == ' ') &&
|
||||
(pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0'))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern char *optarg;
|
||||
extern int optind, opterr, optopt;
|
||||
static char optstr[] = "v";
|
||||
|
||||
static void usage(char *name)
|
||||
{
|
||||
printf("usage: %s\n", name);
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Display *disp;
|
||||
XVisualInfo *pvi;
|
||||
XSetWindowAttributes swa;
|
||||
int attrib[14];
|
||||
Window winGL;
|
||||
GLXContext context;
|
||||
int dummy;
|
||||
Atom wmDelete;
|
||||
int verbose = 0, width = 200, height = 200;
|
||||
int c, i = 1;
|
||||
int64_t ust, msc, sbc;
|
||||
|
||||
opterr = 0;
|
||||
while ((c = getopt(argc, argv, optstr)) != -1) {
|
||||
switch (c) {
|
||||
case 'v':
|
||||
verbose = 1;
|
||||
break;
|
||||
default:
|
||||
usage(argv[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
disp = XOpenDisplay(NULL);
|
||||
if (!disp) {
|
||||
fprintf(stderr, "failed to open display\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!glXQueryExtension(disp, &dummy, &dummy)) {
|
||||
fprintf(stderr, "glXQueryExtension failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!GLXExtensionSupported(disp, "GLX_OML_sync_control")) {
|
||||
fprintf(stderr, "GLX_OML_sync_control not supported, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
attrib[0] = GLX_RGBA;
|
||||
attrib[1] = 1;
|
||||
attrib[2] = GLX_RED_SIZE;
|
||||
attrib[3] = 1;
|
||||
attrib[4] = GLX_GREEN_SIZE;
|
||||
attrib[5] = 1;
|
||||
attrib[6] = GLX_BLUE_SIZE;
|
||||
attrib[7] = 1;
|
||||
attrib[8] = GLX_DOUBLEBUFFER;
|
||||
attrib[9] = 1;
|
||||
attrib[10] = None;
|
||||
|
||||
pvi = glXChooseVisual(disp, DefaultScreen(disp), attrib);
|
||||
if (!pvi) {
|
||||
fprintf(stderr, "failed to choose visual, exiting\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
context = glXCreateContext(disp, pvi, None, GL_TRUE);
|
||||
if (!context) {
|
||||
fprintf(stderr, "failed to create glx context\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
pvi->screen = DefaultScreen(disp);
|
||||
|
||||
swa.colormap = XCreateColormap(disp, RootWindow(disp, pvi->screen),
|
||||
pvi->visual, AllocNone);
|
||||
swa.border_pixel = 0;
|
||||
swa.event_mask = ExposureMask | KeyPressMask | ButtonPressMask |
|
||||
StructureNotifyMask;
|
||||
winGL = XCreateWindow(disp, RootWindow(disp, pvi->screen),
|
||||
0, 0,
|
||||
width, height,
|
||||
0, pvi->depth, InputOutput, pvi->visual,
|
||||
CWBorderPixel | CWColormap | CWEventMask, &swa);
|
||||
if (!winGL) {
|
||||
fprintf(stderr, "window creation failed\n");
|
||||
return -1;
|
||||
}
|
||||
wmDelete = XInternAtom(disp, "WM_DELETE_WINDOW", True);
|
||||
XSetWMProtocols(disp, winGL, &wmDelete, 1);
|
||||
|
||||
XSetStandardProperties(disp, winGL, "msc test", "msc text",
|
||||
None, NULL, 0, NULL);
|
||||
|
||||
XMapRaised(disp, winGL);
|
||||
|
||||
glXMakeCurrent(disp, winGL, context);
|
||||
|
||||
get_sync_values = glXGetProcAddress((unsigned char *)"glXGetSyncValuesOML");
|
||||
wait_sync = glXGetProcAddress((unsigned char *)"glXWaitForMscOML");
|
||||
|
||||
if (!get_sync_values || !wait_sync) {
|
||||
fprintf(stderr, "failed to get sync values function\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (i++) {
|
||||
get_sync_values(disp, winGL, &ust, &msc, &sbc);
|
||||
fprintf(stderr, "ust: %llu, msc: %llu, sbc: %llu\n", ust, msc,
|
||||
sbc);
|
||||
|
||||
/* Alternate colors to make tearing obvious */
|
||||
if (i & 1)
|
||||
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
else
|
||||
glClearColor(1.0f, 0.0f, 0.0f, 0.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glXSwapBuffers(disp, winGL);
|
||||
wait_sync(disp, winGL, 0, 60, 0, &ust, &msc, &sbc);
|
||||
fprintf(stderr,
|
||||
"wait returned ust: %llu, msc: %llu, sbc: %llu\n",
|
||||
ust, msc, sbc);
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
XDestroyWindow(disp, winGL);
|
||||
glXDestroyContext(disp, context);
|
||||
XCloseDisplay(disp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -174,6 +174,10 @@ AddWindow(Display *dpy, const char *displayName, int xpos, int ypos,
|
|||
{
|
||||
static int id = 0;
|
||||
struct window *h = &Windows[NumWindows];
|
||||
if (strlen(displayName) + 1 > sizeof(h->DisplayName)) {
|
||||
Error(displayName, "string overflow");
|
||||
return NULL;
|
||||
}
|
||||
strcpy(h->DisplayName, displayName);
|
||||
h->Dpy = dpy;
|
||||
h->Win = win;
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ def generate(env):
|
|||
env.AppendUnique(CPPDEFINES = [
|
||||
'__STDC_LIMIT_MACROS',
|
||||
'__STDC_CONSTANT_MACROS',
|
||||
'HAVE_STDINT_H',
|
||||
])
|
||||
env.Prepend(LIBPATH = [os.path.join(llvm_dir, 'lib')])
|
||||
env.Prepend(LIBS = [
|
||||
|
|
@ -98,6 +99,16 @@ def generate(env):
|
|||
'imagehlp',
|
||||
'psapi',
|
||||
])
|
||||
if env['msvc']:
|
||||
# Some of the LLVM C headers use the inline keyword without
|
||||
# defining it.
|
||||
env.Append(CPPDEFINES = [('inline', '__inline')])
|
||||
if env['debug']:
|
||||
# LLVM libraries are static, build with /MT, and they
|
||||
# automatically link agains LIBCMT. When we're doing a
|
||||
# debug build we'll be linking against LIBCMTD, so disable
|
||||
# that.
|
||||
env.Append(LINKFLAGS = ['/nodefaultlib:LIBCMT'])
|
||||
env['LLVM_VERSION'] = '2.6'
|
||||
return
|
||||
elif env.Detect('llvm-config'):
|
||||
|
|
|
|||
|
|
@ -899,7 +899,7 @@ GLX_eglSwapBuffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
|
|||
* Called from eglGetProcAddress() via drv->API.GetProcAddress().
|
||||
*/
|
||||
static _EGLProc
|
||||
GLX_eglGetProcAddress(const char *procname)
|
||||
GLX_eglGetProcAddress(_EGLDriver *drv, const char *procname)
|
||||
{
|
||||
return (_EGLProc) glXGetProcAddress((const GLubyte *) procname);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -355,7 +355,7 @@ xdri_eglTerminate(_EGLDriver *drv, _EGLDisplay *dpy)
|
|||
* Called from eglGetProcAddress() via drv->API.GetProcAddress().
|
||||
*/
|
||||
static _EGLProc
|
||||
xdri_eglGetProcAddress(const char *procname)
|
||||
xdri_eglGetProcAddress(_EGLDriver *drv, const char *procname)
|
||||
{
|
||||
/* the symbol is defined in libGL.so */
|
||||
return (_EGLProc) _glapi_get_proc_address(procname);
|
||||
|
|
@ -562,7 +562,7 @@ xdri_eglSwapBuffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *draw)
|
|||
struct xdri_egl_display *xdri_dpy = lookup_display(dpy);
|
||||
struct xdri_egl_surface *xdri_surf = lookup_surface(draw);
|
||||
|
||||
xdri_dpy->psc->driScreen->swapBuffers(xdri_surf->driDrawable);
|
||||
xdri_dpy->psc->driScreen->swapBuffers(xdri_surf->driDrawable, 0, 0, 0);
|
||||
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,10 @@ TOP = ../../..
|
|||
include $(TOP)/configs/current
|
||||
|
||||
|
||||
INCLUDE_DIRS = -I$(TOP)/include -I$(TOP)/src/mesa/glapi $(X11_INCLUDES)
|
||||
EGL_MAJOR = 1
|
||||
EGL_MINOR = 0
|
||||
|
||||
INCLUDE_DIRS = -I$(TOP)/include
|
||||
|
||||
HEADERS = \
|
||||
eglcompiler.h \
|
||||
|
|
@ -43,7 +46,7 @@ SOURCES = \
|
|||
OBJECTS = $(SOURCES:.c=.o)
|
||||
|
||||
|
||||
# Undefined for now
|
||||
# use dl*() to load drivers
|
||||
LOCAL_CFLAGS = -D_EGL_PLATFORM_X=1
|
||||
|
||||
|
||||
|
|
@ -56,21 +59,21 @@ default: depend library
|
|||
|
||||
|
||||
# EGL Library
|
||||
library: $(TOP)/$(LIB_DIR)/libEGL.so
|
||||
library: $(TOP)/$(LIB_DIR)/$(EGL_LIB_NAME)
|
||||
|
||||
$(TOP)/$(LIB_DIR)/libEGL.so: $(OBJECTS)
|
||||
$(MKLIB) -o EGL -linker '$(CC)' -ldflags '$(LDFLAGS)' \
|
||||
-major 1 -minor 0 \
|
||||
-install $(TOP)/$(LIB_DIR) \
|
||||
$(TOP)/$(LIB_DIR)/$(EGL_LIB_NAME): $(OBJECTS)
|
||||
$(MKLIB) -o $(EGL_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
|
||||
-major $(EGL_MAJOR) -minor $(EGL_MINOR) \
|
||||
-install $(TOP)/$(LIB_DIR) $(MKLIB_OPTIONS) \
|
||||
$(EGL_LIB_DEPS) $(OBJECTS)
|
||||
|
||||
install: default
|
||||
$(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
|
||||
$(MINSTALL) $(TOP)/$(LIB_DIR)/libEGL.so* $(DESTDIR)$(INSTALL_LIB_DIR)
|
||||
$(MINSTALL) $(TOP)/$(LIB_DIR)/$(EGL_LIB_GLOB) \
|
||||
$(DESTDIR)$(INSTALL_LIB_DIR)
|
||||
|
||||
clean:
|
||||
-rm -f *.o *.so*
|
||||
-rm -f core.*
|
||||
-rm -f *.o
|
||||
-rm -f depend depend.bak
|
||||
|
||||
|
||||
|
|
@ -82,5 +85,5 @@ depend: $(SOURCES) $(HEADERS)
|
|||
$(SOURCES) $(HEADERS) > /dev/null 2>/dev/null
|
||||
|
||||
|
||||
include depend
|
||||
-include depend
|
||||
# DO NOT DELETE
|
||||
|
|
|
|||
|
|
@ -716,7 +716,8 @@ void (* EGLAPIENTRY eglGetProcAddress(const char *procname))()
|
|||
|
||||
/* now loop over drivers to query their procs */
|
||||
for (i = 0; i < _eglGlobal.NumDrivers; i++) {
|
||||
_EGLProc p = _eglGlobal.Drivers[i]->API.GetProcAddress(procname);
|
||||
_EGLDriver *drv = _eglGlobal.Drivers[i];
|
||||
_EGLProc p = drv->API.GetProcAddress(drv, procname);
|
||||
if (p)
|
||||
return p;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ typedef const char *(*QueryString_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLint n
|
|||
typedef EGLBoolean (*WaitClient_t)(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx);
|
||||
typedef EGLBoolean (*WaitNative_t)(_EGLDriver *drv, _EGLDisplay *dpy, EGLint engine);
|
||||
|
||||
typedef _EGLProc (*GetProcAddress_t)(const char *procname);
|
||||
typedef _EGLProc (*GetProcAddress_t)(_EGLDriver *drv, const char *procname);
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -324,6 +324,7 @@ _eglValidateConfig(const _EGLConfig *conf, EGLBoolean for_matching)
|
|||
mask = EGL_PBUFFER_BIT |
|
||||
EGL_PIXMAP_BIT |
|
||||
EGL_WINDOW_BIT |
|
||||
EGL_SCREEN_BIT_MESA | /* XXX should check the extension */
|
||||
EGL_VG_COLORSPACE_LINEAR_BIT |
|
||||
EGL_VG_ALPHA_FORMAT_PRE_BIT |
|
||||
EGL_MULTISAMPLE_RESOLVE_BOX_BIT |
|
||||
|
|
|
|||
|
|
@ -111,6 +111,7 @@ C_SOURCES = \
|
|||
util/u_math.c \
|
||||
util/u_mm.c \
|
||||
util/u_rect.c \
|
||||
util/u_ringbuffer.c \
|
||||
util/u_simple_shaders.c \
|
||||
util/u_snprintf.c \
|
||||
util/u_stream_stdc.c \
|
||||
|
|
|
|||
|
|
@ -147,6 +147,7 @@ source = [
|
|||
'util/u_math.c',
|
||||
'util/u_mm.c',
|
||||
'util/u_rect.c',
|
||||
'util/u_ringbuffer.c',
|
||||
'util/u_simple_shaders.c',
|
||||
'util/u_snprintf.c',
|
||||
'util/u_stream_stdc.c',
|
||||
|
|
|
|||
|
|
@ -95,6 +95,7 @@ void draw_destroy( struct draw_context *draw )
|
|||
draw_pipeline_destroy( draw );
|
||||
draw_pt_destroy( draw );
|
||||
draw_vs_destroy( draw );
|
||||
draw_gs_destroy( draw );
|
||||
|
||||
FREE( draw );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -164,6 +164,14 @@ void draw_set_mapped_constant_buffer(struct draw_context *draw,
|
|||
void draw_arrays(struct draw_context *draw, unsigned prim,
|
||||
unsigned start, unsigned count);
|
||||
|
||||
void
|
||||
draw_arrays_instanced(struct draw_context *draw,
|
||||
unsigned mode,
|
||||
unsigned start,
|
||||
unsigned count,
|
||||
unsigned startInstance,
|
||||
unsigned instanceCount);
|
||||
|
||||
void draw_flush(struct draw_context *draw);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -59,6 +59,15 @@ draw_gs_init( struct draw_context *draw )
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
void draw_gs_destroy( struct draw_context *draw )
|
||||
{
|
||||
if (!draw->gs.machine)
|
||||
return;
|
||||
|
||||
align_free(draw->gs.machine->Primitives);
|
||||
|
||||
tgsi_exec_machine_destroy(draw->gs.machine);
|
||||
}
|
||||
|
||||
void draw_gs_set_constants( struct draw_context *draw,
|
||||
const float (*constants)[4],
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@
|
|||
|
||||
|
||||
|
||||
struct clipper {
|
||||
struct clip_stage {
|
||||
struct draw_stage stage; /**< base class */
|
||||
|
||||
/* Basically duplicate some of the flatshading logic here:
|
||||
|
|
@ -70,9 +70,9 @@ struct clipper {
|
|||
|
||||
/* This is a bit confusing:
|
||||
*/
|
||||
static INLINE struct clipper *clipper_stage( struct draw_stage *stage )
|
||||
static INLINE struct clip_stage *clip_stage( struct draw_stage *stage )
|
||||
{
|
||||
return (struct clipper *)stage;
|
||||
return (struct clip_stage *)stage;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -92,11 +92,12 @@ static void interp_attr( float *fdst,
|
|||
fdst[3] = LINTERP( t, fout[3], fin[3] );
|
||||
}
|
||||
|
||||
|
||||
static void copy_colors( struct draw_stage *stage,
|
||||
struct vertex_header *dst,
|
||||
const struct vertex_header *src )
|
||||
{
|
||||
const struct clipper *clipper = clipper_stage(stage);
|
||||
const struct clip_stage *clipper = clip_stage(stage);
|
||||
uint i;
|
||||
for (i = 0; i < clipper->num_color_attribs; i++) {
|
||||
const uint attr = clipper->color_attribs[i];
|
||||
|
|
@ -108,7 +109,7 @@ static void copy_colors( struct draw_stage *stage,
|
|||
|
||||
/* Interpolate between two vertices to produce a third.
|
||||
*/
|
||||
static void interp( const struct clipper *clip,
|
||||
static void interp( const struct clip_stage *clip,
|
||||
struct vertex_header *dst,
|
||||
float t,
|
||||
const struct vertex_header *out,
|
||||
|
|
@ -179,7 +180,7 @@ static void emit_poly( struct draw_stage *stage,
|
|||
header.v[2] = inlist[0]; /* keep in v[2] for flatshading */
|
||||
|
||||
if (i == n-1)
|
||||
header.flags |= edge_last;
|
||||
header.flags |= edge_last;
|
||||
|
||||
if (0) {
|
||||
const struct draw_vertex_shader *vs = stage->draw->vs.vertex_shader;
|
||||
|
|
@ -200,13 +201,14 @@ static void emit_poly( struct draw_stage *stage,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
static INLINE float
|
||||
dot4(const float *a, const float *b)
|
||||
{
|
||||
return (a[0]*b[0] +
|
||||
a[1]*b[1] +
|
||||
a[2]*b[2] +
|
||||
a[3]*b[3]);
|
||||
return (a[0] * b[0] +
|
||||
a[1] * b[1] +
|
||||
a[2] * b[2] +
|
||||
a[3] * b[3]);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -217,7 +219,7 @@ do_clip_tri( struct draw_stage *stage,
|
|||
struct prim_header *header,
|
||||
unsigned clipmask )
|
||||
{
|
||||
struct clipper *clipper = clipper_stage( stage );
|
||||
struct clip_stage *clipper = clip_stage( stage );
|
||||
struct vertex_header *a[MAX_CLIPPED_VERTICES];
|
||||
struct vertex_header *b[MAX_CLIPPED_VERTICES];
|
||||
struct vertex_header **inlist = a;
|
||||
|
|
@ -280,6 +282,7 @@ do_clip_tri( struct draw_stage *stage,
|
|||
dp_prev = dp;
|
||||
}
|
||||
|
||||
/* swap in/out lists */
|
||||
{
|
||||
struct vertex_header **tmp = inlist;
|
||||
inlist = outlist;
|
||||
|
|
@ -291,15 +294,11 @@ do_clip_tri( struct draw_stage *stage,
|
|||
/* If flat-shading, copy color to new provoking vertex.
|
||||
*/
|
||||
if (clipper->flat && inlist[0] != header->v[2]) {
|
||||
if (1) {
|
||||
inlist[0] = dup_vert(stage, inlist[0], tmpnr++);
|
||||
}
|
||||
inlist[0] = dup_vert(stage, inlist[0], tmpnr++);
|
||||
|
||||
copy_colors(stage, inlist[0], header->v[2]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Emit the polygon as triangles to the setup stage:
|
||||
*/
|
||||
if (n >= 3)
|
||||
|
|
@ -314,7 +313,7 @@ do_clip_line( struct draw_stage *stage,
|
|||
struct prim_header *header,
|
||||
unsigned clipmask )
|
||||
{
|
||||
const struct clipper *clipper = clipper_stage( stage );
|
||||
const struct clip_stage *clipper = clip_stage( stage );
|
||||
struct vertex_header *v0 = header->v[0];
|
||||
struct vertex_header *v1 = header->v[1];
|
||||
const float *pos0 = v0->clip;
|
||||
|
|
@ -416,13 +415,14 @@ clip_tri( struct draw_stage *stage,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/* Update state. Could further delay this until we hit the first
|
||||
* primitive that really requires clipping.
|
||||
*/
|
||||
static void
|
||||
clip_init_state( struct draw_stage *stage )
|
||||
{
|
||||
struct clipper *clipper = clipper_stage( stage );
|
||||
struct clip_stage *clipper = clip_stage( stage );
|
||||
|
||||
clipper->flat = stage->draw->rasterizer->flatshade ? TRUE : FALSE;
|
||||
|
||||
|
|
@ -488,7 +488,7 @@ static void clip_destroy( struct draw_stage *stage )
|
|||
*/
|
||||
struct draw_stage *draw_clip_stage( struct draw_context *draw )
|
||||
{
|
||||
struct clipper *clipper = CALLOC_STRUCT(clipper);
|
||||
struct clip_stage *clipper = CALLOC_STRUCT(clip_stage);
|
||||
if (clipper == NULL)
|
||||
goto fail;
|
||||
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ emit_vertex( struct vbuf_stage *vbuf,
|
|||
/* Note: we really do want data[0] here, not data[pos]:
|
||||
*/
|
||||
vbuf->translate->set_buffer(vbuf->translate, 0, vertex->data[0], 0);
|
||||
vbuf->translate->run(vbuf->translate, 0, 1, vbuf->vertex_ptr);
|
||||
vbuf->translate->run(vbuf->translate, 0, 1, 0, vbuf->vertex_ptr);
|
||||
|
||||
if (0) draw_dump_emitted_vertex(vbuf->vinfo, (uint8_t *)vbuf->vertex_ptr);
|
||||
|
||||
|
|
@ -271,10 +271,12 @@ vbuf_start_prim( struct vbuf_stage *vbuf, uint prim )
|
|||
emit_sz = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
hw_key.element[i].type = TRANSLATE_ELEMENT_NORMAL;
|
||||
hw_key.element[i].input_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
|
||||
hw_key.element[i].input_buffer = src_buffer;
|
||||
hw_key.element[i].input_offset = src_offset;
|
||||
hw_key.element[i].instance_divisor = 0;
|
||||
hw_key.element[i].output_format = output_format;
|
||||
hw_key.element[i].output_offset = dst_offset;
|
||||
|
||||
|
|
|
|||
|
|
@ -172,6 +172,8 @@ struct draw_context
|
|||
|
||||
boolean force_passthrough; /**< never clip or shade */
|
||||
|
||||
boolean dump_vs;
|
||||
|
||||
double mrd; /**< minimum resolvable depth value, for polygon offset */
|
||||
|
||||
/* pipe state that we need: */
|
||||
|
|
@ -239,6 +241,8 @@ struct draw_context
|
|||
|
||||
unsigned reduced_prim;
|
||||
|
||||
unsigned instance_id;
|
||||
|
||||
void *driver_private;
|
||||
};
|
||||
|
||||
|
|
@ -265,6 +269,7 @@ boolean draw_gs_init( struct draw_context *draw );
|
|||
void draw_gs_set_constants( struct draw_context *,
|
||||
const float (*constants)[4],
|
||||
unsigned size );
|
||||
void draw_gs_destroy( struct draw_context *draw );
|
||||
|
||||
/*******************************************************************************
|
||||
* Common shading code:
|
||||
|
|
|
|||
|
|
@ -280,20 +280,33 @@ void
|
|||
draw_arrays(struct draw_context *draw, unsigned prim,
|
||||
unsigned start, unsigned count)
|
||||
{
|
||||
unsigned reduced_prim = u_reduced_prim(prim);
|
||||
draw_arrays_instanced(draw, prim, start, count, 0, 1);
|
||||
}
|
||||
|
||||
void
|
||||
draw_arrays_instanced(struct draw_context *draw,
|
||||
unsigned mode,
|
||||
unsigned start,
|
||||
unsigned count,
|
||||
unsigned startInstance,
|
||||
unsigned instanceCount)
|
||||
{
|
||||
unsigned reduced_prim = u_reduced_prim(mode);
|
||||
unsigned instance;
|
||||
|
||||
if (reduced_prim != draw->reduced_prim) {
|
||||
draw_do_flush( draw, DRAW_FLUSH_STATE_CHANGE );
|
||||
draw_do_flush(draw, DRAW_FLUSH_STATE_CHANGE);
|
||||
draw->reduced_prim = reduced_prim;
|
||||
}
|
||||
|
||||
if (0)
|
||||
draw_print_arrays(draw, prim, start, MIN2(count, 20));
|
||||
draw_print_arrays(draw, mode, start, MIN2(count, 20));
|
||||
|
||||
#if 0
|
||||
{
|
||||
int i;
|
||||
debug_printf("draw_arrays(prim=%u start=%u count=%u):\n",
|
||||
prim, start, count);
|
||||
debug_printf("draw_arrays(mode=%u start=%u count=%u):\n",
|
||||
mode, start, count);
|
||||
tgsi_dump(draw->vs.vertex_shader->state.tokens, 0);
|
||||
debug_printf("Elements:\n");
|
||||
for (i = 0; i < draw->pt.nr_vertex_elements; i++) {
|
||||
|
|
@ -311,6 +324,8 @@ draw_arrays(struct draw_context *draw, unsigned prim,
|
|||
}
|
||||
#endif
|
||||
|
||||
/* drawing done here: */
|
||||
draw_pt_arrays(draw, prim, start, count);
|
||||
for (instance = 0; instance < instanceCount; instance++) {
|
||||
draw->instance_id = instance + startInstance;
|
||||
draw_pt_arrays(draw, mode, start, count);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -183,7 +183,8 @@ struct pt_emit *draw_pt_emit_create( struct draw_context *draw );
|
|||
struct pt_fetch;
|
||||
void draw_pt_fetch_prepare( struct pt_fetch *fetch,
|
||||
unsigned vertex_input_count,
|
||||
unsigned vertex_size );
|
||||
unsigned vertex_size,
|
||||
unsigned instance_id_index );
|
||||
|
||||
void draw_pt_fetch_run( struct pt_fetch *fetch,
|
||||
const unsigned *elts,
|
||||
|
|
|
|||
|
|
@ -121,10 +121,12 @@ void draw_pt_emit_prepare( struct pt_emit *emit,
|
|||
emit_sz = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
hw_key.element[i].type = TRANSLATE_ELEMENT_NORMAL;
|
||||
hw_key.element[i].input_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
|
||||
hw_key.element[i].input_buffer = src_buffer;
|
||||
hw_key.element[i].input_offset = src_offset;
|
||||
hw_key.element[i].instance_divisor = 0;
|
||||
hw_key.element[i].output_format = output_format;
|
||||
hw_key.element[i].output_offset = dst_offset;
|
||||
|
||||
|
|
@ -204,6 +206,7 @@ void draw_pt_emit( struct pt_emit *emit,
|
|||
translate->run( translate,
|
||||
0,
|
||||
vertex_count,
|
||||
draw->instance_id,
|
||||
hw_verts );
|
||||
|
||||
render->unmap_vertices( render,
|
||||
|
|
@ -263,6 +266,7 @@ void draw_pt_emit_linear(struct pt_emit *emit,
|
|||
translate->run(translate,
|
||||
0,
|
||||
count,
|
||||
draw->instance_id,
|
||||
hw_verts);
|
||||
|
||||
if (0) {
|
||||
|
|
|
|||
|
|
@ -58,12 +58,14 @@ struct pt_fetch {
|
|||
*/
|
||||
void draw_pt_fetch_prepare( struct pt_fetch *fetch,
|
||||
unsigned vs_input_count,
|
||||
unsigned vertex_size )
|
||||
unsigned vertex_size,
|
||||
unsigned instance_id_index )
|
||||
{
|
||||
struct draw_context *draw = fetch->draw;
|
||||
unsigned nr_inputs;
|
||||
unsigned i, nr = 0;
|
||||
unsigned i, nr = 0, ei = 0;
|
||||
unsigned dst_offset = 0;
|
||||
unsigned num_extra_inputs = 0;
|
||||
struct translate_key key;
|
||||
|
||||
fetch->vertex_size = vertex_size;
|
||||
|
|
@ -78,9 +80,11 @@ void draw_pt_fetch_prepare( struct pt_fetch *fetch,
|
|||
{
|
||||
/* Need to set header->vertex_id = 0xffff somehow.
|
||||
*/
|
||||
key.element[nr].type = TRANSLATE_ELEMENT_NORMAL;
|
||||
key.element[nr].input_format = PIPE_FORMAT_R32_FLOAT;
|
||||
key.element[nr].input_buffer = draw->pt.nr_vertex_buffers;
|
||||
key.element[nr].input_offset = 0;
|
||||
key.element[nr].instance_divisor = 0;
|
||||
key.element[nr].output_format = PIPE_FORMAT_R32_FLOAT;
|
||||
key.element[nr].output_offset = dst_offset;
|
||||
dst_offset += 1 * sizeof(float);
|
||||
|
|
@ -91,19 +95,36 @@ void draw_pt_fetch_prepare( struct pt_fetch *fetch,
|
|||
*/
|
||||
dst_offset += 4 * sizeof(float);
|
||||
}
|
||||
|
||||
assert( draw->pt.nr_vertex_elements >= vs_input_count );
|
||||
|
||||
nr_inputs = MIN2( vs_input_count, draw->pt.nr_vertex_elements );
|
||||
if (instance_id_index != ~0) {
|
||||
num_extra_inputs++;
|
||||
}
|
||||
|
||||
assert(draw->pt.nr_vertex_elements + num_extra_inputs >= vs_input_count);
|
||||
|
||||
nr_inputs = MIN2(vs_input_count, draw->pt.nr_vertex_elements + num_extra_inputs);
|
||||
|
||||
for (i = 0; i < nr_inputs; i++) {
|
||||
key.element[nr].input_format = draw->pt.vertex_element[i].src_format;
|
||||
key.element[nr].input_buffer = draw->pt.vertex_element[i].vertex_buffer_index;
|
||||
key.element[nr].input_offset = draw->pt.vertex_element[i].src_offset;
|
||||
key.element[nr].output_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
|
||||
key.element[nr].output_offset = dst_offset;
|
||||
if (i == instance_id_index) {
|
||||
key.element[nr].type = TRANSLATE_ELEMENT_INSTANCE_ID;
|
||||
key.element[nr].input_format = PIPE_FORMAT_R32_USCALED;
|
||||
key.element[nr].output_format = PIPE_FORMAT_R32_USCALED;
|
||||
key.element[nr].output_offset = dst_offset;
|
||||
|
||||
dst_offset += sizeof(uint);
|
||||
} else {
|
||||
key.element[nr].type = TRANSLATE_ELEMENT_NORMAL;
|
||||
key.element[nr].input_format = draw->pt.vertex_element[ei].src_format;
|
||||
key.element[nr].input_buffer = draw->pt.vertex_element[ei].vertex_buffer_index;
|
||||
key.element[nr].input_offset = draw->pt.vertex_element[ei].src_offset;
|
||||
key.element[nr].instance_divisor = draw->pt.vertex_element[ei].instance_divisor;
|
||||
key.element[nr].output_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
|
||||
key.element[nr].output_offset = dst_offset;
|
||||
|
||||
ei++;
|
||||
dst_offset += 4 * sizeof(float);
|
||||
}
|
||||
|
||||
dst_offset += 4 * sizeof(float);
|
||||
nr++;
|
||||
}
|
||||
|
||||
|
|
@ -158,6 +179,7 @@ void draw_pt_fetch_run( struct pt_fetch *fetch,
|
|||
translate->run_elts( translate,
|
||||
elts,
|
||||
count,
|
||||
draw->instance_id,
|
||||
verts );
|
||||
|
||||
}
|
||||
|
|
@ -183,6 +205,7 @@ void draw_pt_fetch_run_linear( struct pt_fetch *fetch,
|
|||
translate->run( translate,
|
||||
start,
|
||||
count,
|
||||
draw->instance_id,
|
||||
verts );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -166,9 +166,11 @@ static void fetch_emit_prepare( struct draw_pt_middle_end *middle,
|
|||
continue;
|
||||
}
|
||||
|
||||
key.element[i].type = TRANSLATE_ELEMENT_NORMAL;
|
||||
key.element[i].input_format = input_format;
|
||||
key.element[i].input_buffer = input_buffer;
|
||||
key.element[i].input_offset = input_offset;
|
||||
key.element[i].instance_divisor = src->instance_divisor;
|
||||
key.element[i].output_format = output_format;
|
||||
key.element[i].output_offset = dst_offset;
|
||||
|
||||
|
|
@ -256,6 +258,7 @@ static void fetch_emit_run( struct draw_pt_middle_end *middle,
|
|||
feme->translate->run_elts( feme->translate,
|
||||
fetch_elts,
|
||||
fetch_count,
|
||||
draw->instance_id,
|
||||
hw_verts );
|
||||
|
||||
if (0) {
|
||||
|
|
@ -314,6 +317,7 @@ static void fetch_emit_run_linear( struct draw_pt_middle_end *middle,
|
|||
feme->translate->run( feme->translate,
|
||||
start,
|
||||
count,
|
||||
draw->instance_id,
|
||||
hw_verts );
|
||||
|
||||
if (0) {
|
||||
|
|
@ -374,6 +378,7 @@ static boolean fetch_emit_run_linear_elts( struct draw_pt_middle_end *middle,
|
|||
feme->translate->run( feme->translate,
|
||||
start,
|
||||
count,
|
||||
draw->instance_id,
|
||||
hw_verts );
|
||||
|
||||
draw->render->unmap_vertices( draw->render, 0, (ushort)(count - 1) );
|
||||
|
|
|
|||
|
|
@ -59,6 +59,8 @@ static void fetch_pipeline_prepare( struct draw_pt_middle_end *middle,
|
|||
struct fetch_pipeline_middle_end *fpme = (struct fetch_pipeline_middle_end *)middle;
|
||||
struct draw_context *draw = fpme->draw;
|
||||
struct draw_vertex_shader *vs = draw->vs.vertex_shader;
|
||||
unsigned i;
|
||||
unsigned instance_id_index = ~0;
|
||||
|
||||
/* Add one to num_outputs because the pipeline occasionally tags on
|
||||
* an additional texcoord, eg for AA lines.
|
||||
|
|
@ -66,6 +68,15 @@ static void fetch_pipeline_prepare( struct draw_pt_middle_end *middle,
|
|||
unsigned nr = MAX2( vs->info.num_inputs,
|
||||
vs->info.num_outputs + 1 );
|
||||
|
||||
/* Scan for instanceID system value.
|
||||
*/
|
||||
for (i = 0; i < vs->info.num_inputs; i++) {
|
||||
if (vs->info.input_semantic_name[i] == TGSI_SEMANTIC_INSTANCEID) {
|
||||
instance_id_index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fpme->prim = prim;
|
||||
fpme->opt = opt;
|
||||
|
||||
|
|
@ -79,7 +90,8 @@ static void fetch_pipeline_prepare( struct draw_pt_middle_end *middle,
|
|||
|
||||
draw_pt_fetch_prepare( fpme->fetch,
|
||||
vs->info.num_inputs,
|
||||
fpme->vertex_size );
|
||||
fpme->vertex_size,
|
||||
instance_id_index );
|
||||
/* XXX: it's not really gl rasterization rules we care about here,
|
||||
* but gl vs dx9 clip spaces.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -43,11 +43,11 @@
|
|||
#include "translate/translate.h"
|
||||
#include "translate/translate_cache.h"
|
||||
|
||||
#include "tgsi/tgsi_dump.h"
|
||||
#include "tgsi/tgsi_exec.h"
|
||||
|
||||
|
||||
|
||||
|
||||
void draw_vs_set_constants( struct draw_context *draw,
|
||||
const float (*constants)[4],
|
||||
unsigned size )
|
||||
|
|
@ -83,6 +83,10 @@ draw_create_vertex_shader(struct draw_context *draw,
|
|||
{
|
||||
struct draw_vertex_shader *vs;
|
||||
|
||||
if (draw->dump_vs) {
|
||||
tgsi_dump(shader->tokens, 0);
|
||||
}
|
||||
|
||||
vs = draw_create_vs_llvm( draw, shader );
|
||||
if (!vs) {
|
||||
vs = draw_create_vs_sse( draw, shader );
|
||||
|
|
@ -152,6 +156,8 @@ draw_delete_vertex_shader(struct draw_context *draw,
|
|||
boolean
|
||||
draw_vs_init( struct draw_context *draw )
|
||||
{
|
||||
draw->dump_vs = debug_get_bool_option("GALLIUM_DUMP_VS", FALSE);
|
||||
|
||||
draw->vs.machine = tgsi_exec_machine_create();
|
||||
if (!draw->vs.machine)
|
||||
return FALSE;
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ struct draw_varient_input
|
|||
enum pipe_format format;
|
||||
unsigned buffer;
|
||||
unsigned offset;
|
||||
unsigned instance_divisor;
|
||||
};
|
||||
|
||||
struct draw_varient_output
|
||||
|
|
|
|||
|
|
@ -98,9 +98,9 @@ vs_ppc_run_linear( struct draw_vertex_shader *base,
|
|||
/* loop over verts */
|
||||
for (i = 0; i < count; i += MAX_VERTICES) {
|
||||
const uint max_vertices = MIN2(MAX_VERTICES, count - i);
|
||||
float inputs_soa[PIPE_MAX_SHADER_INPUTS][4][4] ALIGN16_ATTRIB;
|
||||
float outputs_soa[PIPE_MAX_SHADER_OUTPUTS][4][4] ALIGN16_ATTRIB;
|
||||
float temps_soa[TGSI_EXEC_NUM_TEMPS][4][4] ALIGN16_ATTRIB;
|
||||
PIPE_ALIGN_VAR(16) float inputs_soa[PIPE_MAX_SHADER_INPUTS][4][4];
|
||||
PIPE_ALIGN_VAR(16) float outputs_soa[PIPE_MAX_SHADER_OUTPUTS][4][4];
|
||||
PIPE_ALIGN_VAR(16) float temps_soa[TGSI_EXEC_NUM_TEMPS][4][4];
|
||||
uint attr;
|
||||
|
||||
/* convert (up to) four input verts to SoA format */
|
||||
|
|
|
|||
|
|
@ -142,6 +142,7 @@ static void PIPE_CDECL vsvg_run_elts( struct draw_vs_varient *varient,
|
|||
vsvg->fetch->run_elts( vsvg->fetch,
|
||||
elts,
|
||||
count,
|
||||
vsvg->draw->instance_id,
|
||||
temp_buffer );
|
||||
|
||||
vsvg->base.vs->run_linear( vsvg->base.vs,
|
||||
|
|
@ -181,6 +182,7 @@ static void PIPE_CDECL vsvg_run_elts( struct draw_vs_varient *varient,
|
|||
|
||||
vsvg->emit->run( vsvg->emit,
|
||||
0, count,
|
||||
vsvg->draw->instance_id,
|
||||
output_buffer );
|
||||
|
||||
FREE(temp_buffer);
|
||||
|
|
@ -203,6 +205,7 @@ static void PIPE_CDECL vsvg_run_linear( struct draw_vs_varient *varient,
|
|||
vsvg->fetch->run( vsvg->fetch,
|
||||
start,
|
||||
count,
|
||||
vsvg->draw->instance_id,
|
||||
temp_buffer );
|
||||
|
||||
vsvg->base.vs->run_linear( vsvg->base.vs,
|
||||
|
|
@ -239,6 +242,7 @@ static void PIPE_CDECL vsvg_run_linear( struct draw_vs_varient *varient,
|
|||
|
||||
vsvg->emit->run( vsvg->emit,
|
||||
0, count,
|
||||
vsvg->draw->instance_id,
|
||||
output_buffer );
|
||||
|
||||
FREE(temp_buffer);
|
||||
|
|
@ -281,9 +285,11 @@ struct draw_vs_varient *draw_vs_varient_generic( struct draw_vertex_shader *vs,
|
|||
fetch.nr_elements = key->nr_inputs;
|
||||
fetch.output_stride = vsvg->temp_vertex_stride;
|
||||
for (i = 0; i < key->nr_inputs; i++) {
|
||||
fetch.element[i].type = TRANSLATE_ELEMENT_NORMAL;
|
||||
fetch.element[i].input_format = key->element[i].in.format;
|
||||
fetch.element[i].input_buffer = key->element[i].in.buffer;
|
||||
fetch.element[i].input_offset = key->element[i].in.offset;
|
||||
fetch.element[i].instance_divisor = 0;
|
||||
fetch.element[i].output_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
|
||||
fetch.element[i].output_offset = i * 4 * sizeof(float);
|
||||
assert(fetch.element[i].output_offset < fetch.output_stride);
|
||||
|
|
@ -295,17 +301,21 @@ struct draw_vs_varient *draw_vs_varient_generic( struct draw_vertex_shader *vs,
|
|||
for (i = 0; i < key->nr_outputs; i++) {
|
||||
if (key->element[i].out.format != EMIT_1F_PSIZE)
|
||||
{
|
||||
emit.element[i].type = TRANSLATE_ELEMENT_NORMAL;
|
||||
emit.element[i].input_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
|
||||
emit.element[i].input_buffer = 0;
|
||||
emit.element[i].input_offset = key->element[i].out.vs_output * 4 * sizeof(float);
|
||||
emit.element[i].instance_divisor = 0;
|
||||
emit.element[i].output_format = draw_translate_vinfo_format(key->element[i].out.format);
|
||||
emit.element[i].output_offset = key->element[i].out.offset;
|
||||
assert(emit.element[i].input_offset <= fetch.output_stride);
|
||||
}
|
||||
else {
|
||||
emit.element[i].type = TRANSLATE_ELEMENT_NORMAL;
|
||||
emit.element[i].input_format = PIPE_FORMAT_R32_FLOAT;
|
||||
emit.element[i].input_buffer = 1;
|
||||
emit.element[i].input_offset = 0;
|
||||
emit.element[i].instance_divisor = 0;
|
||||
emit.element[i].output_format = PIPE_FORMAT_R32_FLOAT;
|
||||
emit.element[i].output_offset = key->element[i].out.offset;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,27 +80,11 @@ struct fenced_buffer_list
|
|||
*/
|
||||
struct fenced_buffer
|
||||
{
|
||||
/*
|
||||
* Immutable members.
|
||||
*/
|
||||
|
||||
struct pb_buffer base;
|
||||
|
||||
struct pb_buffer *buffer;
|
||||
struct fenced_buffer_list *list;
|
||||
|
||||
/**
|
||||
* Protected by fenced_buffer_list::mutex
|
||||
*/
|
||||
struct list_head head;
|
||||
|
||||
/**
|
||||
* Following members are mutable and protected by this mutex.
|
||||
*
|
||||
* You may lock this mutex alone, or lock it with fenced_buffer_list::mutex
|
||||
* held, but in order to prevent deadlocks you must never lock
|
||||
* fenced_buffer_list::mutex with this mutex held.
|
||||
*/
|
||||
pipe_mutex mutex;
|
||||
/* FIXME: protect access with mutex */
|
||||
|
||||
/**
|
||||
* A bitmask of PIPE_BUFFER_USAGE_CPU/GPU_READ/WRITE describing the current
|
||||
|
|
@ -112,6 +96,9 @@ struct fenced_buffer
|
|||
struct pb_validate *vl;
|
||||
unsigned validation_flags;
|
||||
struct pipe_fence_handle *fence;
|
||||
|
||||
struct list_head head;
|
||||
struct fenced_buffer_list *list;
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -123,24 +110,15 @@ fenced_buffer(struct pb_buffer *buf)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add the buffer to the fenced list.
|
||||
*
|
||||
* fenced_buffer_list::mutex and fenced_buffer::mutex must be held, in this
|
||||
* order, before calling this function.
|
||||
*
|
||||
* Reference count should be incremented before calling this function.
|
||||
*/
|
||||
static INLINE void
|
||||
fenced_buffer_add_locked(struct fenced_buffer_list *fenced_list,
|
||||
struct fenced_buffer *fenced_buf)
|
||||
_fenced_buffer_add(struct fenced_buffer *fenced_buf)
|
||||
{
|
||||
struct fenced_buffer_list *fenced_list = fenced_buf->list;
|
||||
|
||||
assert(pipe_is_referenced(&fenced_buf->base.base.reference));
|
||||
assert(fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE);
|
||||
assert(fenced_buf->fence);
|
||||
|
||||
/* TODO: Move the reference count increment here */
|
||||
|
||||
#ifdef DEBUG
|
||||
LIST_DEL(&fenced_buf->head);
|
||||
assert(fenced_list->numUnfenced);
|
||||
|
|
@ -152,16 +130,32 @@ fenced_buffer_add_locked(struct fenced_buffer_list *fenced_list,
|
|||
|
||||
|
||||
/**
|
||||
* Remove the buffer from the fenced list.
|
||||
*
|
||||
* fenced_buffer_list::mutex and fenced_buffer::mutex must be held, in this
|
||||
* order before calling this function.
|
||||
*
|
||||
* Reference count should be decremented after calling this function.
|
||||
* Actually destroy the buffer.
|
||||
*/
|
||||
static INLINE void
|
||||
fenced_buffer_remove_locked(struct fenced_buffer_list *fenced_list,
|
||||
struct fenced_buffer *fenced_buf)
|
||||
_fenced_buffer_destroy(struct fenced_buffer *fenced_buf)
|
||||
{
|
||||
struct fenced_buffer_list *fenced_list = fenced_buf->list;
|
||||
|
||||
assert(!pipe_is_referenced(&fenced_buf->base.base.reference));
|
||||
assert(!fenced_buf->fence);
|
||||
#ifdef DEBUG
|
||||
assert(fenced_buf->head.prev);
|
||||
assert(fenced_buf->head.next);
|
||||
LIST_DEL(&fenced_buf->head);
|
||||
assert(fenced_list->numUnfenced);
|
||||
--fenced_list->numUnfenced;
|
||||
#else
|
||||
(void)fenced_list;
|
||||
#endif
|
||||
pb_reference(&fenced_buf->buffer, NULL);
|
||||
FREE(fenced_buf);
|
||||
}
|
||||
|
||||
|
||||
static INLINE void
|
||||
_fenced_buffer_remove(struct fenced_buffer_list *fenced_list,
|
||||
struct fenced_buffer *fenced_buf)
|
||||
{
|
||||
struct pb_fence_ops *ops = fenced_list->ops;
|
||||
|
||||
|
|
@ -183,56 +177,37 @@ fenced_buffer_remove_locked(struct fenced_buffer_list *fenced_list,
|
|||
++fenced_list->numUnfenced;
|
||||
#endif
|
||||
|
||||
/* TODO: Move the reference count decrement and destruction here */
|
||||
/**
|
||||
* FIXME!!!
|
||||
*/
|
||||
|
||||
if(!pipe_is_referenced(&fenced_buf->base.base.reference))
|
||||
_fenced_buffer_destroy(fenced_buf);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Wait for the fence to expire, and remove it from the fenced list.
|
||||
*
|
||||
* fenced_buffer::mutex must be held. fenced_buffer_list::mutex must not be
|
||||
* held -- it will be acquired internally.
|
||||
*/
|
||||
static INLINE enum pipe_error
|
||||
fenced_buffer_finish_locked(struct fenced_buffer_list *fenced_list,
|
||||
struct fenced_buffer *fenced_buf)
|
||||
_fenced_buffer_finish(struct fenced_buffer *fenced_buf)
|
||||
{
|
||||
struct fenced_buffer_list *fenced_list = fenced_buf->list;
|
||||
struct pb_fence_ops *ops = fenced_list->ops;
|
||||
enum pipe_error ret = PIPE_ERROR;
|
||||
|
||||
#if 0
|
||||
debug_warning("waiting for GPU");
|
||||
#endif
|
||||
|
||||
assert(pipe_is_referenced(&fenced_buf->base.base.reference));
|
||||
assert(fenced_buf->fence);
|
||||
|
||||
/*
|
||||
* Acquire the global lock. Must release buffer mutex first to preserve
|
||||
* lock order.
|
||||
*/
|
||||
pipe_mutex_unlock(fenced_buf->mutex);
|
||||
pipe_mutex_lock(fenced_list->mutex);
|
||||
pipe_mutex_lock(fenced_buf->mutex);
|
||||
|
||||
if(fenced_buf->fence) {
|
||||
if(ops->fence_finish(ops, fenced_buf->fence, 0) == 0) {
|
||||
/* Remove from the fenced list */
|
||||
/* TODO: remove consequents */
|
||||
fenced_buffer_remove_locked(fenced_list, fenced_buf);
|
||||
|
||||
p_atomic_dec(&fenced_buf->base.base.reference.count);
|
||||
assert(pipe_is_referenced(&fenced_buf->base.base.reference));
|
||||
|
||||
fenced_buf->flags &= ~PIPE_BUFFER_USAGE_GPU_READ_WRITE;
|
||||
|
||||
ret = PIPE_OK;
|
||||
if(ops->fence_finish(ops, fenced_buf->fence, 0) != 0) {
|
||||
return PIPE_ERROR;
|
||||
}
|
||||
/* Remove from the fenced list */
|
||||
/* TODO: remove consequents */
|
||||
_fenced_buffer_remove(fenced_list, fenced_buf);
|
||||
}
|
||||
|
||||
pipe_mutex_unlock(fenced_list->mutex);
|
||||
|
||||
return ret;
|
||||
fenced_buf->flags &= ~PIPE_BUFFER_USAGE_GPU_READ_WRITE;
|
||||
return PIPE_OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -240,8 +215,8 @@ fenced_buffer_finish_locked(struct fenced_buffer_list *fenced_list,
|
|||
* Free as many fenced buffers from the list head as possible.
|
||||
*/
|
||||
static void
|
||||
fenced_buffer_list_check_free_locked(struct fenced_buffer_list *fenced_list,
|
||||
int wait)
|
||||
_fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
|
||||
int wait)
|
||||
{
|
||||
struct pb_fence_ops *ops = fenced_list->ops;
|
||||
struct list_head *curr, *next;
|
||||
|
|
@ -254,29 +229,21 @@ fenced_buffer_list_check_free_locked(struct fenced_buffer_list *fenced_list,
|
|||
while(curr != &fenced_list->delayed) {
|
||||
fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head);
|
||||
|
||||
pipe_mutex_lock(fenced_buf->mutex);
|
||||
|
||||
if(fenced_buf->fence != prev_fence) {
|
||||
int signaled;
|
||||
if (wait)
|
||||
signaled = ops->fence_finish(ops, fenced_buf->fence, 0);
|
||||
else
|
||||
signaled = ops->fence_signalled(ops, fenced_buf->fence, 0);
|
||||
if (signaled != 0) {
|
||||
pipe_mutex_unlock(fenced_buf->mutex);
|
||||
if (signaled != 0)
|
||||
break;
|
||||
}
|
||||
prev_fence = fenced_buf->fence;
|
||||
}
|
||||
else {
|
||||
assert(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0);
|
||||
}
|
||||
|
||||
fenced_buffer_remove_locked(fenced_list, fenced_buf);
|
||||
pipe_mutex_unlock(fenced_buf->mutex);
|
||||
|
||||
pb_buf = &fenced_buf->base;
|
||||
pb_reference(&pb_buf, NULL);
|
||||
_fenced_buffer_remove(fenced_list, fenced_buf);
|
||||
|
||||
curr = next;
|
||||
next = curr->next;
|
||||
|
|
@ -290,25 +257,30 @@ fenced_buffer_destroy(struct pb_buffer *buf)
|
|||
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
|
||||
struct fenced_buffer_list *fenced_list = fenced_buf->list;
|
||||
|
||||
assert(!pipe_is_referenced(&fenced_buf->base.base.reference));
|
||||
assert(!fenced_buf->fence);
|
||||
|
||||
#ifdef DEBUG
|
||||
pipe_mutex_lock(fenced_list->mutex);
|
||||
assert(fenced_buf->head.prev);
|
||||
assert(fenced_buf->head.next);
|
||||
LIST_DEL(&fenced_buf->head);
|
||||
assert(fenced_list->numUnfenced);
|
||||
--fenced_list->numUnfenced;
|
||||
assert(!pipe_is_referenced(&fenced_buf->base.base.reference));
|
||||
if (fenced_buf->fence) {
|
||||
struct pb_fence_ops *ops = fenced_list->ops;
|
||||
if(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0) {
|
||||
struct list_head *curr, *prev;
|
||||
curr = &fenced_buf->head;
|
||||
prev = curr->prev;
|
||||
do {
|
||||
fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head);
|
||||
assert(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0);
|
||||
_fenced_buffer_remove(fenced_list, fenced_buf);
|
||||
curr = prev;
|
||||
prev = curr->prev;
|
||||
} while (curr != &fenced_list->delayed);
|
||||
}
|
||||
else {
|
||||
/* delay destruction */
|
||||
}
|
||||
}
|
||||
else {
|
||||
_fenced_buffer_destroy(fenced_buf);
|
||||
}
|
||||
pipe_mutex_unlock(fenced_list->mutex);
|
||||
#else
|
||||
(void)fenced_list;
|
||||
#endif
|
||||
|
||||
pb_reference(&fenced_buf->buffer, NULL);
|
||||
|
||||
pipe_mutex_destroy(fenced_buf->mutex);
|
||||
FREE(fenced_buf);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -319,23 +291,24 @@ fenced_buffer_map(struct pb_buffer *buf,
|
|||
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
|
||||
struct fenced_buffer_list *fenced_list = fenced_buf->list;
|
||||
struct pb_fence_ops *ops = fenced_list->ops;
|
||||
void *map = NULL;
|
||||
|
||||
pipe_mutex_lock(fenced_buf->mutex);
|
||||
void *map;
|
||||
|
||||
assert(!(flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE));
|
||||
|
||||
/* Serialize writes */
|
||||
if((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_WRITE) ||
|
||||
((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ) && (flags & PIPE_BUFFER_USAGE_CPU_WRITE))) {
|
||||
if((flags & PIPE_BUFFER_USAGE_DONTBLOCK) &&
|
||||
ops->fence_signalled(ops, fenced_buf->fence, 0) == 0) {
|
||||
if(flags & PIPE_BUFFER_USAGE_DONTBLOCK) {
|
||||
/* Don't wait for the GPU to finish writing */
|
||||
goto done;
|
||||
if(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0)
|
||||
_fenced_buffer_remove(fenced_list, fenced_buf);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
else {
|
||||
/* Wait for the GPU to finish writing */
|
||||
_fenced_buffer_finish(fenced_buf);
|
||||
}
|
||||
|
||||
/* Wait for the GPU to finish writing */
|
||||
fenced_buffer_finish_locked(fenced_list, fenced_buf);
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
|
@ -352,9 +325,6 @@ fenced_buffer_map(struct pb_buffer *buf,
|
|||
fenced_buf->flags |= flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE;
|
||||
}
|
||||
|
||||
done:
|
||||
pipe_mutex_unlock(fenced_buf->mutex);
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
|
|
@ -363,9 +333,6 @@ static void
|
|||
fenced_buffer_unmap(struct pb_buffer *buf)
|
||||
{
|
||||
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
|
||||
|
||||
pipe_mutex_lock(fenced_buf->mutex);
|
||||
|
||||
assert(fenced_buf->mapcount);
|
||||
if(fenced_buf->mapcount) {
|
||||
pb_unmap(fenced_buf->buffer);
|
||||
|
|
@ -373,8 +340,6 @@ fenced_buffer_unmap(struct pb_buffer *buf)
|
|||
if(!fenced_buf->mapcount)
|
||||
fenced_buf->flags &= ~PIPE_BUFFER_USAGE_CPU_READ_WRITE;
|
||||
}
|
||||
|
||||
pipe_mutex_unlock(fenced_buf->mutex);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -386,14 +351,11 @@ fenced_buffer_validate(struct pb_buffer *buf,
|
|||
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
|
||||
enum pipe_error ret;
|
||||
|
||||
pipe_mutex_lock(fenced_buf->mutex);
|
||||
|
||||
if(!vl) {
|
||||
/* invalidate */
|
||||
fenced_buf->vl = NULL;
|
||||
fenced_buf->validation_flags = 0;
|
||||
ret = PIPE_OK;
|
||||
goto done;
|
||||
return PIPE_OK;
|
||||
}
|
||||
|
||||
assert(flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE);
|
||||
|
|
@ -401,17 +363,14 @@ fenced_buffer_validate(struct pb_buffer *buf,
|
|||
flags &= PIPE_BUFFER_USAGE_GPU_READ_WRITE;
|
||||
|
||||
/* Buffer cannot be validated in two different lists */
|
||||
if(fenced_buf->vl && fenced_buf->vl != vl) {
|
||||
ret = PIPE_ERROR_RETRY;
|
||||
goto done;
|
||||
}
|
||||
if(fenced_buf->vl && fenced_buf->vl != vl)
|
||||
return PIPE_ERROR_RETRY;
|
||||
|
||||
#if 0
|
||||
/* Do not validate if buffer is still mapped */
|
||||
if(fenced_buf->flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE) {
|
||||
/* TODO: wait for the thread that mapped the buffer to unmap it */
|
||||
ret = PIPE_ERROR_RETRY;
|
||||
goto done;
|
||||
return PIPE_ERROR_RETRY;
|
||||
}
|
||||
/* Final sanity checking */
|
||||
assert(!(fenced_buf->flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE));
|
||||
|
|
@ -421,21 +380,17 @@ fenced_buffer_validate(struct pb_buffer *buf,
|
|||
if(fenced_buf->vl == vl &&
|
||||
(fenced_buf->validation_flags & flags) == flags) {
|
||||
/* Nothing to do -- buffer already validated */
|
||||
ret = PIPE_OK;
|
||||
goto done;
|
||||
return PIPE_OK;
|
||||
}
|
||||
|
||||
ret = pb_validate(fenced_buf->buffer, vl, flags);
|
||||
if (ret != PIPE_OK)
|
||||
goto done;
|
||||
return ret;
|
||||
|
||||
fenced_buf->vl = vl;
|
||||
fenced_buf->validation_flags |= flags;
|
||||
|
||||
done:
|
||||
pipe_mutex_unlock(fenced_buf->mutex);
|
||||
|
||||
return ret;
|
||||
return PIPE_OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -450,36 +405,29 @@ fenced_buffer_fence(struct pb_buffer *buf,
|
|||
fenced_buf = fenced_buffer(buf);
|
||||
fenced_list = fenced_buf->list;
|
||||
ops = fenced_list->ops;
|
||||
|
||||
pipe_mutex_lock(fenced_list->mutex);
|
||||
pipe_mutex_lock(fenced_buf->mutex);
|
||||
|
||||
assert(pipe_is_referenced(&fenced_buf->base.base.reference));
|
||||
|
||||
if(fence != fenced_buf->fence) {
|
||||
assert(fenced_buf->vl);
|
||||
assert(fenced_buf->validation_flags);
|
||||
|
||||
if (fenced_buf->fence) {
|
||||
fenced_buffer_remove_locked(fenced_list, fenced_buf);
|
||||
p_atomic_dec(&fenced_buf->base.base.reference.count);
|
||||
assert(pipe_is_referenced(&fenced_buf->base.base.reference));
|
||||
}
|
||||
if (fence) {
|
||||
ops->fence_reference(ops, &fenced_buf->fence, fence);
|
||||
fenced_buf->flags |= fenced_buf->validation_flags;
|
||||
p_atomic_inc(&fenced_buf->base.base.reference.count);
|
||||
fenced_buffer_add_locked(fenced_list, fenced_buf);
|
||||
}
|
||||
|
||||
pb_fence(fenced_buf->buffer, fence);
|
||||
|
||||
fenced_buf->vl = NULL;
|
||||
fenced_buf->validation_flags = 0;
|
||||
if(fence == fenced_buf->fence) {
|
||||
/* Nothing to do */
|
||||
return;
|
||||
}
|
||||
|
||||
pipe_mutex_unlock(fenced_buf->mutex);
|
||||
assert(fenced_buf->vl);
|
||||
assert(fenced_buf->validation_flags);
|
||||
|
||||
pipe_mutex_lock(fenced_list->mutex);
|
||||
if (fenced_buf->fence)
|
||||
_fenced_buffer_remove(fenced_list, fenced_buf);
|
||||
if (fence) {
|
||||
ops->fence_reference(ops, &fenced_buf->fence, fence);
|
||||
fenced_buf->flags |= fenced_buf->validation_flags;
|
||||
_fenced_buffer_add(fenced_buf);
|
||||
}
|
||||
pipe_mutex_unlock(fenced_list->mutex);
|
||||
|
||||
pb_fence(fenced_buf->buffer, fence);
|
||||
|
||||
fenced_buf->vl = NULL;
|
||||
fenced_buf->validation_flags = 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -489,7 +437,6 @@ fenced_buffer_get_base_buffer(struct pb_buffer *buf,
|
|||
pb_size *offset)
|
||||
{
|
||||
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
|
||||
/* NOTE: accesses immutable members only -- mutex not necessary */
|
||||
pb_get_base_buffer(fenced_buf->buffer, base_buf, offset);
|
||||
}
|
||||
|
||||
|
|
@ -529,8 +476,6 @@ fenced_buffer_create(struct fenced_buffer_list *fenced_list,
|
|||
buf->buffer = buffer;
|
||||
buf->list = fenced_list;
|
||||
|
||||
pipe_mutex_init(buf->mutex);
|
||||
|
||||
#ifdef DEBUG
|
||||
pipe_mutex_lock(fenced_list->mutex);
|
||||
LIST_ADDTAIL(&buf->head, &fenced_list->unfenced);
|
||||
|
|
@ -572,7 +517,7 @@ fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
|
|||
int wait)
|
||||
{
|
||||
pipe_mutex_lock(fenced_list->mutex);
|
||||
fenced_buffer_list_check_free_locked(fenced_list, wait);
|
||||
_fenced_buffer_list_check_free(fenced_list, wait);
|
||||
pipe_mutex_unlock(fenced_list->mutex);
|
||||
}
|
||||
|
||||
|
|
@ -594,13 +539,11 @@ fenced_buffer_list_dump(struct fenced_buffer_list *fenced_list)
|
|||
next = curr->next;
|
||||
while(curr != &fenced_list->unfenced) {
|
||||
fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head);
|
||||
pipe_mutex_lock(fenced_buf->mutex);
|
||||
assert(!fenced_buf->fence);
|
||||
debug_printf("%10p %7u %7u\n",
|
||||
(void *) fenced_buf,
|
||||
fenced_buf->base.base.size,
|
||||
p_atomic_read(&fenced_buf->base.base.reference.count));
|
||||
pipe_mutex_unlock(fenced_buf->mutex);
|
||||
curr = next;
|
||||
next = curr->next;
|
||||
}
|
||||
|
|
@ -610,7 +553,6 @@ fenced_buffer_list_dump(struct fenced_buffer_list *fenced_list)
|
|||
while(curr != &fenced_list->delayed) {
|
||||
int signaled;
|
||||
fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head);
|
||||
pipe_mutex_lock(fenced_buf->mutex);
|
||||
signaled = ops->fence_signalled(ops, fenced_buf->fence, 0);
|
||||
debug_printf("%10p %7u %7u %10p %s\n",
|
||||
(void *) fenced_buf,
|
||||
|
|
@ -618,7 +560,6 @@ fenced_buffer_list_dump(struct fenced_buffer_list *fenced_list)
|
|||
p_atomic_read(&fenced_buf->base.base.reference.count),
|
||||
(void *) fenced_buf->fence,
|
||||
signaled == 0 ? "y" : "n");
|
||||
pipe_mutex_unlock(fenced_buf->mutex);
|
||||
curr = next;
|
||||
next = curr->next;
|
||||
}
|
||||
|
|
@ -639,8 +580,8 @@ fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list)
|
|||
#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS)
|
||||
sched_yield();
|
||||
#endif
|
||||
_fenced_buffer_list_check_free(fenced_list, 1);
|
||||
pipe_mutex_lock(fenced_list->mutex);
|
||||
fenced_buffer_list_check_free_locked(fenced_list, 1);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
@ -648,7 +589,6 @@ fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list)
|
|||
#endif
|
||||
|
||||
pipe_mutex_unlock(fenced_list->mutex);
|
||||
pipe_mutex_destroy(fenced_list->mutex);
|
||||
|
||||
fenced_list->ops->destroy(fenced_list->ops);
|
||||
|
||||
|
|
|
|||
|
|
@ -673,6 +673,13 @@ void x86_and( struct x86_function *p,
|
|||
emit_op_modrm( p, 0x23, 0x21, dst, src );
|
||||
}
|
||||
|
||||
void x86_div( struct x86_function *p,
|
||||
struct x86_reg src )
|
||||
{
|
||||
assert(src.file == file_REG32 && src.mod == mod_REG);
|
||||
emit_op_modrm(p, 0xf7, 0, x86_make_reg(file_REG32, 6), src);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
|
|
|
|||
|
|
@ -244,6 +244,7 @@ void x86_sub( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
|
|||
void x86_test( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
|
||||
void x86_xor( struct x86_function *p, struct x86_reg dst, struct x86_reg src );
|
||||
void x86_sahf( struct x86_function *p );
|
||||
void x86_div( struct x86_function *p, struct x86_reg src );
|
||||
|
||||
|
||||
void x86_cdecl_caller_push_regs( struct x86_function *p );
|
||||
|
|
|
|||
|
|
@ -123,7 +123,8 @@ static const char *semantic_names[] =
|
|||
"NORMAL",
|
||||
"FACE",
|
||||
"EDGEFLAG",
|
||||
"PRIM_ID"
|
||||
"PRIM_ID",
|
||||
"INSTANCEID"
|
||||
};
|
||||
|
||||
static const char *immediate_type_names[] =
|
||||
|
|
|
|||
|
|
@ -1041,11 +1041,19 @@ fetch_src_file_channel(
|
|||
|
||||
default:
|
||||
assert( 0 );
|
||||
chan->u[0] = 0;
|
||||
chan->u[1] = 0;
|
||||
chan->u[2] = 0;
|
||||
chan->u[3] = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
assert( 0 );
|
||||
chan->u[0] = 0;
|
||||
chan->u[1] = 0;
|
||||
chan->u[2] = 0;
|
||||
chan->u[3] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,8 @@
|
|||
* Since it's pretty much impossible to form PPC vector immediates, load
|
||||
* them from memory here:
|
||||
*/
|
||||
const float ppc_builtin_constants[] ALIGN16_ATTRIB = {
|
||||
PIPE_ALIGN_VAR(16) const float
|
||||
ppc_builtin_constants[] = {
|
||||
1.0f, -128.0f, 128.0, 0.0
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -335,13 +335,13 @@ iter_instruction(
|
|||
fill_scan_register1d(ind_reg,
|
||||
inst->Src[i].Indirect.File,
|
||||
inst->Src[i].Indirect.Index);
|
||||
if (!(reg->file == TGSI_FILE_ADDRESS || reg->file == TGSI_FILE_LOOP) ||
|
||||
reg->indices[0] != 0) {
|
||||
if (!(ind_reg->file == TGSI_FILE_ADDRESS || ind_reg->file == TGSI_FILE_LOOP) ||
|
||||
ind_reg->indices[0] != 0) {
|
||||
report_warning(ctx, "Indirect register neither ADDR[0] nor LOOP[0]");
|
||||
}
|
||||
check_register_usage(
|
||||
ctx,
|
||||
reg,
|
||||
ind_reg,
|
||||
"indirect",
|
||||
FALSE );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2146,40 +2146,50 @@ emit_instruction(
|
|||
break;
|
||||
|
||||
case TGSI_OPCODE_XPD:
|
||||
/* Note: we do all stores after all operands have been fetched
|
||||
* to avoid src/dst register aliasing issues for an instruction
|
||||
* such as: XPD TEMP[2].xyz, TEMP[0], TEMP[2];
|
||||
*/
|
||||
if( IS_DST0_CHANNEL_ENABLED( *inst, CHAN_X ) ||
|
||||
IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Y ) ) {
|
||||
FETCH( func, *inst, 1, 1, CHAN_Z );
|
||||
FETCH( func, *inst, 3, 0, CHAN_Z );
|
||||
FETCH( func, *inst, 1, 1, CHAN_Z ); /* xmm[1] = src[1].z */
|
||||
FETCH( func, *inst, 3, 0, CHAN_Z ); /* xmm[3] = src[0].z */
|
||||
}
|
||||
if( IS_DST0_CHANNEL_ENABLED( *inst, CHAN_X ) ||
|
||||
IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Z ) ) {
|
||||
FETCH( func, *inst, 0, 0, CHAN_Y );
|
||||
FETCH( func, *inst, 4, 1, CHAN_Y );
|
||||
FETCH( func, *inst, 0, 0, CHAN_Y ); /* xmm[0] = src[0].y */
|
||||
FETCH( func, *inst, 4, 1, CHAN_Y ); /* xmm[4] = src[1].y */
|
||||
}
|
||||
IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_X ) {
|
||||
emit_MOV( func, 2, 0 );
|
||||
emit_mul( func, 2, 1 );
|
||||
emit_MOV( func, 5, 3 );
|
||||
emit_mul( func, 5, 4 );
|
||||
emit_sub( func, 2, 5 );
|
||||
STORE( func, *inst, 2, 0, CHAN_X );
|
||||
emit_MOV( func, 7, 0 ); /* xmm[7] = xmm[0] */
|
||||
emit_mul( func, 7, 1 ); /* xmm[7] = xmm[2] * xmm[1] */
|
||||
emit_MOV( func, 5, 3 ); /* xmm[5] = xmm[3] */
|
||||
emit_mul( func, 5, 4 ); /* xmm[5] = xmm[5] * xmm[4] */
|
||||
emit_sub( func, 7, 5 ); /* xmm[7] = xmm[2] - xmm[5] */
|
||||
/* store xmm[7] in dst.x below */
|
||||
}
|
||||
if( IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Y ) ||
|
||||
IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Z ) ) {
|
||||
FETCH( func, *inst, 2, 1, CHAN_X );
|
||||
FETCH( func, *inst, 5, 0, CHAN_X );
|
||||
FETCH( func, *inst, 2, 1, CHAN_X ); /* xmm[2] = src[1].x */
|
||||
FETCH( func, *inst, 5, 0, CHAN_X ); /* xmm[5] = src[0].x */
|
||||
}
|
||||
IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Y ) {
|
||||
emit_mul( func, 3, 2 );
|
||||
emit_mul( func, 1, 5 );
|
||||
emit_sub( func, 3, 1 );
|
||||
STORE( func, *inst, 3, 0, CHAN_Y );
|
||||
emit_mul( func, 3, 2 ); /* xmm[3] = xmm[3] * xmm[2] */
|
||||
emit_mul( func, 1, 5 ); /* xmm[1] = xmm[1] * xmm[5] */
|
||||
emit_sub( func, 3, 1 ); /* xmm[3] = xmm[3] - xmm[1] */
|
||||
/* store xmm[3] in dst.y below */
|
||||
}
|
||||
IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Z ) {
|
||||
emit_mul( func, 5, 4 );
|
||||
emit_mul( func, 0, 2 );
|
||||
emit_sub( func, 5, 0 );
|
||||
STORE( func, *inst, 5, 0, CHAN_Z );
|
||||
emit_mul( func, 5, 4 ); /* xmm[5] = xmm[5] * xmm[4] */
|
||||
emit_mul( func, 0, 2 ); /* xmm[0] = xmm[0] * xmm[2] */
|
||||
emit_sub( func, 5, 0 ); /* xmm[5] = xmm[5] - xmm[0] */
|
||||
STORE( func, *inst, 5, 0, CHAN_Z ); /* dst.z = xmm[5] */
|
||||
}
|
||||
IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_X ) {
|
||||
STORE( func, *inst, 7, 0, CHAN_X ); /* dst.x = xmm[7] */
|
||||
}
|
||||
IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_Y ) {
|
||||
STORE( func, *inst, 3, 0, CHAN_Y ); /* dst.y = xmm[3] */
|
||||
}
|
||||
IF_IS_DST0_CHANNEL_ENABLED( *inst, CHAN_W ) {
|
||||
emit_tempf(
|
||||
|
|
|
|||
|
|
@ -40,6 +40,8 @@ union tgsi_any_token {
|
|||
struct tgsi_header header;
|
||||
struct tgsi_processor processor;
|
||||
struct tgsi_token token;
|
||||
struct tgsi_property prop;
|
||||
struct tgsi_property_data prop_data;
|
||||
struct tgsi_declaration decl;
|
||||
struct tgsi_declaration_range decl_range;
|
||||
struct tgsi_declaration_semantic decl_semantic;
|
||||
|
|
@ -64,6 +66,7 @@ struct ureg_tokens {
|
|||
};
|
||||
|
||||
#define UREG_MAX_INPUT PIPE_MAX_ATTRIBS
|
||||
#define UREG_MAX_SYSTEM_VALUE PIPE_MAX_ATTRIBS
|
||||
#define UREG_MAX_OUTPUT PIPE_MAX_ATTRIBS
|
||||
#define UREG_MAX_CONSTANT_RANGE 32
|
||||
#define UREG_MAX_IMMEDIATE 32
|
||||
|
|
@ -94,6 +97,13 @@ struct ureg_program
|
|||
} gs_input[UREG_MAX_INPUT];
|
||||
unsigned nr_gs_inputs;
|
||||
|
||||
struct {
|
||||
unsigned index;
|
||||
unsigned semantic_name;
|
||||
unsigned semantic_index;
|
||||
} system_value[UREG_MAX_SYSTEM_VALUE];
|
||||
unsigned nr_system_values;
|
||||
|
||||
struct {
|
||||
unsigned semantic_name;
|
||||
unsigned semantic_index;
|
||||
|
|
@ -123,6 +133,8 @@ struct ureg_program
|
|||
} constant_range[UREG_MAX_CONSTANT_RANGE];
|
||||
unsigned nr_constant_ranges;
|
||||
|
||||
unsigned property_gs_input_prim;
|
||||
|
||||
unsigned nr_addrs;
|
||||
unsigned nr_preds;
|
||||
unsigned nr_loops;
|
||||
|
|
@ -234,19 +246,28 @@ ureg_src_register( unsigned file,
|
|||
src.SwizzleY = TGSI_SWIZZLE_Y;
|
||||
src.SwizzleZ = TGSI_SWIZZLE_Z;
|
||||
src.SwizzleW = TGSI_SWIZZLE_W;
|
||||
src.Pad = 0;
|
||||
src.Indirect = 0;
|
||||
src.IndirectIndex = 0;
|
||||
src.IndirectSwizzle = 0;
|
||||
src.Absolute = 0;
|
||||
src.Index = index;
|
||||
src.Negate = 0;
|
||||
src.Dimension = 0;
|
||||
src.DimensionIndex = 0;
|
||||
|
||||
return src;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void
|
||||
ureg_property_gs_input_prim(struct ureg_program *ureg,
|
||||
unsigned gs_input_prim)
|
||||
{
|
||||
ureg->property_gs_input_prim = gs_input_prim;
|
||||
}
|
||||
|
||||
|
||||
|
||||
struct ureg_src
|
||||
ureg_DECL_fs_input( struct ureg_program *ureg,
|
||||
|
|
@ -304,6 +325,25 @@ ureg_DECL_gs_input(struct ureg_program *ureg,
|
|||
}
|
||||
|
||||
|
||||
struct ureg_src
|
||||
ureg_DECL_system_value(struct ureg_program *ureg,
|
||||
unsigned index,
|
||||
unsigned semantic_name,
|
||||
unsigned semantic_index)
|
||||
{
|
||||
if (ureg->nr_system_values < UREG_MAX_SYSTEM_VALUE) {
|
||||
ureg->system_value[ureg->nr_system_values].index = index;
|
||||
ureg->system_value[ureg->nr_system_values].semantic_name = semantic_name;
|
||||
ureg->system_value[ureg->nr_system_values].semantic_index = semantic_index;
|
||||
ureg->nr_system_values++;
|
||||
} else {
|
||||
set_bad(ureg);
|
||||
}
|
||||
|
||||
return ureg_src_register(TGSI_FILE_SYSTEM_VALUE, index);
|
||||
}
|
||||
|
||||
|
||||
struct ureg_dst
|
||||
ureg_DECL_output( struct ureg_program *ureg,
|
||||
unsigned name,
|
||||
|
|
@ -628,7 +668,7 @@ void
|
|||
ureg_emit_src( struct ureg_program *ureg,
|
||||
struct ureg_src src )
|
||||
{
|
||||
unsigned size = 1 + (src.Indirect ? 1 : 0);
|
||||
unsigned size = 1 + (src.Indirect ? 1 : 0) + (src.Dimension ? 1 : 0);
|
||||
|
||||
union tgsi_any_token *out = get_tokens( ureg, DOMAIN_INSN, size );
|
||||
unsigned n = 0;
|
||||
|
|
@ -660,6 +700,15 @@ ureg_emit_src( struct ureg_program *ureg,
|
|||
n++;
|
||||
}
|
||||
|
||||
if (src.Dimension) {
|
||||
out[0].src.Dimension = 1;
|
||||
out[n].dim.Indirect = 0;
|
||||
out[n].dim.Dimension = 0;
|
||||
out[n].dim.Padding = 0;
|
||||
out[n].dim.Index = src.DimensionIndex;
|
||||
n++;
|
||||
}
|
||||
|
||||
assert(n == size);
|
||||
}
|
||||
|
||||
|
|
@ -1027,13 +1076,34 @@ emit_immediate( struct ureg_program *ureg,
|
|||
out[4].imm_data.Uint = v[3];
|
||||
}
|
||||
|
||||
static void
|
||||
emit_property(struct ureg_program *ureg,
|
||||
unsigned name,
|
||||
unsigned data)
|
||||
{
|
||||
union tgsi_any_token *out = get_tokens(ureg, DOMAIN_DECL, 2);
|
||||
|
||||
out[0].value = 0;
|
||||
out[0].prop.Type = TGSI_TOKEN_TYPE_PROPERTY;
|
||||
out[0].prop.NrTokens = 2;
|
||||
out[0].prop.PropertyName = name;
|
||||
|
||||
out[1].prop_data.Data = data;
|
||||
}
|
||||
|
||||
|
||||
static void emit_decls( struct ureg_program *ureg )
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
if (ureg->property_gs_input_prim != ~0) {
|
||||
assert(ureg->processor == TGSI_PROCESSOR_GEOMETRY);
|
||||
|
||||
emit_property(ureg,
|
||||
TGSI_PROPERTY_GS_INPUT_PRIM,
|
||||
ureg->property_gs_input_prim);
|
||||
}
|
||||
|
||||
if (ureg->processor == TGSI_PROCESSOR_VERTEX) {
|
||||
for (i = 0; i < UREG_MAX_INPUT; i++) {
|
||||
if (ureg->vs_inputs[i/32] & (1 << (i%32))) {
|
||||
|
|
@ -1058,6 +1128,15 @@ static void emit_decls( struct ureg_program *ureg )
|
|||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < ureg->nr_system_values; i++) {
|
||||
emit_decl(ureg,
|
||||
TGSI_FILE_SYSTEM_VALUE,
|
||||
ureg->system_value[i].index,
|
||||
ureg->system_value[i].semantic_name,
|
||||
ureg->system_value[i].semantic_index,
|
||||
TGSI_INTERPOLATE_CONSTANT);
|
||||
}
|
||||
|
||||
for (i = 0; i < ureg->nr_outputs; i++) {
|
||||
emit_decl( ureg,
|
||||
TGSI_FILE_OUTPUT,
|
||||
|
|
@ -1234,6 +1313,7 @@ struct ureg_program *ureg_create( unsigned processor )
|
|||
return NULL;
|
||||
|
||||
ureg->processor = processor;
|
||||
ureg->property_gs_input_prim = ~0;
|
||||
return ureg;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,13 +47,14 @@ struct ureg_src
|
|||
unsigned SwizzleY : 2; /* TGSI_SWIZZLE_ */
|
||||
unsigned SwizzleZ : 2; /* TGSI_SWIZZLE_ */
|
||||
unsigned SwizzleW : 2; /* TGSI_SWIZZLE_ */
|
||||
unsigned Pad : 1; /* BOOL */
|
||||
unsigned Indirect : 1; /* BOOL */
|
||||
unsigned Dimension : 1; /* BOOL */
|
||||
unsigned Absolute : 1; /* BOOL */
|
||||
int Index : 16; /* SINT */
|
||||
unsigned Negate : 1; /* BOOL */
|
||||
int Index : 16; /* SINT */
|
||||
int IndirectIndex : 16; /* SINT */
|
||||
int IndirectSwizzle : 2; /* TGSI_SWIZZLE_ */
|
||||
int DimensionIndex : 16; /* SINT */
|
||||
};
|
||||
|
||||
/* Very similar to a tgsi_dst_register, removing unsupported fields
|
||||
|
|
@ -118,6 +119,14 @@ ureg_create_shader_and_destroy( struct ureg_program *p,
|
|||
}
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Build shader properties:
|
||||
*/
|
||||
|
||||
void
|
||||
ureg_property_gs_input_prim(struct ureg_program *ureg,
|
||||
unsigned gs_input_prim);
|
||||
|
||||
|
||||
/***********************************************************************
|
||||
* Build shader declarations:
|
||||
|
|
@ -137,6 +146,12 @@ struct ureg_src
|
|||
ureg_DECL_gs_input(struct ureg_program *,
|
||||
unsigned index);
|
||||
|
||||
struct ureg_src
|
||||
ureg_DECL_system_value(struct ureg_program *,
|
||||
unsigned index,
|
||||
unsigned semantic_name,
|
||||
unsigned semantic_index);
|
||||
|
||||
struct ureg_dst
|
||||
ureg_DECL_output( struct ureg_program *,
|
||||
unsigned semantic_name,
|
||||
|
|
@ -760,6 +775,15 @@ ureg_src_indirect( struct ureg_src reg, struct ureg_src addr )
|
|||
return reg;
|
||||
}
|
||||
|
||||
static INLINE struct ureg_src
|
||||
ureg_src_dimension( struct ureg_src reg, int index )
|
||||
{
|
||||
assert(reg.File != TGSI_FILE_NULL);
|
||||
reg.Dimension = 1;
|
||||
reg.DimensionIndex = index;
|
||||
return reg;
|
||||
}
|
||||
|
||||
static INLINE struct ureg_dst
|
||||
ureg_dst( struct ureg_src src )
|
||||
{
|
||||
|
|
@ -792,13 +816,14 @@ ureg_src( struct ureg_dst dst )
|
|||
src.SwizzleY = TGSI_SWIZZLE_Y;
|
||||
src.SwizzleZ = TGSI_SWIZZLE_Z;
|
||||
src.SwizzleW = TGSI_SWIZZLE_W;
|
||||
src.Pad = 0;
|
||||
src.Indirect = dst.Indirect;
|
||||
src.IndirectIndex = dst.IndirectIndex;
|
||||
src.IndirectSwizzle = dst.IndirectSwizzle;
|
||||
src.Absolute = 0;
|
||||
src.Index = dst.Index;
|
||||
src.Negate = 0;
|
||||
src.Dimension = 0;
|
||||
src.DimensionIndex = 0;
|
||||
|
||||
return src;
|
||||
}
|
||||
|
|
@ -837,13 +862,14 @@ ureg_src_undef( void )
|
|||
src.SwizzleY = 0;
|
||||
src.SwizzleZ = 0;
|
||||
src.SwizzleW = 0;
|
||||
src.Pad = 0;
|
||||
src.Indirect = 0;
|
||||
src.IndirectIndex = 0;
|
||||
src.IndirectSwizzle = 0;
|
||||
src.Absolute = 0;
|
||||
src.Index = 0;
|
||||
src.Negate = 0;
|
||||
src.Dimension = 0;
|
||||
src.DimensionIndex = 0;
|
||||
|
||||
return src;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,12 +44,19 @@
|
|||
#include "pipe/p_format.h"
|
||||
#include "pipe/p_state.h"
|
||||
|
||||
enum translate_element_type {
|
||||
TRANSLATE_ELEMENT_NORMAL,
|
||||
TRANSLATE_ELEMENT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct translate_element
|
||||
{
|
||||
enum translate_element_type type;
|
||||
enum pipe_format input_format;
|
||||
enum pipe_format output_format;
|
||||
unsigned input_buffer:8;
|
||||
unsigned input_offset:24;
|
||||
unsigned instance_divisor;
|
||||
unsigned output_offset;
|
||||
};
|
||||
|
||||
|
|
@ -74,11 +81,13 @@ struct translate {
|
|||
void (PIPE_CDECL *run_elts)( struct translate *,
|
||||
const unsigned *elts,
|
||||
unsigned count,
|
||||
unsigned instance_id,
|
||||
void *output_buffer);
|
||||
|
||||
void (PIPE_CDECL *run)( struct translate *,
|
||||
unsigned start,
|
||||
unsigned count,
|
||||
unsigned instance_id,
|
||||
void *output_buffer);
|
||||
};
|
||||
|
||||
|
|
@ -103,8 +112,13 @@ static INLINE int translate_keysize( const struct translate_key *key )
|
|||
static INLINE int translate_key_compare( const struct translate_key *a,
|
||||
const struct translate_key *b )
|
||||
{
|
||||
int keysize = translate_keysize(a);
|
||||
return memcmp(a, b, keysize);
|
||||
int keysize_a = translate_keysize(a);
|
||||
int keysize_b = translate_keysize(b);
|
||||
|
||||
if (keysize_a != keysize_b) {
|
||||
return keysize_a - keysize_b;
|
||||
}
|
||||
return memcmp(a, b, keysize_a);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -46,9 +46,12 @@ struct translate_generic {
|
|||
struct translate translate;
|
||||
|
||||
struct {
|
||||
enum translate_element_type type;
|
||||
|
||||
fetch_func fetch;
|
||||
unsigned buffer;
|
||||
unsigned input_offset;
|
||||
unsigned instance_divisor;
|
||||
|
||||
emit_func emit;
|
||||
unsigned output_offset;
|
||||
|
|
@ -568,6 +571,7 @@ static emit_func get_emit_func( enum pipe_format format )
|
|||
static void PIPE_CDECL generic_run_elts( struct translate *translate,
|
||||
const unsigned *elts,
|
||||
unsigned count,
|
||||
unsigned instance_id,
|
||||
void *output_buffer )
|
||||
{
|
||||
struct translate_generic *tg = translate_generic(translate);
|
||||
|
|
@ -583,13 +587,20 @@ static void PIPE_CDECL generic_run_elts( struct translate *translate,
|
|||
|
||||
for (attr = 0; attr < nr_attrs; attr++) {
|
||||
float data[4];
|
||||
|
||||
const char *src = (tg->attrib[attr].input_ptr +
|
||||
tg->attrib[attr].input_stride * elt);
|
||||
const char *src;
|
||||
|
||||
char *dst = (vert +
|
||||
tg->attrib[attr].output_offset);
|
||||
|
||||
if (tg->attrib[attr].instance_divisor) {
|
||||
src = tg->attrib[attr].input_ptr +
|
||||
tg->attrib[attr].input_stride *
|
||||
(instance_id / tg->attrib[attr].instance_divisor);
|
||||
} else {
|
||||
src = tg->attrib[attr].input_ptr +
|
||||
tg->attrib[attr].input_stride * elt;
|
||||
}
|
||||
|
||||
tg->attrib[attr].fetch( src, data );
|
||||
|
||||
if (0) debug_printf("vert %d/%d attr %d: %f %f %f %f\n",
|
||||
|
|
@ -607,6 +618,7 @@ static void PIPE_CDECL generic_run_elts( struct translate *translate,
|
|||
static void PIPE_CDECL generic_run( struct translate *translate,
|
||||
unsigned start,
|
||||
unsigned count,
|
||||
unsigned instance_id,
|
||||
void *output_buffer )
|
||||
{
|
||||
struct translate_generic *tg = translate_generic(translate);
|
||||
|
|
@ -623,13 +635,25 @@ static void PIPE_CDECL generic_run( struct translate *translate,
|
|||
for (attr = 0; attr < nr_attrs; attr++) {
|
||||
float data[4];
|
||||
|
||||
const char *src = (tg->attrib[attr].input_ptr +
|
||||
tg->attrib[attr].input_stride * elt);
|
||||
|
||||
char *dst = (vert +
|
||||
tg->attrib[attr].output_offset);
|
||||
|
||||
tg->attrib[attr].fetch( src, data );
|
||||
if (tg->attrib[attr].type == TRANSLATE_ELEMENT_NORMAL) {
|
||||
const char *src;
|
||||
|
||||
if (tg->attrib[attr].instance_divisor) {
|
||||
src = tg->attrib[attr].input_ptr +
|
||||
tg->attrib[attr].input_stride *
|
||||
(instance_id / tg->attrib[attr].instance_divisor);
|
||||
} else {
|
||||
src = tg->attrib[attr].input_ptr +
|
||||
tg->attrib[attr].input_stride * elt;
|
||||
}
|
||||
|
||||
tg->attrib[attr].fetch( src, data );
|
||||
} else {
|
||||
data[0] = (float)instance_id;
|
||||
}
|
||||
|
||||
if (0) debug_printf("vert %d attr %d: %f %f %f %f\n",
|
||||
i, attr, data[0], data[1], data[2], data[3]);
|
||||
|
|
@ -683,10 +707,12 @@ struct translate *translate_generic_create( const struct translate_key *key )
|
|||
tg->translate.run = generic_run;
|
||||
|
||||
for (i = 0; i < key->nr_elements; i++) {
|
||||
tg->attrib[i].type = key->element[i].type;
|
||||
|
||||
tg->attrib[i].fetch = get_fetch_func(key->element[i].input_format);
|
||||
tg->attrib[i].buffer = key->element[i].input_buffer;
|
||||
tg->attrib[i].input_offset = key->element[i].input_offset;
|
||||
tg->attrib[i].instance_divisor = key->element[i].instance_divisor;
|
||||
|
||||
tg->attrib[i].emit = get_emit_func(key->element[i].output_format);
|
||||
tg->attrib[i].output_offset = key->element[i].output_offset;
|
||||
|
|
|
|||
|
|
@ -49,19 +49,29 @@
|
|||
typedef void (PIPE_CDECL *run_func)( struct translate *translate,
|
||||
unsigned start,
|
||||
unsigned count,
|
||||
void *output_buffer );
|
||||
unsigned instance_id,
|
||||
void *output_buffer);
|
||||
|
||||
typedef void (PIPE_CDECL *run_elts_func)( struct translate *translate,
|
||||
const unsigned *elts,
|
||||
unsigned count,
|
||||
void *output_buffer );
|
||||
unsigned instance_id,
|
||||
void *output_buffer);
|
||||
|
||||
struct translate_buffer {
|
||||
const void *base_ptr;
|
||||
unsigned stride;
|
||||
void *ptr; /* updated per vertex */
|
||||
};
|
||||
|
||||
struct translate_buffer_varient {
|
||||
unsigned buffer_index;
|
||||
unsigned instance_divisor;
|
||||
void *ptr; /* updated either per vertex or per instance */
|
||||
};
|
||||
|
||||
|
||||
#define ELEMENT_BUFFER_INSTANCE_ID 1001
|
||||
|
||||
|
||||
struct translate_sse {
|
||||
struct translate translate;
|
||||
|
|
@ -81,6 +91,16 @@ struct translate_sse {
|
|||
struct translate_buffer buffer[PIPE_MAX_ATTRIBS];
|
||||
unsigned nr_buffers;
|
||||
|
||||
/* Multiple buffer varients can map to a single buffer. */
|
||||
struct translate_buffer_varient buffer_varient[PIPE_MAX_ATTRIBS];
|
||||
unsigned nr_buffer_varients;
|
||||
|
||||
/* Multiple elements can map to a single buffer varient. */
|
||||
unsigned element_to_buffer_varient[PIPE_MAX_ATTRIBS];
|
||||
|
||||
boolean use_instancing;
|
||||
unsigned instance_id;
|
||||
|
||||
run_func gen_run;
|
||||
run_elts_func gen_run_elts;
|
||||
|
||||
|
|
@ -359,32 +379,61 @@ static boolean init_inputs( struct translate_sse *p,
|
|||
boolean linear )
|
||||
{
|
||||
unsigned i;
|
||||
if (linear) {
|
||||
for (i = 0; i < p->nr_buffers; i++) {
|
||||
struct x86_reg buf_stride = x86_make_disp(p->machine_EDX,
|
||||
get_offset(p, &p->buffer[i].stride));
|
||||
struct x86_reg buf_ptr = x86_make_disp(p->machine_EDX,
|
||||
get_offset(p, &p->buffer[i].ptr));
|
||||
struct x86_reg buf_base_ptr = x86_make_disp(p->machine_EDX,
|
||||
get_offset(p, &p->buffer[i].base_ptr));
|
||||
struct x86_reg elt = p->idx_EBX;
|
||||
struct x86_reg tmp = p->tmp_EAX;
|
||||
struct x86_reg instance_id = x86_make_disp(p->machine_EDX,
|
||||
get_offset(p, &p->instance_id));
|
||||
|
||||
for (i = 0; i < p->nr_buffer_varients; i++) {
|
||||
struct translate_buffer_varient *varient = &p->buffer_varient[i];
|
||||
struct translate_buffer *buffer = &p->buffer[varient->buffer_index];
|
||||
|
||||
if (linear || varient->instance_divisor) {
|
||||
struct x86_reg buf_stride = x86_make_disp(p->machine_EDX,
|
||||
get_offset(p, &buffer->stride));
|
||||
struct x86_reg buf_ptr = x86_make_disp(p->machine_EDX,
|
||||
get_offset(p, &varient->ptr));
|
||||
struct x86_reg buf_base_ptr = x86_make_disp(p->machine_EDX,
|
||||
get_offset(p, &buffer->base_ptr));
|
||||
struct x86_reg elt = p->idx_EBX;
|
||||
struct x86_reg tmp_EAX = p->tmp_EAX;
|
||||
|
||||
/* Calculate pointer to first attrib:
|
||||
* base_ptr + stride * index, where index depends on instance divisor
|
||||
*/
|
||||
x86_mov(p->func, tmp, buf_stride);
|
||||
x86_imul(p->func, tmp, elt);
|
||||
x86_add(p->func, tmp, buf_base_ptr);
|
||||
if (varient->instance_divisor) {
|
||||
/* Our index is instance ID divided by instance divisor.
|
||||
*/
|
||||
x86_mov(p->func, tmp_EAX, instance_id);
|
||||
|
||||
if (varient->instance_divisor != 1) {
|
||||
struct x86_reg tmp_EDX = p->machine_EDX;
|
||||
struct x86_reg tmp_ECX = p->outbuf_ECX;
|
||||
|
||||
/* TODO: Add x86_shr() to rtasm and use it whenever
|
||||
* instance divisor is power of two.
|
||||
*/
|
||||
|
||||
x86_push(p->func, tmp_EDX);
|
||||
x86_push(p->func, tmp_ECX);
|
||||
x86_xor(p->func, tmp_EDX, tmp_EDX);
|
||||
x86_mov_reg_imm(p->func, tmp_ECX, varient->instance_divisor);
|
||||
x86_div(p->func, tmp_ECX); /* EAX = EDX:EAX / ECX */
|
||||
x86_pop(p->func, tmp_ECX);
|
||||
x86_pop(p->func, tmp_EDX);
|
||||
}
|
||||
} else {
|
||||
x86_mov(p->func, tmp_EAX, elt);
|
||||
}
|
||||
x86_imul(p->func, tmp_EAX, buf_stride);
|
||||
x86_add(p->func, tmp_EAX, buf_base_ptr);
|
||||
|
||||
|
||||
/* In the linear case, keep the buffer pointer instead of the
|
||||
* index number.
|
||||
*/
|
||||
if (p->nr_buffers == 1)
|
||||
x86_mov( p->func, elt, tmp );
|
||||
if (linear && p->nr_buffer_varients == 1)
|
||||
x86_mov(p->func, elt, tmp_EAX);
|
||||
else
|
||||
x86_mov( p->func, buf_ptr, tmp );
|
||||
x86_mov(p->func, buf_ptr, tmp_EAX);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -394,31 +443,36 @@ static boolean init_inputs( struct translate_sse *p,
|
|||
|
||||
static struct x86_reg get_buffer_ptr( struct translate_sse *p,
|
||||
boolean linear,
|
||||
unsigned buf_idx,
|
||||
unsigned var_idx,
|
||||
struct x86_reg elt )
|
||||
{
|
||||
if (linear && p->nr_buffers == 1) {
|
||||
if (var_idx == ELEMENT_BUFFER_INSTANCE_ID) {
|
||||
return x86_make_disp(p->machine_EDX,
|
||||
get_offset(p, &p->instance_id));
|
||||
}
|
||||
if (linear && p->nr_buffer_varients == 1) {
|
||||
return p->idx_EBX;
|
||||
}
|
||||
else if (linear) {
|
||||
else if (linear || p->buffer_varient[var_idx].instance_divisor) {
|
||||
struct x86_reg ptr = p->tmp_EAX;
|
||||
struct x86_reg buf_ptr =
|
||||
x86_make_disp(p->machine_EDX,
|
||||
get_offset(p, &p->buffer[buf_idx].ptr));
|
||||
get_offset(p, &p->buffer_varient[var_idx].ptr));
|
||||
|
||||
x86_mov(p->func, ptr, buf_ptr);
|
||||
return ptr;
|
||||
}
|
||||
else {
|
||||
struct x86_reg ptr = p->tmp_EAX;
|
||||
const struct translate_buffer_varient *varient = &p->buffer_varient[var_idx];
|
||||
|
||||
struct x86_reg buf_stride =
|
||||
x86_make_disp(p->machine_EDX,
|
||||
get_offset(p, &p->buffer[buf_idx].stride));
|
||||
get_offset(p, &p->buffer[varient->buffer_index].stride));
|
||||
|
||||
struct x86_reg buf_base_ptr =
|
||||
x86_make_disp(p->machine_EDX,
|
||||
get_offset(p, &p->buffer[buf_idx].base_ptr));
|
||||
get_offset(p, &p->buffer[varient->buffer_index].base_ptr));
|
||||
|
||||
|
||||
|
||||
|
|
@ -436,28 +490,33 @@ static struct x86_reg get_buffer_ptr( struct translate_sse *p,
|
|||
static boolean incr_inputs( struct translate_sse *p,
|
||||
boolean linear )
|
||||
{
|
||||
if (linear && p->nr_buffers == 1) {
|
||||
if (linear && p->nr_buffer_varients == 1) {
|
||||
struct x86_reg stride = x86_make_disp(p->machine_EDX,
|
||||
get_offset(p, &p->buffer[0].stride));
|
||||
|
||||
x86_add(p->func, p->idx_EBX, stride);
|
||||
sse_prefetchnta(p->func, x86_make_disp(p->idx_EBX, 192));
|
||||
if (p->buffer_varient[0].instance_divisor == 0) {
|
||||
x86_add(p->func, p->idx_EBX, stride);
|
||||
sse_prefetchnta(p->func, x86_make_disp(p->idx_EBX, 192));
|
||||
}
|
||||
}
|
||||
else if (linear) {
|
||||
unsigned i;
|
||||
|
||||
/* Is this worthwhile??
|
||||
*/
|
||||
for (i = 0; i < p->nr_buffers; i++) {
|
||||
for (i = 0; i < p->nr_buffer_varients; i++) {
|
||||
struct translate_buffer_varient *varient = &p->buffer_varient[i];
|
||||
struct x86_reg buf_ptr = x86_make_disp(p->machine_EDX,
|
||||
get_offset(p, &p->buffer[i].ptr));
|
||||
get_offset(p, &varient->ptr));
|
||||
struct x86_reg buf_stride = x86_make_disp(p->machine_EDX,
|
||||
get_offset(p, &p->buffer[i].stride));
|
||||
get_offset(p, &p->buffer[varient->buffer_index].stride));
|
||||
|
||||
x86_mov(p->func, p->tmp_EAX, buf_ptr);
|
||||
x86_add(p->func, p->tmp_EAX, buf_stride);
|
||||
if (i == 0) sse_prefetchnta(p->func, x86_make_disp(p->tmp_EAX, 192));
|
||||
x86_mov(p->func, buf_ptr, p->tmp_EAX);
|
||||
if (varient->instance_divisor == 0) {
|
||||
x86_mov(p->func, p->tmp_EAX, buf_ptr);
|
||||
x86_add(p->func, p->tmp_EAX, buf_stride);
|
||||
if (i == 0) sse_prefetchnta(p->func, x86_make_disp(p->tmp_EAX, 192));
|
||||
x86_mov(p->func, buf_ptr, p->tmp_EAX);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
@ -514,7 +573,18 @@ static boolean build_vertex_emit( struct translate_sse *p,
|
|||
x86_mov(p->func, p->machine_EDX, x86_fn_arg(p->func, 1));
|
||||
x86_mov(p->func, p->idx_EBX, x86_fn_arg(p->func, 2));
|
||||
x86_mov(p->func, p->count_ESI, x86_fn_arg(p->func, 3));
|
||||
x86_mov(p->func, p->outbuf_ECX, x86_fn_arg(p->func, 4));
|
||||
x86_mov(p->func, p->outbuf_ECX, x86_fn_arg(p->func, 5));
|
||||
|
||||
/* Load instance ID.
|
||||
*/
|
||||
if (p->use_instancing) {
|
||||
x86_mov(p->func,
|
||||
p->tmp_EAX,
|
||||
x86_fn_arg(p->func, 4));
|
||||
x86_mov(p->func,
|
||||
x86_make_disp(p->machine_EDX, get_offset(p, &p->instance_id)),
|
||||
p->tmp_EAX);
|
||||
}
|
||||
|
||||
/* Get vertex count, compare to zero
|
||||
*/
|
||||
|
|
@ -531,17 +601,18 @@ static boolean build_vertex_emit( struct translate_sse *p,
|
|||
label = x86_get_label(p->func);
|
||||
{
|
||||
struct x86_reg elt = linear ? p->idx_EBX : x86_deref(p->idx_EBX);
|
||||
int last_vb = -1;
|
||||
int last_varient = -1;
|
||||
struct x86_reg vb;
|
||||
|
||||
for (j = 0; j < p->translate.key.nr_elements; j++) {
|
||||
const struct translate_element *a = &p->translate.key.element[j];
|
||||
unsigned varient = p->element_to_buffer_varient[j];
|
||||
|
||||
/* Figure out source pointer address:
|
||||
*/
|
||||
if (a->input_buffer != last_vb) {
|
||||
last_vb = a->input_buffer;
|
||||
vb = get_buffer_ptr(p, linear, a->input_buffer, elt);
|
||||
if (varient != last_varient) {
|
||||
last_varient = varient;
|
||||
vb = get_buffer_ptr(p, linear, varient, elt);
|
||||
}
|
||||
|
||||
if (!translate_attr( p, a,
|
||||
|
|
@ -624,6 +695,7 @@ static void translate_sse_release( struct translate *translate )
|
|||
static void PIPE_CDECL translate_sse_run_elts( struct translate *translate,
|
||||
const unsigned *elts,
|
||||
unsigned count,
|
||||
unsigned instance_id,
|
||||
void *output_buffer )
|
||||
{
|
||||
struct translate_sse *p = (struct translate_sse *)translate;
|
||||
|
|
@ -631,12 +703,14 @@ static void PIPE_CDECL translate_sse_run_elts( struct translate *translate,
|
|||
p->gen_run_elts( translate,
|
||||
elts,
|
||||
count,
|
||||
output_buffer );
|
||||
instance_id,
|
||||
output_buffer);
|
||||
}
|
||||
|
||||
static void PIPE_CDECL translate_sse_run( struct translate *translate,
|
||||
unsigned start,
|
||||
unsigned count,
|
||||
unsigned instance_id,
|
||||
void *output_buffer )
|
||||
{
|
||||
struct translate_sse *p = (struct translate_sse *)translate;
|
||||
|
|
@ -644,7 +718,8 @@ static void PIPE_CDECL translate_sse_run( struct translate *translate,
|
|||
p->gen_run( translate,
|
||||
start,
|
||||
count,
|
||||
output_buffer );
|
||||
instance_id,
|
||||
output_buffer);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -666,8 +741,37 @@ struct translate *translate_sse2_create( const struct translate_key *key )
|
|||
p->translate.run_elts = translate_sse_run_elts;
|
||||
p->translate.run = translate_sse_run;
|
||||
|
||||
for (i = 0; i < key->nr_elements; i++)
|
||||
p->nr_buffers = MAX2( p->nr_buffers, key->element[i].input_buffer + 1 );
|
||||
for (i = 0; i < key->nr_elements; i++) {
|
||||
if (key->element[i].type == TRANSLATE_ELEMENT_NORMAL) {
|
||||
unsigned j;
|
||||
|
||||
p->nr_buffers = MAX2(p->nr_buffers, key->element[i].input_buffer + 1);
|
||||
|
||||
if (key->element[i].instance_divisor) {
|
||||
p->use_instancing = TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Map vertex element to vertex buffer varient.
|
||||
*/
|
||||
for (j = 0; j < p->nr_buffer_varients; j++) {
|
||||
if (p->buffer_varient[j].buffer_index == key->element[i].input_buffer &&
|
||||
p->buffer_varient[j].instance_divisor == key->element[i].instance_divisor) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j == p->nr_buffer_varients) {
|
||||
p->buffer_varient[j].buffer_index = key->element[i].input_buffer;
|
||||
p->buffer_varient[j].instance_divisor = key->element[i].instance_divisor;
|
||||
p->nr_buffer_varients++;
|
||||
}
|
||||
p->element_to_buffer_varient[i] = j;
|
||||
} else {
|
||||
assert(key->element[i].type == TRANSLATE_ELEMENT_INSTANCE_ID);
|
||||
|
||||
p->element_to_buffer_varient[i] = ELEMENT_BUFFER_INSTANCE_ID;
|
||||
}
|
||||
}
|
||||
|
||||
if (0) debug_printf("nr_buffers: %d\n", p->nr_buffers);
|
||||
|
||||
|
|
|
|||
|
|
@ -163,6 +163,7 @@ struct blitter_context *util_blitter_create(struct pipe_context *pipe)
|
|||
rs_state.cull_mode = PIPE_WINDING_NONE;
|
||||
rs_state.bypass_vs_clip_and_viewport = 1;
|
||||
rs_state.gl_rasterization_rules = 1;
|
||||
rs_state.flatshade = 1;
|
||||
ctx->rs_state = pipe->create_rasterizer_state(pipe, &rs_state);
|
||||
|
||||
/* fragment shaders are created on-demand */
|
||||
|
|
@ -378,9 +379,16 @@ static void blitter_set_texcoords_cube(struct blitter_context_priv *ctx,
|
|||
float t1 = y1 / (float)surf->height;
|
||||
float s2 = x2 / (float)surf->width;
|
||||
float t2 = y2 / (float)surf->height;
|
||||
const float st[4][2] = {
|
||||
{s1, t1}, {s2, t1}, {s2, t2}, {s1, t2}
|
||||
};
|
||||
float st[4][2];
|
||||
|
||||
st[0][0] = s1;
|
||||
st[0][1] = t1;
|
||||
st[1][0] = s2;
|
||||
st[1][1] = t1;
|
||||
st[2][0] = s2;
|
||||
st[2][1] = t2;
|
||||
st[3][0] = s1;
|
||||
st[3][1] = t2;
|
||||
|
||||
util_map_texcoords2d_onto_cubemap(surf->face,
|
||||
/* pointer, stride in floats */
|
||||
|
|
@ -567,45 +575,29 @@ void util_blitter_clear(struct blitter_context *blitter,
|
|||
blitter_restore_CSOs(ctx);
|
||||
}
|
||||
|
||||
void util_blitter_copy(struct blitter_context *blitter,
|
||||
struct pipe_surface *dst,
|
||||
unsigned dstx, unsigned dsty,
|
||||
struct pipe_surface *src,
|
||||
unsigned srcx, unsigned srcy,
|
||||
unsigned width, unsigned height,
|
||||
boolean ignore_stencil)
|
||||
static boolean
|
||||
is_overlap(unsigned sx1, unsigned sx2, unsigned sy1, unsigned sy2,
|
||||
unsigned dx1, unsigned dx2, unsigned dy1, unsigned dy2)
|
||||
{
|
||||
if (sx1 >= dx2 || sx2 <= dx1 || sy1 >= dy2 || sy2 <= dy1) {
|
||||
return FALSE;
|
||||
} else {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static void util_blitter_do_copy(struct blitter_context *blitter,
|
||||
struct pipe_surface *dst,
|
||||
unsigned dstx, unsigned dsty,
|
||||
struct pipe_surface *src,
|
||||
unsigned srcx, unsigned srcy,
|
||||
unsigned width, unsigned height,
|
||||
boolean is_depth)
|
||||
{
|
||||
struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
|
||||
struct pipe_context *pipe = ctx->pipe;
|
||||
struct pipe_screen *screen = pipe->screen;
|
||||
struct pipe_framebuffer_state fb_state;
|
||||
boolean is_stencil, is_depth;
|
||||
unsigned dst_tex_usage;
|
||||
|
||||
/* give up if textures are not set */
|
||||
assert(dst->texture && src->texture);
|
||||
if (!dst->texture || !src->texture)
|
||||
return;
|
||||
|
||||
is_depth = util_format_get_component_bits(src->format, UTIL_FORMAT_COLORSPACE_ZS, 0) != 0;
|
||||
is_stencil = util_format_get_component_bits(src->format, UTIL_FORMAT_COLORSPACE_ZS, 1) != 0;
|
||||
dst_tex_usage = is_depth || is_stencil ? PIPE_TEXTURE_USAGE_DEPTH_STENCIL :
|
||||
PIPE_TEXTURE_USAGE_RENDER_TARGET;
|
||||
|
||||
/* check if we can sample from and render to the surfaces */
|
||||
/* (assuming copying a stencil buffer is not possible) */
|
||||
if ((!ignore_stencil && is_stencil) ||
|
||||
!screen->is_format_supported(screen, dst->format, dst->texture->target,
|
||||
dst_tex_usage, 0) ||
|
||||
!screen->is_format_supported(screen, src->format, src->texture->target,
|
||||
PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
|
||||
util_surface_copy(pipe, FALSE, dst, dstx, dsty, src, srcx, srcy,
|
||||
width, height);
|
||||
return;
|
||||
}
|
||||
|
||||
/* check whether the states are properly saved */
|
||||
blitter_check_saved_CSOs(ctx);
|
||||
assert(blitter->saved_fb_state.nr_cbufs != ~0);
|
||||
assert(blitter->saved_num_textures != ~0);
|
||||
assert(blitter->saved_num_sampler_states != ~0);
|
||||
|
|
@ -663,6 +655,108 @@ void util_blitter_copy(struct blitter_context *blitter,
|
|||
|
||||
blitter_set_rectangle(ctx, dstx, dsty, dstx+width, dsty+height, 0);
|
||||
blitter_draw_quad(ctx);
|
||||
|
||||
}
|
||||
|
||||
static void util_blitter_overlap_copy(struct blitter_context *blitter,
|
||||
struct pipe_surface *dst,
|
||||
unsigned dstx, unsigned dsty,
|
||||
struct pipe_surface *src,
|
||||
unsigned srcx, unsigned srcy,
|
||||
unsigned width, unsigned height)
|
||||
{
|
||||
struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
|
||||
struct pipe_context *pipe = ctx->pipe;
|
||||
struct pipe_screen *screen = pipe->screen;
|
||||
|
||||
struct pipe_texture texTemp;
|
||||
struct pipe_texture *texture;
|
||||
struct pipe_surface *tex_surf;
|
||||
|
||||
/* check whether the states are properly saved */
|
||||
blitter_check_saved_CSOs(ctx);
|
||||
|
||||
memset(&texTemp, 0, sizeof(texTemp));
|
||||
texTemp.target = PIPE_TEXTURE_2D;
|
||||
texTemp.format = dst->texture->format; /* XXX verify supported by driver! */
|
||||
texTemp.last_level = 0;
|
||||
texTemp.width0 = width;
|
||||
texTemp.height0 = height;
|
||||
texTemp.depth0 = 1;
|
||||
|
||||
texture = screen->texture_create(screen, &texTemp);
|
||||
if (!texture)
|
||||
return;
|
||||
|
||||
tex_surf = screen->get_tex_surface(screen, texture, 0, 0, 0,
|
||||
PIPE_BUFFER_USAGE_GPU_READ |
|
||||
PIPE_BUFFER_USAGE_GPU_WRITE);
|
||||
|
||||
/* blit from the src to the temp */
|
||||
util_blitter_do_copy(blitter, tex_surf, 0, 0,
|
||||
src, srcx, srcy,
|
||||
width, height,
|
||||
FALSE);
|
||||
util_blitter_do_copy(blitter, dst, dstx, dsty,
|
||||
tex_surf, 0, 0,
|
||||
width, height,
|
||||
FALSE);
|
||||
pipe_surface_reference(&tex_surf, NULL);
|
||||
pipe_texture_reference(&texture, NULL);
|
||||
blitter_restore_CSOs(ctx);
|
||||
}
|
||||
|
||||
void util_blitter_copy(struct blitter_context *blitter,
|
||||
struct pipe_surface *dst,
|
||||
unsigned dstx, unsigned dsty,
|
||||
struct pipe_surface *src,
|
||||
unsigned srcx, unsigned srcy,
|
||||
unsigned width, unsigned height,
|
||||
boolean ignore_stencil)
|
||||
{
|
||||
struct blitter_context_priv *ctx = (struct blitter_context_priv*)blitter;
|
||||
struct pipe_context *pipe = ctx->pipe;
|
||||
struct pipe_screen *screen = pipe->screen;
|
||||
boolean is_stencil, is_depth;
|
||||
unsigned dst_tex_usage;
|
||||
|
||||
/* give up if textures are not set */
|
||||
assert(dst->texture && src->texture);
|
||||
if (!dst->texture || !src->texture)
|
||||
return;
|
||||
|
||||
if (dst->texture == src->texture) {
|
||||
if (is_overlap(srcx, srcx + width, srcy, srcy + height,
|
||||
dstx, dstx + width, dsty, dsty + height)) {
|
||||
util_blitter_overlap_copy(blitter, dst, dstx, dsty, src, srcx, srcy,
|
||||
width, height);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
is_depth = util_format_get_component_bits(src->format, UTIL_FORMAT_COLORSPACE_ZS, 0) != 0;
|
||||
is_stencil = util_format_get_component_bits(src->format, UTIL_FORMAT_COLORSPACE_ZS, 1) != 0;
|
||||
dst_tex_usage = is_depth || is_stencil ? PIPE_TEXTURE_USAGE_DEPTH_STENCIL :
|
||||
PIPE_TEXTURE_USAGE_RENDER_TARGET;
|
||||
|
||||
/* check if we can sample from and render to the surfaces */
|
||||
/* (assuming copying a stencil buffer is not possible) */
|
||||
if ((!ignore_stencil && is_stencil) ||
|
||||
!screen->is_format_supported(screen, dst->format, dst->texture->target,
|
||||
dst_tex_usage, 0) ||
|
||||
!screen->is_format_supported(screen, src->format, src->texture->target,
|
||||
PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
|
||||
util_surface_copy(pipe, FALSE, dst, dstx, dsty, src, srcx, srcy,
|
||||
width, height);
|
||||
return;
|
||||
}
|
||||
|
||||
/* check whether the states are properly saved */
|
||||
blitter_check_saved_CSOs(ctx);
|
||||
util_blitter_do_copy(blitter,
|
||||
dst, dstx, dsty,
|
||||
src, srcx, srcy,
|
||||
width, height, is_depth);
|
||||
blitter_restore_CSOs(ctx);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ util_draw_vertex_buffer(struct pipe_context *pipe,
|
|||
/* tell pipe about the vertex attributes */
|
||||
for (i = 0; i < num_attribs; i++) {
|
||||
velements[i].src_offset = i * 4 * sizeof(float);
|
||||
velements[i].instance_divisor = 0;
|
||||
velements[i].vertex_buffer_index = 0;
|
||||
velements[i].src_format = PIPE_FORMAT_R32G32B32A32_FLOAT;
|
||||
velements[i].nr_components = 4;
|
||||
|
|
|
|||
|
|
@ -62,10 +62,10 @@ PIPE_FORMAT_R16G16_SSCALED , array , 1, 1, s16 , s16 , , , xy01,
|
|||
PIPE_FORMAT_R16G16B16_SSCALED , array , 1, 1, s16 , s16 , s16 , , xyz1, rgb
|
||||
PIPE_FORMAT_R16G16B16A16_SSCALED , array , 1, 1, s16 , s16 , s16 , s16 , xyzw, rgb
|
||||
PIPE_FORMAT_R8_UNORM , array , 1, 1, un8 , , , , x001, rgb
|
||||
PIPE_FORMAT_R8G8_UNORM , array , 1, 1, un8 , un8 , , , xy01, rgb
|
||||
PIPE_FORMAT_R8G8B8_UNORM , array , 1, 1, un8 , un8 , un8 , , xyz1, rgb
|
||||
PIPE_FORMAT_R8G8B8A8_UNORM , array , 1, 1, un8 , un8 , un8 , un8 , xyzw, rgb
|
||||
PIPE_FORMAT_R8G8B8X8_UNORM , array , 1, 1, un8 , un8 , un8 , un8 , xyz1, rgb
|
||||
PIPE_FORMAT_R8G8_UNORM , array , 1, 1, un8 , un8 , , , yx01, rgb
|
||||
PIPE_FORMAT_R8G8B8_UNORM , array , 1, 1, un8 , un8 , un8 , , zyx1, rgb
|
||||
PIPE_FORMAT_R8G8B8A8_UNORM , array , 1, 1, un8 , un8 , un8 , un8 , wzyx, rgb
|
||||
PIPE_FORMAT_R8G8B8X8_UNORM , array , 1, 1, un8 , un8 , un8 , un8 , wzy1, rgb
|
||||
PIPE_FORMAT_R8_USCALED , array , 1, 1, u8 , , , , x001, rgb
|
||||
PIPE_FORMAT_R8G8_USCALED , array , 1, 1, u8 , u8 , , , xy01, rgb
|
||||
PIPE_FORMAT_R8G8B8_USCALED , array , 1, 1, u8 , u8 , u8 , , xyz1, rgb
|
||||
|
|
|
|||
|
|
|
@ -425,6 +425,8 @@ util_pack_z(enum pipe_format format, double z)
|
|||
if (z == 1.0)
|
||||
return 0xffffffff;
|
||||
return (uint) (z * 0xffffffff);
|
||||
case PIPE_FORMAT_Z32_FLOAT:
|
||||
return (uint)z;
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
case PIPE_FORMAT_X8Z24_UNORM:
|
||||
if (z == 1.0)
|
||||
|
|
|
|||
145
src/gallium/auxiliary/util/u_ringbuffer.c
Normal file
145
src/gallium/auxiliary/util/u_ringbuffer.c
Normal file
|
|
@ -0,0 +1,145 @@
|
|||
|
||||
#include "pipe/p_thread.h"
|
||||
#include "pipe/p_defines.h"
|
||||
#include "util/u_ringbuffer.h"
|
||||
#include "util/u_math.h"
|
||||
#include "util/u_memory.h"
|
||||
|
||||
/* Generic ringbuffer:
|
||||
*/
|
||||
struct util_ringbuffer
|
||||
{
|
||||
struct util_packet *buf;
|
||||
unsigned mask;
|
||||
|
||||
/* Can this be done with atomic variables??
|
||||
*/
|
||||
unsigned head;
|
||||
unsigned tail;
|
||||
pipe_condvar change;
|
||||
pipe_mutex mutex;
|
||||
};
|
||||
|
||||
|
||||
struct util_ringbuffer *util_ringbuffer_create( unsigned dwords )
|
||||
{
|
||||
struct util_ringbuffer *ring = CALLOC_STRUCT(util_ringbuffer);
|
||||
if (ring == NULL)
|
||||
return NULL;
|
||||
|
||||
assert(util_is_power_of_two(dwords));
|
||||
|
||||
ring->buf = MALLOC( dwords * sizeof(unsigned) );
|
||||
if (ring->buf == NULL)
|
||||
goto fail;
|
||||
|
||||
ring->mask = dwords - 1;
|
||||
|
||||
pipe_condvar_init(ring->change);
|
||||
pipe_mutex_init(ring->mutex);
|
||||
return ring;
|
||||
|
||||
fail:
|
||||
FREE(ring->buf);
|
||||
FREE(ring);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void util_ringbuffer_destroy( struct util_ringbuffer *ring )
|
||||
{
|
||||
pipe_condvar_destroy(ring->change);
|
||||
pipe_mutex_destroy(ring->mutex);
|
||||
FREE(ring->buf);
|
||||
FREE(ring);
|
||||
}
|
||||
|
||||
static INLINE unsigned util_ringbuffer_space( const struct util_ringbuffer *ring )
|
||||
{
|
||||
return (ring->tail - (ring->head + 1)) & ring->mask;
|
||||
}
|
||||
|
||||
void util_ringbuffer_enqueue( struct util_ringbuffer *ring,
|
||||
const struct util_packet *packet )
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
/* XXX: over-reliance on mutexes, etc:
|
||||
*/
|
||||
pipe_mutex_lock(ring->mutex);
|
||||
|
||||
/* Wait for free space:
|
||||
*/
|
||||
while (util_ringbuffer_space(ring) < packet->dwords)
|
||||
pipe_condvar_wait(ring->change, ring->mutex);
|
||||
|
||||
/* Copy data to ring:
|
||||
*/
|
||||
for (i = 0; i < packet->dwords; i++) {
|
||||
|
||||
/* Copy all dwords of the packet. Note we're abusing the
|
||||
* typesystem a little - we're being passed a pointer to
|
||||
* something, but probably not an array of packet structs:
|
||||
*/
|
||||
ring->buf[ring->head] = packet[i];
|
||||
ring->head++;
|
||||
ring->head &= ring->mask;
|
||||
}
|
||||
|
||||
/* Signal change:
|
||||
*/
|
||||
pipe_condvar_signal(ring->change);
|
||||
pipe_mutex_unlock(ring->mutex);
|
||||
}
|
||||
|
||||
enum pipe_error util_ringbuffer_dequeue( struct util_ringbuffer *ring,
|
||||
struct util_packet *packet,
|
||||
unsigned max_dwords,
|
||||
boolean wait )
|
||||
{
|
||||
const struct util_packet *ring_packet;
|
||||
unsigned i;
|
||||
int ret = PIPE_OK;
|
||||
|
||||
/* XXX: over-reliance on mutexes, etc:
|
||||
*/
|
||||
pipe_mutex_lock(ring->mutex);
|
||||
|
||||
/* Wait for free space:
|
||||
*/
|
||||
if (wait) {
|
||||
while (util_ringbuffer_space(ring) == 0)
|
||||
pipe_condvar_wait(ring->change, ring->mutex);
|
||||
}
|
||||
else {
|
||||
if (util_ringbuffer_space(ring) == 0) {
|
||||
ret = PIPE_ERROR_OUT_OF_MEMORY;
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
||||
ring_packet = &ring->buf[ring->tail];
|
||||
|
||||
/* Both of these are considered bugs. Raise an assert on debug builds.
|
||||
*/
|
||||
if (ring_packet->dwords > ring->mask + 1 - util_ringbuffer_space(ring) ||
|
||||
ring_packet->dwords > max_dwords) {
|
||||
assert(0);
|
||||
ret = PIPE_ERROR_BAD_INPUT;
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Copy data from ring:
|
||||
*/
|
||||
for (i = 0; i < ring_packet->dwords; i++) {
|
||||
packet[i] = ring->buf[ring->tail];
|
||||
ring->tail++;
|
||||
ring->tail &= ring->mask;
|
||||
}
|
||||
|
||||
out:
|
||||
/* Signal change:
|
||||
*/
|
||||
pipe_condvar_signal(ring->change);
|
||||
pipe_mutex_unlock(ring->mutex);
|
||||
return ret;
|
||||
}
|
||||
29
src/gallium/auxiliary/util/u_ringbuffer.h
Normal file
29
src/gallium/auxiliary/util/u_ringbuffer.h
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
|
||||
#ifndef UTIL_RINGBUFFER_H
|
||||
#define UTIL_RINGBUFFER_H
|
||||
|
||||
#include "pipe/p_compiler.h"
|
||||
#include "pipe/p_defines.h" /* only for pipe_error! */
|
||||
|
||||
/* Generic header
|
||||
*/
|
||||
struct util_packet {
|
||||
unsigned dwords:8;
|
||||
unsigned data24:24;
|
||||
};
|
||||
|
||||
struct util_ringbuffer;
|
||||
|
||||
struct util_ringbuffer *util_ringbuffer_create( unsigned dwords );
|
||||
|
||||
void util_ringbuffer_destroy( struct util_ringbuffer *ring );
|
||||
|
||||
void util_ringbuffer_enqueue( struct util_ringbuffer *ring,
|
||||
const struct util_packet *packet );
|
||||
|
||||
enum pipe_error util_ringbuffer_dequeue( struct util_ringbuffer *ring,
|
||||
struct util_packet *packet,
|
||||
unsigned max_dwords,
|
||||
boolean wait );
|
||||
|
||||
#endif
|
||||
|
|
@ -1357,7 +1357,10 @@ pipe_put_tile_rgba(struct pipe_transfer *pt,
|
|||
/*z24s8_put_tile_rgba((unsigned *) packed, w, h, p, src_stride);*/
|
||||
break;
|
||||
default:
|
||||
debug_printf("%s: unsupported format %s\n", __FUNCTION__, pf_name(format));
|
||||
util_format_write_4f(format,
|
||||
p, src_stride * sizeof(float),
|
||||
packed, util_format_get_stride(format, w),
|
||||
0, 0, w, h);
|
||||
}
|
||||
|
||||
pipe_put_tile_raw(pt, x, y, w, h, packed, 0);
|
||||
|
|
|
|||
|
|
@ -316,6 +316,7 @@ init_buffers(struct vl_compositor *c)
|
|||
pipe_buffer_unmap(c->pipe->screen, c->vertex_bufs[0].buffer);
|
||||
|
||||
c->vertex_elems[0].src_offset = 0;
|
||||
c->vertex_elems[0].instance_divisor = 0;
|
||||
c->vertex_elems[0].vertex_buffer_index = 0;
|
||||
c->vertex_elems[0].nr_components = 2;
|
||||
c->vertex_elems[0].src_format = PIPE_FORMAT_R32G32_FLOAT;
|
||||
|
|
@ -345,6 +346,7 @@ init_buffers(struct vl_compositor *c)
|
|||
pipe_buffer_unmap(c->pipe->screen, c->vertex_bufs[1].buffer);
|
||||
|
||||
c->vertex_elems[1].src_offset = 0;
|
||||
c->vertex_elems[1].instance_divisor = 0;
|
||||
c->vertex_elems[1].vertex_buffer_index = 1;
|
||||
c->vertex_elems[1].nr_components = 2;
|
||||
c->vertex_elems[1].src_format = PIPE_FORMAT_R32G32_FLOAT;
|
||||
|
|
@ -353,7 +355,7 @@ init_buffers(struct vl_compositor *c)
|
|||
* Create our vertex shader's constant buffer
|
||||
* Const buffer contains scaling and translation vectors
|
||||
*/
|
||||
c->vs_const_buf.buffer = pipe_buffer_create
|
||||
c->vs_const_buf = pipe_buffer_create
|
||||
(
|
||||
c->pipe->screen,
|
||||
1,
|
||||
|
|
@ -365,7 +367,7 @@ init_buffers(struct vl_compositor *c)
|
|||
* Create our fragment shader's constant buffer
|
||||
* Const buffer contains the color conversion matrix and bias vectors
|
||||
*/
|
||||
c->fs_const_buf.buffer = pipe_buffer_create
|
||||
c->fs_const_buf = pipe_buffer_create
|
||||
(
|
||||
c->pipe->screen,
|
||||
1,
|
||||
|
|
@ -390,8 +392,8 @@ cleanup_buffers(struct vl_compositor *c)
|
|||
for (i = 0; i < 2; ++i)
|
||||
pipe_buffer_reference(&c->vertex_bufs[i].buffer, NULL);
|
||||
|
||||
pipe_buffer_reference(&c->vs_const_buf.buffer, NULL);
|
||||
pipe_buffer_reference(&c->fs_const_buf.buffer, NULL);
|
||||
pipe_buffer_reference(&c->vs_const_buf, NULL);
|
||||
pipe_buffer_reference(&c->fs_const_buf, NULL);
|
||||
}
|
||||
|
||||
bool vl_compositor_init(struct vl_compositor *compositor, struct pipe_context *pipe)
|
||||
|
|
@ -483,13 +485,13 @@ void vl_compositor_render(struct vl_compositor *compositor,
|
|||
compositor->pipe->bind_fs_state(compositor->pipe, compositor->fragment_shader);
|
||||
compositor->pipe->set_vertex_buffers(compositor->pipe, 2, compositor->vertex_bufs);
|
||||
compositor->pipe->set_vertex_elements(compositor->pipe, 2, compositor->vertex_elems);
|
||||
compositor->pipe->set_constant_buffer(compositor->pipe, PIPE_SHADER_VERTEX, 0, &compositor->vs_const_buf);
|
||||
compositor->pipe->set_constant_buffer(compositor->pipe, PIPE_SHADER_FRAGMENT, 0, &compositor->fs_const_buf);
|
||||
compositor->pipe->set_constant_buffer(compositor->pipe, PIPE_SHADER_VERTEX, 0, compositor->vs_const_buf);
|
||||
compositor->pipe->set_constant_buffer(compositor->pipe, PIPE_SHADER_FRAGMENT, 0, compositor->fs_const_buf);
|
||||
|
||||
vs_consts = pipe_buffer_map
|
||||
(
|
||||
compositor->pipe->screen,
|
||||
compositor->vs_const_buf.buffer,
|
||||
compositor->vs_const_buf,
|
||||
PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_DISCARD
|
||||
);
|
||||
|
||||
|
|
@ -511,7 +513,7 @@ void vl_compositor_render(struct vl_compositor *compositor,
|
|||
vs_consts->src_trans.z = 0;
|
||||
vs_consts->src_trans.w = 0;
|
||||
|
||||
pipe_buffer_unmap(compositor->pipe->screen, compositor->vs_const_buf.buffer);
|
||||
pipe_buffer_unmap(compositor->pipe->screen, compositor->vs_const_buf);
|
||||
|
||||
compositor->pipe->draw_arrays(compositor->pipe, PIPE_PRIM_TRIANGLE_STRIP, 0, 4);
|
||||
compositor->pipe->flush(compositor->pipe, PIPE_FLUSH_RENDER_CACHE, fence);
|
||||
|
|
@ -525,10 +527,10 @@ void vl_compositor_set_csc_matrix(struct vl_compositor *compositor, const float
|
|||
|
||||
memcpy
|
||||
(
|
||||
pipe_buffer_map(compositor->pipe->screen, compositor->fs_const_buf.buffer, PIPE_BUFFER_USAGE_CPU_WRITE),
|
||||
pipe_buffer_map(compositor->pipe->screen, compositor->fs_const_buf, PIPE_BUFFER_USAGE_CPU_WRITE),
|
||||
mat,
|
||||
sizeof(struct fragment_shader_consts)
|
||||
);
|
||||
|
||||
pipe_buffer_unmap(compositor->pipe->screen, compositor->fs_const_buf.buffer);
|
||||
pipe_buffer_unmap(compositor->pipe->screen, compositor->fs_const_buf);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ struct vl_compositor
|
|||
struct pipe_scissor_state scissor;
|
||||
struct pipe_vertex_buffer vertex_bufs[2];
|
||||
struct pipe_vertex_element vertex_elems[2];
|
||||
struct pipe_constant_buffer vs_const_buf, fs_const_buf;
|
||||
struct pipe_buffer *vs_const_buf, *fs_const_buf;
|
||||
};
|
||||
|
||||
bool vl_compositor_init(struct vl_compositor *compositor, struct pipe_context *pipe);
|
||||
|
|
|
|||
|
|
@ -891,53 +891,61 @@ init_buffers(struct vl_mpeg12_mc_renderer *r)
|
|||
|
||||
/* Position element */
|
||||
r->vertex_elems[0].src_offset = 0;
|
||||
r->vertex_elems[0].instance_divisor = 0;
|
||||
r->vertex_elems[0].vertex_buffer_index = 0;
|
||||
r->vertex_elems[0].nr_components = 2;
|
||||
r->vertex_elems[0].src_format = PIPE_FORMAT_R32G32_FLOAT;
|
||||
|
||||
/* Luma, texcoord element */
|
||||
r->vertex_elems[1].src_offset = sizeof(struct vertex2f);
|
||||
r->vertex_elems[1].instance_divisor = 0;
|
||||
r->vertex_elems[1].vertex_buffer_index = 0;
|
||||
r->vertex_elems[1].nr_components = 2;
|
||||
r->vertex_elems[1].src_format = PIPE_FORMAT_R32G32_FLOAT;
|
||||
|
||||
/* Chroma Cr texcoord element */
|
||||
r->vertex_elems[2].src_offset = sizeof(struct vertex2f) * 2;
|
||||
r->vertex_elems[2].instance_divisor = 0;
|
||||
r->vertex_elems[2].vertex_buffer_index = 0;
|
||||
r->vertex_elems[2].nr_components = 2;
|
||||
r->vertex_elems[2].src_format = PIPE_FORMAT_R32G32_FLOAT;
|
||||
|
||||
/* Chroma Cb texcoord element */
|
||||
r->vertex_elems[3].src_offset = sizeof(struct vertex2f) * 3;
|
||||
r->vertex_elems[3].instance_divisor = 0;
|
||||
r->vertex_elems[3].vertex_buffer_index = 0;
|
||||
r->vertex_elems[3].nr_components = 2;
|
||||
r->vertex_elems[3].src_format = PIPE_FORMAT_R32G32_FLOAT;
|
||||
|
||||
/* First ref surface top field texcoord element */
|
||||
r->vertex_elems[4].src_offset = 0;
|
||||
r->vertex_elems[4].instance_divisor = 0;
|
||||
r->vertex_elems[4].vertex_buffer_index = 1;
|
||||
r->vertex_elems[4].nr_components = 2;
|
||||
r->vertex_elems[4].src_format = PIPE_FORMAT_R32G32_FLOAT;
|
||||
|
||||
/* First ref surface bottom field texcoord element */
|
||||
r->vertex_elems[5].src_offset = sizeof(struct vertex2f);
|
||||
r->vertex_elems[5].instance_divisor = 0;
|
||||
r->vertex_elems[5].vertex_buffer_index = 1;
|
||||
r->vertex_elems[5].nr_components = 2;
|
||||
r->vertex_elems[5].src_format = PIPE_FORMAT_R32G32_FLOAT;
|
||||
|
||||
/* Second ref surface top field texcoord element */
|
||||
r->vertex_elems[6].src_offset = 0;
|
||||
r->vertex_elems[6].instance_divisor = 0;
|
||||
r->vertex_elems[6].vertex_buffer_index = 2;
|
||||
r->vertex_elems[6].nr_components = 2;
|
||||
r->vertex_elems[6].src_format = PIPE_FORMAT_R32G32_FLOAT;
|
||||
|
||||
/* Second ref surface bottom field texcoord element */
|
||||
r->vertex_elems[7].src_offset = sizeof(struct vertex2f);
|
||||
r->vertex_elems[7].instance_divisor = 0;
|
||||
r->vertex_elems[7].vertex_buffer_index = 2;
|
||||
r->vertex_elems[7].nr_components = 2;
|
||||
r->vertex_elems[7].src_format = PIPE_FORMAT_R32G32_FLOAT;
|
||||
|
||||
r->vs_const_buf.buffer = pipe_buffer_create
|
||||
r->vs_const_buf = pipe_buffer_create
|
||||
(
|
||||
r->pipe->screen,
|
||||
DEFAULT_BUF_ALIGNMENT,
|
||||
|
|
@ -945,7 +953,7 @@ init_buffers(struct vl_mpeg12_mc_renderer *r)
|
|||
sizeof(struct vertex_shader_consts)
|
||||
);
|
||||
|
||||
r->fs_const_buf.buffer = pipe_buffer_create
|
||||
r->fs_const_buf = pipe_buffer_create
|
||||
(
|
||||
r->pipe->screen,
|
||||
DEFAULT_BUF_ALIGNMENT,
|
||||
|
|
@ -954,11 +962,11 @@ init_buffers(struct vl_mpeg12_mc_renderer *r)
|
|||
|
||||
memcpy
|
||||
(
|
||||
pipe_buffer_map(r->pipe->screen, r->fs_const_buf.buffer, PIPE_BUFFER_USAGE_CPU_WRITE),
|
||||
pipe_buffer_map(r->pipe->screen, r->fs_const_buf, PIPE_BUFFER_USAGE_CPU_WRITE),
|
||||
&fs_consts, sizeof(struct fragment_shader_consts)
|
||||
);
|
||||
|
||||
pipe_buffer_unmap(r->pipe->screen, r->fs_const_buf.buffer);
|
||||
pipe_buffer_unmap(r->pipe->screen, r->fs_const_buf);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -970,8 +978,8 @@ cleanup_buffers(struct vl_mpeg12_mc_renderer *r)
|
|||
|
||||
assert(r);
|
||||
|
||||
pipe_buffer_reference(&r->vs_const_buf.buffer, NULL);
|
||||
pipe_buffer_reference(&r->fs_const_buf.buffer, NULL);
|
||||
pipe_buffer_reference(&r->vs_const_buf, NULL);
|
||||
pipe_buffer_reference(&r->fs_const_buf, NULL);
|
||||
|
||||
for (i = 0; i < 3; ++i)
|
||||
pipe_buffer_reference(&r->vertex_bufs.all[i].buffer, NULL);
|
||||
|
|
@ -1284,19 +1292,19 @@ flush(struct vl_mpeg12_mc_renderer *r)
|
|||
|
||||
vs_consts = pipe_buffer_map
|
||||
(
|
||||
r->pipe->screen, r->vs_const_buf.buffer,
|
||||
r->pipe->screen, r->vs_const_buf,
|
||||
PIPE_BUFFER_USAGE_CPU_WRITE | PIPE_BUFFER_USAGE_DISCARD
|
||||
);
|
||||
|
||||
vs_consts->denorm.x = r->surface->width0;
|
||||
vs_consts->denorm.y = r->surface->height0;
|
||||
|
||||
pipe_buffer_unmap(r->pipe->screen, r->vs_const_buf.buffer);
|
||||
pipe_buffer_unmap(r->pipe->screen, r->vs_const_buf);
|
||||
|
||||
r->pipe->set_constant_buffer(r->pipe, PIPE_SHADER_VERTEX, 0,
|
||||
&r->vs_const_buf);
|
||||
r->vs_const_buf);
|
||||
r->pipe->set_constant_buffer(r->pipe, PIPE_SHADER_FRAGMENT, 0,
|
||||
&r->fs_const_buf);
|
||||
r->fs_const_buf);
|
||||
|
||||
if (num_macroblocks[MACROBLOCK_TYPE_INTRA] > 0) {
|
||||
r->pipe->set_vertex_buffers(r->pipe, 1, r->vertex_bufs.all);
|
||||
|
|
|
|||
|
|
@ -63,8 +63,8 @@ struct vl_mpeg12_mc_renderer
|
|||
|
||||
struct pipe_viewport_state viewport;
|
||||
struct pipe_scissor_state scissor;
|
||||
struct pipe_constant_buffer vs_const_buf;
|
||||
struct pipe_constant_buffer fs_const_buf;
|
||||
struct pipe_buffer *vs_const_buf;
|
||||
struct pipe_buffer *fs_const_buf;
|
||||
struct pipe_framebuffer_state fb_state;
|
||||
struct pipe_vertex_element vertex_elems[8];
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue