[Mesa-dev] [PATCH 7/9] gallium/u_tests: test a NULL texture sampler view

Marek Olšák maraeo at gmail.com
Sun Feb 1 09:15:59 PST 2015


From: Marek Olšák <marek.olsak at amd.com>

It shouldn't crash the GPU and it should return (0, 0, 0, 1).

This is r300 behavior, so I assume it's also DX9 behavior.
Radeonsi can support this easily.
---
 src/gallium/auxiliary/util/u_tests.c | 39 ++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/src/gallium/auxiliary/util/u_tests.c b/src/gallium/auxiliary/util/u_tests.c
index 89ae840..9c8514c 100644
--- a/src/gallium/auxiliary/util/u_tests.c
+++ b/src/gallium/auxiliary/util/u_tests.c
@@ -304,6 +304,44 @@ tgsi_vs_window_space_position(struct pipe_context *ctx)
    util_report_result(pass);
 }
 
+static void
+null_sampler_view(struct pipe_context *ctx)
+{
+   struct cso_context *cso;
+   struct pipe_resource *cb;
+   void *fs, *vs;
+   bool pass = true;
+   static const float expected[] = {0, 0, 0, 1};
+
+   cso = cso_create_context(ctx);
+   cb = util_create_texture2d(ctx->screen, 256, 256,
+                              PIPE_FORMAT_R8G8B8A8_UNORM);
+   util_set_common_states_and_clear(cso, ctx, cb);
+
+   ctx->set_sampler_views(ctx, PIPE_SHADER_FRAGMENT, 0, 1, NULL);
+
+   /* Fragment shader. */
+   fs = util_make_fragment_tex_shader(ctx, TGSI_TEXTURE_2D,
+                                      TGSI_INTERPOLATE_LINEAR);
+   cso_set_fragment_shader_handle(cso, fs);
+
+   /* Vertex shader. */
+   vs = util_set_passthrough_vertex_shader(cso, ctx, false);
+   util_draw_fullscreen_quad(cso);
+
+   /* Probe pixels. */
+   pass = pass && util_probe_rect_rgba(ctx, cb, 0, 0,
+                                       cb->width0, cb->height0, expected);
+
+   /* Cleanup. */
+   cso_destroy_context(cso);
+   ctx->delete_vs_state(ctx, vs);
+   ctx->delete_fs_state(ctx, fs);
+   pipe_resource_reference(&cb, NULL);
+
+   util_report_result(pass);
+}
+
 /**
  * Run all tests. This should be run with a clean context after
  * context_create.
@@ -314,6 +352,7 @@ util_run_tests(struct pipe_screen *screen)
    struct pipe_context *ctx = screen->context_create(screen, NULL);
 
    tgsi_vs_window_space_position(ctx);
+   null_sampler_view(ctx);
 
    ctx->destroy(ctx);
 
-- 
2.1.0



More information about the mesa-dev mailing list