Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

tegra: Gallium driver for NVIDIA Tegra

Add a stub Gallium driver for NVIDIA Tegra SoCs to serve as a basis for
future development. The driver contains enough stubs to allow Wayland's
reference compositor Weston to run, though without any actual output.

Signed-off-by: Thierry Reding <thierry.reding@avionic-design.de>
  • Loading branch information...
commit b33282cb998321786217c0026f9a17a0ba48abb5 1 parent 43a8a6d
Thierry Reding authored
View
12 configure.ac
@@ -36,6 +36,7 @@ LIBDRM_INTEL_REQUIRED=2.4.38
LIBDRM_NVVIEUX_REQUIRED=2.4.33
LIBDRM_NOUVEAU_REQUIRED="2.4.33 libdrm >= 2.4.41"
LIBDRM_FREEDRENO_REQUIRED=2.4.39
+LIBDRM_TEGRA_REQUIRED=2.4.42
DRI2PROTO_REQUIRED=2.6
GLPROTO_REQUIRED=1.4.14
LIBDRM_XORG_REQUIRED=2.4.24
@@ -1848,6 +1849,13 @@ if test "x$with_gallium_drivers" != x; then
GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS freedreno"
gallium_check_st "freedreno/drm" "dri-freedreno" "" "" "" ""
;;
+ xtegra)
+ HAVE_GALLIUM_TEGRA=yes
+ PKG_CHECK_MODULES([TEGRA], [libdrm_tegra >= $LIBDRM_TEGRA_REQUIRED])
+ gallium_require_drm_loader
+ GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS tegra"
+ gallium_check_st "tegra/drm" "dri-tegra" "" "" "" ""
+ ;;
xswrast)
HAVE_GALLIUM_SOFTPIPE=yes
GALLIUM_DRIVERS_DIRS="$GALLIUM_DRIVERS_DIRS softpipe"
@@ -1929,6 +1937,7 @@ AM_CONDITIONAL(HAVE_GALLIUM_R600, test "x$HAVE_GALLIUM_R600" = xyes)
AM_CONDITIONAL(HAVE_GALLIUM_RADEONSI, test "x$HAVE_GALLIUM_RADEONSI" = xyes)
AM_CONDITIONAL(HAVE_GALLIUM_NOUVEAU, test "x$HAVE_GALLIUM_NOUVEAU" = xyes)
AM_CONDITIONAL(HAVE_GALLIUM_FREEDRENO, test "x$HAVE_GALLIUM_FREEDRENO" = xyes)
+AM_CONDITIONAL(HAVE_GALLIUM_TEGRA, test "x$HAVE_GALLIUM_TEGRA" = xyes)
AM_CONDITIONAL(HAVE_GALLIUM_SOFTPIPE, test "x$HAVE_GALLIUM_SOFTPIPE" = xyes)
AM_CONDITIONAL(HAVE_GALLIUM_LLVMPIPE, test "x$HAVE_GALLIUM_LLVMPIPE" = xyes)
@@ -2061,6 +2070,7 @@ AC_CONFIG_FILES([Makefile
src/gallium/drivers/rbug/Makefile
src/gallium/drivers/softpipe/Makefile
src/gallium/drivers/svga/Makefile
+ src/gallium/drivers/tegra/Makefile
src/gallium/drivers/trace/Makefile
src/gallium/state_trackers/Makefile
src/gallium/state_trackers/clover/Makefile
@@ -2084,6 +2094,7 @@ AC_CONFIG_FILES([Makefile
src/gallium/targets/dri-r600/Makefile
src/gallium/targets/dri-radeonsi/Makefile
src/gallium/targets/dri-swrast/Makefile
+ src/gallium/targets/dri-tegra/Makefile
src/gallium/targets/dri-vmwgfx/Makefile
src/gallium/targets/egl-static/Makefile
src/gallium/targets/gbm/Makefile
@@ -2122,6 +2133,7 @@ AC_CONFIG_FILES([Makefile
src/gallium/winsys/sw/wayland/Makefile
src/gallium/winsys/sw/wrapper/Makefile
src/gallium/winsys/sw/xlib/Makefile
+ src/gallium/winsys/tegra/drm/Makefile
src/gbm/Makefile
src/gbm/main/gbm.pc
src/glsl/Makefile
View
24 src/gallium/drivers/tegra/Makefile.am
@@ -0,0 +1,24 @@
+include $(top_srcdir)/src/gallium/Automake.inc
+
+noinst_LTLIBRARIES = libtegra.la
+
+AM_CPPFLAGS = \
+ -I$(top_srcdir)/src/gallium/drivers/tegra/include \
+ -I$(top_srcdir)/src/gallium/drivers \
+ -I$(top_srcdir)/include
+
+AM_CFLAGS = \
+ $(GALLIUM_CFLAGS) \
+ $(LIBDRM_CFLAGS)
+
+libtegra_la_SOURCES = \
+ tegra_context.c \
+ tegra_context.h \
+ tegra_resource.c \
+ tegra_resource.h \
+ tegra_screen.c \
+ tegra_screen.h \
+ tegra_state.c \
+ tegra_state.h \
+ tegra_surface.c \
+ tegra_surface.h
View
57 src/gallium/drivers/tegra/tegra_context.c
@@ -0,0 +1,57 @@
+#include <stdio.h>
+
+#include "tegra_context.h"
+#include "tegra_state.h"
+#include "tegra_surface.h"
+
+static void tegra_context_destroy(struct pipe_context *pcontext)
+{
+ struct tegra_context *context = tegra_context(pcontext);
+
+ fprintf(stdout, "> %s(pcontext=%p)\n", __func__, pcontext);
+
+ free(context);
+
+ fprintf(stdout, "< %s()\n", __func__);
+}
+
+static void tegra_context_flush(struct pipe_context *pcontext,
+ struct pipe_fence_handle **fence,
+ enum pipe_flush_flags flags)
+{
+ fprintf(stdout, "> %s(pcontext=%p, fence=%p, flags=%x)\n", __func__,
+ pcontext, fence, flags);
+ fprintf(stdout, "< %s()\n", __func__);
+}
+
+struct pipe_context *tegra_screen_context_create(struct pipe_screen *pscreen,
+ void *priv)
+{
+ struct tegra_context *context;
+
+ fprintf(stdout, "> %s(pscreen=%p, priv=%p)\n", __func__, pscreen, priv);
+
+ context = calloc(1, sizeof(*context));
+ if (!context) {
+ fprintf(stdout, "< %s() = NULL\n", __func__);
+ return NULL;
+ }
+
+ context->base.screen = pscreen;
+ context->base.priv = priv;
+
+ context->base.destroy = tegra_context_destroy;
+ context->base.flush = tegra_context_flush;
+
+ tegra_context_surface_init(&context->base);
+ tegra_context_state_init(&context->base);
+ tegra_context_blend_init(&context->base);
+ tegra_context_rasterizer_init(&context->base);
+ tegra_context_zsa_init(&context->base);
+ tegra_context_vs_init(&context->base);
+ tegra_context_fs_init(&context->base);
+ tegra_context_vbo_init(&context->base);
+
+ fprintf(stdout, "< %s() = %p\n", __func__, &context->base);
+ return &context->base;
+}
View
18 src/gallium/drivers/tegra/tegra_context.h
@@ -0,0 +1,18 @@
+#ifndef TEGRA_CONTEXT_H
+#define TEGRA_CONTEXT_H
+
+#include "pipe/p_context.h"
+
+struct tegra_context {
+ struct pipe_context base;
+};
+
+static INLINE struct tegra_context *tegra_context(struct pipe_context *context)
+{
+ return (struct tegra_context *)context;
+}
+
+struct pipe_context *tegra_screen_context_create(struct pipe_screen *pscreen,
+ void *priv);
+
+#endif
View
94 src/gallium/drivers/tegra/tegra_resource.c
@@ -0,0 +1,94 @@
+#include <stdio.h>
+
+#include "util/u_inlines.h"
+
+#include "tegra_resource.h"
+
+static boolean
+tegra_screen_can_create_resource(struct pipe_screen *pscreen,
+ const struct pipe_resource *template)
+{
+ bool ret = TRUE;
+ fprintf(stdout, "> %s(pscreen=%p, template=%p)\n", __func__, pscreen,
+ template);
+ fprintf(stdout, "< %s() = %d\n", __func__, ret);
+ return ret;
+}
+
+static struct pipe_resource *
+tegra_screen_resource_create(struct pipe_screen *pscreen,
+ const struct pipe_resource *template)
+{
+ struct tegra_resource *resource;
+
+ fprintf(stdout, "> %s(pscreen=%p, template=%p)\n", __func__, pscreen,
+ template);
+
+ resource = calloc(1, sizeof(*resource));
+ if (!resource) {
+ fprintf(stdout, "< %s() = NULL\n", __func__);
+ return NULL;
+ }
+
+ resource->base = *template;
+
+ pipe_reference_init(&resource->base.reference, 1);
+ resource->base.screen = pscreen;
+
+ fprintf(stdout, "< %s() = %p\n", __func__, &resource->base);
+ return &resource->base;
+}
+
+static struct pipe_resource *
+tegra_screen_resource_from_handle(struct pipe_screen *pscreen,
+ const struct pipe_resource *template,
+ struct winsys_handle *handle)
+{
+ struct tegra_resource *resource;
+
+ fprintf(stdout, "> %s(pscreen=%p, template=%p, handle=%p)\n",
+ __func__, pscreen, template, handle);
+
+ resource = calloc(1, sizeof(*resource));
+ if (!resource) {
+ fprintf(stdout, "< %s() = NULL\n", __func__);
+ return NULL;
+ }
+
+ resource->base = *template;
+
+ pipe_reference_init(&resource->base.reference, 1);
+ resource->base.screen = pscreen;
+
+ fprintf(stdout, "< %s() = %p\n", __func__, &resource->base);
+ return &resource->base;
+}
+
+static boolean
+tegra_screen_resource_get_handle(struct pipe_screen *pscreen,
+ struct pipe_resource *resource,
+ struct winsys_handle *handle)
+{
+ boolean ret = TRUE;
+ fprintf(stdout, "> %s(pscreen=%p, resource=%p, handle=%p)\n",
+ __func__, pscreen, resource, handle);
+ fprintf(stdout, "< %s() = %d\n", __func__, ret);
+ return ret;
+}
+
+static void tegra_screen_resource_destroy(struct pipe_screen *pscreen,
+ struct pipe_resource *resource)
+{
+ fprintf(stdout, "> %s(pscreen=%p, resource=%p)\n", __func__, pscreen,
+ resource);
+ fprintf(stdout, "< %s()\n", __func__);
+}
+
+void tegra_screen_resource_init(struct pipe_screen *pscreen)
+{
+ pscreen->can_create_resource = tegra_screen_can_create_resource;
+ pscreen->resource_create = tegra_screen_resource_create;
+ pscreen->resource_from_handle = tegra_screen_resource_from_handle;
+ pscreen->resource_get_handle = tegra_screen_resource_get_handle;
+ pscreen->resource_destroy = tegra_screen_resource_destroy;
+}
View
13 src/gallium/drivers/tegra/tegra_resource.h
@@ -0,0 +1,13 @@
+#ifndef TEGRA_RESOURCE_H
+#define TEGRA_RESOURCE_H
+
+#include "pipe/p_screen.h"
+#include "pipe/p_state.h"
+
+struct tegra_resource {
+ struct pipe_resource base;
+};
+
+void tegra_screen_resource_init(struct pipe_screen *pscreen);
+
+#endif
View
695 src/gallium/drivers/tegra/tegra_screen.c
@@ -0,0 +1,695 @@
+#include <stdio.h>
+
+#include "tegra_context.h"
+#include "tegra_resource.h"
+#include "tegra_screen.h"
+
+static void tegra_screen_destroy(struct pipe_screen *pscreen)
+{
+ fprintf(stdout, "> %s(pscreen=%p)\n", __func__, pscreen);
+ fprintf(stdout, "< %s()\n", __func__);
+}
+
+static const char *tegra_screen_get_name(struct pipe_screen *pscreen)
+{
+ const char *name = "Tegra";
+ fprintf(stderr, "> %s(pscreen=%p)\n", __func__, pscreen);
+ fprintf(stderr, "< %s() = %s\n", __func__, name);
+ return name;
+}
+
+static const char *tegra_screen_get_vendor(struct pipe_screen *pscreen)
+{
+ const char *vendor = "NVIDIA";
+ fprintf(stderr, "> %s(pscreen=%p)\n", __func__, pscreen);
+ fprintf(stderr, "< %s() = %s\n", __func__, vendor);
+ return vendor;
+}
+
+static int tegra_screen_get_param(struct pipe_screen *pscreen,
+ enum pipe_cap param)
+{
+ int ret = 0;
+
+ //fprintf(stdout, "> %s(pscreen=%p, param=%d)\n", __func__, pscreen,
+ // param);
+
+ switch (param) {
+ case PIPE_CAP_NPOT_TEXTURES:
+ fprintf(stdout, " PIPE_CAP_NPOT_TEXTURES\n");
+ ret = 1;
+ break;
+
+ case PIPE_CAP_TWO_SIDED_STENCIL:
+ fprintf(stdout, " PIPE_CAP_TWO_SIDED_STENCIL\n");
+ ret = 1;
+ break;
+
+ case PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS:
+ fprintf(stdout, " PIPE_CAP_MAX_DUAL_SOURCE_RENDER_TARGETS\n");
+ ret = 1;
+ break;
+
+ case PIPE_CAP_ANISOTROPIC_FILTER:
+ fprintf(stdout, " PIPE_CAP_ANISOTROPIC_FILTER\n");
+ ret = 1;
+ break;
+
+ case PIPE_CAP_POINT_SPRITE:
+ fprintf(stdout, " PIPE_CAP_POINT_SPRITE\n");
+ ret = 1;
+ break;
+
+ case PIPE_CAP_MAX_RENDER_TARGETS:
+ fprintf(stdout, " PIPE_CAP_MAX_RENDER_TARGETS\n");
+ ret = 8;
+ break;
+
+ case PIPE_CAP_OCCLUSION_QUERY:
+ fprintf(stdout, " PIPE_CAP_OCCLUSION_QUERY\n");
+ ret = 0;
+ break;
+
+ case PIPE_CAP_QUERY_TIME_ELAPSED:
+ fprintf(stdout, " PIPE_CAP_QUERY_TIME_ELAPSED\n");
+ ret = 0;
+ break;
+
+ case PIPE_CAP_TEXTURE_SHADOW_MAP:
+ fprintf(stdout, " PIPE_CAP_TEXTURE_SHADOW_MAP\n");
+ ret = 1;
+ break;
+
+ case PIPE_CAP_TEXTURE_SWIZZLE:
+ fprintf(stdout, " PIPE_CAP_TEXTURE_SWIZZLE\n");
+ ret = 1;
+ break;
+
+ case PIPE_CAP_MAX_TEXTURE_2D_LEVELS:
+ fprintf(stdout, " PIPE_CAP_MAX_TEXTURE_2D_LEVELS\n");
+ ret = 1;
+ break;
+
+ case PIPE_CAP_MAX_TEXTURE_3D_LEVELS:
+ fprintf(stdout, " PIPE_CAP_MAX_TEXTURE_3D_LEVELS\n");
+ ret = 1;
+ break;
+
+ case PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS:
+ fprintf(stdout, " PIPE_CAP_MAX_TEXTURE_CUBE_LEVELS\n");
+ ret = 1;
+ break;
+
+ case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
+ fprintf(stdout, " PIPE_CAP_TEXTURE_MIRROR_CLAMP\n");
+ ret = 1;
+ break;
+
+ case PIPE_CAP_BLEND_EQUATION_SEPARATE:
+ fprintf(stdout, " PIPE_CAP_BLEND_EQUATION_SEPARATE\n");
+ ret = 1;
+ break;
+
+ case PIPE_CAP_SM3:
+ fprintf(stdout, " PIPE_CAP_SM3\n");
+ ret = 1;
+ break;
+
+ case PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS:
+ fprintf(stdout, " PIPE_CAP_MAX_STREAM_OUTPUT_BUFFERS\n");
+ ret = 0;
+ break;
+
+ case PIPE_CAP_PRIMITIVE_RESTART:
+ fprintf(stdout, " PIPE_CAP_PRIMITIVE_RESTART\n");
+ ret = 1;
+ break;
+
+ case PIPE_CAP_MAX_COMBINED_SAMPLERS:
+ fprintf(stdout, " PIPE_CAP_MAX_COMBINED_SAMPLERS\n");
+ ret = 8;
+ break;
+
+ case PIPE_CAP_INDEP_BLEND_ENABLE:
+ fprintf(stdout, " PIPE_CAP_INDEP_BLEND_ENABLE\n");
+ ret = 0;
+ break;
+
+ case PIPE_CAP_INDEP_BLEND_FUNC:
+ fprintf(stdout, " PIPE_CAP_INDEP_BLEND_FUNC\n");
+ ret = 0;
+ break;
+
+ case PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS:
+ fprintf(stdout, " PIPE_CAP_MAX_TEXTURE_ARRAY_LAYERS\n");
+ ret = 1;
+ break;
+
+ case PIPE_CAP_DEPTH_CLIP_DISABLE:
+ fprintf(stdout, " PIPE_CAP_DEPTH_CLIP_DISABLE\n");
+ ret = 0;
+ break;
+
+ case PIPE_CAP_SHADER_STENCIL_EXPORT:
+ fprintf(stdout, " PIPE_CAP_SHADER_STENCIL_EXPORT\n");
+ ret = 1;
+ break;
+
+ case PIPE_CAP_TGSI_INSTANCEID:
+ fprintf(stdout, " PIPE_CAP_TGSI_INSTANCEID\n");
+ ret = 1;
+ break;
+
+ case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR:
+ fprintf(stdout, " PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR\n");
+ ret = 1;
+ break;
+
+ case PIPE_CAP_FRAGMENT_COLOR_CLAMPED:
+ fprintf(stdout, " PIPE_CAP_FRAGMENT_COLOR_CLAMPED\n");
+ ret = 0;
+ break;
+
+ case PIPE_CAP_SEAMLESS_CUBE_MAP:
+ fprintf(stdout, " PIPE_CAP_SEAMLESS_CUBE_MAP\n");
+ ret = 1;
+ break;
+
+ case PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE:
+ fprintf(stdout, " PIPE_CAP_SEAMLESS_CUBE_MAP_PER_TEXTURE\n");
+ ret = 0;
+ break;
+
+ case PIPE_CAP_MIN_TEXEL_OFFSET:
+ fprintf(stdout, " PIPE_CAP_MIN_TEXEL_OFFSET\n");
+ ret = 0;
+ break;
+
+ case PIPE_CAP_MAX_TEXEL_OFFSET:
+ fprintf(stdout, " PIPE_CAP_MAX_TEXEL_OFFSET\n");
+ ret = 0;
+ break;
+
+ case PIPE_CAP_CONDITIONAL_RENDER:
+ fprintf(stdout, " PIPE_CAP_CONDITIONAL_RENDER\n");
+ ret = 1;
+ break;
+
+ case PIPE_CAP_TEXTURE_BARRIER:
+ fprintf(stdout, " PIPE_CAP_TEXTURE_BARRIER\n");
+ ret = 1;
+ break;
+
+ case PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS:
+ fprintf(stdout, " PIPE_CAP_MAX_STREAM_OUTPUT_SEPARATE_COMPONENTS\n");
+ ret = 0;
+ break;
+
+ case PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS:
+ fprintf(stdout, " PIPE_CAP_MAX_STREAM_OUTPUT_INTERLEAVED_COMPONENTS\n");
+ ret = 0;
+ break;
+
+ case PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME:
+ fprintf(stdout, " PIPE_CAP_STREAM_OUTPUT_PAUSE_RESUME\n");
+ ret = 0;
+ break;
+
+ case PIPE_CAP_TGSI_CAN_COMPACT_VARYINGS:
+ fprintf(stdout, " PIPE_CAP_TGSI_CAN_COMPACT_VARYINGS\n");
+ ret = 0;
+ break;
+
+ case PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS:
+ fprintf(stdout, " PIPE_CAP_TGSI_CAN_COMPACT_CONSTANTS\n");
+ ret = 0;
+ break;
+
+ case PIPE_CAP_VERTEX_COLOR_UNCLAMPED:
+ fprintf(stdout, " PIPE_CAP_VERTEX_COLOR_UNCLAMPED\n");
+ ret = 1;
+ break;
+
+ case PIPE_CAP_VERTEX_COLOR_CLAMPED:
+ fprintf(stdout, " PIPE_CAP_VERTEX_COLOR_CLAMPED\n");
+ ret = 0;
+ break;
+
+ case PIPE_CAP_GLSL_FEATURE_LEVEL:
+ fprintf(stdout, " PIPE_CAP_GLSL_FEATURE_LEVEL\n");
+ ret = 120;
+ break;
+
+ case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION:
+ fprintf(stdout, " PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION\n");
+ ret = 1;
+ break;
+
+ case PIPE_CAP_USER_VERTEX_BUFFERS:
+ fprintf(stdout, " PIPE_CAP_USER_VERTEX_BUFFERS\n");
+ ret = 1;
+ break;
+
+ case PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY:
+ fprintf(stdout, " PIPE_CAP_VERTEX_BUFFER_OFFSET_4BYTE_ALIGNED_ONLY\n");
+ ret = 0;
+ break;
+
+ case PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY:
+ fprintf(stdout, " PIPE_CAP_VERTEX_BUFFER_STRIDE_4BYTE_ALIGNED_ONLY\n");
+ ret = 0;
+ break;
+
+ case PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY:
+ fprintf(stdout, " PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY\n");
+ ret = 0;
+ break;
+
+ case PIPE_CAP_USER_INDEX_BUFFERS:
+ fprintf(stdout, " PIPE_CAP_USER_INDEX_BUFFERS\n");
+ ret = 1;
+ break;
+
+ case PIPE_CAP_USER_CONSTANT_BUFFERS:
+ fprintf(stdout, " PIPE_CAP_USER_CONSTANT_BUFFERS\n");
+ ret = 1;
+ break;
+
+ case PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT:
+ fprintf(stdout, " PIPE_CAP_CONSTANT_BUFFER_OFFSET_ALIGNMENT\n");
+ ret = 64;
+ break;
+
+ case PIPE_CAP_START_INSTANCE:
+ fprintf(stdout, " PIPE_CAP_START_INSTANCE\n");
+ ret = 1;
+ break;
+
+ case PIPE_CAP_QUERY_TIMESTAMP:
+ fprintf(stdout, " PIPE_CAP_QUERY_TIMESTAMP\n");
+ ret = 0;
+ break;
+
+ case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT:
+ fprintf(stdout, " PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT\n");
+ ret = 1;
+ break;
+
+ case PIPE_CAP_CUBE_MAP_ARRAY:
+ fprintf(stdout, " PIPE_CAP_CUBE_MAP_ARRAY\n");
+ ret = 0;
+ break;
+
+ case PIPE_CAP_TEXTURE_BUFFER_OBJECTS:
+ fprintf(stdout, " PIPE_CAP_TEXTURE_BUFFER_OBJECTS\n");
+ ret = 1;
+ break;
+
+ case PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT:
+ fprintf(stdout, " PIPE_CAP_TEXTURE_BUFFER_OFFSET_ALIGNMENT\n");
+ ret = 64;
+ break;
+
+ case PIPE_CAP_TGSI_TEXCOORD:
+ fprintf(stdout, " PIPE_CAP_TGSI_TEXCOORD\n");
+ ret = 0;
+ break;
+
+ case PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER:
+ fprintf(stdout, " PIPE_CAP_PREFER_BLIT_BASED_TEXTURE_TRANSFER\n");
+ ret = 0;
+ break;
+
+ default:
+ fprintf(stdout, " unsupported parameter: %d\n", param);
+ break;
+ }
+
+ //fprintf(stdout, "< %s() = %d\n", __func__, ret);
+ return ret;
+}
+
+static float tegra_screen_get_paramf(struct pipe_screen *pscreen,
+ enum pipe_capf param)
+{
+ float ret = 0.0f;
+
+ //fprintf(stdout, "> %s(pscreen=%p, param=%d)\n", __func__, pscreen,
+ // param);
+
+ switch (param) {
+ case PIPE_CAPF_MAX_LINE_WIDTH:
+ fprintf(stdout, " PIPE_CAPF_MAX_LINE_WIDTH\n");
+ ret = 8192.0f;
+ break;
+
+ case PIPE_CAPF_MAX_LINE_WIDTH_AA:
+ fprintf(stdout, " PIPE_CAPF_MAX_LINE_WIDTH_AA\n");
+ ret = 8192.0f;
+ break;
+
+ case PIPE_CAPF_MAX_POINT_WIDTH:
+ fprintf(stdout, " PIPE_CAPF_MAX_POINT_WIDTH\n");
+ ret = 8192.0f;
+ break;
+
+ case PIPE_CAPF_MAX_POINT_WIDTH_AA:
+ fprintf(stdout, " PIPE_CAPF_MAX_POINT_WIDTH_AA\n");
+ ret = 8192.0f;
+ break;
+
+ case PIPE_CAPF_MAX_TEXTURE_ANISOTROPY:
+ fprintf(stdout, " PIPE_CAPF_MAX_TEXTURE_ANISOTROPY\n");
+ ret = 16.0f;
+ break;
+
+ case PIPE_CAPF_MAX_TEXTURE_LOD_BIAS:
+ fprintf(stdout, " PIPE_CAPF_MAX_TEXTURE_LOD_BIAS\n");
+ ret = 16.0f;
+ break;
+
+ default:
+ fprintf(stdout, " unsupported parameter: %d\n", param);
+ ret = 0.0f;
+ break;
+ }
+
+ //fprintf(stdout, "< %s() = %f\n", __func__, ret);
+ return ret;
+}
+
+static int tegra_screen_get_shader_param(struct pipe_screen *pscreen,
+ unsigned int shader,
+ enum pipe_shader_cap param)
+{
+ int ret = 0;
+
+ //fprintf(stdout, "> %s(pscreen=%p, shader=%u, param=%d)\n", __func__,
+ // pscreen, shader, param);
+
+ switch (shader) {
+ case PIPE_SHADER_VERTEX:
+ fprintf(stdout, " PIPE_SHADER_VERTEX: ");
+
+ switch (param) {
+ case PIPE_SHADER_CAP_MAX_INSTRUCTIONS:
+ fprintf(stdout, "PIPE_SHADER_CAP_MAX_INSTRUCTIONS\n");
+ ret = 1024;
+ break;
+
+ case PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS:
+ fprintf(stdout, "PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS\n");
+ ret = 1024;
+ break;
+
+ case PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS:
+ fprintf(stdout, "PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS\n");
+ ret = 1024;
+ break;
+
+ case PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS:
+ fprintf(stdout, "PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS\n");
+ ret = 8;
+ break;
+
+ case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH:
+ fprintf(stdout, "PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH\n");
+ ret = 4;
+ break;
+
+ case PIPE_SHADER_CAP_MAX_INPUTS:
+ fprintf(stdout, "PIPE_SHADER_CAP_MAX_INPUTS\n");
+ ret = 16;
+ break;
+
+ case PIPE_SHADER_CAP_MAX_CONSTS:
+ fprintf(stdout, "PIPE_SHADER_CAP_MAX_CONSTS\n");
+ ret = 64;
+ break;
+
+ case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
+ fprintf(stdout, "PIPE_SHADER_CAP_MAX_CONST_BUFFERS\n");
+ ret = 64;
+ break;
+
+ case PIPE_SHADER_CAP_MAX_TEMPS:
+ fprintf(stdout, "PIPE_SHADER_CAP_MAX_TEMPS\n");
+ ret = 16;
+ break;
+
+ case PIPE_SHADER_CAP_MAX_ADDRS:
+ fprintf(stdout, "PIPE_SHADER_CAP_MAX_ADDRS\n");
+ ret = 0;
+ break;
+
+ case PIPE_SHADER_CAP_MAX_PREDS:
+ fprintf(stdout, "PIPE_SHADER_CAP_MAX_PREDS\n");
+ ret = 0;
+ break;
+
+ case PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED:
+ fprintf(stdout, "PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED\n");
+ ret = 1;
+ break;
+
+ case PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR:
+ fprintf(stdout, "PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR\n");
+ ret = 1;
+ break;
+
+ case PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR:
+ fprintf(stdout, "PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR\n");
+ ret = 1;
+ break;
+
+ case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR:
+ fprintf(stdout, "PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR\n");
+ ret = 1;
+ break;
+
+ case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR:
+ fprintf(stdout, "PIPE_SHADER_CAP_INDIRECT_CONST_ADDR\n");
+ ret = 1;
+ break;
+
+ case PIPE_SHADER_CAP_SUBROUTINES:
+ fprintf(stdout, "PIPE_SHADER_CAP_SUBROUTINES\n");
+ ret = 0;
+ break;
+
+ case PIPE_SHADER_CAP_INTEGERS:
+ fprintf(stdout, "PIPE_SHADER_CAP_INTEGERS\n");
+ ret = 1;
+ break;
+
+ case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
+ fprintf(stdout, "PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS\n");
+ ret = 8;
+ break;
+
+ case PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED:
+ fprintf(stdout, "PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED\n");
+ ret = 0;
+ break;
+
+ default:
+ fprintf(stdout, "unsupported parameter: %d\n", param);
+ ret = 0;
+ break;
+ }
+ break;
+
+ case PIPE_SHADER_FRAGMENT:
+ fprintf(stdout, " PIPE_SHADER_FRAGMENT: ");
+
+ switch (param) {
+ case PIPE_SHADER_CAP_MAX_INSTRUCTIONS:
+ fprintf(stdout, "PIPE_SHADER_CAP_MAX_INSTRUCTIONS\n");
+ ret = 1024;
+ break;
+
+ case PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS:
+ fprintf(stdout, "PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS\n");
+ ret = 1024;
+ break;
+
+ case PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS:
+ fprintf(stdout, "PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS\n");
+ ret = 1024;
+ break;
+
+ case PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS:
+ fprintf(stdout, "PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS\n");
+ ret = 8;
+ break;
+
+ case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH:
+ fprintf(stdout, "PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH\n");
+ ret = 4;
+ break;
+
+ case PIPE_SHADER_CAP_MAX_INPUTS:
+ fprintf(stdout, "PIPE_SHADER_CAP_MAX_INPUTS\n");
+ ret = 16;
+ break;
+
+ case PIPE_SHADER_CAP_MAX_CONSTS:
+ fprintf(stdout, "PIPE_SHADER_CAP_MAX_CONSTS\n");
+ ret = 64;
+ break;
+
+ case PIPE_SHADER_CAP_MAX_CONST_BUFFERS:
+ fprintf(stdout, "PIPE_SHADER_CAP_MAX_CONST_BUFFERS\n");
+ ret = 64;
+ break;
+
+ case PIPE_SHADER_CAP_MAX_TEMPS:
+ fprintf(stdout, "PIPE_SHADER_CAP_MAX_TEMPS\n");
+ ret = 16;
+ break;
+
+ case PIPE_SHADER_CAP_MAX_ADDRS:
+ fprintf(stdout, "PIPE_SHADER_CAP_MAX_ADDRS\n");
+ ret = 0;
+ break;
+
+ case PIPE_SHADER_CAP_MAX_PREDS:
+ fprintf(stdout, "PIPE_SHADER_CAP_MAX_PREDS\n");
+ ret = 0;
+ break;
+
+ case PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED:
+ fprintf(stdout, "PIPE_SHADER_CAP_TGSI_CONT_SUPPORTED\n");
+ ret = 1;
+ break;
+
+ case PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR:
+ fprintf(stdout, "PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR\n");
+ ret = 1;
+ break;
+
+ case PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR:
+ fprintf(stdout, "PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR\n");
+ ret = 1;
+ break;
+
+ case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR:
+ fprintf(stdout, "PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR\n");
+ ret = 1;
+ break;
+
+ case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR:
+ fprintf(stdout, "PIPE_SHADER_CAP_INDIRECT_CONST_ADDR\n");
+ ret = 1;
+ break;
+
+ case PIPE_SHADER_CAP_SUBROUTINES:
+ fprintf(stdout, "PIPE_SHADER_CAP_SUBROUTINES\n");
+ ret = 0;
+ break;
+
+ case PIPE_SHADER_CAP_INTEGERS:
+ fprintf(stdout, "PIPE_SHADER_CAP_INTEGERS\n");
+ ret = 1;
+ break;
+
+ case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS:
+ fprintf(stdout, "PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS\n");
+ ret = 8;
+ break;
+
+ case PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED:
+ fprintf(stdout, "PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED\n");
+ ret = 0;
+ break;
+
+ default:
+ fprintf(stdout, "unsupported parameter: %d\n", param);
+ ret = 0;
+ break;
+ }
+ break;
+
+ case PIPE_SHADER_GEOMETRY:
+ fprintf(stdout, " PIPE_SHADER_GEOMETRY not supported\n");
+ ret = 0;
+ break;
+
+ case PIPE_SHADER_COMPUTE:
+ fprintf(stdout, " PIPE_SHADER_COMPUTE not supported\n");
+ ret = 0;
+ break;
+
+ default:
+ fprintf(stdout, " unknown shader type: %u\n", shader);
+ ret = 0;
+ break;
+ }
+
+ //fprintf(stdout, "< %s() = %d\n", __func__, ret);
+ return ret;
+}
+
+static int tegra_screen_get_video_param(struct pipe_screen *pscreen,
+ enum pipe_video_profile profile,
+ enum pipe_video_cap param)
+{
+ int ret = 0;
+ fprintf(stdout, "> %s(pscreen=%p, profile=%d, param=%d)\n", __func__,
+ pscreen, profile, param);
+ fprintf(stdout, "< %s() = %d\n", __func__, ret);
+ return ret;
+}
+
+static int tegra_screen_get_compute_param(struct pipe_screen *pscreen,
+ enum pipe_compute_cap param,
+ void *ret)
+{
+ int size = 0;
+ fprintf(stdout, "> %s(pscreen=%p, param=%d, ret=%p)\n", __func__,
+ pscreen, param, ret);
+ fprintf(stdout, "< %s() = %d\n", __func__, size);
+ return size;
+}
+
+static boolean tegra_screen_is_format_supported(struct pipe_screen *pscreen,
+ enum pipe_format format,
+ enum pipe_texture_target target,
+ unsigned int sample_count,
+ unsigned int bindings)
+{
+ boolean ret = TRUE;
+ fprintf(stdout, "> %s(pscreen=%p, format=%d, target=%d, sample_count=%u, bindings=%u)\n",
+ __func__, pscreen, format, target, sample_count, bindings);
+ fprintf(stdout, "< %s() = %d\n", __func__, ret);
+ return ret;
+}
+
+struct pipe_screen *tegra_screen_create(struct drm_tegra *drm)
+{
+ struct tegra_screen *screen;
+
+ fprintf(stdout, "> %s(drm=%p)\n", __func__, drm);
+
+ screen = calloc(1, sizeof(*screen));
+ if (!screen) {
+ fprintf(stdout, "< %s() = NULL\n", __func__);
+ return NULL;
+ }
+
+ screen->base.destroy = tegra_screen_destroy;
+ screen->base.get_name = tegra_screen_get_name;
+ screen->base.get_vendor = tegra_screen_get_vendor;
+ screen->base.get_param = tegra_screen_get_param;
+ screen->base.get_paramf = tegra_screen_get_paramf;
+ screen->base.get_shader_param = tegra_screen_get_shader_param;
+ screen->base.get_video_param = tegra_screen_get_video_param;
+ screen->base.get_compute_param = tegra_screen_get_compute_param;
+ screen->base.context_create = tegra_screen_context_create;
+ screen->base.is_format_supported = tegra_screen_is_format_supported;
+
+ tegra_screen_resource_init(&screen->base);
+
+ fprintf(stdout, "< %s() = %p\n", __func__, &screen->base);
+ return &screen->base;
+}
View
19 src/gallium/drivers/tegra/tegra_screen.h
@@ -0,0 +1,19 @@
+#ifndef TEGRA_SCREEN_H
+#define TEGRA_SCREEN_H
+
+#include "pipe/p_screen.h"
+
+#include <libdrm/tegra.h>
+
+struct tegra_screen {
+ struct pipe_screen base;
+};
+
+static INLINE struct tegra_screen *tegra_screen(struct pipe_screen *screen)
+{
+ return (struct tegra_screen *)screen;
+}
+
+struct pipe_screen *tegra_screen_create(struct drm_tegra *drm);
+
+#endif
View
343 src/gallium/drivers/tegra/tegra_state.c
@@ -0,0 +1,343 @@
+#include <stdio.h>
+
+#include "tegra_state.h"
+
+static void tegra_set_sample_mask(struct pipe_context *pcontext,
+ unsigned int sample_mask)
+{
+ fprintf(stdout, "> %s(pcontext=%p, sample_mask=%x)\n", __func__,
+ pcontext, sample_mask);
+ fprintf(stdout, "< %s()\n", __func__);
+}
+
+static void tegra_set_constant_buffer(struct pipe_context *pcontext,
+ unsigned int shader, unsigned int index,
+ struct pipe_constant_buffer *buffer)
+{
+ fprintf(stdout, "> %s(pcontext=%p, shader=%u, index=%u, buffer=%p)\n",
+ __func__, pcontext, shader, index, buffer);
+ fprintf(stdout, "< %s()\n", __func__);
+}
+
+static void
+tegra_set_framebuffer_state(struct pipe_context *pcontext,
+ const struct pipe_framebuffer_state *framebuffer)
+{
+ fprintf(stdout, "> %s(pcontext=%p, framebuffer=%p)\n", __func__,
+ pcontext, framebuffer);
+ fprintf(stdout, "< %s()\n", __func__);
+}
+
+static void tegra_set_polygon_stipple(struct pipe_context *pcontext,
+ const struct pipe_poly_stipple *stipple)
+{
+ fprintf(stdout, "> %s(pcontext=%p, stipple=%p)\n", __func__, pcontext,
+ stipple);
+ fprintf(stdout, "< %s()\n", __func__);
+}
+
+static void
+tegra_set_viewport_state(struct pipe_context *pcontext,
+ const struct pipe_viewport_state *viewport)
+{
+ fprintf(stdout, "> %s(pcontext=%p, viewport=%p)\n", __func__,
+ pcontext, viewport);
+ fprintf(stdout, "< %s()\n", __func__);
+}
+
+static void tegra_set_vertex_buffers(struct pipe_context *pcontext,
+ unsigned int start, unsigned int count,
+ const struct pipe_vertex_buffer *buffer)
+{
+ fprintf(stdout, "> %s(pcontext=%p, start=%u, count=%u, buffer=%p)\n",
+ __func__, pcontext, start, count, buffer);
+ fprintf(stdout, "< %s()\n", __func__);
+}
+
+static void tegra_set_index_buffer(struct pipe_context *pcontext,
+ const struct pipe_index_buffer *buffer)
+{
+ fprintf(stdout, "> %s(pcontext=%p, buffer=%p)\n", __func__, pcontext,
+ buffer);
+ fprintf(stdout, "< %s()\n", __func__);
+}
+
+void tegra_context_state_init(struct pipe_context *pcontext)
+{
+ pcontext->set_sample_mask = tegra_set_sample_mask;
+ pcontext->set_constant_buffer = tegra_set_constant_buffer;
+ pcontext->set_framebuffer_state = tegra_set_framebuffer_state;
+ pcontext->set_polygon_stipple = tegra_set_polygon_stipple;
+ pcontext->set_viewport_state = tegra_set_viewport_state;
+ pcontext->set_vertex_buffers = tegra_set_vertex_buffers;
+ pcontext->set_index_buffer = tegra_set_index_buffer;
+}
+
+static void *tegra_create_blend_state(struct pipe_context *pcontext,
+ const struct pipe_blend_state *template)
+{
+ struct tegra_blend_state *so;
+
+ fprintf(stdout, "> %s(pcontext=%p, template=%p)\n", __func__,
+ pcontext, template);
+
+ so = calloc(1, sizeof(*so));
+ if (!so) {
+ fprintf(stdout, "< %s() = NULL\n", __func__);
+ return NULL;
+ }
+
+ so->base = *template;
+
+ fprintf(stdout, "< %s() = %p\n", __func__, so);
+ return so;
+}
+
+static void tegra_bind_blend_state(struct pipe_context *pcontext, void *so)
+{
+ fprintf(stdout, "> %s(pcontext=%p, so=%p)\n", __func__, pcontext, so);
+ fprintf(stdout, "< %s()\n", __func__);
+}
+
+static void tegra_delete_blend_state(struct pipe_context *pcontext, void *so)
+{
+ fprintf(stdout, "> %s(pcontext=%p, so=%p)\n", __func__, pcontext, so);
+
+ free(so);
+
+ fprintf(stdout, "< %s()\n", __func__);
+}
+
+void tegra_context_blend_init(struct pipe_context *pcontext)
+{
+ pcontext->create_blend_state = tegra_create_blend_state;
+ pcontext->bind_blend_state = tegra_bind_blend_state;
+ pcontext->delete_blend_state = tegra_delete_blend_state;
+}
+
+static void *
+tegra_create_rasterizer_state(struct pipe_context *pcontext,
+ const struct pipe_rasterizer_state *template)
+{
+ struct tegra_rasterizer_state *so;
+
+ fprintf(stdout, "> %s(pcontext=%p, template=%p)\n", __func__,
+ pcontext, template);
+
+ so = calloc(1, sizeof(*so));
+ if (!so) {
+ fprintf(stdout, "< %s() = NULL\n", __func__);
+ return NULL;
+ }
+
+ so->base = *template;
+
+ fprintf(stdout, "< %s() = %p\n", __func__, so);
+ return so;
+}
+
+static void tegra_bind_rasterizer_state(struct pipe_context *pcontext,
+ void *so)
+{
+ fprintf(stdout, "> %s(pcontext=%p, so=%p)\n", __func__, pcontext, so);
+ fprintf(stdout, "< %s()\n", __func__);
+}
+
+static void tegra_delete_rasterizer_state(struct pipe_context *pcontext,
+ void *so)
+{
+ fprintf(stdout, "> %s(pcontext=%p, so=%p)\n", __func__, pcontext, so);
+
+ free(so);
+
+ fprintf(stdout, "< %s()\n", __func__);
+}
+
+void tegra_context_rasterizer_init(struct pipe_context *pcontext)
+{
+ pcontext->create_rasterizer_state = tegra_create_rasterizer_state;
+ pcontext->bind_rasterizer_state = tegra_bind_rasterizer_state;
+ pcontext->delete_rasterizer_state = tegra_delete_rasterizer_state;
+}
+
+static void *
+tegra_create_zsa_state(struct pipe_context *pcontext,
+ const struct pipe_depth_stencil_alpha_state *template)
+{
+ struct tegra_zsa_state *so;
+
+ fprintf(stdout, "> %s(pcontext=%p, template=%p)\n", __func__,
+ pcontext, template);
+
+ so = calloc(1, sizeof(*so));
+ if (!so) {
+ fprintf(stdout, "< %s() = NULL\n", __func__);
+ return NULL;
+ }
+
+ so->base = *template;
+
+ fprintf(stdout, "< %s() = %p\n", __func__, so);
+ return so;
+}
+
+static void tegra_bind_zsa_state(struct pipe_context *pcontext, void *so)
+{
+ fprintf(stdout, "> %s(pcontext=%p, so=%p)\n", __func__, pcontext, so);
+ fprintf(stdout, "< %s()\n", __func__);
+}
+
+static void tegra_delete_zsa_state(struct pipe_context *pcontext, void *so)
+{
+ fprintf(stdout, "> %s(pcontext=%p, so=%p)\n", __func__, pcontext, so);
+
+ free(so);
+
+ fprintf(stdout, "< %s()\n", __func__);
+}
+
+void tegra_context_zsa_init(struct pipe_context *pcontext)
+{
+ pcontext->create_depth_stencil_alpha_state = tegra_create_zsa_state;
+ pcontext->bind_depth_stencil_alpha_state = tegra_bind_zsa_state;
+ pcontext->delete_depth_stencil_alpha_state = tegra_delete_zsa_state;
+}
+
+static void *
+tegra_create_vs_state(struct pipe_context *pcontext,
+ const struct pipe_shader_state *template)
+{
+ struct tegra_vs_state *so;
+
+ fprintf(stdout, "> %s(pcontext=%p, template=%p)\n", __func__,
+ pcontext, template);
+
+ so = calloc(1, sizeof(*so));
+ if (!so) {
+ fprintf(stdout, "< %s() = NULL\n", __func__);
+ return NULL;
+ }
+
+ so->base = *template;
+
+ fprintf(stdout, "< %s() = %p\n", __func__, so);
+ return so;
+}
+
+static void tegra_bind_vs_state(struct pipe_context *pcontext, void *so)
+{
+ fprintf(stdout, "> %s(pcontext=%p, so=%p)\n", __func__, pcontext, so);
+ fprintf(stdout, "< %s()\n", __func__);
+}
+
+static void tegra_delete_vs_state(struct pipe_context *pcontext, void *so)
+{
+ fprintf(stdout, "> %s(pcontext=%p, so=%p)\n", __func__, pcontext, so);
+
+ free(so);
+
+ fprintf(stdout, "< %s()\n", __func__);
+}
+
+void tegra_context_vs_init(struct pipe_context *pcontext)
+{
+ pcontext->create_vs_state = tegra_create_vs_state;
+ pcontext->bind_vs_state = tegra_bind_vs_state;
+ pcontext->delete_vs_state = tegra_delete_vs_state;
+}
+
+static void *
+tegra_create_fs_state(struct pipe_context *pcontext,
+ const struct pipe_shader_state *template)
+{
+ struct tegra_fs_state *so;
+
+ fprintf(stdout, "> %s(pcontext=%p, template=%p)\n", __func__,
+ pcontext, template);
+
+ so = calloc(1, sizeof(*so));
+ if (!so) {
+ fprintf(stdout, "< %s() = NULL\n", __func__);
+ return NULL;
+ }
+
+ so->base = *template;
+
+ fprintf(stdout, "< %s() = %p\n", __func__, so);
+ return so;
+}
+
+static void tegra_bind_fs_state(struct pipe_context *pcontext, void *so)
+{
+ fprintf(stdout, "> %s(pcontext=%p, so=%p)\n", __func__, pcontext, so);
+ fprintf(stdout, "< %s()\n", __func__);
+}
+
+static void tegra_delete_fs_state(struct pipe_context *pcontext, void *so)
+{
+ fprintf(stdout, "> %s(pcontext=%p, so=%p)\n", __func__, pcontext, so);
+
+ free(so);
+
+ fprintf(stdout, "< %s()\n", __func__);
+}
+
+void tegra_context_fs_init(struct pipe_context *pcontext)
+{
+ pcontext->create_fs_state = tegra_create_fs_state;
+ pcontext->bind_fs_state = tegra_bind_fs_state;
+ pcontext->delete_fs_state = tegra_delete_fs_state;
+}
+
+static void *
+tegra_create_vbo_state(struct pipe_context *pcontext, unsigned int count,
+ const struct pipe_vertex_element *elements)
+{
+ struct tegra_vbo_state *so;
+
+ fprintf(stdout, "> %s(pcontext=%p, count=%u, elements=%p)\n",
+ __func__, pcontext, count, elements);
+
+ so = calloc(1, sizeof(*so));
+ if (!so) {
+ fprintf(stdout, "< %s() = NULL\n", __func__);
+ return NULL;
+ }
+
+ memcpy(so->elements, elements, sizeof(*elements) * count);
+ so->num_elements = count;
+
+ fprintf(stdout, "< %s() = %p\n", __func__, so);
+ return so;
+}
+
+static void tegra_bind_vbo_state(struct pipe_context *pcontext, void *so)
+{
+ fprintf(stdout, "> %s(pcontext=%p, so=%p)\n", __func__, pcontext, so);
+ fprintf(stdout, "< %s()\n", __func__);
+}
+
+static void tegra_delete_vbo_state(struct pipe_context *pcontext, void *so)
+{
+ fprintf(stdout, "> %s(pcontext=%p, so=%p)\n", __func__, pcontext, so);
+
+ free(so);
+
+ fprintf(stdout, "< %s()\n", __func__);
+}
+
+static void tegra_draw_vbo(struct pipe_context *pcontext,
+ const struct pipe_draw_info *info)
+{
+ fprintf(stdout, "> %s(pcontext=%p, info=%p)\n", __func__, pcontext,
+ info);
+ fprintf(stdout, "< %s()\n", __func__);
+}
+
+void tegra_context_vbo_init(struct pipe_context *pcontext)
+{
+ pcontext->create_vertex_elements_state = tegra_create_vbo_state;
+ pcontext->bind_vertex_elements_state = tegra_bind_vbo_state;
+ pcontext->delete_vertex_elements_state = tegra_delete_vbo_state;
+ pcontext->draw_vbo = tegra_draw_vbo;
+}
View
40 src/gallium/drivers/tegra/tegra_state.h
@@ -0,0 +1,40 @@
+#ifndef TEGRA_STATE_H
+#define TEGRA_STATE_H
+
+#include "pipe/p_context.h"
+#include "pipe/p_state.h"
+
+struct tegra_blend_state {
+ struct pipe_blend_state base;
+};
+
+struct tegra_rasterizer_state {
+ struct pipe_rasterizer_state base;
+};
+
+struct tegra_zsa_state {
+ struct pipe_depth_stencil_alpha_state base;
+};
+
+struct tegra_vs_state {
+ struct pipe_shader_state base;
+};
+
+struct tegra_fs_state {
+ struct pipe_shader_state base;
+};
+
+struct tegra_vbo_state {
+ struct pipe_vertex_element elements[PIPE_MAX_ATTRIBS];
+ unsigned int num_elements;
+};
+
+void tegra_context_state_init(struct pipe_context *pcontext);
+void tegra_context_blend_init(struct pipe_context *pcontext);
+void tegra_context_rasterizer_init(struct pipe_context *pcontext);
+void tegra_context_zsa_init(struct pipe_context *pcontext);
+void tegra_context_vs_init(struct pipe_context *pcontext);
+void tegra_context_fs_init(struct pipe_context *pcontext);
+void tegra_context_vbo_init(struct pipe_context *pcontext);
+
+#endif
View
43 src/gallium/drivers/tegra/tegra_surface.c
@@ -0,0 +1,43 @@
+#include <stdio.h>
+
+#include "util/u_inlines.h"
+
+#include "tegra_surface.h"
+
+static struct pipe_surface *
+tegra_create_surface(struct pipe_context *context,
+ struct pipe_resource *resource,
+ const struct pipe_surface *template)
+{
+ struct tegra_surface *surface;
+
+ fprintf(stdout, "> %s(context=%p, resource=%p, template=%p)\n",
+ __func__, context, resource, template);
+
+ surface = calloc(1, sizeof(*surface));
+ if (!surface) {
+ fprintf(stdout, "< %s() = NULL\n", __func__);
+ return NULL;
+ }
+
+ pipe_resource_reference(&surface->base.texture, resource);
+ pipe_reference_init(&surface->base.reference, 1);
+ surface->base.context = context;
+
+ fprintf(stdout, "< %s() = %p\n", __func__, &surface->base);
+ return &surface->base;
+}
+
+static void tegra_surface_destroy(struct pipe_context *context,
+ struct pipe_surface *surface)
+{
+ fprintf(stdout, "> %s(context=%p, surface=%p)\n", __func__, context,
+ surface);
+ fprintf(stdout, "< %s()\n", __func__);
+}
+
+void tegra_context_surface_init(struct pipe_context *context)
+{
+ context->create_surface = tegra_create_surface;
+ context->surface_destroy = tegra_surface_destroy;
+}
View
13 src/gallium/drivers/tegra/tegra_surface.h
@@ -0,0 +1,13 @@
+#ifndef TEGRA_SURFACE_H
+#define TEGRA_SURFACE_H
+
+#include "pipe/p_context.h"
+#include "pipe/p_state.h"
+
+struct tegra_surface {
+ struct pipe_surface base;
+};
+
+void tegra_context_surface_init(struct pipe_context *context);
+
+#endif
View
73 src/gallium/targets/dri-tegra/Makefile.am
@@ -0,0 +1,73 @@
+# Copyright © 2012 Intel Corporation
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+
+include $(top_srcdir)/src/gallium/Automake.inc
+
+AM_CFLAGS = \
+ $(GALLIUM_CFLAGS) \
+ $(PTHREAD_CFLAGS) \
+ $(LIBDRM_CFLAGS) \
+ $(TEGRA_CFLAGS)
+
+AM_CPPFLAGS = \
+ -I$(top_srcdir)/src/gallium/drivers \
+ -I$(top_srcdir)/src/gallium/winsys \
+ -I$(top_srcdir)/src/mesa \
+ -I$(top_srcdir)/src/mapi \
+ -I$(top_builddir)/src/mesa/drivers/dri/common \
+ -DGALLIUM_RBUG \
+ -DGALLIUM_TRACE
+
+dridir = $(DRI_DRIVER_INSTALL_DIR)
+dri_LTLIBRARIES = tegra_dri.la
+
+nodist_EXTRA_tegra_dri_la_SOURCES = dummy.cpp
+tegra_dri_la_SOURCES = \
+ target.c \
+ $(top_srcdir)/src/mesa/drivers/dri/common/utils.c \
+ $(top_srcdir)/src/mesa/drivers/dri/common/dri_util.c \
+ $(top_srcdir)/src/mesa/drivers/dri/common/xmlconfig.c
+
+tegra_dri_la_LDFLAGS = -module -avoid-version -shared -no-undefined
+
+tegra_dri_la_LIBADD = \
+ $(top_builddir)/src/mesa/libmesagallium.la \
+ $(top_builddir)/src/gallium/auxiliary/libgallium.la \
+ $(top_builddir)/src/gallium/state_trackers/dri/drm/libdridrm.la \
+ $(top_builddir)/src/gallium/winsys/tegra/drm/libtegradrm.la \
+ $(top_builddir)/src/gallium/drivers/trace/libtrace.la \
+ $(top_builddir)/src/gallium/drivers/rbug/librbug.la \
+ $(top_builddir)/src/gallium/drivers/tegra/libtegra.la \
+ $(GALLIUM_DRI_LIB_DEPS) \
+ $(LIBDRM_LIBS) \
+ $(TEGRA_LIBS)
+
+if HAVE_MESA_LLVM
+tegra_dri_la_LDFLAGS += $(LLVM_LDFLAGS)
+tegra_dri_la_LIBADD += $(LLVM_LIBS)
+endif
+
+# Provide compatibility with scripts for the old Mesa build system for
+# a while by putting a link to the driver into /lib of the build tree.
+all-local: tegra_dri.la
+ $(MKDIR_P) $(top_builddir)/$(LIB_DIR)/gallium
+ ln -f .libs/tegra_dri.so $(top_builddir)/$(LIB_DIR)/gallium/tegra_dri.so
View
24 src/gallium/targets/dri-tegra/target.c
@@ -0,0 +1,24 @@
+#include <stdio.h>
+
+#include "target-helpers/inline_debug_helper.h"
+#include "tegra/drm/tegra_drm_public.h"
+#include "state_tracker/drm_driver.h"
+
+static struct pipe_screen *create_screen(int fd)
+{
+ struct pipe_screen *screen;
+
+ fprintf(stderr, "> %s(fd=%d)\n", __func__, fd);
+
+ screen = tegra_drm_screen_create(fd);
+ if (!screen)
+ goto out;
+
+ screen = debug_screen_wrap(screen);
+
+out:
+ fprintf(stderr, "< %s() = %p\n", __func__, screen);
+ return screen;
+}
+
+DRM_DRIVER_DESCRIPTOR("tegra", "tegra", create_screen, NULL)
View
33 src/gallium/winsys/tegra/drm/Makefile.am
@@ -0,0 +1,33 @@
+# Copyright © 2012 Intel Corporation
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice (including the next
+# paragraph) shall be included in all copies or substantial portions of the
+# Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+
+include $(top_srcdir)/src/gallium/Automake.inc
+
+AM_CFLAGS = \
+ -I$(top_srcdir)/src/gallium/drivers \
+ $(GALLIUM_CFLAGS) \
+ $(TEGRA_CFLAGS)
+
+noinst_LTLIBRARIES = libtegradrm.la
+
+libtegradrm_la_SOURCES = \
+ tegra_drm_winsys.c
View
8 src/gallium/winsys/tegra/drm/tegra_drm_public.h
@@ -0,0 +1,8 @@
+#ifndef TEGRA_DRM_PUBLIC_H
+#define TEGRA_DRM_PUBLIC_H
+
+struct pipe_screen;
+
+struct pipe_screen *tegra_drm_screen_create(int fd);
+
+#endif
View
26 src/gallium/winsys/tegra/drm/tegra_drm_winsys.c
@@ -0,0 +1,26 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <libdrm/tegra.h>
+
+#include "tegra/tegra_screen.h"
+#include "tegra_drm_public.h"
+
+struct pipe_screen *tegra_drm_screen_create(int fd)
+{
+ struct pipe_screen *screen = NULL;
+ struct drm_tegra *drm;
+ int err;
+
+ fprintf(stderr, "> %s(fd=%d)\n", __func__, fd);
+
+ err = drm_tegra_open(fd, &drm);
+ if (err < 0)
+ goto out;
+
+ screen = tegra_screen_create(drm);
+
+out:
+ fprintf(stderr, "< %s() = %p\n", __func__, screen);
+ return screen;
+}
Please sign in to comment.
Something went wrong with that request. Please try again.