summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/Android.mk2
-rw-r--r--src/gallium/drivers/llvmpipe/Android.mk37
-rw-r--r--src/gallium/include/state_tracker/drm_driver.h10
-rw-r--r--src/gallium/state_trackers/dri/dri2.c6
-rw-r--r--src/gallium/state_trackers/dri/drisw.c46
-rw-r--r--src/gallium/targets/dri/Android.mk8
-rw-r--r--src/gallium/winsys/sw/dri/Android.mk2
-rw-r--r--src/gallium/winsys/sw/dri/dri_sw_winsys.c64
8 files changed, 168 insertions, 7 deletions
diff --git a/src/gallium/Android.mk b/src/gallium/Android.mk
index 2b469b6..690b289 100644
--- a/src/gallium/Android.mk
+++ b/src/gallium/Android.mk
@@ -35,7 +35,7 @@ SUBDIRS += auxiliary/pipe-loader
# swrast
ifneq ($(filter swrast,$(MESA_GPU_DRIVERS)),)
-SUBDIRS += winsys/sw/dri drivers/softpipe
+SUBDIRS += winsys/sw/dri drivers/llvmpipe drivers/softpipe
endif
# freedreno
diff --git a/src/gallium/drivers/llvmpipe/Android.mk b/src/gallium/drivers/llvmpipe/Android.mk
new file mode 100644
index 0000000..b074e34
--- /dev/null
+++ b/src/gallium/drivers/llvmpipe/Android.mk
@@ -0,0 +1,37 @@
+# Mesa 3-D graphics library
+#
+# Copyright (C) 2015-2016 Zhen Wu <wuzhen@jidemail.com>
+# Copyright (C) 2015-2016 Jide Inc.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+
+LOCAL_PATH := $(call my-dir)
+
+# get C_SOURCES
+include $(LOCAL_PATH)/Makefile.sources
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ $(C_SOURCES)
+
+LOCAL_MODULE := libmesa_pipe_llvmpipe
+
+include $(GALLIUM_COMMON_MK)
+include $(BUILD_STATIC_LIBRARY)
diff --git a/src/gallium/include/state_tracker/drm_driver.h b/src/gallium/include/state_tracker/drm_driver.h
index c80fb09..b8dfd23 100644
--- a/src/gallium/include/state_tracker/drm_driver.h
+++ b/src/gallium/include/state_tracker/drm_driver.h
@@ -11,6 +11,7 @@ struct pipe_resource;
#define DRM_API_HANDLE_TYPE_SHARED 0
#define DRM_API_HANDLE_TYPE_KMS 1
#define DRM_API_HANDLE_TYPE_FD 2
+#define DRM_API_HANDLE_TYPE_BUFFER 3
/**
@@ -20,11 +21,18 @@ struct winsys_handle
{
/**
* Input for texture_from_handle, valid values are
- * DRM_API_HANDLE_TYPE_SHARED or DRM_API_HANDLE_TYPE_FD.
+ * DRM_API_HANDLE_TYPE_SHARED or DRM_API_HANDLE_TYPE_FD or DRM_API_HANDLE_TYPE_BUFFER.
* Input to texture_get_handle,
* to select handle for kms, flink, or prime.
*/
unsigned type;
+
+ /**
+ * Input to texture_from_handle.
+ * Output for texture_get_handle.
+ */
+ void* externalBuffer;
+
/**
* Input for texture_get_handle, allows to export the offset
* of a specific layer of an array texture.
diff --git a/src/gallium/state_trackers/dri/dri2.c b/src/gallium/state_trackers/dri/dri2.c
index db8f70e..8c058f7 100644
--- a/src/gallium/state_trackers/dri/dri2.c
+++ b/src/gallium/state_trackers/dri/dri2.c
@@ -765,7 +765,7 @@ dri2_update_tex_buffer(struct dri_drawable *drawable,
/* no-op */
}
-static __DRIimage *
+__DRIimage *
dri2_lookup_egl_image(struct dri_screen *screen, void *handle)
{
const __DRIimageLookupExtension *loader = screen->sPriv->dri2.image;
@@ -780,7 +780,7 @@ dri2_lookup_egl_image(struct dri_screen *screen, void *handle)
return img;
}
-static __DRIimage *
+__DRIimage *
dri2_create_image_from_winsys(__DRIscreen *_screen,
int width, int height, int format,
int num_handles, struct winsys_handle *whandle,
@@ -1374,7 +1374,7 @@ dri2_unmap_image(__DRIcontext *context, __DRIimage *image, void *data)
pipe_transfer_unmap(pipe, (struct pipe_transfer *)data);
}
-static void
+void
dri2_destroy_image(__DRIimage *img)
{
pipe_resource_reference(&img->texture, NULL);
diff --git a/src/gallium/state_trackers/dri/drisw.c b/src/gallium/state_trackers/dri/drisw.c
index b85a73c..9b62b96 100644
--- a/src/gallium/state_trackers/dri/drisw.c
+++ b/src/gallium/state_trackers/dri/drisw.c
@@ -361,14 +361,57 @@ drisw_update_tex_buffer(struct dri_drawable *drawable,
pipe_transfer_unmap(pipe, transfer);
}
+extern __DRIimage *dri2_lookup_egl_image(struct dri_screen *screen, void *handle);
+
+extern __DRIimage *dri2_create_image_from_winsys(__DRIscreen *_screen,
+ int width, int height, int format,
+ int num_handles, struct winsys_handle *whandle,
+ void *loaderPrivate);
+
+extern void dri2_destroy_image(__DRIimage *img);
+
+static GLboolean
+drisw_query_image(__DRIimage *image, int attrib, int *value)
+{
+ switch (attrib) {
+ case __DRI_IMAGE_ATTRIB_FORMAT:
+ *value = image->dri_format;
+ return GL_TRUE;
+ case __DRI_IMAGE_ATTRIB_WIDTH:
+ *value = image->texture->width0;
+ return GL_TRUE;
+ case __DRI_IMAGE_ATTRIB_HEIGHT:
+ *value = image->texture->height0;
+ return GL_TRUE;
+ case __DRI_IMAGE_ATTRIB_COMPONENTS:
+ if (image->dri_components == 0)
+ return GL_FALSE;
+ *value = image->dri_components;
+ return GL_TRUE;
+ case __DRI_IMAGE_ATTRIB_NUM_PLANES:
+ *value = 1;
+ return GL_TRUE;
+ default:
+ return GL_FALSE;
+ }
+}
+
/*
* Backend function for init_screen.
*/
+static const __DRIimageExtension driswImageExtension = {
+ .base = { __DRI_IMAGE, 11 },
+
+ .destroyImage = dri2_destroy_image,
+ .queryImage = drisw_query_image,
+};
+
static const __DRIextension *drisw_screen_extensions[] = {
&driTexBufferExtension.base,
&dri2RendererQueryExtension.base,
&dri2ConfigQueryExtension.base,
+ &driswImageExtension.base,
NULL
};
@@ -407,6 +450,9 @@ drisw_init_screen(__DRIscreen * sPriv)
if (!configs)
goto fail;
+ screen->lookup_egl_image = dri2_lookup_egl_image;
+ driSWRastExtension.createImageFromWinsys = dri2_create_image_from_winsys;
+
return configs;
fail:
dri_destroy_screen_helper(screen);
diff --git a/src/gallium/targets/dri/Android.mk b/src/gallium/targets/dri/Android.mk
index f1a5b0e..13505c8 100644
--- a/src/gallium/targets/dri/Android.mk
+++ b/src/gallium/targets/dri/Android.mk
@@ -49,6 +49,7 @@ LOCAL_SHARED_LIBRARIES := \
liblog \
libglapi \
libexpat \
+ libhardware \
ifneq ($(filter freedreno,$(MESA_GPU_DRIVERS)),)
LOCAL_CFLAGS += -DGALLIUM_FREEDRENO
@@ -88,8 +89,9 @@ gallium_DRIVERS += libmesa_winsys_radeon libmesa_pipe_radeon libmesa_amdgpu_addr
LOCAL_SHARED_LIBRARIES += libdrm_radeon
endif
ifneq ($(filter swrast,$(MESA_GPU_DRIVERS)),)
-gallium_DRIVERS += libmesa_pipe_softpipe libmesa_winsys_sw_dri
-LOCAL_CFLAGS += -DGALLIUM_SOFTPIPE
+gallium_DRIVERS += libmesa_pipe_llvmpipe libmesa_pipe_softpipe libmesa_winsys_sw_dri
+LOCAL_CFLAGS += -DGALLIUM_LLVMPIPE -DGALLIUM_SOFTPIPE
+LOCAL_SHARED_LIBRARIES += libLLVM
endif
ifneq ($(filter vc4,$(MESA_GPU_DRIVERS)),)
LOCAL_CFLAGS += -DGALLIUM_VC4
@@ -133,5 +135,7 @@ LOCAL_STATIC_LIBRARIES += \
LOCAL_LDLIBS += $(if $(filter true,$(MESA_LOLLIPOP_BUILD)),-lgcc)
endif
+LOCAL_ADDITION_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
+
include $(GALLIUM_COMMON_MK)
include $(BUILD_SHARED_LIBRARY)
diff --git a/src/gallium/winsys/sw/dri/Android.mk b/src/gallium/winsys/sw/dri/Android.mk
index 72fb920..d25e677 100644
--- a/src/gallium/winsys/sw/dri/Android.mk
+++ b/src/gallium/winsys/sw/dri/Android.mk
@@ -29,6 +29,8 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(C_SOURCES)
+LOCAL_CFLAGS += -DHAVE_ANDROID_PLATFORM
+
LOCAL_MODULE := libmesa_winsys_sw_dri
include $(GALLIUM_COMMON_MK)
diff --git a/src/gallium/winsys/sw/dri/dri_sw_winsys.c b/src/gallium/winsys/sw/dri/dri_sw_winsys.c
index 94d5092..ea1fe58 100644
--- a/src/gallium/winsys/sw/dri/dri_sw_winsys.c
+++ b/src/gallium/winsys/sw/dri/dri_sw_winsys.c
@@ -34,8 +34,14 @@
#include "util/u_memory.h"
#include "state_tracker/sw_winsys.h"
+#include "state_tracker/drm_driver.h"
#include "dri_sw_winsys.h"
+#ifdef HAVE_ANDROID_PLATFORM
+#include <system/graphics.h>
+#include <system/window.h>
+#include <hardware/gralloc.h>
+#endif
struct dri_sw_displaytarget
{
@@ -45,11 +51,31 @@ struct dri_sw_displaytarget
unsigned stride;
unsigned map_flags;
+#ifdef HAVE_ANDROID_PLATFORM
+ struct ANativeWindowBuffer *androidBuffer;
+#endif
void *data;
void *mapped;
const void *front_private;
};
+#ifdef HAVE_ANDROID_PLATFORM
+const struct gralloc_module_t* get_gralloc()
+{
+ static const struct gralloc_module_t* gr_module = NULL;
+ const hw_module_t *mod;
+ int err;
+
+ if (!gr_module) {
+ err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &mod);
+ if (!err) {
+ gr_module = (gralloc_module_t *) mod;
+ }
+ }
+ return gr_module;
+}
+#endif
+
struct dri_sw_winsys
{
struct sw_winsys base;
@@ -125,6 +151,12 @@ dri_sw_displaytarget_destroy(struct sw_winsys *ws,
{
struct dri_sw_displaytarget *dri_sw_dt = dri_sw_displaytarget(dt);
+#ifdef HAVE_ANDROID_PLATFORM
+ if (dri_sw_dt->androidBuffer) {
+ dri_sw_dt->androidBuffer->common.decRef(&dri_sw_dt->androidBuffer->common);
+ }
+#endif
+
align_free(dri_sw_dt->data);
FREE(dri_sw_dt);
@@ -136,6 +168,17 @@ dri_sw_displaytarget_map(struct sw_winsys *ws,
unsigned flags)
{
struct dri_sw_displaytarget *dri_sw_dt = dri_sw_displaytarget(dt);
+#ifdef HAVE_ANDROID_PLATFORM
+ if (dri_sw_dt->androidBuffer) {
+ if (!get_gralloc()->lock(get_gralloc(), dri_sw_dt->androidBuffer->handle,
+ GRALLOC_USAGE_SW_READ_OFTEN | GRALLOC_USAGE_SW_WRITE_OFTEN,
+ 0, 0, dri_sw_dt->androidBuffer->width, dri_sw_dt->androidBuffer->height,
+ (void**)&dri_sw_dt->mapped)) {
+ dri_sw_dt->map_flags = flags;
+ return dri_sw_dt->mapped;
+ }
+ }
+#endif
dri_sw_dt->mapped = dri_sw_dt->data;
if (dri_sw_dt->front_private && (flags & PIPE_TRANSFER_READ)) {
@@ -156,6 +199,11 @@ dri_sw_displaytarget_unmap(struct sw_winsys *ws,
dri_sw_ws->lf->put_image2((void *)dri_sw_dt->front_private, dri_sw_dt->data, 0, 0, dri_sw_dt->width, dri_sw_dt->height, dri_sw_dt->stride);
}
dri_sw_dt->map_flags = 0;
+#ifdef HAVE_ANDROID_PLATFORM
+ if (dri_sw_dt->androidBuffer) {
+ get_gralloc()->unlock(get_gralloc(), dri_sw_dt->androidBuffer->handle);
+ }
+#endif
dri_sw_dt->mapped = NULL;
}
@@ -165,6 +213,22 @@ dri_sw_displaytarget_from_handle(struct sw_winsys *winsys,
struct winsys_handle *whandle,
unsigned *stride)
{
+#ifdef HAVE_ANDROID_PLATFORM
+ struct dri_sw_displaytarget *dri_sw_dt;
+
+ if (whandle->type == DRM_API_HANDLE_TYPE_BUFFER) {
+ dri_sw_dt = CALLOC_STRUCT(dri_sw_displaytarget);
+ dri_sw_dt->width = templ->width0;
+ dri_sw_dt->height = templ->height0;
+ dri_sw_dt->androidBuffer = whandle->externalBuffer;
+ dri_sw_dt->stride = whandle->stride;
+
+ dri_sw_dt->androidBuffer->common.incRef(&dri_sw_dt->androidBuffer->common);
+ *stride = dri_sw_dt->stride;
+
+ return dri_sw_dt;
+ }
+#endif
assert(0);
return NULL;
}