summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThierry Reding <thierry.reding@gmail.com>2016-07-04 09:29:00 +0200
committerThierry Reding <thierry.reding@gmail.com>2016-07-04 09:44:28 +0200
commit69a0e75c84421f9be60fd489d0b5f0a9ac43a32b (patch)
tree0c56cdafda45740b0e431d7980c272d4522a8c98
parent8f072fa4293befc455e41f4d2c9d53663f4ec47a (diff)
tegra: Make more completetegra-wip
Signed-off-by: Thierry Reding <thierry.reding@gmail.com>
-rw-r--r--src/gallium/drivers/tegra/Makefile.sources1
-rw-r--r--src/gallium/drivers/tegra/tegra_context.c918
-rw-r--r--src/gallium/drivers/tegra/tegra_context.h5
-rw-r--r--src/gallium/drivers/tegra/tegra_resource.c181
-rw-r--r--src/gallium/drivers/tegra/tegra_resource.h52
-rw-r--r--src/gallium/drivers/tegra/tegra_screen.c448
6 files changed, 1299 insertions, 306 deletions
diff --git a/src/gallium/drivers/tegra/Makefile.sources b/src/gallium/drivers/tegra/Makefile.sources
index 978dd14667f5..655c60ab6853 100644
--- a/src/gallium/drivers/tegra/Makefile.sources
+++ b/src/gallium/drivers/tegra/Makefile.sources
@@ -1,4 +1,3 @@
C_SOURCES := \
tegra_context.c \
- tegra_resource.c \
tegra_screen.c
diff --git a/src/gallium/drivers/tegra/tegra_context.c b/src/gallium/drivers/tegra/tegra_context.c
index 0f7ca482fdbb..7db5ad7b197c 100644
--- a/src/gallium/drivers/tegra/tegra_context.c
+++ b/src/gallium/drivers/tegra/tegra_context.c
@@ -21,12 +21,12 @@
* IN THE SOFTWARE.
*/
+#include <inttypes.h>
#include <stdlib.h>
#include "util/u_debug.h"
#include "tegra/tegra_context.h"
-#include "tegra/tegra_resource.h"
#include "tegra/tegra_screen.h"
static void
@@ -56,6 +56,154 @@ tegra_draw_vbo(struct pipe_context *pcontext,
debug_printf("< %s()\n", __func__);
}
+static void
+tegra_render_condition(struct pipe_context *pcontext,
+ struct pipe_query *query,
+ boolean condition,
+ unsigned int mode)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, query=%p, condition=%d, mode=%u)\n",
+ __func__, pcontext, query, condition, mode);
+
+ context->gpu->render_condition(context->gpu, query, condition, mode);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static struct pipe_query *
+tegra_create_query(struct pipe_context *pcontext,
+ unsigned int query_type,
+ unsigned int index)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+ struct pipe_query *query;
+
+ debug_printf("> %s(pcontext=%p, query_type=%u, index=%u)\n", __func__,
+ pcontext, query_type, index);
+
+ query = context->gpu->create_query(context->gpu, query_type, index);
+
+ debug_printf("< %s() = %p\n", __func__, query);
+ return query;
+}
+
+static struct pipe_query *
+tegra_create_batch_query(struct pipe_context *pcontext,
+ unsigned int num_queries,
+ unsigned int *queries)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+ struct pipe_query *query;
+
+ debug_printf("> %s(pcontext=%p, num_queries=%u, queries=%p)\n",
+ __func__, pcontext, num_queries, queries);
+
+ query = context->gpu->create_batch_query(context->gpu, num_queries,
+ queries);
+
+ debug_printf("< %s() = %p\n", __func__, query);
+ return query;
+}
+
+static void
+tegra_destroy_query(struct pipe_context *pcontext, struct pipe_query *query)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, query=%p)\n", __func__, pcontext,
+ query);
+
+ context->gpu->destroy_query(context->gpu, query);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static boolean
+tegra_begin_query(struct pipe_context *pcontext, struct pipe_query *query)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+ boolean ret;
+
+ debug_printf("> %s(pcontext=%p, query=%p)\n", __func__, pcontext,
+ query);
+
+ ret = context->gpu->begin_query(context->gpu, query);
+
+ debug_printf("< %s() = %d\n", __func__, ret);
+ return ret;
+}
+
+static bool
+tegra_end_query(struct pipe_context *pcontext, struct pipe_query *query)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+ bool ret;
+
+ debug_printf("> %s(pcontext=%p, query=%p)\n", __func__, pcontext,
+ query);
+
+ ret = context->gpu->end_query(context->gpu, query);
+
+ debug_printf("< %s()\n", __func__);
+ return ret;
+}
+
+static boolean
+tegra_get_query_result(struct pipe_context *pcontext,
+ struct pipe_query *query,
+ boolean wait,
+ union pipe_query_result *result)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+ boolean ret;
+
+ debug_printf("> %s(pcontext=%p, query=%p, wait=%d, result=%p)\n",
+ __func__, pcontext, query, wait, result);
+
+ ret = context->gpu->get_query_result(context->gpu, query, wait,
+ result);
+
+ debug_printf("< %s() = %d\n", __func__, ret);
+ return ret;
+}
+
+static void
+tegra_get_query_result_resource(struct pipe_context *pcontext,
+ struct pipe_query *query,
+ boolean wait,
+ enum pipe_query_value_type result_type,
+ int index,
+ struct pipe_resource *resource,
+ unsigned int offset)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, query=%p, wait=%d, result_type=%d, index=%d, resource=%p, offset=%u)\n",
+ __func__, pcontext, query, wait, result_type, index,
+ resource, offset);
+
+ context->gpu->get_query_result_resource(context->gpu, query, wait,
+ result_type, index, resource,
+ offset);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static void
+tegra_set_active_query_state(struct pipe_context *pcontext, boolean enable)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, enable=%d)\n", __func__, pcontext,
+ enable);
+
+ context->gpu->set_active_query_state(pcontext, enable);
+
+ debug_printf("< %s()\n", __func__);
+}
+
static void *
tegra_create_blend_state(struct pipe_context *pcontext,
const struct pipe_blend_state *cso)
@@ -72,8 +220,7 @@ tegra_create_blend_state(struct pipe_context *pcontext,
}
static void
-tegra_bind_blend_state(struct pipe_context *pcontext,
- void *so)
+tegra_bind_blend_state(struct pipe_context *pcontext, void *so)
{
struct tegra_context *context = to_tegra_context(pcontext);
@@ -85,8 +232,7 @@ tegra_bind_blend_state(struct pipe_context *pcontext,
}
static void
-tegra_delete_blend_state(struct pipe_context *pcontext,
- void *so)
+tegra_delete_blend_state(struct pipe_context *pcontext, void *so)
{
struct tegra_context *context = to_tegra_context(pcontext);
@@ -132,8 +278,7 @@ tegra_bind_sampler_states(struct pipe_context *pcontext,
}
static void
-tegra_delete_sampler_state(struct pipe_context *pcontext,
- void *so)
+tegra_delete_sampler_state(struct pipe_context *pcontext, void *so)
{
struct tegra_context *context = to_tegra_context(pcontext);
@@ -160,8 +305,7 @@ tegra_create_rasterizer_state(struct pipe_context *pcontext,
}
static void
-tegra_bind_rasterizer_state(struct pipe_context *pcontext,
- void *so)
+tegra_bind_rasterizer_state(struct pipe_context *pcontext, void *so)
{
struct tegra_context *context = to_tegra_context(pcontext);
@@ -173,8 +317,7 @@ tegra_bind_rasterizer_state(struct pipe_context *pcontext,
}
static void
-tegra_delete_rasterizer_state(struct pipe_context *pcontext,
- void *so)
+tegra_delete_rasterizer_state(struct pipe_context *pcontext, void *so)
{
struct tegra_context *context = to_tegra_context(pcontext);
@@ -202,8 +345,7 @@ tegra_create_depth_stencil_alpha_state(struct pipe_context *pcontext,
}
static void
-tegra_bind_depth_stencil_alpha_state(struct pipe_context *pcontext,
- void *so)
+tegra_bind_depth_stencil_alpha_state(struct pipe_context *pcontext, void *so)
{
struct tegra_context *context = to_tegra_context(pcontext);
@@ -215,8 +357,7 @@ tegra_bind_depth_stencil_alpha_state(struct pipe_context *pcontext,
}
static void
-tegra_delete_depth_stencil_alpha_state(struct pipe_context *pcontext,
- void *so)
+tegra_delete_depth_stencil_alpha_state(struct pipe_context *pcontext, void *so)
{
struct tegra_context *context = to_tegra_context(pcontext);
@@ -243,8 +384,7 @@ tegra_create_fs_state(struct pipe_context *pcontext,
}
static void
-tegra_bind_fs_state(struct pipe_context *pcontext,
- void *so)
+tegra_bind_fs_state(struct pipe_context *pcontext, void *so)
{
struct tegra_context *context = to_tegra_context(pcontext);
@@ -256,8 +396,7 @@ tegra_bind_fs_state(struct pipe_context *pcontext,
}
static void
-tegra_delete_fs_state(struct pipe_context *pcontext,
- void *so)
+tegra_delete_fs_state(struct pipe_context *pcontext, void *so)
{
struct tegra_context *context = to_tegra_context(pcontext);
@@ -284,8 +423,7 @@ tegra_create_vs_state(struct pipe_context *pcontext,
}
static void
-tegra_bind_vs_state(struct pipe_context *pcontext,
- void *so)
+tegra_bind_vs_state(struct pipe_context *pcontext, void *so)
{
struct tegra_context *context = to_tegra_context(pcontext);
@@ -297,8 +435,7 @@ tegra_bind_vs_state(struct pipe_context *pcontext,
}
static void
-tegra_delete_vs_state(struct pipe_context *pcontext,
- void *so)
+tegra_delete_vs_state(struct pipe_context *pcontext, void *so)
{
struct tegra_context *context = to_tegra_context(pcontext);
@@ -325,8 +462,7 @@ tegra_create_gs_state(struct pipe_context *pcontext,
}
static void
-tegra_bind_gs_state(struct pipe_context *pcontext,
- void *so)
+tegra_bind_gs_state(struct pipe_context *pcontext, void *so)
{
struct tegra_context *context = to_tegra_context(pcontext);
@@ -338,8 +474,7 @@ tegra_bind_gs_state(struct pipe_context *pcontext,
}
static void
-tegra_delete_gs_state(struct pipe_context *pcontext,
- void *so)
+tegra_delete_gs_state(struct pipe_context *pcontext, void *so)
{
struct tegra_context *context = to_tegra_context(pcontext);
@@ -351,6 +486,84 @@ tegra_delete_gs_state(struct pipe_context *pcontext,
}
static void *
+tegra_create_tcs_state(struct pipe_context *pcontext,
+ const struct pipe_shader_state *cso)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+ void *so;
+
+ debug_printf("> %s(pcontext=%p, cso=%p)\n", __func__, pcontext, cso);
+
+ so = context->gpu->create_tcs_state(context->gpu, cso);
+
+ debug_printf("< %s() = %p\n", __func__, so);
+ return so;
+}
+
+static void
+tegra_bind_tcs_state(struct pipe_context *pcontext, void *so)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, so=%p)\n", __func__, pcontext, so);
+
+ context->gpu->bind_tcs_state(context->gpu, so);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static void
+tegra_delete_tcs_state(struct pipe_context *pcontext, void *so)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, so=%p)\n", __func__, pcontext, so);
+
+ context->gpu->delete_tcs_state(context->gpu, so);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static void *
+tegra_create_tes_state(struct pipe_context *pcontext,
+ const struct pipe_shader_state *cso)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+ void *so;
+
+ debug_printf("> %s(pcontext=%p, cso=%p)\n", __func__, pcontext, cso);
+
+ so = context->gpu->create_tes_state(context->gpu, cso);
+
+ debug_printf("< %s() = %p\n", __func__, so);
+ return so;
+}
+
+static void
+tegra_bind_tes_state(struct pipe_context *pcontext, void *so)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, so=%p)\n", __func__, pcontext, so);
+
+ context->gpu->bind_tes_state(context->gpu, so);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static void
+tegra_delete_tes_state(struct pipe_context *pcontext, void *so)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, so=%p)\n", __func__, pcontext, so);
+
+ context->gpu->delete_tes_state(context->gpu, so);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static void *
tegra_create_vertex_elements_state(struct pipe_context *pcontext,
unsigned num_elements,
const struct pipe_vertex_element *elements)
@@ -370,8 +583,7 @@ tegra_create_vertex_elements_state(struct pipe_context *pcontext,
}
static void
-tegra_bind_vertex_elements_state(struct pipe_context *pcontext,
- void *so)
+tegra_bind_vertex_elements_state(struct pipe_context *pcontext, void *so)
{
struct tegra_context *context = to_tegra_context(pcontext);
@@ -383,8 +595,7 @@ tegra_bind_vertex_elements_state(struct pipe_context *pcontext,
}
static void
-tegra_delete_vertex_elements_state(struct pipe_context *pcontext,
- void *so)
+tegra_delete_vertex_elements_state(struct pipe_context *pcontext, void *so)
{
struct tegra_context *context = to_tegra_context(pcontext);
@@ -396,10 +607,77 @@ tegra_delete_vertex_elements_state(struct pipe_context *pcontext,
}
static void
+tegra_set_blend_color(struct pipe_context *pcontext,
+ const struct pipe_blend_color *color)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, color=%p)\n", __func__, pcontext,
+ color);
+
+ context->gpu->set_blend_color(context->gpu, color);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static void
+tegra_set_stencil_ref(struct pipe_context *pcontext,
+ const struct pipe_stencil_ref *ref)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, ref=%p)\n", __func__, pcontext, ref);
+
+ context->gpu->set_stencil_ref(context->gpu, ref);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static void
+tegra_set_sample_mask(struct pipe_context *pcontext, unsigned int mask)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, mask=%x)\n", __func__, pcontext,
+ mask);
+
+ context->gpu->set_sample_mask(context->gpu, mask);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static void
+tegra_set_min_samples(struct pipe_context *pcontext, unsigned int samples)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, samples=%x)\n", __func__, pcontext,
+ samples);
+
+ context->gpu->set_min_samples(context->gpu, samples);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static void
+tegra_set_clip_state(struct pipe_context *pcontext,
+ const struct pipe_clip_state *state)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, state=%p)\n", __func__, pcontext,
+ state);
+
+ context->gpu->set_clip_state(context->gpu, state);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static void
tegra_set_constant_buffer(struct pipe_context *pcontext,
- uint shader,
- uint index,
- struct pipe_constant_buffer *buf)
+ unsigned int shader,
+ unsigned int index,
+ const struct pipe_constant_buffer *buf)
{
struct tegra_context *context = to_tegra_context(pcontext);
@@ -456,6 +734,23 @@ tegra_set_scissor_states(struct pipe_context *pcontext,
}
static void
+tegra_set_window_rectangles(struct pipe_context *pcontext,
+ boolean include,
+ unsigned int num_rectangles,
+ const struct pipe_scissor_state *rectangles)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, include=%d, num_rectangles=%u, rectangles=%p)\n",
+ __func__, pcontext, include, num_rectangles, rectangles);
+
+ context->gpu->set_window_rectangles(context->gpu, include,
+ num_rectangles, rectangles);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static void
tegra_set_viewport_states(struct pipe_context *pcontext,
unsigned start_slot,
unsigned num_viewports,
@@ -493,18 +788,68 @@ tegra_set_sampler_views(struct pipe_context *pcontext,
}
static void
-tegra_set_shader_resources(struct pipe_context *pcontext,
- unsigned start,
- unsigned count,
- struct pipe_surface **resources)
+tegra_set_tess_state(struct pipe_context *pcontext,
+ const float default_outer_level[4],
+ const float default_inner_level[2])
{
struct tegra_context *context = to_tegra_context(pcontext);
- debug_printf("> %s(pcontext=%p, startt=%u, count=%u, resources=%p)\n",
- __func__, pcontext, start, count, resources);
+ debug_printf("> %s(pcontext=%p, default_outer_level=%p, default_inner_level=%p)\n",
+ __func__, pcontext, default_outer_level,
+ default_inner_level);
+
+ context->gpu->set_tess_state(context->gpu, default_outer_level,
+ default_inner_level);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static void
+tegra_set_debug_callback(struct pipe_context *pcontext,
+ const struct pipe_debug_callback *callback)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, callback=%p)\n", __func__, pcontext,
+ callback);
+
+ context->gpu->set_debug_callback(context->gpu, callback);
+
+ debug_printf("< %s()\n", __func__);
+}
- context->gpu->set_shader_resources(context->gpu, start, count,
- resources);
+static void
+tegra_set_shader_buffers(struct pipe_context *pcontext,
+ unsigned int shader,
+ unsigned start,
+ unsigned count,
+ const struct pipe_shader_buffer *buffers)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, shader=%u, start=%u, count=%u, buffers=%p)\n",
+ __func__, pcontext, shader, start, count, buffers);
+
+ context->gpu->set_shader_buffers(context->gpu, shader, start, count,
+ buffers);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static void
+tegra_set_shader_images(struct pipe_context *pcontext,
+ unsigned int shader,
+ unsigned start,
+ unsigned count,
+ const struct pipe_image_view *images)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, shader=%u, start=%u, count=%u, images=%p)\n",
+ __func__, pcontext, shader, start, count, images);
+
+ context->gpu->set_shader_images(context->gpu, shader, start, count,
+ images);
debug_printf("< %s()\n", __func__);
}
@@ -594,6 +939,30 @@ tegra_set_stream_output_targets(struct pipe_context *pcontext,
}
static void
+tegra_resource_copy_region(struct pipe_context *pcontext,
+ struct pipe_resource *dst,
+ unsigned int dst_level,
+ unsigned int dstx,
+ unsigned int dsty,
+ unsigned int dstz,
+ struct pipe_resource *src,
+ unsigned int src_level,
+ const struct pipe_box *src_box)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, dst=%p, dst_level=%u, dstx=%x, dsty=%x, dstz=%u, src=%p, src_level=%u, src_box=%p)\n",
+ __func__, pcontext, dst, dst_level, dstx, dsty, dstz,
+ src, src_level, src_box);
+
+ context->gpu->resource_copy_region(pcontext, dst, dst_level, dstx,
+ dsty, dstz, src, src_level,
+ src_box);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static void
tegra_blit(struct pipe_context *pcontext,
const struct pipe_blit_info *info)
{
@@ -625,6 +994,87 @@ tegra_clear(struct pipe_context *pcontext,
}
static void
+tegra_clear_render_target(struct pipe_context *pcontext,
+ struct pipe_surface *dst,
+ const union pipe_color_union *color,
+ unsigned int dstx,
+ unsigned int dsty,
+ unsigned int width,
+ unsigned int height)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, dst=%p, color=%p, dstx=%u, dsty=%u, width=%u, height=%u)\n",
+ __func__, pcontext, dst, color, dstx, dsty, width,
+ height);
+
+ context->gpu->clear_render_target(pcontext, dst, color, dstx, dsty,
+ width, height);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static void
+tegra_clear_depth_stencil(struct pipe_context *pcontext,
+ struct pipe_surface *dst,
+ unsigned int flags,
+ double depth,
+ unsigned int stencil,
+ unsigned int dstx,
+ unsigned int dsty,
+ unsigned int width,
+ unsigned int height)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, dst=%p, flags=%x, depth=%f, stencil=%u, dstx=%u, dsty=%u, width=%u, height=%u)\n",
+ __func__, pcontext, dst, flags, depth, stencil, dstx,
+ dsty, width, height);
+
+ context->gpu->clear_depth_stencil(pcontext, dst, flags, depth,
+ stencil, dstx, dsty, width, height);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static void
+tegra_clear_texture(struct pipe_context *pcontext,
+ struct pipe_resource *res,
+ unsigned int level,
+ const struct pipe_box *box,
+ const void *data)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, res=%p, level=%u, box=%p, data=%p)\n",
+ __func__, pcontext, res, level, box, data);
+
+ context->gpu->clear_texture(pcontext, res, level, box, data);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static void
+tegra_clear_buffer(struct pipe_context *pcontext,
+ struct pipe_resource *res,
+ unsigned int offset,
+ unsigned int size,
+ const void *value,
+ int value_size)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, res=%p, offset=%u, size=%u, value=%p, value_size=%d)\n",
+ __func__, pcontext, res, offset, size, value,
+ value_size);
+
+ context->gpu->clear_buffer(pcontext, res, offset, size, value,
+ value_size);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static void
tegra_flush(struct pipe_context *pcontext,
struct pipe_fence_handle **fence,
unsigned flags)
@@ -671,16 +1121,34 @@ tegra_sampler_view_destroy(struct pipe_context *pcontext,
debug_printf("< %s()\n", __func__);
}
+static struct pipe_surface *
+tegra_create_surface(struct pipe_context *pcontext,
+ struct pipe_resource *resource,
+ const struct pipe_surface *template)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+ struct pipe_surface *surface;
+
+ debug_printf("> %s(pcontext=%p, resource=%p, template=%p)\n",
+ __func__, pcontext, resource, template);
+
+ surface = context->gpu->create_surface(context->gpu, resource,
+ template);
+
+ debug_printf("< %s() = %p\n", __func__, surface);
+ return surface;
+}
+
static void
-tegra_flush_resource(struct pipe_context *pcontext,
- struct pipe_resource *resource)
+tegra_surface_destroy(struct pipe_context *pcontext,
+ struct pipe_surface *surface)
{
struct tegra_context *context = to_tegra_context(pcontext);
- debug_printf("> %s(pcontext=%p, resource=%p)\n", __func__, pcontext,
- resource);
+ debug_printf("> %s(pcontext=%p, surface=%p)\n", __func__, pcontext,
+ surface);
- context->gpu->flush_resource(context->gpu, resource);
+ context->gpu->surface_destroy(context->gpu, surface);
debug_printf("< %s()\n", __func__);
}
@@ -708,6 +1176,21 @@ tegra_transfer_map(struct pipe_context *pcontext,
}
static void
+tegra_transfer_flush_region(struct pipe_context *pcontext,
+ struct pipe_transfer *transfer,
+ const struct pipe_box *box)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, transfer=%p, box=%p)\n", __func__,
+ pcontext, transfer, box);
+
+ context->gpu->transfer_flush_region(context->gpu, transfer, box);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static void
tegra_transfer_unmap(struct pipe_context *pcontext,
struct pipe_transfer *transfer)
{
@@ -744,14 +1227,285 @@ tegra_transfer_inline_write(struct pipe_context *pcontext,
debug_printf("< %s()\n", __func__);
}
+static void
+tegra_texture_barrier(struct pipe_context *pcontext)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p)\n", __func__, pcontext);
+
+ context->gpu->texture_barrier(context->gpu);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static void
+tegra_memory_barrier(struct pipe_context *pcontext, unsigned int flags)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, flags=%x)\n", __func__, pcontext,
+ flags);
+
+ context->gpu->memory_barrier(context->gpu, flags);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static struct pipe_video_codec *
+tegra_create_video_codec(struct pipe_context *pcontext,
+ const struct pipe_video_codec *template)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+ struct pipe_video_codec *codec;
+
+ debug_printf("> %s(pcontext=%p, template=%p)\n", __func__, pcontext,
+ template);
+
+ codec = context->gpu->create_video_codec(context->gpu, template);
+
+ debug_printf("< %s() = %p\n", __func__, codec);
+ return codec;
+}
+
+static struct pipe_video_buffer *
+tegra_create_video_buffer(struct pipe_context *pcontext,
+ const struct pipe_video_buffer *template)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+ struct pipe_video_buffer *buffer;
+
+ debug_printf("> %s(pcontext=%p, template=%p)\n", __func__, pcontext,
+ template);
+
+ buffer = context->gpu->create_video_buffer(context->gpu, template);
+
+ debug_printf("< %s() = %p\n", __func__, buffer);
+ return buffer;
+}
+
+static void *
+tegra_create_compute_state(struct pipe_context *pcontext,
+ const struct pipe_compute_state *template)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+ void *so;
+
+ debug_printf("> %s(pcontext=%p, template=%p)\n", __func__, pcontext,
+ template);
+
+ so = context->gpu->create_compute_state(context->gpu, template);
+
+ debug_printf("< %s() = %p\n", __func__, so);
+ return so;
+}
+
+static void
+tegra_bind_compute_state(struct pipe_context *pcontext, void *so)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, so=%p)\n", __func__, pcontext, so);
+
+ context->gpu->bind_compute_state(context->gpu, so);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static void
+tegra_delete_compute_state(struct pipe_context *pcontext, void *so)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, so=%p)\n", __func__, pcontext, so);
+
+ context->gpu->delete_compute_state(context->gpu, so);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static void
+tegra_set_compute_resources(struct pipe_context *pcontext,
+ unsigned int start,
+ unsigned int count,
+ struct pipe_surface **resources)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, start=%u, count=%u, resources=%p)\n",
+ __func__, pcontext, start, count, resources);
+
+ context->gpu->set_compute_resources(context->gpu, start, count,
+ resources);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static void
+tegra_set_global_binding(struct pipe_context *pcontext,
+ unsigned int first,
+ unsigned int count,
+ struct pipe_resource **resources,
+ uint32_t **handles)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, first=%u, count=%u, resources=%p, handles=%p)\n",
+ __func__, pcontext, first, count, resources, handles);
+
+ context->gpu->set_global_binding(context->gpu, first, count,
+ resources, handles);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static void
+tegra_launch_grid(struct pipe_context *pcontext,
+ const struct pipe_grid_info *info)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, info=%p)\n", __func__, pcontext, info);
+
+ context->gpu->launch_grid(context->gpu, info);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static void
+tegra_get_sample_position(struct pipe_context *pcontext,
+ unsigned int count,
+ unsigned int index,
+ float *value)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, count=%u, index=%u, value=%p)\n",
+ __func__, pcontext, count, index, value);
+
+ context->gpu->get_sample_position(context->gpu, count, index, value);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static uint64_t
+tegra_get_timestamp(struct pipe_context *pcontext)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+ uint64_t timestamp;
+
+ debug_printf("> %s(pcontext=%p)\n", __func__, pcontext);
+
+ timestamp = context->gpu->get_timestamp(context->gpu);
+
+ debug_printf("< %s() = %" PRIu64 "\n", __func__, timestamp);
+ return timestamp;
+}
+
+static void
+tegra_flush_resource(struct pipe_context *pcontext,
+ struct pipe_resource *resource)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, resource=%p)\n", __func__, pcontext,
+ resource);
+
+ context->gpu->flush_resource(context->gpu, resource);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static void
+tegra_invalidate_resource(struct pipe_context *pcontext,
+ struct pipe_resource *resource)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, resource=%p)\n", __func__, pcontext,
+ resource);
+
+ context->gpu->invalidate_resource(context->gpu, resource);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static enum pipe_reset_status
+tegra_get_device_reset_status(struct pipe_context *pcontext)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+ enum pipe_reset_status status;
+
+ debug_printf("> %s(pcontext=%p)\n", __func__, pcontext);
+
+ status = context->gpu->get_device_reset_status(context->gpu);
+
+ debug_printf("< %s() = %d\n", __func__, status);
+ return status;
+}
+
+static void
+tegra_dump_debug_state(struct pipe_context *pcontext, FILE *stream,
+ unsigned int flags)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, stream=%p, flags=%x)\n", __func__,
+ pcontext, stream, flags);
+
+ context->gpu->dump_debug_state(context->gpu, stream, flags);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static void
+tegra_emit_string_marker(struct pipe_context *pcontext, const char *string,
+ int length)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+
+ debug_printf("> %s(pcontext=%p, string=%p, length=%d)\n", __func__,
+ pcontext, string, length);
+
+ context->gpu->emit_string_marker(context->gpu, string, length);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static boolean
+tegra_generate_mipmap(struct pipe_context *pcontext,
+ struct pipe_resource *resource,
+ enum pipe_format format,
+ unsigned int base_level,
+ unsigned int last_level,
+ unsigned int first_layer,
+ unsigned int last_layer)
+{
+ struct tegra_context *context = to_tegra_context(pcontext);
+ boolean ret;
+
+ debug_printf("> %s(pcontext=%p, resource=%p, format=%d, base_level=%u, last_level=%u, first_layer=%u, last_layer=%u)\n",
+ __func__, pcontext, resource, format, base_level,
+ last_level, first_layer, last_layer);
+
+ ret = context->gpu->generate_mipmap(context->gpu, resource, format,
+ base_level, last_level,
+ first_layer, last_layer);
+
+ debug_printf("< %s() = %d\n", __func__, ret);
+ return ret;
+}
+
struct pipe_context *
-tegra_context_create(struct pipe_screen *pscreen, void *priv)
+tegra_screen_context_create(struct pipe_screen *pscreen, void *priv,
+ unsigned int flags)
{
struct tegra_screen *screen = to_tegra_screen(pscreen);
struct pipe_context *pcontext = NULL;
struct tegra_context *context;
- debug_printf("> %s(pscreen=%p, priv=%p)\n", __func__, pscreen, priv);
+ debug_printf("> %s(pscreen=%p, priv=%p, flags=%x)\n", __func__,
+ pscreen, priv, flags);
context = calloc(1, sizeof(*context));
if (!context)
@@ -759,7 +1513,7 @@ tegra_context_create(struct pipe_screen *pscreen, void *priv)
context->screen = screen;
- context->gpu = screen->gpu->context_create(screen->gpu, priv);
+ context->gpu = screen->gpu->context_create(screen->gpu, priv, flags);
if (!context->gpu) {
debug_printf("failed to create GPU context\n");
free(context);
@@ -774,6 +1528,17 @@ tegra_context_create(struct pipe_screen *pscreen, void *priv)
pcontext->draw_vbo = tegra_draw_vbo;
+ pcontext->render_condition = tegra_render_condition;
+
+ pcontext->create_query = tegra_create_query;
+ pcontext->create_batch_query = tegra_create_batch_query;
+ pcontext->destroy_query = tegra_destroy_query;
+ pcontext->begin_query = tegra_begin_query;
+ pcontext->end_query = tegra_end_query;
+ pcontext->get_query_result = tegra_get_query_result;
+ pcontext->get_query_result_resource = tegra_get_query_result_resource;
+ pcontext->set_active_query_state = tegra_set_active_query_state;
+
pcontext->create_blend_state = tegra_create_blend_state;
pcontext->bind_blend_state = tegra_bind_blend_state;
pcontext->delete_blend_state = tegra_delete_blend_state;
@@ -802,18 +1567,37 @@ tegra_context_create(struct pipe_screen *pscreen, void *priv)
pcontext->bind_gs_state = tegra_bind_gs_state;
pcontext->delete_gs_state = tegra_delete_gs_state;
+ pcontext->create_tcs_state = tegra_create_tcs_state;
+ pcontext->bind_tcs_state = tegra_bind_tcs_state;
+ pcontext->delete_tcs_state = tegra_delete_tcs_state;
+
+ pcontext->create_tes_state = tegra_create_tes_state;
+ pcontext->bind_tes_state = tegra_bind_tes_state;
+ pcontext->delete_tes_state = tegra_delete_tes_state;
+
pcontext->create_vertex_elements_state = tegra_create_vertex_elements_state;
pcontext->bind_vertex_elements_state = tegra_bind_vertex_elements_state;
pcontext->delete_vertex_elements_state = tegra_delete_vertex_elements_state;
+ pcontext->set_blend_color = tegra_set_blend_color;
+ pcontext->set_stencil_ref = tegra_set_stencil_ref;
+ pcontext->set_sample_mask = tegra_set_sample_mask;
+ pcontext->set_min_samples = tegra_set_min_samples;
+ pcontext->set_clip_state = tegra_set_clip_state;
+
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_scissor_states = tegra_set_scissor_states;
+ pcontext->set_window_rectangles = tegra_set_window_rectangles;
pcontext->set_viewport_states = tegra_set_viewport_states;
pcontext->set_sampler_views = tegra_set_sampler_views;
+ pcontext->set_tess_state = tegra_set_tess_state;
- pcontext->set_shader_resources = tegra_set_shader_resources;
+ pcontext->set_debug_callback = tegra_set_debug_callback;
+
+ pcontext->set_shader_buffers = tegra_set_shader_buffers;
+ pcontext->set_shader_images = tegra_set_shader_images;
pcontext->set_vertex_buffers = tegra_set_vertex_buffers;
pcontext->set_index_buffer = tegra_set_index_buffer;
@@ -821,22 +1605,50 @@ tegra_context_create(struct pipe_screen *pscreen, void *priv)
pcontext->stream_output_target_destroy = tegra_stream_output_target_destroy;
pcontext->set_stream_output_targets = tegra_set_stream_output_targets;
+ pcontext->resource_copy_region = tegra_resource_copy_region;
pcontext->blit = tegra_blit;
pcontext->clear = tegra_clear;
+ pcontext->clear_render_target = tegra_clear_render_target;
+ pcontext->clear_depth_stencil = tegra_clear_depth_stencil;
+ pcontext->clear_texture = tegra_clear_texture;
+ pcontext->clear_buffer = tegra_clear_buffer;
pcontext->flush = tegra_flush;
pcontext->create_sampler_view = tegra_create_sampler_view;
pcontext->sampler_view_destroy = tegra_sampler_view_destroy;
- pcontext->flush_resource = tegra_flush_resource;
-
pcontext->create_surface = tegra_create_surface;
pcontext->surface_destroy = tegra_surface_destroy;
pcontext->transfer_map = tegra_transfer_map;
+ pcontext->transfer_flush_region = tegra_transfer_flush_region;
pcontext->transfer_unmap = tegra_transfer_unmap;
pcontext->transfer_inline_write = tegra_transfer_inline_write;
+ pcontext->texture_barrier = tegra_texture_barrier;
+ pcontext->memory_barrier = tegra_memory_barrier;
+
+ pcontext->create_video_codec = tegra_create_video_codec;
+ pcontext->create_video_buffer = tegra_create_video_buffer;
+
+ pcontext->create_compute_state = tegra_create_compute_state;
+ pcontext->bind_compute_state = tegra_bind_compute_state;
+ pcontext->delete_compute_state = tegra_delete_compute_state;
+ pcontext->set_compute_resources = tegra_set_compute_resources;
+ pcontext->set_global_binding = tegra_set_global_binding;
+ pcontext->launch_grid = tegra_launch_grid;
+ pcontext->get_sample_position = tegra_get_sample_position;
+ pcontext->get_timestamp = tegra_get_timestamp;
+
+ pcontext->flush_resource = tegra_flush_resource;
+ pcontext->invalidate_resource = tegra_invalidate_resource;
+
+ pcontext->get_device_reset_status = tegra_get_device_reset_status;
+ pcontext->dump_debug_state = tegra_dump_debug_state;
+ pcontext->emit_string_marker = tegra_emit_string_marker;
+
+ pcontext->generate_mipmap = tegra_generate_mipmap;
+
out:
debug_printf("< %s() = %p\n", __func__, pcontext);
return pcontext;
diff --git a/src/gallium/drivers/tegra/tegra_context.h b/src/gallium/drivers/tegra/tegra_context.h
index 117e83d170d0..89ef8a4044d7 100644
--- a/src/gallium/drivers/tegra/tegra_context.h
+++ b/src/gallium/drivers/tegra/tegra_context.h
@@ -41,7 +41,8 @@ to_tegra_context(struct pipe_context *context)
return (struct tegra_context *)context;
}
-struct pipe_context *tegra_context_create(struct pipe_screen *pscreen,
- void *priv);
+struct pipe_context *
+tegra_screen_context_create(struct pipe_screen *pscreen, void *priv,
+ unsigned int flags);
#endif /* TEGRA_SCREEN_H */
diff --git a/src/gallium/drivers/tegra/tegra_resource.c b/src/gallium/drivers/tegra/tegra_resource.c
deleted file mode 100644
index 6eb1428870f8..000000000000
--- a/src/gallium/drivers/tegra/tegra_resource.c
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Copyright © 2014 NVIDIA 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 <stdlib.h>
-#include <stdint.h>
-
-#include <tegra_drm.h>
-#include <xf86drm.h>
-
-#include "pipe/p_state.h"
-#include "util/u_debug.h"
-
-#include "state_tracker/drm_driver.h"
-
-#include "tegra/tegra_context.h"
-#include "tegra/tegra_resource.h"
-#include "tegra/tegra_screen.h"
-
-struct pipe_resource *
-tegra_resource_create(struct pipe_screen *pscreen,
- const struct pipe_resource *template)
-{
- struct tegra_screen *screen = to_tegra_screen(pscreen);
- struct pipe_resource *resource;
-
- debug_printf("> %s(pscreen=%p, template=%p)\n", __func__, pscreen,
- template);
-
- resource = screen->gpu->resource_create(screen->gpu, template);
-
- resource->screen = pscreen;
-
- debug_printf("< %s() = %p\n", __func__, resource);
- return resource;
-}
-
-boolean
-tegra_resource_get_handle(struct pipe_screen *pscreen,
- struct pipe_resource *resource,
- struct winsys_handle *handle)
-{
- struct tegra_screen *screen = to_tegra_screen(pscreen);
- uint32_t import;
- boolean ret;
- int fd, err;
-
- debug_printf("> %s(pscreen=%p, resource=%p, handle=%p)\n", __func__,
- pscreen, resource, handle);
-
- debug_printf(" resource: %p\n", resource);
- debug_printf(" usage: %x\n", resource->usage);
- debug_printf(" bind: %x\n", resource->bind);
- debug_printf(" flags: %x\n", resource->flags);
-
- debug_printf(" handle: %p\n", handle);
- debug_printf(" type: %u\n", handle->type);
- debug_printf(" handle: %x\n", handle->handle);
- debug_printf(" stride: %u\n", handle->stride);
-
- ret = screen->gpu->resource_get_handle(screen->gpu, resource, handle);
-
- if (handle->type == DRM_API_HANDLE_TYPE_KMS) {
- err = drmPrimeHandleToFD(screen->gpu_fd, handle->handle, 0,
- &fd);
- if (err < 0)
- debug_printf("drmPrimeHandleToFD() failed: %m\n");
- }
-
- if (handle->type == DRM_API_HANDLE_TYPE_FD)
- fd = handle->handle;
-
- err = drmPrimeFDToHandle(screen->fd, fd, &import);
- if (err < 0) {
- debug_printf("drmPrimeFDToHandle() failed: %m\n");
- }
-
- if (1) {
- struct drm_tegra_gem_set_tiling args;
-
- memset(&args, 0, sizeof(args));
- args.handle = import;
- args.mode = DRM_TEGRA_GEM_TILING_MODE_BLOCK;
- args.value = 4;
-
- err = drmIoctl(screen->fd, DRM_IOCTL_TEGRA_GEM_SET_TILING,
- &args);
- if (err < 0)
- debug_printf("failed to set tiling parameters: %m\n");
- }
-
- if (0) {
- struct drm_tegra_gem_set_flags args;
-
- memset(&args, 0, sizeof(args));
- args.handle = import;
- args.flags = DRM_TEGRA_GEM_BOTTOM_UP;
-
- err = drmIoctl(screen->fd, DRM_IOCTL_TEGRA_GEM_SET_FLAGS,
- &args);
- if (err < 0)
- debug_printf("failed to set flags: %m\n");
- }
-
- debug_printf(" handle: %p\n", handle);
- debug_printf(" type: %u\n", handle->type);
- debug_printf(" handle: %x\n", handle->handle);
- debug_printf(" imported: %x\n", import);
- debug_printf(" stride: %u\n", handle->stride);
-
- /* find a way to track the imported buffer object */
- handle->handle = import;
-
- debug_printf("< %s() = %d\n", __func__, ret);
- return ret;
-}
-
-void
-tegra_resource_destroy(struct pipe_screen *pscreen,
- struct pipe_resource *resource)
-{
- struct tegra_screen *screen = to_tegra_screen(pscreen);
-
- debug_printf("> %s(pscreen=%p, resource=%p)\n", __func__, pscreen,
- resource);
-
- screen->gpu->resource_destroy(screen->gpu, resource);
-
- debug_printf("< %s()\n", __func__);
-}
-
-struct pipe_surface *
-tegra_create_surface(struct pipe_context *pcontext,
- struct pipe_resource *resource,
- const struct pipe_surface *template)
-{
- struct tegra_context *context = to_tegra_context(pcontext);
- struct pipe_surface *surface;
-
- debug_printf("> %s(pcontext=%p, resource=%p, template=%p)\n",
- __func__, pcontext, resource, template);
-
- surface = context->gpu->create_surface(context->gpu, resource,
- template);
-
- debug_printf("< %s() = %p\n", __func__, surface);
- return surface;
-}
-
-void
-tegra_surface_destroy(struct pipe_context *pcontext,
- struct pipe_surface *surface)
-{
- struct tegra_context *context = to_tegra_context(pcontext);
-
- debug_printf("> %s(pcontext=%p, surface=%p)\n", __func__, pcontext,
- surface);
-
- context->gpu->surface_destroy(context->gpu, surface);
-
- debug_printf("< %s()\n", __func__);
-}
diff --git a/src/gallium/drivers/tegra/tegra_resource.h b/src/gallium/drivers/tegra/tegra_resource.h
deleted file mode 100644
index 11ef27e24664..000000000000
--- a/src/gallium/drivers/tegra/tegra_resource.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright © 2014 NVIDIA 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.
- */
-
-#ifndef TEGRA_RESOURCE_H
-#define TEGRA_RESOURCE_H
-
-struct pipe_resource;
-struct winsys_handle;
-
-struct tegra_resource {
- struct pipe_resource *gpu;
-};
-
-struct pipe_resource *
-tegra_resource_create(struct pipe_screen *pscreen,
- const struct pipe_resource *template);
-boolean
-tegra_resource_get_handle(struct pipe_screen *pscreen,
- struct pipe_resource *resource,
- struct winsys_handle *handle);
-void
-tegra_resource_destroy(struct pipe_screen *pscreen,
- struct pipe_resource *resource);
-struct pipe_surface *
-tegra_create_surface(struct pipe_context *pcontext,
- struct pipe_resource *presource,
- const struct pipe_surface *template);
-void
-tegra_surface_destroy(struct pipe_context *pcontext,
- struct pipe_surface *psurface);
-
-#endif /* TEGRA_RESOURCE_H */
diff --git a/src/gallium/drivers/tegra/tegra_screen.c b/src/gallium/drivers/tegra/tegra_screen.c
index 0fe7067f1246..6bc76eeb13ae 100644
--- a/src/gallium/drivers/tegra/tegra_screen.c
+++ b/src/gallium/drivers/tegra/tegra_screen.c
@@ -22,38 +22,53 @@
*/
#include <fcntl.h>
+#include <inttypes.h>
+#include <tegra_drm.h>
+#include <xf86drm.h>
+
+#include "pipe/p_state.h"
#include "util/u_debug.h"
+#include "state_tracker/drm_driver.h"
+
#include "tegra/tegra_context.h"
-#include "tegra/tegra_resource.h"
#include "tegra/tegra_screen.h"
/* TODO: obtain from include file */
struct pipe_screen *nouveau_drm_screen_create(int fd);
-static const char *
-tegra_get_name(struct pipe_screen *pscreen)
+static void tegra_screen_destroy(struct pipe_screen *pscreen)
{
- return "tegra";
+ struct tegra_screen *screen = to_tegra_screen(pscreen);
+
+ debug_printf("> %s(pscreen=%p)\n", __func__, pscreen);
+
+ screen->gpu->destroy(screen->gpu);
+ free(pscreen);
+
+ debug_printf("< %s()\n", __func__);
}
static const char *
-tegra_get_vendor(struct pipe_screen *pscreen)
+tegra_screen_get_name(struct pipe_screen *pscreen)
{
return "tegra";
}
-static void tegra_screen_destroy(struct pipe_screen *pscreen)
+static const char *
+tegra_screen_get_vendor(struct pipe_screen *pscreen)
{
- struct tegra_screen *screen = to_tegra_screen(pscreen);
+ return "NVIDIA";
+}
+static const char *
+tegra_screen_get_device_vendor(struct pipe_screen *pscreen)
+{
debug_printf("> %s(pscreen=%p)\n", __func__, pscreen);
-
- screen->gpu->destroy(screen->gpu);
- free(pscreen);
-
debug_printf("< %s()\n", __func__);
+
+ return "NVIDIA";
}
static int
@@ -103,6 +118,58 @@ tegra_screen_get_shader_param(struct pipe_screen *pscreen,
return ret;
}
+static int
+tegra_screen_get_video_param(struct pipe_screen *pscreen,
+ enum pipe_video_profile profile,
+ enum pipe_video_entrypoint entrypoint,
+ enum pipe_video_cap param)
+{
+ struct tegra_screen *screen = to_tegra_screen(pscreen);
+ int ret;
+
+ debug_printf("> %s(pscreen=%p, profile=%d, entrypoint=%d, param=%d)\n",
+ __func__, pscreen, profile, entrypoint, param);
+
+ ret = screen->gpu->get_video_param(screen->gpu, profile, entrypoint,
+ param);
+
+ debug_printf("< %s() = %d\n", __func__, ret);
+ return ret;
+}
+
+static int
+tegra_screen_get_compute_param(struct pipe_screen *pscreen,
+ enum pipe_shader_ir ir_type,
+ enum pipe_compute_cap param,
+ void *retp)
+{
+ struct tegra_screen *screen = to_tegra_screen(pscreen);
+ int ret;
+
+ debug_printf("> %s(pscreen=%p, ir_type=%d, param=%d, retp=%p)\n",
+ __func__, pscreen, ir_type, param, retp);
+
+ ret = screen->gpu->get_compute_param(screen->gpu, ir_type, param,
+ retp);
+
+ debug_printf("< %s() = %d\n", __func__, ret);
+ return ret;
+}
+
+static uint64_t
+tegra_screen_get_timestamp(struct pipe_screen *pscreen)
+{
+ struct tegra_screen *screen = to_tegra_screen(pscreen);
+ uint64_t ret;
+
+ debug_printf("> %s(pscreen=%p)\n", __func__, pscreen);
+
+ ret = screen->gpu->get_timestamp(screen->gpu);
+
+ debug_printf("< %s() = %" PRIu64 "\n", __func__, ret);
+ return ret;
+}
+
static boolean
tegra_screen_is_format_supported(struct pipe_screen *pscreen,
enum pipe_format format,
@@ -123,6 +190,334 @@ tegra_screen_is_format_supported(struct pipe_screen *pscreen,
return ret;
}
+static boolean
+tegra_screen_is_video_format_supported(struct pipe_screen *pscreen,
+ enum pipe_format format,
+ enum pipe_video_profile profile,
+ enum pipe_video_entrypoint entrypoint)
+{
+ struct tegra_screen *screen = to_tegra_screen(pscreen);
+ boolean ret;
+
+ debug_printf("> %s(pscreen=%p, format=%d, profile=%d, entrypoint=%d)\n",
+ __func__, pscreen, format, profile, entrypoint);
+
+ ret = screen->gpu->is_video_format_supported(screen->gpu, format,
+ profile, entrypoint);
+
+ debug_printf("< %s() = %d\n", __func__, ret);
+ return ret;
+}
+
+static boolean
+tegra_screen_can_create_resource(struct pipe_screen *pscreen,
+ const struct pipe_resource *template)
+{
+ struct tegra_screen *screen = to_tegra_screen(pscreen);
+ boolean ret;
+
+ debug_printf("> %s(pscreen=%p, template=%p)\n", __func__, pscreen,
+ template);
+
+ ret = screen->gpu->can_create_resource(screen->gpu, template);
+
+ debug_printf("< %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_screen *screen = to_tegra_screen(pscreen);
+ struct pipe_resource *resource;
+
+ debug_printf("> %s(pscreen=%p, template=%p)\n", __func__, pscreen,
+ template);
+
+ resource = screen->gpu->resource_create(screen->gpu, template);
+ if (resource)
+ resource->screen = pscreen;
+
+ debug_printf("< %s() = %p\n", __func__, resource);
+ return resource;
+}
+
+static struct pipe_resource *
+tegra_screen_resource_create_front(struct pipe_screen *pscreen,
+ const struct pipe_resource *template,
+ const void *map_front_private)
+{
+ struct tegra_screen *screen = to_tegra_screen(pscreen);
+ struct pipe_resource *resource;
+
+ debug_printf("> %s(pscreen=%p, template=%p, map_front_private=%p)\n",
+ __func__, pscreen, template, map_front_private);
+
+ resource = screen->gpu->resource_create_front(screen->gpu, template,
+ map_front_private);
+ if (resource)
+ resource->screen = pscreen;
+
+ debug_printf("< %s() = %p\n", __func__, resource);
+ return resource;
+}
+
+static struct pipe_resource *
+tegra_screen_resource_from_handle(struct pipe_screen *pscreen,
+ const struct pipe_resource *template,
+ struct winsys_handle *handle,
+ unsigned int usage)
+{
+ struct tegra_screen *screen = to_tegra_screen(pscreen);
+ struct pipe_resource *resource;
+
+ debug_printf("> %s(pscreen=%p, template=%p, handle=%p, usage=%x)\n",
+ __func__, pscreen, template, handle, usage);
+
+ resource = screen->gpu->resource_from_handle(screen->gpu, template,
+ handle, usage);
+ if (resource)
+ resource->screen = pscreen;
+
+ debug_printf("< %s() = %p\n", __func__, resource);
+ return resource;
+}
+
+static struct pipe_resource *
+tegra_screen_resource_from_user_memory(struct pipe_screen *pscreen,
+ const struct pipe_resource *template,
+ void *buffer)
+{
+ struct tegra_screen *screen = to_tegra_screen(pscreen);
+ struct pipe_resource *resource;
+
+ debug_printf("> %s(pscreen=%p, template=%p, buffer=%p)\n", __func__,
+ pscreen, template, buffer);
+
+ resource = screen->gpu->resource_from_user_memory(screen->gpu,
+ template,
+ buffer);
+ if (resource)
+ resource->screen = pscreen;
+
+ debug_printf("< %s() = %p\n", __func__, resource);
+ return resource;
+}
+
+static boolean
+tegra_screen_resource_get_handle(struct pipe_screen *pscreen,
+ struct pipe_resource *resource,
+ struct winsys_handle *handle,
+ unsigned int usage)
+{
+ struct tegra_screen *screen = to_tegra_screen(pscreen);
+ uint32_t import;
+ boolean ret;
+ int fd, err;
+
+ debug_printf("> %s(pscreen=%p, resource=%p, handle=%p, usage=%u)\n",
+ __func__, pscreen, resource, handle, usage);
+
+ debug_printf(" resource: %p\n", resource);
+ debug_printf(" usage: %x\n", resource->usage);
+ debug_printf(" bind: %x\n", resource->bind);
+ debug_printf(" flags: %x\n", resource->flags);
+
+ debug_printf(" handle: %p\n", handle);
+ debug_printf(" type: %u\n", handle->type);
+ debug_printf(" handle: %x\n", handle->handle);
+ debug_printf(" stride: %u\n", handle->stride);
+
+ ret = screen->gpu->resource_get_handle(screen->gpu, resource, handle,
+ usage);
+
+ if (handle->type == DRM_API_HANDLE_TYPE_KMS) {
+ err = drmPrimeHandleToFD(screen->gpu_fd, handle->handle, 0,
+ &fd);
+ if (err < 0)
+ debug_printf("drmPrimeHandleToFD() failed: %m\n");
+ }
+
+ if (handle->type == DRM_API_HANDLE_TYPE_FD)
+ fd = handle->handle;
+
+ err = drmPrimeFDToHandle(screen->fd, fd, &import);
+ if (err < 0) {
+ debug_printf("drmPrimeFDToHandle() failed: %m\n");
+ }
+
+ if (1) {
+ struct drm_tegra_gem_set_tiling args;
+
+ memset(&args, 0, sizeof(args));
+ args.handle = import;
+ args.mode = DRM_TEGRA_GEM_TILING_MODE_BLOCK;
+ args.value = 4;
+
+ err = drmIoctl(screen->fd, DRM_IOCTL_TEGRA_GEM_SET_TILING,
+ &args);
+ if (err < 0)
+ debug_printf("failed to set tiling parameters: %m\n");
+ }
+
+ if (0) {
+ struct drm_tegra_gem_set_flags args;
+
+ memset(&args, 0, sizeof(args));
+ args.handle = import;
+ args.flags = DRM_TEGRA_GEM_BOTTOM_UP;
+
+ err = drmIoctl(screen->fd, DRM_IOCTL_TEGRA_GEM_SET_FLAGS,
+ &args);
+ if (err < 0)
+ debug_printf("failed to set flags: %m\n");
+ }
+
+ debug_printf(" handle: %p\n", handle);
+ debug_printf(" type: %u\n", handle->type);
+ debug_printf(" handle: %x\n", handle->handle);
+ debug_printf(" imported: %x\n", import);
+ debug_printf(" stride: %u\n", handle->stride);
+
+ /* find a way to track the imported buffer object */
+ handle->handle = import;
+
+ debug_printf("< %s() = %d\n", __func__, ret);
+ return ret;
+}
+
+static void
+tegra_screen_resource_destroy(struct pipe_screen *pscreen,
+ struct pipe_resource *resource)
+{
+ struct tegra_screen *screen = to_tegra_screen(pscreen);
+
+ debug_printf("> %s(pscreen=%p, resource=%p)\n", __func__, pscreen,
+ resource);
+
+ screen->gpu->resource_destroy(screen->gpu, resource);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static void
+tegra_screen_flush_frontbuffer(struct pipe_screen *pscreen,
+ struct pipe_resource *resource,
+ unsigned int level,
+ unsigned int layer,
+ void *winsys_drawable_handle,
+ struct pipe_box *box)
+{
+ struct tegra_screen *screen = to_tegra_screen(pscreen);
+
+ debug_printf("> %s(pscreen=%p, resource=%p, level=%u, layer=%u, winsys_drawable_handle=%p, box=%p)\n",
+ __func__, pscreen, resource, level, layer,
+ winsys_drawable_handle, box);
+
+ screen->gpu->flush_frontbuffer(screen->gpu, resource, level, layer,
+ winsys_drawable_handle, box);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static void
+tegra_screen_fence_reference(struct pipe_screen *pscreen,
+ struct pipe_fence_handle **ptr,
+ struct pipe_fence_handle *fence)
+{
+ struct tegra_screen *screen = to_tegra_screen(pscreen);
+
+ debug_printf("> %s(pscreen=%p, ptr=%p, fence=%p)\n", __func__,
+ pscreen, ptr, fence);
+
+ screen->gpu->fence_reference(screen->gpu, ptr, fence);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static boolean
+tegra_screen_fence_finish(struct pipe_screen *pscreen,
+ struct pipe_fence_handle *fence,
+ uint64_t timeout)
+{
+ struct tegra_screen *screen = to_tegra_screen(pscreen);
+ boolean ret;
+
+ debug_printf("> %s(pscreen=%p, fence=%p, timeout=%" PRIu64 ")\n",
+ __func__, pscreen, fence, timeout);
+
+ ret = screen->gpu->fence_finish(screen->gpu, fence, timeout);
+
+ debug_printf("< %s() = %d\n", __func__, ret);
+ return ret;
+}
+
+static int
+tegra_screen_get_driver_query_info(struct pipe_screen *pscreen,
+ unsigned int index,
+ struct pipe_driver_query_info *info)
+{
+ struct tegra_screen *screen = to_tegra_screen(pscreen);
+ int ret;
+
+ debug_printf("> %s(pscreen=%p, index=%u, info=%p)\n", __func__,
+ pscreen, index, info);
+
+ ret = screen->gpu->get_driver_query_info(screen->gpu, index, info);
+
+ debug_printf("< %s() = %d\n", __func__, ret);
+ return ret;
+}
+
+static int
+tegra_screen_get_driver_query_group_info(struct pipe_screen *pscreen,
+ unsigned int index,
+ struct pipe_driver_query_group_info *info)
+{
+ struct tegra_screen *screen = to_tegra_screen(pscreen);
+ int ret;
+
+ debug_printf("> %s(pscreen=%p, index=%u, info=%p)\n", __func__,
+ pscreen, index, info);
+
+ ret = screen->gpu->get_driver_query_group_info(screen->gpu, index,
+ info);
+
+ debug_printf("< %s() = %d\n", __func__, ret);
+ return ret;
+}
+
+static void
+tegra_screen_query_memory_info(struct pipe_screen *pscreen,
+ struct pipe_memory_info *info)
+{
+ struct tegra_screen *screen = to_tegra_screen(pscreen);
+
+ debug_printf("> %s(pscreen=%p, info=%p)\n", __func__, pscreen, info);
+
+ screen->gpu->query_memory_info(screen->gpu, info);
+
+ debug_printf("< %s()\n", __func__);
+}
+
+static const void *
+tegra_screen_get_compiler_options(struct pipe_screen *pscreen,
+ enum pipe_shader_ir ir,
+ unsigned int shader)
+{
+ struct tegra_screen *screen = to_tegra_screen(pscreen);
+ const void *options;
+
+ debug_printf("> %s(pscreen=%p, ir=%d, shader=%u)\n", __func__,
+ pscreen, ir, shader);
+
+ options = screen->gpu->get_compiler_options(screen->gpu, ir, shader);
+
+ debug_printf("< %s() = %p\n", __func__, options);
+ return options;
+}
+
struct pipe_screen *
tegra_screen_create(int fd)
{
@@ -157,17 +552,36 @@ tegra_screen_create(int fd)
debug_printf(" fd: %d\n", screen->gpu_fd);
pscreen = &screen->base;
- pscreen->get_name = tegra_get_name;
- pscreen->get_vendor = tegra_get_vendor;
pscreen->destroy = tegra_screen_destroy;
+ pscreen->get_name = tegra_screen_get_name;
+ pscreen->get_vendor = tegra_screen_get_vendor;
+ pscreen->get_device_vendor = tegra_screen_get_device_vendor;
pscreen->get_param = tegra_screen_get_param;
pscreen->get_paramf = tegra_screen_get_paramf;
pscreen->get_shader_param = tegra_screen_get_shader_param;
- pscreen->context_create = tegra_context_create;
+ pscreen->get_video_param = tegra_screen_get_video_param;
+ pscreen->get_compute_param = tegra_screen_get_compute_param;
+ pscreen->get_timestamp = tegra_screen_get_timestamp;
+ pscreen->context_create = tegra_screen_context_create;
pscreen->is_format_supported = tegra_screen_is_format_supported;
- pscreen->resource_create = tegra_resource_create;
- pscreen->resource_get_handle = tegra_resource_get_handle;
- pscreen->resource_destroy = tegra_resource_destroy;
+ pscreen->is_video_format_supported = tegra_screen_is_video_format_supported;
+ pscreen->can_create_resource = tegra_screen_can_create_resource;
+ pscreen->resource_create = tegra_screen_resource_create;
+ pscreen->resource_create_front = tegra_screen_resource_create_front;
+ pscreen->resource_from_handle = tegra_screen_resource_from_handle;
+ pscreen->resource_from_user_memory = tegra_screen_resource_from_user_memory;
+ pscreen->resource_get_handle = tegra_screen_resource_get_handle;
+ pscreen->resource_destroy = tegra_screen_resource_destroy;
+
+ pscreen->flush_frontbuffer = tegra_screen_flush_frontbuffer;
+ pscreen->fence_reference = tegra_screen_fence_reference;
+ pscreen->fence_finish = tegra_screen_fence_finish;
+
+ pscreen->get_driver_query_info = tegra_screen_get_driver_query_info;
+ pscreen->get_driver_query_group_info = tegra_screen_get_driver_query_group_info;
+ pscreen->query_memory_info = tegra_screen_query_memory_info;
+
+ pscreen->get_compiler_options = tegra_screen_get_compiler_options;
out:
debug_printf("< %s() = %p\n", __func__, pscreen);