From 48f0543b39969694626bbeeca0b69b184db315f6 Mon Sep 17 00:00:00 2001 From: Robert Noland Date: Fri, 10 Apr 2009 11:41:27 -0500 Subject: Build dri drivers for powerpc and sparc on FreeBSD. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 67994274f3..ce7507fd29 100644 --- a/configure.ac +++ b/configure.ac @@ -389,7 +389,7 @@ linux*) ;; *freebsd* | dragonfly*) case "$host_cpu" in - i*86|x86_64) default_driver="dri";; + i*86|x86_64|powerpc*|sparc*) default_driver="dri";; esac ;; esac -- cgit v1.2.3 From 373e6716830c52377374458a3c655f32ae84b54f Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sat, 18 Apr 2009 23:13:56 +0100 Subject: autoconf: Build gallium softpipe when driver=xlib --- configure.ac | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index ce7507fd29..c4fe8a1a5f 100644 --- a/configure.ac +++ b/configure.ac @@ -424,12 +424,13 @@ GALLIUM_STATE_TRACKERS_DIRS="" case "$mesa_driver" in xlib) DRIVER_DIRS="x11" + GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS xlib" ;; dri) SRC_DIRS="glx/x11 $SRC_DIRS" DRIVER_DIRS="dri" WINDOW_SYSTEM="dri" - GALLIUM_WINSYS_DIRS="drm $GALLIUM_WINSYS_DIRS" + GALLIUM_WINSYS_DIRS="$GALLIUM_WINSYS_DIRS drm" ;; osmesa) DRIVER_DIRS="osmesa" @@ -1107,6 +1108,9 @@ no) yes) # look at what else is built case "$mesa_driver" in + xlib) + GALLIUM_STATE_TRACKERS_DIRS=glx + ;; dri) GALLIUM_STATE_TRACKERS_DIRS=egl ;; -- cgit v1.2.3 From 6bd4bc785e587ac86231349648595fc0e136f10d Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Tue, 21 Apr 2009 18:32:42 +0100 Subject: Update GALLIUM_AUXILIARY_DIRS in configure.ac to match configs/default. --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index c4fe8a1a5f..8412cdce7f 100644 --- a/configure.ac +++ b/configure.ac @@ -417,7 +417,7 @@ WINDOW_SYSTEM="" GALLIUM_DIRS="auxiliary drivers state_trackers" GALLIUM_WINSYS_DIRS="" GALLIUM_WINSYS_DRM_DIRS="" -GALLIUM_AUXILIARY_DIRS="draw translate cso_cache pipebuffer tgsi sct rtasm util" +GALLIUM_AUXILIARY_DIRS="draw translate cso_cache pipebuffer tgsi sct rtasm util indices" GALLIUM_DRIVERS_DIRS="softpipe failover trace" GALLIUM_STATE_TRACKERS_DIRS="" -- cgit v1.2.3 From d18dd6ad11268c7a6c2835f4f5fa999c735da300 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Thu, 23 Apr 2009 05:43:22 -0700 Subject: GNU/Hurd fixes Here is a couple of fixes for GNU/Hurd: - dri_interface.h: no libdrm support either. - configure.ac: - GNU/Hurd is a GNU OS with _GNU_SOURCE and PTHREADS. - GNU needs a couple of flags like other OSes Signed-off-by: Dan Nicholson --- configure.ac | 6 +++++- include/GL/internal/dri_interface.h | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 8412cdce7f..7b07f0fa7c 100644 --- a/configure.ac +++ b/configure.ac @@ -87,7 +87,7 @@ dnl Compiler macros DEFINES="" AC_SUBST([DEFINES]) case "$host_os" in -linux*|*-gnu*) +linux*|*-gnu*|gnu*) DEFINES="$DEFINES -D_GNU_SOURCE -DPTHREADS" ;; solaris*) @@ -742,6 +742,10 @@ if test "$mesa_driver" = dri; then unichrome savage sis swrast" fi ;; + gnu*) + DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER" + DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING -DHAVE_ALIAS" + ;; solaris*) DEFINES="$DEFINES -DUSE_EXTERNAL_DXTN_LIB=1 -DIN_DRI_DRIVER" DEFINES="$DEFINES -DGLX_INDIRECT_RENDERING" diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index bfa8a33b3c..910c9166b5 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -41,7 +41,7 @@ #define DRI_INTERFACE_H /* For archs with no drm.h */ -#if !defined(__APPLE__) && !defined(__CYGWIN__) +#if !defined(__APPLE__) && !defined(__CYGWIN__) && !defined(__GNU__) #include #else typedef unsigned int drm_context_t; -- cgit v1.2.3 From 356f311c4a3ee91a4afe33d210dd4c5fdc897ea3 Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Wed, 29 Apr 2009 06:49:27 -0700 Subject: autoconf: Clean up some m4 usage m4_fatal is equivalent to m4_errprint + m4_exit. --- configure.ac | 22 +++++++--------------- 1 file changed, 7 insertions(+), 15 deletions(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 7b07f0fa7c..154f6e6352 100644 --- a/configure.ac +++ b/configure.ac @@ -5,12 +5,8 @@ AC_PREREQ([2.59]) dnl Versioning - scrape the version from configs/default m4_define([mesa_version], [m4_esyscmd([${MAKE-make} -s -f bin/version.mk version | tr -d '\n'])]) -m4_ifval(mesa_version,[],[ - m4_errprint([Error: Failed to get the Mesa version from the output of - running `make -f bin/version.mk version' -]) - m4_exit([1]) -]) +m4_ifval(mesa_version,, + [m4_fatal([Failed to get the Mesa version from `make -f bin/version.mk version`])]) dnl Tell the user about autoconf.html in the --help output m4_divert_once([HELP_END], [ @@ -58,15 +54,11 @@ fi AC_SUBST([MKDEP_OPTIONS]) dnl Make sure the pkg-config macros are defined -m4_ifdef([PKG_PROG_PKG_CONFIG],[],[ - m4_errprint([Error: Could not locate the pkg-config autoconf macros. - These are usually located in /usr/share/aclocal/pkg.m4. If your - macros are in a different location, try setting the environment - variable ACLOCAL="aclocal -I/other/macro/dir" before running - autoreconf. -]) - m4_exit([1]) -]) +m4_ifndef([PKG_PROG_PKG_CONFIG], + [m4_fatal([Could not locate the pkg-config autoconf macros. + These are usually located in /usr/share/aclocal/pkg.m4. If your macros + are in a different location, try setting the environment variable + ACLOCAL="aclocal -I/other/macro/dir" before running autoreconf.])]) PKG_PROG_PKG_CONFIG() dnl LIB_DIR - library basename -- cgit v1.2.3 From 66f978625685d83b04c32b19b62c3cb8c0d25f74 Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Wed, 29 Apr 2009 12:11:43 -0700 Subject: autoconf: Add switch for optional EGL EGL doesn't build on all platforms, so allow people to opt out. --- configure.ac | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 154f6e6352..8110e0f869 100644 --- a/configure.ac +++ b/configure.ac @@ -403,7 +403,7 @@ esac dnl dnl Driver specific build directories dnl -SRC_DIRS="mesa egl glew" +SRC_DIRS="mesa glew" GLU_DIRS="sgi" WINDOW_SYSTEM="" GALLIUM_DIRS="auxiliary drivers state_trackers" @@ -857,14 +857,23 @@ AC_SUBST([OSMESA_PC_LIB_PRIV]) dnl dnl EGL configuration dnl -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" +AC_ARG_ENABLE([egl], + [AS_HELP_STRING([--disable-egl], + [disable EGL library @<:@default=enabled@:>@])], + [enable_egl="$enableval"], + [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" + fi + EGL_LIB_DEPS="$EGL_LIB_DEPS $DLOPEN_LIBS" fi -EGL_LIB_DEPS="$EGL_LIB_DEPS $DLOPEN_LIBS" AC_SUBST([EGL_LIB_DEPS]) dnl @@ -1108,7 +1117,7 @@ yes) GALLIUM_STATE_TRACKERS_DIRS=glx ;; dri) - GALLIUM_STATE_TRACKERS_DIRS=egl + test "x$enable_egl" = xyes && GALLIUM_STATE_TRACKERS_DIRS=egl ;; esac ;; @@ -1118,6 +1127,10 @@ yes) for tracker in $state_trackers; do test -d "$srcdir/src/gallium/state_trackers/$tracker" || \ AC_MSG_ERROR([state tracker '$tracker' doesn't exist]) + + if test "$tracker" = egl && test "x$enable_egl" != xyes; then + AC_MSG_ERROR([cannot build egl state tracker without EGL library]) + fi done GALLIUM_STATE_TRACKERS_DIRS="$state_trackers" ;; @@ -1233,6 +1246,7 @@ dnl Libraries echo "" echo " Shared libs: $enable_shared" echo " Static libs: $enable_static" +echo " EGL: $enable_egl" echo " GLU: $enable_glu" echo " GLw: $enable_glw (Motif: $enable_motif)" echo " glut: $enable_glut" -- cgit v1.2.3 From dfa4ebcbcc9c7e9e7562f73a4ddc367756623e5e Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 15 May 2009 01:07:05 +0200 Subject: rbug: Add Gallium Remote Debugger Protocol code This is the (de)marshalling and connection managment code --- configs/default | 2 +- configure.ac | 2 +- src/gallium/SConscript | 1 + src/gallium/auxiliary/rbug/Makefile | 14 + src/gallium/auxiliary/rbug/README | 21 + src/gallium/auxiliary/rbug/SConscript | 14 + src/gallium/auxiliary/rbug/rbug.h | 33 ++ src/gallium/auxiliary/rbug/rbug_connection.c | 167 +++++++ src/gallium/auxiliary/rbug/rbug_connection.h | 45 ++ src/gallium/auxiliary/rbug/rbug_context.c | 442 +++++++++++++++++++ src/gallium/auxiliary/rbug/rbug_context.h | 128 ++++++ src/gallium/auxiliary/rbug/rbug_core.c | 359 +++++++++++++++ src/gallium/auxiliary/rbug/rbug_core.h | 101 +++++ src/gallium/auxiliary/rbug/rbug_demarshal.c | 85 ++++ src/gallium/auxiliary/rbug/rbug_internal.h | 100 +++++ src/gallium/auxiliary/rbug/rbug_proto.h | 90 ++++ src/gallium/auxiliary/rbug/rbug_shader.c | 468 ++++++++++++++++++++ src/gallium/auxiliary/rbug/rbug_shader.h | 144 ++++++ src/gallium/auxiliary/rbug/rbug_texture.c | 631 +++++++++++++++++++++++++++ src/gallium/auxiliary/rbug/rbug_texture.h | 207 +++++++++ 20 files changed, 3052 insertions(+), 2 deletions(-) create mode 100644 src/gallium/auxiliary/rbug/Makefile create mode 100644 src/gallium/auxiliary/rbug/README create mode 100644 src/gallium/auxiliary/rbug/SConscript create mode 100644 src/gallium/auxiliary/rbug/rbug.h create mode 100644 src/gallium/auxiliary/rbug/rbug_connection.c create mode 100644 src/gallium/auxiliary/rbug/rbug_connection.h create mode 100644 src/gallium/auxiliary/rbug/rbug_context.c create mode 100644 src/gallium/auxiliary/rbug/rbug_context.h create mode 100644 src/gallium/auxiliary/rbug/rbug_core.c create mode 100644 src/gallium/auxiliary/rbug/rbug_core.h create mode 100644 src/gallium/auxiliary/rbug/rbug_demarshal.c create mode 100644 src/gallium/auxiliary/rbug/rbug_internal.h create mode 100644 src/gallium/auxiliary/rbug/rbug_proto.h create mode 100644 src/gallium/auxiliary/rbug/rbug_shader.c create mode 100644 src/gallium/auxiliary/rbug/rbug_shader.h create mode 100644 src/gallium/auxiliary/rbug/rbug_texture.c create mode 100644 src/gallium/auxiliary/rbug/rbug_texture.h (limited to 'configure.ac') diff --git a/configs/default b/configs/default index 9c479fccdf..d2ea3b2487 100644 --- a/configs/default +++ b/configs/default @@ -90,7 +90,7 @@ EGL_DRIVERS_DIRS = demo # Gallium directories and GALLIUM_DIRS = auxiliary drivers state_trackers -GALLIUM_AUXILIARY_DIRS = draw translate cso_cache pipebuffer tgsi sct rtasm util indices +GALLIUM_AUXILIARY_DIRS = rbug draw translate cso_cache pipebuffer tgsi sct rtasm util indices GALLIUM_AUXILIARIES = $(foreach DIR,$(GALLIUM_AUXILIARY_DIRS),$(TOP)/src/gallium/auxiliary/$(DIR)/lib$(DIR).a) GALLIUM_DRIVERS_DIRS = softpipe i915simple failover trace GALLIUM_DRIVERS = $(foreach DIR,$(GALLIUM_DRIVERS_DIRS),$(TOP)/src/gallium/drivers/$(DIR)/lib$(DIR).a) diff --git a/configure.ac b/configure.ac index 8110e0f869..24aa13a7ca 100644 --- a/configure.ac +++ b/configure.ac @@ -409,7 +409,7 @@ WINDOW_SYSTEM="" GALLIUM_DIRS="auxiliary drivers state_trackers" GALLIUM_WINSYS_DIRS="" GALLIUM_WINSYS_DRM_DIRS="" -GALLIUM_AUXILIARY_DIRS="draw translate cso_cache pipebuffer tgsi sct rtasm util indices" +GALLIUM_AUXILIARY_DIRS="rbug draw translate cso_cache pipebuffer tgsi sct rtasm util indices" GALLIUM_DRIVERS_DIRS="softpipe failover trace" GALLIUM_STATE_TRACKERS_DIRS="" diff --git a/src/gallium/SConscript b/src/gallium/SConscript index b6ceaf3edf..32b7c2980a 100644 --- a/src/gallium/SConscript +++ b/src/gallium/SConscript @@ -22,6 +22,7 @@ SConscript([ 'auxiliary/draw/SConscript', 'auxiliary/pipebuffer/SConscript', 'auxiliary/indices/SConscript', + 'auxiliary/rbug/SConscript', ]) for driver in env['drivers']: diff --git a/src/gallium/auxiliary/rbug/Makefile b/src/gallium/auxiliary/rbug/Makefile new file mode 100644 index 0000000000..cd12e8468f --- /dev/null +++ b/src/gallium/auxiliary/rbug/Makefile @@ -0,0 +1,14 @@ +TOP = ../../../.. +include $(TOP)/configs/current + +LIBNAME = rbug + +C_SOURCES = \ + rbug_connection.c \ + rbug_core.c \ + rbug_texture.c \ + rbug_context.c \ + rbug_shader.c \ + rbug_demarshal.c + +include ../../Makefile.template diff --git a/src/gallium/auxiliary/rbug/README b/src/gallium/auxiliary/rbug/README new file mode 100644 index 0000000000..33d76371de --- /dev/null +++ b/src/gallium/auxiliary/rbug/README @@ -0,0 +1,21 @@ + GALLIUM REMOTE DEBUGGING COMMON CODE + += About = + +This directory contains the common code for the Gallium 3D remote debugging +driver and clients. The code is two parts the connection managment code and +the (de)marsheller. + +The code currently uses tcp and ip4v for connections. + +Information about driver integration can be found in: + +src/gallium/drivers/trace/README + +for information about applications look in: + +progs/rbug/README + + +-- +Jakob Bornecrantz diff --git a/src/gallium/auxiliary/rbug/SConscript b/src/gallium/auxiliary/rbug/SConscript new file mode 100644 index 0000000000..4a9afb45d3 --- /dev/null +++ b/src/gallium/auxiliary/rbug/SConscript @@ -0,0 +1,14 @@ +Import('*') + +rbug = env.ConvenienceLibrary( + target = 'rbug', + source = [ + 'rbug_core.c', + 'rbug_shader.c', + 'rbug_context.c', + 'rbug_texture.c', + 'rbug_demarshal.c', + 'rbug_connection.c', + ]) + +auxiliaries.insert(0, rbug) diff --git a/src/gallium/auxiliary/rbug/rbug.h b/src/gallium/auxiliary/rbug/rbug.h new file mode 100644 index 0000000000..259bfc6c79 --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug.h @@ -0,0 +1,33 @@ +/* + * Copyright 2009 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * VMWARE AND/OR THEIR 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. + */ + +/* + * Include all for users the remote debugger protocol code. + */ + +#include "rbug/rbug_core.h" +#include "rbug/rbug_shader.h" +#include "rbug/rbug_context.h" +#include "rbug/rbug_texture.h" +#include "rbug/rbug_connection.h" diff --git a/src/gallium/auxiliary/rbug/rbug_connection.c b/src/gallium/auxiliary/rbug/rbug_connection.c new file mode 100644 index 0000000000..52acb700af --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_connection.c @@ -0,0 +1,167 @@ +/* + * Copyright 2009 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * VMWARE AND/OR THEIR 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. + */ + +#include "rbug/rbug.h" +#include "rbug/rbug_internal.h" + +#include "util/u_network.h" + +struct rbug_connection +{ + int socket; + uint32_t send_serial; + uint32_t recv_serial; + enum rbug_opcode opcode; +}; + +/** + * Create a rbug connection from a socket created with u_socket. + * + * Result: + * A new allocated connection using socket as communication path + */ +struct rbug_connection * +rbug_from_socket(int socket) +{ + struct rbug_connection *c = CALLOC_STRUCT(rbug_connection); + c->socket = socket; + return c; +} + +/** + * Free a connection, also closes socket. + */ +void +rbug_disconnect(struct rbug_connection *c) +{ + u_socket_close(c->socket); + FREE(c); +} + +/** + * Waits for a message to be fully received. + * Also returns the serial for the message, serial is not touched for replys. + * + * Result: + * demarshaled message on success, NULL on connection error + */ +struct rbug_header * +rbug_get_message(struct rbug_connection *c, uint32_t *serial) +{ + struct rbug_proto_header header; + struct rbug_header *out; + struct rbug_proto_header *data; + size_t length = 0; + size_t read = 0; + int ret; + + + ret = u_socket_peek(c->socket, &header, sizeof(header)); + if (ret <= 0) { + return NULL; + } + + length = (size_t)header.length * 4; + data = MALLOC(length); + if (!data) { + return NULL; + } + + do { + uint8_t *ptr = ((uint8_t*)data) + read; + ret = u_socket_recv(c->socket, ptr, length - read); + + if (ret <= 0) { + FREE(data); + return NULL; + } + + read += ret; + } while(read < length); + + out = rbug_demarshal(data); + if (!out) + FREE(data); + else if (serial) + *serial = c->recv_serial++; + else + c->recv_serial++; + + return out; +} + +/** + * Frees a message and associated data. + */ +void +rbug_free_header(struct rbug_header *header) +{ + if (!header) + return; + + FREE(header->__message); + FREE(header); +} + +/** + * Internal function used by rbug_send_* functions. + * + * Start sending a message. + */ +int +rbug_connection_send_start(struct rbug_connection *c, enum rbug_opcode opcode, uint32_t length) +{ + c->opcode = opcode; + return 0; +} + +/** + * Internal function used by rbug_send_* functions. + * + * Write data to the socket. + */ +int +rbug_connection_write(struct rbug_connection *c, void *to, uint32_t size) +{ + int ret = u_socket_send(c->socket, to, size); + return ret; +} + +/** + * Internal function used by rbug_send_* functions. + * + * Finish writeing data to the socket. + * Ups the send_serial and sets the serial argument if supplied. + */ +int rbug_connection_send_finish(struct rbug_connection *c, uint32_t *serial) +{ + if (c->opcode < 0) + return 0; + else if (serial) + *serial = c->send_serial++; + else + c->send_serial++; + + return 0; +} diff --git a/src/gallium/auxiliary/rbug/rbug_connection.h b/src/gallium/auxiliary/rbug/rbug_connection.h new file mode 100644 index 0000000000..1f2c9ff347 --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_connection.h @@ -0,0 +1,45 @@ +/* + * Copyright 2009 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * VMWARE AND/OR THEIR 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. + */ + +/* + * This file contains the function defentions for connection see c file for + * more comments covering function use. + */ + +#ifndef _RBUG_CONNECTION_H_ +#define _RBUG_CONNECTION_H_ + +#include "rbug/rbug_proto.h" + +struct rbug_connection * rbug_from_socket(int socket); + +void rbug_disconnect(struct rbug_connection *c); + +struct rbug_header * rbug_get_message(struct rbug_connection *c, uint32_t *serial); + +void rbug_free_header(struct rbug_header *header); + +struct rbug_header * rbug_demarshal(struct rbug_proto_header *header); + +#endif diff --git a/src/gallium/auxiliary/rbug/rbug_context.c b/src/gallium/auxiliary/rbug/rbug_context.c new file mode 100644 index 0000000000..b4fad5300d --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_context.c @@ -0,0 +1,442 @@ +/* + * Copyright 2009 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * VMWARE AND/OR THEIR 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. + */ + +/* + * This file holds the function implementation for one of the rbug extensions. + * Prototypes and declerations of functions and structs is in the same folder + * in the header file matching this file's name. + * + * The functions starting rbug_send_* encodes a call to the write format and + * sends that to the supplied connection, while functions starting with + * rbug_demarshal_* demarshal data in the wire protocol. + * + * Functions ending with _reply are replies to requests. + */ + +#include "rbug_internal.h" +#include "rbug/rbug_context.h" + +int rbug_send_context_list(struct rbug_connection *__con, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_LIST)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_CONTEXT_LIST, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_context_info(struct rbug_connection *__con, + rbug_context_t context, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(8); /* context */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_INFO)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(8, rbug_context_t, context); /* context */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_CONTEXT_INFO, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_context_block_draw(struct rbug_connection *__con, + rbug_context_t context, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(8); /* context */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_BLOCK_DRAW)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(8, rbug_context_t, context); /* context */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_CONTEXT_BLOCK_DRAW, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_context_unblock_draw(struct rbug_connection *__con, + rbug_context_t context, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(8); /* context */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_UNBLOCK_DRAW)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(8, rbug_context_t, context); /* context */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_CONTEXT_UNBLOCK_DRAW, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_context_list_reply(struct rbug_connection *__con, + uint32_t serial, + rbug_context_t *contexts, + uint32_t contexts_len, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(4); /* serial */ + LEN_ARRAY(8, contexts); /* contexts */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_LIST_REPLY)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(4, uint32_t, serial); /* serial */ + WRITE_ARRAY(8, rbug_context_t, contexts); /* contexts */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_CONTEXT_LIST_REPLY, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_context_info_reply(struct rbug_connection *__con, + uint32_t serial, + rbug_texture_t *cbufs, + uint32_t cbufs_len, + rbug_texture_t zdbuf, + uint8_t blocked, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(4); /* serial */ + LEN_ARRAY(8, cbufs); /* cbufs */ + LEN(8); /* zdbuf */ + LEN(1); /* blocked */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_CONTEXT_INFO_REPLY)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(4, uint32_t, serial); /* serial */ + WRITE_ARRAY(8, rbug_texture_t, cbufs); /* cbufs */ + WRITE(8, rbug_texture_t, zdbuf); /* zdbuf */ + WRITE(1, uint8_t, blocked); /* blocked */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_CONTEXT_INFO_REPLY, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +struct rbug_proto_context_list * rbug_demarshal_context_list(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_context_list *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_CONTEXT_LIST) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + + return ret; +} + +struct rbug_proto_context_info * rbug_demarshal_context_info(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_context_info *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_CONTEXT_INFO) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(8, rbug_context_t, context); /* context */ + + return ret; +} + +struct rbug_proto_context_block_draw * rbug_demarshal_context_block_draw(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_context_block_draw *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_CONTEXT_BLOCK_DRAW) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(8, rbug_context_t, context); /* context */ + + return ret; +} + +struct rbug_proto_context_unblock_draw * rbug_demarshal_context_unblock_draw(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_context_unblock_draw *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_CONTEXT_UNBLOCK_DRAW) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(8, rbug_context_t, context); /* context */ + + return ret; +} + +struct rbug_proto_context_list_reply * rbug_demarshal_context_list_reply(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_context_list_reply *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_CONTEXT_LIST_REPLY) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(4, uint32_t, serial); /* serial */ + READ_ARRAY(8, rbug_context_t, contexts); /* contexts */ + + return ret; +} + +struct rbug_proto_context_info_reply * rbug_demarshal_context_info_reply(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_context_info_reply *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_CONTEXT_INFO_REPLY) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(4, uint32_t, serial); /* serial */ + READ_ARRAY(8, rbug_texture_t, cbufs); /* cbufs */ + READ(8, rbug_texture_t, zdbuf); /* zdbuf */ + READ(1, uint8_t, blocked); /* blocked */ + + return ret; +} diff --git a/src/gallium/auxiliary/rbug/rbug_context.h b/src/gallium/auxiliary/rbug/rbug_context.h new file mode 100644 index 0000000000..bcd2a826a7 --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_context.h @@ -0,0 +1,128 @@ +/* + * Copyright 2009 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * VMWARE AND/OR THEIR 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. + */ + +/* + * This file holds structs decelerations and function prototypes for one of + * the rbug extensions. Implementation of the functions is in the same folder + * in the c file matching this file's name. + * + * The structs what is returned from the demarshal functions. The functions + * starting rbug_send_* encodes a call to the write format and sends that to + * the supplied connection, while functions starting with rbug_demarshal_* + * demarshal data from the wire protocol. + * + * Structs and functions ending with _reply are replies to requests. + */ + +#ifndef _RBUG_PROTO_CONTEXT_H_ +#define _RBUG_PROTO_CONTEXT_H_ + +#include "rbug/rbug_proto.h" +#include "rbug/rbug_texture.h" + +typedef uint64_t rbug_context_t; + +struct rbug_proto_context_list +{ + struct rbug_header header; +}; + +struct rbug_proto_context_info +{ + struct rbug_header header; + rbug_context_t context; +}; + +struct rbug_proto_context_block_draw +{ + struct rbug_header header; + rbug_context_t context; +}; + +struct rbug_proto_context_unblock_draw +{ + struct rbug_header header; + rbug_context_t context; +}; + +struct rbug_proto_context_list_reply +{ + struct rbug_header header; + uint32_t serial; + rbug_context_t *contexts; + uint32_t contexts_len; +}; + +struct rbug_proto_context_info_reply +{ + struct rbug_header header; + uint32_t serial; + rbug_texture_t *cbufs; + uint32_t cbufs_len; + rbug_texture_t zdbuf; + uint8_t blocked; +}; + +int rbug_send_context_list(struct rbug_connection *__con, + uint32_t *__serial); + +int rbug_send_context_info(struct rbug_connection *__con, + rbug_context_t context, + uint32_t *__serial); + +int rbug_send_context_block_draw(struct rbug_connection *__con, + rbug_context_t context, + uint32_t *__serial); + +int rbug_send_context_unblock_draw(struct rbug_connection *__con, + rbug_context_t context, + uint32_t *__serial); + +int rbug_send_context_list_reply(struct rbug_connection *__con, + uint32_t serial, + rbug_context_t *contexts, + uint32_t contexts_len, + uint32_t *__serial); + +int rbug_send_context_info_reply(struct rbug_connection *__con, + uint32_t serial, + rbug_texture_t *cbufs, + uint32_t cbufs_len, + rbug_texture_t zdbuf, + uint8_t blocked, + uint32_t *__serial); + +struct rbug_proto_context_list * rbug_demarshal_context_list(struct rbug_proto_header *header); + +struct rbug_proto_context_info * rbug_demarshal_context_info(struct rbug_proto_header *header); + +struct rbug_proto_context_block_draw * rbug_demarshal_context_block_draw(struct rbug_proto_header *header); + +struct rbug_proto_context_unblock_draw * rbug_demarshal_context_unblock_draw(struct rbug_proto_header *header); + +struct rbug_proto_context_list_reply * rbug_demarshal_context_list_reply(struct rbug_proto_header *header); + +struct rbug_proto_context_info_reply * rbug_demarshal_context_info_reply(struct rbug_proto_header *header); + +#endif diff --git a/src/gallium/auxiliary/rbug/rbug_core.c b/src/gallium/auxiliary/rbug/rbug_core.c new file mode 100644 index 0000000000..876ae5a0ce --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_core.c @@ -0,0 +1,359 @@ +/* + * Copyright 2009 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * VMWARE AND/OR THEIR 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. + */ + +/* + * This file holds the function implementation for one of the rbug extensions. + * Prototypes and declerations of functions and structs is in the same folder + * in the header file matching this file's name. + * + * The functions starting rbug_send_* encodes a call to the write format and + * sends that to the supplied connection, while functions starting with + * rbug_demarshal_* demarshal data in the wire protocol. + * + * Functions ending with _reply are replies to requests. + */ + +#include "rbug_internal.h" +#include "rbug/rbug_core.h" + +int rbug_send_noop(struct rbug_connection *__con, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_NOOP)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_NOOP, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_ping(struct rbug_connection *__con, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_PING)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_PING, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_error(struct rbug_connection *__con, + uint32_t error, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(4); /* error */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_ERROR)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(4, uint32_t, error); /* error */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_ERROR, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_ping_reply(struct rbug_connection *__con, + uint32_t serial, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(4); /* serial */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_PING_REPLY)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(4, uint32_t, serial); /* serial */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_PING_REPLY, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_error_reply(struct rbug_connection *__con, + uint32_t serial, + uint32_t error, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(4); /* serial */ + LEN(4); /* error */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_ERROR_REPLY)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(4, uint32_t, serial); /* serial */ + WRITE(4, uint32_t, error); /* error */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_ERROR_REPLY, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +struct rbug_proto_noop * rbug_demarshal_noop(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_noop *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_NOOP) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + + return ret; +} + +struct rbug_proto_ping * rbug_demarshal_ping(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_ping *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_PING) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + + return ret; +} + +struct rbug_proto_error * rbug_demarshal_error(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_error *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_ERROR) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(4, uint32_t, error); /* error */ + + return ret; +} + +struct rbug_proto_ping_reply * rbug_demarshal_ping_reply(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_ping_reply *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_PING_REPLY) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(4, uint32_t, serial); /* serial */ + + return ret; +} + +struct rbug_proto_error_reply * rbug_demarshal_error_reply(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_error_reply *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_ERROR_REPLY) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(4, uint32_t, serial); /* serial */ + READ(4, uint32_t, error); /* error */ + + return ret; +} diff --git a/src/gallium/auxiliary/rbug/rbug_core.h b/src/gallium/auxiliary/rbug/rbug_core.h new file mode 100644 index 0000000000..d63a8c8076 --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_core.h @@ -0,0 +1,101 @@ +/* + * Copyright 2009 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * VMWARE AND/OR THEIR 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. + */ + +/* + * This file holds structs decelerations and function prototypes for one of + * the rbug extensions. Implementation of the functions is in the same folder + * in the c file matching this file's name. + * + * The structs what is returned from the demarshal functions. The functions + * starting rbug_send_* encodes a call to the write format and sends that to + * the supplied connection, while functions starting with rbug_demarshal_* + * demarshal data from the wire protocol. + * + * Structs and functions ending with _reply are replies to requests. + */ + +#ifndef _RBUG_PROTO_CORE_H_ +#define _RBUG_PROTO_CORE_H_ + +#include "rbug/rbug_proto.h" + +struct rbug_proto_noop +{ + struct rbug_header header; +}; + +struct rbug_proto_ping +{ + struct rbug_header header; +}; + +struct rbug_proto_error +{ + struct rbug_header header; + uint32_t error; +}; + +struct rbug_proto_ping_reply +{ + struct rbug_header header; + uint32_t serial; +}; + +struct rbug_proto_error_reply +{ + struct rbug_header header; + uint32_t serial; + uint32_t error; +}; + +int rbug_send_noop(struct rbug_connection *__con, + uint32_t *__serial); + +int rbug_send_ping(struct rbug_connection *__con, + uint32_t *__serial); + +int rbug_send_error(struct rbug_connection *__con, + uint32_t error, + uint32_t *__serial); + +int rbug_send_ping_reply(struct rbug_connection *__con, + uint32_t serial, + uint32_t *__serial); + +int rbug_send_error_reply(struct rbug_connection *__con, + uint32_t serial, + uint32_t error, + uint32_t *__serial); + +struct rbug_proto_noop * rbug_demarshal_noop(struct rbug_proto_header *header); + +struct rbug_proto_ping * rbug_demarshal_ping(struct rbug_proto_header *header); + +struct rbug_proto_error * rbug_demarshal_error(struct rbug_proto_header *header); + +struct rbug_proto_ping_reply * rbug_demarshal_ping_reply(struct rbug_proto_header *header); + +struct rbug_proto_error_reply * rbug_demarshal_error_reply(struct rbug_proto_header *header); + +#endif diff --git a/src/gallium/auxiliary/rbug/rbug_demarshal.c b/src/gallium/auxiliary/rbug/rbug_demarshal.c new file mode 100644 index 0000000000..e3c0954f9e --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_demarshal.c @@ -0,0 +1,85 @@ +/* + * Copyright 2009 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * VMWARE AND/OR THEIR 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. + */ + +#include "rbug.h" + +/** + * Small function that looks at the proto_header and selects the correct + * demarshal functions and return the result. + */ +struct rbug_header * rbug_demarshal(struct rbug_proto_header *header) +{ + switch(header->opcode) { + case RBUG_OP_NOOP: + return (struct rbug_header *)rbug_demarshal_noop(header); + case RBUG_OP_PING: + return (struct rbug_header *)rbug_demarshal_ping(header); + case RBUG_OP_ERROR: + return (struct rbug_header *)rbug_demarshal_error(header); + case RBUG_OP_PING_REPLY: + return (struct rbug_header *)rbug_demarshal_ping_reply(header); + case RBUG_OP_ERROR_REPLY: + return (struct rbug_header *)rbug_demarshal_error_reply(header); + case RBUG_OP_TEXTURE_LIST: + return (struct rbug_header *)rbug_demarshal_texture_list(header); + case RBUG_OP_TEXTURE_INFO: + return (struct rbug_header *)rbug_demarshal_texture_info(header); + case RBUG_OP_TEXTURE_WRITE: + return (struct rbug_header *)rbug_demarshal_texture_write(header); + case RBUG_OP_TEXTURE_READ: + return (struct rbug_header *)rbug_demarshal_texture_read(header); + case RBUG_OP_TEXTURE_LIST_REPLY: + return (struct rbug_header *)rbug_demarshal_texture_list_reply(header); + case RBUG_OP_TEXTURE_INFO_REPLY: + return (struct rbug_header *)rbug_demarshal_texture_info_reply(header); + case RBUG_OP_TEXTURE_READ_REPLY: + return (struct rbug_header *)rbug_demarshal_texture_read_reply(header); + case RBUG_OP_CONTEXT_LIST: + return (struct rbug_header *)rbug_demarshal_context_list(header); + case RBUG_OP_CONTEXT_INFO: + return (struct rbug_header *)rbug_demarshal_context_info(header); + case RBUG_OP_CONTEXT_BLOCK_DRAW: + return (struct rbug_header *)rbug_demarshal_context_block_draw(header); + case RBUG_OP_CONTEXT_UNBLOCK_DRAW: + return (struct rbug_header *)rbug_demarshal_context_unblock_draw(header); + case RBUG_OP_CONTEXT_LIST_REPLY: + return (struct rbug_header *)rbug_demarshal_context_list_reply(header); + case RBUG_OP_CONTEXT_INFO_REPLY: + return (struct rbug_header *)rbug_demarshal_context_info_reply(header); + case RBUG_OP_SHADER_LIST: + return (struct rbug_header *)rbug_demarshal_shader_list(header); + case RBUG_OP_SHADER_INFO: + return (struct rbug_header *)rbug_demarshal_shader_info(header); + case RBUG_OP_SHADER_DISABLE: + return (struct rbug_header *)rbug_demarshal_shader_disable(header); + case RBUG_OP_SHADER_REPLACE: + return (struct rbug_header *)rbug_demarshal_shader_replace(header); + case RBUG_OP_SHADER_LIST_REPLY: + return (struct rbug_header *)rbug_demarshal_shader_list_reply(header); + case RBUG_OP_SHADER_INFO_REPLY: + return (struct rbug_header *)rbug_demarshal_shader_info_reply(header); + default: + return NULL; + } +} diff --git a/src/gallium/auxiliary/rbug/rbug_internal.h b/src/gallium/auxiliary/rbug/rbug_internal.h new file mode 100644 index 0000000000..4aba1a810f --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_internal.h @@ -0,0 +1,100 @@ +/* + * Copyright 2009 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * VMWARE AND/OR THEIR 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. + */ + +/* + * This file is internal to the rbug protocol code, and contains asorted + * features needed by the code. + */ + +#ifndef _RBUG_INTERNAL_H_ +#define _RBUG_INTERNAL_H_ + +#include "rbug/rbug_proto.h" + +#include "util/u_memory.h" +#include "util/u_debug.h" +#include + +int rbug_connection_send_start(struct rbug_connection *con, enum rbug_opcode opcode, uint32_t length); +int rbug_connection_write(struct rbug_connection *con, void *data, uint32_t size); +int rbug_connection_send_finish(struct rbug_connection *con, uint32_t *c); + +/** + * Only works with multiples of 2 + */ +#define PAD(from, to) \ +do { \ + from = (from + to - 1) & ~(to - 1); \ +} while(0) + +#define LEN(size) \ +do { \ + PAD(__len, size); \ + __len += size; \ +} while(0) + +#define LEN_ARRAY(size, name) \ +do { \ + LEN(4); \ + PAD(__len, size); \ + __len += size * name##_len; \ +} while(0) + +#define WRITE(size, type, name) \ +do { \ + PAD(__pos, size); \ + *((type *)(&__data[__pos])) = name; \ + __pos += size; \ +} while(0) + +#define WRITE_ARRAY(size, type, name) \ +do { \ + WRITE(4, uint32_t, name##_len); \ + PAD(__pos, size); \ + memcpy(&__data[__pos], name, size * name##_len); \ + __pos += size * name##_len; \ +} while(0) + +#define READ(size, type, name) \ +do { \ + PAD(pos, size); \ + pos += size; \ + if (pos > len) \ + break; \ + ret->name = *((type *)(&data[pos - size])); \ +} while(0) + +#define READ_ARRAY(size, type, name) \ +do { \ + READ(4, uint32_t, name##_len); \ + if (pos > len) \ + break; \ + PAD(pos, size); \ + pos += size * ret->name##_len; \ + if (pos > len) \ + break; \ + ret->name = (type *)&data[pos - size * ret->name##_len]; \ +} while(0) + +#endif diff --git a/src/gallium/auxiliary/rbug/rbug_proto.h b/src/gallium/auxiliary/rbug/rbug_proto.h new file mode 100644 index 0000000000..8fa1836771 --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_proto.h @@ -0,0 +1,90 @@ +/* + * Copyright 2009 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * VMWARE AND/OR THEIR 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. + */ + +/* + * This file holds common definitions of the gallium remote debugging protocol. + */ + +#ifndef _RBUG_PROTO_H_ +#define _RBUG_PROTO_H_ + +#include "pipe/p_compiler.h" + +/** + * Uniqe indentifier for each command. + * + * Replys are designated by negative. + */ +enum rbug_opcode +{ + RBUG_OP_NOOP = 0, + RBUG_OP_PING = 1, + RBUG_OP_ERROR = 2, + RBUG_OP_PING_REPLY = -1, + RBUG_OP_ERROR_REPLY = -2, + RBUG_OP_TEXTURE_LIST = 256, + RBUG_OP_TEXTURE_INFO = 257, + RBUG_OP_TEXTURE_WRITE = 258, + RBUG_OP_TEXTURE_READ = 259, + RBUG_OP_TEXTURE_LIST_REPLY = -256, + RBUG_OP_TEXTURE_INFO_REPLY = -257, + RBUG_OP_TEXTURE_READ_REPLY = -259, + RBUG_OP_CONTEXT_LIST = 512, + RBUG_OP_CONTEXT_INFO = 513, + RBUG_OP_CONTEXT_BLOCK_DRAW = 514, + RBUG_OP_CONTEXT_UNBLOCK_DRAW = 515, + RBUG_OP_CONTEXT_LIST_REPLY = -512, + RBUG_OP_CONTEXT_INFO_REPLY = -513, + RBUG_OP_SHADER_LIST = 768, + RBUG_OP_SHADER_INFO = 769, + RBUG_OP_SHADER_DISABLE = 770, + RBUG_OP_SHADER_REPLACE = 771, + RBUG_OP_SHADER_LIST_REPLY = -768, + RBUG_OP_SHADER_INFO_REPLY = -769, +}; + +/** + * Header for demarshaled message. + */ +struct rbug_header +{ + enum rbug_opcode opcode; + void *__message; +}; + +/** + * Header for a message in wire format. + */ +struct rbug_proto_header +{ + int32_t opcode; + uint32_t length; +}; + +/** + * Forward declare connection here, as this file is included by all users. + */ +struct rbug_connection; + +#endif diff --git a/src/gallium/auxiliary/rbug/rbug_shader.c b/src/gallium/auxiliary/rbug/rbug_shader.c new file mode 100644 index 0000000000..fccd2f55ef --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_shader.c @@ -0,0 +1,468 @@ +/* + * Copyright 2009 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * VMWARE AND/OR THEIR 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. + */ + +/* + * This file holds the function implementation for one of the rbug extensions. + * Prototypes and declerations of functions and structs is in the same folder + * in the header file matching this file's name. + * + * The functions starting rbug_send_* encodes a call to the write format and + * sends that to the supplied connection, while functions starting with + * rbug_demarshal_* demarshal data in the wire protocol. + * + * Functions ending with _reply are replies to requests. + */ + +#include "rbug_internal.h" +#include "rbug/rbug_shader.h" + +int rbug_send_shader_list(struct rbug_connection *__con, + rbug_context_t context, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(8); /* context */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_LIST)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(8, rbug_context_t, context); /* context */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_SHADER_LIST, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_shader_info(struct rbug_connection *__con, + rbug_context_t context, + rbug_shader_t shader, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(8); /* context */ + LEN(8); /* shader */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_INFO)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(8, rbug_context_t, context); /* context */ + WRITE(8, rbug_shader_t, shader); /* shader */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_SHADER_INFO, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_shader_disable(struct rbug_connection *__con, + rbug_context_t context, + rbug_shader_t shader, + uint8_t disable, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(8); /* context */ + LEN(8); /* shader */ + LEN(1); /* disable */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_DISABLE)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(8, rbug_context_t, context); /* context */ + WRITE(8, rbug_shader_t, shader); /* shader */ + WRITE(1, uint8_t, disable); /* disable */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_SHADER_DISABLE, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_shader_replace(struct rbug_connection *__con, + rbug_context_t context, + rbug_shader_t shader, + uint32_t *tokens, + uint32_t tokens_len, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(8); /* context */ + LEN(8); /* shader */ + LEN_ARRAY(4, tokens); /* tokens */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_REPLACE)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(8, rbug_context_t, context); /* context */ + WRITE(8, rbug_shader_t, shader); /* shader */ + WRITE_ARRAY(4, uint32_t, tokens); /* tokens */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_SHADER_REPLACE, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_shader_list_reply(struct rbug_connection *__con, + uint32_t serial, + rbug_shader_t *shaders, + uint32_t shaders_len, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(4); /* serial */ + LEN_ARRAY(8, shaders); /* shaders */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_LIST_REPLY)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(4, uint32_t, serial); /* serial */ + WRITE_ARRAY(8, rbug_shader_t, shaders); /* shaders */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_SHADER_LIST_REPLY, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_shader_info_reply(struct rbug_connection *__con, + uint32_t serial, + uint32_t *original, + uint32_t original_len, + uint32_t *replaced, + uint32_t replaced_len, + uint8_t disabled, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(4); /* serial */ + LEN_ARRAY(4, original); /* original */ + LEN_ARRAY(4, replaced); /* replaced */ + LEN(1); /* disabled */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_SHADER_INFO_REPLY)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(4, uint32_t, serial); /* serial */ + WRITE_ARRAY(4, uint32_t, original); /* original */ + WRITE_ARRAY(4, uint32_t, replaced); /* replaced */ + WRITE(1, uint8_t, disabled); /* disabled */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_SHADER_INFO_REPLY, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +struct rbug_proto_shader_list * rbug_demarshal_shader_list(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_shader_list *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_SHADER_LIST) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(8, rbug_context_t, context); /* context */ + + return ret; +} + +struct rbug_proto_shader_info * rbug_demarshal_shader_info(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_shader_info *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_SHADER_INFO) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(8, rbug_context_t, context); /* context */ + READ(8, rbug_shader_t, shader); /* shader */ + + return ret; +} + +struct rbug_proto_shader_disable * rbug_demarshal_shader_disable(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_shader_disable *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_SHADER_DISABLE) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(8, rbug_context_t, context); /* context */ + READ(8, rbug_shader_t, shader); /* shader */ + READ(1, uint8_t, disable); /* disable */ + + return ret; +} + +struct rbug_proto_shader_replace * rbug_demarshal_shader_replace(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_shader_replace *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_SHADER_REPLACE) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(8, rbug_context_t, context); /* context */ + READ(8, rbug_shader_t, shader); /* shader */ + READ_ARRAY(4, uint32_t, tokens); /* tokens */ + + return ret; +} + +struct rbug_proto_shader_list_reply * rbug_demarshal_shader_list_reply(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_shader_list_reply *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_SHADER_LIST_REPLY) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(4, uint32_t, serial); /* serial */ + READ_ARRAY(8, rbug_shader_t, shaders); /* shaders */ + + return ret; +} + +struct rbug_proto_shader_info_reply * rbug_demarshal_shader_info_reply(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_shader_info_reply *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_SHADER_INFO_REPLY) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(4, uint32_t, serial); /* serial */ + READ_ARRAY(4, uint32_t, original); /* original */ + READ_ARRAY(4, uint32_t, replaced); /* replaced */ + READ(1, uint8_t, disabled); /* disabled */ + + return ret; +} diff --git a/src/gallium/auxiliary/rbug/rbug_shader.h b/src/gallium/auxiliary/rbug/rbug_shader.h new file mode 100644 index 0000000000..fe1b9ac0f7 --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_shader.h @@ -0,0 +1,144 @@ +/* + * Copyright 2009 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * VMWARE AND/OR THEIR 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. + */ + +/* + * This file holds structs decelerations and function prototypes for one of + * the rbug extensions. Implementation of the functions is in the same folder + * in the c file matching this file's name. + * + * The structs what is returned from the demarshal functions. The functions + * starting rbug_send_* encodes a call to the write format and sends that to + * the supplied connection, while functions starting with rbug_demarshal_* + * demarshal data from the wire protocol. + * + * Structs and functions ending with _reply are replies to requests. + */ + +#ifndef _RBUG_PROTO_SHADER_H_ +#define _RBUG_PROTO_SHADER_H_ + +#include "rbug/rbug_proto.h" +#include "rbug/rbug_context.h" + +typedef uint64_t rbug_shader_t; + +struct rbug_proto_shader_list +{ + struct rbug_header header; + rbug_context_t context; +}; + +struct rbug_proto_shader_info +{ + struct rbug_header header; + rbug_context_t context; + rbug_shader_t shader; +}; + +struct rbug_proto_shader_disable +{ + struct rbug_header header; + rbug_context_t context; + rbug_shader_t shader; + uint8_t disable; +}; + +struct rbug_proto_shader_replace +{ + struct rbug_header header; + rbug_context_t context; + rbug_shader_t shader; + uint32_t *tokens; + uint32_t tokens_len; +}; + +struct rbug_proto_shader_list_reply +{ + struct rbug_header header; + uint32_t serial; + rbug_shader_t *shaders; + uint32_t shaders_len; +}; + +struct rbug_proto_shader_info_reply +{ + struct rbug_header header; + uint32_t serial; + uint32_t *original; + uint32_t original_len; + uint32_t *replaced; + uint32_t replaced_len; + uint8_t disabled; +}; + +int rbug_send_shader_list(struct rbug_connection *__con, + rbug_context_t context, + uint32_t *__serial); + +int rbug_send_shader_info(struct rbug_connection *__con, + rbug_context_t context, + rbug_shader_t shader, + uint32_t *__serial); + +int rbug_send_shader_disable(struct rbug_connection *__con, + rbug_context_t context, + rbug_shader_t shader, + uint8_t disable, + uint32_t *__serial); + +int rbug_send_shader_replace(struct rbug_connection *__con, + rbug_context_t context, + rbug_shader_t shader, + uint32_t *tokens, + uint32_t tokens_len, + uint32_t *__serial); + +int rbug_send_shader_list_reply(struct rbug_connection *__con, + uint32_t serial, + rbug_shader_t *shaders, + uint32_t shaders_len, + uint32_t *__serial); + +int rbug_send_shader_info_reply(struct rbug_connection *__con, + uint32_t serial, + uint32_t *original, + uint32_t original_len, + uint32_t *replaced, + uint32_t replaced_len, + uint8_t disabled, + uint32_t *__serial); + +struct rbug_proto_shader_list * rbug_demarshal_shader_list(struct rbug_proto_header *header); + +struct rbug_proto_shader_info * rbug_demarshal_shader_info(struct rbug_proto_header *header); + +struct rbug_proto_shader_disable * rbug_demarshal_shader_disable(struct rbug_proto_header *header); + +struct rbug_proto_shader_replace * rbug_demarshal_shader_replace(struct rbug_proto_header *header); + +struct rbug_proto_shader_list_reply * rbug_demarshal_shader_list_reply(struct rbug_proto_header *header); + +struct rbug_proto_shader_info_reply * rbug_demarshal_shader_info_reply(struct rbug_proto_header *header); + +#endif diff --git a/src/gallium/auxiliary/rbug/rbug_texture.c b/src/gallium/auxiliary/rbug/rbug_texture.c new file mode 100644 index 0000000000..5a918fe6bc --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_texture.c @@ -0,0 +1,631 @@ +/* + * Copyright 2009 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * VMWARE AND/OR THEIR 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. + */ + +/* + * This file holds the function implementation for one of the rbug extensions. + * Prototypes and declerations of functions and structs is in the same folder + * in the header file matching this file's name. + * + * The functions starting rbug_send_* encodes a call to the write format and + * sends that to the supplied connection, while functions starting with + * rbug_demarshal_* demarshal data in the wire protocol. + * + * Functions ending with _reply are replies to requests. + */ + +#include "rbug_internal.h" +#include "rbug/rbug_texture.h" + +int rbug_send_texture_list(struct rbug_connection *__con, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_LIST)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_TEXTURE_LIST, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_texture_info(struct rbug_connection *__con, + rbug_texture_t texture, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(8); /* texture */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_INFO)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(8, rbug_texture_t, texture); /* texture */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_TEXTURE_INFO, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_texture_write(struct rbug_connection *__con, + rbug_texture_t texture, + uint32_t face, + uint32_t level, + uint32_t zslice, + uint32_t x, + uint32_t y, + uint32_t w, + uint32_t h, + uint8_t *data, + uint32_t data_len, + uint32_t stride, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(8); /* texture */ + LEN(4); /* face */ + LEN(4); /* level */ + LEN(4); /* zslice */ + LEN(4); /* x */ + LEN(4); /* y */ + LEN(4); /* w */ + LEN(4); /* h */ + LEN_ARRAY(1, data); /* data */ + LEN(4); /* stride */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_WRITE)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(8, rbug_texture_t, texture); /* texture */ + WRITE(4, uint32_t, face); /* face */ + WRITE(4, uint32_t, level); /* level */ + WRITE(4, uint32_t, zslice); /* zslice */ + WRITE(4, uint32_t, x); /* x */ + WRITE(4, uint32_t, y); /* y */ + WRITE(4, uint32_t, w); /* w */ + WRITE(4, uint32_t, h); /* h */ + WRITE_ARRAY(1, uint8_t, data); /* data */ + WRITE(4, uint32_t, stride); /* stride */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_TEXTURE_WRITE, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_texture_read(struct rbug_connection *__con, + rbug_texture_t texture, + uint32_t face, + uint32_t level, + uint32_t zslice, + uint32_t x, + uint32_t y, + uint32_t w, + uint32_t h, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(8); /* texture */ + LEN(4); /* face */ + LEN(4); /* level */ + LEN(4); /* zslice */ + LEN(4); /* x */ + LEN(4); /* y */ + LEN(4); /* w */ + LEN(4); /* h */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_READ)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(8, rbug_texture_t, texture); /* texture */ + WRITE(4, uint32_t, face); /* face */ + WRITE(4, uint32_t, level); /* level */ + WRITE(4, uint32_t, zslice); /* zslice */ + WRITE(4, uint32_t, x); /* x */ + WRITE(4, uint32_t, y); /* y */ + WRITE(4, uint32_t, w); /* w */ + WRITE(4, uint32_t, h); /* h */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_TEXTURE_READ, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_texture_list_reply(struct rbug_connection *__con, + uint32_t serial, + rbug_texture_t *textures, + uint32_t textures_len, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(4); /* serial */ + LEN_ARRAY(8, textures); /* textures */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_LIST_REPLY)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(4, uint32_t, serial); /* serial */ + WRITE_ARRAY(8, rbug_texture_t, textures); /* textures */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_TEXTURE_LIST_REPLY, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_texture_info_reply(struct rbug_connection *__con, + uint32_t serial, + uint32_t target, + uint32_t format, + uint32_t *width, + uint32_t width_len, + uint32_t *height, + uint32_t height_len, + uint32_t *depth, + uint32_t depth_len, + uint32_t blockw, + uint32_t blockh, + uint32_t blocksize, + uint32_t last_level, + uint32_t nr_samples, + uint32_t tex_usage, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(4); /* serial */ + LEN(4); /* target */ + LEN(4); /* format */ + LEN_ARRAY(4, width); /* width */ + LEN_ARRAY(4, height); /* height */ + LEN_ARRAY(4, depth); /* depth */ + LEN(4); /* blockw */ + LEN(4); /* blockh */ + LEN(4); /* blocksize */ + LEN(4); /* last_level */ + LEN(4); /* nr_samples */ + LEN(4); /* tex_usage */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_INFO_REPLY)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(4, uint32_t, serial); /* serial */ + WRITE(4, uint32_t, target); /* target */ + WRITE(4, uint32_t, format); /* format */ + WRITE_ARRAY(4, uint32_t, width); /* width */ + WRITE_ARRAY(4, uint32_t, height); /* height */ + WRITE_ARRAY(4, uint32_t, depth); /* depth */ + WRITE(4, uint32_t, blockw); /* blockw */ + WRITE(4, uint32_t, blockh); /* blockh */ + WRITE(4, uint32_t, blocksize); /* blocksize */ + WRITE(4, uint32_t, last_level); /* last_level */ + WRITE(4, uint32_t, nr_samples); /* nr_samples */ + WRITE(4, uint32_t, tex_usage); /* tex_usage */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_TEXTURE_INFO_REPLY, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +int rbug_send_texture_read_reply(struct rbug_connection *__con, + uint32_t serial, + uint32_t format, + uint32_t blockw, + uint32_t blockh, + uint32_t blocksize, + uint8_t *data, + uint32_t data_len, + uint32_t stride, + uint32_t *__serial) +{ + uint32_t __len = 0; + uint32_t __pos = 0; + uint8_t *__data = NULL; + int __ret = 0; + + LEN(8); /* header */ + LEN(4); /* serial */ + LEN(4); /* format */ + LEN(4); /* blockw */ + LEN(4); /* blockh */ + LEN(4); /* blocksize */ + LEN_ARRAY(1, data); /* data */ + LEN(4); /* stride */ + + /* align */ + PAD(__len, 8); + + __data = (uint8_t*)MALLOC(__len); + if (!__data) + return -ENOMEM; + + WRITE(4, int32_t, ((int32_t)RBUG_OP_TEXTURE_READ_REPLY)); + WRITE(4, uint32_t, ((uint32_t)(__len / 4))); + WRITE(4, uint32_t, serial); /* serial */ + WRITE(4, uint32_t, format); /* format */ + WRITE(4, uint32_t, blockw); /* blockw */ + WRITE(4, uint32_t, blockh); /* blockh */ + WRITE(4, uint32_t, blocksize); /* blocksize */ + WRITE_ARRAY(1, uint8_t, data); /* data */ + WRITE(4, uint32_t, stride); /* stride */ + + /* final pad */ + PAD(__pos, 8); + + if (__pos != __len) { + __ret = -EINVAL; + } else { + rbug_connection_send_start(__con, RBUG_OP_TEXTURE_READ_REPLY, __len); + rbug_connection_write(__con, __data, __len); + __ret = rbug_connection_send_finish(__con, __serial); + } + + FREE(__data); + return __ret; +} + +struct rbug_proto_texture_list * rbug_demarshal_texture_list(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_texture_list *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_TEXTURE_LIST) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + + return ret; +} + +struct rbug_proto_texture_info * rbug_demarshal_texture_info(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_texture_info *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_TEXTURE_INFO) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(8, rbug_texture_t, texture); /* texture */ + + return ret; +} + +struct rbug_proto_texture_write * rbug_demarshal_texture_write(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_texture_write *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_TEXTURE_WRITE) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(8, rbug_texture_t, texture); /* texture */ + READ(4, uint32_t, face); /* face */ + READ(4, uint32_t, level); /* level */ + READ(4, uint32_t, zslice); /* zslice */ + READ(4, uint32_t, x); /* x */ + READ(4, uint32_t, y); /* y */ + READ(4, uint32_t, w); /* w */ + READ(4, uint32_t, h); /* h */ + READ_ARRAY(1, uint8_t, data); /* data */ + READ(4, uint32_t, stride); /* stride */ + + return ret; +} + +struct rbug_proto_texture_read * rbug_demarshal_texture_read(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_texture_read *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_TEXTURE_READ) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(8, rbug_texture_t, texture); /* texture */ + READ(4, uint32_t, face); /* face */ + READ(4, uint32_t, level); /* level */ + READ(4, uint32_t, zslice); /* zslice */ + READ(4, uint32_t, x); /* x */ + READ(4, uint32_t, y); /* y */ + READ(4, uint32_t, w); /* w */ + READ(4, uint32_t, h); /* h */ + + return ret; +} + +struct rbug_proto_texture_list_reply * rbug_demarshal_texture_list_reply(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_texture_list_reply *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_TEXTURE_LIST_REPLY) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(4, uint32_t, serial); /* serial */ + READ_ARRAY(8, rbug_texture_t, textures); /* textures */ + + return ret; +} + +struct rbug_proto_texture_info_reply * rbug_demarshal_texture_info_reply(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_texture_info_reply *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_TEXTURE_INFO_REPLY) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(4, uint32_t, serial); /* serial */ + READ(4, uint32_t, target); /* target */ + READ(4, uint32_t, format); /* format */ + READ_ARRAY(4, uint32_t, width); /* width */ + READ_ARRAY(4, uint32_t, height); /* height */ + READ_ARRAY(4, uint32_t, depth); /* depth */ + READ(4, uint32_t, blockw); /* blockw */ + READ(4, uint32_t, blockh); /* blockh */ + READ(4, uint32_t, blocksize); /* blocksize */ + READ(4, uint32_t, last_level); /* last_level */ + READ(4, uint32_t, nr_samples); /* nr_samples */ + READ(4, uint32_t, tex_usage); /* tex_usage */ + + return ret; +} + +struct rbug_proto_texture_read_reply * rbug_demarshal_texture_read_reply(struct rbug_proto_header *header) +{ + uint32_t len = 0; + uint32_t pos = 0; + uint8_t *data = NULL; + struct rbug_proto_texture_read_reply *ret; + + if (!header) + return NULL; + if (header->opcode != (int16_t)RBUG_OP_TEXTURE_READ_REPLY) + return NULL; + + pos = 0; + len = header->length * 4; + data = (uint8_t*)&header[1]; + ret = MALLOC(sizeof(*ret)); + if (!ret) + return NULL; + + ret->header.__message = header; + ret->header.opcode = header->opcode; + + READ(4, uint32_t, serial); /* serial */ + READ(4, uint32_t, format); /* format */ + READ(4, uint32_t, blockw); /* blockw */ + READ(4, uint32_t, blockh); /* blockh */ + READ(4, uint32_t, blocksize); /* blocksize */ + READ_ARRAY(1, uint8_t, data); /* data */ + READ(4, uint32_t, stride); /* stride */ + + return ret; +} diff --git a/src/gallium/auxiliary/rbug/rbug_texture.h b/src/gallium/auxiliary/rbug/rbug_texture.h new file mode 100644 index 0000000000..2bcc3566f3 --- /dev/null +++ b/src/gallium/auxiliary/rbug/rbug_texture.h @@ -0,0 +1,207 @@ +/* + * Copyright 2009 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 + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, and/or sell copies of the Software, and to permit persons to whom + * the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * VMWARE AND/OR THEIR 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. + */ + +/* + * This file holds structs decelerations and function prototypes for one of + * the rbug extensions. Implementation of the functions is in the same folder + * in the c file matching this file's name. + * + * The structs what is returned from the demarshal functions. The functions + * starting rbug_send_* encodes a call to the write format and sends that to + * the supplied connection, while functions starting with rbug_demarshal_* + * demarshal data from the wire protocol. + * + * Structs and functions ending with _reply are replies to requests. + */ + +#ifndef _RBUG_PROTO_TEXTURE_H_ +#define _RBUG_PROTO_TEXTURE_H_ + +#include "rbug/rbug_proto.h" + +typedef uint64_t rbug_texture_t; + +struct rbug_proto_texture_list +{ + struct rbug_header header; +}; + +struct rbug_proto_texture_info +{ + struct rbug_header header; + rbug_texture_t texture; +}; + +struct rbug_proto_texture_write +{ + struct rbug_header header; + rbug_texture_t texture; + uint32_t face; + uint32_t level; + uint32_t zslice; + uint32_t x; + uint32_t y; + uint32_t w; + uint32_t h; + uint8_t *data; + uint32_t data_len; + uint32_t stride; +}; + +struct rbug_proto_texture_read +{ + struct rbug_header header; + rbug_texture_t texture; + uint32_t face; + uint32_t level; + uint32_t zslice; + uint32_t x; + uint32_t y; + uint32_t w; + uint32_t h; +}; + +struct rbug_proto_texture_list_reply +{ + struct rbug_header header; + uint32_t serial; + rbug_texture_t *textures; + uint32_t textures_len; +}; + +struct rbug_proto_texture_info_reply +{ + struct rbug_header header; + uint32_t serial; + uint32_t target; + uint32_t format; + uint32_t *width; + uint32_t width_len; + uint32_t *height; + uint32_t height_len; + uint32_t *depth; + uint32_t depth_len; + uint32_t blockw; + uint32_t blockh; + uint32_t blocksize; + uint32_t last_level; + uint32_t nr_samples; + uint32_t tex_usage; +}; + +struct rbug_proto_texture_read_reply +{ + struct rbug_header header; + uint32_t serial; + uint32_t format; + uint32_t blockw; + uint32_t blockh; + uint32_t blocksize; + uint8_t *data; + uint32_t data_len; + uint32_t stride; +}; + +int rbug_send_texture_list(struct rbug_connection *__con, + uint32_t *__serial); + +int rbug_send_texture_info(struct rbug_connection *__con, + rbug_texture_t texture, + uint32_t *__serial); + +int rbug_send_texture_write(struct rbug_connection *__con, + rbug_texture_t texture, + uint32_t face, + uint32_t level, + uint32_t zslice, + uint32_t x, + uint32_t y, + uint32_t w, + uint32_t h, + uint8_t *data, + uint32_t data_len, + uint32_t stride, + uint32_t *__serial); + +int rbug_send_texture_read(struct rbug_connection *__con, + rbug_texture_t texture, + uint32_t face, + uint32_t level, + uint32_t zslice, + uint32_t x, + uint32_t y, + uint32_t w, + uint32_t h, + uint32_t *__serial); + +int rbug_send_texture_list_reply(struct rbug_connection *__con, + uint32_t serial, + rbug_texture_t *textures, + uint32_t textures_len, + uint32_t *__serial); + +int rbug_send_texture_info_reply(struct rbug_connection *__con, + uint32_t serial, + uint32_t target, + uint32_t format, + uint32_t *width, + uint32_t width_len, + uint32_t *height, + uint32_t height_len, + uint32_t *depth, + uint32_t depth_len, + uint32_t blockw, + uint32_t blockh, + uint32_t blocksize, + uint32_t last_level, + uint32_t nr_samples, + uint32_t tex_usage, + uint32_t *__serial); + +int rbug_send_texture_read_reply(struct rbug_connection *__con, + uint32_t serial, + uint32_t format, + uint32_t blockw, + uint32_t blockh, + uint32_t blocksize, + uint8_t *data, + uint32_t data_len, + uint32_t stride, + uint32_t *__serial); + +struct rbug_proto_texture_list * rbug_demarshal_texture_list(struct rbug_proto_header *header); + +struct rbug_proto_texture_info * rbug_demarshal_texture_info(struct rbug_proto_header *header); + +struct rbug_proto_texture_write * rbug_demarshal_texture_write(struct rbug_proto_header *header); + +struct rbug_proto_texture_read * rbug_demarshal_texture_read(struct rbug_proto_header *header); + +struct rbug_proto_texture_list_reply * rbug_demarshal_texture_list_reply(struct rbug_proto_header *header); + +struct rbug_proto_texture_info_reply * rbug_demarshal_texture_info_reply(struct rbug_proto_header *header); + +struct rbug_proto_texture_read_reply * rbug_demarshal_texture_read_reply(struct rbug_proto_header *header); + +#endif -- cgit v1.2.3 From bc302b2a33ceffe454bcf443daa0ac1edc118e9b Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Fri, 22 May 2009 09:39:02 -0700 Subject: Use separate $(MINSTALL) for installing libraries The special feature of bin/minstall to copy symlinks is only ever needed when installing libraries which may have .so symlinks. All the headers and directories can use a normal install program. These two modes are separated as $(INSTALL) and $(MINSTALL) to allow the user (or autoconf) to override installing normal files as they please. An autoconf check for the install program has been added and will be used in preference to minstall when available. Fixes bug 16053. --- configs/autoconf.in | 1 + configs/default | 5 ++++- configure.ac | 5 +++++ src/egl/drivers/dri/Makefile | 2 +- src/egl/drivers/glx/Makefile | 2 +- src/egl/drivers/xdri/Makefile | 2 +- src/egl/main/Makefile | 2 +- src/gallium/winsys/drm/Makefile.template | 2 +- src/gallium/winsys/drm/intel/xorg/Makefile | 2 +- src/gallium/winsys/drm/radeon/xorg/Makefile | 2 +- src/gallium/winsys/egl_xlib/Makefile | 2 +- src/gallium/winsys/xlib/Makefile | 2 +- src/glu/Makefile | 2 +- src/glut/fbdev/Makefile | 2 +- src/glut/glx/Makefile | 2 +- src/glut/mini/Makefile | 2 +- src/glw/Makefile | 2 +- src/mesa/Makefile | 4 ++-- src/mesa/drivers/dri/Makefile.template | 2 +- 19 files changed, 27 insertions(+), 18 deletions(-) (limited to 'configure.ac') diff --git a/configs/autoconf.in b/configs/autoconf.in index b61d7f33f0..77422e3fe5 100644 --- a/configs/autoconf.in +++ b/configs/autoconf.in @@ -31,6 +31,7 @@ SHELL = @SHELL@ MKLIB_OPTIONS = @MKLIB_OPTIONS@ MKDEP = @MKDEP@ MKDEP_OPTIONS = @MKDEP_OPTIONS@ +INSTALL = @INSTALL@ # Python and flags (generally only needed by the developers) PYTHON2 = python diff --git a/configs/default b/configs/default index d2ea3b2487..dc28be37dd 100644 --- a/configs/default +++ b/configs/default @@ -36,7 +36,10 @@ MKLIB_OPTIONS = MKDEP = makedepend MKDEP_OPTIONS = -fdepend MAKE = make -INSTALL = $(SHELL) $(TOP)/bin/minstall + +# Use MINSTALL for installing libraries, INSTALL for everything else +MINSTALL = $(SHELL) $(TOP)/bin/minstall +INSTALL = $(MINSTALL) # Tools for regenerating glapi (generally only needed by the developers) PYTHON2 = python diff --git a/configure.ac b/configure.ac index 24aa13a7ca..772fb29973 100644 --- a/configure.ac +++ b/configure.ac @@ -29,6 +29,11 @@ AC_CHECK_PROGS([MAKE], [gmake make]) AC_PATH_PROG([MKDEP], [makedepend]) AC_PATH_PROG([SED], [sed]) +dnl Our fallback install-sh is a symlink to minstall. Use the existing +dnl configuration in that case. +AC_PROG_INSTALL +test "x$INSTALL" = "x$ac_install_sh" && INSTALL='$(MINSTALL)' + dnl We need a POSIX shell for parts of the build. Assume we have one dnl in most cases. case "$host_os" in diff --git a/src/egl/drivers/dri/Makefile b/src/egl/drivers/dri/Makefile index 4041d5c906..567edfae97 100644 --- a/src/egl/drivers/dri/Makefile +++ b/src/egl/drivers/dri/Makefile @@ -50,7 +50,7 @@ $(TOP)/$(LIB_DIR)/libEGLdri.so: $(OBJECTS) install: $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) - $(INSTALL) $(TOP)/$(LIB_DIR)/libEGLdri.so $(DESTDIR)$(INSTALL_LIB_DIR) + $(MINSTALL) $(TOP)/$(LIB_DIR)/libEGLdri.so $(DESTDIR)$(INSTALL_LIB_DIR) clean: -rm -f *.o diff --git a/src/egl/drivers/glx/Makefile b/src/egl/drivers/glx/Makefile index 5f041a268f..20ef0352ad 100644 --- a/src/egl/drivers/glx/Makefile +++ b/src/egl/drivers/glx/Makefile @@ -58,7 +58,7 @@ $(TOP)/$(LIB_DIR)/$(DRIVER_NAME): $(OBJECTS) install: $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) - $(INSTALL) $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) $(DESTDIR)$(INSTALL_LIB_DIR) + $(MINSTALL) $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) $(DESTDIR)$(INSTALL_LIB_DIR) clean: rm -f *.o diff --git a/src/egl/drivers/xdri/Makefile b/src/egl/drivers/xdri/Makefile index eb83867b71..8a14027fc7 100644 --- a/src/egl/drivers/xdri/Makefile +++ b/src/egl/drivers/xdri/Makefile @@ -54,7 +54,7 @@ $(TOP)/$(LIB_DIR)/$(DRIVER_NAME): $(OBJECTS) install: $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) - $(INSTALL) $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) $(DESTDIR)$(INSTALL_LIB_DIR) + $(MINSTALL) $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) $(DESTDIR)$(INSTALL_LIB_DIR) clean: rm -f *.o diff --git a/src/egl/main/Makefile b/src/egl/main/Makefile index 8cfa25ca16..cddba9f088 100644 --- a/src/egl/main/Makefile +++ b/src/egl/main/Makefile @@ -66,7 +66,7 @@ $(TOP)/$(LIB_DIR)/libEGL.so: $(OBJECTS) install: default $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) - $(INSTALL) $(TOP)/$(LIB_DIR)/libEGL.so* $(DESTDIR)$(INSTALL_LIB_DIR) + $(MINSTALL) $(TOP)/$(LIB_DIR)/libEGL.so* $(DESTDIR)$(INSTALL_LIB_DIR) clean: -rm -f *.o *.so* diff --git a/src/gallium/winsys/drm/Makefile.template b/src/gallium/winsys/drm/Makefile.template index 9f92cb4207..985e5a861f 100644 --- a/src/gallium/winsys/drm/Makefile.template +++ b/src/gallium/winsys/drm/Makefile.template @@ -118,7 +118,7 @@ clean: install: $(LIBNAME) $(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) - $(INSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) + $(MINSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) include depend diff --git a/src/gallium/winsys/drm/intel/xorg/Makefile b/src/gallium/winsys/drm/intel/xorg/Makefile index b1b6b9362b..d9aa5d54e1 100644 --- a/src/gallium/winsys/drm/intel/xorg/Makefile +++ b/src/gallium/winsys/drm/intel/xorg/Makefile @@ -39,6 +39,6 @@ clean: install: $(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR) - $(INSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR) + $(MINSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR) .PHONY = all clean install diff --git a/src/gallium/winsys/drm/radeon/xorg/Makefile b/src/gallium/winsys/drm/radeon/xorg/Makefile index 6ffd4a3a54..0241625f69 100644 --- a/src/gallium/winsys/drm/radeon/xorg/Makefile +++ b/src/gallium/winsys/drm/radeon/xorg/Makefile @@ -37,6 +37,6 @@ clean: install: $(INSTALL) -d $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR) - $(INSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR) + $(MINSTALL) -m 755 $(TARGET) $(DESTDIR)/$(XORG_DRIVER_INSTALL_DIR) .PHONY = all clean install diff --git a/src/gallium/winsys/egl_xlib/Makefile b/src/gallium/winsys/egl_xlib/Makefile index 8646ee3b52..a33a50ec22 100644 --- a/src/gallium/winsys/egl_xlib/Makefile +++ b/src/gallium/winsys/egl_xlib/Makefile @@ -74,7 +74,7 @@ depend: $(ALL_SOURCES) install: default $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR) @if [ -e $(TOP)/$(LIB_DIR) ]; then \ - $(INSTALL) $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) $(INSTALL_DIR)/$(LIB_DIR); \ + $(MINSTALL) $(TOP)/$(LIB_DIR)/$(DRIVER_NAME) $(INSTALL_DIR)/$(LIB_DIR); \ fi diff --git a/src/gallium/winsys/xlib/Makefile b/src/gallium/winsys/xlib/Makefile index 04309e67ee..522f6dc5ae 100644 --- a/src/gallium/winsys/xlib/Makefile +++ b/src/gallium/winsys/xlib/Makefile @@ -90,7 +90,7 @@ install: default $(INSTALL) -d $(INSTALL_DIR)/$(LIB_DIR) $(INSTALL) -m 644 $(TOP)/include/GL/*.h $(INSTALL_DIR)/include/GL @if [ -e $(TOP)/$(LIB_DIR)/$(GL_LIB_NAME) ]; then \ - $(INSTALL) $(TOP)/$(LIB_DIR)/libGL* $(INSTALL_DIR)/$(LIB_DIR); \ + $(MINSTALL) $(TOP)/$(LIB_DIR)/libGL* $(INSTALL_DIR)/$(LIB_DIR); \ fi diff --git a/src/glu/Makefile b/src/glu/Makefile index 5c26ead1bb..b268265976 100644 --- a/src/glu/Makefile +++ b/src/glu/Makefile @@ -30,7 +30,7 @@ glu.pc: glu.pc.in install: glu.pc $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig - $(INSTALL) $(TOP)/$(LIB_DIR)/$(GLU_LIB_GLOB) $(DESTDIR)$(INSTALL_LIB_DIR) + $(MINSTALL) $(TOP)/$(LIB_DIR)/$(GLU_LIB_GLOB) $(DESTDIR)$(INSTALL_LIB_DIR) $(INSTALL) -m 644 glu.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig clean: diff --git a/src/glut/fbdev/Makefile b/src/glut/fbdev/Makefile index 199d8c390a..c150ea88dc 100644 --- a/src/glut/fbdev/Makefile +++ b/src/glut/fbdev/Makefile @@ -72,7 +72,7 @@ install: $(INSTALL) -d $(DESTDIR)$(INSTALL_INC_DIR)/GL $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) $(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(DESTDIR)$(INSTALL_INC_DIR)/GL - $(INSTALL) $(TOP)/$(LIB_DIR)/libglut* $(DESTDIR)$(INSTALL_LIB_DIR) + $(MINSTALL) $(TOP)/$(LIB_DIR)/libglut* $(DESTDIR)$(INSTALL_LIB_DIR) # Run 'make -f Makefile.solo dep' to update the dependencies if you change # what's included by any source file. diff --git a/src/glut/glx/Makefile b/src/glut/glx/Makefile index 1b072906c7..6889cd4b40 100644 --- a/src/glut/glx/Makefile +++ b/src/glut/glx/Makefile @@ -117,7 +117,7 @@ install: glut.pc $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig $(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(DESTDIR)$(INSTALL_INC_DIR)/GL - $(INSTALL) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_GLOB) $(DESTDIR)$(INSTALL_LIB_DIR) + $(MINSTALL) $(TOP)/$(LIB_DIR)/$(GLUT_LIB_GLOB) $(DESTDIR)$(INSTALL_LIB_DIR) $(INSTALL) -m 644 glut.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig diff --git a/src/glut/mini/Makefile b/src/glut/mini/Makefile index 0e42436133..b82a758d2c 100644 --- a/src/glut/mini/Makefile +++ b/src/glut/mini/Makefile @@ -91,7 +91,7 @@ install: glut.pc $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig $(INSTALL) -m 644 $(TOP)/include/GL/glut.h $(DESTDIR)$(INSTALL_INC_DIR)/GL - $(INSTALL) $(TOP)/$(LIB_DIR)/libglut* $(DESTDIR)$(INSTALL_LIB_DIR) + $(MINSTALL) $(TOP)/$(LIB_DIR)/libglut* $(DESTDIR)$(INSTALL_LIB_DIR) $(INSTALL) -m 644 glut.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig diff --git a/src/glw/Makefile b/src/glw/Makefile index d88d773313..1fb3d3c320 100644 --- a/src/glw/Makefile +++ b/src/glw/Makefile @@ -43,7 +43,7 @@ install: glw.pc $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig $(INSTALL) -m 644 *.h $(DESTDIR)$(INSTALL_INC_DIR)/GL - $(INSTALL) $(TOP)/$(LIB_DIR)/$(GLW_LIB_GLOB) $(DESTDIR)$(INSTALL_LIB_DIR) + $(MINSTALL) $(TOP)/$(LIB_DIR)/$(GLW_LIB_GLOB) $(DESTDIR)$(INSTALL_LIB_DIR) $(INSTALL) -m 644 glw.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig clean: diff --git a/src/mesa/Makefile b/src/mesa/Makefile index bb18bee8ea..8300b30144 100644 --- a/src/mesa/Makefile +++ b/src/mesa/Makefile @@ -129,14 +129,14 @@ install-headers: install-libgl: default gl.pc install-headers $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig - $(INSTALL) $(TOP)/$(LIB_DIR)/$(GL_LIB_GLOB) \ + $(MINSTALL) $(TOP)/$(LIB_DIR)/$(GL_LIB_GLOB) \ $(DESTDIR)$(INSTALL_LIB_DIR) $(INSTALL) -m 644 gl.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig install-osmesa: default osmesa.pc $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR) $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig - $(INSTALL) $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_GLOB) \ + $(MINSTALL) $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_GLOB) \ $(DESTDIR)$(INSTALL_LIB_DIR) $(INSTALL) -m 644 osmesa.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig diff --git a/src/mesa/drivers/dri/Makefile.template b/src/mesa/drivers/dri/Makefile.template index 5c01d233c1..bd38e3be47 100644 --- a/src/mesa/drivers/dri/Makefile.template +++ b/src/mesa/drivers/dri/Makefile.template @@ -92,7 +92,7 @@ clean: install: $(LIBNAME) $(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) - $(INSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) + $(MINSTALL) -m 755 $(LIBNAME) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR) -include depend -- cgit v1.2.3 From 4795dd5950d4dcd7c8d421c8fb4851c193297ba1 Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Thu, 4 Jun 2009 19:42:08 -0700 Subject: osmesa: Link with -ldl for dlopen code Now that the dlopen wrappers are built into libmesa.a, we need to link standalone libOSMesa with libdl to resolve dlopen and friends on platforms that need it. --- configure.ac | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 772fb29973..6f0f1f681d 100644 --- a/configure.ac +++ b/configure.ac @@ -831,12 +831,12 @@ case "$mesa_driver" in osmesa) # only link libraries with osmesa if shared if test "$enable_static" = no; then - OSMESA_LIB_DEPS="-lm -lpthread $SELINUX_LIBS" + OSMESA_LIB_DEPS="-lm -lpthread $SELINUX_LIBS $DLOPEN_LIBS" else OSMESA_LIB_DEPS="" fi OSMESA_MESA_DEPS="" - OSMESA_PC_LIB_PRIV="-lm -lpthread $SELINUX_LIBS" + OSMESA_PC_LIB_PRIV="-lm -lpthread $SELINUX_LIBS $DLOPEN_LIBS" ;; *) # Link OSMesa to libGL otherwise @@ -850,9 +850,6 @@ osmesa) OSMESA_PC_REQ="gl" ;; esac -if test "$enable_static" = no; then - OSMESA_LIB_DEPS="$OSMESA_LIB_DEPS" -fi OSMESA_PC_LIB_PRIV="$OSMESA_PC_LIB_PRIV" AC_SUBST([OSMESA_LIB_DEPS]) AC_SUBST([OSMESA_MESA_DEPS]) -- cgit v1.2.3 From 6453605785a3036c7e633400e4bd35bf2297b000 Mon Sep 17 00:00:00 2001 From: Dan Nicholson Date: Thu, 4 Jun 2009 19:42:08 -0700 Subject: osmesa: Link with -ldl for dlopen code Now that the dlopen wrappers are built into libmesa.a, we need to link standalone libOSMesa with libdl to resolve dlopen and friends on platforms that need it. (cherry picked from commit 4795dd5950d4dcd7c8d421c8fb4851c193297ba1) --- configure.ac | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 8110e0f869..48b8022736 100644 --- a/configure.ac +++ b/configure.ac @@ -826,12 +826,12 @@ case "$mesa_driver" in osmesa) # only link libraries with osmesa if shared if test "$enable_static" = no; then - OSMESA_LIB_DEPS="-lm -lpthread $SELINUX_LIBS" + OSMESA_LIB_DEPS="-lm -lpthread $SELINUX_LIBS $DLOPEN_LIBS" else OSMESA_LIB_DEPS="" fi OSMESA_MESA_DEPS="" - OSMESA_PC_LIB_PRIV="-lm -lpthread $SELINUX_LIBS" + OSMESA_PC_LIB_PRIV="-lm -lpthread $SELINUX_LIBS $DLOPEN_LIBS" ;; *) # Link OSMesa to libGL otherwise @@ -845,9 +845,6 @@ osmesa) OSMESA_PC_REQ="gl" ;; esac -if test "$enable_static" = no; then - OSMESA_LIB_DEPS="$OSMESA_LIB_DEPS" -fi OSMESA_PC_LIB_PRIV="$OSMESA_PC_LIB_PRIV" AC_SUBST([OSMESA_LIB_DEPS]) AC_SUBST([OSMESA_MESA_DEPS]) -- cgit v1.2.3 From bc466be695913cd504cefddd857ac1cefda87a04 Mon Sep 17 00:00:00 2001 From: Ben Skeggs Date: Thu, 4 Jun 2009 10:19:04 +1000 Subject: nouveau: add pipe_buffer/fence code to pipe drivers, move nv50 over --- configure.ac | 2 +- src/gallium/drivers/nouveau/nouveau_screen.c | 242 +++++++++++++++++++++++++++ src/gallium/drivers/nouveau/nouveau_screen.h | 24 +++ src/gallium/drivers/nv50/nv50_context.h | 2 - src/gallium/drivers/nv50/nv50_query.c | 2 +- src/gallium/drivers/nv50/nv50_screen.c | 83 ++++----- src/gallium/drivers/nv50/nv50_screen.h | 4 +- src/gallium/drivers/nv50/nv50_surface.c | 6 +- src/gallium/drivers/nv50/nv50_transfer.c | 4 +- src/gallium/winsys/drm/nouveau/dri/Makefile | 3 +- 10 files changed, 310 insertions(+), 62 deletions(-) create mode 100644 src/gallium/drivers/nouveau/nouveau_screen.c create mode 100644 src/gallium/drivers/nouveau/nouveau_screen.h (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 6f0f1f681d..eb2733c0dc 100644 --- a/configure.ac +++ b/configure.ac @@ -1181,7 +1181,7 @@ AC_ARG_ENABLE([gallium-nouveau], [enable_gallium_nouveau=no]) if test "x$enable_gallium_nouveau" = xyes; then GALLIUM_WINSYS_DRM_DIRS="$GALLIUM_WINSYS_DRM_DIRS nouveau" - GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nv04 nv10 nv20 nv30 nv40 nv50" + GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS nouveau nv04 nv10 nv20 nv30 nv40 nv50" fi diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c b/src/gallium/drivers/nouveau/nouveau_screen.c new file mode 100644 index 0000000000..3cab83eec0 --- /dev/null +++ b/src/gallium/drivers/nouveau/nouveau_screen.c @@ -0,0 +1,242 @@ +#include +#include +#include + +#include + +#include "nouveau/nouveau_bo.h" +#include "nouveau_winsys.h" +#include "nouveau_screen.h" + +static const char * +nouveau_screen_get_name(struct pipe_screen *pscreen) +{ + struct nouveau_device *dev = nouveau_screen(pscreen)->device; + static char buffer[128]; + + snprintf(buffer, sizeof(buffer), "NV%02X", dev->chipset); + return buffer; +} + +static const char * +nouveau_screen_get_vendor(struct pipe_screen *pscreen) +{ + return "nouveau"; +} + +static struct pipe_buffer * +nouveau_screen_bo_skel(struct pipe_screen *pscreen, struct nouveau_bo *bo, + unsigned alignment, unsigned usage, unsigned size) +{ + struct pipe_buffer *pb; + + pb = CALLOC(1, sizeof(struct pipe_buffer)+sizeof(struct nouveau_bo *)); + if (!pb) { + nouveau_bo_ref(NULL, &bo); + return NULL; + } + + pipe_reference_init(&pb->reference, 1); + pb->screen = pscreen; + pb->alignment = alignment; + pb->usage = usage; + pb->size = size; + *(struct nouveau_bo **)(pb + 1) = bo; + return pb; +} + +static struct pipe_buffer * +nouveau_screen_bo_new(struct pipe_screen *pscreen, unsigned alignment, + unsigned usage, unsigned size) +{ + struct nouveau_device *dev = nouveau_screen(pscreen)->device; + struct nouveau_bo *bo = NULL; + uint32_t flags = NOUVEAU_BO_MAP; + int ret; + + if (usage & NOUVEAU_BUFFER_USAGE_TRANSFER) + flags |= NOUVEAU_BO_GART; + else + if (usage & PIPE_BUFFER_USAGE_VERTEX) { + if (pscreen->get_param(pscreen, NOUVEAU_CAP_HW_VTXBUF)) + flags |= NOUVEAU_BO_GART; + } else + if (usage & PIPE_BUFFER_USAGE_INDEX) { + if (pscreen->get_param(pscreen, NOUVEAU_CAP_HW_IDXBUF)) + flags |= NOUVEAU_BO_GART; + } + + if (usage & PIPE_BUFFER_USAGE_PIXEL) { + if (usage & NOUVEAU_BUFFER_USAGE_TEXTURE) + flags |= NOUVEAU_BO_GART; + if (!(usage & PIPE_BUFFER_USAGE_CPU_READ_WRITE)) + flags |= NOUVEAU_BO_VRAM; + + if (dev->chipset == 0x50 || dev->chipset >= 0x80) { + flags |= NOUVEAU_BO_TILED; + if (usage & NOUVEAU_BUFFER_USAGE_ZETA) + flags |= NOUVEAU_BO_ZTILE; + } + } + + ret = nouveau_bo_new(dev, flags, alignment, size, &bo); + if (ret) + return NULL; + + return nouveau_screen_bo_skel(pscreen, bo, alignment, usage, size); +} + +static struct pipe_buffer * +nouveau_screen_bo_user(struct pipe_screen *pscreen, void *ptr, unsigned bytes) +{ + struct nouveau_device *dev = nouveau_screen(pscreen)->device; + struct nouveau_bo *bo = NULL; + int ret; + + ret = nouveau_bo_user(dev, ptr, bytes, &bo); + if (ret) + return NULL; + + return nouveau_screen_bo_skel(pscreen, bo, 0, 0, bytes); +} + +static inline uint32_t +nouveau_screen_map_flags(unsigned pipe) +{ + uint32_t flags = 0; + + if (pipe & PIPE_BUFFER_USAGE_CPU_READ) + flags |= NOUVEAU_BO_RD; + if (pipe & PIPE_BUFFER_USAGE_CPU_WRITE) + flags |= NOUVEAU_BO_WR; +#ifdef NOUVEAU_BO_NOWAIT + if (pipe & PIPE_BUFFER_USAGE_DISCARD) + flags |= NOUVEAU_BO_INVAL; + + if (pipe & PIPE_BUFFER_USAGE_DONTBLOCK) + flags |= NOUVEAU_BO_NOWAIT; + else + if (pipe & 0 /*PIPE_BUFFER_USAGE_UNSYNCHRONIZED*/) + flags |= NOUVEAU_BO_NOSYNC; +#endif + + return flags; +} + +static void * +nouveau_screen_bo_map(struct pipe_screen *pscreen, struct pipe_buffer *pb, + unsigned usage) +{ + struct nouveau_bo *bo = nouveau_bo(pb); + int ret; + + ret = nouveau_bo_map(bo, nouveau_screen_map_flags(usage)); + if (ret) { + debug_printf("map failed: %d\n", ret); + return NULL; + } + + return bo->map; +} + +#ifdef NOUVEAU_BO_NOWAIT +static void * +nouveau_screen_bo_map_range(struct pipe_screen *pscreen, struct pipe_buffer *pb, + unsigned offset, unsigned length, unsigned usage) +{ + struct nouveau_bo *bo = nouveau_bo(pb); + int ret; + + ret = nouveau_bo_map_range(bo, offset, length, + nouveau_screen_map_flags(usage)); + if (ret) { + debug_printf("map_range failed: %d\n", ret); + return NULL; + } + + return bo->map; +} + +static void +nouveau_screen_bo_map_flush(struct pipe_screen *pscreen, struct pipe_buffer *pb, + unsigned offset, unsigned length) +{ + struct nouveau_bo *bo = nouveau_bo(pb); + + nouveau_bo_map_flush(bo, offset, length); +} +#endif + +static void +nouveau_screen_bo_unmap(struct pipe_screen *pscreen, struct pipe_buffer *pb) +{ + struct nouveau_bo *bo = nouveau_bo(pb); + + nouveau_bo_unmap(bo); +} + +static void +nouveau_screen_bo_del(struct pipe_buffer *pb) +{ + struct nouveau_bo *bo = nouveau_bo(pb); + + nouveau_bo_ref(NULL, &bo); + FREE(pb); +} + +static void +nouveau_screen_fence_ref(struct pipe_screen *pscreen, + struct pipe_fence_handle **ptr, + struct pipe_fence_handle *pfence) +{ + *ptr = pfence; +} + +static int +nouveau_screen_fence_signalled(struct pipe_screen *screen, + struct pipe_fence_handle *pfence, + unsigned flags) +{ + return 0; +} + +static int +nouveau_screen_fence_finish(struct pipe_screen *screen, + struct pipe_fence_handle *pfence, + unsigned flags) +{ + return 0; +} + +int +nouveau_screen_init(struct nouveau_screen *screen, struct nouveau_device *dev) +{ + struct pipe_screen *pscreen = &screen->base; + + screen->device = dev; + + pscreen->get_name = nouveau_screen_get_name; + pscreen->get_vendor = nouveau_screen_get_vendor; + + pscreen->buffer_create = nouveau_screen_bo_new; + pscreen->user_buffer_create = nouveau_screen_bo_user; + pscreen->buffer_map = nouveau_screen_bo_map; +#ifdef NOUVEAU_BO_NOWAIT + pscreen->buffer_map_range = nouveau_screen_bo_map_range; + pscreen->buffer_flush_mapped_range = nouveau_screen_bo_map_flush; +#endif + pscreen->buffer_unmap = nouveau_screen_bo_unmap; + pscreen->buffer_destroy = nouveau_screen_bo_del; + + pscreen->fence_reference = nouveau_screen_fence_ref; + pscreen->fence_signalled = nouveau_screen_fence_signalled; + pscreen->fence_finish = nouveau_screen_fence_finish; + + return 0; +} + +void +nouveau_screen_fini(struct nouveau_screen *screen) +{ +} + diff --git a/src/gallium/drivers/nouveau/nouveau_screen.h b/src/gallium/drivers/nouveau/nouveau_screen.h new file mode 100644 index 0000000000..cffba11762 --- /dev/null +++ b/src/gallium/drivers/nouveau/nouveau_screen.h @@ -0,0 +1,24 @@ +#ifndef __NOUVEAU_SCREEN_H__ +#define __NOUVEAU_SCREEN_H__ + +struct nouveau_screen { + struct pipe_screen base; + struct nouveau_device *device; +}; + +static inline struct nouveau_screen * +nouveau_screen(struct pipe_screen *pscreen) +{ + return (struct nouveau_screen *)pscreen; +} + +static inline struct nouveau_bo * +nouveau_bo(struct pipe_buffer *pb) +{ + return pb ? *(struct nouveau_bo **)(pb + 1) : NULL; +} + +int nouveau_screen_init(struct nouveau_screen *, struct nouveau_device *); +void nouveau_screen_fini(struct nouveau_screen *); + +#endif diff --git a/src/gallium/drivers/nv50/nv50_context.h b/src/gallium/drivers/nv50/nv50_context.h index d960657066..7b67a75439 100644 --- a/src/gallium/drivers/nv50/nv50_context.h +++ b/src/gallium/drivers/nv50/nv50_context.h @@ -23,8 +23,6 @@ #define NOUVEAU_MSG(fmt, args...) \ fprintf(stderr, "nouveau: "fmt, ##args); -#define nouveau_bo(pb) nv50->screen->nvws->get_bo(pb) - /* Constant buffer assignment */ #define NV50_CB_PMISC 0 #define NV50_CB_PVP 1 diff --git a/src/gallium/drivers/nv50/nv50_query.c b/src/gallium/drivers/nv50/nv50_query.c index 35cebdbdc3..4d05eeac2c 100644 --- a/src/gallium/drivers/nv50/nv50_query.c +++ b/src/gallium/drivers/nv50/nv50_query.c @@ -90,7 +90,7 @@ nv50_query_end(struct pipe_context *pipe, struct pipe_query *pq) struct nouveau_channel *chan = nv50->screen->nvws->channel; struct nouveau_grobj *tesla = nv50->screen->tesla; struct nv50_query *q = nv50_query(pq); - struct nouveau_bo *bo = nv50->screen->nvws->get_bo(q->buffer); + struct nouveau_bo *bo = nouveau_bo(q->buffer); WAIT_RING (chan, 5); BEGIN_RING(chan, tesla, 0x1b00, 4); diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c index b7e9df77db..3b830847ca 100644 --- a/src/gallium/drivers/nv50/nv50_screen.c +++ b/src/gallium/drivers/nv50/nv50_screen.c @@ -22,8 +22,6 @@ #include "pipe/p_screen.h" -#include "util/u_simple_screen.h" - #include "nv50_context.h" #include "nv50_screen.h" @@ -68,23 +66,6 @@ nv50_screen_is_format_supported(struct pipe_screen *pscreen, return FALSE; } -static const char * -nv50_screen_get_name(struct pipe_screen *pscreen) -{ - struct nv50_screen *screen = nv50_screen(pscreen); - struct nouveau_device *dev = screen->nvws->channel->device; - static char buffer[128]; - - snprintf(buffer, sizeof(buffer), "NV%02X", dev->chipset); - return buffer; -} - -static const char * -nv50_screen_get_vendor(struct pipe_screen *pscreen) -{ - return "nouveau"; -} - static int nv50_screen_get_param(struct pipe_screen *pscreen, int param) { @@ -153,7 +134,10 @@ nv50_screen_get_paramf(struct pipe_screen *pscreen, int param) static void nv50_screen_destroy(struct pipe_screen *pscreen) { - FREE(pscreen); + struct nv50_screen *screen = nv50_screen(pscreen); + + nouveau_screen_fini(&screen->base); + FREE(screen); } struct pipe_screen * @@ -161,6 +145,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) { struct nv50_screen *screen = CALLOC_STRUCT(nv50_screen); struct nouveau_device *dev = nvws->channel->device; + struct pipe_screen *pscreen; struct nouveau_stateobj *so; unsigned chipset = dev->chipset; unsigned tesla_class = 0; @@ -168,13 +153,31 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) if (!screen) return NULL; + pscreen = &screen->base.base; + + ret = nouveau_screen_init(&screen->base, nvws->channel->device); + if (ret) { + nv50_screen_destroy(pscreen); + return NULL; + } + + /* Setup the pipe */ screen->nvws = nvws; + pscreen->winsys = ws; + pscreen->destroy = nv50_screen_destroy; + pscreen->get_param = nv50_screen_get_param; + pscreen->get_paramf = nv50_screen_get_paramf; + pscreen->is_format_supported = nv50_screen_is_format_supported; + + nv50_screen_init_miptree_functions(pscreen); + nv50_transfer_init_screen_functions(pscreen); + /* DMA engine object */ ret = nvws->grobj_alloc(nvws, 0x5039, &screen->m2mf); if (ret) { NOUVEAU_ERR("Error creating M2MF object: %d\n", ret); - nv50_screen_destroy(&screen->pipe); + nv50_screen_destroy(pscreen); return NULL; } @@ -182,7 +185,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) ret = nvws->grobj_alloc(nvws, NV50_2D, &screen->eng2d); if (ret) { NOUVEAU_ERR("Error creating 2D object: %d\n", ret); - nv50_screen_destroy(&screen->pipe); + nv50_screen_destroy(pscreen); return NULL; } @@ -200,20 +203,20 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) break; default: NOUVEAU_ERR("Not a known NV50 chipset: NV%02x\n", chipset); - nv50_screen_destroy(&screen->pipe); + nv50_screen_destroy(pscreen); return NULL; } if (tesla_class == 0) { NOUVEAU_ERR("Unknown G8x chipset: NV%02x\n", chipset); - nv50_screen_destroy(&screen->pipe); + nv50_screen_destroy(pscreen); return NULL; } ret = nvws->grobj_alloc(nvws, tesla_class, &screen->tesla); if (ret) { NOUVEAU_ERR("Error creating 3D object: %d\n", ret); - nv50_screen_destroy(&screen->pipe); + nv50_screen_destroy(pscreen); return NULL; } @@ -221,26 +224,10 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) ret = nvws->notifier_alloc(nvws, 1, &screen->sync); if (ret) { NOUVEAU_ERR("Error creating notifier object: %d\n", ret); - nv50_screen_destroy(&screen->pipe); + nv50_screen_destroy(pscreen); return NULL; } - /* Setup the pipe */ - screen->pipe.winsys = ws; - - screen->pipe.destroy = nv50_screen_destroy; - - screen->pipe.get_name = nv50_screen_get_name; - screen->pipe.get_vendor = nv50_screen_get_vendor; - screen->pipe.get_param = nv50_screen_get_param; - screen->pipe.get_paramf = nv50_screen_get_paramf; - - screen->pipe.is_format_supported = nv50_screen_is_format_supported; - - nv50_screen_init_miptree_functions(&screen->pipe); - nv50_transfer_init_screen_functions(&screen->pipe); - u_simple_screen_init(&screen->pipe); - /* Static M2MF init */ so = so_new(32, 0); so_method(so, screen->m2mf, 0x0180, 3); @@ -295,7 +282,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 128*4*4, &screen->constbuf_misc[0]); if (ret) { - nv50_screen_destroy(&screen->pipe); + nv50_screen_destroy(pscreen); return NULL; } @@ -303,7 +290,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 128*4*4, &screen->constbuf_parm[i]); if (ret) { - nv50_screen_destroy(&screen->pipe); + nv50_screen_destroy(pscreen); return NULL; } } @@ -313,7 +300,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) nvws->res_init(&screen->parm_heap[1], 0, 128)) { NOUVEAU_ERR("Error initialising constant buffers.\n"); - nv50_screen_destroy(&screen->pipe); + nv50_screen_destroy(pscreen); return NULL; } @@ -362,7 +349,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) */ ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 32*8*4, &screen->tic); if (ret) { - nv50_screen_destroy(&screen->pipe); + nv50_screen_destroy(pscreen); return NULL; } @@ -381,7 +368,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) ret = nouveau_bo_new(dev, NOUVEAU_BO_VRAM, 0, 32*8*4, &screen->tsc); if (ret) { - nv50_screen_destroy(&screen->pipe); + nv50_screen_destroy(pscreen); return NULL; } @@ -420,6 +407,6 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws) so_ref (NULL, &so); nouveau_pushbuf_flush(nvws->channel, 0); - return &screen->pipe; + return pscreen; } diff --git a/src/gallium/drivers/nv50/nv50_screen.h b/src/gallium/drivers/nv50/nv50_screen.h index fa7d8d0f0d..61e24a5b57 100644 --- a/src/gallium/drivers/nv50/nv50_screen.h +++ b/src/gallium/drivers/nv50/nv50_screen.h @@ -1,10 +1,10 @@ #ifndef __NV50_SCREEN_H__ #define __NV50_SCREEN_H__ -#include "pipe/p_screen.h" +#include "nouveau/nouveau_screen.h" struct nv50_screen { - struct pipe_screen pipe; + struct nouveau_screen base; struct nouveau_winsys *nvws; diff --git a/src/gallium/drivers/nv50/nv50_surface.c b/src/gallium/drivers/nv50/nv50_surface.c index c0f0efe158..121eddfc83 100644 --- a/src/gallium/drivers/nv50/nv50_surface.c +++ b/src/gallium/drivers/nv50/nv50_surface.c @@ -54,14 +54,10 @@ nv50_surface_set(struct nv50_screen *screen, struct pipe_surface *ps, int dst) struct nv50_miptree *mt = nv50_miptree(ps->texture); struct nouveau_channel *chan = screen->nvws->channel; struct nouveau_grobj *eng2d = screen->eng2d; - struct nouveau_bo *bo; + struct nouveau_bo *bo = nouveau_bo(nv50_miptree(ps->texture)->buffer); int format, mthd = dst ? NV50_2D_DST_FORMAT : NV50_2D_SRC_FORMAT; int flags = NOUVEAU_BO_VRAM | (dst ? NOUVEAU_BO_WR : NOUVEAU_BO_RD); - bo = screen->nvws->get_bo(nv50_miptree(ps->texture)->buffer); - if (!bo) - return 1; - format = nv50_format(ps->format); if (format < 0) return 1; diff --git a/src/gallium/drivers/nv50/nv50_transfer.c b/src/gallium/drivers/nv50/nv50_transfer.c index 28e7edd144..5f1e430ad1 100644 --- a/src/gallium/drivers/nv50/nv50_transfer.c +++ b/src/gallium/drivers/nv50/nv50_transfer.c @@ -27,8 +27,8 @@ nv50_transfer_rect_m2mf(struct pipe_screen *pscreen, struct pipe_buffer *src, struct nouveau_winsys *nvws = screen->nvws; struct nouveau_channel *chan = nvws->channel; struct nouveau_grobj *m2mf = screen->m2mf; - struct nouveau_bo *src_bo = nvws->get_bo(src); - struct nouveau_bo *dst_bo = nvws->get_bo(dst); + struct nouveau_bo *src_bo = nouveau_bo(src); + struct nouveau_bo *dst_bo = nouveau_bo(dst); src_reloc |= NOUVEAU_BO_RD; dst_reloc |= NOUVEAU_BO_WR; diff --git a/src/gallium/winsys/drm/nouveau/dri/Makefile b/src/gallium/winsys/drm/nouveau/dri/Makefile index 024ab150cb..0937f68c34 100644 --- a/src/gallium/winsys/drm/nouveau/dri/Makefile +++ b/src/gallium/winsys/drm/nouveau/dri/Makefile @@ -11,7 +11,8 @@ PIPE_DRIVERS = \ $(TOP)/src/gallium/drivers/nv20/libnv20.a \ $(TOP)/src/gallium/drivers/nv30/libnv30.a \ $(TOP)/src/gallium/drivers/nv40/libnv40.a \ - $(TOP)/src/gallium/drivers/nv50/libnv50.a + $(TOP)/src/gallium/drivers/nv50/libnv50.a \ + $(TOP)/src/gallium/drivers/nouveau/libnouveau.a DRIVER_SOURCES = -- cgit v1.2.3 From 7eed6ab5b525b75f690d05042c90d05827253114 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Mon, 8 Jun 2009 16:02:18 +0100 Subject: Cygwin build fixes Fix mklib to deal with NOPREFIX and use --enable-auto-image-base for cygwin Teach configure.ac some basic facts about cygwin Signed-off-by: Jon TURNEY --- bin/mklib | 19 ++++++++++++++++--- configure.ac | 5 +++++ 2 files changed, 21 insertions(+), 3 deletions(-) (limited to 'configure.ac') diff --git a/bin/mklib b/bin/mklib index 2fd95ba775..2444945006 100755 --- a/bin/mklib +++ b/bin/mklib @@ -885,6 +885,17 @@ case $ARCH in CYGWIN*) # GCC-based environment + if [ $NOPREFIX = 1 ] ; then + # No "lib" or ".so" part + echo "mklib: Making CYGWIN shared library: " ${LIBNAME} + OPTS="-shared -Wl,--enable-auto-image-base" + if [ "${ALTOPTS}" ] ; then + OPTS=${ALTOPTS} + fi + rm -f ${LIBNAME} + ${LINK} ${OPTS} ${LDFLAGS} -o ${LIBNAME} ${OBJECTS} ${DEPS} + FINAL_LIBS=${LIBNAME} + else CYGNAME="cyg${LIBNAME}" # prefix with "cyg" LIBNAME="lib${LIBNAME}" # prefix with "lib" @@ -901,11 +912,11 @@ case $ARCH in # finish up FINAL_LIBS=${LIBNAME}.a else - OPTS="-shared -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a" + OPTS="-shared -Wl,--enable-auto-image-base -Wl,-export-all -Wl,--out-implib=${LIBNAME}-${MAJOR}.dll.a" if [ "${ALTOPTS}" ] ; then OPTS=${ALTOPTS} fi - echo "mklib: Making" $ARCH "shared library: " ${LIBNAME}-${MAJOR}.dll + echo "mklib: Making" $ARCH "shared library: " ${CYGNAME}-${MAJOR}.dll if [ $CPLUSPLUS = 1 ] ; then LINK="g++" @@ -914,7 +925,8 @@ case $ARCH in fi # rm any old libs - rm -f ${LIBNAME}-${MAJOR}.dll + rm -f ${CYGNAME}-${MAJOR}.dll + rm -f ${LIBNAME}-${MAJOR}.dll.a rm -f ${LIBNAME}.dll.a rm -f ${LIBNAME}.a @@ -927,6 +939,7 @@ case $ARCH in # special case for installing in bin FINAL_BINS="${CYGNAME}-${MAJOR}.dll" fi + fi ;; 'example') diff --git a/configure.ac b/configure.ac index 48b8022736..2a9ac1ed9c 100644 --- a/configure.ac +++ b/configure.ac @@ -222,6 +222,8 @@ else case "$host_os" in darwin* ) LIB_EXTENSION='dylib' ;; + cygwin* ) + LIB_EXTENSION='dll' ;; * ) LIB_EXTENSION='so' ;; esac @@ -1073,6 +1075,9 @@ if test "x$APP_LIB_DEPS" = x; then solaris*) APP_LIB_DEPS="-lX11 -lsocket -lnsl -lm" ;; + cygwin*) + APP_LIB_DEPS="-lX11" + ;; *) APP_LIB_DEPS="-lm" ;; -- cgit v1.2.3